From 95ce7637f392119e592f8ae9d1ea59c7ec73a8d8 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 10 Apr 2017 10:18:00 +0400 Subject: [PATCH 1/5] Adds persisted pin (feature #2834, bug #2489) --- apps/openmw/mwgui/inventorywindow.cpp | 2 ++ apps/openmw/mwgui/mapwindow.cpp | 11 +++++++++-- apps/openmw/mwgui/spellwindow.cpp | 4 ++++ apps/openmw/mwgui/statswindow.cpp | 4 ++++ apps/openmw/mwgui/windowmanagerimp.cpp | 25 +++++++++++++++++++------ files/settings-default.cfg | 11 +++++++++++ 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 21b90991c..3866c5a96 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -433,6 +433,8 @@ namespace MWGui void InventoryWindow::onPinToggled() { + Settings::Manager::setBool("inventory pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setWeaponVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 8002dc48a..12d1237b0 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -629,7 +629,7 @@ namespace MWGui , mGlobalMap(0) , mGlobalMapImage(NULL) , mGlobalMapOverlay(NULL) - , mGlobal(false) + , mGlobal(Settings::Manager::getBool("global", "Map")) , mEventBoxGlobal(NULL) , mEventBoxLocal(NULL) , mGlobalMapRender(new MWRender::GlobalMap(localMapRender->getRoot(), workQueue)) @@ -667,7 +667,7 @@ namespace MWGui getWidget(mButton, "WorldButton"); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); - mButton->setCaptionWithReplacing("#{sWorld}"); + mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}"); getWidget(mEventBoxGlobal, "EventBoxGlobal"); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); @@ -680,6 +680,9 @@ namespace MWGui mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked); LocalMapBase::init(mLocalMap, mPlayerArrowLocal, Settings::Manager::getInt("local map widget size", "Map"), Settings::Manager::getInt("local map cell distance", "Map")); + + mGlobalMap->setVisible(mGlobal); + mLocalMap->setVisible(!mGlobal); } void MapWindow::onNoteEditOk() @@ -912,6 +915,8 @@ namespace MWGui mGlobalMap->setVisible(mGlobal); mLocalMap->setVisible(!mGlobal); + Settings::Manager::setBool("global", "Map", mGlobal); + mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}"); @@ -921,6 +926,8 @@ namespace MWGui void MapWindow::onPinToggled() { + Settings::Manager::setBool("map pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setMinimapVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index 7c12a8fc2..0c3485e6a 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -4,6 +4,8 @@ #include +#include + #include "../mwbase/windowmanager.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -48,6 +50,8 @@ namespace MWGui void SpellWindow::onPinToggled() { + Settings::Manager::setBool("spells pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setSpellVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index d68c1bcc5..780e4905e 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -672,6 +674,8 @@ namespace MWGui void StatsWindow::onPinToggled() { + Settings::Manager::setBool("stats pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setHMSVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 16d1a9c6d..38aa142c4 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -400,6 +400,11 @@ namespace MWGui allow(GW_ALL); mRestAllowed = !newgame; + + mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows")); + mMap->setPinned(Settings::Manager::getBool("map pin", "Windows")); + mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows")); + mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows")); } WindowManager::~WindowManager() @@ -550,15 +555,23 @@ namespace MWGui setSpellVisibility((mAllowed & GW_Magic) && (!mSpellWindow->pinned() || (mForceHidden & GW_Magic))); setHMSVisibility((mAllowed & GW_Stats) && (!mStatsWindow->pinned() || (mForceHidden & GW_Stats))); - // If in game mode, show only the pinned windows + // If in game mode (or interactive messagebox), show only the pinned windows + if (mGuiModes.empty()) + { + mInventoryWindow->setGuiMode(GM_None); + + mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map)); + mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats)); + mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory)); + mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic) && (mAllowed & GW_Magic)); + + return; + } + + // No need to check GUI if game mode if (gameMode) { mInventoryWindow->setGuiMode(GM_None); - mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map)); - mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats)); - mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory)); - mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic)); - return; } diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 55f550d5a..6756d0e7a 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -107,6 +107,9 @@ local map widget size = 512 # may result in longer loading times. local map cell distance = 1 +# If true, map in world mode, otherwise in local mode +global = false + [GUI] # Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger). @@ -365,18 +368,24 @@ stats x = 0.0 stats y = 0.0 stats w = 0.375 stats h = 0.4275 +# Stats window pin status +stats pin = false # Spells window displaying powers, spells, and magical items. spells x = 0.625 spells y = 0.5725 spells w = 0.375 spells h = 0.4275 +# Spells window pin status +spells pin = false # Local and world map window. map x = 0.625 map y = 0.0 map w = 0.375 map h = 0.5725 +# Map window pin status +map pin = false # Dialog window for talking with NPCs. dialogue x = 0.095 @@ -401,6 +410,8 @@ inventory x = 0.0 inventory y = 0.4275 inventory w = 0.6225 inventory h = 0.5725 +# Inventory window pin status +inventory pin = false # Player inventory window when searching a container. inventory container x = 0.0 From c3d49d5ca5737534c04acb62baf07cf8b03d17d9 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 12 Apr 2017 22:57:32 +0400 Subject: [PATCH 2/5] Fixed inventory crash and skipmenu launch --- apps/openmw/mwbase/windowmanager.hpp | 1 + apps/openmw/mwgui/mapwindow.cpp | 2 +- apps/openmw/mwgui/windowmanagerimp.cpp | 27 +++++++++++++++++++------ apps/openmw/mwgui/windowmanagerimp.hpp | 2 ++ apps/openmw/mwstate/statemanagerimp.cpp | 5 +++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index f103ce191..6a159ea7d 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -104,6 +104,7 @@ namespace MWBase * new dialogs. */ virtual void update() = 0; + virtual void updateVisible() = 0; /// @note This method will block until the video finishes playing /// (and will continually update the window while doing so) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 3d342db44..4d4efeecb 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -780,7 +780,7 @@ namespace MWGui void MapWindow::setVisible(bool visible) { WindowBase::setVisible(visible); - mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->isGuiMode()); + mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_None); } void MapWindow::renderGlobalMap() diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 38aa142c4..119c9f551 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -368,6 +368,8 @@ namespace MWGui mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue())); } + updatePinnedWindows(); + // Set up visibility updateVisible(); @@ -400,11 +402,6 @@ namespace MWGui allow(GW_ALL); mRestAllowed = !newgame; - - mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows")); - mMap->setPinned(Settings::Manager::getBool("map pin", "Windows")); - mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows")); - mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows")); } WindowManager::~WindowManager() @@ -492,7 +489,6 @@ namespace MWGui void WindowManager::update() { cleanupGarbage(); - mHud->update(); } @@ -560,6 +556,12 @@ namespace MWGui { mInventoryWindow->setGuiMode(GM_None); + // If game is not running, we can't be sure that widgets are initialized properly + MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState(); + + if (state != MWBase::StateManager::State_Running) + return; + mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map)); mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats)); mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory)); @@ -1709,6 +1711,8 @@ namespace MWGui mCompanionWindow->resetReference(); mConsole->resetReference(); + mInventoryWindow->rebuildAvatar(); + mSelectedSpell.clear(); mCustomMarkers.clear(); @@ -1868,6 +1872,17 @@ namespace MWGui mVideoWidget->stop(); } + void WindowManager::updatePinnedWindows() + { + mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows")); + + mMap->setPinned(Settings::Manager::getBool("map pin", "Windows")); + + mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows")); + + mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows")); + } + void WindowManager::pinWindow(GuiWindow window) { switch (window) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index a8f6263c2..40ebe8bbd 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -362,6 +362,8 @@ namespace MWGui virtual void pinWindow (MWGui::GuiWindow window); + virtual void updatePinnedWindows (); + /// Fade the screen in, over \a time seconds virtual void fadeScreenIn(const float time, bool clearQueue); /// Fade the screen out to black, over \a time seconds diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 64c543fb1..067cf481f 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -139,8 +139,7 @@ void MWState::StateManager::newGame (bool bypass) { cleanup(); - if (!bypass) - MWBase::Environment::get().getWindowManager()->setNewGame (true); + MWBase::Environment::get().getWindowManager()->setNewGame (!bypass); try { @@ -149,6 +148,8 @@ void MWState::StateManager::newGame (bool bypass) MWBase::Environment::get().getWorld()->startNewGame (bypass); mState = State_Running; + + MWBase::Environment::get().getWindowManager()->updateVisible(); } catch (std::exception& e) { From 8581d68b8e05ef02d46d213704598c948b33ad99 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 14 Apr 2017 22:46:24 +0400 Subject: [PATCH 3/5] Updated documentation for windows settings --- .../source/reference/modding/settings/map.rst | 11 +++ .../reference/modding/settings/windows.rst | 81 ++++++++++++------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/docs/source/reference/modding/settings/map.rst b/docs/source/reference/modding/settings/map.rst index f3e0a1c53..c120cf020 100644 --- a/docs/source/reference/modding/settings/map.rst +++ b/docs/source/reference/modding/settings/map.rst @@ -51,3 +51,14 @@ local map widget size This setting controls the canvas size of the GUI mode local map window. Larger values result in a larger physical map size on screen, and typically require more panning to see all available portions of the map. This larger size also enables an overall greater level of detail if the local map resolution setting is also increased. The default value for this setting is 512. This setting can not be configured except by editing the settings configuration file. + +global +------ + +:Type: boolean +:Range: True/False +:Default: False + +If this setting is true, a world map on a map window will be displayed, otherwise a local map will be displayed. + +The default value is false. This setting can be toggled with the Local/World map switch button on the map window. diff --git a/docs/source/reference/modding/settings/windows.rst b/docs/source/reference/modding/settings/windows.rst index 8860de983..bafcac295 100644 --- a/docs/source/reference/modding/settings/windows.rst +++ b/docs/source/reference/modding/settings/windows.rst @@ -18,6 +18,21 @@ Each window in the GUI mode remembers it's previous location when exiting the ga .. note:: To scale the windows, making the widgets proportionally larger, see the scaling factor setting instead. +:Type: boolean +:Range: True/False + +This section controls the state of pinnable windows: pinned or not. For example, to pin only the map window, the actual settings will be:: + + inventory pin = false + map pin = true + stats pin = false + spells pin = false + +The pinnable window can be pinned/unpinned by clicking on a button in the right upper corner of the window. + +.. note:: + A world/local map switch button on the map window will be showed only in GUI mode. + stats ----- @@ -25,6 +40,7 @@ stats y = 0.0 h = 0.375 w = 0.4275 + pin = false The stats window, displaying level, race, class, skills and stats. Activated by clicking on any of the three bars in the lower left corner of the HUD. @@ -35,6 +51,7 @@ spells y = 0.5725 h = 0.375 w = 0.4275 + pin = false The spells window, displaying powers, spells, and magical items. Activated by clicking on the spells widget (third from left) in the bottom left corner of the HUD. @@ -45,39 +62,10 @@ map y = 0.0 h = 0.375 w = 0.5725 + pin = false The local and world map window. Activated by clicking on the map widget in the bottom right corner of the HUD. -dialogue --------- - -:Default: x = 0.095 - y = 0.095 - h = 0.810 - w = 0.810 - -The dialog window, for talking with NPCs. Activated by clicking on a NPC. - -alchemy -------- - -:Default: x = 0.25 - y = 0.25 - h = 0.5 - w = 0.5 - -The alchemy window, for crafting potions. Activated by dragging an alchemy tool on to the rag doll. Unlike most other windows, this window hides all other windows when opened. - -console -------- - -:Default: x = 0.0 - y = 0.0 - h = 1.0 - w = 0.5 - -The console command window. Activated by pressing the tilde (~) key. - inventory --------- @@ -85,6 +73,7 @@ inventory y = 0.4275 h = 0.6225 w = 0.5725 + pin = false The inventory window, displaying the paper doll and possessions, when activated by clicking on the inventory widget (second from left) in the bottom left corner of the HUD. @@ -146,4 +135,34 @@ companion h = 0.75 w = 0.375 -The NPC's inventory window while interacting with a companion. The companion windows were added in the Tribunal expansion, but are available everywhere in the OpenMW engine. \ No newline at end of file +The NPC's inventory window while interacting with a companion. The companion windows were added in the Tribunal expansion, but are available everywhere in the OpenMW engine. + +dialogue +-------- + +:Default: x = 0.095 + y = 0.095 + h = 0.810 + w = 0.810 + +The dialog window, for talking with NPCs. Activated by clicking on a NPC. + +alchemy +------- + +:Default: x = 0.25 + y = 0.25 + h = 0.5 + w = 0.5 + +The alchemy window, for crafting potions. Activated by dragging an alchemy tool on to the rag doll. Unlike most other windows, this window hides all other windows when opened. + +console +------- + +:Default: x = 0.0 + y = 0.0 + h = 1.0 + w = 0.5 + +The console command window. Activated by pressing the tilde (~) key. From f986e3fafa63590ff5c4b836b688d336f2c5d45e Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 21 Apr 2017 18:03:23 +0400 Subject: [PATCH 4/5] Remove unused code --- apps/openmw/mwbase/windowmanager.hpp | 1 - apps/openmw/mwgui/windowmanagerimp.cpp | 8 +------- apps/openmw/mwgui/windowmanagerimp.hpp | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 6a159ea7d..f103ce191 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -104,7 +104,6 @@ namespace MWBase * new dialogs. */ virtual void update() = 0; - virtual void updateVisible() = 0; /// @note This method will block until the video finishes playing /// (and will continually update the window while doing so) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 08d369250..e77281898 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -485,6 +485,7 @@ namespace MWGui void WindowManager::update() { cleanupGarbage(); + mHud->update(); } @@ -559,13 +560,6 @@ namespace MWGui return; } - // No need to check GUI if game mode - if (gameMode) - { - mInventoryWindow->setGuiMode(GM_None); - return; - } - if(mGuiModes.size() != 0) { GuiMode mode = mGuiModes.back(); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 791ed602e..1b8ceecc2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -361,7 +361,7 @@ namespace MWGui virtual void pinWindow (MWGui::GuiWindow window); - virtual void updatePinnedWindows (); + void updatePinnedWindows (); /// Fade the screen in, over \a time seconds virtual void fadeScreenIn(const float time, bool clearQueue); From 2b3b6d558fab78107f6cd04783d5348446f3890c Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 21 Apr 2017 19:37:09 +0400 Subject: [PATCH 5/5] Move updatePinnedWindows() function to private section --- apps/openmw/mwgui/windowmanagerimp.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 1b8ceecc2..787c88598 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -361,8 +361,6 @@ namespace MWGui virtual void pinWindow (MWGui::GuiWindow window); - void updatePinnedWindows (); - /// Fade the screen in, over \a time seconds virtual void fadeScreenIn(const float time, bool clearQueue); /// Fade the screen out to black, over \a time seconds @@ -541,6 +539,8 @@ namespace MWGui void createTextures(); void createCursors(); void setMenuTransparency(float value); + + void updatePinnedWindows(); }; }