2012-08-12 16:11:09 +00:00
|
|
|
#include "windowmanagerimp.hpp"
|
2012-08-12 12:07:48 +00:00
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
2015-05-01 01:03:44 +00:00
|
|
|
#include <osgViewer/Viewer>
|
2014-02-19 17:40:29 +00:00
|
|
|
|
2015-01-10 01:50:43 +00:00
|
|
|
#include <MyGUI_UString.h>
|
|
|
|
#include <MyGUI_IPointer.h>
|
|
|
|
#include <MyGUI_TextureUtility.h>
|
|
|
|
#include <MyGUI_FactoryManager.h>
|
|
|
|
#include <MyGUI_LanguageManager.h>
|
|
|
|
#include <MyGUI_PointerManager.h>
|
|
|
|
#include <MyGUI_InputManager.h>
|
|
|
|
#include <MyGUI_Gui.h>
|
|
|
|
#include <MyGUI_ClipboardManager.h>
|
2017-09-22 21:01:34 +00:00
|
|
|
#include <MyGUI_WidgetManager.h>
|
2012-08-12 12:07:48 +00:00
|
|
|
|
2020-05-15 08:38:22 +00:00
|
|
|
// For BT_NO_PROFILE
|
|
|
|
#include <LinearMath/btQuickprof.h>
|
|
|
|
|
2015-01-31 22:27:34 +00:00
|
|
|
#include <SDL_keyboard.h>
|
|
|
|
#include <SDL_clipboard.h>
|
|
|
|
|
2018-08-14 19:05:43 +00:00
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
2015-05-13 16:56:14 +00:00
|
|
|
#include <components/sdlutil/sdlcursormanager.hpp>
|
2020-04-16 13:31:20 +00:00
|
|
|
#include <components/sdlutil/sdlvideowrapper.hpp>
|
2013-01-11 12:27:59 +00:00
|
|
|
|
2015-07-07 17:16:32 +00:00
|
|
|
#include <components/esm/esmreader.hpp>
|
|
|
|
#include <components/esm/esmwriter.hpp>
|
|
|
|
|
2014-09-12 02:27:23 +00:00
|
|
|
#include <components/fontloader/fontloader.hpp>
|
|
|
|
|
2015-04-30 23:15:25 +00:00
|
|
|
#include <components/resource/resourcesystem.hpp>
|
2016-02-05 22:03:53 +00:00
|
|
|
#include <components/resource/imagemanager.hpp>
|
2015-04-30 23:15:25 +00:00
|
|
|
|
2017-02-14 02:55:29 +00:00
|
|
|
#include <components/sceneutil/workqueue.hpp>
|
|
|
|
|
2015-01-31 22:27:34 +00:00
|
|
|
#include <components/translation/translation.hpp>
|
|
|
|
|
2015-04-30 23:15:25 +00:00
|
|
|
#include <components/myguiplatform/myguiplatform.hpp>
|
2015-11-07 16:39:31 +00:00
|
|
|
#include <components/myguiplatform/myguirendermanager.hpp>
|
2015-11-07 16:45:22 +00:00
|
|
|
#include <components/myguiplatform/additivelayer.hpp>
|
2015-11-08 17:24:28 +00:00
|
|
|
#include <components/myguiplatform/scalinglayer.hpp>
|
2015-04-30 23:15:25 +00:00
|
|
|
|
2015-05-03 16:35:29 +00:00
|
|
|
#include <components/vfs/manager.hpp>
|
|
|
|
|
2014-09-24 22:04:38 +00:00
|
|
|
#include <components/widgets/tags.hpp>
|
2014-09-12 03:14:21 +00:00
|
|
|
|
2015-05-01 16:37:24 +00:00
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
|
|
|
|
2012-08-12 12:07:48 +00:00
|
|
|
#include "../mwbase/inputmanager.hpp"
|
2014-01-21 13:50:58 +00:00
|
|
|
#include "../mwbase/statemanager.hpp"
|
2015-07-18 17:40:31 +00:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2019-02-18 22:10:55 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-08-12 12:07:48 +00:00
|
|
|
|
2020-04-20 16:47:14 +00:00
|
|
|
#include "../mwrender/vismask.hpp"
|
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
#include "../mwworld/class.hpp"
|
2013-12-31 23:12:31 +00:00
|
|
|
#include "../mwworld/player.hpp"
|
2014-02-23 19:11:05 +00:00
|
|
|
#include "../mwworld/cellstore.hpp"
|
2015-01-10 02:56:06 +00:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-08-12 12:07:48 +00:00
|
|
|
|
2015-02-09 15:23:41 +00:00
|
|
|
#include "../mwmechanics/stat.hpp"
|
2014-09-06 01:13:35 +00:00
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
2015-08-21 09:12:39 +00:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2014-09-06 01:13:35 +00:00
|
|
|
|
2015-05-26 14:40:44 +00:00
|
|
|
#include "../mwrender/localmap.hpp"
|
|
|
|
|
2012-08-12 12:07:48 +00:00
|
|
|
#include "console.hpp"
|
|
|
|
#include "journalwindow.hpp"
|
2013-01-27 20:16:46 +00:00
|
|
|
#include "journalviewmodel.hpp"
|
2012-08-12 12:07:48 +00:00
|
|
|
#include "charactercreation.hpp"
|
2010-11-03 20:21:08 +00:00
|
|
|
#include "dialogue.hpp"
|
2013-04-10 04:32:05 +00:00
|
|
|
#include "statswindow.hpp"
|
2011-06-14 16:29:55 +00:00
|
|
|
#include "messagebox.hpp"
|
2012-04-14 15:47:44 +00:00
|
|
|
#include "tooltips.hpp"
|
2012-05-03 01:33:33 +00:00
|
|
|
#include "scrollwindow.hpp"
|
|
|
|
#include "bookwindow.hpp"
|
2012-05-13 16:14:03 +00:00
|
|
|
#include "hud.hpp"
|
|
|
|
#include "mainmenu.hpp"
|
2012-05-15 10:51:51 +00:00
|
|
|
#include "countdialog.hpp"
|
2012-05-17 15:15:44 +00:00
|
|
|
#include "tradewindow.hpp"
|
2012-09-09 18:10:07 +00:00
|
|
|
#include "spellbuyingwindow.hpp"
|
2012-09-26 16:30:47 +00:00
|
|
|
#include "travelwindow.hpp"
|
2012-05-22 19:40:42 +00:00
|
|
|
#include "settingswindow.hpp"
|
2012-05-23 03:28:25 +00:00
|
|
|
#include "confirmationdialog.hpp"
|
2012-05-24 13:57:23 +00:00
|
|
|
#include "alchemywindow.hpp"
|
2012-05-29 07:02:22 +00:00
|
|
|
#include "spellwindow.hpp"
|
2012-08-26 08:52:06 +00:00
|
|
|
#include "quickkeysmenu.hpp"
|
2012-09-11 14:37:54 +00:00
|
|
|
#include "loadingscreen.hpp"
|
2012-09-14 17:44:00 +00:00
|
|
|
#include "levelupdialog.hpp"
|
2012-09-18 16:29:03 +00:00
|
|
|
#include "waitdialog.hpp"
|
2012-09-27 06:47:47 +00:00
|
|
|
#include "enchantingdialog.hpp"
|
2012-10-17 16:03:02 +00:00
|
|
|
#include "trainingwindow.hpp"
|
2013-11-19 05:48:47 +00:00
|
|
|
#include "recharge.hpp"
|
2013-02-17 01:56:07 +00:00
|
|
|
#include "exposedwindow.hpp"
|
2013-03-01 17:45:52 +00:00
|
|
|
#include "cursor.hpp"
|
2013-03-22 13:13:10 +00:00
|
|
|
#include "merchantrepair.hpp"
|
2013-03-23 07:16:46 +00:00
|
|
|
#include "repair.hpp"
|
2013-03-30 14:51:07 +00:00
|
|
|
#include "soulgemdialog.hpp"
|
2013-03-31 11:13:46 +00:00
|
|
|
#include "companionwindow.hpp"
|
2013-04-17 00:16:22 +00:00
|
|
|
#include "inventorywindow.hpp"
|
2013-01-27 19:56:00 +00:00
|
|
|
#include "bookpage.hpp"
|
2013-05-11 16:38:27 +00:00
|
|
|
#include "itemview.hpp"
|
2014-03-27 18:10:15 +00:00
|
|
|
#include "videowidget.hpp"
|
2014-03-30 21:04:12 +00:00
|
|
|
#include "backgroundimage.hpp"
|
2014-06-05 20:13:18 +00:00
|
|
|
#include "itemwidget.hpp"
|
2014-08-01 14:25:41 +00:00
|
|
|
#include "screenfader.hpp"
|
2014-09-28 15:57:14 +00:00
|
|
|
#include "debugwindow.hpp"
|
2014-12-15 12:13:25 +00:00
|
|
|
#include "spellview.hpp"
|
2015-01-10 00:21:17 +00:00
|
|
|
#include "draganddrop.hpp"
|
|
|
|
#include "container.hpp"
|
2015-01-10 01:50:43 +00:00
|
|
|
#include "controllers.hpp"
|
2015-02-07 03:05:28 +00:00
|
|
|
#include "jailscreen.hpp"
|
2016-11-06 10:01:46 +00:00
|
|
|
#include "itemchargeview.hpp"
|
2017-09-22 14:52:39 +00:00
|
|
|
#include "keyboardnavigation.hpp"
|
2019-04-01 17:47:12 +00:00
|
|
|
#include "resourceskin.hpp"
|
2010-07-17 12:01:47 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
namespace MWGui
|
|
|
|
{
|
|
|
|
WindowManager::WindowManager(
|
2020-04-16 13:31:20 +00:00
|
|
|
SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
2018-09-04 05:15:07 +00:00
|
|
|
const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
2019-01-22 06:08:48 +00:00
|
|
|
ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& userDataPath)
|
2019-06-21 13:37:00 +00:00
|
|
|
: mOldUpdateMask(0)
|
|
|
|
, mOldCullMask(0)
|
|
|
|
, mStore(nullptr)
|
2015-12-09 00:06:53 +00:00
|
|
|
, mResourceSystem(resourceSystem)
|
2017-02-14 02:55:29 +00:00
|
|
|
, mWorkQueue(workQueue)
|
2015-05-01 16:37:24 +00:00
|
|
|
, mViewer(viewer)
|
2015-05-01 01:03:44 +00:00
|
|
|
, mConsoleOnlyScripts(consoleOnlyScripts)
|
2015-04-25 18:37:42 +00:00
|
|
|
, mCurrentModals()
|
2018-10-09 06:21:12 +00:00
|
|
|
, mHud(nullptr)
|
|
|
|
, mMap(nullptr)
|
|
|
|
, mLocalMapRender(nullptr)
|
|
|
|
, mToolTips(nullptr)
|
|
|
|
, mStatsWindow(nullptr)
|
|
|
|
, mMessageBoxManager(nullptr)
|
|
|
|
, mConsole(nullptr)
|
|
|
|
, mDialogueWindow(nullptr)
|
|
|
|
, mDragAndDrop(nullptr)
|
|
|
|
, mInventoryWindow(nullptr)
|
|
|
|
, mScrollWindow(nullptr)
|
|
|
|
, mBookWindow(nullptr)
|
|
|
|
, mCountDialog(nullptr)
|
|
|
|
, mTradeWindow(nullptr)
|
|
|
|
, mSettingsWindow(nullptr)
|
|
|
|
, mConfirmationDialog(nullptr)
|
|
|
|
, mSpellWindow(nullptr)
|
|
|
|
, mQuickKeysMenu(nullptr)
|
|
|
|
, mLoadingScreen(nullptr)
|
|
|
|
, mWaitDialog(nullptr)
|
|
|
|
, mSoulgemDialog(nullptr)
|
|
|
|
, mVideoBackground(nullptr)
|
|
|
|
, mVideoWidget(nullptr)
|
|
|
|
, mWerewolfFader(nullptr)
|
|
|
|
, mBlindnessFader(nullptr)
|
|
|
|
, mHitFader(nullptr)
|
|
|
|
, mScreenFader(nullptr)
|
|
|
|
, mDebugWindow(nullptr)
|
|
|
|
, mJailScreen(nullptr)
|
2013-10-10 21:06:37 +00:00
|
|
|
, mTranslationDataStorage (translationDataStorage)
|
2018-10-09 06:21:12 +00:00
|
|
|
, mCharGen(nullptr)
|
|
|
|
, mInputBlocker(nullptr)
|
2013-10-10 21:06:37 +00:00
|
|
|
, mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD"))
|
|
|
|
, mSubtitlesEnabled(Settings::Manager::getBool ("subtitles", "GUI"))
|
2014-10-05 15:53:50 +00:00
|
|
|
, mHitFaderEnabled(Settings::Manager::getBool ("hit fader", "GUI"))
|
|
|
|
, mWerewolfOverlayEnabled(Settings::Manager::getBool ("werewolf overlay", "GUI"))
|
2013-10-10 21:06:37 +00:00
|
|
|
, mHudEnabled(true)
|
|
|
|
, mCursorVisible(true)
|
2017-09-26 15:44:35 +00:00
|
|
|
, mCursorActive(false)
|
2019-09-05 16:16:03 +00:00
|
|
|
, mPlayerBounty(-1)
|
2018-10-09 06:21:12 +00:00
|
|
|
, mGui(nullptr)
|
2013-10-10 21:06:37 +00:00
|
|
|
, mGuiModes()
|
2018-10-09 06:21:12 +00:00
|
|
|
, mCursorManager(nullptr)
|
2013-04-17 22:56:48 +00:00
|
|
|
, mGarbageDialogs()
|
|
|
|
, mShown(GW_ALL)
|
2013-08-05 21:15:26 +00:00
|
|
|
, mForceHidden(GW_None)
|
2013-05-15 15:54:18 +00:00
|
|
|
, mAllowed(GW_ALL)
|
|
|
|
, mRestAllowed(true)
|
2015-07-18 15:13:20 +00:00
|
|
|
, mShowOwned(0)
|
2017-11-21 05:32:35 +00:00
|
|
|
, mEncoding(encoding)
|
2015-07-18 01:01:06 +00:00
|
|
|
, mVersionDescription(versionDescription)
|
2020-04-16 13:31:20 +00:00
|
|
|
, mWindowVisible(true)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2015-05-14 22:41:21 +00:00
|
|
|
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
|
2016-02-05 22:10:27 +00:00
|
|
|
mGuiPlatform = new osgMyGUI::Platform(viewer, guiRoot, resourceSystem->getImageManager(), uiScale);
|
2015-04-24 21:30:30 +00:00
|
|
|
mGuiPlatform->initialise(resourcePath, logpath);
|
2015-04-01 15:02:15 +00:00
|
|
|
|
2015-05-03 16:35:29 +00:00
|
|
|
mGui = new MyGUI::Gui;
|
|
|
|
mGui->initialise("");
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2015-05-02 16:06:54 +00:00
|
|
|
createTextures();
|
|
|
|
|
2014-09-19 09:53:20 +00:00
|
|
|
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
|
|
|
|
|
2013-06-06 20:13:30 +00:00
|
|
|
// Load fonts
|
2018-09-04 05:15:07 +00:00
|
|
|
mFontLoader.reset(new Gui::FontLoader(encoding, resourceSystem->getVFS(), userDataPath));
|
|
|
|
mFontLoader->loadBitmapFonts(exportFonts);
|
2013-06-06 20:13:30 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
//Register own widgets with MyGUI
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWEffectList>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWDynamicStat>("Widget");
|
2019-04-26 07:37:57 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Window>("Widget");
|
2014-03-27 18:10:15 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<VideoWidget>("Widget");
|
2014-03-30 21:04:12 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<BackgroundImage>("Widget");
|
2015-11-07 16:45:22 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<osgMyGUI::AdditiveLayer>("Layer");
|
2015-11-08 17:24:28 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<osgMyGUI::ScalingLayer>("Layer");
|
2013-01-27 19:56:00 +00:00
|
|
|
BookPage::registerMyGUIComponents ();
|
2013-05-11 16:38:27 +00:00
|
|
|
ItemView::registerComponents();
|
2016-11-06 10:01:46 +00:00
|
|
|
ItemChargeView::registerComponents();
|
2014-06-05 20:13:18 +00:00
|
|
|
ItemWidget::registerComponents();
|
2014-12-15 12:13:25 +00:00
|
|
|
SpellView::registerComponents();
|
2014-09-25 18:28:00 +00:00
|
|
|
Gui::registerAllWidgets();
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2014-08-01 15:14:35 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerFollowMouse>("Controller");
|
2013-07-05 17:17:00 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
|
2019-04-01 17:47:12 +00:00
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<AutoSizedResourceSkin>("Resource", "AutoSizedResourceSkin");
|
2013-04-17 22:56:48 +00:00
|
|
|
MyGUI::ResourceManager::getInstance().load("core.xml");
|
2019-11-17 16:10:09 +00:00
|
|
|
WindowManager::loadUserFonts();
|
2015-05-03 14:58:05 +00:00
|
|
|
|
2018-03-08 23:39:35 +00:00
|
|
|
bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI");
|
2017-09-22 14:52:39 +00:00
|
|
|
mKeyboardNavigation.reset(new KeyboardNavigation());
|
2018-03-08 23:39:35 +00:00
|
|
|
mKeyboardNavigation->setEnabled(keyboardNav);
|
|
|
|
Gui::ImageButton::setDefaultNeedKeyFocus(keyboardNav);
|
2017-09-22 14:52:39 +00:00
|
|
|
|
2020-05-05 13:37:00 +00:00
|
|
|
mLoadingScreen = new LoadingScreen(mResourceSystem, mViewer);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mLoadingScreen);
|
2015-05-03 14:58:05 +00:00
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
//set up the hardware cursor manager
|
2015-05-13 16:56:14 +00:00
|
|
|
mCursorManager = new SDLUtil::SDLCursorManager();
|
2013-08-27 13:48:13 +00:00
|
|
|
|
|
|
|
MyGUI::PointerManager::getInstance().eventChangeMousePointer += MyGUI::newDelegate(this, &WindowManager::onCursorChange);
|
|
|
|
|
|
|
|
MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &WindowManager::onKeyFocusChanged);
|
|
|
|
|
2015-07-13 21:36:25 +00:00
|
|
|
// Create all cursors in advance
|
|
|
|
createCursors();
|
2013-08-27 13:48:13 +00:00
|
|
|
onCursorChange(MyGUI::PointerManager::getInstance().getDefaultPointer());
|
2015-05-13 16:56:14 +00:00
|
|
|
mCursorManager->setEnabled(true);
|
2013-12-31 13:13:42 +00:00
|
|
|
|
2013-11-20 05:20:16 +00:00
|
|
|
// hide mygui's pointer
|
|
|
|
MyGUI::PointerManager::getInstance().setVisible(false);
|
2014-03-27 18:10:15 +00:00
|
|
|
|
|
|
|
mVideoBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>("ImageBox", 0,0,1,1,
|
2015-11-07 18:45:30 +00:00
|
|
|
MyGUI::Align::Default, "InputBlocker");
|
2015-05-15 21:21:29 +00:00
|
|
|
mVideoBackground->setImageTexture("black");
|
2014-03-27 18:10:15 +00:00
|
|
|
mVideoBackground->setVisible(false);
|
2014-06-09 23:57:54 +00:00
|
|
|
mVideoBackground->setNeedMouseFocus(true);
|
|
|
|
mVideoBackground->setNeedKeyFocus(true);
|
2014-03-27 18:10:15 +00:00
|
|
|
|
|
|
|
mVideoWidget = mVideoBackground->createWidgetReal<VideoWidget>("ImageBox", 0,0,1,1, MyGUI::Align::Default);
|
2014-06-09 23:57:54 +00:00
|
|
|
mVideoWidget->setNeedMouseFocus(true);
|
|
|
|
mVideoWidget->setNeedKeyFocus(true);
|
2015-05-01 01:03:44 +00:00
|
|
|
mVideoWidget->setVFS(resourceSystem->getVFS());
|
2014-08-25 16:00:53 +00:00
|
|
|
|
|
|
|
// Removes default MyGUI system clipboard implementation, which supports windows only
|
|
|
|
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
|
|
|
|
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
|
|
|
|
|
|
|
|
MyGUI::ClipboardManager::getInstance().eventClipboardChanged += MyGUI::newDelegate(this, &WindowManager::onClipboardChanged);
|
|
|
|
MyGUI::ClipboardManager::getInstance().eventClipboardRequested += MyGUI::newDelegate(this, &WindowManager::onClipboardRequested);
|
2015-07-18 10:22:37 +00:00
|
|
|
|
2015-07-18 15:13:20 +00:00
|
|
|
mShowOwned = Settings::Manager::getInt("show owned", "Game");
|
2020-04-16 13:31:20 +00:00
|
|
|
|
|
|
|
mVideoWrapper = new SDLUtil::VideoWrapper(window, viewer);
|
|
|
|
mVideoWrapper->setGammaContrast(Settings::Manager::getFloat("gamma", "Video"),
|
|
|
|
Settings::Manager::getFloat("contrast", "Video"));
|
2013-08-27 13:48:13 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 05:15:07 +00:00
|
|
|
void WindowManager::loadUserFonts()
|
|
|
|
{
|
|
|
|
mFontLoader->loadTrueTypeFonts();
|
|
|
|
}
|
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
void WindowManager::initUI()
|
|
|
|
{
|
|
|
|
// Get size info from the Gui object
|
2013-04-17 22:56:48 +00:00
|
|
|
int w = MyGUI::RenderManager::getInstance().getViewSize().width;
|
|
|
|
int h = MyGUI::RenderManager::getInstance().getViewSize().height;
|
|
|
|
|
2020-05-26 13:10:56 +00:00
|
|
|
mTextColours.loadColours();
|
2017-07-24 11:25:01 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mDragAndDrop = new DragAndDrop();
|
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
Recharge* recharge = new Recharge();
|
|
|
|
mGuiModeStates[GM_Recharge] = GuiModeState(recharge);
|
|
|
|
mWindows.push_back(recharge);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
MainMenu* menu = new MainMenu(w, h, mResourceSystem->getVFS(), mVersionDescription);
|
|
|
|
mGuiModeStates[GM_MainMenu] = GuiModeState(menu);
|
|
|
|
mWindows.push_back(menu);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2016-08-16 20:37:44 +00:00
|
|
|
mLocalMapRender = new MWRender::LocalMap(mViewer->getSceneData()->asGroup());
|
2017-02-14 02:55:29 +00:00
|
|
|
mMap = new MapWindow(mCustomMarkers, mDragAndDrop, mLocalMapRender, mWorkQueue);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mMap);
|
2017-04-20 22:50:22 +00:00
|
|
|
mMap->renderGlobalMap();
|
2013-12-03 17:42:35 +00:00
|
|
|
trackWindow(mMap, "map");
|
2017-09-23 19:45:52 +00:00
|
|
|
|
2014-01-26 13:47:01 +00:00
|
|
|
mStatsWindow = new StatsWindow(mDragAndDrop);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mStatsWindow);
|
2013-12-03 17:42:35 +00:00
|
|
|
trackWindow(mStatsWindow, "stats");
|
2017-09-23 19:45:52 +00:00
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer->getSceneData()->asGroup(), mResourceSystem);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mInventoryWindow);
|
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
mSpellWindow = new SpellWindow(mDragAndDrop);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mSpellWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
trackWindow(mSpellWindow, "spells");
|
|
|
|
|
|
|
|
mGuiModeStates[GM_Inventory] = GuiModeState({mMap, mInventoryWindow, mSpellWindow, mStatsWindow});
|
|
|
|
mGuiModeStates[GM_None] = GuiModeState({mMap, mInventoryWindow, mSpellWindow, mStatsWindow});
|
|
|
|
|
|
|
|
mTradeWindow = new TradeWindow();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mTradeWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
trackWindow(mTradeWindow, "barter");
|
|
|
|
mGuiModeStates[GM_Barter] = GuiModeState({mInventoryWindow, mTradeWindow});
|
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
mConsole = new Console(w,h, mConsoleOnlyScripts);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mConsole);
|
2013-12-03 17:42:35 +00:00
|
|
|
trackWindow(mConsole, "console");
|
2015-12-07 14:32:00 +00:00
|
|
|
|
|
|
|
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
|
2017-11-22 04:32:38 +00:00
|
|
|
JournalWindow* journal = JournalWindow::create(JournalViewModel::create (), questList, mEncoding);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(journal);
|
|
|
|
mGuiModeStates[GM_Journal] = GuiModeState(journal);
|
2017-09-22 22:00:40 +00:00
|
|
|
mGuiModeStates[GM_Journal].mCloseSound = "book close";
|
|
|
|
mGuiModeStates[GM_Journal].mOpenSound = "book open";
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2018-08-29 15:38:12 +00:00
|
|
|
mMessageBoxManager = new MessageBoxManager(mStore->get<ESM::GameSetting>().find("fMessageTimePerChar")->mValue.getFloat());
|
2017-09-23 19:45:52 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
SpellBuyingWindow* spellBuyingWindow = new SpellBuyingWindow();
|
|
|
|
mWindows.push_back(spellBuyingWindow);
|
|
|
|
mGuiModeStates[GM_SpellBuying] = GuiModeState(spellBuyingWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
TravelWindow* travelWindow = new TravelWindow();
|
|
|
|
mWindows.push_back(travelWindow);
|
|
|
|
mGuiModeStates[GM_Travel] = GuiModeState(travelWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mDialogueWindow = new DialogueWindow();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mDialogueWindow);
|
2013-12-03 17:42:35 +00:00
|
|
|
trackWindow(mDialogueWindow, "dialogue");
|
2017-09-22 18:46:08 +00:00
|
|
|
mGuiModeStates[GM_Dialogue] = GuiModeState(mDialogueWindow);
|
2017-09-25 16:07:49 +00:00
|
|
|
mTradeWindow->eventTradeDone += MyGUI::newDelegate(mDialogueWindow, &DialogueWindow::onTradeComplete);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
ContainerWindow* containerWindow = new ContainerWindow(mDragAndDrop);
|
|
|
|
mWindows.push_back(containerWindow);
|
|
|
|
trackWindow(containerWindow, "container");
|
|
|
|
mGuiModeStates[GM_Container] = GuiModeState({containerWindow, mInventoryWindow});
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2015-11-06 23:13:13 +00:00
|
|
|
mHud = new HUD(mCustomMarkers, mDragAndDrop, mLocalMapRender);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mHud);
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mToolTips = new ToolTips();
|
2017-09-23 19:45:52 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mScrollWindow = new ScrollWindow();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mScrollWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
mGuiModeStates[GM_Scroll] = GuiModeState(mScrollWindow);
|
2017-09-22 22:00:40 +00:00
|
|
|
mGuiModeStates[GM_Scroll].mOpenSound = "scroll";
|
|
|
|
mGuiModeStates[GM_Scroll].mCloseSound = "scroll";
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mBookWindow = new BookWindow();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mBookWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
mGuiModeStates[GM_Book] = GuiModeState(mBookWindow);
|
2017-09-22 22:00:40 +00:00
|
|
|
mGuiModeStates[GM_Book].mOpenSound = "book open";
|
|
|
|
mGuiModeStates[GM_Book].mCloseSound = "book close";
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mCountDialog = new CountDialog();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mCountDialog);
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mSettingsWindow = new SettingsWindow();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mSettingsWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
mGuiModeStates[GM_Settings] = GuiModeState(mSettingsWindow);
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mConfirmationDialog = new ConfirmationDialog();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mConfirmationDialog);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
AlchemyWindow* alchemyWindow = new AlchemyWindow();
|
|
|
|
mWindows.push_back(alchemyWindow);
|
|
|
|
trackWindow(alchemyWindow, "alchemy");
|
|
|
|
mGuiModeStates[GM_Alchemy] = GuiModeState(alchemyWindow);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mQuickKeysMenu = new QuickKeysMenu();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mQuickKeysMenu);
|
2017-09-22 18:46:08 +00:00
|
|
|
mGuiModeStates[GM_QuickKeysMenu] = GuiModeState(mQuickKeysMenu);
|
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
LevelupDialog* levelupDialog = new LevelupDialog();
|
|
|
|
mWindows.push_back(levelupDialog);
|
|
|
|
mGuiModeStates[GM_Levelup] = GuiModeState(levelupDialog);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mWaitDialog = new WaitDialog();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mWaitDialog);
|
2017-09-24 10:58:14 +00:00
|
|
|
mGuiModeStates[GM_Rest] = GuiModeState({mWaitDialog->getProgressBar(), mWaitDialog});
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
SpellCreationDialog* spellCreationDialog = new SpellCreationDialog();
|
|
|
|
mWindows.push_back(spellCreationDialog);
|
|
|
|
mGuiModeStates[GM_SpellCreation] = GuiModeState(spellCreationDialog);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
EnchantingDialog* enchantingDialog = new EnchantingDialog();
|
|
|
|
mWindows.push_back(enchantingDialog);
|
|
|
|
mGuiModeStates[GM_Enchanting] = GuiModeState(enchantingDialog);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
TrainingWindow* trainingWindow = new TrainingWindow();
|
|
|
|
mWindows.push_back(trainingWindow);
|
2017-09-24 10:58:14 +00:00
|
|
|
mGuiModeStates[GM_Training] = GuiModeState({trainingWindow->getProgressBar(), trainingWindow});
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
MerchantRepair* merchantRepair = new MerchantRepair();
|
|
|
|
mWindows.push_back(merchantRepair);
|
|
|
|
mGuiModeStates[GM_MerchantRepair] = GuiModeState(merchantRepair);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
Repair* repair = new Repair();
|
|
|
|
mWindows.push_back(repair);
|
|
|
|
mGuiModeStates[GM_Repair] = GuiModeState(repair);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mSoulgemDialog = new SoulgemDialog(mMessageBoxManager);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 20:42:55 +00:00
|
|
|
CompanionWindow* companionWindow = new CompanionWindow(mDragAndDrop, mMessageBoxManager);
|
|
|
|
mWindows.push_back(companionWindow);
|
|
|
|
trackWindow(companionWindow, "companion");
|
|
|
|
mGuiModeStates[GM_Companion] = GuiModeState({mInventoryWindow, companionWindow});
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2015-02-07 03:05:28 +00:00
|
|
|
mJailScreen = new JailScreen();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mJailScreen);
|
2017-09-22 18:46:08 +00:00
|
|
|
mGuiModeStates[GM_Jail] = GuiModeState(mJailScreen);
|
2014-10-05 15:53:50 +00:00
|
|
|
|
2015-12-07 13:41:33 +00:00
|
|
|
std::string werewolfFaderTex = "textures\\werewolfoverlay.dds";
|
|
|
|
if (mResourceSystem->getVFS()->exists(werewolfFaderTex))
|
2017-09-23 19:45:52 +00:00
|
|
|
{
|
2015-12-07 13:41:33 +00:00
|
|
|
mWerewolfFader = new ScreenFader(werewolfFaderTex);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mWerewolfFader);
|
|
|
|
}
|
2015-05-15 21:21:29 +00:00
|
|
|
mBlindnessFader = new ScreenFader("black");
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mBlindnessFader);
|
2015-12-07 17:32:58 +00:00
|
|
|
|
2014-10-11 21:09:20 +00:00
|
|
|
// fall back to player_hit_01.dds if bm_player_hit_01.dds is not available
|
2015-12-07 17:32:58 +00:00
|
|
|
std::string hitFaderTexture = "textures\\bm_player_hit_01.dds";
|
|
|
|
const std::string hitFaderLayout = "openmw_screen_fader_hit.layout";
|
|
|
|
MyGUI::FloatCoord hitFaderCoord (0,0,1,1);
|
2015-05-03 16:35:29 +00:00
|
|
|
if(!mResourceSystem->getVFS()->exists(hitFaderTexture))
|
2015-12-07 17:32:58 +00:00
|
|
|
{
|
2015-05-03 16:35:29 +00:00
|
|
|
hitFaderTexture = "textures\\player_hit_01.dds";
|
2015-12-07 17:32:58 +00:00
|
|
|
hitFaderCoord = MyGUI::FloatCoord(0.2, 0.25, 0.6, 0.5);
|
|
|
|
}
|
|
|
|
mHitFader = new ScreenFader(hitFaderTexture, hitFaderLayout, hitFaderCoord);
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mHitFader);
|
2015-12-07 17:32:58 +00:00
|
|
|
|
2015-05-15 21:21:29 +00:00
|
|
|
mScreenFader = new ScreenFader("black");
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mScreenFader);
|
2014-10-05 15:53:50 +00:00
|
|
|
|
2014-09-28 15:57:14 +00:00
|
|
|
mDebugWindow = new DebugWindow();
|
2017-09-23 19:45:52 +00:00
|
|
|
mWindows.push_back(mDebugWindow);
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2015-11-07 16:48:36 +00:00
|
|
|
mInputBlocker = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Stretch,"InputBlocker");
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2017-09-23 10:58:28 +00:00
|
|
|
mHud->setVisible(true);
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2016-08-16 20:47:45 +00:00
|
|
|
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2017-04-12 18:57:32 +00:00
|
|
|
updatePinnedWindows();
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
// Set up visibility
|
|
|
|
updateVisible();
|
2013-08-27 13:48:13 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 09:43:39 +00:00
|
|
|
int WindowManager::getFontHeight() const
|
|
|
|
{
|
2020-05-28 19:09:10 +00:00
|
|
|
return mFontLoader->getFontHeight();
|
2018-06-18 09:43:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-15 15:54:18 +00:00
|
|
|
void WindowManager::setNewGame(bool newgame)
|
2010-10-22 20:53:34 +00:00
|
|
|
{
|
2013-05-15 15:54:18 +00:00
|
|
|
if (newgame)
|
2010-10-22 20:53:34 +00:00
|
|
|
{
|
2013-05-15 15:54:18 +00:00
|
|
|
disallowAll();
|
|
|
|
delete mCharGen;
|
2016-08-16 20:47:45 +00:00
|
|
|
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
2010-10-22 20:53:34 +00:00
|
|
|
}
|
2013-05-15 15:54:18 +00:00
|
|
|
else
|
|
|
|
allow(GW_ALL);
|
|
|
|
}
|
2012-05-29 10:35:03 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
WindowManager::~WindowManager()
|
2010-10-22 20:53:34 +00:00
|
|
|
{
|
2018-09-09 12:06:25 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
mKeyboardNavigation.reset();
|
2017-09-22 14:52:39 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
MyGUI::LanguageManager::getInstance().eventRequestTag.clear();
|
|
|
|
MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear();
|
|
|
|
MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear();
|
|
|
|
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
|
|
|
|
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
|
2015-01-31 00:31:41 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
for (WindowBase* window : mWindows)
|
|
|
|
delete window;
|
|
|
|
mWindows.clear();
|
2017-09-23 19:45:52 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
delete mMessageBoxManager;
|
|
|
|
delete mLocalMapRender;
|
|
|
|
delete mCharGen;
|
|
|
|
delete mDragAndDrop;
|
|
|
|
delete mSoulgemDialog;
|
|
|
|
delete mCursorManager;
|
|
|
|
delete mToolTips;
|
2015-01-31 00:31:41 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
cleanupGarbage();
|
2015-04-24 21:30:30 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
mFontLoader.reset();
|
2015-05-03 15:52:50 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
mGui->shutdown();
|
|
|
|
delete mGui;
|
2015-05-08 13:10:17 +00:00
|
|
|
|
2018-09-09 12:06:25 +00:00
|
|
|
mGuiPlatform->shutdown();
|
|
|
|
delete mGuiPlatform;
|
2020-04-16 13:31:20 +00:00
|
|
|
delete mVideoWrapper;
|
2018-09-09 12:06:25 +00:00
|
|
|
}
|
|
|
|
catch(const MyGUI::Exception& e)
|
|
|
|
{
|
|
|
|
Log(Debug::Error) << "Error in the destructor: " << e.what();
|
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2010-10-22 20:53:34 +00:00
|
|
|
|
2015-12-09 00:06:53 +00:00
|
|
|
void WindowManager::setStore(const MWWorld::ESMStore &store)
|
|
|
|
{
|
|
|
|
mStore = &store;
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::cleanupGarbage()
|
|
|
|
{
|
|
|
|
// Delete any dialogs which are no longer in use
|
|
|
|
if (!mGarbageDialogs.empty())
|
2012-03-31 19:29:46 +00:00
|
|
|
{
|
2019-03-02 09:27:59 +00:00
|
|
|
for (Layout* widget : mGarbageDialogs)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2019-03-02 09:27:59 +00:00
|
|
|
delete widget;
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
|
|
|
mGarbageDialogs.clear();
|
2011-06-19 17:10:44 +00:00
|
|
|
}
|
2011-11-28 15:51:11 +00:00
|
|
|
}
|
2010-07-26 09:15:38 +00:00
|
|
|
|
2019-06-21 13:37:00 +00:00
|
|
|
void WindowManager::enableScene(bool enable)
|
|
|
|
{
|
|
|
|
unsigned int disablemask = MWRender::Mask_GUI|MWRender::Mask_PreCompile;
|
|
|
|
if (!enable && mViewer->getCamera()->getCullMask() != disablemask)
|
|
|
|
{
|
|
|
|
mOldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask();
|
|
|
|
mOldCullMask = mViewer->getCamera()->getCullMask();
|
|
|
|
mViewer->getUpdateVisitor()->setTraversalMask(disablemask);
|
|
|
|
mViewer->getCamera()->setCullMask(disablemask);
|
|
|
|
}
|
|
|
|
else if (enable && mViewer->getCamera()->getCullMask() == disablemask)
|
|
|
|
{
|
|
|
|
mViewer->getUpdateVisitor()->setTraversalMask(mOldUpdateMask);
|
|
|
|
mViewer->getCamera()->setCullMask(mOldCullMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::updateVisible()
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2019-06-21 13:37:00 +00:00
|
|
|
bool loading = (getMode() == GM_Loading || getMode() == GM_LoadingWallpaper);
|
|
|
|
|
|
|
|
bool mainmenucover = containsMode(GM_MainMenu) && MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame;
|
|
|
|
|
|
|
|
enableScene(!loading && !mainmenucover);
|
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
if (!mMap)
|
|
|
|
return; // UI not created yet
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2017-09-23 10:58:28 +00:00
|
|
|
mHud->setVisible(mHudEnabled && !loading);
|
|
|
|
mToolTips->setVisible(mHudEnabled && !loading);
|
2013-04-17 22:56:48 +00:00
|
|
|
|
|
|
|
bool gameMode = !isGuiMode();
|
|
|
|
|
2017-09-23 21:14:53 +00:00
|
|
|
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mInputBlocker->setVisible (gameMode);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
|
|
|
if (loading)
|
|
|
|
setCursorVisible(mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox());
|
|
|
|
else
|
|
|
|
setCursorVisible(!gameMode);
|
2013-04-17 22:56:48 +00:00
|
|
|
|
|
|
|
if (gameMode)
|
2019-06-08 23:08:09 +00:00
|
|
|
setKeyFocusWidget (nullptr);
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2013-08-12 08:39:45 +00:00
|
|
|
// Icons of forced hidden windows are displayed
|
|
|
|
setMinimapVisibility((mAllowed & GW_Map) && (!mMap->pinned() || (mForceHidden & GW_Map)));
|
|
|
|
setWeaponVisibility((mAllowed & GW_Inventory) && (!mInventoryWindow->pinned() || (mForceHidden & GW_Inventory)));
|
|
|
|
setSpellVisibility((mAllowed & GW_Magic) && (!mSpellWindow->pinned() || (mForceHidden & GW_Magic)));
|
|
|
|
setHMSVisibility((mAllowed & GW_Stats) && (!mStatsWindow->pinned() || (mForceHidden & GW_Stats)));
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2017-09-23 12:42:25 +00:00
|
|
|
mInventoryWindow->setGuiMode(getMode());
|
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
// If in game mode (or interactive messagebox), show the pinned windows
|
2017-04-10 06:18:00 +00:00
|
|
|
if (mGuiModes.empty())
|
2012-03-31 19:29:46 +00:00
|
|
|
{
|
2019-05-16 06:28:56 +00:00
|
|
|
mMap->setVisible(mMap->pinned() && !isConsoleMode() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map));
|
|
|
|
mStatsWindow->setVisible(mStatsWindow->pinned() && !isConsoleMode() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats));
|
|
|
|
mInventoryWindow->setVisible(mInventoryWindow->pinned() && !isConsoleMode() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory));
|
|
|
|
mSpellWindow->setVisible(mSpellWindow->pinned() && !isConsoleMode() && !(mForceHidden & GW_Magic) && (mAllowed & GW_Magic));
|
2017-04-10 06:18:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-09-23 12:42:25 +00:00
|
|
|
else if (getMode() != GM_Inventory)
|
|
|
|
{
|
|
|
|
mMap->setVisible(false);
|
|
|
|
mStatsWindow->setVisible(false);
|
|
|
|
mSpellWindow->setVisible(false);
|
2017-10-03 22:07:56 +00:00
|
|
|
mInventoryWindow->setVisible(getMode() == GM_Container || getMode() == GM_Barter || getMode() == GM_Companion);
|
2017-09-23 12:42:25 +00:00
|
|
|
}
|
2017-04-10 06:18:00 +00:00
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
GuiMode mode = mGuiModes.back();
|
|
|
|
|
|
|
|
mInventoryWindow->setTrading(mode == GM_Barter);
|
|
|
|
|
|
|
|
if (getMode() == GM_Inventory)
|
2014-06-02 22:21:13 +00:00
|
|
|
{
|
2017-10-04 15:08:09 +00:00
|
|
|
// For the inventory mode, compute the effective set of windows to show.
|
|
|
|
// This is controlled both by what windows the
|
|
|
|
// user has opened/closed (the 'shown' variable) and by what
|
|
|
|
// windows we are allowed to show (the 'allowed' var.)
|
|
|
|
int eff = mShown & mAllowed & ~mForceHidden;
|
|
|
|
mMap->setVisible(eff & GW_Map);
|
|
|
|
mInventoryWindow->setVisible(eff & GW_Inventory);
|
|
|
|
mSpellWindow->setVisible(eff & GW_Magic);
|
|
|
|
mStatsWindow->setVisible(eff & GW_Stats);
|
|
|
|
}
|
2017-09-22 18:46:08 +00:00
|
|
|
|
|
|
|
switch (mode)
|
2014-06-02 22:21:13 +00:00
|
|
|
{
|
2017-09-22 18:46:08 +00:00
|
|
|
// FIXME: refactor chargen windows to use modes properly (or not use them at all)
|
|
|
|
case GM_Name:
|
|
|
|
case GM_Race:
|
|
|
|
case GM_Class:
|
|
|
|
case GM_ClassPick:
|
|
|
|
case GM_ClassCreate:
|
|
|
|
case GM_Birth:
|
|
|
|
case GM_ClassGenerate:
|
|
|
|
case GM_Review:
|
|
|
|
mCharGen->spawnDialog(mode);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-02-03 10:24:28 +00:00
|
|
|
}
|
2010-07-27 13:59:41 +00:00
|
|
|
|
2014-01-03 00:59:15 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, const MWMechanics::AttributeValue& value)
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
mStatsWindow->setValue (id, value);
|
|
|
|
mCharGen->setValue(id, value);
|
2012-02-03 10:24:28 +00:00
|
|
|
}
|
2010-08-22 09:22:10 +00:00
|
|
|
|
2014-01-03 00:59:15 +00:00
|
|
|
void WindowManager::setValue (int parSkill, const MWMechanics::SkillValue& value)
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
/// \todo Don't use the skill enum as a parameter type (we will have to drop it anyway, once we
|
|
|
|
/// allow custom skills.
|
|
|
|
mStatsWindow->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
|
|
|
mCharGen->setValue(static_cast<ESM::Skill::SkillEnum> (parSkill), value);
|
2012-02-03 10:24:28 +00:00
|
|
|
}
|
2010-09-15 10:22:06 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
2012-02-03 10:24:28 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
mStatsWindow->setValue (id, value);
|
|
|
|
mHud->setValue (id, value);
|
|
|
|
mCharGen->setValue(id, value);
|
2012-02-03 10:24:28 +00:00
|
|
|
}
|
2010-10-21 07:28:09 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, const std::string& value)
|
|
|
|
{
|
|
|
|
mStatsWindow->setValue (id, value);
|
|
|
|
}
|
2010-09-17 23:30:23 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setValue (const std::string& id, int value)
|
|
|
|
{
|
|
|
|
mStatsWindow->setValue (id, value);
|
|
|
|
}
|
2010-09-18 00:24:42 +00:00
|
|
|
|
2014-04-27 02:27:26 +00:00
|
|
|
void WindowManager::setDrowningTimeLeft (float time, float maxTime)
|
2013-08-07 13:34:11 +00:00
|
|
|
{
|
2014-04-27 02:27:26 +00:00
|
|
|
mHud->setDrowningTimeLeft(time, maxTime);
|
2013-08-07 13:34:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setPlayerClass (const ESM::Class &class_)
|
|
|
|
{
|
|
|
|
mStatsWindow->setValue("class", class_.mName);
|
|
|
|
}
|
2010-09-18 00:24:42 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::configureSkills (const SkillList& major, const SkillList& minor)
|
|
|
|
{
|
|
|
|
mStatsWindow->configureSkills (major, minor);
|
|
|
|
mCharGen->configureSkills(major, minor);
|
|
|
|
}
|
2010-09-18 00:24:42 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::updateSkillArea()
|
2011-06-14 16:29:55 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
mStatsWindow->updateSkillArea();
|
2010-08-22 10:56:35 +00:00
|
|
|
}
|
2010-09-14 17:33:40 +00:00
|
|
|
|
2015-05-01 00:09:57 +00:00
|
|
|
void WindowManager::removeDialog(Layout*dialog)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
|
|
|
if (!dialog)
|
|
|
|
return;
|
|
|
|
dialog->setVisible(false);
|
|
|
|
mGarbageDialogs.push_back(dialog);
|
|
|
|
}
|
2011-07-12 18:05:04 +00:00
|
|
|
|
2017-09-22 21:25:20 +00:00
|
|
|
void WindowManager::exitCurrentGuiMode()
|
|
|
|
{
|
|
|
|
if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
{
|
|
|
|
mDragAndDrop->finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-23 10:18:39 +00:00
|
|
|
GuiModeState& state = mGuiModeStates[mGuiModes.back()];
|
|
|
|
for (WindowBase* window : state.mWindows)
|
|
|
|
{
|
|
|
|
if (!window->exit())
|
|
|
|
{
|
|
|
|
// unable to exit window, but give access to main menu
|
2017-10-05 16:35:09 +00:00
|
|
|
if (!MyGUI::InputManager::getInstance().isModalAny() && getMode() != GM_MainMenu)
|
|
|
|
pushGuiMode (GM_MainMenu);
|
2017-09-23 10:18:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-05-27 03:13:37 +00:00
|
|
|
}
|
2017-09-23 10:18:39 +00:00
|
|
|
|
|
|
|
popGuiMode();
|
2014-05-27 03:13:37 +00:00
|
|
|
}
|
|
|
|
|
2015-01-10 22:21:39 +00:00
|
|
|
void WindowManager::interactiveMessageBox(const std::string &message, const std::vector<std::string> &buttons, bool block)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2015-01-10 22:21:39 +00:00
|
|
|
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
|
|
|
|
updateVisible();
|
|
|
|
|
|
|
|
if (block)
|
|
|
|
{
|
2017-08-30 21:26:30 +00:00
|
|
|
osg::Timer frameTimer;
|
2015-01-10 22:58:55 +00:00
|
|
|
while (mMessageBoxManager->readPressedButton(false) == -1
|
2015-01-10 22:21:39 +00:00
|
|
|
&& !MWBase::Environment::get().getStateManager()->hasQuitRequest())
|
|
|
|
{
|
2017-08-30 21:26:30 +00:00
|
|
|
double dt = frameTimer.time_s();
|
|
|
|
frameTimer.setStartTick();
|
2015-01-10 22:21:39 +00:00
|
|
|
|
2017-09-27 19:40:59 +00:00
|
|
|
mKeyboardNavigation->onFrame();
|
2017-08-30 21:26:30 +00:00
|
|
|
mMessageBoxManager->onFrame(dt);
|
|
|
|
MWBase::Environment::get().getInputManager()->update(dt, true, false);
|
2015-01-10 22:21:39 +00:00
|
|
|
|
2020-04-16 13:31:20 +00:00
|
|
|
if (!mWindowVisible)
|
2017-08-30 21:26:30 +00:00
|
|
|
OpenThreads::Thread::microSleep(5000);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mViewer->eventTraversal();
|
|
|
|
mViewer->updateTraversal();
|
|
|
|
mViewer->renderingTraversals();
|
|
|
|
}
|
2015-11-06 21:41:32 +00:00
|
|
|
// at the time this function is called we are in the middle of a frame,
|
|
|
|
// so out of order calls are necessary to get a correct frameNumber for the next frame.
|
|
|
|
// refer to the advance() and frame() order in Engine::go()
|
|
|
|
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
2017-08-30 21:26:30 +00:00
|
|
|
|
|
|
|
MWBase::Environment::get().limitFrameRate(frameTimer.time_s());
|
2013-05-09 21:19:04 +00:00
|
|
|
}
|
2015-01-10 22:21:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode)
|
|
|
|
{
|
|
|
|
if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never) {
|
|
|
|
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(message));
|
|
|
|
} else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) {
|
|
|
|
mMessageBoxManager->createMessageBox(message);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2011-06-14 16:29:55 +00:00
|
|
|
}
|
2012-11-06 07:29:18 +00:00
|
|
|
|
2013-05-03 10:44:27 +00:00
|
|
|
void WindowManager::staticMessageBox(const std::string& message)
|
|
|
|
{
|
|
|
|
mMessageBoxManager->createMessageBox(message, true);
|
|
|
|
}
|
2010-09-15 10:41:53 +00:00
|
|
|
|
2013-05-03 10:44:27 +00:00
|
|
|
void WindowManager::removeStaticMessageBox()
|
2010-11-03 20:21:08 +00:00
|
|
|
{
|
2013-05-03 10:44:27 +00:00
|
|
|
mMessageBoxManager->removeStaticMessageBox();
|
2010-11-03 20:21:08 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
int WindowManager::readPressedButton ()
|
2012-05-18 15:58:33 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
return mMessageBoxManager->readPressedButton();
|
2012-05-18 15:58:33 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
|
|
|
|
{
|
2015-12-09 00:06:53 +00:00
|
|
|
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().search(id);
|
2012-11-06 07:29:18 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
if (setting && setting->mValue.getType()==ESM::VT_String)
|
|
|
|
return setting->mValue.getString();
|
2012-11-05 22:16:37 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
return default_;
|
|
|
|
}
|
2012-05-19 12:19:21 +00:00
|
|
|
|
2015-05-26 14:40:44 +00:00
|
|
|
void WindowManager::updateMap()
|
|
|
|
{
|
2015-07-11 01:33:31 +00:00
|
|
|
if (!mLocalMapRender)
|
|
|
|
return;
|
|
|
|
|
2016-02-04 23:39:52 +00:00
|
|
|
MWWorld::ConstPtr player = MWMechanics::getPlayer();
|
2015-05-26 14:40:44 +00:00
|
|
|
|
|
|
|
osg::Vec3f playerPosition = player.getRefData().getPosition().asVec3();
|
|
|
|
osg::Quat playerOrientation (-player.getRefData().getPosition().rot[2], osg::Vec3(0,0,1));
|
|
|
|
|
|
|
|
osg::Vec3f playerdirection;
|
|
|
|
int x,y;
|
|
|
|
float u,v;
|
|
|
|
mLocalMapRender->updatePlayer(playerPosition, playerOrientation, u, v, x, y, playerdirection);
|
|
|
|
|
|
|
|
if (!player.getCell()->isExterior())
|
|
|
|
{
|
2016-02-04 23:39:52 +00:00
|
|
|
setActiveMap(x, y, true);
|
2015-05-26 14:40:44 +00:00
|
|
|
}
|
2016-02-04 23:39:52 +00:00
|
|
|
// else: need to know the current grid center, call setActiveMap from changeCell
|
2015-05-26 14:40:44 +00:00
|
|
|
|
|
|
|
mMap->setPlayerDir(playerdirection.x(), playerdirection.y());
|
|
|
|
mMap->setPlayerPos(x, y, u, v);
|
|
|
|
mHud->setPlayerDir(playerdirection.x(), playerdirection.y());
|
|
|
|
mHud->setPlayerPos(x, y, u, v);
|
|
|
|
}
|
|
|
|
|
2020-05-26 12:54:04 +00:00
|
|
|
void WindowManager::update (float frameDuration)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2019-02-20 13:37:00 +00:00
|
|
|
bool gameRunning = MWBase::Environment::get().getStateManager()->getState()!=
|
|
|
|
MWBase::StateManager::State_NoGame;
|
|
|
|
|
|
|
|
if (gameRunning)
|
|
|
|
updateMap();
|
|
|
|
|
2017-09-23 20:00:15 +00:00
|
|
|
if (!mGuiModes.empty())
|
|
|
|
{
|
|
|
|
GuiModeState& state = mGuiModeStates[mGuiModes.back()];
|
|
|
|
for (WindowBase* window : state.mWindows)
|
|
|
|
window->onFrame(frameDuration);
|
|
|
|
}
|
2017-10-04 15:08:52 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// update pinned windows if visible
|
|
|
|
for (WindowBase* window : mGuiModeStates[GM_Inventory].mWindows)
|
|
|
|
if (window->isVisible())
|
|
|
|
window->onFrame(frameDuration);
|
|
|
|
}
|
|
|
|
|
2018-01-14 00:27:53 +00:00
|
|
|
// Make sure message boxes are always in front
|
|
|
|
// This is an awful workaround for a series of awfully interwoven issues that couldn't be worked around
|
|
|
|
// in a better way because of an impressive number of even more awfully interwoven issues.
|
|
|
|
if (mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox() && mCurrentModals.back() != mMessageBoxManager->getInteractiveMessageBox())
|
|
|
|
{
|
|
|
|
std::vector<WindowModal*>::iterator found = std::find(mCurrentModals.begin(), mCurrentModals.end(), mMessageBoxManager->getInteractiveMessageBox());
|
|
|
|
if (found != mCurrentModals.end())
|
|
|
|
{
|
|
|
|
WindowModal* msgbox = *found;
|
|
|
|
std::swap(*found, mCurrentModals.back());
|
|
|
|
MyGUI::InputManager::getInstance().addWidgetModal(msgbox->mMainWidget);
|
|
|
|
mKeyboardNavigation->setModalWindow(msgbox->mMainWidget);
|
|
|
|
mKeyboardNavigation->setDefaultFocus(msgbox->mMainWidget, msgbox->getDefaultKeyFocus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-23 20:00:15 +00:00
|
|
|
if (!mCurrentModals.empty())
|
2017-10-04 15:03:23 +00:00
|
|
|
mCurrentModals.back()->onFrame(frameDuration);
|
2017-09-23 20:00:15 +00:00
|
|
|
|
2017-09-26 17:22:23 +00:00
|
|
|
mKeyboardNavigation->onFrame();
|
|
|
|
|
2018-08-01 15:30:30 +00:00
|
|
|
if (mMessageBoxManager)
|
|
|
|
mMessageBoxManager->onFrame(frameDuration);
|
2012-05-26 21:06:15 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mToolTips->onFrame(frameDuration);
|
2012-09-19 00:53:06 +00:00
|
|
|
|
2015-05-26 14:40:44 +00:00
|
|
|
if (mLocalMapRender)
|
|
|
|
mLocalMapRender->cleanupCameras();
|
|
|
|
|
2019-02-20 13:37:00 +00:00
|
|
|
if (!gameRunning)
|
2014-01-21 13:50:58 +00:00
|
|
|
return;
|
|
|
|
|
2019-09-05 16:16:03 +00:00
|
|
|
// We should display message about crime only once per frame, even if there are several crimes.
|
|
|
|
// Otherwise we will get message spam when stealing several items via Take All button.
|
|
|
|
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
int currentBounty = player.getClass().getNpcStats(player).getBounty();
|
|
|
|
if (currentBounty != mPlayerBounty)
|
|
|
|
{
|
|
|
|
if (mPlayerBounty >= 0 && currentBounty > mPlayerBounty)
|
|
|
|
messageBox("#{sCrimeMessage}");
|
|
|
|
|
|
|
|
mPlayerBounty = currentBounty;
|
|
|
|
}
|
|
|
|
|
2017-09-26 14:51:19 +00:00
|
|
|
mDragAndDrop->onFrame();
|
2011-06-15 20:53:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mHud->onFrame(frameDuration);
|
2012-05-26 23:14:33 +00:00
|
|
|
|
2014-09-28 15:57:14 +00:00
|
|
|
mDebugWindow->onFrame(frameDuration);
|
2016-11-18 16:59:05 +00:00
|
|
|
|
|
|
|
if (mCharGen)
|
|
|
|
mCharGen->onFrame(frameDuration);
|
2017-09-23 20:24:22 +00:00
|
|
|
|
|
|
|
updateActivatedQuickKey ();
|
|
|
|
|
|
|
|
cleanupGarbage();
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2011-06-15 20:53:05 +00:00
|
|
|
|
2016-02-04 23:39:52 +00:00
|
|
|
void WindowManager::changeCell(const MWWorld::CellStore* cell)
|
2012-03-16 16:09:31 +00:00
|
|
|
{
|
2016-02-04 23:39:52 +00:00
|
|
|
mMap->requestMapRender(cell);
|
|
|
|
|
2013-11-26 10:49:07 +00:00
|
|
|
std::string name = MWBase::Environment::get().getWorld()->getCellName (cell);
|
|
|
|
|
|
|
|
mMap->setCellName( name );
|
|
|
|
mHud->setCellName( name );
|
|
|
|
|
2014-02-21 10:35:46 +00:00
|
|
|
if (cell->getCell()->isExterior())
|
2012-09-20 15:30:09 +00:00
|
|
|
{
|
2014-02-21 10:35:46 +00:00
|
|
|
if (!cell->getCell()->mName.empty())
|
2015-08-06 21:29:19 +00:00
|
|
|
mMap->addVisitedLocation (name, cell->getCell()->getGridX (), cell->getCell()->getGridY ());
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2014-02-21 10:35:46 +00:00
|
|
|
mMap->cellExplored (cell->getCell()->getGridX(), cell->getCell()->getGridY());
|
2016-02-04 23:39:52 +00:00
|
|
|
|
|
|
|
setActiveMap(cell->getCell()->getGridX(), cell->getCell()->getGridY(), false);
|
2012-09-20 15:30:09 +00:00
|
|
|
}
|
2012-03-16 16:09:31 +00:00
|
|
|
else
|
2012-04-17 16:47:51 +00:00
|
|
|
{
|
2014-02-21 10:35:46 +00:00
|
|
|
mMap->setCellPrefix (cell->getCell()->mName );
|
|
|
|
mHud->setCellPrefix (cell->getCell()->mName );
|
2013-12-31 17:35:46 +00:00
|
|
|
|
2015-06-03 17:41:19 +00:00
|
|
|
osg::Vec3f worldPos;
|
2013-12-31 23:12:31 +00:00
|
|
|
if (!MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos))
|
|
|
|
worldPos = MWBase::Environment::get().getWorld()->getPlayer().getLastKnownExteriorPosition();
|
|
|
|
else
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setLastKnownExteriorPosition(worldPos);
|
2015-06-03 17:41:19 +00:00
|
|
|
mMap->setGlobalMapPlayerPosition(worldPos.x(), worldPos.y());
|
2016-02-04 23:39:52 +00:00
|
|
|
|
|
|
|
setActiveMap(0, 0, true);
|
2012-04-17 16:47:51 +00:00
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-03-23 15:51:56 +00:00
|
|
|
|
2014-05-11 00:27:43 +00:00
|
|
|
void WindowManager::setActiveMap(int x, int y, bool interior)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2014-05-11 00:27:43 +00:00
|
|
|
mMap->setActiveCell(x,y, interior);
|
|
|
|
mHud->setActiveCell(x,y, interior);
|
2012-03-16 16:09:31 +00:00
|
|
|
}
|
2012-03-23 15:51:56 +00:00
|
|
|
|
2013-08-07 13:34:11 +00:00
|
|
|
void WindowManager::setDrowningBarVisibility(bool visible)
|
|
|
|
{
|
|
|
|
mHud->setDrowningBarVisible(visible);
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setHMSVisibility(bool visible)
|
|
|
|
{
|
|
|
|
mHud->setHmsVisible (visible);
|
|
|
|
}
|
2012-03-23 07:16:04 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setMinimapVisibility(bool visible)
|
|
|
|
{
|
|
|
|
mHud->setMinimapVisible (visible);
|
|
|
|
}
|
2012-03-23 14:00:48 +00:00
|
|
|
|
2014-05-16 07:21:08 +00:00
|
|
|
bool WindowManager::toggleFogOfWar()
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
|
|
|
mMap->toggleFogOfWar();
|
2014-05-16 07:21:08 +00:00
|
|
|
return mHud->toggleFogOfWar();
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-04-05 22:17:23 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setFocusObject(const MWWorld::Ptr& focus)
|
|
|
|
{
|
|
|
|
mToolTips->setFocusObject(focus);
|
2015-07-18 10:22:37 +00:00
|
|
|
|
2015-07-18 15:13:20 +00:00
|
|
|
if(mHud && (mShowOwned == 2 || mShowOwned == 3))
|
2015-07-17 17:13:45 +00:00
|
|
|
{
|
|
|
|
bool owned = mToolTips->checkOwned();
|
2015-07-18 10:22:37 +00:00
|
|
|
mHud->setCrosshairOwned(owned);
|
2015-07-17 17:13:45 +00:00
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-04-05 22:17:23 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y)
|
|
|
|
{
|
|
|
|
mToolTips->setFocusObjectScreenCoords(min_x, min_y, max_x, max_y);
|
|
|
|
}
|
2012-04-07 14:30:20 +00:00
|
|
|
|
2014-05-16 07:21:08 +00:00
|
|
|
bool WindowManager::toggleFullHelp()
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2014-05-16 07:21:08 +00:00
|
|
|
return mToolTips->toggleFullHelp();
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-04-13 11:17:50 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::getFullHelp() const
|
|
|
|
{
|
|
|
|
return mToolTips->getFullHelp();
|
|
|
|
}
|
2012-04-16 13:00:44 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setWeaponVisibility(bool visible)
|
|
|
|
{
|
|
|
|
mHud->setWeapVisible (visible);
|
|
|
|
}
|
2012-05-14 19:37:43 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setSpellVisibility(bool visible)
|
|
|
|
{
|
|
|
|
mHud->setSpellVisible (visible);
|
|
|
|
mHud->setEffectVisible (visible);
|
|
|
|
}
|
2012-04-16 20:58:16 +00:00
|
|
|
|
2013-08-03 00:45:26 +00:00
|
|
|
void WindowManager::setSneakVisibility(bool visible)
|
|
|
|
{
|
|
|
|
mHud->setSneakVisible(visible);
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setDragDrop(bool dragDrop)
|
|
|
|
{
|
|
|
|
mToolTips->setEnabled(!dragDrop);
|
|
|
|
MWBase::Environment::get().getInputManager()->setDragDrop(dragDrop);
|
|
|
|
}
|
2012-05-12 20:44:12 +00:00
|
|
|
|
2013-06-12 10:34:33 +00:00
|
|
|
void WindowManager::setCursorVisible(bool visible)
|
|
|
|
{
|
|
|
|
mCursorVisible = visible;
|
2017-09-26 15:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::setCursorActive(bool active)
|
|
|
|
{
|
|
|
|
mCursorActive = active;
|
2013-01-12 15:57:29 +00:00
|
|
|
}
|
2013-06-12 10:34:33 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result)
|
2013-01-12 15:57:29 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
std::string tag(_tag);
|
2015-07-18 20:17:46 +00:00
|
|
|
|
|
|
|
std::string MyGuiPrefix = "setting=";
|
|
|
|
size_t MyGuiPrefixLength = MyGuiPrefix.length();
|
2013-01-12 15:57:29 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
std::string tokenToFind = "sCell=";
|
|
|
|
size_t tokenLength = tokenToFind.length();
|
2015-07-18 20:17:46 +00:00
|
|
|
|
|
|
|
if(tag.compare(0, MyGuiPrefixLength, MyGuiPrefix) == 0)
|
|
|
|
{
|
|
|
|
tag = tag.substr(MyGuiPrefixLength, tag.length());
|
|
|
|
std::string settingSection = tag.substr(0, tag.find(","));
|
|
|
|
std::string settingTag = tag.substr(tag.find(",")+1, tag.length());
|
|
|
|
|
|
|
|
_result = Settings::Manager::getString(settingTag, settingSection);
|
|
|
|
}
|
|
|
|
else if (tag.compare(0, tokenLength, tokenToFind) == 0)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
|
|
|
_result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength));
|
2019-05-26 22:41:06 +00:00
|
|
|
_result = MyGUI::TextIterator::toTagsString(_result);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2019-01-22 06:08:48 +00:00
|
|
|
else if (Gui::replaceTag(tag, _result))
|
2014-09-19 09:53:20 +00:00
|
|
|
{
|
2014-09-24 22:04:38 +00:00
|
|
|
return;
|
2014-09-20 07:07:47 +00:00
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
else
|
|
|
|
{
|
2015-12-09 00:06:53 +00:00
|
|
|
if (!mStore)
|
|
|
|
{
|
2018-08-14 19:05:43 +00:00
|
|
|
Log(Debug::Error) << "Error: WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'";
|
2015-12-09 00:06:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().find(tag);
|
2013-01-11 13:32:29 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
if (setting && setting->mValue.getType()==ESM::VT_String)
|
|
|
|
_result = setting->mValue.getString();
|
|
|
|
else
|
|
|
|
_result = tag;
|
|
|
|
}
|
|
|
|
}
|
2012-05-13 09:25:35 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
|
|
|
{
|
|
|
|
mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI"));
|
2012-05-19 12:19:21 +00:00
|
|
|
|
2020-04-16 13:31:20 +00:00
|
|
|
bool changeRes = false;
|
2019-03-02 09:27:59 +00:00
|
|
|
for (const auto& setting : changed)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2019-03-02 09:27:59 +00:00
|
|
|
if (setting.first == "HUD" && setting.second == "crosshair")
|
2013-04-17 22:56:48 +00:00
|
|
|
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
|
2019-03-02 09:27:59 +00:00
|
|
|
else if (setting.first == "GUI" && setting.second == "subtitles")
|
2013-04-17 22:56:48 +00:00
|
|
|
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
2019-03-02 09:27:59 +00:00
|
|
|
else if (setting.first == "GUI" && setting.second == "menu transparency")
|
2015-05-02 16:06:54 +00:00
|
|
|
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
2020-04-16 13:31:20 +00:00
|
|
|
else if (setting.first == "Video" && (
|
|
|
|
setting.second == "resolution x"
|
|
|
|
|| setting.second == "resolution y"
|
|
|
|
|| setting.second == "fullscreen"
|
|
|
|
|| setting.second == "window border"))
|
|
|
|
changeRes = true;
|
|
|
|
|
|
|
|
else if (setting.first == "Video" && setting.second == "vsync")
|
|
|
|
mVideoWrapper->setSyncToVBlank(Settings::Manager::getBool("vsync", "Video"));
|
|
|
|
else if (setting.first == "Video" && (setting.second == "gamma" || setting.second == "contrast"))
|
|
|
|
mVideoWrapper->setGammaContrast(Settings::Manager::getFloat("gamma", "Video"),
|
|
|
|
Settings::Manager::getFloat("contrast", "Video"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changeRes)
|
|
|
|
{
|
|
|
|
mVideoWrapper->setVideoMode(Settings::Manager::getInt("resolution x", "Video"),
|
|
|
|
Settings::Manager::getInt("resolution y", "Video"),
|
|
|
|
Settings::Manager::getBool("fullscreen", "Video"),
|
|
|
|
Settings::Manager::getBool("window border", "Video"));
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2013-07-29 00:32:08 +00:00
|
|
|
}
|
2012-12-23 19:23:24 +00:00
|
|
|
|
2013-07-29 00:32:08 +00:00
|
|
|
void WindowManager::windowResized(int x, int y)
|
|
|
|
{
|
2020-04-16 13:31:20 +00:00
|
|
|
// Note: this is a side effect of resolution change or window resize.
|
|
|
|
// There is no need to track these changes.
|
|
|
|
Settings::Manager::setInt("resolution x", "Video", x);
|
|
|
|
Settings::Manager::setInt("resolution y", "Video", y);
|
|
|
|
Settings::Manager::resetPendingChange("resolution x", "Video");
|
|
|
|
Settings::Manager::resetPendingChange("resolution y", "Video");
|
|
|
|
|
2015-05-14 22:41:21 +00:00
|
|
|
mGuiPlatform->getRenderManagerPtr()->setViewSize(x, y);
|
|
|
|
|
|
|
|
// scaled size
|
|
|
|
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
x = viewSize.width;
|
|
|
|
y = viewSize.height;
|
|
|
|
|
2014-03-27 18:10:15 +00:00
|
|
|
sizeVideo(x, y);
|
2015-04-24 19:55:30 +00:00
|
|
|
|
2013-08-28 15:04:38 +00:00
|
|
|
if (!mHud)
|
|
|
|
return; // UI not initialized yet
|
2013-12-03 17:42:35 +00:00
|
|
|
|
|
|
|
for (std::map<MyGUI::Window*, std::string>::iterator it = mTrackedWindows.begin(); it != mTrackedWindows.end(); ++it)
|
|
|
|
{
|
2019-04-26 07:37:57 +00:00
|
|
|
std::string settingName = it->second;
|
|
|
|
if (Settings::Manager::getBool(settingName + " maximized", "Windows"))
|
|
|
|
settingName += " maximized";
|
|
|
|
|
|
|
|
MyGUI::IntPoint pos(static_cast<int>(Settings::Manager::getFloat(settingName + " x", "Windows") * x),
|
|
|
|
static_cast<int>(Settings::Manager::getFloat(settingName + " y", "Windows") * y));
|
|
|
|
MyGUI::IntSize size(static_cast<int>(Settings::Manager::getFloat(settingName + " w", "Windows") * x),
|
|
|
|
static_cast<int>(Settings::Manager::getFloat(settingName + " h", "Windows") * y));
|
2013-12-03 17:42:35 +00:00
|
|
|
it->first->setPosition(pos);
|
|
|
|
it->first->setSize(size);
|
|
|
|
}
|
|
|
|
|
2017-09-23 20:07:30 +00:00
|
|
|
for (WindowBase* window : mWindows)
|
|
|
|
window->onResChange(x, y);
|
|
|
|
|
2020-04-16 13:31:20 +00:00
|
|
|
// We should reload TrueType fonts to fit new resolution
|
|
|
|
loadUserFonts();
|
|
|
|
|
2017-09-23 20:07:30 +00:00
|
|
|
// TODO: check if any windows are now off-screen and move them back if so
|
2012-12-23 19:23:24 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 13:31:20 +00:00
|
|
|
bool WindowManager::isWindowVisible()
|
|
|
|
{
|
|
|
|
return mWindowVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::windowVisibilityChange(bool visible)
|
|
|
|
{
|
|
|
|
mWindowVisible = visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::windowClosed()
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
|
|
|
}
|
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
void WindowManager::onCursorChange(const std::string &name)
|
|
|
|
{
|
|
|
|
mCursorManager->cursorChanged(name);
|
2012-12-23 19:23:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::pushGuiMode(GuiMode mode)
|
2012-12-23 19:23:24 +00:00
|
|
|
{
|
2017-09-22 19:26:41 +00:00
|
|
|
pushGuiMode(mode, MWWorld::Ptr());
|
|
|
|
}
|
2012-12-23 19:23:24 +00:00
|
|
|
|
2017-09-22 19:26:41 +00:00
|
|
|
void WindowManager::pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg)
|
2012-12-23 19:23:24 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
if (mode==GM_Inventory && mAllowed==GW_None)
|
|
|
|
return;
|
2012-12-23 19:23:24 +00:00
|
|
|
|
2017-09-22 19:26:41 +00:00
|
|
|
if (mGuiModes.empty() || mGuiModes.back() != mode)
|
2012-05-28 07:19:25 +00:00
|
|
|
{
|
2017-09-22 19:26:41 +00:00
|
|
|
// If this mode already exists somewhere in the stack, just bring it to the front.
|
|
|
|
if (std::find(mGuiModes.begin(), mGuiModes.end(), mode) != mGuiModes.end())
|
|
|
|
{
|
|
|
|
mGuiModes.erase(std::find(mGuiModes.begin(), mGuiModes.end(), mode));
|
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2017-09-22 19:26:41 +00:00
|
|
|
if (!mGuiModes.empty())
|
2017-09-23 11:49:09 +00:00
|
|
|
{
|
|
|
|
mKeyboardNavigation->saveFocus(mGuiModes.back());
|
2017-09-22 19:26:41 +00:00
|
|
|
mGuiModeStates[mGuiModes.back()].update(false);
|
2017-09-23 11:49:09 +00:00
|
|
|
}
|
2017-09-22 19:26:41 +00:00
|
|
|
mGuiModes.push_back(mode);
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2017-09-22 19:26:41 +00:00
|
|
|
mGuiModeStates[mode].update(true);
|
2017-09-22 22:00:40 +00:00
|
|
|
playSound(mGuiModeStates[mode].mOpenSound);
|
2017-09-22 19:26:41 +00:00
|
|
|
}
|
2019-05-14 10:20:27 +00:00
|
|
|
for (WindowBase* window : mGuiModeStates[mode].mWindows)
|
|
|
|
window->setPtr(arg);
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2017-09-23 11:49:09 +00:00
|
|
|
mKeyboardNavigation->restoreFocus(mode);
|
2012-11-08 18:34:54 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
updateVisible();
|
2012-12-23 19:23:24 +00:00
|
|
|
}
|
2012-05-24 09:50:48 +00:00
|
|
|
|
2017-09-22 22:00:40 +00:00
|
|
|
void WindowManager::popGuiMode(bool noSound)
|
2013-01-11 12:27:59 +00:00
|
|
|
{
|
2017-09-22 21:25:20 +00:00
|
|
|
if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
{
|
|
|
|
mDragAndDrop->finish();
|
|
|
|
}
|
2013-01-11 12:27:59 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
if (!mGuiModes.empty())
|
2017-09-22 18:46:08 +00:00
|
|
|
{
|
2017-09-23 10:18:39 +00:00
|
|
|
const GuiMode mode = mGuiModes.back();
|
2017-09-23 11:49:09 +00:00
|
|
|
mKeyboardNavigation->saveFocus(mode);
|
2013-04-17 22:56:48 +00:00
|
|
|
mGuiModes.pop_back();
|
2017-09-23 10:18:39 +00:00
|
|
|
mGuiModeStates[mode].update(false);
|
|
|
|
if (!noSound)
|
|
|
|
playSound(mGuiModeStates[mode].mCloseSound);
|
2017-09-22 18:46:08 +00:00
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
if (!mGuiModes.empty())
|
2017-09-23 11:49:09 +00:00
|
|
|
{
|
|
|
|
const GuiMode mode = mGuiModes.back();
|
|
|
|
mGuiModeStates[mode].update(true);
|
|
|
|
mKeyboardNavigation->restoreFocus(mode);
|
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
updateVisible();
|
2019-05-16 06:28:56 +00:00
|
|
|
|
|
|
|
// To make sure that console window get focus again
|
|
|
|
if (mConsole && mConsole->isVisible())
|
|
|
|
mConsole->onOpen();
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-05-28 07:19:25 +00:00
|
|
|
|
2017-09-22 22:00:40 +00:00
|
|
|
void WindowManager::removeGuiMode(GuiMode mode, bool noSound)
|
2012-05-28 07:19:25 +00:00
|
|
|
{
|
2017-09-22 18:46:08 +00:00
|
|
|
if (!mGuiModes.empty() && mGuiModes.back() == mode)
|
|
|
|
{
|
2017-09-22 22:00:40 +00:00
|
|
|
popGuiMode(noSound);
|
2017-09-22 18:46:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
std::vector<GuiMode>::iterator it = mGuiModes.begin();
|
|
|
|
while (it != mGuiModes.end())
|
2012-05-28 07:19:25 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
if (*it == mode)
|
|
|
|
it = mGuiModes.erase(it);
|
|
|
|
else
|
|
|
|
++it;
|
2012-05-28 07:19:25 +00:00
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
updateVisible();
|
2012-05-26 23:14:33 +00:00
|
|
|
}
|
2012-11-08 18:34:54 +00:00
|
|
|
|
2015-02-07 03:05:28 +00:00
|
|
|
void WindowManager::goToJail(int days)
|
|
|
|
{
|
|
|
|
pushGuiMode(MWGui::GM_Jail);
|
|
|
|
mJailScreen->goToJail(days);
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent)
|
2012-11-08 18:34:54 +00:00
|
|
|
{
|
2013-12-26 21:32:39 +00:00
|
|
|
mSelectedSpell = spellId;
|
2017-02-14 23:55:35 +00:00
|
|
|
mSelectedEnchantItem = MWWorld::Ptr();
|
2013-04-17 22:56:48 +00:00
|
|
|
mHud->setSelectedSpell(spellId, successChancePercent);
|
2012-05-29 16:33:01 +00:00
|
|
|
|
2015-12-09 00:06:53 +00:00
|
|
|
const ESM::Spell* spell = mStore->get<ESM::Spell>().find(spellId);
|
2012-11-06 07:29:18 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mSpellWindow->setTitle(spell->mName);
|
2012-11-08 18:34:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item)
|
|
|
|
{
|
2017-02-14 23:55:35 +00:00
|
|
|
mSelectedEnchantItem = item;
|
2013-12-26 21:32:39 +00:00
|
|
|
mSelectedSpell = "";
|
2015-12-09 00:06:53 +00:00
|
|
|
const ESM::Enchantment* ench = mStore->get<ESM::Enchantment>()
|
2014-05-22 18:37:22 +00:00
|
|
|
.find(item.getClass().getEnchantment(item));
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2018-10-25 13:09:07 +00:00
|
|
|
int chargePercent = static_cast<int>(item.getCellRef().getNormalizedEnchantmentCharge(ench->mData.mCharge) * 100);
|
2013-04-17 22:56:48 +00:00
|
|
|
mHud->setSelectedEnchantItem(item, chargePercent);
|
2014-05-22 18:37:22 +00:00
|
|
|
mSpellWindow->setTitle(item.getClass().getName(item));
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2017-02-14 23:55:35 +00:00
|
|
|
const MWWorld::Ptr &WindowManager::getSelectedEnchantItem() const
|
|
|
|
{
|
|
|
|
return mSelectedEnchantItem;
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
|
|
|
|
{
|
2017-02-14 23:55:35 +00:00
|
|
|
mSelectedWeapon = item;
|
2018-09-22 02:51:56 +00:00
|
|
|
int durabilityPercent = 100;
|
|
|
|
if (item.getClass().hasItemHealth(item))
|
|
|
|
{
|
2018-10-26 09:53:15 +00:00
|
|
|
durabilityPercent = static_cast<int>(item.getClass().getItemNormalizedHealth(item) * 100);
|
2018-09-22 02:51:56 +00:00
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
mHud->setSelectedWeapon(item, durabilityPercent);
|
2014-05-22 18:37:22 +00:00
|
|
|
mInventoryWindow->setTitle(item.getClass().getName(item));
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2017-02-14 23:55:35 +00:00
|
|
|
const MWWorld::Ptr &WindowManager::getSelectedWeapon() const
|
|
|
|
{
|
|
|
|
return mSelectedWeapon;
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::unsetSelectedSpell()
|
|
|
|
{
|
2013-12-26 21:32:39 +00:00
|
|
|
mSelectedSpell = "";
|
2017-02-14 23:55:35 +00:00
|
|
|
mSelectedEnchantItem = MWWorld::Ptr();
|
2013-04-17 22:56:48 +00:00
|
|
|
mHud->unsetSelectedSpell();
|
2014-02-11 15:34:51 +00:00
|
|
|
|
|
|
|
MWWorld::Player* player = &MWBase::Environment::get().getWorld()->getPlayer();
|
|
|
|
if (player->getDrawState() == MWMechanics::DrawState_Spell)
|
|
|
|
player->setDrawState(MWMechanics::DrawState_Nothing);
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mSpellWindow->setTitle("#{sNone}");
|
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::unsetSelectedWeapon()
|
|
|
|
{
|
2017-02-14 23:55:35 +00:00
|
|
|
mSelectedWeapon = MWWorld::Ptr();
|
2013-04-17 22:56:48 +00:00
|
|
|
mHud->unsetSelectedWeapon();
|
|
|
|
mInventoryWindow->setTitle("#{sSkillHandtohand}");
|
|
|
|
}
|
2012-05-23 10:23:35 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::getMousePosition(int &x, int &y)
|
|
|
|
{
|
|
|
|
const MyGUI::IntPoint& pos = MyGUI::InputManager::getInstance().getMousePosition();
|
|
|
|
x = pos.left;
|
|
|
|
y = pos.top;
|
|
|
|
}
|
2012-05-26 23:14:33 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::getMousePosition(float &x, float &y)
|
2012-05-26 23:14:33 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
const MyGUI::IntPoint& pos = MyGUI::InputManager::getInstance().getMousePosition();
|
2015-03-08 00:07:29 +00:00
|
|
|
x = static_cast<float>(pos.left);
|
|
|
|
y = static_cast<float>(pos.top);
|
2013-04-17 22:56:48 +00:00
|
|
|
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
x /= viewSize.width;
|
|
|
|
y /= viewSize.height;
|
2012-05-26 23:14:33 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::getWorldMouseOver()
|
|
|
|
{
|
|
|
|
return mHud->getWorldMouseOver();
|
|
|
|
}
|
2012-06-19 15:07:00 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::executeInConsole (const std::string& path)
|
|
|
|
{
|
2015-04-24 19:55:30 +00:00
|
|
|
mConsole->executeFile (path);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-05-29 16:33:01 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
MWGui::InventoryWindow* WindowManager::getInventoryWindow() { return mInventoryWindow; }
|
|
|
|
MWGui::CountDialog* WindowManager::getCountDialog() { return mCountDialog; }
|
|
|
|
MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; }
|
|
|
|
MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; }
|
|
|
|
|
2018-07-09 15:31:40 +00:00
|
|
|
void WindowManager::useItem(const MWWorld::Ptr &item, bool bypassBeastRestrictions)
|
2015-09-07 19:32:28 +00:00
|
|
|
{
|
|
|
|
if (mInventoryWindow)
|
2018-07-09 15:31:40 +00:00
|
|
|
mInventoryWindow->useItem(item, bypassBeastRestrictions);
|
2015-09-07 19:32:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::isAllowed (GuiWindow wnd) const
|
|
|
|
{
|
2015-03-06 10:19:57 +00:00
|
|
|
return (mAllowed & wnd) != 0;
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-11-06 07:29:18 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::allow (GuiWindow wnd)
|
|
|
|
{
|
|
|
|
mAllowed = (GuiWindow)(mAllowed | wnd);
|
2012-05-29 16:33:01 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
if (wnd & GW_Inventory)
|
|
|
|
{
|
|
|
|
mBookWindow->setInventoryAllowed (true);
|
|
|
|
mScrollWindow->setInventoryAllowed (true);
|
|
|
|
}
|
2012-05-29 16:33:01 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
updateVisible();
|
2013-02-17 14:56:22 +00:00
|
|
|
}
|
2012-05-29 16:33:01 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::disallowAll()
|
|
|
|
{
|
|
|
|
mAllowed = GW_None;
|
2017-09-23 21:09:41 +00:00
|
|
|
mRestAllowed = false;
|
2012-05-29 16:33:01 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mBookWindow->setInventoryAllowed (false);
|
|
|
|
mScrollWindow->setInventoryAllowed (false);
|
2012-06-02 10:25:24 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
updateVisible();
|
|
|
|
}
|
2012-06-02 10:25:24 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::toggleVisible (GuiWindow wnd)
|
|
|
|
{
|
2013-08-07 21:30:08 +00:00
|
|
|
if (getMode() != GM_Inventory)
|
|
|
|
return;
|
|
|
|
|
2019-04-25 16:55:55 +00:00
|
|
|
std::string settingName;
|
|
|
|
switch (wnd)
|
|
|
|
{
|
|
|
|
case GW_Inventory:
|
|
|
|
settingName = "inventory";
|
|
|
|
break;
|
|
|
|
case GW_Map:
|
|
|
|
settingName = "map";
|
|
|
|
break;
|
|
|
|
case GW_Magic:
|
|
|
|
settingName = "spells";
|
|
|
|
break;
|
|
|
|
case GW_Stats:
|
|
|
|
settingName = "stats";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!settingName.empty())
|
|
|
|
{
|
|
|
|
settingName += " hidden";
|
|
|
|
bool hidden = Settings::Manager::getBool(settingName, "Windows");
|
|
|
|
Settings::Manager::setBool(settingName, "Windows", !hidden);
|
|
|
|
}
|
|
|
|
|
2013-08-05 21:15:26 +00:00
|
|
|
mShown = (GuiWindow)(mShown ^ wnd);
|
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::forceHide(GuiWindow wnd)
|
|
|
|
{
|
|
|
|
mForceHidden = (GuiWindow)(mForceHidden | wnd);
|
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::unsetForceHide(GuiWindow wnd)
|
|
|
|
{
|
|
|
|
mForceHidden = (GuiWindow)(mForceHidden & ~wnd);
|
2013-04-17 22:56:48 +00:00
|
|
|
updateVisible();
|
|
|
|
}
|
2012-06-02 10:25:24 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::isGuiMode() const
|
|
|
|
{
|
2019-05-16 06:28:56 +00:00
|
|
|
return
|
|
|
|
!mGuiModes.empty() ||
|
|
|
|
isConsoleMode() ||
|
|
|
|
(mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox());
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-07-30 10:37:46 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::isConsoleMode() const
|
|
|
|
{
|
2019-05-16 06:28:56 +00:00
|
|
|
return mConsole && mConsole->isVisible();
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
MWGui::GuiMode WindowManager::getMode() const
|
|
|
|
{
|
|
|
|
if (mGuiModes.empty())
|
|
|
|
return GM_None;
|
|
|
|
return mGuiModes.back();
|
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::disallowMouse()
|
|
|
|
{
|
|
|
|
mInputBlocker->setVisible (true);
|
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::allowMouse()
|
|
|
|
{
|
|
|
|
mInputBlocker->setVisible (!isGuiMode ());
|
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::notifyInputActionBound ()
|
|
|
|
{
|
|
|
|
mSettingsWindow->updateControlsBox ();
|
|
|
|
allowMouse();
|
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2013-06-12 10:34:33 +00:00
|
|
|
bool WindowManager::containsMode(GuiMode mode) const
|
|
|
|
{
|
|
|
|
if(mGuiModes.empty())
|
|
|
|
return false;
|
2013-01-09 10:09:47 +00:00
|
|
|
|
2013-06-12 10:34:33 +00:00
|
|
|
return std::find(mGuiModes.begin(), mGuiModes.end(), mode) != mGuiModes.end();
|
|
|
|
}
|
2013-01-09 10:09:47 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::showCrosshair (bool show)
|
|
|
|
{
|
2013-08-27 13:48:13 +00:00
|
|
|
if (mHud)
|
|
|
|
mHud->setCrosshairVisible (show && mCrosshairEnabled);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2017-08-18 15:24:34 +00:00
|
|
|
void WindowManager::updateActivatedQuickKey ()
|
|
|
|
{
|
|
|
|
mQuickKeysMenu->updateActivatedQuickKey();
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::activateQuickKey (int index)
|
|
|
|
{
|
|
|
|
mQuickKeysMenu->activateQuickKey(index);
|
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::getSubtitlesEnabled ()
|
|
|
|
{
|
|
|
|
return mSubtitlesEnabled;
|
|
|
|
}
|
2012-08-12 09:10:17 +00:00
|
|
|
|
2017-09-23 10:58:28 +00:00
|
|
|
bool WindowManager::toggleHud()
|
2014-06-20 16:49:19 +00:00
|
|
|
{
|
2017-09-23 10:58:28 +00:00
|
|
|
mHudEnabled = !mHudEnabled;
|
2014-06-20 16:49:19 +00:00
|
|
|
updateVisible();
|
2017-09-23 10:58:28 +00:00
|
|
|
return mHudEnabled;
|
2014-06-20 16:49:19 +00:00
|
|
|
}
|
|
|
|
|
2013-04-29 15:19:20 +00:00
|
|
|
bool WindowManager::getRestEnabled()
|
|
|
|
{
|
|
|
|
//Enable rest dialogue if character creation finished
|
2013-11-28 08:10:38 +00:00
|
|
|
if(mRestAllowed==false && MWBase::Environment::get().getWorld()->getGlobalFloat ("chargenstate")==-1)
|
2013-04-29 15:19:20 +00:00
|
|
|
mRestAllowed=true;
|
|
|
|
return mRestAllowed;
|
|
|
|
}
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
bool WindowManager::getPlayerSleeping ()
|
|
|
|
{
|
|
|
|
return mWaitDialog->getSleeping();
|
|
|
|
}
|
2012-08-27 17:18:55 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::wakeUpPlayer()
|
|
|
|
{
|
|
|
|
mWaitDialog->wakeUp();
|
|
|
|
}
|
2012-08-28 07:06:40 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::addVisitedLocation(const std::string& name, int x, int y)
|
|
|
|
{
|
|
|
|
mMap->addVisitedLocation (name, x, y);
|
|
|
|
}
|
2012-08-28 07:06:40 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
const Translation::Storage& WindowManager::getTranslationDataStorage() const
|
|
|
|
{
|
|
|
|
return mTranslationDataStorage;
|
|
|
|
}
|
2012-09-29 07:41:34 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::changePointer(const std::string &name)
|
|
|
|
{
|
2013-11-27 17:45:46 +00:00
|
|
|
MyGUI::PointerManager::getInstance().setPointer(name);
|
2013-06-12 10:34:33 +00:00
|
|
|
onCursorChange(name);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-09-27 06:47:47 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void WindowManager::showSoulgemDialog(MWWorld::Ptr item)
|
|
|
|
{
|
|
|
|
mSoulgemDialog->show(item);
|
2015-01-08 02:29:13 +00:00
|
|
|
updateVisible();
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-10-17 16:03:02 +00:00
|
|
|
|
2013-05-15 15:54:18 +00:00
|
|
|
void WindowManager::updatePlayer()
|
|
|
|
{
|
2015-04-24 19:55:30 +00:00
|
|
|
mInventoryWindow->updatePlayer();
|
2014-09-06 01:13:35 +00:00
|
|
|
|
2015-08-21 09:12:39 +00:00
|
|
|
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
2014-09-06 01:13:35 +00:00
|
|
|
if (player.getClass().getNpcStats(player).isWerewolf())
|
2014-10-05 15:53:50 +00:00
|
|
|
{
|
|
|
|
setWerewolfOverlay(true);
|
2014-09-06 01:13:35 +00:00
|
|
|
forceHide((GuiWindow)(MWGui::GW_Inventory | MWGui::GW_Magic));
|
2014-10-05 15:53:50 +00:00
|
|
|
}
|
2013-05-15 15:54:18 +00:00
|
|
|
}
|
2012-12-31 00:15:47 +00:00
|
|
|
|
2019-06-08 23:08:09 +00:00
|
|
|
// Remove this wrapper once onKeyFocusChanged call is rendered unnecessary
|
|
|
|
void WindowManager::setKeyFocusWidget(MyGUI::Widget *widget)
|
|
|
|
{
|
|
|
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(widget);
|
|
|
|
onKeyFocusChanged(widget);
|
|
|
|
}
|
|
|
|
|
2013-06-16 16:06:55 +00:00
|
|
|
void WindowManager::onKeyFocusChanged(MyGUI::Widget *widget)
|
|
|
|
{
|
|
|
|
if (widget && widget->castType<MyGUI::EditBox>(false))
|
|
|
|
SDL_StartTextInput();
|
|
|
|
else
|
|
|
|
SDL_StopTextInput();
|
|
|
|
}
|
|
|
|
|
2013-07-30 04:00:20 +00:00
|
|
|
void WindowManager::setEnemy(const MWWorld::Ptr &enemy)
|
|
|
|
{
|
|
|
|
mHud->setEnemy(enemy);
|
|
|
|
}
|
|
|
|
|
2018-10-28 07:44:14 +00:00
|
|
|
int WindowManager::getMessagesCount() const
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
if (mMessageBoxManager)
|
|
|
|
count = mMessageBoxManager->getMessagesCount();
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
Loading::Listener* WindowManager::getLoadingScreen()
|
|
|
|
{
|
2015-05-03 14:58:05 +00:00
|
|
|
return mLoadingScreen;
|
2013-08-27 13:48:13 +00:00
|
|
|
}
|
|
|
|
|
2013-11-20 15:05:24 +00:00
|
|
|
bool WindowManager::getCursorVisible()
|
|
|
|
{
|
2017-09-26 15:44:35 +00:00
|
|
|
return mCursorVisible && mCursorActive;
|
2013-11-20 15:05:24 +00:00
|
|
|
}
|
|
|
|
|
2015-05-01 00:09:57 +00:00
|
|
|
void WindowManager::trackWindow(Layout *layout, const std::string &name)
|
2013-12-03 17:42:35 +00:00
|
|
|
{
|
2019-04-26 07:37:57 +00:00
|
|
|
std::string settingName = name;
|
2013-12-03 17:42:35 +00:00
|
|
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
2019-04-26 07:37:57 +00:00
|
|
|
bool isMaximized = Settings::Manager::getBool(name + " maximized", "Windows");
|
|
|
|
if (isMaximized)
|
|
|
|
settingName += " maximized";
|
|
|
|
|
|
|
|
MyGUI::IntPoint pos(static_cast<int>(Settings::Manager::getFloat(settingName + " x", "Windows") * viewSize.width),
|
|
|
|
static_cast<int>(Settings::Manager::getFloat(settingName + " y", "Windows") * viewSize.height));
|
|
|
|
MyGUI::IntSize size (static_cast<int>(Settings::Manager::getFloat(settingName + " w", "Windows") * viewSize.width),
|
|
|
|
static_cast<int>(Settings::Manager::getFloat(settingName + " h", "Windows") * viewSize.height));
|
2013-12-03 17:42:35 +00:00
|
|
|
layout->mMainWidget->setPosition(pos);
|
|
|
|
layout->mMainWidget->setSize(size);
|
|
|
|
|
2016-03-05 19:00:51 +00:00
|
|
|
MyGUI::Window* window = layout->mMainWidget->castType<MyGUI::Window>();
|
2013-12-03 17:42:35 +00:00
|
|
|
window->eventWindowChangeCoord += MyGUI::newDelegate(this, &WindowManager::onWindowChangeCoord);
|
|
|
|
mTrackedWindows[window] = name;
|
|
|
|
}
|
|
|
|
|
2019-04-26 07:37:57 +00:00
|
|
|
void WindowManager::toggleMaximized(Layout *layout)
|
|
|
|
{
|
|
|
|
MyGUI::Window* window = layout->mMainWidget->castType<MyGUI::Window>();
|
|
|
|
std::string setting = mTrackedWindows[window];
|
|
|
|
if (setting.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool maximized = !Settings::Manager::getBool(setting + " maximized", "Windows");
|
|
|
|
if (maximized)
|
|
|
|
setting += " maximized";
|
|
|
|
|
|
|
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
float x = Settings::Manager::getFloat(setting + " x", "Windows") * float(viewSize.width);
|
|
|
|
float y = Settings::Manager::getFloat(setting + " y", "Windows") * float(viewSize.height);
|
|
|
|
float w = Settings::Manager::getFloat(setting + " w", "Windows") * float(viewSize.width);
|
|
|
|
float h = Settings::Manager::getFloat(setting + " h", "Windows") * float(viewSize.height);
|
|
|
|
window->setCoord(x, y, w, h);
|
|
|
|
Settings::Manager::setBool(mTrackedWindows[window] + " maximized", "Windows", maximized);
|
|
|
|
}
|
|
|
|
|
2013-12-03 17:42:35 +00:00
|
|
|
void WindowManager::onWindowChangeCoord(MyGUI::Window *_sender)
|
|
|
|
{
|
|
|
|
std::string setting = mTrackedWindows[_sender];
|
|
|
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
float x = _sender->getPosition().left / float(viewSize.width);
|
|
|
|
float y = _sender->getPosition().top / float(viewSize.height);
|
|
|
|
float w = _sender->getSize().width / float(viewSize.width);
|
|
|
|
float h = _sender->getSize().height / float(viewSize.height);
|
|
|
|
Settings::Manager::setFloat(setting + " x", "Windows", x);
|
|
|
|
Settings::Manager::setFloat(setting + " y", "Windows", y);
|
|
|
|
Settings::Manager::setFloat(setting + " w", "Windows", w);
|
|
|
|
Settings::Manager::setFloat(setting + " h", "Windows", h);
|
2019-04-26 07:37:57 +00:00
|
|
|
bool maximized = Settings::Manager::getBool(setting + " maximized", "Windows");
|
|
|
|
if (maximized)
|
|
|
|
Settings::Manager::setBool(setting + " maximized", "Windows", false);
|
2013-12-03 17:42:35 +00:00
|
|
|
}
|
|
|
|
|
2014-01-25 12:34:56 +00:00
|
|
|
void WindowManager::clear()
|
|
|
|
{
|
2019-09-05 16:16:03 +00:00
|
|
|
mPlayerBounty = -1;
|
|
|
|
|
2017-09-23 20:16:56 +00:00
|
|
|
for (WindowBase* window : mWindows)
|
|
|
|
window->clear();
|
|
|
|
|
2015-06-01 19:41:13 +00:00
|
|
|
if (mLocalMapRender)
|
|
|
|
mLocalMapRender->clear();
|
|
|
|
|
2014-06-14 19:52:54 +00:00
|
|
|
mMessageBoxManager->clear();
|
2014-05-02 09:20:43 +00:00
|
|
|
|
2018-11-13 06:00:12 +00:00
|
|
|
mToolTips->clear();
|
2017-04-12 18:57:32 +00:00
|
|
|
|
2014-07-20 11:07:47 +00:00
|
|
|
mSelectedSpell.clear();
|
2014-08-17 03:45:35 +00:00
|
|
|
mCustomMarkers.clear();
|
|
|
|
|
2014-09-06 01:13:35 +00:00
|
|
|
mForceHidden = GW_None;
|
2017-09-23 21:09:41 +00:00
|
|
|
mRestAllowed = true;
|
2014-09-06 01:13:35 +00:00
|
|
|
|
2017-09-23 20:16:56 +00:00
|
|
|
while (!mGuiModes.empty())
|
|
|
|
popGuiMode();
|
2014-10-06 18:24:53 +00:00
|
|
|
|
2014-05-02 09:20:43 +00:00
|
|
|
updateVisible();
|
2014-01-25 12:34:56 +00:00
|
|
|
}
|
|
|
|
|
2014-04-28 09:29:57 +00:00
|
|
|
void WindowManager::write(ESM::ESMWriter &writer, Loading::Listener& progress)
|
2014-01-25 17:20:17 +00:00
|
|
|
{
|
2014-04-28 09:29:57 +00:00
|
|
|
mMap->write(writer, progress);
|
2014-05-01 19:16:32 +00:00
|
|
|
|
|
|
|
mQuickKeysMenu->write(writer);
|
2014-05-12 19:04:02 +00:00
|
|
|
|
|
|
|
if (!mSelectedSpell.empty())
|
|
|
|
{
|
|
|
|
writer.startRecord(ESM::REC_ASPL);
|
|
|
|
writer.writeHNString("ID__", mSelectedSpell);
|
|
|
|
writer.endRecord(ESM::REC_ASPL);
|
|
|
|
}
|
2014-08-17 03:45:35 +00:00
|
|
|
|
2015-07-17 18:49:10 +00:00
|
|
|
for (CustomMarkerCollection::ContainerType::const_iterator it = mCustomMarkers.begin(); it != mCustomMarkers.end(); ++it)
|
2014-08-17 03:45:35 +00:00
|
|
|
{
|
|
|
|
writer.startRecord(ESM::REC_MARK);
|
2015-07-17 18:49:10 +00:00
|
|
|
it->second.save(writer);
|
2014-08-17 03:45:35 +00:00
|
|
|
writer.endRecord(ESM::REC_MARK);
|
|
|
|
}
|
2014-01-25 17:20:17 +00:00
|
|
|
}
|
|
|
|
|
2015-01-22 18:04:59 +00:00
|
|
|
void WindowManager::readRecord(ESM::ESMReader &reader, uint32_t type)
|
2014-01-25 17:20:17 +00:00
|
|
|
{
|
2014-05-01 19:16:32 +00:00
|
|
|
if (type == ESM::REC_GMAP)
|
|
|
|
mMap->readRecord(reader, type);
|
|
|
|
else if (type == ESM::REC_KEYS)
|
|
|
|
mQuickKeysMenu->readRecord(reader, type);
|
2014-05-12 19:04:02 +00:00
|
|
|
else if (type == ESM::REC_ASPL)
|
|
|
|
{
|
|
|
|
reader.getSubNameIs("ID__");
|
2015-08-21 12:24:34 +00:00
|
|
|
std::string spell = reader.getHString();
|
2015-12-09 00:06:53 +00:00
|
|
|
if (mStore->get<ESM::Spell>().search(spell))
|
2015-08-21 12:24:34 +00:00
|
|
|
mSelectedSpell = spell;
|
2014-05-12 19:04:02 +00:00
|
|
|
}
|
2014-08-17 03:45:35 +00:00
|
|
|
else if (type == ESM::REC_MARK)
|
|
|
|
{
|
2015-01-18 23:35:19 +00:00
|
|
|
ESM::CustomMarker marker;
|
2014-08-17 03:45:35 +00:00
|
|
|
marker.load(reader);
|
|
|
|
mCustomMarkers.addMarker(marker, false);
|
|
|
|
}
|
2014-05-01 19:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int WindowManager::countSavedGameRecords() const
|
|
|
|
{
|
|
|
|
return 1 // Global map
|
2014-05-12 19:04:02 +00:00
|
|
|
+ 1 // QuickKeysMenu
|
2014-08-17 03:45:35 +00:00
|
|
|
+ mCustomMarkers.size()
|
2014-05-12 19:04:02 +00:00
|
|
|
+ (!mSelectedSpell.empty() ? 1 : 0);
|
2014-01-25 17:20:17 +00:00
|
|
|
}
|
2014-05-02 09:20:43 +00:00
|
|
|
|
|
|
|
bool WindowManager::isSavingAllowed() const
|
|
|
|
{
|
|
|
|
return !MyGUI::InputManager::getInstance().isModalAny()
|
2019-05-16 06:28:56 +00:00
|
|
|
&& !isConsoleMode()
|
2014-05-02 09:20:43 +00:00
|
|
|
// TODO: remove this, once we have properly serialized the state of open windows
|
2017-09-23 13:06:11 +00:00
|
|
|
&& (!isGuiMode() || (mGuiModes.size() == 1 && (getMode() == GM_MainMenu || getMode() == GM_Rest)));
|
2014-05-02 09:20:43 +00:00
|
|
|
}
|
2014-01-25 17:20:17 +00:00
|
|
|
|
2014-03-27 18:10:15 +00:00
|
|
|
void WindowManager::playVideo(const std::string &name, bool allowSkipping)
|
|
|
|
{
|
2014-06-09 23:57:54 +00:00
|
|
|
mVideoWidget->playVideo("video\\" + name);
|
|
|
|
|
|
|
|
mVideoWidget->eventKeyButtonPressed.clear();
|
|
|
|
mVideoBackground->eventKeyButtonPressed.clear();
|
|
|
|
if (allowSkipping)
|
|
|
|
{
|
|
|
|
mVideoWidget->eventKeyButtonPressed += MyGUI::newDelegate(this, &WindowManager::onVideoKeyPressed);
|
|
|
|
mVideoBackground->eventKeyButtonPressed += MyGUI::newDelegate(this, &WindowManager::onVideoKeyPressed);
|
|
|
|
}
|
2014-03-27 18:10:15 +00:00
|
|
|
|
2019-06-21 13:37:00 +00:00
|
|
|
enableScene(false);
|
2014-03-27 18:10:15 +00:00
|
|
|
|
|
|
|
MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
sizeVideo(screenSize.width, screenSize.height);
|
|
|
|
|
2015-11-12 18:03:24 +00:00
|
|
|
MyGUI::Widget* oldKeyFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
2019-06-08 23:08:09 +00:00
|
|
|
setKeyFocusWidget(mVideoWidget);
|
2014-03-27 18:10:15 +00:00
|
|
|
|
|
|
|
mVideoBackground->setVisible(true);
|
|
|
|
|
|
|
|
bool cursorWasVisible = mCursorVisible;
|
|
|
|
setCursorVisible(false);
|
|
|
|
|
2014-10-22 20:11:03 +00:00
|
|
|
if (mVideoWidget->hasAudioStream())
|
2020-04-05 14:10:05 +00:00
|
|
|
MWBase::Environment::get().getSoundManager()->pauseSounds(MWSound::VideoPlayback,
|
2017-09-15 08:03:41 +00:00
|
|
|
~MWSound::Type::Movie & MWSound::Type::Mask
|
|
|
|
);
|
2020-04-05 14:10:05 +00:00
|
|
|
|
2017-08-30 21:26:30 +00:00
|
|
|
osg::Timer frameTimer;
|
2014-06-05 13:39:08 +00:00
|
|
|
while (mVideoWidget->update() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
|
2014-03-27 18:10:15 +00:00
|
|
|
{
|
2017-08-30 21:26:30 +00:00
|
|
|
double dt = frameTimer.time_s();
|
|
|
|
frameTimer.setStartTick();
|
2014-03-27 18:10:15 +00:00
|
|
|
|
2017-08-30 21:26:30 +00:00
|
|
|
MWBase::Environment::get().getInputManager()->update(dt, true, false);
|
2014-03-27 18:10:15 +00:00
|
|
|
|
2020-04-16 13:31:20 +00:00
|
|
|
if (!mWindowVisible)
|
2020-03-31 09:15:26 +00:00
|
|
|
{
|
|
|
|
mVideoWidget->pause();
|
2017-08-30 21:26:30 +00:00
|
|
|
OpenThreads::Thread::microSleep(5000);
|
2020-03-31 09:15:26 +00:00
|
|
|
}
|
2017-08-30 21:26:30 +00:00
|
|
|
else
|
|
|
|
{
|
2020-03-31 09:15:26 +00:00
|
|
|
if (mVideoWidget->isPaused())
|
|
|
|
mVideoWidget->resume();
|
|
|
|
|
2017-08-30 21:26:30 +00:00
|
|
|
mViewer->eventTraversal();
|
|
|
|
mViewer->updateTraversal();
|
|
|
|
mViewer->renderingTraversals();
|
|
|
|
}
|
2015-11-06 21:41:32 +00:00
|
|
|
// at the time this function is called we are in the middle of a frame,
|
|
|
|
// so out of order calls are necessary to get a correct frameNumber for the next frame.
|
|
|
|
// refer to the advance() and frame() order in Engine::go()
|
|
|
|
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
2017-08-30 21:26:30 +00:00
|
|
|
|
|
|
|
MWBase::Environment::get().limitFrameRate(frameTimer.time_s());
|
2014-03-27 18:10:15 +00:00
|
|
|
}
|
2014-06-09 23:57:54 +00:00
|
|
|
mVideoWidget->stop();
|
2014-03-27 18:10:15 +00:00
|
|
|
|
2020-04-05 14:10:05 +00:00
|
|
|
MWBase::Environment::get().getSoundManager()->resumeSounds(MWSound::VideoPlayback);
|
2014-10-22 20:11:03 +00:00
|
|
|
|
2019-06-08 23:08:09 +00:00
|
|
|
setKeyFocusWidget(oldKeyFocus);
|
2015-11-12 18:03:24 +00:00
|
|
|
|
2014-03-27 18:10:15 +00:00
|
|
|
setCursorVisible(cursorWasVisible);
|
|
|
|
|
|
|
|
// Restore normal rendering
|
2019-06-21 13:37:00 +00:00
|
|
|
updateVisible();
|
2014-03-27 18:10:15 +00:00
|
|
|
|
|
|
|
mVideoBackground->setVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::sizeVideo(int screenWidth, int screenHeight)
|
|
|
|
{
|
|
|
|
// Use black bars to correct aspect ratio
|
2015-01-27 23:02:05 +00:00
|
|
|
bool stretch = Settings::Manager::getBool("stretch menu background", "GUI");
|
2014-03-27 18:10:15 +00:00
|
|
|
mVideoBackground->setSize(screenWidth, screenHeight);
|
2015-01-27 23:02:05 +00:00
|
|
|
mVideoWidget->autoResize(stretch);
|
2014-03-27 18:10:15 +00:00
|
|
|
}
|
2014-05-27 08:38:13 +00:00
|
|
|
|
2015-03-11 19:04:25 +00:00
|
|
|
void WindowManager::exitCurrentModal()
|
2014-05-27 08:38:13 +00:00
|
|
|
{
|
2015-03-11 19:04:25 +00:00
|
|
|
if (!mCurrentModals.empty())
|
2017-09-23 10:18:39 +00:00
|
|
|
{
|
2017-10-06 16:18:57 +00:00
|
|
|
WindowModal* window = mCurrentModals.back();
|
|
|
|
if (!window->exit())
|
2017-09-23 10:18:39 +00:00
|
|
|
return;
|
2017-10-06 16:18:57 +00:00
|
|
|
window->setVisible(false);
|
2017-09-23 10:18:39 +00:00
|
|
|
}
|
2017-09-22 21:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::addCurrentModal(WindowModal *input)
|
|
|
|
{
|
|
|
|
if (mCurrentModals.empty())
|
2017-09-23 11:49:09 +00:00
|
|
|
mKeyboardNavigation->saveFocus(getMode());
|
2017-09-22 21:01:34 +00:00
|
|
|
|
2017-10-04 15:03:23 +00:00
|
|
|
mCurrentModals.push_back(input);
|
2017-09-26 20:21:30 +00:00
|
|
|
mKeyboardNavigation->restoreFocus(-1);
|
|
|
|
|
|
|
|
mKeyboardNavigation->setModalWindow(input->mMainWidget);
|
|
|
|
mKeyboardNavigation->setDefaultFocus(input->mMainWidget, input->getDefaultKeyFocus());
|
2014-05-27 08:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::removeCurrentModal(WindowModal* input)
|
|
|
|
{
|
2014-09-26 15:12:48 +00:00
|
|
|
if(!mCurrentModals.empty())
|
2017-09-24 11:57:09 +00:00
|
|
|
{
|
2017-10-04 15:03:23 +00:00
|
|
|
if(input == mCurrentModals.back())
|
2017-09-26 20:21:30 +00:00
|
|
|
{
|
2017-10-04 15:03:23 +00:00
|
|
|
mCurrentModals.pop_back();
|
2017-09-26 20:21:30 +00:00
|
|
|
mKeyboardNavigation->saveFocus(-1);
|
|
|
|
}
|
2017-09-24 11:57:09 +00:00
|
|
|
else
|
2017-10-04 15:03:23 +00:00
|
|
|
{
|
|
|
|
auto found = std::find(mCurrentModals.begin(), mCurrentModals.end(), input);
|
|
|
|
if (found != mCurrentModals.end())
|
|
|
|
mCurrentModals.erase(found);
|
|
|
|
else
|
2018-08-14 19:05:43 +00:00
|
|
|
Log(Debug::Warning) << "Warning: can't find modal window " << input;
|
2017-10-04 15:03:23 +00:00
|
|
|
}
|
2017-09-24 11:57:09 +00:00
|
|
|
}
|
2017-09-22 21:01:34 +00:00
|
|
|
if (mCurrentModals.empty())
|
2017-09-26 20:21:30 +00:00
|
|
|
{
|
2018-10-09 06:21:12 +00:00
|
|
|
mKeyboardNavigation->setModalWindow(nullptr);
|
2017-09-23 11:49:09 +00:00
|
|
|
mKeyboardNavigation->restoreFocus(getMode());
|
2017-09-26 20:21:30 +00:00
|
|
|
}
|
|
|
|
else
|
2017-10-04 15:03:23 +00:00
|
|
|
mKeyboardNavigation->setModalWindow(mCurrentModals.back()->mMainWidget);
|
2014-05-27 08:38:13 +00:00
|
|
|
}
|
2014-06-09 23:57:54 +00:00
|
|
|
|
|
|
|
void WindowManager::onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
|
|
|
{
|
|
|
|
if (_key == MyGUI::KeyCode::Escape)
|
|
|
|
mVideoWidget->stop();
|
|
|
|
}
|
2014-06-10 15:47:59 +00:00
|
|
|
|
2017-04-12 18:57:32 +00:00
|
|
|
void WindowManager::updatePinnedWindows()
|
|
|
|
{
|
|
|
|
mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows"));
|
2019-04-25 16:55:55 +00:00
|
|
|
if (Settings::Manager::getBool("inventory hidden", "Windows"))
|
|
|
|
mShown = (GuiWindow)(mShown ^ GW_Inventory);
|
2017-04-12 18:57:32 +00:00
|
|
|
|
|
|
|
mMap->setPinned(Settings::Manager::getBool("map pin", "Windows"));
|
2019-04-25 16:55:55 +00:00
|
|
|
if (Settings::Manager::getBool("map hidden", "Windows"))
|
|
|
|
mShown = (GuiWindow)(mShown ^ GW_Map);
|
2017-04-12 18:57:32 +00:00
|
|
|
|
|
|
|
mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows"));
|
2019-04-25 16:55:55 +00:00
|
|
|
if (Settings::Manager::getBool("spells hidden", "Windows"))
|
|
|
|
mShown = (GuiWindow)(mShown ^ GW_Magic);
|
2017-04-12 18:57:32 +00:00
|
|
|
|
|
|
|
mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows"));
|
2019-04-25 16:55:55 +00:00
|
|
|
if (Settings::Manager::getBool("stats hidden", "Windows"))
|
|
|
|
mShown = (GuiWindow)(mShown ^ GW_Stats);
|
2017-04-12 18:57:32 +00:00
|
|
|
}
|
|
|
|
|
2014-06-10 15:47:59 +00:00
|
|
|
void WindowManager::pinWindow(GuiWindow window)
|
|
|
|
{
|
|
|
|
switch (window)
|
|
|
|
{
|
|
|
|
case GW_Inventory:
|
|
|
|
mInventoryWindow->setPinned(true);
|
|
|
|
break;
|
|
|
|
case GW_Map:
|
|
|
|
mMap->setPinned(true);
|
|
|
|
break;
|
|
|
|
case GW_Magic:
|
|
|
|
mSpellWindow->setPinned(true);
|
|
|
|
break;
|
|
|
|
case GW_Stats:
|
|
|
|
mStatsWindow->setPinned(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateVisible();
|
|
|
|
}
|
2014-08-01 14:25:41 +00:00
|
|
|
|
2017-09-24 17:15:39 +00:00
|
|
|
void WindowManager::fadeScreenIn(const float time, bool clearQueue, float delay)
|
2014-08-01 14:25:41 +00:00
|
|
|
{
|
2014-12-01 18:13:04 +00:00
|
|
|
if (clearQueue)
|
|
|
|
mScreenFader->clearQueue();
|
2017-09-24 17:15:39 +00:00
|
|
|
mScreenFader->fadeOut(time, delay);
|
2014-08-01 14:25:41 +00:00
|
|
|
}
|
|
|
|
|
2017-09-24 17:15:39 +00:00
|
|
|
void WindowManager::fadeScreenOut(const float time, bool clearQueue, float delay)
|
2014-08-01 14:25:41 +00:00
|
|
|
{
|
2014-12-01 18:13:04 +00:00
|
|
|
if (clearQueue)
|
|
|
|
mScreenFader->clearQueue();
|
2017-09-24 17:15:39 +00:00
|
|
|
mScreenFader->fadeIn(time, delay);
|
2014-08-01 14:25:41 +00:00
|
|
|
}
|
|
|
|
|
2017-09-24 17:15:39 +00:00
|
|
|
void WindowManager::fadeScreenTo(const int percent, const float time, bool clearQueue, float delay)
|
2014-08-01 14:25:41 +00:00
|
|
|
{
|
2014-12-01 18:13:04 +00:00
|
|
|
if (clearQueue)
|
|
|
|
mScreenFader->clearQueue();
|
2017-09-24 17:15:39 +00:00
|
|
|
mScreenFader->fadeTo(percent, time, delay);
|
2014-08-01 14:25:41 +00:00
|
|
|
}
|
|
|
|
|
2014-10-12 17:06:40 +00:00
|
|
|
void WindowManager::setBlindness(const int percent)
|
2014-08-01 14:25:41 +00:00
|
|
|
{
|
2014-10-12 17:06:40 +00:00
|
|
|
mBlindnessFader->notifyAlphaChanged(percent / 100.f);
|
2014-08-01 14:25:41 +00:00
|
|
|
}
|
2014-08-25 16:00:53 +00:00
|
|
|
|
2014-10-11 20:21:48 +00:00
|
|
|
void WindowManager::activateHitOverlay(bool interrupt)
|
2014-10-05 15:53:50 +00:00
|
|
|
{
|
|
|
|
if (!mHitFaderEnabled)
|
|
|
|
return;
|
|
|
|
|
2014-10-11 20:21:48 +00:00
|
|
|
if (!interrupt && !mHitFader->isEmpty())
|
|
|
|
return;
|
|
|
|
|
2014-10-05 15:53:50 +00:00
|
|
|
mHitFader->clearQueue();
|
2014-10-11 20:21:48 +00:00
|
|
|
mHitFader->fadeTo(100, 0.0f);
|
|
|
|
mHitFader->fadeTo(0, 0.5f);
|
2014-10-05 15:53:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::setWerewolfOverlay(bool set)
|
|
|
|
{
|
2014-10-05 17:53:36 +00:00
|
|
|
if (!mWerewolfOverlayEnabled)
|
2014-10-05 15:53:50 +00:00
|
|
|
return;
|
|
|
|
|
2015-12-07 13:41:33 +00:00
|
|
|
if (mWerewolfFader)
|
|
|
|
mWerewolfFader->notifyAlphaChanged(set ? 1.0f : 0.0f);
|
2014-10-05 15:53:50 +00:00
|
|
|
}
|
|
|
|
|
2014-08-25 16:00:53 +00:00
|
|
|
void WindowManager::onClipboardChanged(const std::string &_type, const std::string &_data)
|
|
|
|
{
|
|
|
|
if (_type == "Text")
|
|
|
|
SDL_SetClipboardText(MyGUI::TextIterator::getOnlyText(MyGUI::UString(_data)).asUTF8().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::onClipboardRequested(const std::string &_type, std::string &_data)
|
|
|
|
{
|
|
|
|
if (_type != "Text")
|
|
|
|
return;
|
|
|
|
char* text=0;
|
|
|
|
text = SDL_GetClipboardText();
|
|
|
|
if (text)
|
2017-08-19 10:30:04 +00:00
|
|
|
_data = MyGUI::TextIterator::toTagsString(text);
|
|
|
|
|
2014-08-25 16:00:53 +00:00
|
|
|
SDL_free(text);
|
|
|
|
}
|
|
|
|
|
2019-05-16 06:28:56 +00:00
|
|
|
void WindowManager::toggleConsole()
|
|
|
|
{
|
|
|
|
bool visible = mConsole->isVisible();
|
|
|
|
|
|
|
|
if (!visible && !mGuiModes.empty())
|
|
|
|
mKeyboardNavigation->saveFocus(mGuiModes.back());
|
|
|
|
|
|
|
|
mConsole->setVisible(!visible);
|
|
|
|
|
|
|
|
if (visible && !mGuiModes.empty())
|
|
|
|
mKeyboardNavigation->restoreFocus(mGuiModes.back());
|
|
|
|
|
|
|
|
updateVisible();
|
|
|
|
}
|
|
|
|
|
2014-09-28 15:57:14 +00:00
|
|
|
void WindowManager::toggleDebugWindow()
|
|
|
|
{
|
2020-05-15 08:38:22 +00:00
|
|
|
#ifndef BT_NO_PROFILE
|
2014-09-28 15:57:14 +00:00
|
|
|
mDebugWindow->setVisible(!mDebugWindow->isVisible());
|
2020-05-15 08:38:22 +00:00
|
|
|
#endif
|
2014-09-28 15:57:14 +00:00
|
|
|
}
|
|
|
|
|
2014-12-15 14:23:03 +00:00
|
|
|
void WindowManager::cycleSpell(bool next)
|
|
|
|
{
|
2017-03-15 13:07:25 +00:00
|
|
|
if (!isGuiMode())
|
|
|
|
mSpellWindow->cycle(next);
|
2014-12-15 14:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::cycleWeapon(bool next)
|
|
|
|
{
|
2017-03-15 13:07:25 +00:00
|
|
|
if (!isGuiMode())
|
|
|
|
mInventoryWindow->cycle(next);
|
2014-12-15 14:23:03 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 12:21:58 +00:00
|
|
|
void WindowManager::playSound(const std::string& soundId, float volume, float pitch)
|
2017-07-10 11:48:00 +00:00
|
|
|
{
|
2017-09-22 22:00:40 +00:00
|
|
|
if (soundId.empty())
|
|
|
|
return;
|
2018-03-11 12:19:37 +00:00
|
|
|
|
2018-05-01 12:21:58 +00:00
|
|
|
MWBase::Environment::get().getSoundManager()->playSound(soundId, volume, pitch, MWSound::Type::Sfx, MWSound::PlayMode::NoEnv);
|
2015-03-11 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::updateSpellWindow()
|
|
|
|
{
|
|
|
|
if (mSpellWindow)
|
|
|
|
mSpellWindow->updateSpells();
|
|
|
|
}
|
|
|
|
|
2017-09-25 19:03:52 +00:00
|
|
|
void WindowManager::setConsoleSelectedObject(const MWWorld::Ptr &object)
|
2015-03-11 19:33:55 +00:00
|
|
|
{
|
2017-09-25 19:03:52 +00:00
|
|
|
mConsole->setSelectedObject(object);
|
2015-03-11 19:33:55 +00:00
|
|
|
}
|
|
|
|
|
2015-05-01 16:37:24 +00:00
|
|
|
std::string WindowManager::correctIconPath(const std::string& path)
|
|
|
|
{
|
|
|
|
return Misc::ResourceHelpers::correctIconPath(path, mResourceSystem->getVFS());
|
|
|
|
}
|
|
|
|
|
2017-09-08 20:50:07 +00:00
|
|
|
std::string WindowManager::correctBookartPath(const std::string& path, int width, int height, bool* exists)
|
2015-05-01 16:37:24 +00:00
|
|
|
{
|
2017-09-08 20:50:07 +00:00
|
|
|
std::string corrected = Misc::ResourceHelpers::correctBookartPath(path, width, height, mResourceSystem->getVFS());
|
|
|
|
if (exists)
|
|
|
|
*exists = mResourceSystem->getVFS()->exists(corrected);
|
|
|
|
return corrected;
|
2015-05-01 16:37:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string WindowManager::correctTexturePath(const std::string& path)
|
|
|
|
{
|
|
|
|
return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS());
|
|
|
|
}
|
|
|
|
|
2016-03-24 15:52:16 +00:00
|
|
|
bool WindowManager::textureExists(const std::string &path)
|
|
|
|
{
|
|
|
|
std::string corrected = Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS());
|
|
|
|
return mResourceSystem->getVFS()->exists(corrected);
|
|
|
|
}
|
|
|
|
|
2015-07-13 21:36:25 +00:00
|
|
|
void WindowManager::createCursors()
|
|
|
|
{
|
2019-04-01 17:47:12 +00:00
|
|
|
// FIXME: currently we do not scale cursor since it is not a MyGUI widget.
|
|
|
|
// In theory, we can do it manually (rescale the cursor image via osg::Imag::scaleImage() and scale the hotspot position).
|
|
|
|
// Unfortunately, this apploach can lead to driver crashes on some setups (e.g. on laptops with nvidia-prime on Linux).
|
2015-07-13 21:36:25 +00:00
|
|
|
MyGUI::ResourceManager::EnumeratorPtr enumerator = MyGUI::ResourceManager::getInstance().getEnumerator();
|
|
|
|
while (enumerator.next())
|
|
|
|
{
|
|
|
|
MyGUI::IResource* resource = enumerator.current().second;
|
2016-03-05 19:00:51 +00:00
|
|
|
ResourceImageSetPointerFix* imgSetPointer = resource->castType<ResourceImageSetPointerFix>(false);
|
2015-07-13 21:36:25 +00:00
|
|
|
if (!imgSetPointer)
|
|
|
|
continue;
|
|
|
|
std::string tex_name = imgSetPointer->getImageSet()->getIndexInfo(0,0).texture;
|
|
|
|
|
2016-02-05 22:10:27 +00:00
|
|
|
osg::ref_ptr<osg::Image> image = mResourceSystem->getImageManager()->getImage(tex_name);
|
2015-07-13 21:36:25 +00:00
|
|
|
|
2016-02-05 21:58:02 +00:00
|
|
|
if(image.valid())
|
2015-07-13 21:36:25 +00:00
|
|
|
{
|
|
|
|
//everything looks good, send it to the cursor manager
|
|
|
|
Uint8 hotspot_x = imgSetPointer->getHotSpot().left;
|
|
|
|
Uint8 hotspot_y = imgSetPointer->getHotSpot().top;
|
|
|
|
int rotation = imgSetPointer->getRotation();
|
|
|
|
|
2016-02-13 03:14:05 +00:00
|
|
|
mCursorManager->createCursor(imgSetPointer->getResourceName(), rotation, image, hotspot_x, hotspot_y);
|
2015-07-13 21:36:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-02 16:06:54 +00:00
|
|
|
void WindowManager::createTextures()
|
|
|
|
{
|
|
|
|
{
|
2015-05-15 21:21:29 +00:00
|
|
|
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("white");
|
2015-05-02 16:06:54 +00:00
|
|
|
tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8);
|
|
|
|
unsigned char* data = reinterpret_cast<unsigned char*>(tex->lock(MyGUI::TextureUsage::Write));
|
|
|
|
for (int x=0; x<8; ++x)
|
|
|
|
for (int y=0; y<8; ++y)
|
|
|
|
{
|
|
|
|
*(data++) = 255;
|
|
|
|
*(data++) = 255;
|
|
|
|
*(data++) = 255;
|
|
|
|
}
|
|
|
|
tex->unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-05-15 21:21:29 +00:00
|
|
|
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("black");
|
2015-05-02 16:06:54 +00:00
|
|
|
tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8);
|
|
|
|
unsigned char* data = reinterpret_cast<unsigned char*>(tex->lock(MyGUI::TextureUsage::Write));
|
|
|
|
for (int x=0; x<8; ++x)
|
|
|
|
for (int y=0; y<8; ++y)
|
|
|
|
{
|
|
|
|
*(data++) = 0;
|
|
|
|
*(data++) = 0;
|
|
|
|
*(data++) = 0;
|
|
|
|
}
|
|
|
|
tex->unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-05-15 21:21:29 +00:00
|
|
|
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("transparent");
|
2015-05-02 16:06:54 +00:00
|
|
|
tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8);
|
|
|
|
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowManager::setMenuTransparency(float value)
|
|
|
|
{
|
2015-05-15 21:21:29 +00:00
|
|
|
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().getTexture("transparent");
|
2015-05-02 16:06:54 +00:00
|
|
|
unsigned char* data = reinterpret_cast<unsigned char*>(tex->lock(MyGUI::TextureUsage::Write));
|
|
|
|
for (int x=0; x<8; ++x)
|
|
|
|
for (int y=0; y<8; ++y)
|
|
|
|
{
|
|
|
|
*(data++) = 255;
|
|
|
|
*(data++) = 255;
|
|
|
|
*(data++) = 255;
|
|
|
|
*(data++) = static_cast<unsigned char>(value*255);
|
|
|
|
}
|
|
|
|
tex->unlock();
|
|
|
|
}
|
|
|
|
|
2019-02-20 13:37:00 +00:00
|
|
|
void WindowManager::addCell(MWWorld::CellStore* cell)
|
|
|
|
{
|
|
|
|
mLocalMapRender->addCell(cell);
|
|
|
|
}
|
|
|
|
|
2015-05-26 14:40:44 +00:00
|
|
|
void WindowManager::removeCell(MWWorld::CellStore *cell)
|
|
|
|
{
|
|
|
|
mLocalMapRender->removeCell(cell);
|
|
|
|
}
|
|
|
|
|
2015-05-28 01:50:44 +00:00
|
|
|
void WindowManager::writeFog(MWWorld::CellStore *cell)
|
|
|
|
{
|
|
|
|
mLocalMapRender->saveFogOfWar(cell);
|
|
|
|
}
|
|
|
|
|
2017-07-24 11:25:01 +00:00
|
|
|
const MWGui::TextColours& WindowManager::getTextColours()
|
|
|
|
{
|
|
|
|
return mTextColours;
|
|
|
|
}
|
|
|
|
|
2018-09-09 19:10:09 +00:00
|
|
|
bool WindowManager::injectKeyPress(MyGUI::KeyCode key, unsigned int text, bool repeat)
|
2017-09-22 14:52:39 +00:00
|
|
|
{
|
2018-09-09 19:10:09 +00:00
|
|
|
if (!mKeyboardNavigation->injectKeyPress(key, text, repeat))
|
2017-09-24 10:47:50 +00:00
|
|
|
{
|
|
|
|
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
|
|
|
bool widgetActive = MyGUI::InputManager::getInstance().injectKeyPress(key, text);
|
|
|
|
if (!widgetActive || !focus)
|
|
|
|
return false;
|
|
|
|
// FIXME: MyGUI doesn't allow widgets to state if a given key was actually used, so make a guess
|
|
|
|
if (focus->getTypeName().find("Button") != std::string::npos)
|
|
|
|
{
|
|
|
|
switch (key.getValue())
|
|
|
|
{
|
|
|
|
case MyGUI::KeyCode::ArrowDown:
|
|
|
|
case MyGUI::KeyCode::ArrowUp:
|
|
|
|
case MyGUI::KeyCode::ArrowLeft:
|
|
|
|
case MyGUI::KeyCode::ArrowRight:
|
|
|
|
case MyGUI::KeyCode::Return:
|
|
|
|
case MyGUI::KeyCode::NumpadEnter:
|
|
|
|
case MyGUI::KeyCode::Space:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-22 14:52:39 +00:00
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
2017-09-22 18:46:08 +00:00
|
|
|
|
2018-09-10 08:55:00 +00:00
|
|
|
bool WindowManager::injectKeyRelease(MyGUI::KeyCode key)
|
|
|
|
{
|
|
|
|
return MyGUI::InputManager::getInstance().injectKeyRelease(key);
|
|
|
|
}
|
|
|
|
|
2017-09-22 18:46:08 +00:00
|
|
|
void WindowManager::GuiModeState::update(bool visible)
|
|
|
|
{
|
|
|
|
for (unsigned int i=0; i<mWindows.size(); ++i)
|
2017-10-04 15:08:09 +00:00
|
|
|
mWindows[i]->setVisible(visible);
|
2017-09-22 18:46:08 +00:00
|
|
|
}
|
2012-12-31 00:15:47 +00:00
|
|
|
}
|