Erwan
- Moved "extraPayment" cancel verification into ActionLayer (was in GuiLayers) - added "HUDDisplay" MTGAbility (displays damage/graveyard info) - Added option to NOT interrupt own's spells and abilities. Allows smoother gameplay. We should add a "quick options" menu ingame to change those options on the fly
This commit is contained in:
@@ -53,6 +53,7 @@ class Interruptible: public PlayGuiObject, public Targetable{
|
||||
virtual void Render(){};
|
||||
int typeAsTarget(){return TARGET_STACKACTION;};
|
||||
Interruptible(int id,bool hasFocus = false):PlayGuiObject(id,40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
|
||||
virtual const char *getDisplayName(){return "stack object";};
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
virtual void Dump();
|
||||
#endif
|
||||
@@ -76,6 +77,7 @@ class Spell: public Interruptible, public TargetsList {
|
||||
~Spell();
|
||||
int resolve();
|
||||
void Render();
|
||||
const char *getDisplayName();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
@@ -122,6 +124,14 @@ class ActionStack :public GuiLayer{
|
||||
void unpackDamageStack(DamageStack * ds);
|
||||
void repackDamageStacks();
|
||||
public:
|
||||
|
||||
enum{
|
||||
NOT_DECIDED = 0,
|
||||
INTERRUPT = -1,
|
||||
DONT_INTERRUPT = 1,
|
||||
DONT_INTERRUPT_ALL = 2,
|
||||
};
|
||||
|
||||
int setIsInterrupting(Player * player);
|
||||
int count( int type = 0 , int state = 0 , int display = -1);
|
||||
Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0 , int display = -1);
|
||||
|
||||
@@ -13,6 +13,8 @@ using std::string;
|
||||
#define OPTIONS_DIFFICULTY "difficulty"
|
||||
#define OPTIONS_CACHESIZE "cacheSize"
|
||||
#define OPTIONS_PLASMAEFFECT "plasmaEffect"
|
||||
#define OPTIONS_INTERRUPTMYSPELLS "interruptMySpells"
|
||||
#define OPTIONS_INTERRUPTMYABILITIES "interruptMyAbilities"
|
||||
|
||||
// WALDORF - added
|
||||
#define OPTIONS_INTERRUPT_SECONDS "interruptSeconds"
|
||||
|
||||
@@ -56,6 +56,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
Player * owner;
|
||||
Counters * counters;
|
||||
int typeAsTarget(){return TARGET_CARD;}
|
||||
const char * getDisplayName();
|
||||
MTGCardInstance * target;
|
||||
void addType(int type);
|
||||
|
||||
|
||||
@@ -180,4 +180,33 @@ class MTGLifelinkRule:public MTGAbility{
|
||||
};
|
||||
|
||||
|
||||
/* HUD Display */
|
||||
|
||||
class HUDString {
|
||||
public:
|
||||
string value;
|
||||
int timestamp;
|
||||
int quantity;
|
||||
HUDString(string s, int ts):value(s),timestamp(ts){quantity = 1;};
|
||||
};
|
||||
|
||||
class HUDDisplay:public MTGAbility{
|
||||
private:
|
||||
list<HUDString *> events;
|
||||
float timestamp;
|
||||
float popdelay;
|
||||
JLBFont * f;
|
||||
float maxWidth;
|
||||
int addEvent(string s);
|
||||
public:
|
||||
int testDestroy();
|
||||
int receiveEvent(WEvent * event);
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
HUDDisplay(int _id);
|
||||
~HUDDisplay();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@ class Player: public Damageable{
|
||||
public:
|
||||
virtual void End();
|
||||
int typeAsTarget(){return TARGET_PLAYER;}
|
||||
const char * getDisplayName();
|
||||
virtual int displayStack(){return 1;}
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
class Targetable{
|
||||
public:
|
||||
virtual int typeAsTarget() = 0;
|
||||
virtual const char * getDisplayName() =0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,6 +42,11 @@ int ActionLayer::unstoppableRenderInProgress(){
|
||||
|
||||
|
||||
bool ActionLayer::CheckUserInput(u32 key){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (g->waitForExtraPayment && key == PSP_CTRL_CROSS){
|
||||
game->waitForExtraPayment = NULL;
|
||||
return 1;
|
||||
}
|
||||
if (menuObject){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ Spell::Spell(int id, MTGCardInstance * _source, Targetable * _targets[], int nb_
|
||||
}
|
||||
|
||||
|
||||
const char * Spell::getDisplayName(){
|
||||
return source->getName();
|
||||
}
|
||||
|
||||
Spell::~Spell(){
|
||||
SAFE_DELETE(cost);
|
||||
}
|
||||
@@ -265,8 +269,13 @@ int ActionStack::addPutInGraveyard(MTGCardInstance * card){
|
||||
|
||||
int ActionStack::addAbility(MTGAbility * ability){
|
||||
StackAbility * stackAbility = NEW StackAbility(mCount,ability);
|
||||
addAction(stackAbility);
|
||||
return 1;
|
||||
int result = addAction(stackAbility);
|
||||
if (!game->players[0]->isAI() &&
|
||||
ability->source->controller()==game->players[0] &&
|
||||
GameOptions::GetInstance()->values[OPTIONS_INTERRUPTMYABILITIES].getIntValue() == 0){
|
||||
interruptDecision[0] = DONT_INTERRUPT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int ActionStack::addDraw(Player * player, int nb_cards){
|
||||
@@ -318,7 +327,13 @@ int ActionStack::addSpell(MTGCardInstance * _source, Targetable * _targets[], in
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
Spell * spell = NEW Spell(mCount,_source,_targets,_nbtargets, mana);
|
||||
return addAction(spell);
|
||||
int result = addAction(spell);
|
||||
if (!game->players[0]->isAI() &&
|
||||
_source->controller()==game->players[0] &&
|
||||
GameOptions::GetInstance()->values[OPTIONS_INTERRUPTMYSPELLS].getIntValue() == 0){
|
||||
interruptDecision[0] = DONT_INTERRUPT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ void DuelLayers::init(){
|
||||
actionLayer->Add(NEW MTGLegendRule(-1));
|
||||
actionLayer->Add(NEW MTGPersistRule(-1));
|
||||
actionLayer->Add(NEW MTGLifelinkRule(-1));
|
||||
//Other display elements
|
||||
actionLayer->Add(NEW HUDDisplay(-1));
|
||||
|
||||
//2 Hand Layer
|
||||
MTGGuiHand * mGuiHand = NEW MTGGuiHand(3, GameObserver::GetInstance());
|
||||
|
||||
@@ -27,6 +27,8 @@ void GameStateOptions::Start()
|
||||
optionsList = NEW OptionsList();
|
||||
if (GameApp::HasMusic) optionsList->Add(NEW OptionItem(OPTIONS_MUSICVOLUME, "Music volume", 100, 10));
|
||||
optionsList->Add(NEW OptionItem(OPTIONS_SFXVOLUME, "SFX volume", 100, 10));
|
||||
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPTMYSPELLS, "interrupt my spells"));
|
||||
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPTMYABILITIES, "interrupt my abilities"));
|
||||
// WALDORF - added next line
|
||||
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) {
|
||||
|
||||
@@ -145,11 +145,6 @@ void GuiLayers::Update(float dt, Player * currentPlayer){
|
||||
int isAI = currentPlayer->isAI();
|
||||
u32 key;
|
||||
while ((key = JGE::GetInstance()->ReadButton())){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (game->waitForExtraPayment && key == PSP_CTRL_CROSS){
|
||||
game->waitForExtraPayment = NULL;
|
||||
continue;
|
||||
}
|
||||
for (int i=0; i<nbitems; i++){
|
||||
if (!isAI){
|
||||
if (0 != key)
|
||||
|
||||
@@ -108,6 +108,10 @@ void MTGCardInstance::initMTGCI(){
|
||||
}
|
||||
|
||||
|
||||
const char * MTGCardInstance::getDisplayName(){
|
||||
return getName();
|
||||
}
|
||||
|
||||
void MTGCardInstance::addType(int type){
|
||||
types[nb_types] = type;
|
||||
nb_types++;
|
||||
|
||||
@@ -292,3 +292,94 @@ ostream& MTGMomirRule::toString(ostream& out) const
|
||||
out << "MTGMomirRule ::: pool : " << pool << " ; initialized : " << initialized << " ; textAlpha : " << textAlpha << " ; text " << text << " ; alreadyplayed : " << alreadyplayed << " ; collection : " << collection << "(";
|
||||
return MTGAbility::toString(out) << ")";
|
||||
}
|
||||
|
||||
|
||||
//HUDDisplay
|
||||
int HUDDisplay::testDestroy(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HUDDisplay::Update(float dt){
|
||||
timestamp += dt;
|
||||
popdelay +=dt;
|
||||
if (events.size()){
|
||||
list<HUDString *>::iterator it = events.begin();
|
||||
HUDString * hs = *it;
|
||||
if (popdelay > 1 && timestamp - hs->timestamp > 2){
|
||||
events.pop_front();
|
||||
delete hs;
|
||||
if (events.size()) popdelay = 0;
|
||||
}
|
||||
}else{
|
||||
maxWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int HUDDisplay::addEvent(string s){
|
||||
events.push_back(NEW HUDString(s, timestamp));
|
||||
float width = f->GetStringWidth(s.c_str());
|
||||
if (width > maxWidth) maxWidth = width;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HUDDisplay::receiveEvent(WEvent * event){
|
||||
|
||||
WEventZoneChange * ezc = dynamic_cast<WEventZoneChange*>(event);
|
||||
if (ezc) {
|
||||
int ok = 0;
|
||||
for (int i = 0; i < 2 ; i++){
|
||||
Player * p = game->players[i];
|
||||
if (ezc->from == p->game->graveyard || ezc->to == p->game->graveyard ) ok = 1;
|
||||
}
|
||||
if (!ok) return 0;
|
||||
char buffer[512];
|
||||
sprintf(buffer,"%s goes to graveyard", ezc->card->getName());
|
||||
string s = buffer;
|
||||
return addEvent(s);
|
||||
}
|
||||
|
||||
WEventDamage * ed = dynamic_cast<WEventDamage*>(event);
|
||||
if (ed) {
|
||||
char buffer[512];
|
||||
sprintf(buffer, "%s: %i -> %s", ed->damage->source->getName(), ed->damage->damage, ed->damage->target->getDisplayName());
|
||||
string s = buffer;
|
||||
return addEvent(s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
void HUDDisplay::Render(){
|
||||
if (!events.size()) return;
|
||||
|
||||
f->SetColor(ARGB(255,255,255,255));
|
||||
|
||||
list<HUDString *>::reverse_iterator it;
|
||||
|
||||
float x0 = SCREEN_WIDTH-10-maxWidth-10;
|
||||
float y0 = 20;
|
||||
float size = events.size() * 16;
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
r->FillRoundRect(x0,y0,maxWidth + 10,size,5,ARGB(50,0,0,0));
|
||||
|
||||
int i = 0;
|
||||
for (it = events.rbegin(); it !=events.rend(); ++it){
|
||||
HUDString * hs = *it;
|
||||
f->DrawString(hs->value.c_str(),x0 + 5, y0 + 16 * i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
HUDDisplay::HUDDisplay(int _id):MTGAbility(_id, NULL){
|
||||
timestamp = 0;
|
||||
popdelay = 2;
|
||||
f = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
||||
maxWidth = 0;
|
||||
}
|
||||
|
||||
HUDDisplay::~HUDDisplay(){
|
||||
list<HUDString *>::iterator it;
|
||||
for (it = events.begin(); it !=events.end(); ++it){
|
||||
HUDString * hs = *it;
|
||||
delete hs;
|
||||
}
|
||||
events.clear();
|
||||
}
|
||||
@@ -34,7 +34,15 @@ void OptionItem::Render(){
|
||||
renderer->FillRoundRect(x-5,y-2,SCREEN_WIDTH -x - 5,20,2,ARGB(150,50,50,50));
|
||||
mFont->DrawString(displayValue.c_str(),x,y);
|
||||
char buf[512];
|
||||
sprintf(buf, "%i", value);
|
||||
if (maxValue == 1){
|
||||
if (value){
|
||||
sprintf(buf, "yes");
|
||||
}else{
|
||||
sprintf(buf,"no");
|
||||
}
|
||||
}else{
|
||||
sprintf(buf, "%i", value);
|
||||
}
|
||||
mFont->DrawString(buf,SCREEN_WIDTH -10 ,y,JGETEXT_RIGHT);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ Player::~Player(){
|
||||
if (mAvatar) delete mAvatar;
|
||||
}
|
||||
|
||||
const char * Player::getDisplayName(){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (this == g->players[0]) return "Player 1";
|
||||
return "Player 2";
|
||||
}
|
||||
|
||||
MTGInPlay * Player::inPlay(){
|
||||
return game->inPlay;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user