diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-03-01 20:41:41 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-03-01 20:46:17 -0700 |
commit | 76b306a5a2eff9f9a6bb65b3d784cc8e31ba6cce (patch) | |
tree | 7a7c43fb950add7ab991459cf91af23c02cb4309 /src/gui | |
parent | 67e678094b9fddd21fb3c690130e772937ab2746 (diff) | |
download | mana-76b306a5a2eff9f9a6bb65b3d784cc8e31ba6cce.tar.gz mana-76b306a5a2eff9f9a6bb65b3d784cc8e31ba6cce.tar.bz2 mana-76b306a5a2eff9f9a6bb65b3d784cc8e31ba6cce.tar.xz mana-76b306a5a2eff9f9a6bb65b3d784cc8e31ba6cce.zip |
Simplify BeignPopup and therefore Viewport
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/beingpopup.cpp | 21 | ||||
-rw-r--r-- | src/gui/beingpopup.h | 8 | ||||
-rw-r--r-- | src/gui/gui.cpp | 16 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 10 |
4 files changed, 26 insertions, 29 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index 7fd99371..33fdff44 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -27,7 +27,7 @@ #include "gui/gui.h" #include "gui/palette.h" -#include "gui/widgets/textbox.h" +#include "gui/widgets/label.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -39,14 +39,14 @@ BeingPopup::BeingPopup(): Popup("BeingPopup") { // Being Name - mBeingName = new TextBox(); + mBeingName = new Label("A"); mBeingName->setFont(boldFont); mBeingName->setPosition(getPadding(), getPadding()); - const int fontHeight = getFont()->getHeight(); + const int fontHeight = mBeingName->getHeight() + getPadding(); // Being's party - mBeingParty = new TextBox(); + mBeingParty = new Label("A"); mBeingParty->setPosition(getPadding(), fontHeight); add(mBeingName); @@ -69,12 +69,15 @@ void BeingPopup::show(int x, int y, Player *p) if (!(p->getPartyName().empty())) { - mBeingName->setTextWrapped(p->getName(), 196); - mBeingParty->setTextWrapped(strprintf(_("Party: %s"), - p->getPartyName().c_str()), 196); + mBeingName->setCaption(p->getName()); + mBeingName->adjustSize(); - int minWidth = std::max(mBeingName->getMinWidth(), - mBeingParty->getMinWidth()); + mBeingParty->setCaption(strprintf(_("Party: %s"), + p->getPartyName().c_str())); + mBeingParty->adjustSize(); + + int minWidth = std::max(mBeingName->getWidth(), + mBeingParty->getWidth()); const int height = getFont()->getHeight(); diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h index 078b84d9..71d9dd2a 100644 --- a/src/gui/beingpopup.h +++ b/src/gui/beingpopup.h @@ -23,10 +23,8 @@ #include "gui/widgets/popup.h" -#include <guichan/mouselistener.hpp> - +class Label; class Player; -class TextBox; /** * A popup that displays information about a being. @@ -52,8 +50,8 @@ class BeingPopup : public Popup // TODO: Add a version for monsters, NPCs, etc? private: - TextBox *mBeingName; - TextBox *mBeingParty; + Label *mBeingName; + Label *mBeingParty; static gcn::Color getColor(); }; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2a6e1ce3..c5b77704 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -92,14 +92,6 @@ Gui::Gui(Graphics *graphics): delete mFocusHandler; mFocusHandler = new FocusHandler; - // Initialize top GUI widget - Viewport *guiTop = new Viewport; - guiTop->setFocusable(true); - guiTop->setDimension(gcn::Rectangle(0, 0, - graphics->getWidth(), graphics->getHeight())); - guiTop->setOpaque(false); - setTop(guiTop); - ResourceManager *resman = ResourceManager::getInstance(); // Set global font @@ -132,6 +124,14 @@ Gui::Gui(Graphics *graphics): gcn::Widget::setGlobalFont(mGuiFont); + // Initialize top GUI widget + Viewport *guiTop = new Viewport; + guiTop->setFocusable(true); + guiTop->setDimension(gcn::Rectangle(0, 0, + graphics->getWidth(), graphics->getHeight())); + guiTop->setOpaque(false); + setTop(guiTop); + // Initialize mouse cursor and listen for changes to the option setUseCustomCursor(config.getValue("customcursor", 1) == 1); mConfigListener = new GuiConfigListener(this); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 99053339..a36f91cf 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -58,8 +58,7 @@ Viewport::Viewport(): mPixelViewY(0.0f), mShowDebugPath(false), mPlayerFollowMouse(false), - mLocalWalkTime(-1), - mBeingPopup(0) + mLocalWalkTime(-1) { setOpaque(false); addMouseListener(this); @@ -75,6 +74,7 @@ Viewport::Viewport(): viewport = this; mPopupMenu = new PopupMenu; + mBeingPopup = new BeingPopup; setFocusable(true); } @@ -91,9 +91,6 @@ void Viewport::setMap(Map *map) map->setDebugFlags(mMap->getDebugFlags()); } mMap = map; - - if (!mBeingPopup) - mBeingPopup = new BeingPopup; } extern MiniStatusWindow *miniStatusWindow; @@ -523,8 +520,7 @@ void Viewport::toggleDebugPath() void Viewport::hideBeingPopup() { - if (mBeingPopup) - mBeingPopup->setVisible(false); + mBeingPopup->setVisible(false); } void Viewport::scheduleDelete(gcn::Widget *widget) |