Some organisational prep work before I start working on a new navigation method (ie replacement for CardSelector). The current design was to allocate a CardSelector and pass in its pointer to a variety of classes via their constructors. To simplify things, now we use a singleton style pattern with an Instance() function - this means that when I implement a new class to replace CardSelector, I only need to modify what's returned by the singleton callback - as long as the new pointer class supports the same function calls, it'll be a straight drop-in.

This commit is contained in:
wrenczes@gmail.com
2010-10-22 08:41:44 +00:00
parent 84004c7c7f
commit e2de03d987
13 changed files with 177 additions and 118 deletions

View File

@@ -5,7 +5,7 @@
#define LIB_GRAVE_OFFSET 230
GuiAvatars::GuiAvatars(CardSelector* cs) : cs(cs), active(NULL)
GuiAvatars::GuiAvatars() : active(NULL)
{
Add(self = NEW GuiAvatar (SCREEN_WIDTH, SCREEN_HEIGHT, false,
GameObserver::GetInstance()->players[0], GuiAvatar::BOTTOM_RIGHT, this));
@@ -22,8 +22,13 @@ GuiAvatars::GuiAvatars(CardSelector* cs) : cs(cs), active(NULL)
Add(opponentGraveyard = NEW GuiGraveyard(5 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 5, false, GameObserver::GetInstance()->players[1], this));
Add(opponentLibrary = NEW GuiLibrary (5 + GuiAvatar::Width *1.2 - GuiGameZone::Width / 2, 5 + GuiGameZone::Height + 5, false, GameObserver::GetInstance()->players[1], this));
cs->Add(self); cs->Add(selfGraveyard); cs->Add(selfLibrary);
cs->Add(opponent); cs->Add(opponentGraveyard); cs->Add(opponentLibrary); cs->Add(opponentHand);
CardSelectorSingleton::Instance()->Add(self);
CardSelectorSingleton::Instance()->Add(selfGraveyard);
CardSelectorSingleton::Instance()->Add(selfLibrary);
CardSelectorSingleton::Instance()->Add(opponent);
CardSelectorSingleton::Instance()->Add(opponentGraveyard);
CardSelectorSingleton::Instance()->Add(opponentLibrary);
CardSelectorSingleton::Instance()->Add(opponentHand);
selfGraveyard->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
}