1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 08:23:53 +00:00

Merge pull request #1253 from akortunov/pinned

Remember "pinned" windows across game restarts
This commit is contained in:
scrawl 2017-04-21 18:44:47 +02:00 committed by GitHub
commit 8fbf9dc597
9 changed files with 113 additions and 40 deletions

View file

@ -444,6 +444,8 @@ namespace MWGui
void InventoryWindow::onPinToggled() void InventoryWindow::onPinToggled()
{ {
Settings::Manager::setBool("inventory pin", "Windows", mPinned);
MWBase::Environment::get().getWindowManager()->setWeaponVisibility(!mPinned); MWBase::Environment::get().getWindowManager()->setWeaponVisibility(!mPinned);
} }

View file

@ -629,7 +629,7 @@ namespace MWGui
, mGlobalMap(0) , mGlobalMap(0)
, mGlobalMapImage(NULL) , mGlobalMapImage(NULL)
, mGlobalMapOverlay(NULL) , mGlobalMapOverlay(NULL)
, mGlobal(false) , mGlobal(Settings::Manager::getBool("global", "Map"))
, mEventBoxGlobal(NULL) , mEventBoxGlobal(NULL)
, mEventBoxLocal(NULL) , mEventBoxLocal(NULL)
, mGlobalMapRender(new MWRender::GlobalMap(localMapRender->getRoot(), workQueue)) , mGlobalMapRender(new MWRender::GlobalMap(localMapRender->getRoot(), workQueue))
@ -667,7 +667,7 @@ namespace MWGui
getWidget(mButton, "WorldButton"); getWidget(mButton, "WorldButton");
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked);
mButton->setCaptionWithReplacing("#{sWorld}"); mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}");
getWidget(mEventBoxGlobal, "EventBoxGlobal"); getWidget(mEventBoxGlobal, "EventBoxGlobal");
mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
@ -680,6 +680,9 @@ namespace MWGui
mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked); 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")); 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() void MapWindow::onNoteEditOk()
@ -777,7 +780,7 @@ namespace MWGui
void MapWindow::setVisible(bool visible) void MapWindow::setVisible(bool visible)
{ {
WindowBase::setVisible(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() void MapWindow::renderGlobalMap()
@ -918,6 +921,8 @@ namespace MWGui
mGlobalMap->setVisible(mGlobal); mGlobalMap->setVisible(mGlobal);
mLocalMap->setVisible(!mGlobal); mLocalMap->setVisible(!mGlobal);
Settings::Manager::setBool("global", "Map", mGlobal);
mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" :
"#{sWorld}"); "#{sWorld}");
@ -927,6 +932,8 @@ namespace MWGui
void MapWindow::onPinToggled() void MapWindow::onPinToggled()
{ {
Settings::Manager::setBool("map pin", "Windows", mPinned);
MWBase::Environment::get().getWindowManager()->setMinimapVisibility(!mPinned); MWBase::Environment::get().getWindowManager()->setMinimapVisibility(!mPinned);
} }

View file

@ -4,6 +4,8 @@
#include <MyGUI_InputManager.h> #include <MyGUI_InputManager.h>
#include <components/settings/settings.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -48,6 +50,8 @@ namespace MWGui
void SpellWindow::onPinToggled() void SpellWindow::onPinToggled()
{ {
Settings::Manager::setBool("spells pin", "Windows", mPinned);
MWBase::Environment::get().getWindowManager()->setSpellVisibility(!mPinned); MWBase::Environment::get().getWindowManager()->setSpellVisibility(!mPinned);
} }

View file

@ -6,6 +6,8 @@
#include <MyGUI_ImageBox.h> #include <MyGUI_ImageBox.h>
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <components/settings/settings.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -672,6 +674,8 @@ namespace MWGui
void StatsWindow::onPinToggled() void StatsWindow::onPinToggled()
{ {
Settings::Manager::setBool("stats pin", "Windows", mPinned);
MWBase::Environment::get().getWindowManager()->setHMSVisibility(!mPinned); MWBase::Environment::get().getWindowManager()->setHMSVisibility(!mPinned);
} }

View file

@ -369,6 +369,8 @@ namespace MWGui
mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue())); mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue()));
} }
updatePinnedWindows();
// Set up visibility // Set up visibility
updateVisible(); updateVisible();
@ -546,14 +548,14 @@ namespace MWGui
setSpellVisibility((mAllowed & GW_Magic) && (!mSpellWindow->pinned() || (mForceHidden & GW_Magic))); setSpellVisibility((mAllowed & GW_Magic) && (!mSpellWindow->pinned() || (mForceHidden & GW_Magic)));
setHMSVisibility((mAllowed & GW_Stats) && (!mStatsWindow->pinned() || (mForceHidden & GW_Stats))); 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 (gameMode) if (mGuiModes.empty())
{ {
mInventoryWindow->setGuiMode(GM_None); mInventoryWindow->setGuiMode(GM_None);
mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map)); mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map));
mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats)); mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats));
mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory)); mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory));
mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic)); mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic) && (mAllowed & GW_Magic));
return; return;
} }
@ -1853,6 +1855,17 @@ namespace MWGui
mVideoWidget->stop(); 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) void WindowManager::pinWindow(GuiWindow window)
{ {
switch (window) switch (window)

View file

@ -539,6 +539,8 @@ namespace MWGui
void createTextures(); void createTextures();
void createCursors(); void createCursors();
void setMenuTransparency(float value); void setMenuTransparency(float value);
void updatePinnedWindows();
}; };
} }

