summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-16 16:30:09 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-16 16:30:09 +0300
commitdb0cb4f13de9b1a6cc7eacbcf8f41aa7982456a2 (patch)
treee4392208bfe2ba7ec7bf665f6e466492336d5b1b /src
parentfe6a120ea38daaad39f6952a886c20269cfedca6 (diff)
downloadplus-db0cb4f13de9b1a6cc7eacbcf8f41aa7982456a2.tar.gz
plus-db0cb4f13de9b1a6cc7eacbcf8f41aa7982456a2.tar.bz2
plus-db0cb4f13de9b1a6cc7eacbcf8f41aa7982456a2.tar.xz
plus-db0cb4f13de9b1a6cc7eacbcf8f41aa7982456a2.zip
Move debug window tabs into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp446
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.h124
-rw-r--r--src/gui/windows/debugwindow.cpp394
-rw-r--r--src/gui/windows/debugwindow.h97
6 files changed, 579 insertions, 486 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 102f5faf5..9e7b69cf3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -126,6 +126,8 @@ SET(SRCS
gui/widgets/tabs/chattab.cpp
gui/widgets/tabs/chattab.h
gui/widgets/tabs/chattabtype.h
+ gui/widgets/tabs/debugwindowtabs.cpp
+ gui/widgets/tabs/debugwindowtabs.h
gui/widgets/chatinput.h
gui/widgets/checkbox.cpp
gui/widgets/checkbox.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f953a17a..a8ace3385 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -218,6 +218,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/tabs/chattab.cpp \
gui/widgets/tabs/chattab.h \
gui/widgets/tabs/chattabtype.h \
+ gui/widgets/tabs/debugwindowtabs.cpp \
+ gui/widgets/tabs/debugwindowtabs.h \
gui/widgets/chatinput.h \
gui/widgets/checkbox.cpp \
gui/widgets/checkbox.h \
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
new file mode 100644
index 000000000..cf0c6af6e
--- /dev/null
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -0,0 +1,446 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/widgets/tabs/debugwindowtabs.h"
+
+#include "game.h"
+#include "main.h"
+
+#include "being/localplayer.h"
+
+#include "particle/particle.h"
+
+#include "gui/viewport.h"
+
+#include "gui/windows/setupwindow.h"
+
+#include "gui/widgets/containerplacer.h"
+#include "gui/widgets/label.h"
+#include "gui/widgets/layoutcell.h"
+#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/tabbedarea.h"
+
+#include "resources/imagehelper.h"
+
+#include "resources/map/map.h"
+
+#include "net/packetcounters.h"
+
+#include "utils/delete2.h"
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+#include "utils/timer.h"
+
+#include "debug.h"
+
+MapDebugTab::MapDebugTab(const Widget2 *const widget) :
+ DebugTab(widget),
+ // TRANSLATORS: debug window label
+ mMusicFileLabel(new Label(this, strprintf(_("Music:")))),
+ // TRANSLATORS: debug window label
+ mMapLabel(new Label(this, strprintf(_("Map:")))),
+ // TRANSLATORS: debug window label
+ mMinimapLabel(new Label(this, strprintf(_("Minimap:")))),
+ mTileMouseLabel(new Label(this, strprintf("%s (%d, %d)",
+ // TRANSLATORS: debug window label
+ _("Cursor:"), 0, 0))),
+ mParticleCountLabel(new Label(this, strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Particle count:"), 88888))),
+ mMapActorCountLabel(new Label(this, strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Map actors count:"), 88888))),
+ // TRANSLATORS: debug window label
+ mXYLabel(new Label(this, strprintf("%s (?,?)", _("Player Position:")))),
+ mTexturesLabel(nullptr),
+ mUpdateTime(0),
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCallsLabel(new Label(this, strprintf("%s %s",
+ // TRANSLATORS: debug window label
+ _("Draw calls:"), "?"))),
+#endif
+#ifdef DEBUG_BIND_TEXTURE
+ mBindsLabel(new Label(this, strprintf("%s %s",
+ // TRANSLATORS: debug window label
+ _("Texture binds:"), "?"))),
+#endif
+ // TRANSLATORS: debug window label, frames per second
+ mFPSLabel(new Label(this, strprintf(_("%d FPS"), 0))),
+ // TRANSLATORS: debug window label, logic per second
+ mLPSLabel(new Label(this, strprintf(_("%d LPS"), 0))),
+ mFPSText()
+{
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+
+#ifdef USE_OPENGL
+ switch (imageHelper->useOpenGL())
+ {
+ case RENDER_SOFTWARE:
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (Software)");
+ break;
+ case RENDER_NORMAL_OPENGL:
+ case RENDER_NULL:
+ case RENDER_LAST:
+ default:
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (normal OpenGL)");
+ break;
+ case RENDER_SAFE_OPENGL:
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (safe OpenGL)");
+ break;
+ case RENDER_GLES_OPENGL:
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (mobile OpenGL)");
+ break;
+ case RENDER_SDL2_DEFAULT:
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (SDL2 default)");
+ break;
+ };
+#else
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (Software)");
+#endif
+
+ place(0, 0, mFPSLabel, 2);
+ place(0, 1, mLPSLabel, 2);
+ place(0, 2, mMusicFileLabel, 2);
+ place(0, 3, mMapLabel, 2);
+ place(0, 4, mMinimapLabel, 2);
+ place(0, 5, mXYLabel, 2);
+ place(0, 6, mTileMouseLabel, 2);
+ place(0, 7, mParticleCountLabel, 2);
+ place(0, 8, mMapActorCountLabel, 2);
+#ifdef USE_OPENGL
+#if defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) \
+ || defined(DEBUG_BIND_TEXTURE)
+ int n = 9;
+#endif
+#ifdef DEBUG_OPENGL_LEAKS
+ mTexturesLabel = new Label(this, strprintf("%s %s",
+ // TRANSLATORS: debug window label
+ _("Textures count:"), "?"));
+ place(0, n, mTexturesLabel, 2);
+ n ++;
+#endif
+#ifdef DEBUG_DRAW_CALLS
+ place(0, n, mDrawCallsLabel, 2);
+ n ++;
+#endif
+#ifdef DEBUG_BIND_TEXTURE
+ place(0, n, mBindsLabel, 2);
+#endif
+#endif
+ place.getCell().matchColWidth(0, 0);
+ place = h.getPlacer(0, 1);
+ setDimension(Rect(0, 0, 600, 300));
+}
+
+void MapDebugTab::logic()
+{
+ BLOCK_START("MapDebugTab::logic")
+ if (player_node)
+ {
+ // TRANSLATORS: debug window label
+ mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"),
+ player_node->getTileX(), player_node->getTileY()));
+ }
+ else
+ {
+ // TRANSLATORS: debug window label
+ mXYLabel->setCaption(strprintf("%s (?, ?)", _("Player Position:")));
+ }
+
+ const Map *const map = Game::instance()->getCurrentMap();
+ if (map && viewport)
+ {
+ // Get the current mouse position
+ const int mouseTileX = (viewport->getMouseX() + viewport->getCameraX())
+ / map->getTileWidth();
+ const int mouseTileY = (viewport->getMouseY() + viewport->getCameraY())
+ / map->getTileHeight();
+ mTileMouseLabel->setCaption(strprintf("%s (%d, %d)",
+ // TRANSLATORS: debug window label
+ _("Cursor:"), mouseTileX, mouseTileY));
+
+ // TRANSLATORS: debug window label
+ mMusicFileLabel->setCaption(strprintf("%s %s", _("Music:"),
+ map->getProperty("music").c_str()));
+ // TRANSLATORS: debug window label
+ mMinimapLabel->setCaption(strprintf("%s %s", _("Minimap:"),
+ map->getProperty("minimap").c_str()));
+ // TRANSLATORS: debug window label
+ mMapLabel->setCaption(strprintf("%s %s", _("Map:"),
+ map->getProperty("_realfilename").c_str()));
+
+
+ if (mUpdateTime != cur_time)
+ {
+ mUpdateTime = cur_time;
+ // TRANSLATORS: debug window label
+ mParticleCountLabel->setCaption(strprintf(_("Particle count: %d"),
+ Particle::particleCount));
+
+ mMapActorCountLabel->setCaption(
+ // TRANSLATORS: debug window label
+ strprintf("%s %d", _("Map actors count:"),
+ map->getActorsCount()));
+#ifdef USE_OPENGL
+#ifdef DEBUG_OPENGL_LEAKS
+ mTexturesLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Textures count:"), textures_count));
+#endif
+#ifdef DEBUG_DRAW_CALLS
+ if (mainGraphics)
+ {
+ mDrawCallsLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Draw calls:"), mainGraphics->getDrawCalls()));
+ }
+#endif
+#ifdef DEBUG_BIND_TEXTURE
+ if (mainGraphics)
+ {
+ mBindsLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Texture binds:"), mainGraphics->getBinds()));
+ }
+#endif
+#endif
+ }
+ }
+ else
+ {
+ // TRANSLATORS: debug window label
+ mTileMouseLabel->setCaption(strprintf("%s (?, ?)", _("Cursor:")));
+ // TRANSLATORS: debug window label
+ mMusicFileLabel->setCaption(strprintf("%s ?", _("Music:")));
+ // TRANSLATORS: debug window label
+ mMinimapLabel->setCaption(strprintf("%s ?", _("Minimap:")));
+ // TRANSLATORS: debug window label
+ mMapLabel->setCaption(strprintf("%s ?", _("Map:")));
+
+ mMapActorCountLabel->setCaption(
+ // TRANSLATORS: debug window label
+ strprintf("%s ?", _("Map actors count:")));
+ }
+
+ mMapActorCountLabel->adjustSize();
+ mParticleCountLabel->adjustSize();
+
+ mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps));
+ // TRANSLATORS: debug window label, logic per second
+ mLPSLabel->setCaption(strprintf(_("%d LPS"), lps));
+ BLOCK_END("MapDebugTab::logic")
+}
+
+TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
+ DebugTab(widget),
+ // TRANSLATORS: debug window label
+ mTargetLabel(new Label(this, strprintf("%s ?", _("Target:")))),
+ // TRANSLATORS: debug window label
+ mTargetIdLabel(new Label(this, strprintf("%s ? ", _("Target Id:")))),
+ mTargetTypeLabel(new Label(this, strprintf(
+ // TRANSLATORS: debug window label
+ "%s ? ", _("Target type:")))),
+ // TRANSLATORS: debug window label
+ mTargetLevelLabel(new Label(this, strprintf("%s ?", _("Target level:")))),
+ // TRANSLATORS: debug window label
+ mTargetRaceLabel(new Label(this, strprintf("%s ?", _("Target race:")))),
+ // TRANSLATORS: debug window label
+ mTargetPartyLabel(new Label(this, strprintf("%s ?", _("Target party:")))),
+ // TRANSLATORS: debug window label
+ mTargetGuildLabel(new Label(this, strprintf("%s ?", _("Target guild:")))),
+ // TRANSLATORS: debug window label
+ mAttackDelayLabel(new Label(this, strprintf("%s ?", _("Attack delay:")))),
+ // TRANSLATORS: debug window label
+ mMinHitLabel(new Label(this, strprintf("%s ?", _("Minimal hit:")))),
+ // TRANSLATORS: debug window label
+ mMaxHitLabel(new Label(this, strprintf("%s ?", _("Maximum hit:")))),
+ // TRANSLATORS: debug window label
+ mCriticalHitLabel(new Label(this, strprintf("%s ?", _("Critical hit:"))))
+{
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+
+ place(0, 0, mTargetLabel, 2);
+ place(0, 1, mTargetIdLabel, 2);
+ place(0, 2, mTargetTypeLabel, 2);
+ place(0, 3, mTargetLevelLabel, 2);
+ place(0, 4, mTargetRaceLabel, 2);
+ place(0, 5, mAttackDelayLabel, 2);
+ place(0, 6, mTargetPartyLabel, 2);
+ place(0, 7, mTargetGuildLabel, 2);
+ place(0, 8, mMinHitLabel, 2);
+ place(0, 9, mMaxHitLabel, 2);
+ place(0, 10, mCriticalHitLabel, 2);
+
+ place.getCell().matchColWidth(0, 0);
+ place = h.getPlacer(0, 1);
+ setDimension(Rect(0, 0, 600, 300));
+}
+
+void TargetDebugTab::logic()
+{
+ BLOCK_START("TargetDebugTab::logic")
+ if (player_node && player_node->getTarget())
+ {
+ const Being *const target = player_node->getTarget();
+
+ // TRANSLATORS: debug window label
+ mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"),
+ target->getName().c_str(), target->getTileX(),
+ target->getTileY()));
+
+ mTargetIdLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Target Id:"), target->getId()));
+ mTargetTypeLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Target type:"), target->getSubType()));
+ if (target->getLevel())
+ {
+ mTargetLevelLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Target Level:"), target->getLevel()));
+ }
+ else
+ {
+ mTargetLevelLabel->setCaption(strprintf("%s ?",
+ // TRANSLATORS: debug window label
+ _("Target Level:")));
+ }
+
+ mTargetRaceLabel->setCaption(strprintf("%s %s",
+ // TRANSLATORS: debug window label
+ _("Target race:"), target->getRaceName().c_str()));
+
+ // TRANSLATORS: debug window label
+ mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"),
+ target->getPartyName().c_str()));
+
+ // TRANSLATORS: debug window label
+ mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"),
+ target->getGuildName().c_str()));
+
+ mMinHitLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Minimal hit:"), target->getMinHit()));
+ mMaxHitLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Maximum hit:"), target->getMaxHit()));
+ mCriticalHitLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Critical hit:"), target->getCriticalHit()));
+
+ const int delay = target->getAttackDelay();
+ if (delay)
+ {
+ mAttackDelayLabel->setCaption(strprintf("%s %d",
+ // TRANSLATORS: debug window label
+ _("Attack delay:"), delay));
+ }
+ else
+ {
+ mAttackDelayLabel->setCaption(strprintf(
+ // TRANSLATORS: debug window label
+ "%s ?", _("Attack delay:")));
+ }
+ }
+ else
+ {
+ // TRANSLATORS: debug window label
+ mTargetLabel->setCaption(strprintf("%s ?", _("Target:")));
+ // TRANSLATORS: debug window label
+ mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:")));
+ // TRANSLATORS: debug window label
+ mTargetTypeLabel->setCaption(strprintf("%s ?", _("Target type:")));
+ // TRANSLATORS: debug window label
+ mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:")));
+ // TRANSLATORS: debug window label
+ mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:")));
+ // TRANSLATORS: debug window label
+ mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:")));
+ // TRANSLATORS: debug window label
+ mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:")));
+ // TRANSLATORS: debug window label
+ mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:")));
+ // TRANSLATORS: debug window label
+ mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:")));
+ // TRANSLATORS: debug window label
+ mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:")));
+ }
+
+ mTargetLabel->adjustSize();
+ mTargetIdLabel->adjustSize();
+ mTargetTypeLabel->adjustSize();
+ mTargetLevelLabel->adjustSize();
+ mTargetPartyLabel->adjustSize();
+ mTargetGuildLabel->adjustSize();
+ mAttackDelayLabel->adjustSize();
+ BLOCK_END("TargetDebugTab::logic")
+}
+
+NetDebugTab::NetDebugTab(const Widget2 *const widget) :
+ DebugTab(widget),
+ mPingLabel(new Label(this, " ")),
+ mInPackets1Label(new Label(this, " ")),
+ mOutPackets1Label(new Label(this, " "))
+{
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+
+ place(0, 0, mPingLabel, 2);
+ place(0, 1, mInPackets1Label, 2);
+ place(0, 2, mOutPackets1Label, 2);
+
+ place.getCell().matchColWidth(0, 0);
+ place = h.getPlacer(0, 1);
+ setDimension(Rect(0, 0, 600, 300));
+}
+
+void NetDebugTab::logic()
+{
+ BLOCK_START("NetDebugTab::logic")
+ if (player_node)
+ {
+ // TRANSLATORS: debug window label
+ mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
+ player_node->getPingTime().c_str()));
+ }
+ else
+ {
+ // TRANSLATORS: debug window label
+ mPingLabel->setCaption(strprintf(_("Ping: %s ms"), "0"));
+ }
+ // TRANSLATORS: debug window label
+ mInPackets1Label->setCaption(strprintf(_("In: %d bytes/s"),
+ PacketCounters::getInBytes()));
+ // TRANSLATORS: debug window label
+ mOutPackets1Label->setCaption(strprintf(_("Out: %d bytes/s"),
+ PacketCounters::getOutBytes()));
+ BLOCK_END("NetDebugTab::logic")
+}
diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h
new file mode 100644
index 000000000..4230bc09a
--- /dev/null
+++ b/src/gui/widgets/tabs/debugwindowtabs.h
@@ -0,0 +1,124 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H
+#define GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H
+
+#include "gui/widgets/container.h"
+
+class Label;
+
+class DebugTab : public Container
+{
+ friend class DebugWindow;
+
+ public:
+ A_DELETE_COPY(DebugTab)
+
+ void logic() override
+ {
+ }
+
+ void resize(const int x, const int y)
+ { setDimension(Rect(0, 0, x, y)); }
+
+ protected:
+ explicit DebugTab(const Widget2 *const widget) :
+ Container(widget)
+ { }
+};
+
+class MapDebugTab final : public DebugTab
+{
+ friend class DebugWindow;
+
+ public:
+ explicit MapDebugTab(const Widget2 *const widget);
+
+ A_DELETE_COPY(MapDebugTab)
+
+ void logic() override final;
+
+ private:
+ Label *mMusicFileLabel;
+ Label *mMapLabel;
+ Label *mMinimapLabel;
+ Label *mTileMouseLabel;
+ Label *mParticleCountLabel;
+ Label *mMapActorCountLabel;
+ Label *mXYLabel;
+ Label *mTexturesLabel;
+ int mUpdateTime;
+#ifdef DEBUG_DRAW_CALLS
+ Label *mDrawCallsLabel;
+#endif
+#ifdef DEBUG_BIND_TEXTURE
+ Label *mBindsLabel;
+#endif
+ Label *mFPSLabel;
+ Label *mLPSLabel;
+ std::string mFPSText;
+};
+
+class TargetDebugTab final : public DebugTab
+{
+ friend class DebugWindow;
+
+ public:
+ explicit TargetDebugTab(const Widget2 *const widget);
+
+ A_DELETE_COPY(TargetDebugTab)
+
+ void logic() override final;
+
+ private:
+ Label *mTargetLabel;
+ Label *mTargetIdLabel;
+ Label *mTargetTypeLabel;
+ Label *mTargetLevelLabel;
+ Label *mTargetRaceLabel;
+ Label *mTargetPartyLabel;
+ Label *mTargetGuildLabel;
+ Label *mAttackDelayLabel;
+ Label *mMinHitLabel;
+ Label *mMaxHitLabel;
+ Label *mCriticalHitLabel;
+};
+
+class NetDebugTab final : public DebugTab
+{
+ friend class DebugWindow;
+
+ public:
+ explicit NetDebugTab(const Widget2 *const widget);
+
+ A_DELETE_COPY(NetDebugTab)
+
+ void logic() override final;
+
+ private:
+ Label *mPingLabel;
+ Label *mInPackets1Label;
+ Label *mOutPackets1Label;
+};
+
+#endif // GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 62a82704c..523b72237 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -39,6 +39,8 @@
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/tabbedarea.h"
+#include "gui/widgets/tabs/debugwindowtabs.h"
+
#include "resources/imagehelper.h"
#include "resources/map/map.h"
@@ -165,395 +167,3 @@ void DebugWindow::logicChildren()
}
#endif
-MapDebugTab::MapDebugTab(const Widget2 *const widget) :
- DebugTab(widget),
- // TRANSLATORS: debug window label
- mMusicFileLabel(new Label(this, strprintf(_("Music:")))),
- // TRANSLATORS: debug window label
- mMapLabel(new Label(this, strprintf(_("Map:")))),
- // TRANSLATORS: debug window label
- mMinimapLabel(new Label(this, strprintf(_("Minimap:")))),
- mTileMouseLabel(new Label(this, strprintf("%s (%d, %d)",
- // TRANSLATORS: debug window label
- _("Cursor:"), 0, 0))),
- mParticleCountLabel(new Label(this, strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Particle count:"), 88888))),
- mMapActorCountLabel(new Label(this, strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Map actors count:"), 88888))),
- // TRANSLATORS: debug window label
- mXYLabel(new Label(this, strprintf("%s (?,?)", _("Player Position:")))),
- mTexturesLabel(nullptr),
- mUpdateTime(0),
-#ifdef DEBUG_DRAW_CALLS
- mDrawCallsLabel(new Label(this, strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Draw calls:"), "?"))),
-#endif
-#ifdef DEBUG_BIND_TEXTURE
- mBindsLabel(new Label(this, strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Texture binds:"), "?"))),
-#endif
- // TRANSLATORS: debug window label, frames per second
- mFPSLabel(new Label(this, strprintf(_("%d FPS"), 0))),
- // TRANSLATORS: debug window label, logic per second
- mLPSLabel(new Label(this, strprintf(_("%d LPS"), 0))),
- mFPSText()
-{
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
-#ifdef USE_OPENGL
- switch (imageHelper->useOpenGL())
- {
- case RENDER_SOFTWARE:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (Software)");
- break;
- case RENDER_NORMAL_OPENGL:
- case RENDER_NULL:
- case RENDER_LAST:
- default:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (normal OpenGL)");
- break;
- case RENDER_SAFE_OPENGL:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (safe OpenGL)");
- break;
- case RENDER_GLES_OPENGL:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (mobile OpenGL)");
- break;
- case RENDER_SDL2_DEFAULT:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (SDL2 default)");
- break;
- };
-#else
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (Software)");
-#endif
-
- place(0, 0, mFPSLabel, 2);
- place(0, 1, mLPSLabel, 2);
- place(0, 2, mMusicFileLabel, 2);
- place(0, 3, mMapLabel, 2);
- place(0, 4, mMinimapLabel, 2);
- place(0, 5, mXYLabel, 2);
- place(0, 6, mTileMouseLabel, 2);
- place(0, 7, mParticleCountLabel, 2);
- place(0, 8, mMapActorCountLabel, 2);
-#ifdef USE_OPENGL
-#if defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) \
- || defined(DEBUG_BIND_TEXTURE)
- int n = 9;
-#endif
-#ifdef DEBUG_OPENGL_LEAKS
- mTexturesLabel = new Label(this, strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Textures count:"), "?"));
- place(0, n, mTexturesLabel, 2);
- n ++;
-#endif
-#ifdef DEBUG_DRAW_CALLS
- place(0, n, mDrawCallsLabel, 2);
- n ++;
-#endif
-#ifdef DEBUG_BIND_TEXTURE
- place(0, n, mBindsLabel, 2);
-#endif
-#endif
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- setDimension(Rect(0, 0, 600, 300));
-}
-
-void MapDebugTab::logic()
-{
- BLOCK_START("MapDebugTab::logic")
- if (player_node)
- {
- // TRANSLATORS: debug window label
- mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"),
- player_node->getTileX(), player_node->getTileY()));
- }
- else
- {
- // TRANSLATORS: debug window label
- mXYLabel->setCaption(strprintf("%s (?, ?)", _("Player Position:")));
- }
-
- const Map *const map = Game::instance()->getCurrentMap();
- if (map && viewport)
- {
- // Get the current mouse position
- const int mouseTileX = (viewport->getMouseX() + viewport->getCameraX())
- / map->getTileWidth();
- const int mouseTileY = (viewport->getMouseY() + viewport->getCameraY())
- / map->getTileHeight();
- mTileMouseLabel->setCaption(strprintf("%s (%d, %d)",
- // TRANSLATORS: debug window label
- _("Cursor:"), mouseTileX, mouseTileY));
-
- // TRANSLATORS: debug window label
- mMusicFileLabel->setCaption(strprintf("%s %s", _("Music:"),
- map->getProperty("music").c_str()));
- // TRANSLATORS: debug window label
- mMinimapLabel->setCaption(strprintf("%s %s", _("Minimap:"),
- map->getProperty("minimap").c_str()));
- // TRANSLATORS: debug window label
- mMapLabel->setCaption(strprintf("%s %s", _("Map:"),
- map->getProperty("_realfilename").c_str()));
-
-
- if (mUpdateTime != cur_time)
- {
- mUpdateTime = cur_time;
- // TRANSLATORS: debug window label
- mParticleCountLabel->setCaption(strprintf(_("Particle count: %d"),
- Particle::particleCount));
-
- mMapActorCountLabel->setCaption(
- // TRANSLATORS: debug window label
- strprintf("%s %d", _("Map actors count:"),
- map->getActorsCount()));
-#ifdef USE_OPENGL
-#ifdef DEBUG_OPENGL_LEAKS
- mTexturesLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Textures count:"), textures_count));
-#endif
-#ifdef DEBUG_DRAW_CALLS
- if (mainGraphics)
- {
- mDrawCallsLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Draw calls:"), mainGraphics->getDrawCalls()));
- }
-#endif
-#ifdef DEBUG_BIND_TEXTURE
- if (mainGraphics)
- {
- mBindsLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Texture binds:"), mainGraphics->getBinds()));
- }
-#endif
-#endif
- }
- }
- else
- {
- // TRANSLATORS: debug window label
- mTileMouseLabel->setCaption(strprintf("%s (?, ?)", _("Cursor:")));
- // TRANSLATORS: debug window label
- mMusicFileLabel->setCaption(strprintf("%s ?", _("Music:")));
- // TRANSLATORS: debug window label
- mMinimapLabel->setCaption(strprintf("%s ?", _("Minimap:")));
- // TRANSLATORS: debug window label
- mMapLabel->setCaption(strprintf("%s ?", _("Map:")));
-
- mMapActorCountLabel->setCaption(
- // TRANSLATORS: debug window label
- strprintf("%s ?", _("Map actors count:")));
- }
-
- mMapActorCountLabel->adjustSize();
- mParticleCountLabel->adjustSize();
-
- mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps));
- // TRANSLATORS: debug window label, logic per second
- mLPSLabel->setCaption(strprintf(_("%d LPS"), lps));
- BLOCK_END("MapDebugTab::logic")
-}
-
-TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
- DebugTab(widget),
- // TRANSLATORS: debug window label
- mTargetLabel(new Label(this, strprintf("%s ?", _("Target:")))),
- // TRANSLATORS: debug window label
- mTargetIdLabel(new Label(this, strprintf("%s ? ", _("Target Id:")))),
- mTargetTypeLabel(new Label(this, strprintf(
- // TRANSLATORS: debug window label
- "%s ? ", _("Target type:")))),
- // TRANSLATORS: debug window label
- mTargetLevelLabel(new Label(this, strprintf("%s ?", _("Target level:")))),
- // TRANSLATORS: debug window label
- mTargetRaceLabel(new Label(this, strprintf("%s ?", _("Target race:")))),
- // TRANSLATORS: debug window label
- mTargetPartyLabel(new Label(this, strprintf("%s ?", _("Target party:")))),
- // TRANSLATORS: debug window label
- mTargetGuildLabel(new Label(this, strprintf("%s ?", _("Target guild:")))),
- // TRANSLATORS: debug window label
- mAttackDelayLabel(new Label(this, strprintf("%s ?", _("Attack delay:")))),
- // TRANSLATORS: debug window label
- mMinHitLabel(new Label(this, strprintf("%s ?", _("Minimal hit:")))),
- // TRANSLATORS: debug window label
- mMaxHitLabel(new Label(this, strprintf("%s ?", _("Maximum hit:")))),
- // TRANSLATORS: debug window label
- mCriticalHitLabel(new Label(this, strprintf("%s ?", _("Critical hit:"))))
-{
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mTargetLabel, 2);
- place(0, 1, mTargetIdLabel, 2);
- place(0, 2, mTargetTypeLabel, 2);
- place(0, 3, mTargetLevelLabel, 2);
- place(0, 4, mTargetRaceLabel, 2);
- place(0, 5, mAttackDelayLabel, 2);
- place(0, 6, mTargetPartyLabel, 2);
- place(0, 7, mTargetGuildLabel, 2);
- place(0, 8, mMinHitLabel, 2);
- place(0, 9, mMaxHitLabel, 2);
- place(0, 10, mCriticalHitLabel, 2);
-
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- setDimension(Rect(0, 0, 600, 300));
-}
-
-void TargetDebugTab::logic()
-{
- BLOCK_START("TargetDebugTab::logic")
- if (player_node && player_node->getTarget())
- {
- const Being *const target = player_node->getTarget();
-
- // TRANSLATORS: debug window label
- mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"),
- target->getName().c_str(), target->getTileX(),
- target->getTileY()));
-
- mTargetIdLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Target Id:"), target->getId()));
- mTargetTypeLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Target type:"), target->getSubType()));
- if (target->getLevel())
- {
- mTargetLevelLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Target Level:"), target->getLevel()));
- }
- else
- {
- mTargetLevelLabel->setCaption(strprintf("%s ?",
- // TRANSLATORS: debug window label
- _("Target Level:")));
- }
-
- mTargetRaceLabel->setCaption(strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Target race:"), target->getRaceName().c_str()));
-
- // TRANSLATORS: debug window label
- mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"),
- target->getPartyName().c_str()));
-
- // TRANSLATORS: debug window label
- mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"),
- target->getGuildName().c_str()));
-
- mMinHitLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Minimal hit:"), target->getMinHit()));
- mMaxHitLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Maximum hit:"), target->getMaxHit()));
- mCriticalHitLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Critical hit:"), target->getCriticalHit()));
-
- const int delay = target->getAttackDelay();
- if (delay)
- {
- mAttackDelayLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Attack delay:"), delay));
- }
- else
- {
- mAttackDelayLabel->setCaption(strprintf(
- // TRANSLATORS: debug window label
- "%s ?", _("Attack delay:")));
- }
- }
- else
- {
- // TRANSLATORS: debug window label
- mTargetLabel->setCaption(strprintf("%s ?", _("Target:")));
- // TRANSLATORS: debug window label
- mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:")));
- // TRANSLATORS: debug window label
- mTargetTypeLabel->setCaption(strprintf("%s ?", _("Target type:")));
- // TRANSLATORS: debug window label
- mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:")));
- // TRANSLATORS: debug window label
- mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:")));
- // TRANSLATORS: debug window label
- mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:")));
- // TRANSLATORS: debug window label
- mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:")));
- // TRANSLATORS: debug window label
- mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:")));
- // TRANSLATORS: debug window label
- mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:")));
- // TRANSLATORS: debug window label
- mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:")));
- }
-
- mTargetLabel->adjustSize();
- mTargetIdLabel->adjustSize();
- mTargetTypeLabel->adjustSize();
- mTargetLevelLabel->adjustSize();
- mTargetPartyLabel->adjustSize();
- mTargetGuildLabel->adjustSize();
- mAttackDelayLabel->adjustSize();
- BLOCK_END("TargetDebugTab::logic")
-}
-
-NetDebugTab::NetDebugTab(const Widget2 *const widget) :
- DebugTab(widget),
- mPingLabel(new Label(this, " ")),
- mInPackets1Label(new Label(this, " ")),
- mOutPackets1Label(new Label(this, " "))
-{
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mPingLabel, 2);
- place(0, 1, mInPackets1Label, 2);
- place(0, 2, mOutPackets1Label, 2);
-
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- setDimension(Rect(0, 0, 600, 300));
-}
-
-void NetDebugTab::logic()
-{
- BLOCK_START("NetDebugTab::logic")
- if (player_node)
- {
- // TRANSLATORS: debug window label
- mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
- player_node->getPingTime().c_str()));
- }
- else
- {
- // TRANSLATORS: debug window label
- mPingLabel->setCaption(strprintf(_("Ping: %s ms"), "0"));
- }
- // TRANSLATORS: debug window label
- mInPackets1Label->setCaption(strprintf(_("In: %d bytes/s"),
- PacketCounters::getInBytes()));
- // TRANSLATORS: debug window label
- mOutPackets1Label->setCaption(strprintf(_("Out: %d bytes/s"),
- PacketCounters::getOutBytes()));
- BLOCK_END("NetDebugTab::logic")
-}
diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h
index 1a56f3164..79f0f30e6 100644
--- a/src/gui/windows/debugwindow.h
+++ b/src/gui/windows/debugwindow.h
@@ -27,101 +27,10 @@
#include "gui/widgets/window.h"
class Label;
+class MapDebugTab;
+class NetDebugTab;
class TabbedArea;
-
-class DebugTab : public Container
-{
- friend class DebugWindow;
-
- public:
- A_DELETE_COPY(DebugTab)
-
- void logic() override
- {
- }
-
- void resize(const int x, const int y)
- { setDimension(Rect(0, 0, x, y)); }
-
- protected:
- explicit DebugTab(const Widget2 *const widget) :
- Container(widget)
- { }
-};
-
-class MapDebugTab final : public DebugTab
-{
- friend class DebugWindow;
-
- public:
- explicit MapDebugTab(const Widget2 *const widget);
-
- A_DELETE_COPY(MapDebugTab)
-
- void logic() override final;
-
- private:
- Label *mMusicFileLabel;
- Label *mMapLabel;
- Label *mMinimapLabel;
- Label *mTileMouseLabel;
- Label *mParticleCountLabel;
- Label *mMapActorCountLabel;
- Label *mXYLabel;
- Label *mTexturesLabel;
- int mUpdateTime;
-#ifdef DEBUG_DRAW_CALLS
- Label *mDrawCallsLabel;
-#endif
-#ifdef DEBUG_BIND_TEXTURE
- Label *mBindsLabel;
-#endif
- Label *mFPSLabel;
- Label *mLPSLabel;
- std::string mFPSText;
-};
-
-class TargetDebugTab final : public DebugTab
-{
- friend class DebugWindow;
-
- public:
- explicit TargetDebugTab(const Widget2 *const widget);
-
- A_DELETE_COPY(TargetDebugTab)
-
- void logic() override final;
-
- private:
- Label *mTargetLabel;
- Label *mTargetIdLabel;
- Label *mTargetTypeLabel;
- Label *mTargetLevelLabel;
- Label *mTargetRaceLabel;
- Label *mTargetPartyLabel;
- Label *mTargetGuildLabel;
- Label *mAttackDelayLabel;
- Label *mMinHitLabel;
- Label *mMaxHitLabel;
- Label *mCriticalHitLabel;
-};
-
-class NetDebugTab final : public DebugTab
-{
- friend class DebugWindow;
-
- public:
- explicit NetDebugTab(const Widget2 *const widget);
-
- A_DELETE_COPY(NetDebugTab)
-
- void logic() override final;
-
- private:
- Label *mPingLabel;
- Label *mInPackets1Label;
- Label *mOutPackets1Label;
-};
+class TargetDebugTab;
/**
* The debug window.