Erwan
-Issue 26: added an option for Mana Display. This needs a bit testing, but it should also lower the priority of "manapool slowness" as this mode probably fixes performance issue as well. -I can't seem to be able to "save" some options (hand position, mana display) ion the windows version, does this change break something ?
This commit is contained in:
@@ -32,6 +32,7 @@ public:
|
|||||||
OSD,
|
OSD,
|
||||||
CLOSEDHAND,
|
CLOSEDHAND,
|
||||||
HANDDIRECTION,
|
HANDDIRECTION,
|
||||||
|
MANADISPLAY,
|
||||||
REVERSETRIGGERS,
|
REVERSETRIGGERS,
|
||||||
DISABLECARDS,
|
DISABLECARDS,
|
||||||
INTERRUPT_SECONDS,
|
INTERRUPT_SECONDS,
|
||||||
|
|||||||
@@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
class ManaIcon : public Pos
|
class ManaIcon : public Pos
|
||||||
{
|
{
|
||||||
static const float DESTX;
|
|
||||||
static const float DESTY;
|
|
||||||
|
|
||||||
hgeParticleSystem* particleSys;
|
hgeParticleSystem* particleSys;
|
||||||
JQuad* icon;
|
JQuad* icon;
|
||||||
|
|
||||||
@@ -20,6 +17,7 @@ class ManaIcon : public Pos
|
|||||||
float yP1, yP2, yP3;
|
float yP1, yP2, yP3;
|
||||||
float tP1;
|
float tP1;
|
||||||
float f;
|
float f;
|
||||||
|
float destx,desty;
|
||||||
public:
|
public:
|
||||||
enum { ALIVE, WITHERING, DROPPING, DEAD } mode;
|
enum { ALIVE, WITHERING, DROPPING, DEAD } mode;
|
||||||
int color;
|
int color;
|
||||||
@@ -27,7 +25,7 @@ class ManaIcon : public Pos
|
|||||||
void Update(float dt, float shift);
|
void Update(float dt, float shift);
|
||||||
void Wither();
|
void Wither();
|
||||||
void Drop();
|
void Drop();
|
||||||
ManaIcon(int color, float x, float y);
|
ManaIcon(int color, float x, float y,float destx, float desty);
|
||||||
~ManaIcon();
|
~ManaIcon();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,8 +33,11 @@ class GuiMana : public GuiLayer
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
vector<ManaIcon*> manas;
|
vector<ManaIcon*> manas;
|
||||||
|
float x, y;
|
||||||
|
Player * owner;
|
||||||
|
void RenderStatic();
|
||||||
public:
|
public:
|
||||||
GuiMana();
|
GuiMana(float x, float y, Player *p);
|
||||||
~GuiMana();
|
~GuiMana();
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
|
|||||||
@@ -249,4 +249,17 @@ private:
|
|||||||
static EnumDefinition * definition;
|
static EnumDefinition * definition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OptionManaDisplay : public OptionEnum {
|
||||||
|
public:
|
||||||
|
friend class GameSettings;
|
||||||
|
enum { DYNAMIC = 0, STATIC = 1, BOTH = 2};
|
||||||
|
OptionManaDisplay(int id, string displayValue);
|
||||||
|
|
||||||
|
static EnumDefinition * getDefinition();
|
||||||
|
EnumDefinition * ourDefined() const { return getDefinition();};
|
||||||
|
|
||||||
|
private:
|
||||||
|
static EnumDefinition * definition;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ void DuelLayers::init(){
|
|||||||
//Other display elements
|
//Other display elements
|
||||||
action->Add(NEW HUDDisplay(-1));
|
action->Add(NEW HUDDisplay(-1));
|
||||||
|
|
||||||
Add(NEW GuiMana());
|
Add(NEW GuiMana(20,20,go->players[1]));
|
||||||
|
Add(NEW GuiMana(440,20,go->players[0]));
|
||||||
Add(stack = NEW ActionStack(go));
|
Add(stack = NEW ActionStack(go));
|
||||||
Add(combat = NEW GuiCombat(go));
|
Add(combat = NEW GuiCombat(go));
|
||||||
Add(action);
|
Add(action);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const char * Options::optionNames[] = {
|
|||||||
"displayOSD",
|
"displayOSD",
|
||||||
"closed_hand",
|
"closed_hand",
|
||||||
"hand_direction",
|
"hand_direction",
|
||||||
|
"mana_display",
|
||||||
"reverse_triggers",
|
"reverse_triggers",
|
||||||
"disable_cards",
|
"disable_cards",
|
||||||
"interruptSeconds",
|
"interruptSeconds",
|
||||||
@@ -317,6 +318,8 @@ bool GameOptions::load_option(int id, string input){
|
|||||||
return read_enum(id, input, OptionHandDirection::getDefinition());
|
return read_enum(id, input, OptionHandDirection::getDefinition());
|
||||||
case Options::CLOSEDHAND:
|
case Options::CLOSEDHAND:
|
||||||
return read_enum(id, input, OptionClosedHand::getDefinition());
|
return read_enum(id, input, OptionClosedHand::getDefinition());
|
||||||
|
case Options::MANADISPLAY:
|
||||||
|
return read_enum(id, input, OptionManaDisplay::getDefinition());
|
||||||
default:
|
default:
|
||||||
return read_default(id, input);
|
return read_default(id, input);
|
||||||
}
|
}
|
||||||
@@ -353,6 +356,8 @@ bool GameOptions::save_option(std::ofstream * file, int id, string name, GameOpt
|
|||||||
return write_enum(file, name, opt, OptionHandDirection::getDefinition());
|
return write_enum(file, name, opt, OptionHandDirection::getDefinition());
|
||||||
case Options::CLOSEDHAND:
|
case Options::CLOSEDHAND:
|
||||||
return write_enum(file, name, opt, OptionClosedHand::getDefinition());
|
return write_enum(file, name, opt, OptionClosedHand::getDefinition());
|
||||||
|
case Options::MANADISPLAY:
|
||||||
|
return write_enum(file, name, opt, OptionManaDisplay::getDefinition());
|
||||||
default:
|
default:
|
||||||
return write_default(file, name, opt);
|
return write_default(file, name, opt);
|
||||||
}
|
}
|
||||||
@@ -442,6 +447,7 @@ GameSettings::~GameSettings(){
|
|||||||
SAFE_DELETE(keypad);
|
SAFE_DELETE(keypad);
|
||||||
SAFE_DELETE(OptionHandDirection::definition);
|
SAFE_DELETE(OptionHandDirection::definition);
|
||||||
SAFE_DELETE(OptionClosedHand::definition);
|
SAFE_DELETE(OptionClosedHand::definition);
|
||||||
|
SAFE_DELETE(OptionManaDisplay::definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameOption GameSettings::invalid_option = GameOption(0);
|
GameOption GameSettings::invalid_option = GameOption(0);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ void GameStateOptions::Start()
|
|||||||
optionsList = NEW OptionsList("Game");
|
optionsList = NEW OptionsList("Game");
|
||||||
optionsList->Add(NEW OptionClosedHand(Options::CLOSEDHAND, "Closed hand"));
|
optionsList->Add(NEW OptionClosedHand(Options::CLOSEDHAND, "Closed hand"));
|
||||||
optionsList->Add(NEW OptionHandDirection(Options::HANDDIRECTION, "Hand direction"));
|
optionsList->Add(NEW OptionHandDirection(Options::HANDDIRECTION, "Hand direction"));
|
||||||
|
optionsList->Add(NEW OptionManaDisplay(Options::MANADISPLAY, "Mana display"));
|
||||||
optionsList->Add(NEW OptionInteger(Options::REVERSETRIGGERS, "Reverse left and right triggers"));
|
optionsList->Add(NEW OptionInteger(Options::REVERSETRIGGERS, "Reverse left and right triggers"));
|
||||||
optionsList->Add(NEW OptionInteger(Options::DISABLECARDS,"Disable card image loading"));
|
optionsList->Add(NEW OptionInteger(Options::DISABLECARDS,"Disable card image loading"));
|
||||||
optionsTabs->Add(optionsList);
|
optionsTabs->Add(optionsList);
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ bool GuiHandSelf::CheckUserInput(u32 key)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiHandSelf::Update(float dt)
|
void GuiHandSelf::Update(float dt)
|
||||||
{
|
{
|
||||||
backpos.Update(dt);
|
backpos.Update(dt);
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../include/GuiMana.h"
|
#include "../include/GuiMana.h"
|
||||||
|
#include "../include/OptionItem.h"
|
||||||
|
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
|
||||||
const float ManaIcon::DESTX = 440;
|
ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) : Pos(x, y, 0.5, 0.0, 255), f(-1), destx(destx), desty(desty), mode(ALIVE), color(color)
|
||||||
const float ManaIcon::DESTY = 20;
|
|
||||||
|
|
||||||
ManaIcon::ManaIcon(int color, float x, float y) : Pos(x, y, 0.5, 0.0, 255), f(-1), mode(ALIVE), color(color)
|
|
||||||
{
|
{
|
||||||
hgeParticleSystemInfo * psi = NULL;
|
hgeParticleSystemInfo * psi = NULL;
|
||||||
JQuad * mq = resources.GetQuad("stars");
|
JQuad * mq = resources.GetQuad("stars");
|
||||||
@@ -145,6 +144,9 @@ void ManaIcon::Update(float dt, float shift)
|
|||||||
zoomP3 += zoomP5 * dt;
|
zoomP3 += zoomP5 * dt;
|
||||||
zoomP4 += zoomP6 * dt;
|
zoomP4 += zoomP6 * dt;
|
||||||
|
|
||||||
|
if (OptionManaDisplay::STATIC == options[Options::MANADISPLAY].number)
|
||||||
|
shift = 0;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case DROPPING :
|
case DROPPING :
|
||||||
@@ -162,33 +164,41 @@ void ManaIcon::Update(float dt, float shift)
|
|||||||
if (f < 0) mode = DEAD;
|
if (f < 0) mode = DEAD;
|
||||||
break;
|
break;
|
||||||
case ALIVE :
|
case ALIVE :
|
||||||
x += 10 * dt * (DESTX - x);
|
x += 10 * dt * (destx - x);
|
||||||
y += 10 * dt * (DESTY + shift - y);
|
y += 10 * dt * (desty + shift - y);
|
||||||
yP1 += yP3 * dt;
|
yP1 += yP3 * dt;
|
||||||
actY = y + yP2 * sinf(M_PI * yP1);
|
actY = y + yP2 * sinf(M_PI * yP1);
|
||||||
|
|
||||||
|
if (particleSys && (fabs(destx - x) < 5) && (fabs(desty + shift - y) < 5)){
|
||||||
|
if (OptionManaDisplay::STATIC == options[Options::MANADISPLAY].number){
|
||||||
|
SAFE_DELETE(particleSys); //Static Mana Only: avoid expensive particle processing
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DEAD :
|
case DEAD :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
particleSys->MoveTo(actX, actY);
|
if (particleSys){
|
||||||
particleSys->Update(dt);
|
particleSys->MoveTo(actX, actY);
|
||||||
|
particleSys->Update(dt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManaIcon::Wither()
|
void ManaIcon::Wither()
|
||||||
{
|
{
|
||||||
mode = WITHERING;
|
mode = WITHERING;
|
||||||
f = 1.0;
|
f = 1.0;
|
||||||
particleSys->Stop();
|
if (particleSys) particleSys->Stop();
|
||||||
}
|
}
|
||||||
void ManaIcon::Drop()
|
void ManaIcon::Drop()
|
||||||
{
|
{
|
||||||
mode = DROPPING;
|
mode = DROPPING;
|
||||||
if (f < 0) f = 0;
|
if (f < 0) f = 0;
|
||||||
particleSys->Stop();
|
if (particleSys) particleSys->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiMana::GuiMana()
|
GuiMana::GuiMana(float x, float y, Player *p):x(x),y(y),owner(p)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,11 +208,56 @@ GuiMana::~GuiMana(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiMana::RenderStatic(){
|
||||||
|
int values[Constants::MTG_NB_COLORS];
|
||||||
|
int totalColors = 0;
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
|
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
|
||||||
|
values[i] = 0;
|
||||||
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
|
if (ManaIcon::ALIVE == (*it)->mode) {
|
||||||
|
values[(*it)->color]++;
|
||||||
|
if (values[(*it)->color] == 1) totalColors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!totalColors) return;
|
||||||
|
|
||||||
|
float x0 = x - 20*totalColors;
|
||||||
|
if (x0 < 10) x0 = 10;
|
||||||
|
float xEnd = x0 + 20*totalColors;
|
||||||
|
r->FillRoundRect(x0,y - 5 ,20*totalColors + 5,20,2,ARGB(128,0,0,0));
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i){
|
||||||
|
if (values[i]){
|
||||||
|
offset-=20;
|
||||||
|
r->RenderQuad(manaIcons[i],xEnd + 15 + offset, y + 5,0,0.7,0.7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r->FillRoundRect(x0,y ,20*totalColors + 5,8,2,ARGB(100,0,0,0));
|
||||||
|
offset = 0;
|
||||||
|
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i){
|
||||||
|
if (values[i]){
|
||||||
|
offset-=20;
|
||||||
|
char buf[4];
|
||||||
|
sprintf(buf,"%i",values[i]);
|
||||||
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
|
mFont->DrawString(buf,xEnd+offset + 9, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GuiMana::Render()
|
void GuiMana::Render()
|
||||||
{
|
{
|
||||||
|
|
||||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
(*it)->Render();
|
(*it)->Render();
|
||||||
|
|
||||||
|
if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number)
|
||||||
|
RenderStatic();
|
||||||
|
|
||||||
}
|
}
|
||||||
bool remove_dead(ManaIcon* m) { return ManaIcon::DEAD != m->mode; }
|
bool remove_dead(ManaIcon* m) { return ManaIcon::DEAD != m->mode; }
|
||||||
void GuiMana::Update(float dt)
|
void GuiMana::Update(float dt)
|
||||||
@@ -225,10 +280,11 @@ int GuiMana::receiveEventPlus(WEvent* e)
|
|||||||
{
|
{
|
||||||
if (WEventEngageMana *event = dynamic_cast<WEventEngageMana*>(e))
|
if (WEventEngageMana *event = dynamic_cast<WEventEngageMana*>(e))
|
||||||
{
|
{
|
||||||
|
if (event->destination != owner->getManaPool()) return 0;
|
||||||
if (event->card && event->card->view)
|
if (event->card && event->card->view)
|
||||||
manas.push_back(NEW ManaIcon(event->color, event->card->view->actX, event->card->view->actY));
|
manas.push_back(NEW ManaIcon(event->color, event->card->view->actX, event->card->view->actY, x, y));
|
||||||
else
|
else
|
||||||
manas.push_back(NEW ManaIcon(event->color, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
|
manas.push_back(NEW ManaIcon(event->color, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, x, y));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else return 0;
|
else return 0;
|
||||||
@@ -238,14 +294,19 @@ int GuiMana::receiveEventMinus(WEvent* e)
|
|||||||
{
|
{
|
||||||
if (WEventConsumeMana *event = dynamic_cast<WEventConsumeMana*>(e))
|
if (WEventConsumeMana *event = dynamic_cast<WEventConsumeMana*>(e))
|
||||||
{
|
{
|
||||||
|
if (event->source != owner->getManaPool()) return 0;
|
||||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
if ((event->color == (*it)->color) && (ManaIcon::ALIVE == (*it)->mode)) { (*it)->Wither(); return 1; }
|
if ((event->color == (*it)->color) && (ManaIcon::ALIVE == (*it)->mode)) {
|
||||||
|
(*it)->Wither();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<WEventEmptyManaPool*>(e))
|
else if (WEventEmptyManaPool *event2 = dynamic_cast<WEventEmptyManaPool*>(e))
|
||||||
{
|
{
|
||||||
|
if (event2->source != owner->getManaPool()) return 0;
|
||||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
(*it)->Drop(); //TODO: split according to which manapool was emptied...
|
(*it)->Drop();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -903,3 +903,22 @@ OptionHandDirection::OptionHandDirection(int id, string displayName) : OptionEnu
|
|||||||
getDefinition();
|
getDefinition();
|
||||||
Reload();
|
Reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EnumDefinition * OptionManaDisplay::definition = NULL;
|
||||||
|
|
||||||
|
EnumDefinition * OptionManaDisplay::getDefinition(){
|
||||||
|
if(!definition){
|
||||||
|
definition = NEW EnumDefinition();
|
||||||
|
definition->values.push_back(EnumDefinition::assoc(STATIC, "simple"));
|
||||||
|
definition->values.push_back(EnumDefinition::assoc(DYNAMIC, "Eye candy"));
|
||||||
|
definition->values.push_back(EnumDefinition::assoc(BOTH, "Both"));
|
||||||
|
}
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionManaDisplay::OptionManaDisplay(int id, string displayName) : OptionEnum(id, displayName)
|
||||||
|
{
|
||||||
|
getDefinition();
|
||||||
|
Reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -304,10 +304,8 @@ JQuad * WResourceManager::RetrieveQuad(string filename, float offX, float offY,
|
|||||||
|
|
||||||
//No quad, but we have a managed texture for this!
|
//No quad, but we have a managed texture for this!
|
||||||
WCachedTexture * jtex = NULL;
|
WCachedTexture * jtex = NULL;
|
||||||
if(style == RETRIEVE_MANAGE)
|
if(style == RETRIEVE_MANAGE || style == RETRIEVE_EXISTING)
|
||||||
jtex = textureWCache.Retrieve(filename,RETRIEVE_MANAGE,submode);
|
jtex = textureWCache.Retrieve(filename,style,submode);
|
||||||
else if(style == RETRIEVE_EXISTING)
|
|
||||||
jtex = textureWCache.Retrieve(filename,RETRIEVE_EXISTING,submode);
|
|
||||||
else
|
else
|
||||||
jtex = textureWCache.Retrieve(filename,RETRIEVE_NORMAL,submode);
|
jtex = textureWCache.Retrieve(filename,RETRIEVE_NORMAL,submode);
|
||||||
|
|
||||||
@@ -1194,11 +1192,8 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(string id, int style, int submod
|
|||||||
string lookup = makeID(id,submode);
|
string lookup = makeID(id,submode);
|
||||||
|
|
||||||
//Check for managed resources first. Always
|
//Check for managed resources first. Always
|
||||||
it = managed.end();
|
it = managed.find(lookup);
|
||||||
for(it = managed.begin();it!=managed.end();it++){
|
|
||||||
if(it->first == lookup)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//Something is managed.
|
//Something is managed.
|
||||||
if(it != managed.end()) {
|
if(it != managed.end()) {
|
||||||
if(!it->second && style == RETRIEVE_RESOURCE)
|
if(!it->second && style == RETRIEVE_RESOURCE)
|
||||||
@@ -1214,11 +1209,7 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(string id, int style, int submod
|
|||||||
|
|
||||||
//Not managed, so look in cache.
|
//Not managed, so look in cache.
|
||||||
if(it == managed.end() && style != RETRIEVE_MANAGE && style != RETRIEVE_RESOURCE ){
|
if(it == managed.end() && style != RETRIEVE_MANAGE && style != RETRIEVE_RESOURCE ){
|
||||||
it = cache.end();
|
it = cache.find(lookup);
|
||||||
for(it = cache.begin();it!=cache.end();it++){
|
|
||||||
if(it->first == lookup)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//Well, we've found something...
|
//Well, we've found something...
|
||||||
if(it != cache.end()) {
|
if(it != cache.end()) {
|
||||||
if(!it->second && (submode & CACHE_EXISTING)){
|
if(!it->second && (submode & CACHE_EXISTING)){
|
||||||
|
|||||||
Reference in New Issue
Block a user