From 58700417dab365677af8d0140373cedd53fa8512 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew" Date: Tue, 3 Mar 2009 11:03:38 +0000 Subject: [PATCH] Erwan - Added Waldorf's changes --- projects/mtg/include/AIPlayer.h | 2 +- projects/mtg/include/GameOptions.h | 3 + projects/mtg/include/MTGGuiHand.h | 3 +- projects/mtg/src/ActionStack.cpp | 94 ++++++++++++++++++++------- projects/mtg/src/GameStateOptions.cpp | 3 + projects/mtg/src/MTGGuiHand.cpp | 7 ++ 6 files changed, 88 insertions(+), 24 deletions(-) diff --git a/projects/mtg/include/AIPlayer.h b/projects/mtg/include/AIPlayer.h index 5f72d7b31..436b8048a 100644 --- a/projects/mtg/include/AIPlayer.h +++ b/projects/mtg/include/AIPlayer.h @@ -59,7 +59,7 @@ class AIPlayer: public Player{ AIStats * getStats(); public: void End(){}; - virtual int displayStack(){return 1;}; + virtual int displayStack(){return 0;}; AIStats * stats; ManaCost * getPotentialMana(); AIPlayer(MTGPlayerCards * _deck, string deckFile); diff --git a/projects/mtg/include/GameOptions.h b/projects/mtg/include/GameOptions.h index 31f56b142..d7132e131 100644 --- a/projects/mtg/include/GameOptions.h +++ b/projects/mtg/include/GameOptions.h @@ -8,6 +8,9 @@ using std::string; #define OPTIONS_MUSICVOLUME "musicVolume" #define OPTIONS_SFXVOLUME "sfxVolume" +// WALDORF - added +#define OPTIONS_INTERRUPT_SECONDS "interruptSeconds" + #define OPTIONS_SAVEFILE RESPATH"/settings/options.txt" diff --git a/projects/mtg/include/MTGGuiHand.h b/projects/mtg/include/MTGGuiHand.h index 0f6f3bdd6..43545f8df 100644 --- a/projects/mtg/include/MTGGuiHand.h +++ b/projects/mtg/include/MTGGuiHand.h @@ -27,7 +27,8 @@ class MTGGuiHand: public GuiCardsController{ void Update(float dt); bool CheckUserInput(u32 key); virtual void Render(); - void updateCards(); + void updateCards(); + void showHand (bool show);// WALDORF - added }; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index f7e75ff03..fc2601525 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -7,7 +7,10 @@ #include "../include/GameObserver.h" #include "../include/Damage.h" #include "../include/ManaCost.h" -#include "../include/GameOptions.h" +#include "../include/GameOptions.h" +// WALDORF - added to support drawing big cards during interrupts +#include "../include/CardGui.h" + /* NextGamePhase requested by user @@ -27,7 +30,7 @@ void NextGamePhase::Render(){ int playerId = 1; if (GameObserver::GetInstance()->currentActionPlayer == GameObserver::GetInstance()->players[1]) playerId = 2; sprintf(buffer, "Player %i : -> %s", playerId, Constants::MTGPhaseNames[nextPhase]); - mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT); + mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT); } NextGamePhase::NextGamePhase(int id): Interruptible(id){ @@ -46,7 +49,7 @@ void StackAbility::Render(){ mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; sprintf(buffer, "%s", ability->getMenuText()); - mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT); + mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = ability->source->getThumb(); if (quad){ @@ -108,7 +111,7 @@ void Spell::Render(){ JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); - mFont->DrawString(source->getName(), x + 25 , y, JGETEXT_LEFT); + mFont->DrawString(source->getName(), x + 30 , y, JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = source->getThumb(); if (quad){ @@ -118,6 +121,38 @@ void Spell::Render(){ }else{ // } + // WALDORF - added these lines to render a big card as well as the small one + // in the interrupt window. A big card will be rendered no matter whether + // the user has been using big cards or not. However, I do take into which + // kind of big card they like. + // The card will be rendered in the same place as the GuiHand + // card. It doesn't attempt to hide the GUIHand card, it + // just overwrites it. + // I stole the render code from RenderBig() in CardGUI.cpp + + quad = source->getQuad(); + if (quad){ + quad->SetColor(ARGB(220,255,255,255)); + float scale = 257.f / quad->mHeight; + renderer->RenderQuad(quad, 10 , 20 , 0.0f,scale,scale); + } + else + { + MTGCard * mtgcard = source->model; + JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic"); + CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f); + + quad = source->getThumb(); + if (quad){ + float scale = 250 / quad->mHeight; + quad->SetColor(ARGB(40,255,255,255)); + renderer->RenderQuad(quad, 20, 20, 0.0f, scale, scale); + } + } + + // WALDORF - end + + Damageable * target = getNextDamageableTarget(); if (target){ quad = target->getIcon(); @@ -156,9 +191,9 @@ void PutInGraveyard::Render(){ mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); if (!removeFromGame){ - mFont->DrawString("goes to graveyard", x + 20 , y, JGETEXT_LEFT); + mFont->DrawString("goes to graveyard", x + 30 , y, JGETEXT_LEFT); }else{ - mFont->DrawString("is removed from game", x + 20 , y, JGETEXT_LEFT); + mFont->DrawString("is removed from game", x + 30 , y, JGETEXT_LEFT); } JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = card->getThumb(); @@ -497,14 +532,17 @@ void ActionStack::Update(float dt){ }else if (mode == ACTIONSTACK_TARGET){ GuiLayer::Update(dt); } - if (askIfWishesToInterrupt) - { - if (timer < 0) timer = 3; - timer -= dt; - if (timer < 0){ - cancelInterruptOffer(); - } + if (askIfWishesToInterrupt){ + // WALDORF - added code to use a game option setting to determine how + // long the Interrupt timer should be. If it is set to zero (0), the + // game will wait for ever for the user to make a selection. + if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() > 0) + { + if (timer < 0) timer = GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue(); + timer -= dt; + if (timer < 0) cancelInterruptOffer(); } + } } void ActionStack::cancelInterruptOffer(int cancelMode){ @@ -685,15 +723,27 @@ void ActionStack::Render(){ } char buffer[200]; - sprintf(buffer, "interrupt ? %i", static_cast(timer)); - mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight); - - if (mCount > 1){ - sprintf(buffer, "X Interrupt - 0 No - [] No to All"); - }else{ - sprintf(buffer, "X Interrupt - 0 No"); - } - mFont->DrawString(buffer, x0 + 5 , currenty); + // WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down + // seconds if the user disables auto progressing interrupts by setting the seconds + // value to zero in Options. + if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0) + sprintf(buffer, "Interrupt?"); + else + sprintf(buffer, "Interrupt? %i", static_cast(timer)); + + //WALDORF - removed all the unnecessary math. just display the prompt at the + // top of the box. + //mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight); + mFont->DrawString(buffer, x0 + 5, y0); + + + if (mCount > 1) sprintf(buffer, "X Interrupt - 0 No - [] No to All"); + else sprintf(buffer, "X Interrupt - 0 No"); + + // WALDORF - puts the button legend right under the prompt. the stack + // will be displayed below it now. no more need to do wierd currY math. + //mFont->DrawString(buffer, x0 + 5 , currenty); + mFont->DrawString(buffer, x0 + 5, y0 + 14); }else if (mode == ACTIONSTACK_TARGET && modal){ for (int i=0;iAdd(NEW OptionItem(OPTIONS_MUSICVOLUME, "Music volume", 100, 10)); optionsList->Add(NEW OptionItem(OPTIONS_SFXVOLUME, "SFX volume", 100, 10)); + // WALDORF - added next line + optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1)); + JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170); optionsMenu->Add(1, "Save & Back to Main Menu"); diff --git a/projects/mtg/src/MTGGuiHand.cpp b/projects/mtg/src/MTGGuiHand.cpp index 74b5348f6..ba4a46d57 100644 --- a/projects/mtg/src/MTGGuiHand.cpp +++ b/projects/mtg/src/MTGGuiHand.cpp @@ -102,3 +102,10 @@ void MTGGuiHand::Render(){ } } } + +// WALDORF - added method +void MTGGuiHand::showHand (bool show) +{ + if (show) mShowHand = HAND_SHOW; + else mShowHand = HAND_HIDE; +}