Linkgraph GUI: Add hover tool-tips to graph legend window.

This commit is contained in:
Jonathan G Rennison
2016-11-21 22:38:04 +00:00
parent 37a58fd11d
commit 55057110a5
3 changed files with 25 additions and 1 deletions

View File

@@ -2426,6 +2426,7 @@ STR_LINKGRAPH_LEGEND_CAPTION :{BLACK}Cargo Fl
STR_LINKGRAPH_LEGEND_ALL :{BLACK}All
STR_LINKGRAPH_LEGEND_NONE :{BLACK}None
STR_LINKGRAPH_LEGEND_SELECT_COMPANIES :{BLACK}Select companies to be displayed
STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP :{BLACK}{STRING}{}{COMPANY}
# Linkgraph legend window and linkgraph legend in smallmap
STR_LINKGRAPH_LEGEND_UNUSED :{TINY_FONT}{BLACK}unused

View File

@@ -319,7 +319,7 @@ void LinkGraphOverlay::SetCompanyMask(uint32 company_mask)
/** Make a number of rows with buttons for each company for the linkgraph legend window. */
NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI(int *biggest_index)
{
return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, 3, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES);
return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, 3, 0);
}
NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index)
@@ -500,6 +500,28 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
}
}
void LinkGraphLegendWindow::OnHover(Point pt, int widget)
{
if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
uint64 params[5];
if (this->IsWidgetDisabled(widget)) {
GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES, 0, params, TCC_HOVER);
} else {
CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST);
params[0] = STR_LINKGRAPH_LEGEND_SELECT_COMPANIES;
params[1] = cid;
GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP, 2, params, TCC_HOVER);
}
}
if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
if (this->IsWidgetDisabled(widget)) return;
CargoSpec *cargo = CargoSpec::Get(widget - WID_LGL_CARGO_FIRST);
uint64 params[5];
params[0] = cargo->name;
GuiShowTooltips(this, STR_BLACK_STRING, 1, params, TCC_HOVER);
}
}
/**
* Update the overlay with the new company selection.
*/

View File

@@ -102,6 +102,7 @@ public:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize);
virtual void DrawWidget(const Rect &r, int widget) const;
virtual void OnHover(Point pt, int widget) override;
virtual void OnClick(Point pt, int widget, int click_count);
virtual void OnInvalidateData(int data = 0, bool gui_scope = true);