diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-08-02 00:51:58 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-08-02 00:51:58 +0200 |
commit | 9654a6554c9a42e13f641f8f52e04246d96882b8 (patch) | |
tree | 9bf6cbf82b3e1e074071dbc55d5c7ad540ced79b /src/gui/ministatuswindow.cpp | |
parent | a61c57070aa618ac749e4a90a2b83c0e3a15e5fd (diff) | |
download | mana-client-9654a6554c9a42e13f641f8f52e04246d96882b8.tar.gz mana-client-9654a6554c9a42e13f641f8f52e04246d96882b8.tar.bz2 mana-client-9654a6554c9a42e13f641f8f52e04246d96882b8.tar.xz mana-client-9654a6554c9a42e13f641f8f52e04246d96882b8.zip |
Embedded the minimap into the mini status window
Diffstat (limited to 'src/gui/ministatuswindow.cpp')
-rw-r--r-- | src/gui/ministatuswindow.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 86dd4adf..df8b4aba 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -28,11 +28,14 @@ #include "statuseffect.h" #include "gui/gui.h" +#include "gui/minimap.h" #include "gui/statuswindow.h" #include "gui/textpopup.h" -#include "gui/widgets/progressbar.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" @@ -47,11 +50,17 @@ extern volatile int tick_time; -MiniStatusWindow::MiniStatusWindow() +MiniStatusWindow::MiniStatusWindow(): + mMinimap(new Minimap), + mRegionLabel(new Label), + mWindowSkin(Theme::instance()->load("window.xml")) { 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); @@ -69,9 +78,10 @@ MiniStatusWindow::MiniStatusWindow() mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP); StatusWindow::updateXPBar(mXpBar); - // Add the progressbars to the window - 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); @@ -79,6 +89,7 @@ MiniStatusWindow::MiniStatusWindow() Layout &layout = getLayout(); layout.setMargin(0); + layout.setPadding(7); int w = 0; int h = 0; @@ -235,10 +246,25 @@ 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(static_cast<Graphics*>(graphics)); + drawIcons(g); } void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) @@ -277,3 +303,9 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) { mTextPopup->setVisible(false); } + +void MiniStatusWindow::setMap(Map *map) +{ + mMinimap->setMap(map); + mRegionLabel->setCaption(map ? map->getName() : std::string()); +} |