summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2011-05-20 17:26:29 +0200
committerStefan Dombrowski <stefan@uni-bonn.de>2011-05-20 17:26:29 +0200
commitf971e8903ae6e7f01adb7b2f252c6482fa258ebb (patch)
treedfafbd86d028515cdda0f77f77f11d14eeba6f1f /src
parent108c31241aa8074dba1b1042677b3c87f60a9600 (diff)
downloadmana-f971e8903ae6e7f01adb7b2f252c6482fa258ebb.tar.gz
mana-f971e8903ae6e7f01adb7b2f252c6482fa258ebb.tar.bz2
mana-f971e8903ae6e7f01adb7b2f252c6482fa258ebb.tar.xz
mana-f971e8903ae6e7f01adb7b2f252c6482fa258ebb.zip
Removing KEY_PATHFIND and moving its function into the debug window
* The f-key is no longer used. That means new players are less likely to get into trouble by accidentally activating the debug mode. * The debug mode can now be activated in a new tab in the debug window. * The main advantage of using a gui is its extensibility. At the moment the debug mode does show too much information at once. In a follow-up patch the user should get more choices. Reviewed-by: Bjorn
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp5
-rw-r--r--src/gui/debugwindow.cpp216
-rw-r--r--src/gui/debugwindow.h15
-rw-r--r--src/gui/viewport.cpp10
-rw-r--r--src/gui/viewport.h4
-rw-r--r--src/keyboardconfig.cpp1
-rw-r--r--src/keyboardconfig.h1
7 files changed, 154 insertions, 98 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 16ea45d6..ef930d92 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -722,11 +722,6 @@ void Game::handleInput()
saveScreenshot();
used = true;
break;
- case KeyboardConfig::KEY_PATHFIND:
- // Find path to mouse (debug purpose)
- viewport->toggleDebugPath();
- used = true;
- break;
case KeyboardConfig::KEY_TRADE:
// Toggle accepting of incoming trade requests
unsigned int deflt = player_relations.getDefault();
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 2ad0ba4a..bd69437d 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -24,102 +24,184 @@
#include "client.h"
#include "game.h"
#include "particle.h"
-#include "main.h"
#include "map.h"
#include "gui/setup.h"
-#include "gui/setup_video.h"
#include "gui/viewport.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
+#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/radiobutton.h"
+#include "gui/widgets/tab.h"
+#include "gui/widgets/tabbedarea.h"
#include "resources/image.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
-DebugWindow::DebugWindow():
- Window(_("Debug"))
-{
- setWindowName("Debug");
- setupWindow->registerWindowForReset(this);
-
- setResizable(true);
- setCloseButton(true);
- setSaveVisible(true);
- setDefaultSize(400, 100, ImageRect::CENTER);
+class DebugInfo : public Container
+{
+public:
+ DebugInfo()
+ {
#ifdef USE_OPENGL
- if (Image::getLoadAsOpenGL())
+ if (Image::getLoadAsOpenGL())
+ {
+ mFPSText = _("%d FPS (OpenGL)");
+ }
+ else
+#endif
+ {
+ mFPSText = _("%d FPS");
+ }
+
+ mFPSLabel = new Label("");
+ mMusicFileLabel = new Label("");
+ mMapLabel = new Label("");
+ mMinimapLabel = new Label("");
+ mTileMouseLabel = new Label("");
+ mParticleCountLabel = new Label("");
+
+ LayoutHelper h = (this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+
+ place(0, 0, mFPSLabel, 1);
+ place(0, 1, mMusicFileLabel, 1);
+ place(0, 2, mMapLabel, 1);
+ place(0, 3, mMinimapLabel, 1);
+ place(0, 4, mTileMouseLabel, 1);
+ place(0, 5, mParticleCountLabel, 1);
+
+ h.reflowLayout(0, 0);
+ }
+
+ void logic()
{
- mFPSText = _("%d FPS (OpenGL)");
+ if (!isVisible())
+ return;
+
+ mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps));
+
+ if (const Map *map = Game::instance()->getCurrentMap())
+ {
+ // 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(_("Cursor: (%d, %d)"),
+ mouseTileX, mouseTileY));
+
+ mMusicFileLabel->setCaption(strprintf(
+ _("Music: %s"), map->getProperty("music").c_str()));
+ mMinimapLabel->setCaption(strprintf(_("Minimap: %s"),
+ map->getProperty("minimap").c_str()));
+ mMapLabel->setCaption(strprintf(_("Map: %s"),
+ map->getProperty("_filename").c_str()));
+ }
+
+ mParticleCountLabel->setCaption(strprintf(_("Particle count: %d"),
+ Particle::particleCount));
+
+ mFPSLabel->adjustSize();
+ mMusicFileLabel->adjustSize();
+ mMapLabel->adjustSize();
+ mMinimapLabel->adjustSize();
+ mTileMouseLabel->adjustSize();
+ mParticleCountLabel->adjustSize();
}
- else
-#endif
+
+private:
+ std::string mFPSText;
+ Label *mFPSLabel;
+ Label *mMusicFileLabel;
+ Label *mMapLabel;
+ Label *mMinimapLabel;
+ Label *mTileMouseLabel;
+ Label *mParticleCountLabel;
+};
+
+class DebugSwitches : public Container, public gcn::ActionListener
+{
+public:
+ DebugSwitches()
{
- mFPSText = _("%d FPS");
+ mapNormal = new RadioButton(_("Normal"), "mapdebug");
+ mapDebug = new RadioButton(_("Debug"), "mapdebug");
+ mapSpecial = new RadioButton(_("Special"), "mapdebug");
+ mapSpecial2 = new RadioButton(_("Special 2"), "mapdebug");
+ mapSpecial3 = new RadioButton(_("Special 3"), "mapdebug");
+
+ LayoutHelper h = (this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+
+ place(0, 0, mapNormal, 1);
+ place(0, 1, mapDebug, 1);
+ place(0, 2, mapSpecial, 1);
+ place(0, 3, mapSpecial2, 1);
+ place(0, 4, mapSpecial3, 1);
+
+ h.reflowLayout(0, 0);
+
+ mapNormal->setSelected(true);
+
+ mapNormal->addActionListener(this);
+ mapDebug->addActionListener(this);
+ mapSpecial->addActionListener(this);
+ mapSpecial2->addActionListener(this);
+ mapSpecial3->addActionListener(this);
}
- mFPSLabel = new Label(strprintf(_("%d FPS"), 0));
- mMusicFileLabel = new Label(strprintf(_("Music: %s"), ""));
- mMapLabel = new Label(strprintf(_("Map: %s"), ""));
- mMinimapLabel = new Label(strprintf(_("Minimap: %s"), ""));
- mTileMouseLabel = new Label(strprintf(_("Cursor: (%d, %d)"), 0, 0));
- mParticleCountLabel = new Label(strprintf(_("Particle count: %d"), 88888));
- mParticleDetailLabel = new Label();
- mAmbientDetailLabel = new Label();
-
- place(0, 0, mFPSLabel, 3);
- place(3, 0, mTileMouseLabel);
- place(0, 1, mMusicFileLabel, 3);
- place(3, 1, mParticleCountLabel);
- place(0, 2, mMapLabel, 4);
- place(3, 2, mParticleDetailLabel);
- place(0, 3, mMinimapLabel, 4);
- place(3, 3, mAmbientDetailLabel);
+ void action(const gcn::ActionEvent &event)
+ {
+ if (mapNormal->isSelected())
+ viewport->setShowDebugPath(Map::MAP_NORMAL);
+ else if (mapDebug->isSelected())
+ viewport->setShowDebugPath(Map::MAP_DEBUG);
+ else if (mapSpecial->isSelected())
+ viewport->setShowDebugPath(Map::MAP_SPECIAL);
+ else if (mapSpecial2->isSelected())
+ viewport->setShowDebugPath(Map::MAP_SPECIAL2);
+ else if (mapSpecial3->isSelected())
+ viewport->setShowDebugPath(Map::MAP_SPECIAL3);
+ }
- loadWindowState();
-}
+private:
+ RadioButton *mapNormal;
+ RadioButton *mapDebug;
+ RadioButton *mapSpecial;
+ RadioButton *mapSpecial2;
+ RadioButton *mapSpecial3;
+};
-void DebugWindow::logic()
+DebugWindow::DebugWindow():
+ Window(_("Debug"))
{
- if (!isVisible())
- return;
+ setupWindow->registerWindowForReset(this);
- mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps));
+ setResizable(true);
+ setCloseButton(true);
- if (const Map *map = Game::instance()->getCurrentMap())
- {
- // Get the current mouse position
- int mouseTileX = (viewport->getMouseX() + viewport->getCameraX())
- / map->getTileWidth();
- int mouseTileY = (viewport->getMouseY() + viewport->getCameraY())
- / map->getTileHeight();
- mTileMouseLabel->setCaption(strprintf(_("Cursor: (%d, %d)"),
- mouseTileX,
- mouseTileY));
-
- mMusicFileLabel->setCaption(strprintf(
- _("Music: %s"), map->getProperty("music").c_str()));
- mMinimapLabel->setCaption(
- strprintf(_("Minimap: %s"), map->getProperty("minimap").c_str()));
- mMapLabel->setCaption(
- strprintf(_("Map: %s"), map->getProperty("_filename").c_str()));
- }
+ setMinWidth(100);
+ setMinHeight(100);
+ setDefaultSize(0, 120, 300, 180);
- mParticleCountLabel->setCaption(strprintf(_("Particle count: %d"),
- Particle::particleCount));
+ loadWindowState();
- mParticleCountLabel->adjustSize();
+ TabbedArea *mTabs = new TabbedArea;
- mParticleDetailLabel->setCaption(strprintf(_("Particle detail: %s"),
- Setup_Video::particleDetailToString()));
+ place(0, 0, mTabs, 2, 2);
- mParticleDetailLabel->adjustSize();
+ widgetResized(NULL);
- mAmbientDetailLabel->setCaption(strprintf(_("Ambient FX: %s"),
- Setup_Video::overlayDetailToString()));
+ Tab *tabInfo = new Tab();
+ tabInfo->setCaption("Info");
+ mTabs->addTab(tabInfo, new DebugInfo);
- mAmbientDetailLabel->adjustSize();
+ Tab *tabSwitches = new Tab();
+ tabSwitches->setCaption("Switches");
+ mTabs->addTab(tabSwitches, new DebugSwitches);
}
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index 6fd34420..800d0129 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -24,8 +24,6 @@
#include "gui/widgets/window.h"
-class Label;
-
/**
* The debug window.
*
@@ -35,19 +33,6 @@ class DebugWindow : public Window
{
public:
DebugWindow();
-
- /**
- * Logic (updates components' size and infos)
- */
- void logic();
-
- private:
- Label *mMusicFileLabel, *mMapLabel, *mMinimapLabel;
- Label *mTileMouseLabel, *mFPSLabel;
- Label *mParticleCountLabel, *mParticleDetailLabel;
- Label *mAmbientDetailLabel;
-
- std::string mFPSText;
};
extern DebugWindow *debugWindow;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index cc316e88..427b539f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -583,15 +583,11 @@ void Viewport::updateCursorType()
}
}
-void Viewport::toggleDebugPath()
+void Viewport::setShowDebugPath(int debugFlags)
{
- mShowDebugPath++;
- if (mShowDebugPath > Map::MAP_SPECIAL3)
- mShowDebugPath = Map::MAP_NORMAL;
+ mShowDebugPath = debugFlags;
if (mMap)
- {
- mMap->setDebugFlags(mShowDebugPath);
- }
+ mMap->setDebugFlags(debugFlags);
}
void Viewport::hideBeingPopup()
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index d8687219..0725e505 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -77,9 +77,9 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void logic();
/**
- * Toggles whether the path debug graphics are shown
+ * Sets whether the path debug graphics are shown
*/
- void toggleDebugPath();
+ void setShowDebugPath(int debugFlags);
/**
* Handles mouse press on map.
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 08ee8896..61e7571a 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -53,7 +53,6 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyBeingSit", SDLK_s, _("Sit")},
{"keyScreenshot", SDLK_p, _("Screenshot")},
{"keyTrade", SDLK_r, _("Enable/Disable Trading")},
- {"keyPathfind", SDLK_f, _("Find Path to Mouse")},
{"keyShortcut1", SDLK_1, strprintf(_("Item Shortcut %d"), 1)},
{"keyShortcut2", SDLK_2, strprintf(_("Item Shortcut %d"), 2)},
{"keyShortcut3", SDLK_3, strprintf(_("Item Shortcut %d"), 3)},
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index f4cf7751..aaeb82a2 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -169,7 +169,6 @@ class KeyboardConfig
KEY_SIT,
KEY_SCREENSHOT,
KEY_TRADE,
- KEY_PATHFIND,
KEY_SHORTCUT_1,
KEY_SHORTCUT_2,
KEY_SHORTCUT_3,