Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
added tooltip delay option
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed May 28, 2012
1 parent 14f4f09 commit 6014a90
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/openmw/mwgui/settingswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace MWGui
getWidget(mOkButton, "OkButton");
getWidget(mResolutionList, "ResolutionList");
getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
getWidget(mToolTipDelaySlider, "ToolTipDelaySlider");
getWidget(mViewDistanceSlider, "ViewDistanceSlider");
getWidget(mFullscreenButton, "FullscreenButton");
getWidget(mVSyncButton, "VSyncButton");
Expand All @@ -52,6 +53,7 @@ namespace MWGui
mVSyncButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mFPSButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onFpsToggled);
mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mToolTipDelaySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);

Expand Down Expand Up @@ -79,6 +81,8 @@ namespace MWGui
// read settings
int menu_transparency = (mMenuTransparencySlider->getScrollRange()-1) * Settings::Manager::getFloat("menu transparency", "GUI");
mMenuTransparencySlider->setScrollPosition(menu_transparency);
int tooltip_delay = (mToolTipDelaySlider->getScrollRange()-1) * Settings::Manager::getFloat("tooltip delay", "GUI");
mToolTipDelaySlider->setScrollPosition(tooltip_delay);

float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-2000)/(5600-2000);
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
Expand Down Expand Up @@ -170,6 +174,8 @@ namespace MWGui
float val = pos / float(scroller->getScrollRange()-1);
if (scroller == mMenuTransparencySlider)
Settings::Manager::setFloat("menu transparency", "GUI", val);
else if (scroller == mToolTipDelaySlider)
Settings::Manager::setFloat("tooltip delay", "GUI", val);
else if (scroller == mViewDistanceSlider)
Settings::Manager::setFloat("max viewing distance", "Viewing distance", (1-val) * 2000 + val * 5600);
else if (scroller == mMasterVolumeSlider)
Expand Down
1 change: 1 addition & 0 deletions apps/openmw/mwgui/settingswindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace MWGui
MyGUI::Button* mOkButton;

MyGUI::ScrollBar* mMenuTransparencySlider;
MyGUI::ScrollBar* mToolTipDelaySlider;

// graphics
MyGUI::ListBox* mResolutionList;
Expand Down
30 changes: 30 additions & 0 deletions apps/openmw/mwgui/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <boost/lexical_cast.hpp>

#include <components/settings/settings.hpp>

using namespace MWGui;
using namespace MyGUI;

Expand All @@ -19,6 +21,10 @@ ToolTips::ToolTips(WindowManager* windowManager) :
, mEnabled(true)
, mFocusToolTipX(0.0)
, mFocusToolTipY(0.0)
, mDelay(0.0)
, mRemainingDelay(0.0)
, mLastMouseX(0)
, mLastMouseY(0)
{
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");

Expand All @@ -28,6 +34,9 @@ ToolTips::ToolTips(WindowManager* windowManager) :
// even if the mouse is over the tooltip
mDynamicToolTipBox->setNeedMouseFocus(false);
mMainWidget->setNeedMouseFocus(false);

mDelay = Settings::Manager::getFloat("tooltip delay", "GUI");
mRemainingDelay = mDelay;
}

void ToolTips::setEnabled(bool enabled)
Expand Down Expand Up @@ -57,6 +66,21 @@ void ToolTips::onFrame(float frameDuration)

if (!mGameMode)
{
const MyGUI::IntPoint& mousePos = InputManager::getInstance().getMousePosition();
if (mousePos.left == mLastMouseX && mousePos.top == mLastMouseY)
{
mRemainingDelay -= frameDuration;
}
else
{
mRemainingDelay = mDelay;
}
mLastMouseX = mousePos.left;
mLastMouseY = mousePos.top;

if (mRemainingDelay > 0)
return;

Widget* focus = InputManager::getInstance().getMouseFocusWidget();
if (focus == 0)
{
Expand Down Expand Up @@ -621,3 +645,9 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe
widget->setUserString("ToolTipType", "Layout");
widget->setUserString("ToolTipLayout", "ClassToolTip");
}

void ToolTips::setDelay(float delay)
{
mDelay = delay;
mRemainingDelay = mDelay;
}
8 changes: 8 additions & 0 deletions apps/openmw/mwgui/tooltips.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace MWGui
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;

void setDelay(float delay);

void setFocusObject(const MWWorld::Ptr& focus);
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
///< set the screen-space position of the tooltip for focused object
Expand Down Expand Up @@ -84,6 +86,12 @@ namespace MWGui
float mFocusToolTipX;
float mFocusToolTipY;

float mDelay;
float mRemainingDelay; // remaining time until tooltip will show

int mLastMouseX;
int mLastMouseY;

bool mGameMode;

bool mEnabled;
Expand Down
1 change: 1 addition & 0 deletions apps/openmw/mwgui/window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r
void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed)
{
hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD"));
mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI"));

bool changeRes = false;
for (Settings::CategorySettingVector::const_iterator it = changed.begin();
Expand Down
15 changes: 15 additions & 0 deletions files/mygui/openmw_settings_window_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
<Property key="Caption" value="#{sNone}"/>
<Property key="TextAlign" value="Right"/>
</Widget>

<Widget type="TextBox" skin="NormalText" position="4 78 352 18" align="Left Top">
<Property key="Caption" value="#{sMenu_Help_Delay}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="4 102 352 18" align="Left Top" name="ToolTipDelaySlider">
<Property key="Range" value="1000000"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 126 352 18" align="Left Top">
<Property key="Caption" value="#{sFast}"/>
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 126 352 18" align="Left Top">
<Property key="Caption" value="#{sSlow}"/>
<Property key="TextAlign" value="Right"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sAudio} "/>
Expand Down
3 changes: 3 additions & 0 deletions files/settings-default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ vsync = false
# 1 is fully opaque
menu transparency = 0.84

# 0 - instantly, 1 - max. delay
tooltip delay = 0.2

[General]
# Camera field of view
field of view = 55
Expand Down

0 comments on commit 6014a90

Please sign in to comment.