- quick patch for i379
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-03-13 07:25:07 +00:00
parent e7a1c96d4a
commit 8a4797a06a
4 changed files with 43 additions and 29 deletions

View File

@@ -38,7 +38,7 @@ class GameStateDuel: public GameState, public JGuiListener
bool MusicExist(string FileName);
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
void ensureOpponentMenu(); //loads the opponentMenu if it doesn't exist
public:
GameStateDuel(GameApp* parent);

View File

@@ -49,6 +49,7 @@ class GameStateMenu: public GameState, public JGuiListener
void runTest(); //!!
void listPrimitives();
void genNbCardsStr(); //computes the contents of nbCardsStr
void ensureMGuiController(); //creates the MGuiController if it doesn't exist
public:
GameStateMenu(GameApp* parent);
virtual ~GameStateMenu();

View File

@@ -213,6 +213,16 @@ bool GameStateDuel::MusicExist(string FileName){
return false;
}
void GameStateDuel::ensureOpponentMenu(){
if (!opponentMenu){
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Constants::MENU_FONT, 35, 25, "Choose Opponent");
opponentMenu->Add(0,"Random");
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
}
}
void GameStateDuel::Update(float dt)
{
switch (mGamePhase)
@@ -270,13 +280,7 @@ void GameStateDuel::Update(float dt)
deckmenu->Update(dt);
else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
if (!opponentMenu){
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Constants::MENU_FONT, 35, 25, "Choose Opponent");
opponentMenu->Add(0,"Random");
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
}
ensureOpponentMenu();
opponentMenu->Update(dt);
}else{
loadPlayer(1);
@@ -286,14 +290,14 @@ void GameStateDuel::Update(float dt)
break;
case DUEL_STATE_CHOOSE_DECK2_TO_PLAY:
if (mParent->players[1] == PLAYER_TYPE_HUMAN){
if (deckmenu->closed) mGamePhase = DUEL_STATE_PLAY;
else deckmenu->Update(dt);
if (deckmenu->closed) mGamePhase = DUEL_STATE_PLAY;
else deckmenu->Update(dt);
}
else
{
else{
ensureOpponentMenu();
if (opponentMenu->closed) mGamePhase = DUEL_STATE_PLAY;
else opponentMenu->Update(dt);
}
}
break;
case DUEL_STATE_PLAY:
if (!game){

View File

@@ -10,7 +10,7 @@
#include "../include/PlayerData.h"
#include "../include/utils.h"
static const char* GAME_VERSION = "WTH?! 0.11.0 - by wololo";
static const char* GAME_VERSION = "WTH?! 0.11.1 - by wololo";
#define DEFAULT_ANGLE_MULTIPLIER 0.4
#define MAX_ANGLE_MULTIPLIER (3*M_PI)
@@ -100,7 +100,7 @@ void GameStateMenu::Create()
}
}
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_NONE;
currentState = MENU_STATE_MAJOR_LOADING_CARDS;
bool langChosen = false;
string lang = options[Options::LANG].str;
if (lang.size()){
@@ -340,6 +340,20 @@ void GameStateMenu::listPrimitives(){
primitivesLoadCounter = 0;
}
void GameStateMenu::ensureMGuiController(){
if (!mGuiController) {
mGuiController = NEW JGuiController(100, this);
if (mGuiController) {
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
mFont->SetColor(ARGB(255,255,255,255));
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"particle3.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"particle4.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"particle5.psi",resources.GetQuad("particles")));
}
}
}
void GameStateMenu::Update(float dt)
{
@@ -414,25 +428,16 @@ void GameStateMenu::Update(float dt)
break;
case MENU_STATE_MAJOR_MAINMENU :
if (!scrollerSet) fillScroller();
if (!mGuiController) {
mGuiController = NEW JGuiController(100, this);
if (mGuiController) {
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
mFont->SetColor(ARGB(255,255,255,255));
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"particle3.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"particle4.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"particle5.psi",resources.GetQuad("particles")));
}
}
ensureMGuiController();
if (mGuiController)
mGuiController->Update(dt);
if(mEngine->GetButtonState(JGE_BTN_NEXT)) //Hook for GameStateAward state
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_AWARDS); //TODO: A slide transition would be nice.
break;
case MENU_STATE_MAJOR_SUBMENU :
subMenuController->Update(dt);
if (subMenuController)
subMenuController->Update(dt);
ensureMGuiController();
mGuiController->Update(dt);
break;
case MENU_STATE_MAJOR_DUEL :
@@ -464,6 +469,10 @@ void GameStateMenu::Update(float dt)
switch (MENU_STATE_MINOR & currentState){
case MENU_STATE_MINOR_SUBMENU_CLOSING :
if (!subMenuController){ //http://code.google.com/p/wagic/issues/detail?id=379
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
break;
}
if (subMenuController->closed) {
SAFE_DELETE(subMenuController);
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
@@ -540,7 +549,7 @@ void GameStateMenu::Render()
};
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
if (mGuiController!=NULL)
if (mGuiController)
mGuiController->Render();
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);