View file

@ -1,6 +1,17 @@
Map Settings Map Settings
############ ############
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.
global map cell size global map cell size
-------------------- --------------------

View file

@ -18,6 +18,21 @@ Each window in the GUI mode remembers it's previous location when exiting the ga
.. note:: .. note::
To scale the windows, making the widgets proportionally larger, see the scaling factor setting instead. 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 stats
----- -----
@ -25,6 +40,7 @@ stats
y = 0.0 y = 0.0
h = 0.375 h = 0.375
w = 0.4275 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. 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 y = 0.5725
h = 0.375 h = 0.375
w = 0.4275 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. 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 y = 0.0
h = 0.375 h = 0.375
w = 0.5725 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. 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 inventory
--------- ---------
@ -85,6 +73,7 @@ inventory
y = 0.4275 y = 0.4275
h = 0.6225 h = 0.6225
w = 0.5725 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. 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 h = 0.75
w = 0.375 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. 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.

View file

@ -107,6 +107,9 @@ local map widget size = 512
# may result in longer loading times. # may result in longer loading times.
local map cell distance = 1 local map cell distance = 1
# If true, map in world mode, otherwise in local mode
global = false
[GUI] [GUI]
# Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger). # Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger).
@ -371,18 +374,24 @@ stats x = 0.0
stats y = 0.0 stats y = 0.0
stats w = 0.375 stats w = 0.375
stats h = 0.4275 stats h = 0.4275
# Stats window pin status
stats pin = false
# Spells window displaying powers, spells, and magical items. # Spells window displaying powers, spells, and magical items.
spells x = 0.625 spells x = 0.625
spells y = 0.5725 spells y = 0.5725
spells w = 0.375 spells w = 0.375
spells h = 0.4275 spells h = 0.4275
# Spells window pin status
spells pin = false
# Local and world map window. # Local and world map window.
map x = 0.625 map x = 0.625
map y = 0.0 map y = 0.0
map w = 0.375 map w = 0.375
map h = 0.5725 map h = 0.5725
# Map window pin status
map pin = false
# Dialog window for talking with NPCs. # Dialog window for talking with NPCs.
dialogue x = 0.095 dialogue x = 0.095
@ -407,6 +416,8 @@ inventory x = 0.0
inventory y = 0.4275 inventory y = 0.4275
inventory w = 0.6225 inventory w = 0.6225
inventory h = 0.5725 inventory h = 0.5725
# Inventory window pin status
inventory pin = false
# Player inventory window when searching a container. # Player inventory window when searching a container.
inventory container x = 0.0 inventory container x = 0.0