From e5bbbb358f8ae7b6a87c9a4c37f2b6ff1f554414 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Fri, 28 Aug 2009 01:58:57 +0000 Subject: [PATCH] J : * Fix a few compilation issues. --- projects/mtg/include/OptionItem.h | 4 ++-- projects/mtg/src/OptionItem.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/projects/mtg/include/OptionItem.h b/projects/mtg/include/OptionItem.h index 6b598abfd..237cb8040 100644 --- a/projects/mtg/include/OptionItem.h +++ b/projects/mtg/include/OptionItem.h @@ -105,7 +105,7 @@ class OptionSelect:public OptionItem{ virtual void Render(); virtual void setData(); virtual void initSelections(); - virtual void updateValue(){value++; if (value > selections.size() - 1 || value < 0) value=0;}; + virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;}; virtual ostream& toString(ostream& out) const; }; @@ -138,7 +138,7 @@ private: JTexture * mAvatarTex; GameApp * app; string preview; - int initialValue; + size_t initialValue; }; class OptionsList{ diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index 0acd7de4e..0aaaa45b7 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -117,7 +117,7 @@ void OptionSelect::Render(){ renderer->FillRoundRect(x-5,y-2,width-x-5,height,2,options[Metrics::OPTION_ITEM_FC].asColor(ARGB(150,50,50,50))); mFont->DrawString(displayValue.c_str(),x,y); - if(value >= 0 && value < selections.size()) + if (value < selections.size()) mFont->DrawString(selections[value].c_str(),width-10,y,JGETEXT_RIGHT); else mFont->DrawString("Unset",width-10,y,JGETEXT_RIGHT); @@ -126,7 +126,7 @@ void OptionSelect::Render(){ void OptionSelect::setData() { if(id == "") return; - if(value >= 0 && value < selections.size()) + if (value < selections.size()) options[id] = GameOption(selections[value]); } @@ -207,7 +207,7 @@ OptionProfile::OptionProfile(GameApp * _app): OptionDirectory(RESPATH"/profiles" void OptionProfile::updateValue(){ value++; - if (value > selections.size() - 1 || value < 0) + if (value > selections.size() - 1) value=0; populate(); @@ -216,7 +216,7 @@ void OptionProfile::updateValue(){ void OptionProfile::populate(){ JRenderer * renderer = JRenderer::GetInstance(); string temp = options[Options::ACTIVE_PROFILE].str; - if(value < 0 || value >= selections.size()){ //TODO fail gracefully. + if (value >= selections.size()){ //TODO fail gracefully. return; } @@ -304,7 +304,7 @@ bool OptionProfile::Leaving(){ void OptionProfile::cancelSubmode() { - if(initialValue < 0 || initialValue >= selections.size()) + if (initialValue >= selections.size()) return; options[Options::ACTIVE_PROFILE] = selections[initialValue]; @@ -313,7 +313,7 @@ void OptionProfile::cancelSubmode() } void OptionProfile::acceptSubmode() { - if(value < 0 || value >= selections.size()) + if (value >= selections.size()) return; options[Options::ACTIVE_PROFILE] = selections[value]; @@ -775,4 +775,4 @@ return out << "OptionString ::: displayValue : " << displayValue << " ; value : " << value << " ; hasFocus : " << hasFocus << " ; x,y : " << x << "," << y; -} \ No newline at end of file +}