Erwan
- Events are now sent to GameObserver rather than ActionLayer
This commit is contained in:
@@ -12,7 +12,7 @@ class DamageResolverLayer;
|
|||||||
|
|
||||||
class DuelLayers: public GuiLayers{
|
class DuelLayers: public GuiLayers{
|
||||||
|
|
||||||
public:
|
public :
|
||||||
ActionLayer * actionLayer();
|
ActionLayer * actionLayer();
|
||||||
MTGGuiHand * handLayer();
|
MTGGuiHand * handLayer();
|
||||||
MTGGuiPlay * playLayer();
|
MTGGuiPlay * playLayer();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class GameObserver{
|
|||||||
void Render();
|
void Render();
|
||||||
void ButtonPressed(int, PlayGuiObject*);
|
void ButtonPressed(int, PlayGuiObject*);
|
||||||
|
|
||||||
|
int receiveEvent(WEvent * event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,11 +9,12 @@
|
|||||||
#define DIR_RIGHT 4
|
#define DIR_RIGHT 4
|
||||||
|
|
||||||
#include <JGui.h>
|
#include <JGui.h>
|
||||||
|
#include "../include/WEvent.h"
|
||||||
|
|
||||||
class GameObserver;
|
class GameObserver;
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
|
|
||||||
class GuiLayer{
|
class GuiLayer{
|
||||||
protected:
|
protected:
|
||||||
GameObserver * game;
|
GameObserver * game;
|
||||||
@@ -43,6 +44,8 @@ class GuiLayer{
|
|||||||
if (mCount) return 0;
|
if (mCount) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual int receiveEvent(WEvent * e){return 0;};
|
||||||
};
|
};
|
||||||
|
|
||||||
class GuiLayers{
|
class GuiLayers{
|
||||||
@@ -57,6 +60,7 @@ class GuiLayers{
|
|||||||
void Remove();
|
void Remove();
|
||||||
int unstoppableRenderInProgress();
|
int unstoppableRenderInProgress();
|
||||||
~GuiLayers();
|
~GuiLayers();
|
||||||
|
int receiveEvent(WEvent * e);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ int Damage::resolve(){
|
|||||||
|
|
||||||
//Send Damage event to listeners
|
//Send Damage event to listeners
|
||||||
WEventDamage * e = NEW WEventDamage(this);
|
WEventDamage * e = NEW WEventDamage(this);
|
||||||
GameObserver::GetInstance()->mLayers->actionLayer()->receiveEvent(e);
|
GameObserver::GetInstance()->receiveEvent(e);
|
||||||
delete e;
|
delete e;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
@@ -62,4 +62,3 @@ MTGGuiPlay * DuelLayers::playLayer(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -439,6 +439,10 @@ void GameObserver::untapPhase(){
|
|||||||
currentPlayer->inPlay()->untapAll();
|
currentPlayer->inPlay()->untapAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GameObserver::receiveEvent(WEvent * e){
|
||||||
|
return mLayers->receiveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int GameObserver::isACreature(MTGCardInstance * card){
|
int GameObserver::isACreature(MTGCardInstance * card){
|
||||||
return card->isACreature();
|
return card->isACreature();
|
||||||
|
|||||||
@@ -172,3 +172,12 @@ void GuiLayers::Render(){
|
|||||||
objects[i]->Render();
|
objects[i]->Render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GuiLayers::receiveEvent(WEvent * e){
|
||||||
|
for (int i = 0; i < nbitems; i++){
|
||||||
|
objects[i]->receiveEvent(e);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
|||||||
copy->changedZoneRecently = 1.f;
|
copy->changedZoneRecently = 1.f;
|
||||||
GameObserver *g = GameObserver::GetInstance();
|
GameObserver *g = GameObserver::GetInstance();
|
||||||
WEvent * e = NEW WEventZoneChange(copy, from, to);
|
WEvent * e = NEW WEventZoneChange(copy, from, to);
|
||||||
g->mLayers->actionLayer()->receiveEvent(e);
|
g->receiveEvent(e);
|
||||||
delete e;
|
delete e;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user