Avoid more conflicts. We could now do unit builds...

and make the linker put every data element and function into its own section.
On linktime, we can output every discarded section and get a list of dead
code (for that build).
This commit is contained in:
Tobias Loose
2013-11-23 17:04:24 +01:00
parent 3e94de985f
commit e0428ac7b0
6 changed files with 81 additions and 81 deletions

View File

@@ -7,42 +7,42 @@
#include "Closest.cpp"
#include "GameObserver.h"
struct Left: public Exp
struct CardSelectorLeft: public Exp
{
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
{
return ref->x - test->x > fabs(ref->y - test->y);
}
};
struct Right: public Exp
struct CardSelectorRight: public Exp
{
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
{
return test->x - ref->x > fabs(ref->y - test->y);
}
};
struct Up: public Exp
struct CardSelectorUp: public Exp
{
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
{
return ref->y - test->y > fabs(ref->x - test->x);
}
};
struct Down: public Exp
struct CardSelectorDown: public Exp
{
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
{
return test->y - ref->y > fabs(ref->x - test->x);
}
};
struct Diff: public Exp
struct CardSelectorDiff: public Exp
{
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
{
return ref != test;
}
};
struct True: public Exp
struct CardSelectorTrue: public Exp
{
static inline bool test(CardSelector::Target*, CardSelector::Target*)
{
@@ -94,7 +94,7 @@ void CardSelector::Remove(CardSelector::Target* card)
CardView* c = dynamic_cast<CardView*> (active);
if (c)
c->zoom = 1.0f;
active = closest<Diff> (cards, limitor, active);
active = closest<CardSelectorDiff> (cards, limitor, active);
c = dynamic_cast<CardView*> (active);
if (c)
c->zoom = 1.4f;
@@ -120,7 +120,7 @@ CardSelector::Target* CardSelector::fetchMemory(SelectorMemory& memory)
}
// We come here if the card is not in the selector any more, or if
// it is there but it is now refused by the limitor.
return closest<True> (cards, limitor, memory.x, memory.y);
return closest<CardSelectorTrue> (cards, limitor, memory.x, memory.y);
}
void CardSelector::Push()
@@ -182,7 +182,7 @@ bool CardSelector::CheckUserInput(JButton key)
if(!jge) return false;
if(jge->GetLeftClickCoordinates(x, y))
{
active = closest<True> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
active = closest<CardSelectorTrue> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
}
switch (key)
@@ -196,16 +196,16 @@ bool CardSelector::CheckUserInput(JButton key)
goto switch_active;
break;
case JGE_BTN_LEFT:
active = closest<Left> (cards, limitor, active);
active = closest<CardSelectorLeft> (cards, limitor, active);
break;
case JGE_BTN_RIGHT:
active = closest<Right> (cards, limitor, active);
active = closest<CardSelectorRight> (cards, limitor, active);
break;
case JGE_BTN_UP:
active = closest<Up> (cards, limitor, active);
active = closest<CardSelectorUp> (cards, limitor, active);
break;
case JGE_BTN_DOWN:
active = closest<Down> (cards, limitor, active);
active = closest<CardSelectorDown> (cards, limitor, active);
break;
case JGE_BTN_CANCEL:
mDrawMode = (mDrawMode + 1) % DrawMode::kNumDrawModes;

View File

@@ -13,16 +13,16 @@
#include <iomanip>
namespace
namespace DeckMenuConst
{
const float kVerticalMargin = 16;
const float kHorizontalMargin = 20;
const float kLineHeight = 25;
const float kDescriptionVerticalBoxPadding = -5;
const float kDescriptionVerticalBoxPadding = -5;
const float kDescriptionHorizontalBoxPadding = 5;
const float kDefaultFontScale = 1.0f;
const float kVerticalScrollSpeed = 7.0f;
const float kVerticalScrollSpeed = 7.0f;
const int DETAILED_INFO_THRESHOLD = 20;
const int kDetailedInfoButtonId = 10000;
@@ -52,8 +52,8 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
titleY = 15;
titleWidth = 180; // width of inner box of title
descX = 260 + kDescriptionHorizontalBoxPadding;
descY = 100 + kDescriptionVerticalBoxPadding;
descX = 260 + DeckMenuConst::kDescriptionHorizontalBoxPadding;
descY = 100 + DeckMenuConst::kDescriptionVerticalBoxPadding;
descHeight = 145;
descWidth = 195;
@@ -73,11 +73,11 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
float scrollerWidth = 200.0f;
float scrollerHeight = 28.0f;
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, kVerticalScrollSpeed);
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, DeckMenuConst::kVerticalScrollSpeed);
mAutoTranslate = true;
maxItems = 6;
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
mHeight = 2 * DeckMenuConst::kVerticalMargin + (maxItems * DeckMenuConst::kLineHeight);
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
title = _(_title);
@@ -94,7 +94,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
else
titleFontScale = SCALE_NORMAL;
mSelectionTargetY = selectionY = kVerticalMargin;
mSelectionTargetY = selectionY = DeckMenuConst::kVerticalMargin;
if (NULL == stars)
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get()));
@@ -106,7 +106,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
float stringWidth = descriptionFont->GetStringWidth(detailedInfoString.c_str());
float boxStartX = detailedInfoBoxX - stringWidth / 2 + 20;
dismissButton = NEW InteractiveButton( this, kDetailedInfoButtonId, Fonts::MAIN_FONT, detailedInfoString, boxStartX, detailedInfoBoxY, JGE_BTN_CANCEL);
dismissButton = NEW InteractiveButton( this, DeckMenuConst::kDetailedInfoButtonId, Fonts::MAIN_FONT, detailedInfoString, boxStartX, detailedInfoBoxY, JGE_BTN_CANCEL);
JGuiController::Add(dismissButton, true);
updateScroller();
@@ -181,7 +181,7 @@ bool DeckMenu::showDetailsScreen()
if (currentMenuItem)
{
if (mAlwaysShowDetailsButton) return true;
if (mShowDetailsScreen && currentMenuItem->getVictories() > DETAILED_INFO_THRESHOLD) return true;
if (mShowDetailsScreen && currentMenuItem->getVictories() > DeckMenuConst::DETAILED_INFO_THRESHOLD) return true;
}
return false;
@@ -189,10 +189,10 @@ bool DeckMenu::showDetailsScreen()
void DeckMenu::initMenuItems()
{
float sY = mY + kVerticalMargin;
float sY = mY + DeckMenuConst::kVerticalMargin;
for (int i = startId; i < mCount; ++i)
{
float y = mY + kVerticalMargin + i * kLineHeight;
float y = mY + DeckMenuConst::kVerticalMargin + i * DeckMenuConst::kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
currentMenuItem->Relocate(mX, y);
if (currentMenuItem->hasFocus()) sY = y;
@@ -248,7 +248,7 @@ void DeckMenu::Render()
{
if (i > mCount - 1) break;
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
if (currentMenuItem->getY() - kLineHeight * startId < mY + height - kLineHeight + 7)
if (currentMenuItem->getY() - DeckMenuConst::kLineHeight * startId < mY + height - DeckMenuConst::kLineHeight + 7)
{
// only load stats for visible items in the list
DeckMetaData* metaData = currentMenuItem->getMetaData();
@@ -309,7 +309,7 @@ void DeckMenu::Render()
}
else // reset the font color to be slightly muted
mFont->SetColor(ARGB(150,255,255,255));
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
currentMenuItem->RenderWithOffset(-DeckMenuConst::kLineHeight * startId);
}
}
@@ -342,8 +342,8 @@ void DeckMenu::Update(float dt)
selectionT += 3 * dt;
selectionY += (mSelectionTargetY - selectionY) * 8 * dt;
float starsX = starsOffsetX + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2);
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId;
float starsX = starsOffsetX + ((mWidth - 2 * DeckMenuConst::kHorizontalMargin) * (1 + cos(selectionT)) / 2);
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + DeckMenuConst::kLineHeight / 2 - DeckMenuConst::kLineHeight * startId;
stars->MoveTo(starsX, starsY);
//
@@ -371,7 +371,7 @@ void DeckMenu::Update(float dt)
void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, DeckMetaData * deckMetaData)
{
DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0,
mY + kVerticalMargin + mCount * kLineHeight, (mCount == 0), mAutoTranslate, deckMetaData);
mY + DeckMenuConst::kVerticalMargin + mCount * DeckMenuConst::kLineHeight, (mCount == 0), mAutoTranslate, deckMetaData);
Translator * t = Translator::GetInstance();
map<string, string>::iterator it = t->deckValues.find(text);
string deckDescription = "";
@@ -384,7 +384,7 @@ void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, Deck
menuItem->setDescription(deckDescription);
JGuiController::Add(menuItem);
if (mCount <= maxItems) mHeight += kLineHeight;
if (mCount <= maxItems) mHeight += DeckMenuConst::kLineHeight;
if (forceFocus)
{

View File

@@ -21,7 +21,7 @@ enum ENUM_AWARDS_STATE
};
namespace GameStateAwardsConstants
namespace GameStateAwardsConst
{
const int kBackToTrophiesID = 2;
const int kBackToMainMenuID = 1;
@@ -186,8 +186,8 @@ void GameStateAwards::Update(float dt)
SAFE_DELETE(menu);
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170);
if (mState == STATE_DETAILS)
menu->Add(GameStateAwardsConstants::kBackToTrophiesID, "Back to Trophies");
menu->Add(GameStateAwardsConstants::kBackToMainMenuID, "Back to Main Menu");
menu->Add(GameStateAwardsConst::kBackToTrophiesID, "Back to Trophies");
menu->Add(GameStateAwardsConst::kBackToMainMenuID, "Back to Main Menu");
menu->Add(kCancelMenuID, "Cancel");
break;
case JGE_BTN_PREV:
@@ -359,11 +359,11 @@ void GameStateAwards::ButtonPressed(int controllerId, int controlId)
if (controllerId == EXIT_AWARDS_MENU)
switch (controlId)
{
case GameStateAwardsConstants::kBackToMainMenuID:
case GameStateAwardsConst::kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
showMenu = false;
break;
case GameStateAwardsConstants::kBackToTrophiesID:
case GameStateAwardsConst::kBackToTrophiesID:
mState = STATE_LISTVIEW;
SAFE_DELETE(detailview);
showMenu = false;

View File

@@ -7,7 +7,7 @@
#include "SimplePad.h"
#include "Translate.h"
namespace GameStateOptionsConstants
namespace GameStateOptionsConst
{
const int kSaveAndBackToMainMenuID = 1;
const int kBackToMainMenuID = 2;
@@ -77,7 +77,7 @@ void GameStateOptions::Start()
optionsList->Add(NEW WGuiSplit(cPrf, cThm));
optionsList->Add(cStyle);
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, GameStateOptionsConstants::kNewProfileID, this));
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, GameStateOptionsConst::kNewProfileID, this));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
@@ -117,8 +117,8 @@ void GameStateOptions::Start()
optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -102, this, Fonts::MAIN_FONT, 50, 170);
optionsMenu->Add(GameStateOptionsConstants::kBackToMainMenuID, "Back to Main Menu");
optionsMenu->Add(GameStateOptionsConstants::kSaveAndBackToMainMenuID, "Save And Exit");
optionsMenu->Add(GameStateOptionsConst::kBackToMainMenuID, "Back to Main Menu");
optionsMenu->Add(GameStateOptionsConst::kSaveAndBackToMainMenuID, "Save And Exit");
optionsMenu->Add(kCancelMenuID, "Cancel");
optionsTabs->Entering(JGE_BTN_NONE);
@@ -284,21 +284,21 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
if (controllerId == -102)
switch (controlId)
{
case GameStateOptionsConstants::kSaveAndBackToMainMenuID:
case GameStateOptionsConst::kSaveAndBackToMainMenuID:
mState = SAVE;
break;
//Set Audio volume
case GameStateOptionsConstants::kBackToMainMenuID:
case GameStateOptionsConst::kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
break;
case kCancelMenuID:
mState = SHOW_OPTIONS;
break;
case GameStateOptionsConstants::kNewProfileID:
case GameStateOptionsConst::kNewProfileID:
options.keypadStart("", &newProfile);
options.keypadTitle("New Profile");
break;
case GameStateOptionsConstants::kReloadID:
case GameStateOptionsConst::kReloadID:
mReload = true;
break;
}

