From 8acf04fc084bb2cdb0cd75a1b18ad31923155381 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Mon, 27 Sep 2010 12:56:48 +0200 Subject: [PATCH] Added dialog for editing description in custom class dialog. --- apps/openmw/mwgui/class.cpp | 48 ++++++++++++++++++- apps/openmw/mwgui/class.hpp | 30 +++++++++++- extern/mygui_3.0.1/CMakeLists.txt | 1 + ...penmw_chargen_class_description_layout.xml | 18 +++++++ .../openmw_resources/openmw_edit.skin.xml | 28 +++++++++++ 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_chargen_class_description_layout.xml diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index b09d123eb..d328477d4 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -233,6 +233,7 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment, MyGUI::I , specDialog(nullptr) , attribDialog(nullptr) , skillDialog(nullptr) + , descDialog(nullptr) { // Centre dialog MyGUI::IntCoord coord = mMainWidget->getCoord(); @@ -327,6 +328,7 @@ CreateClassDialog::~CreateClassDialog() delete specDialog; delete attribDialog; delete skillDialog; + delete descDialog; } void CreateClassDialog::setNextButtonShow(bool shown) @@ -374,6 +376,8 @@ void CreateClassDialog::onDialogCancel() attribDialog->setVisible(false); if (skillDialog) skillDialog->setVisible(false); + if (descDialog) + descDialog->setVisible(false); // TODO: Delete dialogs here } @@ -458,7 +462,18 @@ void CreateClassDialog::onSkillSelected() void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender) { - // TODO: Show description dialog + if (descDialog) + delete descDialog; + descDialog = new DescriptionDialog(environment, environment.mWindowManager->getGui()->getViewSize()); + descDialog->setTextInput(description); + descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); + descDialog->setVisible(true); +} + +void CreateClassDialog::onDescriptionEntered() +{ + description = descDialog->getTextInput(); + descDialog->setVisible(false); } void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) @@ -702,3 +717,34 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender) { eventCancel(); } + +/* DescriptionDialog */ + +DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) + : Layout("openmw_chargen_class_description_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); + + getWidget(textEdit, "TextEdit"); + + // TODO: These buttons should be managed by a Dialog class + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); + okButton->setCaption(environment.mWindowManager->getGameSettingString("sInputMenu1", "")); + + // Make sure the edit box has focus + MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); +} + +// widget controls + +void DescriptionDialog::onOkClicked(MyGUI::Widget* _sender) +{ + eventDone(); +} diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index c01344338..15547e594 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -171,6 +171,31 @@ namespace MWGui ESM::Skill::SkillEnum skillId; }; + class DescriptionDialog : public OEngine::GUI::Layout + { + public: + DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); + + std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } + void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } + + // Events + typedef delegates::CDelegate0 EventHandle_Void; + + /** Event : Dialog finished, OK button clicked.\n + signature : void method()\n + */ + EventHandle_Void eventDone; + + protected: + void onOkClicked(MyGUI::Widget* _sender); + + private: + MWWorld::Environment& environment; + + MyGUI::EditPtr textEdit; + }; + class CreateClassDialog : public OEngine::GUI::Layout { public: @@ -197,7 +222,6 @@ namespace MWGui EventHandle_Void eventDone; protected: - void onDescriptionClicked(MyGUI::Widget* _sender); void onOkClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender); @@ -207,6 +231,8 @@ namespace MWGui void onAttributeSelected(); void onSkillClicked(Widgets::MWSkillPtr _sender); void onSkillSelected(); + void onDescriptionClicked(MyGUI::Widget* _sender); + void onDescriptionEntered(); void onDialogCancel(); private: @@ -218,10 +244,12 @@ namespace MWGui Widgets::MWSkillPtr majorSkill0, majorSkill1, majorSkill2, majorSkill3, majorSkill4; Widgets::MWSkillPtr minorSkill0, minorSkill1, minorSkill2, minorSkill3, minorSkill4; std::vector skills; + std::string description; SelectSpecializationDialog *specDialog; SelectAttributeDialog *attribDialog; SelectSkillDialog *skillDialog; + DescriptionDialog *descDialog; ESM::Class::Specialization specializationId; }; diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index 56c1b1864..e982df3ff 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -48,6 +48,7 @@ configure_file("${SDIR}/openmw_chargen_create_class_layout.xml" "${DDIR}/openmw_ 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) 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_inventory_window_layout.xml" "${DDIR}/openmw_inventory_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_layers.xml" "${DDIR}/openmw_layers.xml" COPYONLY) diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_chargen_class_description_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_chargen_class_description_layout.xml new file mode 100644 index 000000000..9cf3dd247 --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_chargen_class_description_layout.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_edit.skin.xml b/extern/mygui_3.0.1/openmw_resources/openmw_edit.skin.xml index 482e4a7b2..9985e623d 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_edit.skin.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_edit.skin.xml @@ -10,6 +10,16 @@ + + + + + + + + + + @@ -26,4 +36,22 @@ + + + + + + + + + + + + + + + + + +