diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-10-09 21:34:58 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-10-09 21:34:58 +0000 |
commit | 31047c05a9b56c101566301d81931c66bc4b9ecd (patch) | |
tree | 8646f4383a0297732e76227bc601cd0f80ec5151 | |
parent | 2327c5a7c3b054e52b69286da906f8e5c4432d1c (diff) | |
download | mana-31047c05a9b56c101566301d81931c66bc4b9ecd.tar.gz mana-31047c05a9b56c101566301d81931c66bc4b9ecd.tar.bz2 mana-31047c05a9b56c101566301d81931c66bc4b9ecd.tar.xz mana-31047c05a9b56c101566301d81931c66bc4b9ecd.zip |
Corrected the white browser font bug and the black hp/mp bug which were linked. Added a debug window.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/engine.cpp | 15 | ||||
-rw-r--r-- | src/game.cpp | 27 | ||||
-rw-r--r-- | src/gui/browserbox.cpp | 1 | ||||
-rw-r--r-- | src/gui/debugwindow.cpp | 115 | ||||
-rw-r--r-- | src/gui/debugwindow.h | 73 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 4 |
8 files changed, 224 insertions, 20 deletions
@@ -1,3 +1,10 @@ +2005-10-09 Yohann Ferreira <bertram@cegetel.net> + + * ChangeLog, src/gui/browserbox.cpp, src/gui/ministatus.cpp, + src/gui/debugwindow.h, src/gui/debugwindow.cpp, src/game.cpp, + src/engine.cpp, src/Makefile.am: Corrected the white browser font + bug and the black hp/mp bug which were linked. Added a debug window + 2005-10-09 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/being.cpp, src/being.h, src/engine.cpp, src/engine.h, diff --git a/src/Makefile.am b/src/Makefile.am index bef31080..1284e7bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,8 @@ tmw_SOURCES = graphic/spriteset.cpp \ gui/checkbox.h \ gui/confirm_dialog.cpp \ gui/confirm_dialog.h \ + gui/debugwindow.cpp \ + gui/debugwindow.h \ gui/equipmentwindow.cpp \ gui/equipmentwindow.h \ gui/error.cpp \ diff --git a/src/engine.cpp b/src/engine.cpp index 2175096d..ef5d8a7a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -286,20 +286,5 @@ void Engine::draw() (*i)->drawSpeech(graphics, -map_x, -map_y); } -#ifdef DEBUG - std::stringstream debugStream; - debugStream << "[" << fps << " fps] " << mouseTileX << ", " << mouseTileY; - - if (mCurrentMap != NULL) - { - debugStream - << " [music: " << mCurrentMap->getProperty("music") << "]" - << " [minimap: " << mCurrentMap->getProperty("minimap") << "]"; - } - - debugInfo->setCaption(debugStream.str()); - debugInfo->adjustSize(); -#endif - gui->draw(); } diff --git a/src/game.cpp b/src/game.cpp index bc256b7c..8b952ebd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -68,6 +68,10 @@ #include "gui/ministatus.h" #include "gui/trade.h" +#ifdef DEBUG +#include "gui/debugwindow.h" +#endif + #include "net/messagein.h" #include "net/messageout.h" #include "net/network.h" @@ -116,6 +120,9 @@ TradeWindow *tradeWindow; //BuddyWindow *buddyWindow; HelpWindow *helpWindow; PopupMenu *popupMenu; +#ifdef DEBUG +DebugWindow *debugWindow; +#endif Inventory *inventory = NULL; @@ -216,7 +223,9 @@ void createGuiWindows() //buddyWindow = new BuddyWindow(); helpWindow = new HelpWindow(); popupMenu = new PopupMenu(); - +#ifdef DEBUG + debugWindow = new DebugWindow(); +#endif // Initialize window positions int screenW = graphics->getWidth(); int screenH = graphics->getHeight(); @@ -250,7 +259,9 @@ void createGuiWindows() //buddyWindow->setVisible(false); helpWindow->setVisible(false); popupMenu->setVisible(false); - +#ifdef DEBUG + debugWindow->setVisible(true); +#endif // Do not focus any text field gui->focusNone(); } @@ -280,6 +291,9 @@ void destroyGuiWindows() //delete buddyWindow; delete helpWindow; delete popupMenu; +#ifdef DEBUG + delete debugWindow; +#endif } void do_init() @@ -635,7 +649,14 @@ void do_input() setupWindow->requestMoveToTop(); used = true; break; - +#ifdef DEBUG + // Debug window + case SDLK_d: + debugWindow->setVisible(!debugWindow->isVisible()); + if (debugWindow->isVisible()) debugWindow->requestMoveToTop(); + used = true; + break; +#endif // screenshot (picture, hence the p) case SDLK_p: { diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 23da7225..9a8aed34 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -251,6 +251,7 @@ void BrowserBox::draw(gcn::Graphics* graphics) unsigned int i, j; int x = 0, y = 0; int wrappedLines = 0; + graphics->setColor(BLACK); for (i = 0; i < mTextRows.size(); i++) { int selColor = BLACK; diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp new file mode 100644 index 00000000..3823ab6a --- /dev/null +++ b/src/gui/debugwindow.cpp @@ -0,0 +1,115 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "debugwindow.h" + +#include <guichan/widgets/label.hpp> +#include "button.h" +#include <sstream> +#include "minimap.h" +#include "../game.h" +#include "../graphics.h" +#include "../engine.h" +extern Graphics *graphics; +extern Minimap *minimap; +extern int frame; + +DebugWindow::DebugWindow(): + Window("Debug") +{ + setWindowName("Debug"); + + setResizable(true); + setDefaultSize(0, 0, 400, 100); + loadWindowState(); + + FPSLabel = new gcn::Label("[0 FPS]"); + FPSLabel->setPosition(0,0); + musicFileLabel = new gcn::Label("Music File: "); + musicFileLabel->setPosition(0, 20); + mapFileLabel = new gcn::Label("Mini-Map File: "); + mapFileLabel->setPosition(0, 40); + tileMouseLabel = new gcn::Label("[Mouse: 0, 0]"); + tileMouseLabel->setPosition(100, 0); + closeButton = new Button("Close"); + closeButton->setEventId("close"); + closeButton->setPosition(5, 60); + closeButton->addActionListener(this); + + add(FPSLabel); + add(musicFileLabel); + add(mapFileLabel); + add(tileMouseLabel); + add(closeButton); +} + +DebugWindow::~DebugWindow() +{ + delete FPSLabel; + delete musicFileLabel; + delete mapFileLabel; + delete tileMouseLabel; + delete closeButton; +} + +void DebugWindow::logic() +{ + // Get the current mouse position + int mouseX, mouseY; + SDL_GetMouseState(&mouseX, &mouseY); + int mouseTileX = mouseX / 32 + camera_x; + int mouseTileY = mouseY / 32 + camera_y; + +std::stringstream updatedText; + updatedText << "[" << fps << " FPS]"; + FPSLabel->setCaption(updatedText.str()); + FPSLabel->adjustSize(); + + updatedText.str(""); + updatedText << "[Mouse: " << mouseTileX << ", " << mouseTileY << "]"; + tileMouseLabel->setCaption(updatedText.str()); + tileMouseLabel->adjustSize(); + + updatedText.str(""); + mCurrentMap = engine->getCurrentMap(); + if (mCurrentMap != NULL) + { + updatedText + << " [Music File: " << mCurrentMap->getProperty("music") << "]"; + musicFileLabel->setCaption(updatedText.str()); + musicFileLabel->adjustSize(); + updatedText.str(""); + updatedText + << " [MiniMap File: " << mCurrentMap->getProperty("minimap") << "]"; + mapFileLabel->setCaption(updatedText.str()); + mapFileLabel->adjustSize(); + } +} + +void DebugWindow::action(const std::string& eventId) +{ + if (eventId == "close") + { + setVisible(false); + } +} diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h new file mode 100644 index 00000000..f2efc31c --- /dev/null +++ b/src/gui/debugwindow.h @@ -0,0 +1,73 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_DEBUGWINDOW_H +#define _TMW_DEBUGWINDOW_H + +#include <string> + +#include <guichan/actionlistener.hpp> + +#include "window.h" +#include "map.h" +#include "../guichanfwd.h" + +/** + * The chat window. + * + * \ingroup Interface + */ +class DebugWindow : public Window, public gcn::ActionListener +{ + public: + /** + * Constructor. + */ + DebugWindow(); + + /** + * Destructor. + */ + ~DebugWindow(); + + /** + * Logic (updates components' size and infos) + */ + void logic(); + + /** + * Performs action. + */ + void action(const std::string &actionId); + + private: + gcn::Label *musicFileLabel, *mapFileLabel; + gcn::Label *tileMouseLabel, *FPSLabel; + gcn::Button *closeButton; + Map *mCurrentMap; + +}; + +extern DebugWindow *debugWindow; + +#endif diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 438470d8..9d423a7e 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -50,10 +50,10 @@ MiniStatusWindow::MiniStatusWindow(): hpLabel = new gcn::Label(""); mpLabel = new gcn::Label(""); + hpLabel->setForegroundColor(gcn::Color(255, 255, 255)); + mpLabel->setForegroundColor(gcn::Color(255, 255, 255)); hpLabel->setFont(speechFont); mpLabel->setFont(speechFont); - hpLabel->setForegroundColor(gcn::Color(255,255,255)); - mpLabel->setForegroundColor(gcn::Color(255,255,255)); add(hpBar); add(mpBar); |