From 232164bfb074163c9005db9a89cee1033bdc45cc Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Sun, 10 Oct 2010 01:52:08 +0200 Subject: [PATCH] Implemented the final dialog for Generate Class which shows the class that was chosen by the game based on the players chosen questions. The class is currently hardcoded to Acrobat. --- apps/openmw/mwgui/class.cpp | 54 ++++++++++++++++++ apps/openmw/mwgui/class.hpp | 34 +++++++++++ apps/openmw/mwgui/window_manager.cpp | 56 ++++++++++++++++--- apps/openmw/mwgui/window_manager.hpp | 5 ++ extern/mygui_3.0.1/CMakeLists.txt | 1 + ...w_chargen_generate_class_result_layout.xml | 28 ++++++++++ 6 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_chargen_generate_class_result_layout.xml diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index ec792daa4..032434298 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -12,6 +12,60 @@ using namespace MWGui; +/* GenerateClassResultDialog */ + +GenerateClassResultDialog::GenerateClassResultDialog(MWWorld::Environment& environment) + : Layout("openmw_chargen_generate_class_result_layout.xml") + , environment(environment) +{ + // Centre dialog + MyGUI::IntSize gameWindowSize = environment.mWindowManager->getGui()->getViewSize(); + MyGUI::IntCoord coord = mMainWidget->getCoord(); + coord.left = (gameWindowSize.width - coord.width)/2; + coord.top = (gameWindowSize.height - coord.height)/2; + mMainWidget->setCoord(coord); + + WindowManager *wm = environment.mWindowManager; + setText("ReflectT", wm->getGameSettingString("sMessageQuestionAnswer1", "")); + + getWidget(classImage, "ClassImage"); + getWidget(className, "ClassName"); + + // TODO: These buttons should be managed by a Dialog class + MyGUI::ButtonPtr backButton; + getWidget(backButton, "BackButton"); + backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked); + + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); +} + +std::string GenerateClassResultDialog::getClassId() const +{ + return className->getCaption(); +} + +void GenerateClassResultDialog::setClassId(const std::string &classId) +{ + currentClassId = classId; + classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); + ESMS::ESMStore &store = environment.mWorld->getStore(); + className->setCaption(store.classes.find(currentClassId)->name); +} + +// widget controls + +void GenerateClassResultDialog::onOkClicked(MyGUI::Widget* _sender) +{ + eventDone(); +} + +void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender) +{ + eventBack(); +} + /* PickClassDialog */ PickClassDialog::PickClassDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 38457b7e3..aaf63becb 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -75,6 +75,40 @@ namespace MWGui ClassChoiceDialog(MWWorld::Environment& environment); }; + class GenerateClassResultDialog : public OEngine::GUI::Layout + { + public: + GenerateClassResultDialog(MWWorld::Environment& environment); + + std::string getClassId() const; + void setClassId(const std::string &classId); + + // Events + typedef delegates::CDelegate0 EventHandle_Void; + + /** Event : Back button clicked.\n + signature : void method()\n + */ + EventHandle_Void eventBack; + + /** Event : Dialog finished, OK button clicked.\n + signature : void method()\n + */ + EventHandle_Void eventDone; + + protected: + void onOkClicked(MyGUI::Widget* _sender); + void onBackClicked(MyGUI::Widget* _sender); + + private: + MWWorld::Environment& environment; + + MyGUI::StaticImagePtr classImage; + MyGUI::StaticTextPtr className; + + std::string currentClassId; + }; + class PickClassDialog : public OEngine::GUI::Layout { public: diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 7c4e16bf7..da10f1dca 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -23,6 +23,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment , raceDialog(nullptr) , classChoiceDialog(nullptr) , generateClassQuestionDialog(nullptr) + , generateClassResultDialog(nullptr) , pickClassDialog(nullptr) , birthSignDialog(nullptr) , nameChosen(false) @@ -71,6 +72,7 @@ WindowManager::~WindowManager() delete raceDialog; delete classChoiceDialog; delete generateClassQuestionDialog; + delete generateClassResultDialog; delete pickClassDialog; delete birthSignDialog; } @@ -369,9 +371,6 @@ void WindowManager::onClassChoice(MyGUI::WidgetPtr, int _index) void WindowManager::showClassQuestionDialog() { - if (!generateClassQuestionDialog) - generateClassQuestionDialog = new InfoBoxDialog(environment); - struct Step { const char* text; @@ -390,17 +389,29 @@ void WindowManager::showClassQuestionDialog() }, } }; + if (generateClassStep == steps.size()) + { + // TODO: Calculate this in mechanics manager + generateClass = "acrobat"; + + if (generateClassResultDialog) + delete generateClassResultDialog; + generateClassResultDialog = new GenerateClassResultDialog(environment); + generateClassResultDialog->setClassId(generateClass); + generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack); + generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone); + generateClassResultDialog->setVisible(true); + return; + } + if (generateClassStep > steps.size()) { environment.mInputManager->setGuiMode(GM_Class); return; } - if (generateClassStep == steps.size()) - { - // TODO: Show selected class - environment.mInputManager->setGuiMode(GM_Review); - return; - } + + if (!generateClassQuestionDialog) + generateClassQuestionDialog = new InfoBoxDialog(environment); InfoBoxDialog::ButtonList buttons; generateClassQuestionDialog->setText(steps[generateClassStep].text); @@ -426,6 +437,33 @@ void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index) showClassQuestionDialog(); } +void WindowManager::onGenerateClassBack() +{ + if (generateClassResultDialog) + { + generateClassResultDialog->setVisible(false); + } + environment.mMechanicsManager->setPlayerClass(generateClass); + + updateCharacterGeneration(); + + environment.mInputManager->setGuiMode(GM_Class); +} + +void WindowManager::onGenerateClassDone() +{ + if (generateClassResultDialog) + { + generateClassResultDialog->setVisible(false); + } + environment.mMechanicsManager->setPlayerClass(generateClass); + + updateCharacterGeneration(); + + environment.mInputManager->setGuiMode(GM_Review); +} + + void WindowManager::onPickClassDialogDone() { pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void(); diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index a0810e091..82bf6ff5a 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -46,6 +46,7 @@ namespace MWGui class InfoBoxDialog; class RaceDialog; class ClassChoiceDialog; + class GenerateClassResultDialog; class PickClassDialog; class BirthDialog; @@ -66,6 +67,7 @@ namespace MWGui RaceDialog *raceDialog; ClassChoiceDialog *classChoiceDialog; InfoBoxDialog *generateClassQuestionDialog; + GenerateClassResultDialog *generateClassResultDialog; PickClassDialog *pickClassDialog; BirthDialog *birthSignDialog; @@ -79,6 +81,7 @@ namespace MWGui // Keeps track of current step in Generate Class dialogs unsigned generateClassStep; + std::string generateClass; MyGUI::Gui *gui; @@ -203,6 +206,8 @@ namespace MWGui // Character generation: Generate Class void showClassQuestionDialog(); void onClassQuestionChosen(MyGUI::Widget* _sender, int _index); + void onGenerateClassBack(); + void onGenerateClassDone(); // Character generation: Pick Class dialog void onPickClassDialogDone(); diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index a02b02f1b..a577ae72c 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -45,6 +45,7 @@ configure_file("${SDIR}/openmw_text_input_layout.xml" "${DDIR}/openmw_text_input configure_file("${SDIR}/openmw_infobox_layout.xml" "${DDIR}/openmw_infobox_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_race_layout.xml" "${DDIR}/openmw_chargen_race_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_class_layout.xml" "${DDIR}/openmw_chargen_class_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_chargen_generate_class_result_layout.xml" "${DDIR}/openmw_chargen_generate_class_result_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_create_class_layout.xml" "${DDIR}/openmw_chargen_create_class_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_select_specialization_layout.xml" "${DDIR}/openmw_chargen_select_specialization_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_select_attribute_layout.xml" "${DDIR}/openmw_chargen_select_attribute_layout.xml" COPYONLY) diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_chargen_generate_class_result_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_chargen_generate_class_result_layout.xml new file mode 100644 index 000000000..39bce0199 --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_chargen_generate_class_result_layout.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +