From 12fe9305a6a2fd7fd75e12a2a28a0f137cadbf9d Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Sat, 23 Oct 2010 00:11:54 +0200 Subject: [PATCH] Further unification of dialog API, all dialogs now have an open() method which updates gui content and makes it visible. --- apps/openmw/mwgui/class.cpp | 10 +++++++--- apps/openmw/mwgui/class.hpp | 4 +++- apps/openmw/mwgui/review.cpp | 6 ++++++ apps/openmw/mwgui/review.hpp | 3 ++- apps/openmw/mwgui/window_manager.cpp | 10 ++++------ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 51b17b286..592ca1f39 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -41,6 +41,11 @@ GenerateClassResultDialog::GenerateClassResultDialog(MWWorld::Environment& envir okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); } +void GenerateClassResultDialog::open() +{ + setVisible(true); +} + std::string GenerateClassResultDialog::getClassId() const { return className->getCaption(); @@ -363,7 +368,7 @@ void InfoBoxDialog::setButtons(ButtonList &buttons) } } -void InfoBoxDialog::update() +void InfoBoxDialog::open() { // Fix layout layoutVertically(textBox, 4); @@ -371,6 +376,7 @@ void InfoBoxDialog::update() layoutVertically(mMainWidget, 4 + 6); center(); + setVisible(true); } int InfoBoxDialog::getChosenButton() const @@ -417,8 +423,6 @@ ClassChoiceDialog::ClassChoiceDialog(MWWorld::Environment& environment) buttons.push_back(mw->getGameSettingString("sClassChoiceMenu3", "")); buttons.push_back(mw->getGameSettingString("sBack", "")); setButtons(buttons); - - update(); } /* CreateClassDialog */ diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 7f50a8b3e..3a8672f1f 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -34,7 +34,7 @@ namespace MWGui std::string getText() const; void setButtons(ButtonList &buttons); - void update(); + void open(); int getChosenButton() const; // Events @@ -83,6 +83,8 @@ namespace MWGui std::string getClassId() const; void setClassId(const std::string &classId); + void open(); + // Events typedef delegates::CDelegate0 EventHandle_Void; diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 6315ce485..4e202c2d2 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -95,6 +95,12 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment, MyGUI::IntSize gam okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); } +void ReviewDialog::open() +{ + updateSkillArea(); + setVisible(true); +} + void ReviewDialog::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos) { int diff = lastPos - pos; diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index fc17ecf65..9f97eb14d 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -41,7 +41,7 @@ namespace MWGui void configureSkills(const SkillList& major, const SkillList& minor); void setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat& value); - void updateSkillArea(); + void open(); // Events typedef delegates::CDelegate0 EventHandle_Void; @@ -74,6 +74,7 @@ namespace MWGui MyGUI::WidgetPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); + void updateSkillArea(); void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos); void onWindowResize(MyGUI::WidgetPtr window); diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 6e588406e..03a8dc626 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -198,6 +198,7 @@ void WindowManager::updateVisible() removeDialog(classChoiceDialog); classChoiceDialog = new ClassChoiceDialog(environment); classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice); + classChoiceDialog->open(); return; } @@ -277,11 +278,9 @@ void WindowManager::updateVisible() reviewDialog->configureSkills(playerMajorSkills, playerMinorSkills); } - reviewDialog->updateSkillArea(); - reviewDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onReviewDialogDone); reviewDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onReviewDialogBack); - reviewDialog->setVisible(true); + reviewDialog->open(); return; } @@ -585,7 +584,7 @@ void WindowManager::showClassQuestionDialog() generateClassResultDialog->setClassId(generateClass); generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack); generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone); - generateClassResultDialog->setVisible(true); + generateClassResultDialog->open(); return; } @@ -605,9 +604,8 @@ void WindowManager::showClassQuestionDialog() buttons.push_back(steps[generateClassStep].buttons[1]); buttons.push_back(steps[generateClassStep].buttons[2]); generateClassQuestionDialog->setButtons(buttons); - generateClassQuestionDialog->update(); generateClassQuestionDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassQuestionChosen); - generateClassQuestionDialog->setVisible(true); + generateClassQuestionDialog->open(); } void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)