diff options
author | Mateusz Kaduk <mateusz.kaduk@gmail.com> | 2008-06-04 08:32:39 +0000 |
---|---|---|
committer | Mateusz Kaduk <mateusz.kaduk@gmail.com> | 2008-06-04 08:32:39 +0000 |
commit | 54d3f15fde8305e7e65944668bde66d7a4e127db (patch) | |
tree | bad2722f67eabff7adad0fc1890e1307ca6e8b1c /src/gui/viewport.cpp | |
parent | 0fdbf1d62c1add8800ffc7171a1911e1e243ac2a (diff) | |
download | mana-54d3f15fde8305e7e65944668bde66d7a4e127db.tar.gz mana-54d3f15fde8305e7e65944668bde66d7a4e127db.tar.bz2 mana-54d3f15fde8305e7e65944668bde66d7a4e127db.tar.xz mana-54d3f15fde8305e7e65944668bde66d7a4e127db.zip |
Added switch option drawing nicknames only if mouse hover. Useful in crowded places.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r-- | src/gui/viewport.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 819cb761..0dcebd87 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -58,7 +58,8 @@ Viewport::Viewport(): mShowDebugPath(false), mPlayerFollowMouse(false), mWalkTime(0), - mLocalWalkTime(-1) + mLocalWalkTime(-1), + mVisibleNames(false) { setOpaque(false); addMouseListener(this); @@ -67,9 +68,11 @@ Viewport::Viewport(): mScrollRadius = (int) config.getValue("ScrollRadius", 32); mScrollCenterOffsetX = (int) config.getValue("ScrollCenterOffsetX", 0); mScrollCenterOffsetY = (int) config.getValue("ScrollCenterOffsetY", 0); + mVisibleNames = (config.getValue("visiblenames", 1) == 1); config.addListener("ScrollLaziness", this); config.addListener("ScrollRadius", this); + config.addListener("visiblenames", this); mPopupMenu = new PopupMenu(); @@ -122,6 +125,8 @@ Viewport::loadTargetCursor(std::string filename, int width, int height, Viewport::~Viewport() { delete mPopupMenu; + + config.removeListener("visiblenames", this); for (int i = Being::TC_SMALL; i < Being::NUM_TC; i++) { @@ -234,6 +239,7 @@ Viewport::draw(gcn::Graphics *gcnGraphics) for (BeingIterator i = beings.begin(); i != beings.end(); i++) { (*i)->drawSpeech(graphics, -(int) mViewX, -(int) mViewY); + if(mVisibleNames && (*i) == mSelectedBeing) (*i)->drawName(graphics, -(int) mViewX, -(int) mViewY); (*i)->drawEmotion(graphics, -(int) mViewX, -(int) mViewY); } @@ -459,4 +465,22 @@ Viewport::optionChanged(const std::string &name) { mScrollLaziness = (int) config.getValue("ScrollLaziness", 32); mScrollRadius = (int) config.getValue("ScrollRadius", 32); + + if (name == "visiblenames") { + mVisibleNames = config.getValue("visiblenames", 1) == 1; + } } + +void +Viewport::mouseMoved(gcn::MouseEvent &event) +{ + // Check if we are on the map + if (!mMap || !player_node) + return; + + const int tilex = (event.getX() + (int) mViewX) / 32; + const int tiley = (event.getY() + (int) mViewY) / 32; + + mSelectedBeing = beingManager->findBeing(tilex, tiley); +} + |