Skip to content

Commit d2f0c65

Browse files
authored
Add tooltips for disabled options during a race (#5618)
Maintainer's note: the tooltips persist outside of race pause, this will be fixed in an upcoming commit
1 parent a7c1a28 commit d2f0c65

6 files changed

Lines changed: 108 additions & 0 deletions

File tree

src/guiengine/skin.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,19 @@ void Skin::drawButton(Widget* w, const core::recti &rect,
11151115
SkinConfig::m_render_params["button::neutral"],
11161116
w->m_deactivated);
11171117
} // if not deactivated or focused
1118+
1119+
// Check for tooltips even on deactivated widgets
1120+
if (w->hasTooltip())
1121+
{
1122+
const core::position2di mouse_position =
1123+
irr_driver->getDevice()->getCursorControl()->getPosition();
1124+
1125+
if (sized_rect.isPointInside(mouse_position))
1126+
{
1127+
m_tooltip_at_mouse.push_back(true);
1128+
m_tooltips.push_back(w);
1129+
}
1130+
}
11181131
}
11191132
else // not within an appearing dialog
11201133
{
@@ -1136,6 +1149,19 @@ void Skin::drawButton(Widget* w, const core::recti &rect,
11361149
SkinConfig::m_render_params["button::neutral"],
11371150
w->m_deactivated);
11381151
} // if not deactivated or focused
1152+
1153+
// Check for tooltips even on deactivated widgets
1154+
if (w->hasTooltip())
1155+
{
1156+
const core::position2di mouse_position =
1157+
irr_driver->getDevice()->getCursorControl()->getPosition();
1158+
1159+
if (rect.isPointInside(mouse_position))
1160+
{
1161+
m_tooltip_at_mouse.push_back(true);
1162+
m_tooltips.push_back(w);
1163+
}
1164+
}
11391165
} // not within an appearing dialog
11401166
} // drawButton
11411167

@@ -1687,6 +1713,16 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
16871713
m_tooltips.push_back(widget);
16881714
}
16891715
}
1716+
else if (widget->hasTooltip())
1717+
{
1718+
// Check tooltips for deactivated widgets too
1719+
if (rect.isPointInside(irr_driver->getDevice()->getCursorControl()
1720+
->getPosition()))
1721+
{
1722+
m_tooltip_at_mouse.push_back(true);
1723+
m_tooltips.push_back(widget);
1724+
}
1725+
}
16901726
#endif
16911727
} // drawRibbonChild
16921728

@@ -1875,6 +1911,18 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
18751911
m_tooltip_at_mouse.push_back(false);
18761912
m_tooltips.push_back(widget);
18771913
}
1914+
else if (widget->hasTooltip())
1915+
{
1916+
// Check tooltips for deactivated widgets too
1917+
const core::position2di mouse_position =
1918+
irr_driver->getDevice()->getCursorControl()->getPosition();
1919+
1920+
if (sized_rect.isPointInside(mouse_position))
1921+
{
1922+
m_tooltip_at_mouse.push_back(true);
1923+
m_tooltips.push_back(widget);
1924+
}
1925+
}
18781926
}
18791927

18801928
// ----------------------------------------------------------------------------
@@ -2144,6 +2192,18 @@ void Skin::drawCheckBox(const core::recti &rect, Widget* widget, bool focused)
21442192
m_tooltips.push_back(widget);
21452193
}
21462194
}
2195+
else if (widget->hasTooltip())
2196+
{
2197+
// Check tooltips for deactivated widgets too
2198+
const core::position2di mouse_position =
2199+
irr_driver->getDevice()->getCursorControl()->getPosition();
2200+
2201+
if (rect.isPointInside(mouse_position))
2202+
{
2203+
m_tooltip_at_mouse.push_back(true);
2204+
m_tooltips.push_back(widget);
2205+
}
2206+
}
21472207
} // drawCheckBox
21482208

21492209
// ----------------------------------------------------------------------------

