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 /src/gui | |
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
Diffstat (limited to 'src/gui')
-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 |
4 files changed, 128 insertions, 46 deletions
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; }; |