diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c7935cb77..41482cf85 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -40,6 +40,7 @@ set(GAMEGUI_HEADER mwgui/race.hpp mwgui/class.hpp mwgui/birth.hpp + mwgui/review.hpp mwgui/window_manager.hpp mwgui/console.hpp ) @@ -52,6 +53,7 @@ set(GAMEGUI mwgui/race.cpp mwgui/birth.cpp mwgui/class.cpp + mwgui/review.cpp ) source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp new file mode 100644 index 000000000..6bc5daf01 --- /dev/null +++ b/apps/openmw/mwgui/review.cpp @@ -0,0 +1,93 @@ +#include "review.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" +#include "window_manager.hpp" +#include "widgets.hpp" +#include "components/esm_store/store.hpp" + +#include +#include + +using namespace MWGui; +using namespace Widgets; + +ReviewDialog::ReviewDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) + : Layout("openmw_chargen_review_layout.xml") + , environment(environment) +{ + // Centre dialog + 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; + + // Setup static stats + StaticTextPtr name, race, klass, sign; + ButtonPtr button; + getWidget(name, "NameText"); + name->setCaption("Drizt"); + getWidget(button, "NameButton"); + button->setCaption(wm->getGameSettingString("sName", "")); + + getWidget(race, "RaceText"); + race->setCaption("Dark Elf"); + getWidget(button, "RaceButton"); + button->setCaption(wm->getGameSettingString("sRace", "")); + + getWidget(klass, "ClassText"); + klass->setCaption("Adventurer"); + getWidget(button, "ClassButton"); + button->setCaption(wm->getGameSettingString("sClass", "")); + + getWidget(sign, "SignText"); + sign->setCaption("The Angel"); + getWidget(button, "SignButton"); + button->setCaption(wm->getGameSettingString("sBirthSign", "")); + + // Setup dynamic stats + MWDynamicStatPtr health, magicka, fatigue; + getWidget(health, "Health"); + health->setTitle(wm->getGameSettingString("sHealth", "")); + health->setValue(45, 45); + + getWidget(magicka, "Magicka"); + magicka->setTitle(wm->getGameSettingString("sMagic", "")); + magicka->setValue(50, 50); + + getWidget(fatigue, "Fatigue"); + fatigue->setTitle(wm->getGameSettingString("sFatigue", "")); + fatigue->setValue(160, 160); + + // Setup attributes + MWAttributePtr attribute; + for (int idx = 0; idx < ESM::Attribute::Length; ++idx) + { + getWidget(attribute, std::string("Attribute") + boost::lexical_cast(idx)); + attribute->setWindowManager(wm); + attribute->setAttributeId(ESM::Attribute::attributeIds[idx]); + attribute->setAttributeValue(MWAttribute::AttributeValue(40, 50)); + } + + // TODO: These buttons should be managed by a Dialog class + MyGUI::ButtonPtr backButton; + getWidget(backButton, "BackButton"); + backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); + + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); +} + +// widget controls + +void ReviewDialog::onOkClicked(MyGUI::Widget* _sender) +{ + eventDone(); +} + +void ReviewDialog::onBackClicked(MyGUI::Widget* _sender) +{ + eventBack(); +} diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp new file mode 100644 index 000000000..d18693872 --- /dev/null +++ b/apps/openmw/mwgui/review.hpp @@ -0,0 +1,46 @@ +#ifndef MWGUI_REVIEW_H +#define MWGUI_REVIEW_H + +#include + +namespace MWWorld +{ + class Environment; +} + +/* +This file contains the dialog for reviewing the generated character. +Layout is defined by resources/mygui/openmw_chargen_review_layout.xml. +*/ + +namespace MWGui +{ + using namespace MyGUI; + + class ReviewDialog : public OEngine::GUI::Layout + { + public: + ReviewDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); + + // 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; + }; +} +#endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 89bdb7b9e..a4274b378 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -4,6 +4,7 @@ #include "race.hpp" #include "class.hpp" #include "birth.hpp" +#include "review.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -27,6 +28,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment , pickClassDialog(nullptr) , createClassDialog(nullptr) , birthSignDialog(nullptr) + , reviewDialog(nullptr) , nameChosen(false) , raceChosen(false) , classChosen(false) @@ -77,6 +79,7 @@ WindowManager::~WindowManager() delete pickClassDialog; delete createClassDialog; delete birthSignDialog; + delete reviewDialog; } void WindowManager::updateVisible() @@ -185,6 +188,17 @@ void WindowManager::updateVisible() return; } + if (mode == GM_Review) + { + reviewNext = false; + if (!reviewDialog) + reviewDialog = new ReviewDialog(environment, gui->getViewSize()); + reviewDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onReviewDialogDone); + reviewDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onReviewDialogBack); + reviewDialog->setVisible(true); + return; + } + if(mode == GM_Inventory) { // Ah, inventory mode. First, compute the effective set of @@ -605,3 +619,31 @@ void WindowManager::onBirthSignDialogBack() environment.mInputManager->setGuiMode(GM_Class); } + +void WindowManager::onReviewDialogDone() +{ + reviewDialog->eventDone = MWGui::BirthDialog::EventHandle_Void(); + + if (reviewDialog) + { + reviewDialog->setVisible(false); + //environment.mMechanicsManager->setPlayerBirthsign(reviewDialog->getBirthId()); + } + + updateCharacterGeneration(); + + environment.mInputManager->setGuiMode(GM_Game); +} + +void WindowManager::onReviewDialogBack() +{ + if (reviewDialog) + { + reviewDialog->setVisible(false); + //environment.mMechanicsManager->setPlayerBirthsign(reviewDialog->getBirthId()); + } + + updateCharacterGeneration(); + + environment.mInputManager->setGuiMode(GM_Birth); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index cf51e1aa6..046890f87 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -50,6 +50,7 @@ namespace MWGui class PickClassDialog; class CreateClassDialog; class BirthDialog; + class ReviewDialog; class WindowManager { @@ -72,6 +73,7 @@ namespace MWGui PickClassDialog *pickClassDialog; CreateClassDialog *createClassDialog; BirthDialog *birthSignDialog; + ReviewDialog *reviewDialog; // Which dialogs have been shown, controls back/next/ok buttons bool nameChosen; @@ -222,6 +224,10 @@ namespace MWGui // Character generation: Birth sign dialog void onBirthSignDialogDone(); void onBirthSignDialogBack(); + + // Character generation: Review dialog + void onReviewDialogDone(); + void onReviewDialogBack(); }; } #endif diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index a577ae72c..9da8c59e4 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -52,6 +52,7 @@ configure_file("${SDIR}/openmw_chargen_select_attribute_layout.xml" "${DDIR}/ope configure_file("${SDIR}/openmw_chargen_select_skill_layout.xml" "${DDIR}/openmw_chargen_select_skill_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_class_description_layout.xml" "${DDIR}/openmw_chargen_class_description_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_chargen_birth_layout.xml" "${DDIR}/openmw_chargen_birth_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_chargen_review_layout.xml" "${DDIR}/openmw_chargen_review_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_inventory_window_layout.xml" "${DDIR}/openmw_inventory_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_layers.xml" "${DDIR}/openmw_layers.xml" COPYONLY) configure_file("${SDIR}/openmw_mainmenu_layout.xml" "${DDIR}/openmw_mainmenu_layout.xml" COPYONLY) diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_chargen_review_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_chargen_review_layout.xml new file mode 100644 index 000000000..f5c7e28f2 --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_chargen_review_layout.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +