From a9716272cd2b5720a88f3d6904ec0f156177266d Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 9 Jan 2009 13:22:30 -0700 Subject: Fixed minimap state saving. Signed-off-by: Ira Rice --- src/game.cpp | 35 ++++++++++++++--------------------- src/gui/minimap.cpp | 17 ++++++++++++++++- src/gui/minimap.h | 6 ++++++ 3 files changed, 36 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index da733fe3..18169cd0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -30,7 +30,6 @@ #include #include "beingmanager.h" -#include "configuration.h" #include "effectmanager.h" #include "engine.h" #include "flooritemmanager.h" @@ -91,6 +90,8 @@ #include "resources/imagewriter.h" +#include "utils/gettext.h" + extern Graphics *graphics; class Map; @@ -125,7 +126,6 @@ Setup* setupWindow; Minimap *minimap; EquipmentWindow *equipmentWindow; TradeWindow *tradeWindow; -//BuddyWindow *buddyWindow; HelpWindow *helpWindow; DebugWindow *debugWindow; ShortcutWindow *itemShortcutWindow; @@ -210,15 +210,11 @@ void createGuiWindows(Network *network) minimap = new Minimap(); equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); tradeWindow = new TradeWindow(network); - //buddyWindow = new BuddyWindow(); helpWindow = new HelpWindow(); debugWindow = new DebugWindow(); itemShortcutWindow = new ShortcutWindow("ItemShortcut",new ItemShortcutContainer); smileyShortcutWindow = new ShortcutWindow("SmileyShortcut",new SmileyShortcutContainer); - // Initialize window positions - //buddyWindow->setPosition(10, minimap->getHeight() + 30); - // Set initial window visibility chatWindow->setVisible((bool) config.getValue( chatWindow->getWindowName() + "Visible", true)); @@ -226,8 +222,6 @@ void createGuiWindows(Network *network) miniStatusWindow->getWindowName() + "Visible", true)); buyDialog->setVisible(false); sellDialog->setVisible(false); - minimap->setVisible((bool) config.getValue( - minimap->getWindowName() + "Visible", true)); tradeWindow->setVisible(false); menuWindow->setVisible((bool) config.getValue( menuWindow->getWindowName() + "Visible", true)); @@ -264,7 +258,6 @@ void destroyGuiWindows() delete minimap; delete equipmentWindow; delete tradeWindow; - //delete buddyWindow; delete helpWindow; delete debugWindow; delete itemShortcutWindow; @@ -390,13 +383,13 @@ static bool saveScreenshot() if (success) { std::stringstream chatlogentry; - chatlogentry << "Screenshot saved to ~/" << filenameSuffix.str(); + chatlogentry << _("Screenshot saved to ~/") << filenameSuffix.str(); chatWindow->chatLog(chatlogentry.str(), BY_SERVER); } else { - chatWindow->chatLog("Saving screenshot failed!", BY_SERVER); - logger->log("Error: could not save screenshot."); + chatWindow->chatLog(_("Saving screenshot failed!"), BY_SERVER); + logger->log(_("Error: could not save screenshot.")); } SDL_FreeSurface(screenshot); @@ -471,9 +464,8 @@ void Game::logic() { if (!disconnectedDialog) { - disconnectedDialog = new OkDialog("Network Error", - "The connection to the server was lost, " - "the program will now quit"); + disconnectedDialog = new OkDialog(_("Network Error"), + _("The connection to the server was lost, the program will now quit")); disconnectedDialog->addActionListener(&exitListener); disconnectedDialog->requestMoveToTop(); } @@ -536,12 +528,12 @@ void Game::handleInput() unsigned int deflt = player_relations.getDefault(); if (deflt & PlayerRelation::TRADE) { chatWindow->chatLog( - "Ignoring incoming trade requests", + _("Ignoring incoming trade requests"), BY_SERVER); deflt &= ~PlayerRelation::TRADE; } else { chatWindow->chatLog( - "Accepting incoming trade requests", + _("Accepting incoming trade requests"), BY_SERVER); deflt |= PlayerRelation::TRADE; } @@ -557,7 +549,7 @@ void Game::handleInput() if (keyboard.isKeyActive(keyboard.KEY_SMILIE)) { // Emotions - int emotion=keyboard.getKeySmilieOffset(event.key.keysym.sym); + int emotion = keyboard.getKeySmilieOffset(event.key.keysym.sym); if (emotion) { smileyShortcut->useSmiley(emotion); @@ -643,13 +635,13 @@ void Game::handleInput() case SDLK_ESCAPE: if (!exitConfirm) { exitConfirm = new ConfirmDialog( - "Quit", "Are you sure you want to quit?"); + _("Quit"), _("Are you sure you want to quit?")); exitConfirm->addActionListener(&exitListener); exitConfirm->requestMoveToTop(); } else { - exitConfirm->action(gcn::ActionEvent(NULL, "no")); + exitConfirm->action(gcn::ActionEvent(NULL, _("no"))); } break; @@ -738,6 +730,7 @@ void Game::handleInput() requestedWindow = skillDialog; break; case KeyboardConfig::KEY_WINDOW_MINIMAP: + minimap->toggle(); requestedWindow = minimap; break; case KeyboardConfig::KEY_WINDOW_CHAT: @@ -789,7 +782,7 @@ void Game::handleInput() catch (gcn::Exception e) { const char* err = e.getMessage().c_str(); - logger->log("Warning: guichan input exception: %s", err); + logger->log(_("Warning: guichan input exception: %s"), err); } } } // End while diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 8519b985..ebeed6d7 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -23,6 +23,7 @@ #include "../being.h" #include "../beingmanager.h" +#include "../configuration.h" #include "../graphics.h" #include "../localplayer.h" @@ -30,6 +31,8 @@ #include "../utils/gettext.h" +bool Minimap::mShow = config.getValue("MinimapVisible", true); + Minimap::Minimap(): Window(_("Map")), mMapImage(NULL), @@ -56,13 +59,14 @@ void Minimap::setMapImage(Image *img) { int offsetX = getPadding() + 4; int offsetY = getTitleBarHeight() + 4; - mMapImage->setAlpha(0.7); + mMapImage->setAlpha(config.getValue("guialpha", 0.8)); setDefaultSize(offsetX, offsetY, mMapImage->getWidth() < 100 ? mMapImage->getWidth() + offsetX : 100, mMapImage->getHeight() < 100 ? mMapImage->getHeight() + offsetY : 100); loadWindowState(); + setVisible(mShow); } else { @@ -70,10 +74,21 @@ void Minimap::setMapImage(Image *img) } } +void Minimap::toggle() +{ + mShow = !mShow; + config.setValue("MinimapVisible", mShow); +} + void Minimap::draw(gcn::Graphics *graphics) { + setVisible(mShow); + Window::draw(graphics); + if (!mShow) + return; + const gcn::Rectangle a = getChildrenArea(); graphics->pushClipArea(a); diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 7897ebdb..b6dbc322 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -56,6 +56,11 @@ class Minimap : public Window */ void setProportion(float proportion) { mProportion = proportion; } + /** + * Toggles the displaying of the minimap. + */ + void toggle(); + /** * Draws the minimap. */ @@ -64,6 +69,7 @@ class Minimap : public Window private: Image *mMapImage; float mProportion; + static bool mShow; }; extern Minimap *minimap; -- cgit v1.2.3-70-g09d2