View File

@@ -16,21 +16,21 @@ const float kZoom_level1 = 1.4f;
const float kZoom_level2 = 2.2f;
const float kZoom_level3 = 2.7f;
struct True: public Exp
struct GuiCombatTrue: public Exp
{
static inline bool test(DamagerDamaged*, DamagerDamaged*)
{
return true;
}
};
struct Left: public Exp
struct GuiCombatLeft: public Exp
{
static inline bool test(DamagerDamaged* ref, DamagerDamaged* test)
{
return ref->y == test->y && ref->x > test->x && test->show;
}
};
struct Right: public Exp
struct GuiCombatRight: public Exp
{
static inline bool test(DamagerDamaged* ref, DamagerDamaged* test)
{
@@ -217,7 +217,7 @@ void GuiCombat::shiftLeft()
case ATK:
{
DamagerDamaged* old = active;
active = closest<Left> (attackers, NULL, static_cast<AttackerDamaged*> (active));
active = closest<GuiCombatLeft> (attackers, NULL, static_cast<AttackerDamaged*> (active));
activeAtk = static_cast<AttackerDamaged*> (active);
if (old != active)
{
@@ -231,7 +231,7 @@ void GuiCombat::shiftLeft()
case BLK:
{
DamagerDamaged* old = active;
active = closest<Left> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
active = closest<GuiCombatLeft> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
if (old != active)
{
if (old)
@@ -255,7 +255,7 @@ void GuiCombat::shiftRight( DamagerDamaged* oldActive )
case BLK:
{
DamagerDamaged* old = active;
active = closest<Right> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
active = closest<GuiCombatRight> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
if (old != active)
{
if (old)
@@ -268,7 +268,7 @@ void GuiCombat::shiftRight( DamagerDamaged* oldActive )
case ATK:
{
DamagerDamaged* old = active;
active = closest<Right> (attackers, NULL, static_cast<AttackerDamaged*> (active));
active = closest<GuiCombatRight> (attackers, NULL, static_cast<AttackerDamaged*> (active));
if (active == oldActive)
{
active = activeAtk = NULL;
@@ -321,7 +321,7 @@ bool GuiCombat::CheckUserInput(JButton key)
// position selected card
if (BLK == cursor_pos)
{
DamagerDamaged* selectedCard = closest<True> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
DamagerDamaged* selectedCard = closest<GuiCombatTrue> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
// find the index into the vector where the current selected card is.
int c1 = 0, c2 = 0;
int i = 0;

View File

@@ -6,7 +6,7 @@
#include "GameApp.h"
#include "Translate.h"
namespace
namespace SimpleMenuConst
{
const float kPoleWidth = 7;
const float kVerticalMargin = 20;
@@ -38,7 +38,7 @@ SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGui
{
autoTranslate = true;
isMultipleChoice = false;
mHeight = 2 * kVerticalMargin;
mHeight = 2 * SimpleMenuConst::kVerticalMargin;
mWidth = 0;
mX = x;
mY = y;
@@ -48,7 +48,7 @@ SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGui
selectionT = 0;
timeOpen = 0;
mClosed = false;
selectionTargetY = selectionY = y + kVerticalMargin;
selectionTargetY = selectionY = y + SimpleMenuConst::kVerticalMargin;
if(resourceManager)
{
@@ -61,7 +61,7 @@ SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGui
spadeL = resourceManager->RetrieveQuad("spade_ul.png", 0, 0, 0, 0, "spade_ul", RETRIEVE_MANAGE);
spadeR = resourceManager->RetrieveQuad("spade_ur.png", 0, 0, 0, 0, "spade_ur", RETRIEVE_MANAGE);
jewel.reset(NEW JQuad(jewelTex, 1, 1, 3, 3));
side = resourceManager->RetrieveQuad("menuside.png", 1, 1, 1, kPoleWidth, "menuside", RETRIEVE_MANAGE);
side = resourceManager->RetrieveQuad("menuside.png", 1, 1, 1, SimpleMenuConst::kPoleWidth, "menuside", RETRIEVE_MANAGE);
stars = NEW hgeParticleSystem(resourceManager->RetrievePSI("stars.psi", resourceManager->GetQuad("stars").get()));
@@ -78,16 +78,16 @@ void SimpleMenu::drawHorzPole(float x, float y, float width)
{
JRenderer* renderer = JRenderer::GetInstance();
float leftXOffset = (spadeR->mWidth - kPoleWidth) / 2;
float leftXOffset = (spadeR->mWidth - SimpleMenuConst::kPoleWidth) / 2;
float rightXOffset = leftXOffset;
float yOffset = leftXOffset;
if (spadeR->mWidth != spadeR->mHeight)
{
//We have a weird case to deal with in the "Classic" theme, the spades graphics need to be aligned specifically,
// While the ones in the "Final Saga" theme need to be centered
leftXOffset = kSpadeWidthOffset;
yOffset = kSpadeHeightOffset;
rightXOffset = kSpadeRightBottomOffset;
leftXOffset = SimpleMenuConst::kSpadeWidthOffset;
yOffset = SimpleMenuConst::kSpadeHeightOffset;
rightXOffset = SimpleMenuConst::kSpadeRightBottomOffset;
}
renderer->RenderQuad(side.get(), x, y, 0, width);
@@ -104,23 +104,23 @@ void SimpleMenu::drawVertPole(float x, float y, float height)
{
JRenderer* renderer = JRenderer::GetInstance();
float xOffset = (spadeR->mWidth - kPoleWidth) / 2;
float xOffset = (spadeR->mWidth - SimpleMenuConst::kPoleWidth) / 2;
float topYOffset = xOffset;
float bottomYOffset = xOffset;
if (spadeR->mWidth != spadeR->mHeight)
{
//We have a weird case to deal with in the "Classic" theme, the spades graphics need to be aligned specifically,
// While the ones in the "Final Saga" theme need to be centered
xOffset = kSpadeHeightOffset;
topYOffset = kSpadeWidthOffset;
bottomYOffset = kSpadeRightBottomOffset;
xOffset = SimpleMenuConst::kSpadeHeightOffset;
topYOffset = SimpleMenuConst::kSpadeWidthOffset;
bottomYOffset = SimpleMenuConst::kSpadeRightBottomOffset;
}
renderer->RenderQuad(side.get(), x + kPoleWidth, y, M_PI / 2, height);
renderer->RenderQuad(side.get(), x + SimpleMenuConst::kPoleWidth, y, M_PI / 2, height);
spadeR->SetHFlip(true);
spadeL->SetHFlip(false);
renderer->RenderQuad(spadeR.get(), x + kPoleWidth + xOffset, y - topYOffset, M_PI / 2);
renderer->RenderQuad(spadeL.get(), x + kPoleWidth + xOffset, y + height - bottomYOffset, M_PI / 2);
renderer->RenderQuad(spadeR.get(), x + SimpleMenuConst::kPoleWidth + xOffset, y - topYOffset, M_PI / 2);
renderer->RenderQuad(spadeL.get(), x + SimpleMenuConst::kPoleWidth + xOffset, y + height - bottomYOffset, M_PI / 2);
renderer->RenderQuad(jewel.get(), x - 1, y - 1);
renderer->RenderQuad(jewel.get(), x - 1, y + height - 1);
@@ -133,7 +133,7 @@ void SimpleMenu::Render()
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
if (0 == mWidth)
{
float sY = mY + kVerticalMargin;
float sY = mY + SimpleMenuConst::kVerticalMargin;
for (int i = 0; i < mCount; ++i)
{
@@ -146,7 +146,7 @@ void SimpleMenu::Render()
if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str())))
mWidth = titleFont->GetStringWidth(title.c_str());
titleFont->SetScale(scaleFactor);
mWidth += 2 * kHorizontalMargin;
mWidth += 2 * SimpleMenuConst::kHorizontalMargin;
if (mCenterHorizontal)
mX = (SCREEN_WIDTH_F - mWidth) / 2;
@@ -156,7 +156,7 @@ void SimpleMenu::Render()
for (int i = 0; i < mCount; ++i)
{
float y = mY + kVerticalMargin + i * kLineHeight;
float y = mY + SimpleMenuConst::kVerticalMargin + i * SimpleMenuConst::kLineHeight;
SimpleMenuItem * smi = static_cast<SimpleMenuItem*> (mObjects[i]);
smi->Relocate(mX + mWidth / 2, y);
if (smi->hasFocus()) sY = y;
@@ -171,7 +171,7 @@ void SimpleMenu::Render()
float height = mHeight;
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
float heightPadding = kLineHeight/2; // this to reduce the bottom padding of the menu
float heightPadding = SimpleMenuConst::kLineHeight/2; // this to reduce the bottom padding of the menu
renderer->FillRect(mX, mY, mWidth, height - heightPadding, ARGB(180,0,0,0));
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
@@ -200,8 +200,8 @@ void SimpleMenu::Render()
{
if (i > mCount - 1) break;
SimpleMenuItem *currentMenuItem = static_cast<SimpleMenuItem*>(mObjects[i]);
float currentY = currentMenuItem->getY() - kLineHeight * startId;
float menuBottomEdge = mY + height - kLineHeight + 7;
float currentY = currentMenuItem->getY() - SimpleMenuConst::kLineHeight * startId;
float menuBottomEdge = mY + height - SimpleMenuConst::kLineHeight + 7;
if (currentY < menuBottomEdge)
{
if (currentMenuItem->hasFocus())
@@ -214,7 +214,7 @@ void SimpleMenu::Render()
{
mFont->SetColor(ARGB(150,255,255,255));
}
(static_cast<SimpleMenuItem*> (mObjects[i]))->RenderWithOffset(-kLineHeight * startId);
(static_cast<SimpleMenuItem*> (mObjects[i]))->RenderWithOffset(-SimpleMenuConst::kLineHeight * startId);
}
mFont->SetScale(SCALE_NORMAL);
}
@@ -244,8 +244,8 @@ bool SimpleMenu::CheckUserInput(JButton key)
if (mObjects.size())
{
float top, left;
float menuTopEdge = mY + kLineHeight;
float menuBottomEdge = mY + mHeight - (kLineHeight/2);
float menuTopEdge = mY + SimpleMenuConst::kLineHeight;
float menuBottomEdge = mY + mHeight - (SimpleMenuConst::kLineHeight/2);
if (y < menuTopEdge)
n = (mCurr - 1) > 0 ? mCurr -1 : 0;
@@ -257,7 +257,7 @@ bool SimpleMenu::CheckUserInput(JButton key)
{
if (mObjects[i]->getTopLeft(top, left))
{
if ( (y > top) && (y <= (top + kLineHeight)) )
if ( (y > top) && (y <= (top + SimpleMenuConst::kLineHeight)) )
n = i;
}
}
@@ -308,8 +308,8 @@ void SimpleMenu::Update(float dt)
selectionT += 3 * dt;
selectionY += (selectionTargetY - selectionY) * 8 * dt;
if(stars)
stars->MoveTo(mX + kHorizontalMargin + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2), selectionY + 5 * cos(
selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId);
stars->MoveTo(mX + SimpleMenuConst::kHorizontalMargin + ((mWidth - 2 * SimpleMenuConst::kHorizontalMargin) * (1 + cos(selectionT)) / 2), selectionY + 5 * cos(
selectionT * 2.35f) + SimpleMenuConst::kLineHeight / 2 - SimpleMenuConst::kLineHeight * startId);
if (timeOpen < 0)
{
timeOpen += dt * 10;
@@ -330,12 +330,12 @@ void SimpleMenu::Update(float dt)
void SimpleMenu::Add(int id, const char * text, string desc, bool forceFocus)
{
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + kVerticalMargin + mCount * kLineHeight,
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + SimpleMenuConst::kVerticalMargin + mCount * SimpleMenuConst::kLineHeight,
(mCount == 0), autoTranslate);
smi->setDescription(desc);
JGuiController::Add(smi);
if (mCount <= maxItems) mHeight += kLineHeight;
if (mCount <= maxItems) mHeight += SimpleMenuConst::kLineHeight;
if (forceFocus)
{
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);