From 700e379d564668907788a6c95b7e3ae9ab2d75f3 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Mon, 1 Nov 2010 18:56:09 +0100 Subject: [PATCH 01/28] Fix some compiler warnings --- apps/openmw/mwgui/layouts.cpp | 2 +- apps/openmw/mwgui/window_manager.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index d1f829705..78412d5e2 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -205,7 +205,7 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat Date: Wed, 3 Nov 2010 20:01:53 +0100 Subject: [PATCH 02/28] Use the input manager to enable the dialog --- apps/openmw/mwdialogue/dialoguemanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index f33d625fc..0f6e73276 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -14,7 +14,7 @@ #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" -#include "../mwgui/window_manager.hpp" +#include "../mwinput/inputmanager.hpp" #include @@ -275,7 +275,7 @@ namespace MWDialogue // TODO execute script } - mEnvironment.mWindowManager->setMode (MWGui::GM_Dialogue); + mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); break; } } From be5562cb2cea5cec5e9464219712828df845b3b3 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Wed, 3 Nov 2010 21:21:08 +0100 Subject: [PATCH 03/28] Added dialouge window --- apps/openmw/CMakeLists.txt | 4 + apps/openmw/mwgui/dialogue.cpp | 127 ++++++++++++++++++ apps/openmw/mwgui/dialogue.hpp | 55 ++++++++ apps/openmw/mwgui/dialogue_history.cpp | 77 +++++++++++ apps/openmw/mwgui/dialogue_history.hpp | 20 +++ apps/openmw/mwgui/window_manager.cpp | 29 ++++ apps/openmw/mwgui/window_manager.hpp | 5 + extern/mygui_3.0.1/CMakeLists.txt | 1 + .../openmw_dialogue_window_layout.xml | 29 ++++ 9 files changed, 347 insertions(+) create mode 100644 apps/openmw/mwgui/dialogue.cpp create mode 100644 apps/openmw/mwgui/dialogue.hpp create mode 100644 apps/openmw/mwgui/dialogue_history.cpp create mode 100644 apps/openmw/mwgui/dialogue_history.hpp create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 2f003f6aa..78477aae4 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -43,6 +43,8 @@ set(GAMEGUI_HEADER mwgui/review.hpp mwgui/window_manager.hpp mwgui/console.hpp + mwgui/dialogue.hpp + mwgui/dialogue_history.hpp ) set(GAMEGUI mwgui/window_manager.cpp @@ -54,6 +56,8 @@ set(GAMEGUI mwgui/birth.cpp mwgui/class.cpp mwgui/review.cpp + mwgui/dialogue.cpp + mwgui/dialogue_history.cpp ) source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp new file mode 100644 index 000000000..6f2ca8e96 --- /dev/null +++ b/apps/openmw/mwgui/dialogue.cpp @@ -0,0 +1,127 @@ +#include "dialogue.hpp" +#include "dialogue_history.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" +#include "window_manager.hpp" +#include "widgets.hpp" +#include "components/esm_store/store.hpp" + +#include +#include +#include + +#include +#include + +using namespace MWGui; +using namespace Widgets; + +DialogueWindow::DialogueWindow(MWWorld::Environment& environment) + : Layout("openmw_dialogue_window_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("NpcName", "Name of character"); + + //History view + getWidget(history, "History"); + history->setOverflowToTheLeft(true); + history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); + + //Topics list + getWidget(topicsList, "TopicsList"); + topicsList->setScrollVisible(true); + topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + topicsList->eventListMouseItemActivate = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + topicsList->eventListChangePosition = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + + MyGUI::ButtonPtr byeButton; + getWidget(byeButton, "ByeButton"); + byeButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); + + updateOptions(); +} + +void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) +{ + ISubWidgetText* t = history->getSubWidgetText(); + if(t == nullptr) + return; + + const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed(); + + size_t cursorPosition = t->getCursorPosition(lastPressed); + if(history->getColorAtPos(cursorPosition) != "#FFFFFF") + { + UString key = history->getColorTextAt(cursorPosition); + std::cout << "Clicked on key: " << key << std::endl; + //eventTopicSelected(key); + } +} + +void DialogueWindow::open() +{ + updateOptions(); + setVisible(true); +} + +void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) +{ + eventBye(); +} + +void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) +{ + if (_index == MyGUI::ITEM_NONE) + return; + + //const std::string* theTopic = topicsList->getItemDataAt(_index); + //std::cout << "Selected: "<< theTopic << std::endl; + //eventTopicSelected(key); +} + + +void DialogueWindow::updateOptions() +{ + //FIXME Add this properly + history->addDialogText("Through the translucent surface of the orb, you see shifting images of distant locations..."); + for(int z = 0; z < 10; z++) + { + history->addDialogHeading("Fort Frostmoth"); + history->addDialogText("The image in the orb flickers, and you see.... The cold courtyard of #FF0000Fort Frostmoth#FFFFFF, battered bu werewolf attack, but still standing, still projecting Imperial might even to this distant and cold corner of the world."); + } + + //Clear the list of topics + topicsList->removeAllItems(); + int i = 0; + topicsList->addItem("Ald'ruhn", i++); + topicsList->addItem("Balmora", i++); + topicsList->addItem("Sadrith Mora", i++); + topicsList->addItem("Vivec", i++); + topicsList->addItem("Ald Velothi", i++); + topicsList->addItem("Caldera", i++); + topicsList->addItem("Dagon Fel ", i++); + topicsList->addItem("Gnaar Mok", i++); + topicsList->addItem("Gnisis", i++); + topicsList->addItem("Hla Oad", i++); + topicsList->addItem("Khuul", i++); + topicsList->addItem("Maar Gan", i++); + topicsList->addItem("Molag Mar", i++); + topicsList->addItem("Pelagiad", i++); + topicsList->addItem("Seyda Neen", i++); + topicsList->addItem("Suran", i++); + topicsList->addItem("Tel Aruhn", i++); + topicsList->addItem("Tel Branora", i++); + topicsList->addItem("Tel Fyr", i++); + topicsList->addItem("Tel Mora", i++); + topicsList->addItem("Tel Vos", i++); + topicsList->addItem("Vos", i++); +} + diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp new file mode 100644 index 000000000..625ca225d --- /dev/null +++ b/apps/openmw/mwgui/dialogue.hpp @@ -0,0 +1,55 @@ +#ifndef MWGUI_DIALOGE_H +#define MWGUI_DIALOGE_H + +#include + +#include + +#include + +namespace MWWorld +{ + class Environment; +} + +/* + This file contains the dialouge window + Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. + */ + +namespace MWGui +{ + class DialogeHistory; + + using namespace MyGUI; + + class DialogueWindow: public OEngine::GUI::Layout + { + public: + DialogueWindow(MWWorld::Environment& environment); + + void open(); + + // Events + typedef delegates::CDelegate0 EventHandle_Void; + + /** Event : Dialog finished, OK button clicked.\n + signature : void method()\n + */ + EventHandle_Void eventBye; + + protected: + void onSelectTopic(MyGUI::List* _sender, size_t _index); + void onByeClicked(MyGUI::Widget* _sender); + void onHistoryClicked(MyGUI::Widget* _sender); + + private: + void updateOptions(); + + MWWorld::Environment& environment; + + DialogeHistory* history; + MyGUI::ListPtr topicsList; + }; +} +#endif diff --git a/apps/openmw/mwgui/dialogue_history.cpp b/apps/openmw/mwgui/dialogue_history.cpp new file mode 100644 index 000000000..d7a274f7a --- /dev/null +++ b/apps/openmw/mwgui/dialogue_history.cpp @@ -0,0 +1,77 @@ +#include "dialogue_history.hpp" +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" +#include "window_manager.hpp" +#include "widgets.hpp" +#include "components/esm_store/store.hpp" + +#include +#include +#include + +#include +#include + +using namespace MWGui; +using namespace Widgets; + +UString DialogeHistory::getColorAtPos(size_t _pos) +{ + UString colour = TextIterator::convertTagColour(mText->getTextColour()); + TextIterator iterator(mText->getCaption()); + while(iterator.moveNext()) + { + size_t pos = iterator.getPosition(); + iterator.getTagColour(colour); + if (pos < _pos) + continue; + else if (pos == _pos) + break; + } + return colour; +} + +UString DialogeHistory::getColorTextAt(size_t _pos) +{ + bool breakOnNext = false; + UString colour = TextIterator::convertTagColour(mText->getTextColour()); + UString colour2 = colour; + TextIterator iterator(mText->getCaption()); + TextIterator col_start = iterator; + while(iterator.moveNext()) + { + size_t pos = iterator.getPosition(); + iterator.getTagColour(colour); + if(colour != colour2) + { + if(breakOnNext) + { + return getOnlyText().substr(col_start.getPosition(), iterator.getPosition()-col_start.getPosition()); + } + col_start = iterator; + colour2 = colour; + } + if (pos < _pos) + continue; + else if (pos == _pos) + { + breakOnNext = true; + } + } + return ""; +} + +void DialogeHistory::addDialogHeading(const UString& parText) +{ + UString head("\n#00FF00"); + head.append(parText); + head.append("#FFFFFF\n"); + addText(head); +} + +void DialogeHistory::addDialogText(const UString& parText) +{ + addText(parText); + addText("\n"); +} + diff --git a/apps/openmw/mwgui/dialogue_history.hpp b/apps/openmw/mwgui/dialogue_history.hpp new file mode 100644 index 000000000..ec41678e6 --- /dev/null +++ b/apps/openmw/mwgui/dialogue_history.hpp @@ -0,0 +1,20 @@ +#ifndef MWGUI_DIALOGE_HISTORY_H +#define MWGUI_DIALOGE_HISTORY_H +#include + +namespace MWGui +{ + using namespace MyGUI; + class DialogeHistory : public MyGUI::Edit + { + MYGUI_RTTI_DERIVED( DialogeHistory ) + public: + Widget* getClient() { return mClient; } + UString getColorAtPos(size_t _pos); + UString getColorTextAt(size_t _pos); + void addDialogHeading(const UString& parText); + void addDialogText(const UString& parText); + }; +} +#endif + diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index ce13ff977..6a06865fa 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -5,6 +5,8 @@ #include "class.hpp" #include "birth.hpp" #include "review.hpp" +#include "dialogue.hpp" +#include "dialogue_history.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -22,6 +24,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment : environment(environment) , nameDialog(nullptr) , raceDialog(nullptr) + , dialogueWindow(nullptr) , classChoiceDialog(nullptr) , generateClassQuestionDialog(nullptr) , generateClassResultDialog(nullptr) @@ -41,6 +44,10 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment , shown(GW_ALL) , allowed(newGame ? GW_None : GW_ALL) { + + //Register own widgets with MyGUI + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + // Get size info from the Gui object assert(gui); int w = gui->getViewSize().width; @@ -86,6 +93,7 @@ WindowManager::~WindowManager() delete nameDialog; delete raceDialog; + delete dialogueWindow; delete classChoiceDialog; delete generateClassQuestionDialog; delete generateClassResultDialog; @@ -307,6 +315,17 @@ void WindowManager::updateVisible() return; } + if (mode == GM_Dialogue) + { + if (dialogueWindow) + removeDialog(dialogueWindow); + dialogueWindow = new DialogueWindow(environment); + dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye); + dialogueWindow->open(); + return; + } + + // Unsupported mode, switch back to game // Note: The call will eventually end up this method again but // will stop at the check if(mode == GM_Game) above. @@ -522,6 +541,16 @@ void WindowManager::onRaceDialogDone() setGuiMode(GM_Game); } +void WindowManager::onDialogueWindowBye() +{ + if (dialogueWindow) + { + //FIXME set some state and stuff? + removeDialog(dialogueWindow); + } + setGuiMode(GM_Game); +} + void WindowManager::onRaceDialogBack() { if (raceDialog) diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index f9dd4f55d..5c6c4fd50 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -54,6 +54,7 @@ namespace MWGui class TextInputDialog; class InfoBoxDialog; class RaceDialog; + class DialogueWindow; class ClassChoiceDialog; class GenerateClassResultDialog; class PickClassDialog; @@ -82,6 +83,7 @@ namespace MWGui // Character creation TextInputDialog *nameDialog; RaceDialog *raceDialog; + DialogueWindow *dialogueWindow; ClassChoiceDialog *classChoiceDialog; InfoBoxDialog *generateClassQuestionDialog; GenerateClassResultDialog *generateClassResultDialog; @@ -248,6 +250,9 @@ namespace MWGui const std::string &getGameSettingString(const std::string &id, const std::string &default_); private: + + void onDialogueWindowBye(); + // Character generation: Name dialog void onNameDialogDone(); diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index 9da8c59e4..d7e0bd483 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -53,6 +53,7 @@ configure_file("${SDIR}/openmw_chargen_select_skill_layout.xml" "${DDIR}/openmw_ 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_dialogue_window_layout.xml" "${DDIR}/openmw_dialogue_window_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_dialogue_window_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml new file mode 100644 index 000000000..2987e82be --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_dialogue_window_layout.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From d7b76809ac790e1adc61df5c87f9a868fd9d674a Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 18:49:44 +0100 Subject: [PATCH 04/28] Remove unnecessary member variables from SelectAttributeDialog --- apps/openmw/mwgui/class.cpp | 30 +++++++----------------------- apps/openmw/mwgui/class.hpp | 2 -- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index cd31e1003..79a1604a1 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -800,31 +800,15 @@ SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment, setText("LabelT", wm->getGameSettingString("sAttributesMenu1", "")); - getWidget(attribute0, "Attribute0"); - getWidget(attribute1, "Attribute1"); - getWidget(attribute2, "Attribute2"); - getWidget(attribute3, "Attribute3"); - getWidget(attribute4, "Attribute4"); - getWidget(attribute5, "Attribute5"); - getWidget(attribute6, "Attribute6"); - getWidget(attribute7, "Attribute7"); - - Widgets::MWAttributePtr attributes[8] = { - attribute0, - attribute1, - attribute2, - attribute3, - attribute4, - attribute5, - attribute6, - attribute7 - }; - for (int i = 0; i < 8; ++i) { - attributes[i]->setWindowManager(wm); - attributes[i]->setAttributeId(ESM::Attribute::attributeIds[i]); - attributes[i]->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); + Widgets::MWAttributePtr attribute; + char theIndex = '0'+i; + + getWidget(attribute, std::string("Attribute").append(1, theIndex)); + attribute->setWindowManager(wm); + attribute->setAttributeId(ESM::Attribute::attributeIds[i]); + attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); } // TODO: These buttons should be managed by a Dialog class diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 4ad8de495..e931a7e8f 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -214,8 +214,6 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - Widgets::MWAttributePtr attribute0, attribute1, attribute2, attribute3, - attribute4, attribute5, attribute6, attribute7; Widgets::MWAttributePtr affectedWidget; ESM::Attribute::AttributeID attributeId; From ef54401407eb3f1757c36ed50a7ce738e1825272 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 18:51:42 +0100 Subject: [PATCH 05/28] Use arrays in SelectSkillDialog --- apps/openmw/mwgui/class.cpp | 90 ++++++++++++++----------------------- apps/openmw/mwgui/class.hpp | 9 ++-- 2 files changed, 37 insertions(+), 62 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 79a1604a1..cf4a5d850 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -851,69 +851,47 @@ SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::I setText("MagicLabelT", wm->getGameSettingString("sSpecializationMagic", "")); setText("StealthLabelT", wm->getGameSettingString("sSpecializationStealth", "")); - getWidget(combatSkill0, "CombatSkill0"); - getWidget(combatSkill1, "CombatSkill1"); - getWidget(combatSkill2, "CombatSkill2"); - getWidget(combatSkill3, "CombatSkill3"); - getWidget(combatSkill4, "CombatSkill4"); - getWidget(combatSkill5, "CombatSkill5"); - getWidget(combatSkill6, "CombatSkill6"); - getWidget(combatSkill7, "CombatSkill7"); - getWidget(combatSkill8, "CombatSkill8"); - - getWidget(magicSkill0, "MagicSkill0"); - getWidget(magicSkill1, "MagicSkill1"); - getWidget(magicSkill2, "MagicSkill2"); - getWidget(magicSkill3, "MagicSkill3"); - getWidget(magicSkill4, "MagicSkill4"); - getWidget(magicSkill5, "MagicSkill5"); - getWidget(magicSkill6, "MagicSkill6"); - getWidget(magicSkill7, "MagicSkill7"); - getWidget(magicSkill8, "MagicSkill8"); - - getWidget(stealthSkill0, "StealthSkill0"); - getWidget(stealthSkill1, "StealthSkill1"); - getWidget(stealthSkill2, "StealthSkill2"); - getWidget(stealthSkill3, "StealthSkill3"); - getWidget(stealthSkill4, "StealthSkill4"); - getWidget(stealthSkill5, "StealthSkill5"); - getWidget(stealthSkill6, "StealthSkill6"); - getWidget(stealthSkill7, "StealthSkill7"); - getWidget(stealthSkill8, "StealthSkill8"); + for(int i = 0; i < 9; i++) + { + char theIndex = '0'+i; + getWidget(combatSkill[i], std::string("CombatSkill").append(1, theIndex)); + getWidget(magicSkill[i], std::string("MagicSkill").append(1, theIndex)); + getWidget(stealthSkill[i], std::string("StealthSkill").append(1, theIndex)); + } struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} skills[3][9] = { { - {combatSkill0, ESM::Skill::Block}, - {combatSkill1, ESM::Skill::Armorer}, - {combatSkill2, ESM::Skill::MediumArmor}, - {combatSkill3, ESM::Skill::HeavyArmor}, - {combatSkill4, ESM::Skill::BluntWeapon}, - {combatSkill5, ESM::Skill::LongBlade}, - {combatSkill6, ESM::Skill::Axe}, - {combatSkill7, ESM::Skill::Spear}, - {combatSkill8, ESM::Skill::Athletics} + {combatSkill[0], ESM::Skill::Block}, + {combatSkill[1], ESM::Skill::Armorer}, + {combatSkill[2], ESM::Skill::MediumArmor}, + {combatSkill[3], ESM::Skill::HeavyArmor}, + {combatSkill[4], ESM::Skill::BluntWeapon}, + {combatSkill[5], ESM::Skill::LongBlade}, + {combatSkill[6], ESM::Skill::Axe}, + {combatSkill[7], ESM::Skill::Spear}, + {combatSkill[8], ESM::Skill::Athletics} }, { - {magicSkill0, ESM::Skill::Enchant}, - {magicSkill1, ESM::Skill::Destruction}, - {magicSkill2, ESM::Skill::Alteration}, - {magicSkill3, ESM::Skill::Illusion}, - {magicSkill4, ESM::Skill::Conjuration}, - {magicSkill5, ESM::Skill::Mysticism}, - {magicSkill6, ESM::Skill::Restoration}, - {magicSkill7, ESM::Skill::Alchemy}, - {magicSkill8, ESM::Skill::Unarmored} + {magicSkill[0], ESM::Skill::Enchant}, + {magicSkill[1], ESM::Skill::Destruction}, + {magicSkill[2], ESM::Skill::Alteration}, + {magicSkill[3], ESM::Skill::Illusion}, + {magicSkill[4], ESM::Skill::Conjuration}, + {magicSkill[5], ESM::Skill::Mysticism}, + {magicSkill[6], ESM::Skill::Restoration}, + {magicSkill[7], ESM::Skill::Alchemy}, + {magicSkill[8], ESM::Skill::Unarmored} }, { - {stealthSkill0, ESM::Skill::Security}, - {stealthSkill1, ESM::Skill::Sneak}, - {stealthSkill2, ESM::Skill::Acrobatics}, - {stealthSkill3, ESM::Skill::LightArmor}, - {stealthSkill4, ESM::Skill::ShortBlade}, - {stealthSkill5 ,ESM::Skill::Marksman}, - {stealthSkill6 ,ESM::Skill::Mercantile}, - {stealthSkill7 ,ESM::Skill::Speechcraft}, - {stealthSkill8 ,ESM::Skill::HandToHand} + {stealthSkill[0], ESM::Skill::Security}, + {stealthSkill[1], ESM::Skill::Sneak}, + {stealthSkill[2], ESM::Skill::Acrobatics}, + {stealthSkill[3], ESM::Skill::LightArmor}, + {stealthSkill[4], ESM::Skill::ShortBlade}, + {stealthSkill[5] ,ESM::Skill::Marksman}, + {stealthSkill[6] ,ESM::Skill::Mercantile}, + {stealthSkill[7] ,ESM::Skill::Speechcraft}, + {stealthSkill[8] ,ESM::Skill::HandToHand} } }; diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index e931a7e8f..6f868c471 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -246,12 +246,9 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - Widgets::MWSkillPtr combatSkill0, combatSkill1, combatSkill2, combatSkill3, combatSkill4, - combatSkill5, combatSkill6, combatSkill7, combatSkill8; - Widgets::MWSkillPtr magicSkill0, magicSkill1, magicSkill2, magicSkill3, magicSkill4, - magicSkill5, magicSkill6, magicSkill7, magicSkill8; - Widgets::MWSkillPtr stealthSkill0, stealthSkill1, stealthSkill2, stealthSkill3, stealthSkill4, - stealthSkill5, stealthSkill6, stealthSkill7, stealthSkill8; + Widgets::MWSkillPtr combatSkill[9]; + Widgets::MWSkillPtr magicSkill[9]; + Widgets::MWSkillPtr stealthSkill[9]; Widgets::MWSkillPtr affectedWidget; ESM::Skill::SkillEnum skillId; From 528c39f1bd6508e5dc34bcec989f2b874fd81697 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 19:40:00 +0100 Subject: [PATCH 06/28] Use arrays in PickClassDialog --- apps/openmw/mwgui/class.cpp | 60 ++++++++++--------------------------- apps/openmw/mwgui/class.hpp | 6 ++-- 2 files changed, 19 insertions(+), 47 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index cf4a5d850..1f25792c5 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -89,34 +89,21 @@ PickClassDialog::PickClassDialog(MWWorld::Environment& environment) getWidget(specializationName, "SpecializationName"); setText("FavoriteAttributesT", wm->getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); - getWidget(favoriteAttribute0, "FavoriteAttribute0"); - getWidget(favoriteAttribute1, "FavoriteAttribute1"); - favoriteAttribute0->setWindowManager(wm); - favoriteAttribute1->setWindowManager(wm); + getWidget(favoriteAttribute[0], "FavoriteAttribute0"); + getWidget(favoriteAttribute[1], "FavoriteAttribute1"); + favoriteAttribute[0]->setWindowManager(wm); + favoriteAttribute[1]->setWindowManager(wm); setText("MajorSkillT", wm->getGameSettingString("sChooseClassMenu3", "Major Skills:")); - getWidget(majorSkill0, "MajorSkill0"); - getWidget(majorSkill1, "MajorSkill1"); - getWidget(majorSkill2, "MajorSkill2"); - getWidget(majorSkill3, "MajorSkill3"); - getWidget(majorSkill4, "MajorSkill4"); - majorSkill0->setWindowManager(wm); - majorSkill1->setWindowManager(wm); - majorSkill2->setWindowManager(wm); - majorSkill3->setWindowManager(wm); - majorSkill4->setWindowManager(wm); - setText("MinorSkillT", wm->getGameSettingString("sChooseClassMenu4", "Minor Skills:")); - getWidget(minorSkill0, "MinorSkill0"); - getWidget(minorSkill1, "MinorSkill1"); - getWidget(minorSkill2, "MinorSkill2"); - getWidget(minorSkill3, "MinorSkill3"); - getWidget(minorSkill4, "MinorSkill4"); - minorSkill0->setWindowManager(wm); - minorSkill1->setWindowManager(wm); - minorSkill2->setWindowManager(wm); - minorSkill3->setWindowManager(wm); - minorSkill4->setWindowManager(wm); + for(int i = 0; i < 5; i++) + { + char theIndex = '0'+i; + getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); + getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); + majorSkill[i]->setWindowManager(wm); + minorSkill[i]->setWindowManager(wm); + } getWidget(classList, "ClassList"); classList->setScrollVisible(true); @@ -259,28 +246,13 @@ void PickClassDialog::updateStats() }; specializationName->setCaption(wm->getGameSettingString(specIds[specialization], specIds[specialization])); - favoriteAttribute0->setAttributeId(klass->data.attribute[0]); - favoriteAttribute1->setAttributeId(klass->data.attribute[1]); - - Widgets::MWSkillPtr majorSkills[5] = { - majorSkill0, - majorSkill1, - majorSkill2, - majorSkill3, - majorSkill4 - }; - Widgets::MWSkillPtr minorSkills[5] = { - minorSkill0, - minorSkill1, - minorSkill2, - minorSkill3, - minorSkill4 - }; + favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]); + favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]); for (int i = 0; i < 5; ++i) { - majorSkills[i]->setSkillNumber(klass->data.skills[i][0]); - minorSkills[i]->setSkillNumber(klass->data.skills[i][1]); + majorSkill[i]->setSkillNumber(klass->data.skills[i][0]); + minorSkill[i]->setSkillNumber(klass->data.skills[i][1]); } classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 6f868c471..9b621c297 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -150,9 +150,9 @@ namespace MWGui MyGUI::StaticImagePtr classImage; MyGUI::ListPtr classList; MyGUI::StaticTextPtr specializationName; - Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; - Widgets::MWSkillPtr majorSkill0, majorSkill1, majorSkill2, majorSkill3, majorSkill4; - Widgets::MWSkillPtr minorSkill0, minorSkill1, minorSkill2, minorSkill3, minorSkill4; + Widgets::MWAttributePtr favoriteAttribute[2]; + Widgets::MWSkillPtr majorSkill[5]; + Widgets::MWSkillPtr minorSkill[5]; std::string currentClassId; }; From e5509ce7b1d4a574f2bd3713548e8efa44910648 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 19:40:31 +0100 Subject: [PATCH 07/28] Use arrays in CreateClassDialog --- apps/openmw/mwgui/class.cpp | 67 ++++++++++++++----------------------- apps/openmw/mwgui/class.hpp | 4 +-- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 1f25792c5..3cd9f219a 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -430,28 +430,15 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment) favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); setText("MajorSkillT", wm->getGameSettingString("sSkillClassMajor", "")); - getWidget(majorSkill0, "MajorSkill0"); - getWidget(majorSkill1, "MajorSkill1"); - getWidget(majorSkill2, "MajorSkill2"); - getWidget(majorSkill3, "MajorSkill3"); - getWidget(majorSkill4, "MajorSkill4"); - skills.push_back(majorSkill0); - skills.push_back(majorSkill1); - skills.push_back(majorSkill2); - skills.push_back(majorSkill3); - skills.push_back(majorSkill4); - setText("MinorSkillT", wm->getGameSettingString("sSkillClassMinor", "")); - getWidget(minorSkill0, "MinorSkill0"); - getWidget(minorSkill1, "MinorSkill1"); - getWidget(minorSkill2, "MinorSkill2"); - getWidget(minorSkill3, "MinorSkill3"); - getWidget(minorSkill4, "MinorSkill4"); - skills.push_back(minorSkill0); - skills.push_back(minorSkill1); - skills.push_back(minorSkill2); - skills.push_back(minorSkill3); - skills.push_back(minorSkill4); + for(int i = 0; i < 5; i++) + { + char theIndex = '0'+i; + getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); + getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); + skills.push_back(majorSkill[i]); + skills.push_back(minorSkill[i]); + } std::vector::const_iterator end = skills.end(); for (std::vector::const_iterator it = skills.begin(); it != end; ++it) @@ -484,17 +471,17 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment) favoriteAttribute0->setAttributeId(ESM::Attribute::Strength); favoriteAttribute1->setAttributeId(ESM::Attribute::Agility); - majorSkill0->setSkillId(ESM::Skill::Block); - majorSkill1->setSkillId(ESM::Skill::Armorer); - majorSkill2->setSkillId(ESM::Skill::MediumArmor); - majorSkill3->setSkillId(ESM::Skill::HeavyArmor); - majorSkill4->setSkillId(ESM::Skill::BluntWeapon); + majorSkill[0]->setSkillId(ESM::Skill::Block); + majorSkill[1]->setSkillId(ESM::Skill::Armorer); + majorSkill[2]->setSkillId(ESM::Skill::MediumArmor); + majorSkill[3]->setSkillId(ESM::Skill::HeavyArmor); + majorSkill[4]->setSkillId(ESM::Skill::BluntWeapon); - minorSkill0->setSkillId(ESM::Skill::LongBlade); - minorSkill1->setSkillId(ESM::Skill::Axe); - minorSkill2->setSkillId(ESM::Skill::Spear); - minorSkill3->setSkillId(ESM::Skill::Athletics); - minorSkill4->setSkillId(ESM::Skill::Enchant); + minorSkill[0]->setSkillId(ESM::Skill::LongBlade); + minorSkill[1]->setSkillId(ESM::Skill::Axe); + minorSkill[2]->setSkillId(ESM::Skill::Spear); + minorSkill[3]->setSkillId(ESM::Skill::Athletics); + minorSkill[4]->setSkillId(ESM::Skill::Enchant); } CreateClassDialog::~CreateClassDialog() @@ -531,22 +518,20 @@ std::vector CreateClassDialog::getFavoriteAttributes() const std::vector CreateClassDialog::getMajorSkills() const { std::vector v; - v.push_back(majorSkill0->getSkillId()); - v.push_back(majorSkill1->getSkillId()); - v.push_back(majorSkill2->getSkillId()); - v.push_back(majorSkill3->getSkillId()); - v.push_back(majorSkill4->getSkillId()); + for(int i = 0; i < 5; i++) + { + v.push_back(majorSkill[i]->getSkillId()); + } return v; } std::vector CreateClassDialog::getMinorSkills() const { std::vector v; - v.push_back(majorSkill0->getSkillId()); - v.push_back(majorSkill1->getSkillId()); - v.push_back(majorSkill2->getSkillId()); - v.push_back(majorSkill3->getSkillId()); - v.push_back(majorSkill4->getSkillId()); + for(int i=0; i < 5; i++) + { + v.push_back(majorSkill[i]->getSkillId()); + } return v; } diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 9b621c297..08802479a 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -328,8 +328,8 @@ namespace MWGui MyGUI::EditPtr editName; MyGUI::WidgetPtr specializationName; Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; - Widgets::MWSkillPtr majorSkill0, majorSkill1, majorSkill2, majorSkill3, majorSkill4; - Widgets::MWSkillPtr minorSkill0, minorSkill1, minorSkill2, minorSkill3, minorSkill4; + Widgets::MWSkillPtr majorSkill[5]; + Widgets::MWSkillPtr minorSkill[5]; std::vector skills; std::string description; From bb212e20f4badcd4b61deebc6d41bb1b994d8ddd Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 22:05:50 +0100 Subject: [PATCH 08/28] Do not store StaticTextPtr in WidgetPtr and use setTextColour --- apps/openmw/mwgui/layouts.cpp | 10 +++++----- apps/openmw/mwgui/layouts.hpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 78412d5e2..76699dfba 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -56,7 +56,7 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment) for (int i = 0; i < ESM::Skill::Length; ++i) { skillValues.insert(std::pair >(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::pair(i, nullptr)); + skillWidgetMap.insert(std::pair(i, nullptr)); } static_cast(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize); @@ -99,7 +99,7 @@ void StatsWindow::setPlayerName(const std::string& playerName) mMainWidget->setCaption(playerName); } -void StatsWindow::setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const std::string &value) +void StatsWindow::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value) { widget->setCaption(value); if (style == CS_Super) @@ -211,7 +211,7 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::StatgetGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + MyGUI::StaticTextPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); skillWidgetMap[skillId] = widget; } } diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 2caf33a1d..574e51c8f 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -212,11 +212,11 @@ namespace MWGui CS_Normal, CS_Super }; - void setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const std::string &value); + void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::WidgetPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::StaticTextPtr 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(); @@ -232,7 +232,7 @@ namespace MWGui SkillList majorSkills, minorSkills, miscSkills; std::map > skillValues; - std::map skillWidgetMap; + std::map skillWidgetMap; std::map factionWidgetMap; FactionList factions; ///< Stores a list of factions and the current rank std::string birthSignId; From 9d57b4f0d6d687a13a0fec16247f48521029ed15 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 22:12:27 +0100 Subject: [PATCH 09/28] Do not store StaticTextPtr in WidgetPtr and use setTextColour --- apps/openmw/mwgui/review.cpp | 10 +++++----- apps/openmw/mwgui/review.hpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 3406bf7c4..ea4b10d4c 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -85,7 +85,7 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment) for (int i = 0; i < ESM::Skill::Length; ++i) { skillValues.insert(std::pair >(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::pair(i, nullptr)); + skillWidgetMap.insert(std::pair(i, nullptr)); } static_cast(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); @@ -180,7 +180,7 @@ void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const M void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat& value) { skillValues[skillId] = value; - MyGUI::WidgetPtr widget = skillWidgetMap[skillId]; + MyGUI::StaticTextPtr widget = skillWidgetMap[skillId]; if (widget) { float modified = value.getModified(), base = value.getBase(); @@ -214,7 +214,7 @@ void ReviewDialog::configureSkills(const std::vector& major, const std::vec } } -void ReviewDialog::setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const std::string &value) +void ReviewDialog::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value) { widget->setCaption(value); if (style == CS_Super) @@ -244,7 +244,7 @@ void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, M coord2.top += lineHeight; } -MyGUI::WidgetPtr ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::StaticTextPtr ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::StaticTextPtr skillNameWidget, skillValueWidget; @@ -307,7 +307,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId style = CS_Super; else if (modified < base) style = CS_Sub; - MyGUI::WidgetPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + MyGUI::StaticTextPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); skillWidgetMap[skillId] = widget; } } diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 234ae5137..2809b67c9 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -92,11 +92,11 @@ namespace MWGui CS_Normal, CS_Super }; - void setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const std::string &value); + void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::WidgetPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::StaticTextPtr 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(); @@ -118,7 +118,7 @@ namespace MWGui SkillList majorSkills, minorSkills, miscSkills; std::map > skillValues; - std::map skillWidgetMap; + std::map skillWidgetMap; std::string name, raceId, birthSignId; ESM::Class klass; std::vector skillWidgets; //< Skills and other information From 6f608f1400adba9484a7d1c69b9d2908fe8469fd Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 5 Nov 2010 23:00:20 +0100 Subject: [PATCH 10/28] Make loose functions part of the InfoBoxDialog class --- apps/openmw/mwgui/class.cpp | 4 ++-- apps/openmw/mwgui/class.hpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 3cd9f219a..88e553821 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -260,7 +260,7 @@ void PickClassDialog::updateStats() /* InfoBoxDialog */ -void fitToText(MyGUI::StaticTextPtr widget) +void InfoBoxDialog::fitToText(MyGUI::StaticTextPtr widget) { MyGUI::IntCoord inner = widget->getTextRegion(); MyGUI::IntCoord outer = widget->getCoord(); @@ -270,7 +270,7 @@ void fitToText(MyGUI::StaticTextPtr widget) widget->setSize(size); } -void layoutVertically(MyGUI::WidgetPtr widget, int margin) +void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin) { size_t count = widget->getChildCount(); int pos = 0; diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 08802479a..bd7a785a4 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -53,6 +53,8 @@ namespace MWGui MWWorld::Environment& environment; + void fitToText(MyGUI::StaticTextPtr widget); + void layoutVertically(MyGUI::WidgetPtr widget, int margin); int currentButton; MyGUI::WidgetPtr textBox; MyGUI::StaticTextPtr text; From cb3fa7c3b24c3c71cf1c4f220b429b0d023927a3 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 00:26:32 +0100 Subject: [PATCH 11/28] Remove unused variables --- apps/openmw/mwgui/birth.cpp | 2 -- apps/openmw/mwgui/layouts.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 1c525e8fd..608d2a9e6 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -22,8 +22,6 @@ BirthDialog::BirthDialog(MWWorld::Environment& environment) coord.top = (gameWindowSize.height - coord.height)/2; mMainWidget->setCoord(coord); - WindowManager *wm = environment.mWindowManager; - getWidget(spellArea, "SpellArea"); getWidget(birthImage, "BirthsignImage"); diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 76699dfba..33ab090bd 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -312,8 +312,6 @@ void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { WindowManager *wm = environment.mWindowManager; - MWMechanics::MechanicsManager *mm = environment.mMechanicsManager; - ESMS::ESMStore &store = environment.mWorld->getStore(); // Add a line separator if there are items above if (!skillWidgets.empty()) From 1ff81354eb51bc4d14dab5be00ca28b44904eae5 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 00:17:36 +0100 Subject: [PATCH 12/28] Remove unused variables --- apps/openmw/mwgui/review.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index ea4b10d4c..e193b6072 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -279,8 +279,6 @@ void ReviewDialog::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGU void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { WindowManager *wm = environment.mWindowManager; - MWMechanics::MechanicsManager *mm = environment.mMechanicsManager; - ESMS::ESMStore &store = environment.mWorld->getStore(); // Add a line separator if there are items above if (!skillWidgets.empty()) @@ -333,9 +331,6 @@ void ReviewDialog::updateSkillArea() if (!miscSkills.empty()) addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); - WindowManager *wm = environment.mWindowManager; - ESMS::ESMStore &store = environment.mWorld->getStore(); - clientHeight = coord1.top; updateScroller(); } From 6bf10c93c857d4b53eadf404da1b9b53fb4d8c93 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:25:16 +0100 Subject: [PATCH 13/28] Create a base class for dialog windows --- apps/openmw/CMakeLists.txt | 2 ++ apps/openmw/mwgui/window_base.cpp | 25 +++++++++++++++++++++++++ apps/openmw/mwgui/window_base.hpp | 27 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 apps/openmw/mwgui/window_base.cpp create mode 100644 apps/openmw/mwgui/window_base.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 78477aae4..88aaaecd4 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -45,6 +45,7 @@ set(GAMEGUI_HEADER mwgui/console.hpp mwgui/dialogue.hpp mwgui/dialogue_history.hpp + mwgui/window_base.hpp ) set(GAMEGUI mwgui/window_manager.cpp @@ -58,6 +59,7 @@ set(GAMEGUI mwgui/review.cpp mwgui/dialogue.cpp mwgui/dialogue_history.cpp + mwgui/window_base.cpp ) source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) diff --git a/apps/openmw/mwgui/window_base.cpp b/apps/openmw/mwgui/window_base.cpp new file mode 100644 index 000000000..d6c0a8bfc --- /dev/null +++ b/apps/openmw/mwgui/window_base.cpp @@ -0,0 +1,25 @@ +#include "window_base.hpp" +#include "../mwworld/environment.hpp" +#include "window_manager.hpp" + +using namespace MWGui; + +WindowBase::WindowBase(const std::string& parLayout, MWWorld::Environment& parEnvironment) + : Layout(parLayout) + , environment(parEnvironment) +{ +} + +void WindowBase::open() +{ +} + +void WindowBase::center() +{ + // 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); +} diff --git a/apps/openmw/mwgui/window_base.hpp b/apps/openmw/mwgui/window_base.hpp new file mode 100644 index 000000000..931e7ece1 --- /dev/null +++ b/apps/openmw/mwgui/window_base.hpp @@ -0,0 +1,27 @@ +#ifndef MWGUI_WINDOW_BASE_H +#define MWGUI_WINDOW_BASE_H + +#include + +namespace MWWorld +{ + class Environment; +} + +namespace MWGui +{ + class WindowBase: public OEngine::GUI::Layout + { + public: + WindowBase(const std::string& parLayout, MWWorld::Environment& parEnvironment); + + virtual void open(); + void center(); + + protected: + MWWorld::Environment& environment; + }; +} + +#endif + From 933af72d6028e15f2b0a154ac5365b2b22824a99 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:26:17 +0100 Subject: [PATCH 14/28] Make BirthDialog use the new WindowBase --- apps/openmw/mwgui/birth.cpp | 9 ++------- apps/openmw/mwgui/birth.hpp | 6 ++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 608d2a9e6..84814d778 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -12,15 +12,10 @@ using namespace MWGui; using namespace Widgets; BirthDialog::BirthDialog(MWWorld::Environment& environment) - : Layout("openmw_chargen_birth_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_birth_layout.xml", 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); + center(); getWidget(spellArea, "SpellArea"); diff --git a/apps/openmw/mwgui/birth.hpp b/apps/openmw/mwgui/birth.hpp index 192a03e48..5a8d11b7e 100644 --- a/apps/openmw/mwgui/birth.hpp +++ b/apps/openmw/mwgui/birth.hpp @@ -1,7 +1,7 @@ #ifndef MWGUI_BIRTH_H #define MWGUI_BIRTH_H -#include +#include "window_base.hpp" namespace MWWorld { @@ -17,7 +17,7 @@ namespace MWGui { using namespace MyGUI; - class BirthDialog : public OEngine::GUI::Layout + class BirthDialog : public WindowBase { public: BirthDialog(MWWorld::Environment& environment); @@ -57,8 +57,6 @@ namespace MWGui void updateBirths(); void updateSpells(); - MWWorld::Environment& environment; - MyGUI::ListPtr birthList; MyGUI::WidgetPtr spellArea; MyGUI::StaticImagePtr birthImage; From e551c60e755b34939459ebd3f49407714d2c8f45 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:26:45 +0100 Subject: [PATCH 15/28] Make RaceDialog use the new WindowBase --- apps/openmw/mwgui/race.cpp | 9 ++------- apps/openmw/mwgui/race.hpp | 6 ++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 04896aef1..8ba9d8fe2 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -16,8 +16,7 @@ using namespace MWGui; using namespace Widgets; RaceDialog::RaceDialog(MWWorld::Environment& environment) - : Layout("openmw_chargen_race_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_race_layout.xml", environment) , genderIndex(0) , faceIndex(0) , hairIndex(0) @@ -25,11 +24,7 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment) , hairCount(14) { // 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); + center(); // These are just demo values, you should replace these with // real calls from outside the class later. diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index bfa3c505d..47774703c 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -3,7 +3,7 @@ #include -#include +#include "window_base.hpp" #include @@ -21,7 +21,7 @@ namespace MWGui { using namespace MyGUI; - class RaceDialog : public OEngine::GUI::Layout + class RaceDialog : public WindowBase { public: RaceDialog(MWWorld::Environment& environment); @@ -80,8 +80,6 @@ namespace MWGui void updateSkills(); void updateSpellPowers(); - MWWorld::Environment& environment; - MyGUI::CanvasPtr appearanceBox; MyGUI::ListPtr raceList; MyGUI::HScrollPtr headRotate; From 5db021e99ba97154369b581b3464b846c08abe82 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:27:53 +0100 Subject: [PATCH 16/28] Make TextInputDialog use the new WindowBase --- apps/openmw/mwgui/text_input.cpp | 9 ++------- apps/openmw/mwgui/text_input.hpp | 6 ++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index e1fc216c9..3758e75e6 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -6,15 +6,10 @@ using namespace MWGui; TextInputDialog::TextInputDialog(MWWorld::Environment& environment) - : Layout("openmw_text_input_layout.xml") - , environment(environment) + : WindowBase("openmw_text_input_layout.xml", 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); + center(); getWidget(textEdit, "TextEdit"); textEdit->eventEditSelectAccept = newDelegate(this, &TextInputDialog::onTextAccepted); diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index 5a38e9b46..9ca55715b 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -1,7 +1,7 @@ #ifndef MWGUI_TEXT_INPUT_H #define MWGUI_TEXT_INPUT_H -#include +#include "window_base.hpp" namespace MWWorld { @@ -15,7 +15,7 @@ namespace MWGui { using namespace MyGUI; - class TextInputDialog : public OEngine::GUI::Layout + class TextInputDialog : public WindowBase { public: TextInputDialog(MWWorld::Environment& environment); @@ -40,8 +40,6 @@ namespace MWGui void onTextAccepted(MyGUI::Edit* _sender); private: - MWWorld::Environment& environment; - MyGUI::EditPtr textEdit; }; } From 2e7e79f596ebc39da69f19fd48f63c112a7270fa Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:29:03 +0100 Subject: [PATCH 17/28] Make ReviewDialog use the new WindowBase --- apps/openmw/mwgui/review.cpp | 9 ++------- apps/openmw/mwgui/review.hpp | 6 ++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index e193b6072..9eb6092ce 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -14,16 +14,11 @@ using namespace Widgets; const int ReviewDialog::lineHeight = 18; ReviewDialog::ReviewDialog(MWWorld::Environment& environment) - : Layout("openmw_chargen_review_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_review_layout.xml", environment) , lastPos(0) { // 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); + center(); WindowManager *wm = environment.mWindowManager; diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 2809b67c9..25a183f65 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -1,8 +1,7 @@ #ifndef MWGUI_REVIEW_H #define MWGUI_REVIEW_H -#include -#include +#include "window_base.hpp" #include "../mwmechanics/stat.hpp" #include "widgets.hpp" @@ -20,7 +19,7 @@ namespace MWGui { using namespace MyGUI; - class ReviewDialog : public OEngine::GUI::Layout + class ReviewDialog : public WindowBase { public: typedef std::vector SkillList; @@ -106,7 +105,6 @@ namespace MWGui static const int lineHeight; - MWWorld::Environment& environment; MyGUI::StaticTextPtr nameWidget, raceWidget, classWidget, birthSignWidget; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::VScrollPtr skillScrollerWidget; From 6c7f59725fc5cc08ece462f676ae9826a19cdf5e Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:29:49 +0100 Subject: [PATCH 18/28] Make StatsWindow use the new WindowBase --- apps/openmw/mwgui/layouts.cpp | 6 +++--- apps/openmw/mwgui/layouts.hpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 33ab090bd..501b234d1 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -13,8 +13,7 @@ using namespace MWGui; const int StatsWindow::lineHeight = 18; StatsWindow::StatsWindow (MWWorld::Environment& environment) - : Layout("openmw_stats_window_layout.xml") - , environment(environment) + : WindowBase("openmw_stats_window_layout.xml", environment) , lastPos(0) , reputation(0) , bounty(0) @@ -59,7 +58,8 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment) skillWidgetMap.insert(std::pair(i, nullptr)); } - static_cast(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize); + MyGUI::WindowPtr t = static_cast(mMainWidget); + t->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize); } void StatsWindow::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos) diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 574e51c8f..097790163 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -15,6 +15,7 @@ #include "../mwmechanics/stat.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "window_base.hpp" /* This file contains classes corresponding to all the window layouts @@ -177,7 +178,7 @@ namespace MWGui } }; - class StatsWindow : public OEngine::GUI::Layout + class StatsWindow : public WindowBase { public: typedef std::pair Faction; @@ -225,7 +226,6 @@ namespace MWGui static const int lineHeight; - MWWorld::Environment& environment; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::VScrollPtr skillScrollerWidget; int lastPos, clientHeight; From 0d97200e182ed713c649d94da7b7f27ee07e48ef Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:33:30 +0100 Subject: [PATCH 19/28] Make InfoBoxDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 13 +------------ apps/openmw/mwgui/class.hpp | 6 ++---- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 88e553821..0ec07c650 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -291,8 +291,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin) } InfoBoxDialog::InfoBoxDialog(MWWorld::Environment& environment) - : Layout("openmw_infobox_layout.xml") - , environment(environment) + : WindowBase("openmw_infobox_layout.xml", environment) , currentButton(-1) { getWidget(textBox, "TextBox"); @@ -373,16 +372,6 @@ void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender) } } -void InfoBoxDialog::center() -{ - // 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); -} - /* ClassChoiceDialog */ ClassChoiceDialog::ClassChoiceDialog(MWWorld::Environment& environment) diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index bd7a785a4..816152e3a 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -8,6 +8,7 @@ #include #include "widgets.hpp" +#include "window_base.hpp" namespace MWWorld { @@ -23,7 +24,7 @@ namespace MWGui { using namespace MyGUI; - class InfoBoxDialog : public OEngine::GUI::Layout + class InfoBoxDialog : public WindowBase { public: InfoBoxDialog(MWWorld::Environment& environment); @@ -49,9 +50,6 @@ namespace MWGui void onButtonClicked(MyGUI::WidgetPtr _sender); private: - void center(); - - MWWorld::Environment& environment; void fitToText(MyGUI::StaticTextPtr widget); void layoutVertically(MyGUI::WidgetPtr widget, int margin); From ed05c5752b9f6477514919a2f3c6e748d9723013 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:37:00 +0100 Subject: [PATCH 20/28] Make GenerateClassResultDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 9 ++------- apps/openmw/mwgui/class.hpp | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 0ec07c650..ee13e7719 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -15,15 +15,10 @@ using namespace MWGui; /* GenerateClassResultDialog */ GenerateClassResultDialog::GenerateClassResultDialog(MWWorld::Environment& environment) - : Layout("openmw_chargen_generate_class_result_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_generate_class_result_layout.xml", 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); + center(); WindowManager *wm = environment.mWindowManager; setText("ReflectT", wm->getGameSettingString("sMessageQuestionAnswer1", "")); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 816152e3a..fbbd7efbf 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -75,7 +75,7 @@ namespace MWGui ClassChoiceDialog(MWWorld::Environment& environment); }; - class GenerateClassResultDialog : public OEngine::GUI::Layout + class GenerateClassResultDialog : public WindowBase { public: GenerateClassResultDialog(MWWorld::Environment& environment); @@ -103,8 +103,6 @@ namespace MWGui void onBackClicked(MyGUI::Widget* _sender); private: - MWWorld::Environment& environment; - MyGUI::StaticImagePtr classImage; MyGUI::StaticTextPtr className; From 4e8f55b63090ec5f9659f79b6abb29e960777666 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:38:29 +0100 Subject: [PATCH 21/28] Make PickClassDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 9 ++------- apps/openmw/mwgui/class.hpp | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index ee13e7719..8466c9d3e 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -69,15 +69,10 @@ void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender) /* PickClassDialog */ PickClassDialog::PickClassDialog(MWWorld::Environment& environment) - : Layout("openmw_chargen_class_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_class_layout.xml", 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); + center(); WindowManager *wm = environment.mWindowManager; setText("SpecializationT", wm->getGameSettingString("sChooseClassMenu1", "Specialization")); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index fbbd7efbf..28c2df3c7 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -109,7 +109,7 @@ namespace MWGui std::string currentClassId; }; - class PickClassDialog : public OEngine::GUI::Layout + class PickClassDialog : public WindowBase { public: PickClassDialog(MWWorld::Environment& environment); @@ -143,8 +143,6 @@ namespace MWGui void updateClasses(); void updateStats(); - MWWorld::Environment& environment; - MyGUI::StaticImagePtr classImage; MyGUI::ListPtr classList; MyGUI::StaticTextPtr specializationName; From 037c1021e34b377c03d9c038427907c758b05882 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:39:38 +0100 Subject: [PATCH 22/28] Make SelectSpecializationDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 7 ++----- apps/openmw/mwgui/class.hpp | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 8466c9d3e..f52836f47 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -670,13 +670,10 @@ void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender) /* SelectSpecializationDialog */ SelectSpecializationDialog::SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) - : Layout("openmw_chargen_select_specialization_layout.xml") + : WindowBase("openmw_chargen_select_specialization_layout.xml", 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); + center(); WindowManager *wm = environment.mWindowManager; diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 28c2df3c7..59d4d721c 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -153,7 +153,7 @@ namespace MWGui std::string currentClassId; }; - class SelectSpecializationDialog : public OEngine::GUI::Layout + class SelectSpecializationDialog : public WindowBase { public: SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); From 8f334d1df2e2b51fd7d5ebaca48896a8f630635b Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:40:41 +0100 Subject: [PATCH 23/28] Make SelectAttributeDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 7 ++----- apps/openmw/mwgui/class.hpp | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index f52836f47..b8ce4b71f 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -721,13 +721,10 @@ void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender) /* SelectAttributeDialog */ SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) - : Layout("openmw_chargen_select_attribute_layout.xml") + : WindowBase("openmw_chargen_select_attribute_layout.xml", 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); + center(); WindowManager *wm = environment.mWindowManager; diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 59d4d721c..6236263af 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -183,7 +183,7 @@ namespace MWGui ESM::Class::Specialization specializationId; }; - class SelectAttributeDialog : public OEngine::GUI::Layout + class SelectAttributeDialog : public WindowBase { public: SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); From 12dee62307655a6ce9e548c08e5ac163bb422154 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:41:41 +0100 Subject: [PATCH 24/28] Make SelectSkillDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 7 ++----- apps/openmw/mwgui/class.hpp | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index b8ce4b71f..3ebe1067c 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -766,13 +766,10 @@ void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender) /* SelectSkillDialog */ SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) - : Layout("openmw_chargen_select_skill_layout.xml") + : WindowBase("openmw_chargen_select_skill_layout.xml", 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); + center(); WindowManager *wm = environment.mWindowManager; diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 6236263af..bb76703f3 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -215,7 +215,7 @@ namespace MWGui ESM::Attribute::AttributeID attributeId; }; - class SelectSkillDialog : public OEngine::GUI::Layout + class SelectSkillDialog : public WindowBase { public: SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); From 6fc0e4d6d6ea227dfec90ee24fc5645b3c1bb24a Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:42:54 +0100 Subject: [PATCH 25/28] Make DescriptionDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 8 ++------ apps/openmw/mwgui/class.hpp | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 3ebe1067c..b2385d4da 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -855,14 +855,10 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender) /* DescriptionDialog */ DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) - : Layout("openmw_chargen_class_description_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_class_description_layout.xml", 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); + center(); getWidget(textEdit, "TextEdit"); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index bb76703f3..39d8b8851 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -250,7 +250,7 @@ namespace MWGui ESM::Skill::SkillEnum skillId; }; - class DescriptionDialog : public OEngine::GUI::Layout + class DescriptionDialog : public WindowBase { public: DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); @@ -270,8 +270,6 @@ namespace MWGui void onOkClicked(MyGUI::Widget* _sender); private: - MWWorld::Environment& environment; - MyGUI::EditPtr textEdit; }; From 770b490539636673e172d72402783ab11ac5e8f5 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:44:02 +0100 Subject: [PATCH 26/28] Make CreateClassDialog use the new WindowBase --- apps/openmw/mwgui/class.cpp | 9 ++------- apps/openmw/mwgui/class.hpp | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index b2385d4da..feabddd05 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -380,19 +380,14 @@ ClassChoiceDialog::ClassChoiceDialog(MWWorld::Environment& environment) /* CreateClassDialog */ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment) - : Layout("openmw_chargen_create_class_layout.xml") - , environment(environment) + : WindowBase("openmw_chargen_create_class_layout.xml", environment) , specDialog(nullptr) , attribDialog(nullptr) , skillDialog(nullptr) , descDialog(nullptr) { // 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); + center(); WindowManager *wm = environment.mWindowManager; setText("SpecializationT", wm->getGameSettingString("sChooseClassMenu1", "Specialization")); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 39d8b8851..75fd9324d 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -273,7 +273,7 @@ namespace MWGui MyGUI::EditPtr textEdit; }; - class CreateClassDialog : public OEngine::GUI::Layout + class CreateClassDialog : public WindowBase { public: CreateClassDialog(MWWorld::Environment& environment); @@ -317,8 +317,6 @@ namespace MWGui void onDialogCancel(); private: - MWWorld::Environment& environment; - MyGUI::EditPtr editName; MyGUI::WidgetPtr specializationName; Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; From 180164b2f3a56c878db8211a89ae8da202b34510 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:45:13 +0100 Subject: [PATCH 27/28] Remove unnecessary includes --- apps/openmw/mwgui/class.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 75fd9324d..d2a198737 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -1,12 +1,7 @@ #ifndef MWGUI_CLASS_H #define MWGUI_CLASS_H -#include - -#include - #include - #include "widgets.hpp" #include "window_base.hpp" From d9d626cc957c139df9c5fc550e429328d201e930 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 6 Nov 2010 11:47:46 +0100 Subject: [PATCH 28/28] Make DialogueWindow use the new WindowBase --- apps/openmw/mwgui/dialogue.cpp | 9 ++------- apps/openmw/mwgui/dialogue.hpp | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 6f2ca8e96..fe43cabc9 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -17,15 +17,10 @@ using namespace MWGui; using namespace Widgets; DialogueWindow::DialogueWindow(MWWorld::Environment& environment) - : Layout("openmw_dialogue_window_layout.xml") - , environment(environment) + : WindowBase("openmw_dialogue_window_layout.xml", 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); + center(); //WindowManager *wm = environment.mWindowManager; setText("NpcName", "Name of character"); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 625ca225d..3e4852203 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -1,10 +1,7 @@ #ifndef MWGUI_DIALOGE_H #define MWGUI_DIALOGE_H -#include - -#include - +#include "window_base.hpp" #include namespace MWWorld @@ -23,7 +20,7 @@ namespace MWGui using namespace MyGUI; - class DialogueWindow: public OEngine::GUI::Layout + class DialogueWindow: public WindowBase { public: DialogueWindow(MWWorld::Environment& environment); @@ -46,8 +43,6 @@ namespace MWGui private: void updateOptions(); - MWWorld::Environment& environment; - DialogeHistory* history; MyGUI::ListPtr topicsList; };