From 3cc57a058a1b696f0bb917f419766622c5cefdb6 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 12:41:53 +0200 Subject: [PATCH 01/18] The label for the name dialog is now fetched from the GMST store. --- apps/openmw/mwgui/window_manager.cpp | 13 ++++++++++++- apps/openmw/mwgui/window_manager.hpp | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index f704c16ade..948f55577b 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -94,7 +94,10 @@ void WindowManager::updateVisible() if (mode == GM_Name) { if (!nameDialog) - nameDialog = new TextInputDialog(environment, "Name", nameChosen, gui->getViewSize()); + { + std::string sName = getGameSettingString("sName", "Name"); + nameDialog = new TextInputDialog(environment, sName, nameChosen, gui->getViewSize()); + } nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone); nameDialog->setVisible(true); return; @@ -152,6 +155,14 @@ void WindowManager::messageBox (const std::string& message, const std::vectorgetStore().gameSettings.search(id); + if (setting && setting->type == ESM::VT_String) + return setting->str; + return default; +} + void WindowManager::updateCharacterGeneration() { if (raceDialog) diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 2dcbb848d8..bca7fb8396 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -167,6 +167,15 @@ namespace MWGui void messageBox (const std::string& message, const std::vector& buttons); private: + /** + * Fetches a GMST string from the store, if there is no setting with the given + * ID or it is not a string the default string is returned. + * + * @param id Identifier for the GMST setting, e.g. "aName" + * @param default Default value if the GMST setting cannot be used. + */ + const std::string &getGameSettingString(const std::string &id, const std::string &default); + void updateCharacterGeneration(); void checkCharacterGeneration(GuiMode mode); From a676763aa60289cd517438e50d793c917b8b60cf Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 12:44:43 +0200 Subject: [PATCH 02/18] Dialog now goes to next dialog if the "next" button is shown, this follows Morrowind's behavior. --- apps/openmw/mwgui/window_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 948f55577b..e1382fd401 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -176,6 +176,7 @@ void WindowManager::updateCharacterGeneration() void WindowManager::onNameDialogDone() { + bool goNext = nameChosen; // Go to next dialog if name was previously chosen nameChosen = true; if (nameDialog) { @@ -189,12 +190,13 @@ void WindowManager::onNameDialogDone() if (reviewNext) setMode(GM_Review); - else if (raceChosen) + else if (goNext) setMode(GM_Race); } void WindowManager::onRaceDialogDone() { + bool goNext = nameChosen; // Go to next dialog if race was previously chosen raceChosen = true; if (raceDialog) { @@ -208,7 +210,7 @@ void WindowManager::onRaceDialogDone() if (reviewNext) setMode(GM_Review); - else if (classChosen) + else if (goNext) setMode(GM_Class); } From 0dafd30dfc16132eb7d78037d761e9634d072770 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 12:56:44 +0200 Subject: [PATCH 03/18] The race dialog now fetches strings from GMST. --- apps/openmw/mwgui/race.cpp | 11 +++++++++-- apps/openmw/mwgui/window_manager.hpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index a9549bc244..37217ee9c8 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -1,6 +1,7 @@ #include "race.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "window_manager.hpp" #include "components/esm_store/store.hpp" #include @@ -26,7 +27,8 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext) // These are just demo values, you should replace these with // real calls from outside the class later. - setText("AppearanceT", "Appearance"); + WindowManager *wm = environment.mWindowManager; + setText("AppearanceT", wm->getGameSettingString("sRaceMenu1", "Appearance")); getWidget(appearanceBox, "AppearanceBox"); getWidget(headRotate, "HeadRotate"); @@ -38,29 +40,34 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext) // Set up next/previous buttons MyGUI::ButtonPtr prevButton, nextButton; + setText("GenderChoiceT", wm->getGameSettingString("sRaceMenu2", "Change Sex")); getWidget(prevButton, "PrevGenderButton"); getWidget(nextButton, "NextGenderButton"); prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender); nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender); + setText("FaceChoiceT", wm->getGameSettingString("sRaceMenu3", "Change Face")); getWidget(prevButton, "PrevFaceButton"); getWidget(nextButton, "NextFaceButton"); prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace); nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace); + setText("HairChoiceT", wm->getGameSettingString("sRaceMenu3", "Change Hair")); getWidget(prevButton, "PrevHairButton"); getWidget(nextButton, "NextHairButton"); prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair); nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); - setText("RaceT", "Race"); + setText("RaceT", wm->getGameSettingString("sRaceMenu4", "Race")); getWidget(raceList, "RaceList"); raceList->setScrollVisible(true); raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + setText("SkillsT", wm->getGameSettingString("sBonusSkillTitle", "Skill Bonus")); getWidget(skillList, "SkillList"); + setText("SpellPowerT", wm->getGameSettingString("sRaceMenu7", "Specials")); getWidget(spellPowerList, "SpellPowerList"); // TODO: These buttons should be managed by a Dialog class diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index bca7fb8396..7be3bf991b 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -166,7 +166,6 @@ namespace MWGui void messageBox (const std::string& message, const std::vector& buttons); - private: /** * Fetches a GMST string from the store, if there is no setting with the given * ID or it is not a string the default string is returned. @@ -176,6 +175,7 @@ namespace MWGui */ const std::string &getGameSettingString(const std::string &id, const std::string &default); + private: void updateCharacterGeneration(); void checkCharacterGeneration(GuiMode mode); From 850b8eb6a7aed99dd33b9fad57fbd9059b54a9c5 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 13:04:57 +0200 Subject: [PATCH 04/18] Race dialog uses the ID of the race object instead of the name when referencing it. --- apps/openmw/mwgui/race.cpp | 24 ++++++++++++------------ apps/openmw/mwgui/race.hpp | 6 +++--- apps/openmw/mwgui/window_manager.cpp | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 37217ee9c8..ae1b8081b1 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -92,14 +92,14 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext) updateSpellPowers(); } -void RaceDialog::setRace(const std::string &race) +void RaceDialog::setRaceId(const std::string &raceId) { - currentRace = race; + currentRaceId = raceId; raceList->setIndexSelected(MyGUI::ITEM_NONE); size_t count = raceList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (boost::iequals(raceList->getItem(i), race)) + if (boost::iequals(raceList->getItem(i), raceId)) { raceList->setIndexSelected(i); break; @@ -172,11 +172,11 @@ void RaceDialog::onSelectRace(MyGUI::List* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; - const std::string race = raceList->getItem(_index); - if (boost::iequals(currentRace, race)) + const std::string *raceId = raceList->getItemDataAt(_index); + if (boost::iequals(currentRaceId, *raceId)) return; - currentRace = race; + currentRaceId = *raceId; updateSkills(); updateSpellPowers(); } @@ -199,8 +199,8 @@ void RaceDialog::updateRaces() if (!playable) // Only display playable races continue; - raceList->addItem(race.name); - if (boost::iequals(race.name, currentRace)) + raceList->addItem(race.name, it->first); + if (boost::iequals(race.name, currentRaceId)) raceList->setIndexSelected(index); ++index; } @@ -214,7 +214,7 @@ void RaceDialog::updateSkills() } skillItems.clear(); - if (currentRace.empty()) + if (currentRaceId.empty()) return; MyGUI::StaticTextPtr skillNameWidget, skillBonusWidget; @@ -223,7 +223,7 @@ void RaceDialog::updateSkills() MyGUI::IntCoord coord2(coord1.left + coord1.width, 0, 40, 18); ESMS::ESMStore &store = environment.mWorld->getStore(); - const ESM::Race *race = store.races.find(currentRace); + const ESM::Race *race = store.races.find(currentRaceId); int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) { @@ -257,7 +257,7 @@ void RaceDialog::updateSpellPowers() } spellPowerItems.clear(); - if (currentRace.empty()) + if (currentRaceId.empty()) return; MyGUI::StaticTextPtr spellPowerWidget; @@ -265,7 +265,7 @@ void RaceDialog::updateSpellPowers() MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); ESMS::ESMStore &store = environment.mWorld->getStore(); - const ESM::Race *race = store.races.find(currentRace); + const ESM::Race *race = store.races.find(currentRaceId); std::vector::const_iterator it = race->powers.list.begin(); std::vector::const_iterator end = race->powers.list.end(); diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 749bf55b29..655f74ed45 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -34,12 +34,12 @@ namespace MWGui GM_Female }; - const std::string &getRace() const { return currentRace; } + const std::string &getRaceId() const { return currentRaceId; } Gender getGender() const { return genderIndex == 0 ? GM_Male : GM_Female; } // getFace() // getHair() - void setRace(const std::string &race); + void setRaceId(const std::string &raceId); void setGender(Gender gender) { genderIndex = gender == GM_Male ? 0 : 1; } // setFace() // setHair() @@ -93,7 +93,7 @@ namespace MWGui int genderIndex, faceIndex, hairIndex; int faceCount, hairCount; - std::string currentRace; + std::string currentRaceId; }; } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index e1382fd401..f0e0c5b694 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -201,7 +201,7 @@ void WindowManager::onRaceDialogDone() if (raceDialog) { raceDialog->setVisible(false); - environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male); + environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); } delete raceDialog; raceDialog = nullptr; @@ -219,7 +219,7 @@ void WindowManager::onRaceDialogBack() if (raceDialog) { raceDialog->setVisible(false); - environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male); + environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); } delete raceDialog; raceDialog = nullptr; From 3f1b90e732b78a9ac66ae0790b113325a98babaf Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 13:10:47 +0200 Subject: [PATCH 05/18] When a dialog is done and no new is to be shown we return to Game mode. --- apps/openmw/mwgui/window_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index f0e0c5b694..6bcc2743a1 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -192,6 +192,8 @@ void WindowManager::onNameDialogDone() setMode(GM_Review); else if (goNext) setMode(GM_Race); + else + setMode(GM_Game); } void WindowManager::onRaceDialogDone() @@ -212,6 +214,8 @@ void WindowManager::onRaceDialogDone() setMode(GM_Review); else if (goNext) setMode(GM_Class); + else + setMode(GM_Game); } void WindowManager::onRaceDialogBack() From b037780a7d8cc4eaf44ae76c4a5a69e888949d36 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 13:15:58 +0200 Subject: [PATCH 06/18] Disable the invenory window for now, it's not complete and gives compiler warnings. --- apps/openmw/mwgui/layouts.hpp | 2 ++ apps/openmw/mwgui/window_manager.cpp | 8 ++++++++ apps/openmw/mwgui/window_manager.hpp | 2 ++ 3 files changed, 12 insertions(+) diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 8ab5331615..1c1b2dcb61 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -271,6 +271,7 @@ namespace MWGui } }; +#if 0 class InventoryWindow : public OEngine::GUI::Layout { public: @@ -389,5 +390,6 @@ namespace MWGui MyGUI::Colour activeColor; MyGUI::Colour inactiveColor; }; +#endif } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 6bcc2743a1..7ee0b46c01 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -37,7 +37,9 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment menu = new MainMenu(w,h); map = new MapWindow(); stats = new StatsWindow (environment.mWorld->getStore()); +#if 0 inventory = new InventoryWindow (); +#endif console = new Console(w,h, environment, extensions); // The HUD is always on @@ -54,7 +56,9 @@ WindowManager::~WindowManager() delete map; delete menu; delete stats; +#if 0 delete inventory; +#endif delete nameDialog; delete raceDialog; @@ -66,7 +70,9 @@ void WindowManager::updateVisible() map->setVisible(false); menu->setVisible(false); stats->setVisible(false); +#if 0 inventory->setVisible(false); +#endif console->disable(); // Mouse is visible whenever we're not in game mode @@ -124,7 +130,9 @@ void WindowManager::updateVisible() // Show the windows we want map -> setVisible( eff & GW_Map ); stats -> setVisible( eff & GW_Stats ); +#if 0 // inventory -> setVisible( eff & GW_Inventory ); +#endif return; } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 7be3bf991b..31b091c78d 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -85,7 +85,9 @@ namespace MWGui MapWindow *map; MainMenu *menu; StatsWindow *stats; +#if 0 InventoryWindow *inventory; +#endif Console *console; // Character creation From 869bc4d0845eda8afbaffc6ed994547f1730b727 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 13:16:54 +0200 Subject: [PATCH 07/18] Silence the compiler. --- apps/openmw/mwgui/window_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 7ee0b46c01..d2c2db218b 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -128,8 +128,8 @@ void WindowManager::updateVisible() int eff = shown & allowed; // Show the windows we want - map -> setVisible( eff & GW_Map ); - stats -> setVisible( eff & GW_Stats ); + map -> setVisible( (eff & GW_Map) != 0 ); + stats -> setVisible( (eff & GW_Stats) != 0 ); #if 0 // inventory -> setVisible( eff & GW_Inventory ); #endif From 30e0d713ed92949f9d8bc617c4d8518b0f9ff646 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 13:44:24 +0200 Subject: [PATCH 08/18] Changed list of skill names to contain the ID of the names instead, the actual names are then fetched from GMST. --- apps/openmw/mwgui/race.cpp | 4 ++- components/esm/loadskil.hpp | 2 +- components/esm/skill.cpp | 56 ++++++++++++++++++------------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index ae1b8081b1..5d8e90298d 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -222,6 +222,7 @@ void RaceDialog::updateSkills() MyGUI::IntCoord coord1(0, 0, skillList->getWidth() - (40 + 4), 18); MyGUI::IntCoord coord2(coord1.left + coord1.width, 0, 40, 18); + WindowManager *wm = environment.mWindowManager; ESMS::ESMStore &store = environment.mWorld->getStore(); const ESM::Race *race = store.races.find(currentRaceId); int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? @@ -234,7 +235,8 @@ void RaceDialog::updateSkills() skillNameWidget = skillList->createWidget("SandText", coord1, MyGUI::Align::Default, std::string("SkillName") + boost::lexical_cast(i)); assert(skillId >= 0 && skillId < ESM::Skill::Length); - skillNameWidget->setCaption(ESMS::Skill::sSkillNames[skillId]); + const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; + skillNameWidget->setCaption(wm->getGameSettingString(skillNameId, skillNameId)); skillBonusWidget = skillList->createWidget("SandTextRight", coord2, MyGUI::Align::Default, std::string("SkillBonus") + boost::lexical_cast(i)); diff --git a/components/esm/loadskil.hpp b/components/esm/loadskil.hpp index fbe11f1db9..27959c4efa 100644 --- a/components/esm/loadskil.hpp +++ b/components/esm/loadskil.hpp @@ -61,7 +61,7 @@ struct Skill HandToHand = 26, Length }; - static const std::string sSkillNames[Length]; + static const std::string sSkillNameIds[Length]; void load(ESMReader &esm) { diff --git a/components/esm/skill.cpp b/components/esm/skill.cpp index cc56a40594..021248ab9c 100644 --- a/components/esm/skill.cpp +++ b/components/esm/skill.cpp @@ -2,33 +2,33 @@ namespace ESM { - const std::string Skill::sSkillNames[Length] = { - "Block", - "Armorer", - "Medium Armor", - "Heavy Armor", - "Blunt Weapon", - "Long Blade", - "Axe", - "Spear", - "Athletics", - "Enchant", - "Destruction", - "Alteration", - "Illusion", - "Conjuration", - "Mysticism", - "Restoration", - "Alchemy", - "Unarmored", - "Security", - "Sneak", - "Acrobatics", - "Light Armor", - "Short Blade", - "Marksman", - "Mercantile", - "Speechcraft", - "Hand To Hand", + const std::string Skill::sSkillNameIds[Length] = { + "sSkillBlock", + "sSkillArmorer", + "sSkillMediumarmor", + "sSkillHeavyarmor", + "sSkillBluntweapon", + "sSkillLongblade", + "sSkillAxe", + "sSkillSpear", + "sSkillAthletics", + "sSkillEnchant", + "sSkillDestruction", + "sSkillAlteration", + "sSkillIllusion", + "sSkillConjuration", + "sSkillMysticism", + "sSkillRestoration", + "sSkillAlchemy", + "sSkillUnarmored", + "sSkillSecurity", + "sSkillSneak", + "sSkillAcrobatics", + "sSkillLightarmor", + "sSkillShortblade", + "sSkillMarksman", + "sSkillMercantile", + "sSkillSpeechcraft", + "sSkillHandtohand", }; } From 1907aeb6c6536a50f79f6a99222a8be82da1a630 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 14:48:19 +0200 Subject: [PATCH 09/18] The game mode is now properly restored once a dialog is finished. Previously the game mode was only set in the window manager but it has to go through the input manager firs to get correct input state. Also updated the gui script commands to also use the input manager and not the window manager. At some point the gui mode code should be moved to a class that handles all game mode (engine?). --- apps/openmw/engine.cpp | 1 + apps/openmw/mwgui/mode.hpp | 43 +++++++++++++++ apps/openmw/mwgui/window_manager.cpp | 21 ++++--- apps/openmw/mwgui/window_manager.hpp | 37 +------------ apps/openmw/mwinput/inputmanager.cpp | 61 +++++++++++---------- apps/openmw/mwinput/inputmanager.hpp | 4 ++ apps/openmw/mwscript/guiextensions.cpp | 3 +- apps/openmw/mwscript/interpretercontext.cpp | 7 +++ apps/openmw/mwscript/interpretercontext.hpp | 7 +++ apps/openmw/mwworld/environment.hpp | 11 +++- 10 files changed, 120 insertions(+), 75 deletions(-) create mode 100644 apps/openmw/mwgui/mode.hpp diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index bcb2d7f599..cc6e9470af 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -271,6 +271,7 @@ void OMW::Engine::go() // Sets up the input system MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), *mEnvironment.mWindowManager, mDebug, *this); + mEnvironment.mInputManager = &input; focusFrameCounter = 0; diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp new file mode 100644 index 0000000000..b18dd9f959 --- /dev/null +++ b/apps/openmw/mwgui/mode.hpp @@ -0,0 +1,43 @@ +#ifndef MWGUI_MODE_H +#define MWGUI_MODE_H + +namespace MWGui +{ + enum GuiMode + { + GM_Game, // Game mode, only HUD + GM_Inventory, // Inventory mode + GM_MainMenu, // Main menu mode + + GM_Console, // Console mode + + // None of the following are implemented yet + + GM_Dialogue, // NPC interaction + GM_Barter, + GM_Rest, + // .. more here .. + + // Startup character creation dialogs + GM_Name, + GM_Race, + GM_Birth, + GM_Class, + GM_Review + }; + + // Windows shown in inventory mode + enum GuiWindow + { + GW_None = 0, + + GW_Map = 0x01, + GW_Inventory = 0x02, + GW_Magic = 0x04, + GW_Stats = 0x08, + + GW_ALL = 0xFF + }; +} + +#endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index d2c2db218b..16c2dec213 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -4,6 +4,7 @@ #include "race.hpp" #include "../mwmechanics/mechanicsmanager.hpp" +#include "../mwinput/inputmanager.hpp" #include "console.hpp" @@ -136,8 +137,10 @@ void WindowManager::updateVisible() return; } - // All other modes are ignored - mode = GM_Game; + // 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. + environment.mInputManager->setGuiMode(GM_Game); } void WindowManager::setValue (const std::string& id, const MWMechanics::Stat& value) @@ -197,11 +200,11 @@ void WindowManager::onNameDialogDone() updateCharacterGeneration(); if (reviewNext) - setMode(GM_Review); + environment.mInputManager->setGuiMode(GM_Review); else if (goNext) - setMode(GM_Race); + environment.mInputManager->setGuiMode(GM_Race); else - setMode(GM_Game); + environment.mInputManager->setGuiMode(GM_Game); } void WindowManager::onRaceDialogDone() @@ -219,11 +222,11 @@ void WindowManager::onRaceDialogDone() updateCharacterGeneration(); if (reviewNext) - setMode(GM_Review); + environment.mInputManager->setGuiMode(GM_Review); else if (goNext) - setMode(GM_Class); + environment.mInputManager->setGuiMode(GM_Class); else - setMode(GM_Game); + environment.mInputManager->setGuiMode(GM_Game); } void WindowManager::onRaceDialogBack() @@ -238,5 +241,5 @@ void WindowManager::onRaceDialogBack() updateCharacterGeneration(); - setMode(GM_Name); + environment.mInputManager->setGuiMode(GM_Name); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 31b091c78d..0192186a35 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -14,6 +14,7 @@ #include #include "../mwmechanics/stat.hpp" +#include "mode.hpp" namespace MyGUI { @@ -42,42 +43,6 @@ namespace MWGui class TextInputDialog; class RaceDialog; - enum GuiMode - { - GM_Game, // Game mode, only HUD - GM_Inventory, // Inventory mode - GM_MainMenu, // Main menu mode - - GM_Console, // Console mode - - // None of the following are implemented yet - - GM_Dialogue, // NPC interaction - GM_Barter, - GM_Rest, - // .. more here .. - - // Startup character creation dialogs - GM_Name, - GM_Race, - GM_Birth, - GM_Class, - GM_Review - }; - - // Windows shown in inventory mode - enum GuiWindow - { - GW_None = 0, - - GW_Map = 0x01, - GW_Inventory = 0x02, - GW_Magic = 0x04, - GW_Stats = 0x08, - - GW_ALL = 0xFF - }; - class WindowManager { MWWorld::Environment& environment; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index f730150b0b..8dba12b7a6 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -79,34 +79,6 @@ namespace MWInput ogre.screenshot(buf); } - // Switch between gui modes. Besides controlling the Gui windows - // this also makes sure input is directed to the right place - void setGuiMode(MWGui::GuiMode mode) - { - // Tell the GUI what to show (this also takes care of the mouse - // pointer) - windows.setMode(mode); - - // Are we in GUI mode now? - if(windows.isGuiMode()) - { - // Disable mouse look - mouse->setCamera(NULL); - - // Enable GUI events - guiEvents->enabled = true; - } - else - { - // Start mouse-looking again. TODO: This should also allow - // for other ways to disable mouselook, like paralyzation. - mouse->setCamera(player.getCamera()); - - // Disable GUI events - guiEvents->enabled = false; - } - } - // Called when the user presses the button to toggle the inventory // screen. void toggleInventory() @@ -275,6 +247,34 @@ namespace MWInput return true; } + + // Switch between gui modes. Besides controlling the Gui windows + // this also makes sure input is directed to the right place + void setGuiMode(MWGui::GuiMode mode) + { + // Tell the GUI what to show (this also takes care of the mouse + // pointer) + windows.setMode(mode); + + // Are we in GUI mode now? + if(windows.isGuiMode()) + { + // Disable mouse look + mouse->setCamera(NULL); + + // Enable GUI events + guiEvents->enabled = true; + } + else + { + // Start mouse-looking again. TODO: This should also allow + // for other ways to disable mouselook, like paralyzation. + mouse->setCamera(player.getCamera()); + + // Disable GUI events + guiEvents->enabled = false; + } + } }; MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre, @@ -290,4 +290,9 @@ namespace MWInput { delete impl; } + + void MWInputManager::setGuiMode(MWGui::GuiMode mode) + { + impl->setGuiMode(mode); + } } diff --git a/apps/openmw/mwinput/inputmanager.hpp b/apps/openmw/mwinput/inputmanager.hpp index 554089588d..0e0c4650f0 100644 --- a/apps/openmw/mwinput/inputmanager.hpp +++ b/apps/openmw/mwinput/inputmanager.hpp @@ -1,6 +1,8 @@ #ifndef _MWINPUT_MWINPUTMANAGER_H #define _MWINPUT_MWINPUTMANAGER_H +#include "../mwgui/mode.hpp" + namespace OEngine { namespace Render @@ -45,6 +47,8 @@ namespace MWInput bool debug, OMW::Engine& engine); ~MWInputManager(); + + void setGuiMode(MWGui::GuiMode mode); }; } #endif diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 4d389748d8..0339a11f50 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -8,6 +8,7 @@ #include #include "../mwgui/window_manager.hpp" +#include "../mwinput/inputmanager.hpp" #include "interpretercontext.hpp" @@ -47,7 +48,7 @@ namespace MWScript InterpreterContext& context = static_cast (runtime.getContext()); - context.getWindowManager().setMode(mDialogue); + context.getInputManager().setGuiMode(mDialogue); } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 22a5aaa702..f2f1e6e104 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -11,6 +11,8 @@ #include "../mwgui/window_manager.hpp" +#include "../mwinput/inputmanager.hpp" + #include "locals.hpp" #include "globalscripts.hpp" @@ -263,6 +265,11 @@ namespace MWScript return *mEnvironment.mWindowManager; } + MWInput::MWInputManager& InterpreterContext::getInputManager() + { + return *mEnvironment.mInputManager; + } + MWWorld::World& InterpreterContext::getWorld() { return *mEnvironment.mWorld; diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index ec3c9eb878..031820d5dd 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -15,6 +15,11 @@ namespace MWSound class SoundManager; } +namespace MWInput +{ + struct MWInputManager; +} + namespace MWScript { struct Locals; @@ -107,6 +112,8 @@ namespace MWScript MWGui::WindowManager& getWindowManager(); + MWInput::MWInputManager& getInputManager(); + MWWorld::Ptr getReference(); ///< Reference, that the script is running from (can be empty) }; diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp index f9e2e8a42b..c04dfcbf10 100644 --- a/apps/openmw/mwworld/environment.hpp +++ b/apps/openmw/mwworld/environment.hpp @@ -26,6 +26,11 @@ namespace MWDialogue class DialogueManager; } +namespace MWInput +{ + struct MWInputManager; +} + namespace MWWorld { class World; @@ -36,7 +41,8 @@ namespace MWWorld public: Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mFrameDuration (0) + mMechanicsManager (0), mDialogueManager (0), mFrameDuration (0), + mInputManager (0) {} World *mWorld; @@ -46,6 +52,9 @@ namespace MWWorld MWMechanics::MechanicsManager *mMechanicsManager; MWDialogue::DialogueManager *mDialogueManager; float mFrameDuration; + + // For setting GUI mode + MWInput::MWInputManager *mInputManager; }; } From 58029305006f40711b8bace0689cb74a57545695 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 16:12:36 +0200 Subject: [PATCH 10/18] Text edit field now gets focus when the dialog is shown. --- apps/openmw/mwgui/text_input.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 463f0baf82..fa6f0078ee 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -30,6 +30,9 @@ TextInputDialog::TextInputDialog(MWWorld::Environment& environment, const std::s // Adjust back button when next is shown okButton->setCoord(okButton->getCoord() + MyGUI::IntCoord(-18, 0, 18, 0)); } + + // Make sure the edit box has focus + MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); } // widget controls From 07dd5e5631f93edf8196a4aac9dd411e52ba70b5 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 19:37:06 +0200 Subject: [PATCH 11/18] Race and name dialog are now kept in memory after ok/next is clicked, this avoids a crash where MyGUI would call into the dialog widgets after being destroyed. --- apps/openmw/mwgui/race.cpp | 36 +++++++++++++++++++++------- apps/openmw/mwgui/race.hpp | 4 +++- apps/openmw/mwgui/text_input.cpp | 34 +++++++++++++++++--------- apps/openmw/mwgui/text_input.hpp | 5 +++- apps/openmw/mwgui/window_manager.cpp | 18 ++++++-------- 5 files changed, 64 insertions(+), 33 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 5d8e90298d..b0722d36c0 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -13,7 +13,7 @@ using namespace MWGui; -RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext) +RaceDialog::RaceDialog(MWWorld::Environment& environment) : Layout("openmw_chargen_race_layout.xml") , environment(environment) , genderIndex(0) @@ -78,20 +78,38 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked); - if (showNext) - { - okButton->setCaption("Next"); - - // Adjust back button when next is shown - backButton->setCoord(backButton->getCoord() - MyGUI::IntPoint(18, 0)); - okButton->setCoord(okButton->getCoord() + MyGUI::IntCoord(-18, 0, 18, 0)); - } updateRaces(); updateSkills(); updateSpellPowers(); } +void RaceDialog::setNextButtonShow(bool shown) +{ + MyGUI::ButtonPtr backButton; + getWidget(backButton, "BackButton"); + + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + + // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. + if (shown) + { + okButton->setCaption("Next"); + + // Adjust back button when next is shown + backButton->setCoord(MyGUI::IntCoord(471 - 18, 397, 53, 23)); + okButton->setCoord(MyGUI::IntCoord(532 - 18, 397 + 18, 42, 23)); + } + else + { + okButton->setCaption("ok"); + backButton->setCoord(MyGUI::IntCoord(471, 397, 53, 23)); + okButton->setCoord(MyGUI::IntCoord(532, 397, 42, 23)); + } +} + + void RaceDialog::setRaceId(const std::string &raceId) { currentRaceId = raceId; diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 655f74ed45..98e1dd1fe0 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -26,7 +26,7 @@ namespace MWGui class RaceDialog : public OEngine::GUI::Layout { public: - RaceDialog(MWWorld::Environment& environment, bool showNext); + RaceDialog(MWWorld::Environment& environment); enum Gender { @@ -44,6 +44,8 @@ namespace MWGui // setFace() // setHair() + void setNextButtonShow(bool shown); + // Events /** Event : Back button clicked.\n diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index fa6f0078ee..b81b00c93a 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -4,7 +4,7 @@ using namespace MWGui; -TextInputDialog::TextInputDialog(MWWorld::Environment& environment, const std::string &label, bool showNext, MyGUI::IntSize size) +TextInputDialog::TextInputDialog(MWWorld::Environment& environment, MyGUI::IntSize size) : Layout("openmw_text_input_layout.xml") , environment(environment) { @@ -14,27 +14,39 @@ TextInputDialog::TextInputDialog(MWWorld::Environment& environment, const std::s coord.top = (size.height - coord.height)/2; mMainWidget->setCoord(coord); - setText("LabelT", label); - getWidget(textEdit, "TextEdit"); -// textEdit->eventEditSelectAccept = newDelegate(this, &TextInputDialog::onTextAccepted); + textEdit->eventEditSelectAccept = newDelegate(this, &TextInputDialog::onTextAccepted); // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); - if (showNext) - { - okButton->setCaption("Next"); - - // Adjust back button when next is shown - okButton->setCoord(okButton->getCoord() + MyGUI::IntCoord(-18, 0, 18, 0)); - } // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); } +void TextInputDialog::setNextButtonShow(bool shown) +{ + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + if (shown) + { + okButton->setCaption("Next"); + okButton->setCoord(MyGUI::IntCoord(264 - 18, 60, 42 + 18, 23)); + } + else + { + okButton->setCaption("OK"); + okButton->setCoord(MyGUI::IntCoord(264, 60, 42, 23)); + } +} + +void TextInputDialog::setTextLabel(const std::string &label) +{ + setText("LabelT", label); +} + // widget controls void TextInputDialog::onOkClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index 5f9d7745c4..34312575b8 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -20,11 +20,14 @@ namespace MWGui class TextInputDialog : public OEngine::GUI::Layout { public: - TextInputDialog(MWWorld::Environment& environment, const std::string &label, bool showNext, MyGUI::IntSize size); + TextInputDialog(MWWorld::Environment& environment, MyGUI::IntSize size); std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } + void setNextButtonShow(bool shown); + void setTextLabel(const std::string &label); + // Events /** Event : Dialog finished, OK button clicked.\n diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 16c2dec213..fbd545bb3a 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -101,10 +101,11 @@ void WindowManager::updateVisible() if (mode == GM_Name) { if (!nameDialog) - { - std::string sName = getGameSettingString("sName", "Name"); - nameDialog = new TextInputDialog(environment, sName, nameChosen, gui->getViewSize()); - } + nameDialog = new TextInputDialog(environment, gui->getViewSize()); + + std::string sName = getGameSettingString("sName", "Name"); + nameDialog->setTextLabel(sName); + nameDialog->setNextButtonShow(nameChosen); nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone); nameDialog->setVisible(true); return; @@ -113,7 +114,8 @@ void WindowManager::updateVisible() if (mode == GM_Race) { if (!raceDialog) - raceDialog = new RaceDialog (environment, raceChosen); + raceDialog = new RaceDialog(environment); + nameDialog->setNextButtonShow(raceChosen); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack); raceDialog->setVisible(true); @@ -194,8 +196,6 @@ void WindowManager::onNameDialogDone() nameDialog->setVisible(false); environment.mMechanicsManager->setPlayerName(nameDialog->getTextInput()); } - delete nameDialog; - nameDialog = nullptr; updateCharacterGeneration(); @@ -216,8 +216,6 @@ void WindowManager::onRaceDialogDone() raceDialog->setVisible(false); environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); } - delete raceDialog; - raceDialog = nullptr; updateCharacterGeneration(); @@ -236,8 +234,6 @@ void WindowManager::onRaceDialogBack() raceDialog->setVisible(false); environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); } - delete raceDialog; - raceDialog = nullptr; updateCharacterGeneration(); From 84acab03ecd7b94822a9cb60d8342e104df851ae Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 19:44:53 +0200 Subject: [PATCH 12/18] Avoid delegates being called repeatedly when pressing enter in name dialog. --- apps/openmw/mwgui/race.hpp | 3 +-- apps/openmw/mwgui/text_input.hpp | 3 +-- apps/openmw/mwgui/window_manager.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 98e1dd1fe0..e0cbe08f0d 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -21,8 +21,6 @@ namespace MWGui { using namespace MyGUI; - typedef delegates::CDelegate0 EventHandle_Void; - class RaceDialog : public OEngine::GUI::Layout { public: @@ -47,6 +45,7 @@ namespace MWGui void setNextButtonShow(bool shown); // Events + typedef delegates::CDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index 34312575b8..eac6495ea1 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -15,8 +15,6 @@ namespace MWGui { using namespace MyGUI; - typedef delegates::CDelegate0 EventHandle_Void; - class TextInputDialog : public OEngine::GUI::Layout { public: @@ -29,6 +27,7 @@ namespace MWGui void setTextLabel(const std::string &label); // Events + typedef delegates::CDelegate0 EventHandle_Void; /** Event : Dialog finished, OK button clicked.\n signature : void method()\n diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index fbd545bb3a..0441981521 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -115,7 +115,7 @@ void WindowManager::updateVisible() { if (!raceDialog) raceDialog = new RaceDialog(environment); - nameDialog->setNextButtonShow(raceChosen); + raceDialog->setNextButtonShow(raceChosen); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack); raceDialog->setVisible(true); @@ -189,6 +189,8 @@ void WindowManager::updateCharacterGeneration() void WindowManager::onNameDialogDone() { + nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void(); + bool goNext = nameChosen; // Go to next dialog if name was previously chosen nameChosen = true; if (nameDialog) @@ -209,7 +211,9 @@ void WindowManager::onNameDialogDone() void WindowManager::onRaceDialogDone() { - bool goNext = nameChosen; // Go to next dialog if race was previously chosen + raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void(); + + bool goNext = raceChosen; // Go to next dialog if race was previously chosen raceChosen = true; if (raceDialog) { From 8770e4bc9252bbc1d568a8dd91ec7747927c2df9 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 19:48:37 +0200 Subject: [PATCH 13/18] Made sure text edit widget gets focus when dialog is reopened. --- apps/openmw/mwgui/text_input.cpp | 7 +++++++ apps/openmw/mwgui/text_input.hpp | 1 + apps/openmw/mwgui/window_manager.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index b81b00c93a..472c8d0df6 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -47,6 +47,13 @@ void TextInputDialog::setTextLabel(const std::string &label) setText("LabelT", label); } +void TextInputDialog::open() +{ + // Make sure the edit box has focus + MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); + setVisible(true); +} + // widget controls void TextInputDialog::onOkClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index eac6495ea1..801626c58a 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -25,6 +25,7 @@ namespace MWGui void setNextButtonShow(bool shown); void setTextLabel(const std::string &label); + void open(); // Events typedef delegates::CDelegate0 EventHandle_Void; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 0441981521..1992b0a283 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -107,7 +107,7 @@ void WindowManager::updateVisible() nameDialog->setTextLabel(sName); nameDialog->setNextButtonShow(nameChosen); nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone); - nameDialog->setVisible(true); + nameDialog->open(); return; } From dbc3a43f132fdc95ca99f58beeaddd3beed8aeff Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 19:50:11 +0200 Subject: [PATCH 14/18] Adjusting y coord of ok button is wrong, should be width. --- apps/openmw/mwgui/race.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index b0722d36c0..4201eed97a 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -99,7 +99,7 @@ void RaceDialog::setNextButtonShow(bool shown) // Adjust back button when next is shown backButton->setCoord(MyGUI::IntCoord(471 - 18, 397, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(532 - 18, 397 + 18, 42, 23)); + okButton->setCoord(MyGUI::IntCoord(532 - 18, 397, 42 + 18, 23)); } else { From 1d69689f772e90183ae263f34f4170fec40542cc Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 19:55:09 +0200 Subject: [PATCH 15/18] Uppercase OK. --- apps/openmw/mwgui/race.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 4201eed97a..bb43d66802 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -103,7 +103,7 @@ void RaceDialog::setNextButtonShow(bool shown) } else { - okButton->setCaption("ok"); + okButton->setCaption("OK"); backButton->setCoord(MyGUI::IntCoord(471, 397, 53, 23)); okButton->setCoord(MyGUI::IntCoord(532, 397, 42, 23)); } From 31a728bf074e9cbf039a8e30d302e1f6f8fee735 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 21:36:32 +0200 Subject: [PATCH 16/18] Made sure name and race dialog is properly reset when opening again. --- apps/openmw/mwgui/race.cpp | 8 ++++++++ apps/openmw/mwgui/race.hpp | 1 + apps/openmw/mwgui/text_input.cpp | 1 + apps/openmw/mwgui/window_manager.cpp | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index bb43d66802..9b6f8e76d9 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -109,6 +109,14 @@ void RaceDialog::setNextButtonShow(bool shown) } } +void RaceDialog::open() +{ + updateRaces(); + updateSkills(); + updateSpellPowers(); + setVisible(true); +} + void RaceDialog::setRaceId(const std::string &raceId) { diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index e0cbe08f0d..bfa3c505d1 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -43,6 +43,7 @@ namespace MWGui // setHair() void setNextButtonShow(bool shown); + void open(); // Events typedef delegates::CDelegate0 EventHandle_Void; diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 472c8d0df6..1f955d7735 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -51,6 +51,7 @@ void TextInputDialog::open() { // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); + textEdit->setOnlyText(""); setVisible(true); } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 1992b0a283..0a9c38062f 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -118,7 +118,7 @@ void WindowManager::updateVisible() raceDialog->setNextButtonShow(raceChosen); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack); - raceDialog->setVisible(true); + raceDialog->open(); return; } From 3cf8472ddc3b01f076549b35eee51e5e9fea5520 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 21:48:10 +0200 Subject: [PATCH 17/18] Centre race dialog on screen. --- apps/openmw/mwgui/race.cpp | 8 ++++++-- apps/openmw/mwgui/race.hpp | 2 +- apps/openmw/mwgui/window_manager.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 9b6f8e76d9..00952782c9 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -13,7 +13,7 @@ using namespace MWGui; -RaceDialog::RaceDialog(MWWorld::Environment& environment) +RaceDialog::RaceDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) : Layout("openmw_chargen_race_layout.xml") , environment(environment) , genderIndex(0) @@ -22,7 +22,11 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment) , faceCount(10) , hairCount(14) { - mMainWidget->setCoord(mMainWidget->getCoord() + MyGUI::IntPoint(0, 100)); + // Centre dialog + MyGUI::IntCoord coord = mMainWidget->getCoord(); + coord.left = (gameWindowSize.width - coord.width)/2; + coord.top = (gameWindowSize.height - coord.height)/2; + mMainWidget->setCoord(coord); // 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 bfa3c505d1..fc147c6c7c 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -24,7 +24,7 @@ namespace MWGui class RaceDialog : public OEngine::GUI::Layout { public: - RaceDialog(MWWorld::Environment& environment); + RaceDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); enum Gender { diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 0a9c38062f..bed832989c 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -114,7 +114,7 @@ void WindowManager::updateVisible() if (mode == GM_Race) { if (!raceDialog) - raceDialog = new RaceDialog(environment); + raceDialog = new RaceDialog(environment, gui->getViewSize()); raceDialog->setNextButtonShow(raceChosen); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack); From ff6315a8a6620b000e1ff9547f2adacdcfeb4941 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 21:48:55 +0200 Subject: [PATCH 18/18] Improved parameter name for size sent to text input dialog. --- apps/openmw/mwgui/text_input.cpp | 6 +++--- apps/openmw/mwgui/text_input.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 1f955d7735..36fa68eba1 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -4,14 +4,14 @@ using namespace MWGui; -TextInputDialog::TextInputDialog(MWWorld::Environment& environment, MyGUI::IntSize size) +TextInputDialog::TextInputDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) : Layout("openmw_text_input_layout.xml") , environment(environment) { // Centre dialog MyGUI::IntCoord coord = mMainWidget->getCoord(); - coord.left = (size.width - coord.width)/2; - coord.top = (size.height - coord.height)/2; + coord.left = (gameWindowSize.width - coord.width)/2; + coord.top = (gameWindowSize.height - coord.height)/2; mMainWidget->setCoord(coord); getWidget(textEdit, "TextEdit"); diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index 801626c58a..8a0f1c56e4 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -18,7 +18,7 @@ namespace MWGui class TextInputDialog : public OEngine::GUI::Layout { public: - TextInputDialog(MWWorld::Environment& environment, MyGUI::IntSize size); + TextInputDialog(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); }