src/states_screens/options/options_common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ namespace OptionsCommon
5252
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
5353
{
5454
GUIEngine::getWidget("tab_players")->setActive(false);
55+
GUIEngine::getWidget("tab_players")->setTooltip(_("This option cannot be changed during a race."));
5556
GUIEngine::getWidget("tab_language")->setActive(false);
57+
GUIEngine::getWidget("tab_language")->setTooltip(_("This option cannot be changed during a race."));
5658
}
5759
else
5860
{

src/states_screens/options/options_screen_display.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,23 @@ void OptionsScreenDisplay::init()
128128
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
129129

130130
res->setActive(!in_game || is_vulkan_fullscreen_desktop);
131+
if (in_game && !is_vulkan_fullscreen_desktop)
132+
{
133+
res->setTooltip(_("This option cannot be changed during a race."));
134+
}
135+
131136
full->setActive(!in_game || is_vulkan_fullscreen_desktop);
137+
if (in_game && !is_vulkan_fullscreen_desktop)
138+
{
139+
full->setTooltip(_("This option cannot be changed during a race."));
140+
}
141+
132142
applyBtn->setActive(!in_game);
143+
if (in_game)
144+
{
145+
applyBtn->setTooltip(_("This option cannot be changed during a race."));
146+
}
147+
133148

134149
#if defined(MOBILE_STK) || defined(__SWITCH__)
135150
applyBtn->setVisible(false);

src/states_screens/options/options_screen_input.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ void OptionsScreenInput::init()
180180
// Disable adding keyboard configurations
181181
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
182182
getWidget<ButtonWidget>("add_device")->setActive(!in_game);
183+
if(in_game){
184+
getWidget<ButtonWidget>("add_device")->setTooltip(_("This option cannot be changed during a race."));
185+
}
183186

184187
bool multitouch_enabled = (UserConfigParams::m_multitouch_active == 1 &&
185188
irr_driver->getDevice()->supportsTouchDevice()) ||

src/states_screens/options/options_screen_ui.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,15 @@ void OptionsScreenUI::init()
175175
bool currSkinFound = false;
176176
const std::string& user_skin = UserConfigParams::m_skin_file;
177177
m_base_skin_selector ->setActive(!in_game);
178+
if (in_game)
179+
{
180+
m_base_skin_selector->setTooltip(_("This option cannot be changed during a race."));
181+
}
178182
m_variant_skin_selector->setActive(!in_game);
183+
if (in_game)
184+
{
185+
m_variant_skin_selector->setTooltip(_("This option cannot be changed during a race."));
186+
}
179187

180188
for (unsigned int i = 0; i < m_skins.size(); i++)
181189
{
@@ -229,6 +237,10 @@ void OptionsScreenUI::init()
229237
font_size->setValue(size_int);
230238
UserConfigParams::m_font_size = font_size->getValue();
231239
font_size->setActive(!in_game);
240+
if (in_game)
241+
{
242+
font_size->setTooltip(_("This option cannot be changed during a race."));
243+
}
232244

233245
CheckBoxWidget* karts_powerup_gui = getWidget<CheckBoxWidget>("karts_powerup_gui");
234246
assert(karts_powerup_gui != NULL);

src/states_screens/options/options_screen_video.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,29 @@ void OptionsScreenVideo::init()
184184
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
185185

186186
gfx->setActive(!in_game && CVS->isGLSL());
187+
if (in_game && CVS->isGLSL())
188+
{
189+
gfx->setTooltip(_("This option cannot be changed during a race."));
190+
}
187191
getWidget<ButtonWidget>("custom")->setActive(!in_game || !CVS->isGLSL());
192+
if (in_game && CVS->isGLSL())
193+
{
194+
getWidget<ButtonWidget>("custom")->setTooltip(_("This option cannot be changed during a race."));
195+
}
188196
if (getWidget<SpinnerWidget>("scale_rtts")->isActivated())
189197
{
190198
getWidget<SpinnerWidget>("scale_rtts")->setActive(!in_game ||
191199
GE::getDriver()->getDriverType() == video::EDT_VULKAN);
200+
if (in_game && GE::getDriver()->getDriverType() != video::EDT_VULKAN)
201+
{
202+
getWidget<SpinnerWidget>("scale_rtts")->setTooltip(_("This option cannot be changed during a race."));
203+
}
192204
}
193205
getWidget<ButtonWidget>("benchmarkCurrent")->setActive(!in_game);
206+
if (in_game)
207+
{
208+
getWidget<ButtonWidget>("benchmarkCurrent")->setTooltip(_("This option cannot be changed during a race."));
209+
}
194210

195211
// If a benchmark was requested and the game had to reload
196212
// the graphics engine, start the benchmark when the

0 commit comments

Comments
 (0)