diff --git a/projects/mtg/bin/Res/graphics/iconspsp.png b/projects/mtg/bin/Res/graphics/iconspsp.png index 90aa48a5c..4c9d8ea0b 100644 Binary files a/projects/mtg/bin/Res/graphics/iconspsp.png and b/projects/mtg/bin/Res/graphics/iconspsp.png differ diff --git a/projects/mtg/include/ActionStack.h b/projects/mtg/include/ActionStack.h index ffd0052e6..99813173f 100644 --- a/projects/mtg/include/ActionStack.h +++ b/projects/mtg/include/ActionStack.h @@ -63,6 +63,9 @@ class Interruptible: public PlayGuiObject, public Targetable{ #if defined (WIN32) || defined (LINUX) || defined (IOS) virtual void Dump(); #endif + +protected: + float GetVerticalTextOffset() const; }; class NextGamePhase: public Interruptible { @@ -136,6 +139,7 @@ class DrawAction: public Interruptible { class ActionStack :public GuiLayer{ protected: + JQuad * pspIcons[8]; GameObserver* game; int interruptDecision[2]; float timer; @@ -145,7 +149,8 @@ class ActionStack :public GuiLayer{ public: - enum{ + enum + { NOT_DECIDED = 0, INTERRUPT = -1, DONT_INTERRUPT = 1, diff --git a/projects/mtg/include/GameStateShop.h b/projects/mtg/include/GameStateShop.h index f50fdc5e4..ccab4c1b0 100644 --- a/projects/mtg/include/GameStateShop.h +++ b/projects/mtg/include/GameStateShop.h @@ -59,6 +59,7 @@ private: class GameStateShop: public GameState, public JGuiListener { private: + JQuad * pspIcons[8]; WSrcCards * srcCards; JTexture * altThumb[8]; JQuad * mBack; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 2f1bc1893..8c825ed56 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -17,10 +17,18 @@ The Action Stack contains all information for Game Events that can be interrupte #include +namespace +{ + float kGamepadIconSize = 0.5f; + + const std::string kInterruptString(": Interrupt"); + const std::string kNoString(": No"); + const std::string kNoToAllString(": No To All"); +} + /* NextGamePhase requested by user */ - int NextGamePhase::resolve() { GameObserver::GetInstance()->nextGamePhase(); @@ -72,13 +80,20 @@ const string Interruptible::getDisplayName() const return typeid(*this).name(); } +float Interruptible::GetVerticalTextOffset() const +{ + static const float kTextVerticalOffset = (mHeight - WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT)->GetHeight()) / 2; + return kTextVerticalOffset; +} + void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad) { WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetColor(ARGB(255,255,255,255)); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); - mFont->DrawString(_(action).c_str(), x + 30, y, JGETEXT_LEFT); + + mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = WResourceManager::Instance()->RetrieveCard(source, CACHE_THUMB); if (!quad) @@ -87,11 +102,11 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string { quad->SetColor(ARGB(255,255,255,255)); float scale = mHeight / quad->mHeight; - renderer->RenderQuad(quad, x + 10 * scale, y + 15 * scale, 0, scale, scale); + renderer->RenderQuad(quad, x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale); } else if (alt1.size()) { - mFont->DrawString(_(alt1).c_str(), x, y - 15); + mFont->DrawString(_(alt1).c_str(), x, y + GetVerticalTextOffset()); } if (bigQuad) @@ -107,12 +122,12 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string targetQuad->SetColor(ARGB(255,255,255,255)); targetQuad->SetHotSpot(targetQuad->mWidth / 2, targetQuad->mHeight / 2); float scale = mHeight / targetQuad->mHeight; - renderer->RenderQuad(targetQuad, x + 150, y + 15 * scale, 0, scale, scale); + renderer->RenderQuad(targetQuad, x + 150, y + ((mHeight - targetQuad->mHeight) / 2) + targetQuad->mHotSpotY, 0, scale, scale); targetQuad->SetHotSpot(backupX, backupY); } else if (alt2.size()) { - mFont->DrawString(_(alt2).c_str(), x + 120, y); + mFont->DrawString(_(alt2).c_str(), x + 120, y + GetVerticalTextOffset()); } } @@ -428,7 +443,7 @@ void DrawAction::Render() if (player == GameObserver::GetInstance()->players[1]) playerId = 2; sprintf(buffer, _("Player %i draws %i card").c_str(), playerId, nbcards); - mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT); + mFont->DrawString(buffer, x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT); } ostream& DrawAction::toString(ostream& out) const @@ -437,7 +452,6 @@ ostream& DrawAction::toString(ostream& out) const return out; } -/* The Action Stack itself */ int ActionStack::addPutInGraveyard(MTGCardInstance * card) { PutInGraveyard * death = NEW PutInGraveyard(mCount, card); @@ -556,8 +570,8 @@ Interruptible * ActionStack::getAt(int id) return (Interruptible *) mObjects[id]; } -ActionStack::ActionStack(GameObserver* game) : -game(game) +ActionStack::ActionStack(GameObserver* game) + : game(game) { for (int i = 0; i < 2; i++) interruptDecision[i] = 0; @@ -567,6 +581,13 @@ game(game) mode = ACTIONSTACK_STANDARD; checked = 0; + for (int i = 0; i < 8; ++i) + { + std::ostringstream stream; + stream << "iconspsp" << i; + pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, stream.str(), RETRIEVE_MANAGE); + pspIcons[i]->SetHotSpot(16, 16); + } } int ActionStack::has(MTGAbility * ability) @@ -991,8 +1012,9 @@ void ActionStack::Fizzle(Interruptible * action) void ActionStack::Render() { - float x0 = 250; - float y0 = 30; + static const float kSpacer = 8; + static const float x0 = 250; + static const float y0 = 0; float width = 200; float height = 90; float currenty = y0 + 5; @@ -1019,51 +1041,59 @@ void ActionStack::Render() //float xScale = width / back->mWidth; //float yScale = height / back->mHeight; renderer->FillRoundRect(x0 + 16, y0 + 16, width + 2, height + 2, 10, ARGB(128,0,0,0)); - renderer->FillRoundRect(x0 - 5, y0 - 5, width + 2, height + 2, 10, ARGB(200,0,0,0)); + renderer->FillRoundRect(x0 - 5, y0, width + 2, height + 2, 10, ARGB(200,0,0,0)); //renderer->RenderQuad(back,x0,y0,0,xScale, yScale); - renderer->DrawRoundRect(x0 - 5, y0 - 5, width + 2, height + 2, 10, ARGB(255,255,255,255)); + renderer->DrawRoundRect(x0 - 5, y0, width + 2, height + 2, 10, ARGB(255,255,255,255)); + + std::ostringstream stream; + // 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. + + // Mootpoint 01/12/2011: draw the interrupt text first, at the top. Offset the rest of the + // unresolved stack effects down so that they don't collide with the interrupt text. + if (options[Options::INTERRUPT_SECONDS].number == 0) + stream << "Interrupt?"; + else + stream << "Interrupt? " << static_cast(timer); + + mFont->DrawString(stream.str(), x0 + 5, currenty); + + static const float kIconVerticalOffset = 24; + if (mCount > 1) + { + renderer->RenderQuad(pspIcons[7], x0 + 10, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize); + mFont->DrawString(kInterruptString, x0 + 19, kIconVerticalOffset - 6); + + renderer->RenderQuad(pspIcons[4], x0 + 97, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize); + mFont->DrawString(kNoString, x0 + 106, kIconVerticalOffset - 6); + + renderer->RenderQuad(pspIcons[6], x0 + 145, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize); + mFont->DrawString(kNoToAllString, x0 + 154, kIconVerticalOffset - 6); + } + else + { + renderer->RenderQuad(pspIcons[7], x0 + 40, kIconVerticalOffset, 0, kGamepadIconSize, kGamepadIconSize); + mFont->DrawString(kInterruptString, x0 + 49, kIconVerticalOffset - 6); + + renderer->RenderQuad(pspIcons[4], x0 + 140, kIconVerticalOffset - 6, 0, kGamepadIconSize, kGamepadIconSize); + mFont->DrawString(kNoString, x0 + 146, kIconVerticalOffset - 6); + } + + currenty += kIconVerticalOffset + kSpacer; for (int i = 0; i < mCount; i++) { Interruptible * current = (Interruptible *) mObjects[i]; if (current && current->state == NOT_RESOLVED) { - current->x = x0 + 5; - if (i != mCount - 1) - { - current->y = currenty; - currenty += current->mHeight; - } - else - { - current->y = currenty + 40; - currenty += current->mHeight + 40; - } + current->x = x0; + current->y = currenty; current->Render(); + + currenty += current->mHeight; } } - - char buffer[200]; - // 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 (options[Options::INTERRUPT_SECONDS].number == 0) - sprintf(buffer, "%s", _("Interrupt?").c_str()); - else - sprintf(buffer, "%s %i", _("Interrupt?").c_str(), static_cast (timer)); - - //WALDORF - removed all the unnecessary math. just display the prompt at the - // top of the box. - mFont->DrawString(buffer, x0 + 5, y0); - - if (mCount > 1) - sprintf(buffer, "%s", _("X Interrupt - 0 No - [] No to All").c_str()); - else - sprintf(buffer, "%s", _("X Interrupt - 0 No").c_str()); - - // 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, y0 + 14); } else if (mode == ACTIONSTACK_TARGET && modal) { diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 9f4bb4037..4b285442a 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -26,6 +26,13 @@ float GameStateShop::_y3[] = { 164, 205, 257, 184, 180, 170, 219, 212, 195, 251, float GameStateShop::_x4[] = { 76, 90, 65, 131, 171, 221, 123, 187, 225, 141, 237 }; float GameStateShop::_y4[] = { 169, 188, 250, 182, 182, 168, 220, 208, 198, 259, 245 }; +namespace +{ + float kGamepadIconSize = 0.5f; + const std::string kOtherCardsString(": Other cards"); +} + + BoosterDisplay::BoosterDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener, TargetChooser * tc, int nb_displayed_items) : CardDisplay(id, game, x, y, listener, tc, nb_displayed_items) @@ -134,6 +141,14 @@ void GameStateShop::Start() mBack = WResourceManager::Instance()->GetQuad("back"); + for (int i = 0; i < 8; ++i) + { + std::ostringstream stream; + stream << "iconspsp" << i; + pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, stream.str(), RETRIEVE_MANAGE); + pspIcons[i]->SetHotSpot(16, 16); + } + JRenderer::GetInstance()->EnableVSync(true); taskList = NULL; @@ -718,13 +733,14 @@ void GameStateShop::Render() //Render the info bar r->FillRect(0, SCREEN_HEIGHT - 17, SCREEN_WIDTH, 17, ARGB(128,0,0,0)); - char c[512]; - sprintf(c, _("credits: %i").c_str(), playerdata->credits); + std::ostringstream stream; + stream << "Credits: " << playerdata->credits; mFont->SetColor(ARGB(255,255,255,255)); - mFont->DrawString(c, 5, SCREEN_HEIGHT - 12); - sprintf(c, "%s", _("[]:other cards").c_str()); - float len = 4 + mFont->GetStringWidth(c); - mFont->DrawString(c, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14); + mFont->DrawString(stream.str(), 5, SCREEN_HEIGHT - 14); + + float len = 4 + mFont->GetStringWidth(kOtherCardsString.c_str()); + r->RenderQuad(pspIcons[6], SCREEN_WIDTH - len - kGamepadIconSize - 10, SCREEN_HEIGHT - 8, 0, kGamepadIconSize, kGamepadIconSize); + mFont->DrawString(kOtherCardsString, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14); mFont->SetColor(ARGB(255,255,255,0)); mFont->DrawString(descPurchase(bigSync.getPos()).c_str(), SCREEN_WIDTH / 2, SCREEN_HEIGHT - 14, JGETEXT_CENTER);