Merge pull request #2402 from akortunov/console

Make console to do not hide other GUI windows
pull/2407/head
Alexei Dobrohotov 6 years ago committed by GitHub
commit 58f8d1ac04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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

@ -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>
@ -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)

@ -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);
}
}
}

@ -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

@ -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 ())

@ -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());

@ -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

@ -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()

@ -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"/>

@ -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"/>

Loading…
Cancel
Save