From 5fd233c72bbfcaa27257f688346f2d1e1c0873ab Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sat, 6 Oct 2012 19:01:13 +0000 Subject: [PATCH] bugfix for buttons in message boxes. Init is init and not reuse ... --- source/glest_game/facilities/components.cpp | 20 +++++++------------- source/glest_game/facilities/components.h | 1 + 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index 0903bcbd..b63a4c56 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -492,6 +492,10 @@ GraphicMessageBox::GraphicMessageBox(std::string containerName, std::string objN GraphicMessageBox::~GraphicMessageBox(){ //remove buttons + removeButtons(); +} + +void GraphicMessageBox::removeButtons(){ while(!buttons.empty()){ delete buttons.back(); buttons.pop_back(); @@ -500,23 +504,13 @@ GraphicMessageBox::~GraphicMessageBox(){ void GraphicMessageBox::init(const string &button1Str, const string &button2Str, int newWidth, int newHeight){ init(button1Str, newWidth, newHeight); - if(getButtonCount()>1){ - getButton(1)->setText(button2Str); - } - else{ - addButton(button2Str); - } + addButton(button2Str); } void GraphicMessageBox::init(const string &button1Str, int newWidth, int newHeight){ init(newWidth,newHeight); - - if(getButtonCount()>0){ - getButton(0)->setText(button1Str); - } - else{ - addButton(button1Str); - } + removeButtons(); + addButton(button1Str); } void GraphicMessageBox::init(int newWidth, int newHeight){ diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index 05d28177..cf7ad265 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -273,6 +273,7 @@ public: void init(const string &button1Str, const string &button2Str, int newWidth=-1,int newHeight=-1); void init(const string &button1Str, int newWidth=-1,int newHeight=-1); void init(int newWidth=-1,int newHeight=-1); + void removeButtons(); void addButton(const string &buttonStr, int width=-1,int height=-1); int getButtonCount() const {return buttons.size();}