Skip to content

Commit

Permalink
Make console to do not hide other GUI windows (bug OpenMW#1515)
Browse files Browse the repository at this point in the history
  • Loading branch information
akortunov committed May 29, 2019
1 parent 4d29242 commit 8f2047e
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/openmw/mwbase/windowmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion apps/openmw/mwgui/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <MyGUI_EditBox.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_LayerManager.h>

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions apps/openmw/mwgui/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion apps/openmw/mwgui/mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions apps/openmw/mwgui/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,27 @@ 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;

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);
Expand Down Expand Up @@ -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 ())
Expand Down
42 changes: 33 additions & 9 deletions apps/openmw/mwgui/windowmanagerimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)));
}
Expand Down Expand Up @@ -2083,6 +2088,25 @@ 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());
Expand Down
1 change: 1 addition & 0 deletions apps/openmw/mwgui/windowmanagerimp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 12 additions & 13 deletions apps/openmw/mwinput/inputmanagerimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion files/mygui/openmw_console.layout
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window" position="0 0 400 400" layer="Console" name="_Main">
<Widget type="Window" skin="MW_Window" position="0 0 400 400" layer="Windows" name="_Main">
<Property key="Caption" value="#{sConsoleTitle}"/>
<Property key="MinSize" value="40 40"/>
<Property key="Visible" value="false"/>
Expand Down
1 change: 0 additions & 1 deletion files/mygui/openmw_layers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<Layer name="JournalBooks" type="ScalingLayer" pick="true">
<Property key="Size" value="600 520"/>
</Layer>
<Layer name="Console" overlapped="false" pick="true"/>
<Layer name="Debug" overlapped="true" pick="true"/>
<Layer name="Notification" overlapped="false" pick="false"/>
<Layer name="Popup" overlapped="true" pick="true"/>
Expand Down

0 comments on commit 8f2047e

Please sign in to comment.