mirror of https://github.com/OpenTTD/OpenTTD
(svn r21477) -Fix [FS#4300]: tooltips were removed when their related window got closed
parent
5910bde583
commit
a029b2b83a
|
@ -835,7 +835,7 @@ struct DepotWindow : Window {
|
||||||
uint64 args[2];
|
uint64 args[2];
|
||||||
args[0] = (whole_chain ? num : v->engine_type);
|
args[0] = (whole_chain ? num : v->engine_type);
|
||||||
args[1] = (uint64)(size_t)details;
|
args[1] = (uint64)(size_t)details;
|
||||||
GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
|
GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2564,7 +2564,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
case CFT_INDUSTRY:
|
case CFT_INDUSTRY:
|
||||||
if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES && (this->ind_cargo >= NUM_INDUSTRYTYPES || fieldxy.x != 2)) {
|
if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES && (this->ind_cargo >= NUM_INDUSTRYTYPES || fieldxy.x != 2)) {
|
||||||
GuiShowTooltips(STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, NULL, TCC_HOVER);
|
GuiShowTooltips(this, STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, NULL, TCC_HOVER);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2575,7 +2575,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
const CargoSpec *csp = CargoSpec::Get(cid);
|
const CargoSpec *csp = CargoSpec::Get(cid);
|
||||||
uint64 params[5];
|
uint64 params[5];
|
||||||
params[0] = csp->name;
|
params[0] = csp->name;
|
||||||
GuiShowTooltips(STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, TCC_HOVER);
|
GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, TCC_HOVER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -822,8 +822,9 @@ struct TooltipsWindow : public Window
|
||||||
uint64 params[5]; ///< The string parameters.
|
uint64 params[5]; ///< The string parameters.
|
||||||
TooltipCloseCondition close_cond; ///< Condition for closing the window.
|
TooltipCloseCondition close_cond; ///< Condition for closing the window.
|
||||||
|
|
||||||
TooltipsWindow(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window()
|
TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window()
|
||||||
{
|
{
|
||||||
|
this->parent = parent;
|
||||||
this->string_id = str;
|
this->string_id = str;
|
||||||
assert_compile(sizeof(this->params[0]) == sizeof(params[0]));
|
assert_compile(sizeof(this->params[0]) == sizeof(params[0]));
|
||||||
assert(paramcount <= lengthof(this->params));
|
assert(paramcount <= lengthof(this->params));
|
||||||
|
@ -901,18 +902,19 @@ struct TooltipsWindow : public Window
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a tooltip
|
* Shows a tooltip
|
||||||
|
* @param parent The window this tooltip is related to.
|
||||||
* @param str String to be displayed
|
* @param str String to be displayed
|
||||||
* @param paramcount number of params to deal with
|
* @param paramcount number of params to deal with
|
||||||
* @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
|
* @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
|
||||||
* @param use_left_mouse_button close the tooltip when the left (true) or right (false) mousebutton is released
|
* @param use_left_mouse_button close the tooltip when the left (true) or right (false) mousebutton is released
|
||||||
*/
|
*/
|
||||||
void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
|
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
|
||||||
{
|
{
|
||||||
DeleteWindowById(WC_TOOLTIPS, 0);
|
DeleteWindowById(WC_TOOLTIPS, 0);
|
||||||
|
|
||||||
if (str == STR_NULL) return;
|
if (str == STR_NULL) return;
|
||||||
|
|
||||||
new TooltipsWindow(str, paramcount, params, close_tooltip);
|
new TooltipsWindow(parent, str, paramcount, params, close_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete a character at the caret position in a text buf.
|
/* Delete a character at the caret position in a text buf.
|
||||||
|
|
|
@ -2058,7 +2058,7 @@ void UpdateTileSelection()
|
||||||
static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_LEFT_CLICK)
|
static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_LEFT_CLICK)
|
||||||
{
|
{
|
||||||
if (!_settings_client.gui.measure_tooltip) return;
|
if (!_settings_client.gui.measure_tooltip) return;
|
||||||
GuiShowTooltips(str, paramcount, params, close_cond);
|
GuiShowTooltips(FindWindowById(_thd.window_class, _thd.window_number), str, paramcount, params, close_cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** highlighting tiles while only going over them with the mouse */
|
/** highlighting tiles while only going over them with the mouse */
|
||||||
|
|
|
@ -406,7 +406,7 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
|
||||||
if (w->OnRightClick(pt, wid->index)) return;
|
if (w->OnRightClick(pt, wid->index)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings_client.gui.hover_delay == 0 && wid->tool_tip != 0) GuiShowTooltips(wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
|
if (_settings_client.gui.hover_delay == 0 && wid->tool_tip != 0) GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -424,7 +424,7 @@ static void DispatchHoverEvent(Window *w, int x, int y)
|
||||||
|
|
||||||
/* Show the tooltip if there is any */
|
/* Show the tooltip if there is any */
|
||||||
if (wid->tool_tip != 0) {
|
if (wid->tool_tip != 0) {
|
||||||
GuiShowTooltips(wid->tool_tip);
|
GuiShowTooltips(w, wid->tool_tip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -792,7 +792,7 @@ enum TooltipCloseCondition {
|
||||||
TCC_HOVER,
|
TCC_HOVER,
|
||||||
};
|
};
|
||||||
|
|
||||||
void GuiShowTooltips(StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);
|
void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);
|
||||||
|
|
||||||
/* widget.cpp */
|
/* widget.cpp */
|
||||||
int GetWidgetFromPos(const Window *w, int x, int y);
|
int GetWidgetFromPos(const Window *w, int x, int y);
|
||||||
|
|
Loading…
Reference in New Issue