diff --git a/CHANGELOG.md b/CHANGELOG.md index f117a09bcb..c5c6a08853 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ 0.46.0 ------ + Bug #1515: Opening console masks dialogue, inventory menu Bug #2969: Scripted items can stack Bug #2987: Editor: some chance and AI data fields can overflow Bug #3006: 'else if' operator breaks script compilation diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index f25a90abb5..bbf7a21c41 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -333,6 +333,7 @@ namespace MWBase virtual void activateHitOverlay(bool interrupt=true) = 0; virtual void setWerewolfOverlay(bool set) = 0; + virtual void toggleConsole() = 0; virtual void toggleDebugWindow() = 0; /// Cycle to next or previous spell diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 3a065d13af..705e281381 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -151,8 +152,9 @@ namespace MWGui void Console::onOpen() { // Give keyboard focus to the combo box whenever the console is - // turned on + // turned on and place it over other widgets MyGUI::InputManager::getInstance().setKeyFocusWidget(mCommandLine); + MyGUI::LayerManager::getInstance().upLayerItem(mMainWidget); } void Console::print(const std::string &msg, const std::string& color) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index de66295157..8468cf483b 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -234,6 +234,7 @@ namespace MWGui if (!MWBase::Environment::get().getWindowManager ()->isGuiMode ()) return; + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); if (mDragAndDrop->mIsOnDragAndDrop) { // drop item into the gameworld @@ -248,24 +249,24 @@ namespace MWGui WorldItemModel drop (mouseX, mouseY); mDragAndDrop->drop(&drop, nullptr); - MWBase::Environment::get().getWindowManager()->changePointer("arrow"); + winMgr->changePointer("arrow"); } else { - GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); + GuiMode mode = winMgr->getMode(); - if ( (mode != GM_Console) && (mode != GM_Container) && (mode != GM_Inventory) ) + if (!winMgr->isConsoleMode() && (mode != GM_Container) && (mode != GM_Inventory)) return; MWWorld::Ptr object = MWBase::Environment::get().getWorld()->getFacedObject(); - if (mode == GM_Console) - MWBase::Environment::get().getWindowManager()->setConsoleSelectedObject(object); + if (winMgr->isConsoleMode()) + winMgr->setConsoleSelectedObject(object); else //if ((mode == GM_Container) || (mode == GM_Inventory)) { // pick up object if (!object.isEmpty()) - MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(object); + winMgr->getInventoryWindow()->pickUpObject(object); } } } diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index c452a1f5fe..62d7396577 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -12,7 +12,6 @@ namespace MWGui GM_Companion, GM_MainMenu, // Main menu mode - GM_Console, // Console mode GM_Journal, // Journal mode GM_Scroll, // Read scroll diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index c5cce46320..dc7a9668d1 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -94,17 +94,19 @@ namespace MWGui return; } - bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); + bool guiMode = winMgr->isGuiMode(); if (guiMode) { - if (!MWBase::Environment::get().getWindowManager()->getCursorVisible()) + if (!winMgr->getCursorVisible()) return; const MyGUI::IntPoint& mousePos = MyGUI::InputManager::getInstance().getMousePosition(); - if (MWBase::Environment::get().getWindowManager()->getWorldMouseOver() && ((MWBase::Environment::get().getWindowManager()->getMode() == GM_Console) - || (MWBase::Environment::get().getWindowManager()->getMode() == GM_Container) - || (MWBase::Environment::get().getWindowManager()->getMode() == GM_Inventory))) + if (winMgr->getWorldMouseOver() && + (winMgr->isConsoleMode() || + (winMgr->getMode() == GM_Container) || + (winMgr->getMode() == GM_Inventory))) { if (mFocusObject.isEmpty ()) return; @@ -112,7 +114,7 @@ namespace MWGui const MWWorld::Class& objectclass = mFocusObject.getClass(); MyGUI::IntSize tooltipSize; - if ((!objectclass.hasToolTip(mFocusObject))&&(MWBase::Environment::get().getWindowManager()->getMode() == GM_Console)) + if (!objectclass.hasToolTip(mFocusObject) && winMgr->isConsoleMode()) { setCoord(0, 0, 300, 300); mDynamicToolTipBox->setVisible(true); @@ -212,7 +214,7 @@ namespace MWGui { MyGUI::IntCoord avatarPos = focus->getAbsoluteCoord(); MyGUI::IntPoint relMousePos = MyGUI::InputManager::getInstance ().getMousePosition () - MyGUI::IntPoint(avatarPos.left, avatarPos.top); - MWWorld::Ptr item = MWBase::Environment::get().getWindowManager()->getInventoryWindow ()->getAvatarSelectedItem (relMousePos.left, relMousePos.top); + MWWorld::Ptr item = winMgr->getInventoryWindow ()->getAvatarSelectedItem (relMousePos.left, relMousePos.top); mFocusObject = item; if (!mFocusObject.isEmpty ()) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 42afc0db8f..6c9ca82532 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -445,7 +445,6 @@ namespace MWGui mConsole = new Console(w,h, mConsoleOnlyScripts); mWindows.push_back(mConsole); trackWindow(mConsole, "console"); - mGuiModeStates[GM_Console] = GuiModeState(mConsole); bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds"); JournalWindow* journal = JournalWindow::create(JournalViewModel::create (), questList, mEncoding); @@ -711,10 +710,10 @@ namespace MWGui // If in game mode (or interactive messagebox), show the pinned windows if (mGuiModes.empty()) { - mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map)); - mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats)); - mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory)); - mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic) && (mAllowed & GW_Magic)); + 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)); return; } else if (getMode() != GM_Inventory) @@ -1320,6 +1319,10 @@ namespace MWGui } updateVisible(); + + // To make sure that console window get focus again + if (mConsole && mConsole->isVisible()) + mConsole->onOpen(); } void WindowManager::removeGuiMode(GuiMode mode, bool noSound) @@ -1529,14 +1532,15 @@ namespace MWGui bool WindowManager::isGuiMode() const { - return !mGuiModes.empty() || (mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox()); + return + !mGuiModes.empty() || + isConsoleMode() || + (mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox()); } bool WindowManager::isConsoleMode() const { - if (!mGuiModes.empty() && mGuiModes.back()==GM_Console) - return true; - return false; + return mConsole && mConsole->isVisible(); } MWGui::GuiMode WindowManager::getMode() const @@ -1836,6 +1840,7 @@ namespace MWGui bool WindowManager::isSavingAllowed() const { return !MyGUI::InputManager::getInstance().isModalAny() + && !isConsoleMode() // TODO: remove this, once we have properly serialized the state of open windows && (!isGuiMode() || (mGuiModes.size() == 1 && (getMode() == GM_MainMenu || getMode() == GM_Rest))); } @@ -2083,6 +2088,21 @@ namespace MWGui SDL_free(text); } + 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(); + } + void WindowManager::toggleDebugWindow() { mDebugWindow->setVisible(!mDebugWindow->isVisible()); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 2d16bb6e49..91c61a1e96 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -361,6 +361,7 @@ namespace MWGui virtual void activateHitOverlay(bool interrupt); virtual void setWerewolfOverlay(bool set); + virtual void toggleConsole(); virtual void toggleDebugWindow(); /// Cycle to next or previous spell diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 6ca2ef6e48..61a85e874d 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -495,7 +495,7 @@ namespace MWInput void InputManager::updateCursorMode() { bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu) - && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Console; + && !MWBase::Environment::get().getWindowManager()->isConsoleMode(); bool was_relative = mInputManager->getMouseRelative(); bool is_relative = !MWBase::Environment::get().getWindowManager()->isGuiMode(); @@ -864,7 +864,7 @@ namespace MWInput OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE) == arg.keysym.scancode - && MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console) + && MWBase::Environment::get().getWindowManager()->isConsoleMode()) SDL_StopTextInput(); bool consumed = false; @@ -1152,6 +1152,9 @@ namespace MWInput return; } + if (MWBase::Environment::get().getWindowManager()->isConsoleMode()) + return; + bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame; MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); @@ -1170,6 +1173,9 @@ namespace MWInput return; } + if (MWBase::Environment::get().getWindowManager()->isConsoleMode()) + return; + MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode(); bool inGame = MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_NoGame; @@ -1284,6 +1290,9 @@ namespace MWInput if (MyGUI::InputManager::getInstance ().isModalAny()) return; + if (MWBase::Environment::get().getWindowManager()->isConsoleMode()) + return; + // Toggle between game mode and inventory mode if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Inventory); @@ -1302,17 +1311,7 @@ namespace MWInput if (MyGUI::InputManager::getInstance ().isModalAny()) return; - // Switch to console mode no matter what mode we are currently - // in, except of course if we are already in console mode - if (MWBase::Environment::get().getWindowManager()->isGuiMode()) - { - if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console) - MWBase::Environment::get().getWindowManager()->popGuiMode(); - else - MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Console); - } - else - MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Console); + MWBase::Environment::get().getWindowManager()->toggleConsole(); } void InputManager::toggleJournal() diff --git a/files/mygui/openmw_console.layout b/files/mygui/openmw_console.layout index a58327a481..6ab65d21da 100644 --- a/files/mygui/openmw_console.layout +++ b/files/mygui/openmw_console.layout @@ -1,6 +1,6 @@  - + diff --git a/files/mygui/openmw_layers.xml b/files/mygui/openmw_layers.xml index 5e4a74978f..24595881af 100644 --- a/files/mygui/openmw_layers.xml +++ b/files/mygui/openmw_layers.xml @@ -10,7 +10,6 @@ -