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 | |
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.
-rw-r--r-- | src/gui/setup.cpp | 6 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 40 | ||||
-rw-r--r-- | src/gui/setup_video.h | 2 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 26 | ||||
-rw-r--r-- | src/gui/viewport.h | 8 |
5 files changed, 65 insertions, 17 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index d1f8a38a..22b91ed4 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -49,8 +49,8 @@ Setup::Setup(): Window(_("Setup")) { setCloseButton(true); - int width = 250; - int height = 245; + int width = 260; + int height = 265; setContentSize(width, height); static char const *buttonNames[] = { @@ -65,7 +65,7 @@ Setup::Setup(): } TabbedArea *panel = new TabbedArea(); - panel->setDimension(gcn::Rectangle(5, 5, 250, 205)); + panel->setDimension(gcn::Rectangle(5, 5, 260, 225)); SetupTab *tab; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index eb3c3df2..4d9b5d74 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -106,6 +106,7 @@ Setup_Video::Setup_Video(): mFullScreenEnabled(config.getValue("screen", 0)), mOpenGLEnabled(config.getValue("opengl", 0)), mCustomCursorEnabled(config.getValue("customcursor", 1)), + mVisibleNamesEnabled(config.getValue("visiblenames", 1)), mOpacity(config.getValue("guialpha", 0.8)), mFps((int)config.getValue("fpslimit", 60)), mModeListModel(new ModeListModel()), @@ -113,6 +114,7 @@ Setup_Video::Setup_Video(): mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)), mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), + mVisibleNamesCheckBox(new CheckBox(_("Visible names"), mVisibleNamesEnabled)), mAlphaSlider(new Slider(0.2, 1.0)), mFpsCheckBox(new CheckBox(_("FPS Limit:"))), mFpsSlider(new Slider(10, 200)), @@ -143,12 +145,13 @@ Setup_Video::Setup_Video(): mFsCheckBox->setPosition(110, 10); mOpenGLCheckBox->setPosition(110, 30); mCustomCursorCheckBox->setPosition(110, 50); - mAlphaSlider->setDimension(gcn::Rectangle(10, 80, 100, 10)); + mVisibleNamesCheckBox->setPosition(110, 70); + mAlphaSlider->setDimension(gcn::Rectangle(10, 100, 100, 10)); alphaLabel->setPosition(20 + mAlphaSlider->getWidth(), mAlphaSlider->getY()); - mFpsCheckBox->setPosition(90, 100); - mFpsSlider->setDimension(gcn::Rectangle(10, 100, 75, 10)); - mFpsField->setPosition(100 + mFpsCheckBox->getWidth(), 100); + mFpsCheckBox->setPosition(90, 120); + mFpsSlider->setDimension(gcn::Rectangle(10, 120, 75, 10)); + mFpsField->setPosition(100 + mFpsCheckBox->getWidth(), 120); mFpsField->setWidth(30); mModeList->setSelected(-1); @@ -161,6 +164,7 @@ Setup_Video::Setup_Video(): mFpsCheckBox->setSelected(mFps > 0); mCustomCursorCheckBox->setActionEventId("customcursor"); + mVisibleNamesCheckBox->setActionEventId("visiblenames"); mAlphaSlider->setActionEventId("guialpha"); mFpsCheckBox->setActionEventId("fpslimitcheckbox"); mFpsSlider->setActionEventId("fpslimitslider"); @@ -172,6 +176,7 @@ Setup_Video::Setup_Video(): mOverlayDetailField->setActionEventId("overlaydetailfield"); mCustomCursorCheckBox->addActionListener(this); + mVisibleNamesCheckBox->addActionListener(this); mAlphaSlider->addActionListener(this); mFpsCheckBox->addActionListener(this); mFpsSlider->addActionListener(this); @@ -183,26 +188,26 @@ Setup_Video::Setup_Video(): mOverlayDetailSlider->addActionListener(this); mOverlayDetailField->addKeyListener(this); - mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 120, 75, 10)); + mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 140, 75, 10)); gcn::Label *scrollRadiusLabel = new gcn::Label(_("Scroll radius")); - scrollRadiusLabel->setPosition(90, 120); - mScrollRadiusField->setPosition(180, 120); + scrollRadiusLabel->setPosition(90, 140); + mScrollRadiusField->setPosition(180, 140); mScrollRadiusField->setWidth(30); mScrollRadiusField->setText(toString(mOriginalScrollRadius)); mScrollRadiusSlider->setValue(mOriginalScrollRadius); - mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 140, 75, 10)); + mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 160, 75, 10)); gcn::Label *scrollLazinessLabel = new gcn::Label(_("Scroll laziness")); - scrollLazinessLabel->setPosition(90, 140); - mScrollLazinessField->setPosition(180, 140); + scrollLazinessLabel->setPosition(90, 160); + mScrollLazinessField->setPosition(180, 160); mScrollLazinessField->setWidth(30); mScrollLazinessField->setText(toString(mOriginalScrollLaziness)); mScrollLazinessSlider->setValue(mOriginalScrollLaziness); - mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 160, 75, 10)); + mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 180, 75, 10)); gcn::Label *overlayDetailLabel = new gcn::Label(_("Ambient FX")); - overlayDetailLabel->setPosition(90, 160); - mOverlayDetailField->setPosition(180, 160); + overlayDetailLabel->setPosition(90, 180); + mOverlayDetailField->setPosition(180, 180); mOverlayDetailField->setWidth(30); switch (mOverlayDetail) { @@ -222,6 +227,7 @@ Setup_Video::Setup_Video(): add(mFsCheckBox); add(mOpenGLCheckBox); add(mCustomCursorCheckBox); + add(mVisibleNamesCheckBox); add(mAlphaSlider); add(alphaLabel); add(mFpsCheckBox); @@ -288,6 +294,7 @@ void Setup_Video::apply() // We sync old and new values at apply time mFullScreenEnabled = config.getValue("screen", 0); mCustomCursorEnabled = config.getValue("customcursor", 1); + mVisibleNamesEnabled = config.getValue("visiblenames", 1); mOpacity = config.getValue("guialpha", 0.8); mOverlayDetail = (int)config.getValue("OverlayDetail", 2); mOpenGLEnabled = config.getValue("opengl", 0); @@ -319,6 +326,7 @@ void Setup_Video::cancel() mFsCheckBox->setSelected(mFullScreenEnabled); mOpenGLCheckBox->setSelected(mOpenGLEnabled); mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); + mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled); mAlphaSlider->setValue(mOpacity); mOverlayDetailSlider->setValue(mOverlayDetail); @@ -329,6 +337,7 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled ? 1 : 0); config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0); + config.setValue("visiblenames", mVisibleNamesEnabled ? 1 : 0); config.setValue("guialpha", mOpacity); config.setValue("opengl", mOpenGLEnabled ? 1 : 0); } @@ -344,6 +353,11 @@ void Setup_Video::action(const gcn::ActionEvent &event) config.setValue("customcursor", mCustomCursorCheckBox->isSelected() ? 1 : 0); } + else if (event.getId() == "visiblenames") + { + config.setValue("visiblenames", + mVisibleNamesCheckBox->isSelected() ? 1 : 0); + } else if (event.getId() == "fpslimitslider") { mFps = (int) mFpsSlider->getValue(); diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 095fdbd6..e4e9fcf1 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -51,6 +51,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, bool mFullScreenEnabled; bool mOpenGLEnabled; bool mCustomCursorEnabled; + bool mVisibleNamesEnabled; double mOpacity; int mFps; @@ -60,6 +61,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, gcn::CheckBox *mFsCheckBox; gcn::CheckBox *mOpenGLCheckBox; gcn::CheckBox *mCustomCursorCheckBox; + gcn::CheckBox *mVisibleNamesCheckBox; gcn::Slider *mAlphaSlider; gcn::CheckBox *mFpsCheckBox; 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); +} + diff --git a/src/gui/viewport.h b/src/gui/viewport.h index cb47b5fe..82587938 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -107,6 +107,12 @@ class Viewport : public WindowContainer, public gcn::MouseListener, mouseReleased(gcn::MouseEvent &event); /** + * Handles mouse move on map. + */ + void + mouseMoved(gcn::MouseEvent &event); + + /** * Shows a popup for an item. * TODO Find some way to get rid of Item here */ @@ -170,6 +176,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, float mViewX; /**< Current viewpoint in pixels. */ float mViewY; /**< Current viewpoint in pixels. */ bool mShowDebugPath; /**< Show a path from player to pointer. */ + bool mVisibleNames; /**< Show target names. */ /** Images of in range target cursor. */ ImageSet *mInRangeImages[Being::NUM_TC]; @@ -188,6 +195,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ PopupMenu *mPopupMenu; /**< Popup menu. */ + Being *mSelectedBeing; /**< Current selected being. */ }; #endif |