00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "gui/debugwindow.h"
00023
00024 #include "gui/viewport.h"
00025
00026 #include "gui/widgets/label.h"
00027 #include "gui/widgets/layout.h"
00028
00029 #include "engine.h"
00030 #include "game.h"
00031 #include "particle.h"
00032 #include "map.h"
00033
00034 #include "utils/stringutils.h"
00035
00036 DebugWindow::DebugWindow():
00037 Window("Debug")
00038 {
00039 setWindowName("Debug");
00040
00041 setResizable(true);
00042 setCloseButton(true);
00043 setSaveVisible(true);
00044 setDefaultSize(400, 100, ImageRect::CENTER);
00045
00046 mFPSLabel = new Label("0 FPS");
00047 mMusicFileLabel = new Label("Music: ");
00048 mMapLabel = new Label("Map: ");
00049 mMiniMapLabel = new Label("Mini-Map: ");
00050 mTileMouseLabel = new Label("Mouse: 0, 0");
00051 mParticleCountLabel = new Label("Particle count: 0");
00052
00053 place(0, 0, mFPSLabel, 3);
00054 place(3, 0, mTileMouseLabel);
00055 place(0, 1, mMusicFileLabel, 3);
00056 place(3, 1, mParticleCountLabel);
00057 place(0, 2, mMapLabel, 4);
00058 place(0, 3, mMiniMapLabel, 4);
00059
00060 loadWindowState();
00061 }
00062
00063 void DebugWindow::logic()
00064 {
00065 if (!isVisible())
00066 return;
00067
00068
00069 int mouseTileX = (viewport->getMouseX() + viewport->getCameraX()) / 32;
00070 int mouseTileY = (viewport->getMouseY() + viewport->getCameraY()) / 32;
00071
00072 mFPSLabel->setCaption(toString(fps) + " FPS");
00073
00074 mTileMouseLabel->setCaption("Tile: (" + toString(mouseTileX) + ", " +
00075 toString(mouseTileY) + ")");
00076
00077 Map *currentMap = engine->getCurrentMap();
00078 if (currentMap)
00079 {
00080 const std::string music =
00081 "Music: " + currentMap->getProperty("music");
00082 mMusicFileLabel->setCaption(music);
00083
00084 const std::string minimap =
00085 "MiniMap: " + currentMap->getProperty("minimap");
00086 mMiniMapLabel->setCaption(minimap);
00087
00088 const std::string map =
00089 "Map: " + currentMap->getProperty("_filename");
00090 mMapLabel->setCaption(map);
00091 }
00092
00093 mParticleCountLabel->setCaption("Particle count: " +
00094 toString(Particle::particleCount));
00095 }