summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-07 02:23:04 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-07 02:23:04 +0300
commit3e0bce53e2b3387801f3e0484f01a64d767115da (patch)
tree0601c1a09f7452fb41702249e70cbe0f035ea7df
parentc35ae089aaa484b72c787625d2dd9a1481fa15b6 (diff)
downloadmanaverse-3e0bce53e2b3387801f3e0484f01a64d767115da.tar.gz
manaverse-3e0bce53e2b3387801f3e0484f01a64d767115da.tar.bz2
manaverse-3e0bce53e2b3387801f3e0484f01a64d767115da.tar.xz
manaverse-3e0bce53e2b3387801f3e0484f01a64d767115da.zip
Allow open debug window before connecting to game.
-rw-r--r--src/game.cpp8
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp6
-rw-r--r--src/gui/windowmanager.cpp9
-rw-r--r--src/gui/windows/debugwindow.cpp4
-rw-r--r--src/gui/windows/debugwindow.h2
-rw-r--r--src/input/inputactionmap.h2
6 files changed, 24 insertions, 7 deletions
diff --git a/src/game.cpp b/src/game.cpp
index b9eeb12b7..b90d9c293 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -227,7 +227,13 @@ static void createGuiWindows()
CREATEWIDGETV0(shopWindow, ShopWindow);
CREATEWIDGETV0(skillDialog, SkillDialog);
CREATEWIDGETV0(minimap, Minimap);
- CREATEWIDGETV0(debugWindow, DebugWindow);
+ if (debugWindow)
+ {
+ debugWindow->scheduleDelete();
+ debugWindow = nullptr;
+ }
+ CREATEWIDGETV(debugWindow, DebugWindow,
+ "Debug");
CREATEWIDGETV(itemShortcutWindow, ShortcutWindow,
"ItemShortcut", "items.xml", 83, 460);
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index 4a600d2fd..321c3bcad 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -183,8 +183,10 @@ void MapDebugTab::logic()
mXYLabel->setCaption(strprintf("%s (?, ?)", _("Player Position:")));
}
- const Map *const map = Game::instance()->getCurrentMap();
- if ((map != nullptr) && (viewport != nullptr))
+ Game *const game = Game::instance();
+ const Map *const map = game != nullptr ? game->getCurrentMap() : nullptr;
+ if (map != nullptr &&
+ viewport != nullptr)
{
// Get the current mouse position
const int mouseTileX = (viewport->mMouseX + viewport->getCameraX())
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index 62d2996c7..38141720b 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -49,6 +49,7 @@
#include "gui/popups/textboxpopup.h"
#include "gui/windows/chatwindow.h"
+#include "gui/windows/debugwindow.h"
#include "gui/windows/didyouknowwindow.h"
#include "gui/windows/equipmentwindow.h"
#include "gui/windows/helpwindow.h"
@@ -144,6 +145,13 @@ void WindowManager::createWindows()
"#Debug", ChatTabType::DEBUG);
debugChatTab->setAllowHighlight(false);
chatWindow->setVisible(Visible_false);
+ if (debugWindow)
+ {
+ debugWindow->scheduleDelete();
+ debugWindow = nullptr;
+ }
+ CREATEWIDGETV(debugWindow, DebugWindow,
+ "DebugDebug");
#endif // DYECMD
CREATEWIDGETV0(textPopup, TextPopup);
@@ -187,6 +195,7 @@ void WindowManager::deleteWindows()
delete2(debugChatTab);
delete2(chatWindow);
+ delete2(debugWindow);
#endif // DYECMD
delete2(textPopup);
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 8b4144b98..e10ad1b2c 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -38,7 +38,7 @@
DebugWindow *debugWindow = nullptr;
-DebugWindow::DebugWindow() :
+DebugWindow::DebugWindow(const std::string &name) :
// TRANSLATORS: debug window name
Window(_("Debug"), Modal_false, nullptr, "debug.xml"),
mTabs(CREATEWIDGETR(TabbedArea, this)),
@@ -46,7 +46,7 @@ DebugWindow::DebugWindow() :
mTargetWidget(new TargetDebugTab(this)),
mNetWidget(new NetDebugTab(this))
{
- setWindowName("Debug");
+ setWindowName(name);
if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h
index f39386ec8..3e13352fc 100644
--- a/src/gui/windows/debugwindow.h
+++ b/src/gui/windows/debugwindow.h
@@ -41,7 +41,7 @@ class DebugWindow final : public Window
/**
* Constructor.
*/
- DebugWindow();
+ DebugWindow(const std::string &name);
A_DELETE_COPY(DebugWindow)
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index cfe709674..9f4f3f63e 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -613,7 +613,7 @@ static const InputActionData inputActionData
Input::GRP_DEFAULT | Input::GRP_GUI,
&Actions::debugWindowShow,
InputAction::NO_VALUE, 50,
- InputCondition::GAME | InputCondition::NOTARGET,
+ InputCondition::SHORTCUT0 | InputCondition::NOTARGET,
"debug|opendebug",
UseArgs_false,
Protected_false},