diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-08-02 02:09:01 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-08-02 02:09:01 +0200 |
commit | ce3b24e780d39e323454c6ef24982a1f9c7b605c (patch) | |
tree | db61e54fc0713fbf7e98a13ea839e9d9f12294a5 | |
parent | 422c71c761745bdda86962933d0d39175129e46c (diff) | |
download | mana-ce3b24e780d39e323454c6ef24982a1f9c7b605c.tar.gz mana-ce3b24e780d39e323454c6ef24982a1f9c7b605c.tar.bz2 mana-ce3b24e780d39e323454c6ef24982a1f9c7b605c.tar.xz mana-ce3b24e780d39e323454c6ef24982a1f9c7b605c.zip |
Split off minimap window from mini status window and repositioned them
-rw-r--r-- | mana.cbp | 2 | ||||
-rw-r--r-- | mana.files | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/game.cpp | 11 | ||||
-rw-r--r-- | src/game.h | 2 | ||||
-rw-r--r-- | src/gui/minimapwindow.cpp | 80 | ||||
-rw-r--r-- | src/gui/minimapwindow.h | 47 | ||||
-rw-r--r-- | src/gui/ministatuswindow.cpp | 36 | ||||
-rw-r--r-- | src/gui/ministatuswindow.h | 11 |
9 files changed, 143 insertions, 50 deletions
@@ -189,6 +189,8 @@ <Unit filename="src\gui\logindialog.h" /> <Unit filename="src\gui\minimap.cpp" /> <Unit filename="src\gui\minimap.h" /> + <Unit filename="src\gui\minimapwindow.cpp" /> + <Unit filename="src\gui\minimapwindow.h" /> <Unit filename="src\gui\ministatuswindow.cpp" /> <Unit filename="src\gui\ministatuswindow.h" /> <Unit filename="src\gui\npcdialog.cpp" /> @@ -138,6 +138,8 @@ src/gui/logindialog.cpp src/gui/logindialog.h src/gui/minimap.cpp src/gui/minimap.h +src/gui/minimapwindow.cpp +src/gui/minimapwindow.h src/gui/ministatuswindow.cpp src/gui/ministatuswindow.h src/gui/npcdialog.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b9aa6bb7..05f45e18 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -265,6 +265,8 @@ SET(SRCS gui/logindialog.h gui/minimap.cpp gui/minimap.h + gui/minimapwindow.cpp + gui/minimapwindow.h gui/ministatuswindow.cpp gui/ministatuswindow.h gui/npcdialog.cpp diff --git a/src/game.cpp b/src/game.cpp index 0b79e266..2a8005f5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -49,7 +49,7 @@ #include "gui/helpwindow.h" #include "gui/inventorywindow.h" #include "gui/shortcutwindow.h" -#include "gui/minimap.h" +#include "gui/minimapwindow.h" #include "gui/ministatuswindow.h" #include "gui/npcdialog.h" #include "gui/okdialog.h" @@ -216,12 +216,14 @@ Game::Game(): viewport->requestMoveToBottom(); mWindowMenu = new WindowMenu; + mMinimapWindow = new MinimapWindow; mMiniStatusWindow = new MiniStatusWindow; - top->place(1, 0, mWindowMenu) + top->place(0, 0, mMinimapWindow); + top->place(1, 0, mMiniStatusWindow).setVAlign(Layout::LEFT); + top->place(3, 0, mWindowMenu) .setHAlign(Layout::RIGHT) .setVAlign(Layout::LEFT); - top->place(2, 0, mMiniStatusWindow); top->updateLayout(); createGuiWindows(); @@ -247,6 +249,7 @@ Game::~Game() Event::trigger(Event::GameChannel, Event::Destructing); delete mWindowMenu; + delete mMinimapWindow; delete mMiniStatusWindow; destroyGuiWindows(); @@ -932,7 +935,7 @@ void Game::changeMap(const std::string &mapPath) } // Notify the minimap and beingManager about the map change - mMiniStatusWindow->setMap(newMap); + mMinimapWindow->setMap(newMap); actorSpriteManager->setMap(newMap); particleEngine->setMap(newMap); viewport->setMap(newMap); @@ -25,6 +25,7 @@ #include <string> class Map; +class MinimapWindow; class MiniStatusWindow; class WindowMenu; @@ -86,6 +87,7 @@ class Game bool mDisconnected; WindowMenu *mWindowMenu; + MinimapWindow *mMinimapWindow; MiniStatusWindow *mMiniStatusWindow; Map *mCurrentMap; diff --git a/src/gui/minimapwindow.cpp b/src/gui/minimapwindow.cpp new file mode 100644 index 00000000..3e593731 --- /dev/null +++ b/src/gui/minimapwindow.cpp @@ -0,0 +1,80 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 "minimapwindow.h" + +#include "gui/minimap.h" + +#include "gui/widgets/label.h" +#include "gui/widgets/layout.h" + +#include "resources/theme.h" + +#include "map.h" + +MinimapWindow::MinimapWindow(): + mMinimap(new Minimap), + mRegionLabel(new Label), + mWindowSkin(Theme::instance()->load("window.xml")) +{ + mRegionLabel->setAlignment(gcn::Graphics::CENTER); + mRegionLabel->adjustSize(); + + int row = 0; + place(0, row++, mRegionLabel); + place(0, row++, mMinimap); + + Layout &layout = getLayout(); + layout.setMargin(0); + layout.setPadding(7); + + int w = 0; + int h = 0; + layout.reflow(w, h); + setSize(w, h); +} + +static gcn::Rectangle adjusted(const gcn::Rectangle &rect, + int left, int top, int right, int bottom) +{ + return gcn::Rectangle(rect.x + left, + rect.y + top, + rect.width - left + right, + rect.height - top + bottom); +} + +void MinimapWindow::draw(gcn::Graphics *graphics) +{ + Graphics *g = static_cast<Graphics*>(graphics); + + g->drawImageRect(adjusted(mMinimap->getDimension(), + -5, -10 - mRegionLabel->getHeight(), + 8, 8), + mWindowSkin->getBorder()); + + drawChildren(graphics); +} + +void MinimapWindow::setMap(Map *map) +{ + mMinimap->setMap(map); + mRegionLabel->setCaption(map ? map->getName() : std::string()); +} diff --git a/src/gui/minimapwindow.h b/src/gui/minimapwindow.h new file mode 100644 index 00000000..f589ffe3 --- /dev/null +++ b/src/gui/minimapwindow.h @@ -0,0 +1,47 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana 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 MINIMAPWINDOW_H +#define MINIMAPWINDOW_H + +#include "gui/widgets/container.h" + +class Label; +class Map; +class Minimap; +class Skin; + +class MinimapWindow : public Container +{ +public: + MinimapWindow(); + + void draw(gcn::Graphics *graphics); + + void setMap(Map *map); + +private: + Minimap *mMinimap; + Label *mRegionLabel; + Skin *mWindowSkin; +}; + +#endif // MINIMAPWINDOW_H diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index df8b4aba..ac0ae5d7 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -28,14 +28,11 @@ #include "statuseffect.h" #include "gui/gui.h" -#include "gui/minimap.h" #include "gui/statuswindow.h" #include "gui/textpopup.h" -#include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/progressbar.h" -#include "gui/widgets/spacer.h" #include "net/net.h" #include "net/playerhandler.h" @@ -50,17 +47,11 @@ extern volatile int tick_time; -MiniStatusWindow::MiniStatusWindow(): - mMinimap(new Minimap), - mRegionLabel(new Label), - mWindowSkin(Theme::instance()->load("window.xml")) +MiniStatusWindow::MiniStatusWindow() { listen(Event::AttributesChannel); listen(Event::ActorSpriteChannel); - mRegionLabel->setAlignment(gcn::Graphics::CENTER); - mRegionLabel->adjustSize(); - mHpBar = new ProgressBar(0, 100, 20, Theme::PROG_HP); StatusWindow::updateHPBar(mHpBar); @@ -79,18 +70,12 @@ MiniStatusWindow::MiniStatusWindow(): StatusWindow::updateXPBar(mXpBar); int row = 0; - place(0, row++, mRegionLabel); - place(0, row++, mMinimap); - place(0, row++, new Spacer); place(0, row++, mHpBar); if (mMpBar) place(0, row++, mMpBar); place(0, row++, mXpBar); Layout &layout = getLayout(); - layout.setMargin(0); - layout.setPadding(7); - int w = 0; int h = 0; layout.reflow(w, h); @@ -246,22 +231,9 @@ void MiniStatusWindow::logic() mIcons[i]->update(tick_time * 10); } -static gcn::Rectangle adjust(const gcn::Rectangle &rect, - int left, int top, int right, int bottom) -{ - return gcn::Rectangle(rect.x + left, - rect.y + top, - rect.width - left + right, - rect.height - top + bottom); -} - void MiniStatusWindow::draw(gcn::Graphics *graphics) { Graphics *g = static_cast<Graphics*>(graphics); - g->drawImageRect(adjust(mMinimap->getDimension(), - -5, -10 - mRegionLabel->getHeight(), - 8, 8), - mWindowSkin->getBorder()); drawChildren(graphics); drawIcons(g); @@ -303,9 +275,3 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) { mTextPopup->setVisible(false); } - -void MiniStatusWindow::setMap(Map *map) -{ - mMinimap->setMap(map); - mRegionLabel->setCaption(map ? map->getName() : std::string()); -} diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 86e2e4f0..a9939fcd 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -32,11 +32,7 @@ class AnimatedSprite; class Graphics; -class Label; -class Map; -class Minimap; class ProgressBar; -class Skin; class TextPopup; /** @@ -62,8 +58,6 @@ class MiniStatusWindow : public Container, void mouseMoved(gcn::MouseEvent &mouseEvent); void mouseExited(gcn::MouseEvent &event); - void setMap(Map *map); - private: bool isInBar(ProgressBar *bar, int x, int y) const; @@ -74,9 +68,6 @@ class MiniStatusWindow : public Container, void eraseIcon(int index); - Minimap *mMinimap; - Label *mRegionLabel; - /* * Mini Status Bars */ @@ -85,8 +76,6 @@ class MiniStatusWindow : public Container, ProgressBar *mXpBar; TextPopup *mTextPopup; - Skin *mWindowSkin; - std::vector<int> mStatusEffectIcons; std::vector<AnimatedSprite *> mIcons; }; |