Changeset - r25039:1deb621cd116
[Not reviewed]
master
0 6 0
Tyler Trahan - 3 years ago 2021-03-11 14:30:29
tyler@tylertrahan.com
Change: Recolour graph windows to brown (#8700)
6 files changed with 96 insertions and 95 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -1410,49 +1410,49 @@ struct AIDebugWindow : public Window {
 
		this->SetWidgetDisabledState(WID_AID_RELOAD_TOGGLE, ai_debug_company == INVALID_COMPANY || ai_debug_company == OWNER_DEITY || ai_debug_company == _local_company);
 
		this->SetWidgetDisabledState(WID_AID_CONTINUE_BTN, ai_debug_company == INVALID_COMPANY ||
 
				(ai_debug_company == OWNER_DEITY ? !Game::IsPaused() : !AI::IsPaused(ai_debug_company)));
 
	}
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_AID_LOG_PANEL);
 
	}
 

	
 
	static HotkeyList hotkeys;
 
};
 

	
 
const int AIDebugWindow::top_offset = WD_FRAMERECT_TOP + 2;
 
const int AIDebugWindow::bottom_offset = WD_FRAMERECT_BOTTOM;
 
CompanyID AIDebugWindow::ai_debug_company = INVALID_COMPANY;
 
char AIDebugWindow::break_string[MAX_BREAK_STR_STRING_LENGTH] = "";
 
bool AIDebugWindow::break_check_enabled = true;
 
bool AIDebugWindow::case_sensitive_break_check = false;
 
StringFilter AIDebugWindow::break_string_filter(&AIDebugWindow::case_sensitive_break_check);
 

	
 
/** Make a number of rows with buttons for each company for the AI debug window. */
 
NWidgetBase *MakeCompanyButtonRowsAIDebug(int *biggest_index)
 
{
 
	return MakeCompanyButtonRows(biggest_index, WID_AID_COMPANY_BUTTON_START, WID_AID_COMPANY_BUTTON_END, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP);
 
	return MakeCompanyButtonRows(biggest_index, WID_AID_COMPANY_BUTTON_START, WID_AID_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP);
 
}
 

	
 
/**
 
 * Handler for global hotkeys of the AIDebugWindow.
 
 * @param hotkey Hotkey
 
 * @return ES_HANDLED if hotkey was accepted.
 
 */
 
static EventState AIDebugGlobalHotkeys(int hotkey)
 
{
 
	if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
 
	Window *w = ShowAIDebugWindow(INVALID_COMPANY);
 
	if (w == nullptr) return ES_NOT_HANDLED;
 
	return w->OnHotkey(hotkey);
 
}
 

	
 
static Hotkey aidebug_hotkeys[] = {
 
	Hotkey('1', "company_1", WID_AID_COMPANY_BUTTON_START),
 
	Hotkey('2', "company_2", WID_AID_COMPANY_BUTTON_START + 1),
 
	Hotkey('3', "company_3", WID_AID_COMPANY_BUTTON_START + 2),
 
	Hotkey('4', "company_4", WID_AID_COMPANY_BUTTON_START + 3),
 
	Hotkey('5', "company_5", WID_AID_COMPANY_BUTTON_START + 4),
 
	Hotkey('6', "company_6", WID_AID_COMPANY_BUTTON_START + 5),
 
	Hotkey('7', "company_7", WID_AID_COMPANY_BUTTON_START + 6),
 
	Hotkey('8', "company_8", WID_AID_COMPANY_BUTTON_START + 7),
src/graph_gui.cpp
Show inline comments
 
@@ -92,66 +92,66 @@ struct GraphLegendWindow : Window {
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		if (Company::IsValidID(data)) return;
 

	
 
		SetBit(_legend_excluded_companies, data);
 
		this->RaiseWidget(data + WID_GL_FIRST_COMPANY);
 
	}
 
};
 

	
 
/**
 
 * Construct a vertical list of buttons, one for each company.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @return Panel with company buttons.
 
 * @post \c *biggest_index contains the largest used index in the tree.
 
 */
 
static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index)
 
{
 
	NWidgetVertical *vert = new NWidgetVertical();
 
	uint line_height = std::max<uint>(GetSpriteSize(SPR_COMPANY_ICON).height, FONT_HEIGHT_NORMAL) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 

	
 
	for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum);
 
		panel->SetMinimalSize(246, line_height);
 
		panel->SetFill(1, 0);
 
		panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
 
		vert->Add(panel);
 
	}
 
	*biggest_index = WID_GL_LAST_COMPANY;
 
	return vert;
 
}
 

	
 
static const NWidgetPart _nested_graph_legend_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_GL_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(2, 0),
 
			NWidgetFunction(MakeNWidgetCompanyLines),
 
			NWidget(NWID_SPACER), SetMinimalSize(2, 0),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _graph_legend_desc(
 
	WDP_AUTO, "graph_legend", 0, 0,
 
	WC_GRAPH_LEGEND, WC_NONE,
 
	0,
 
	_nested_graph_legend_widgets, lengthof(_nested_graph_legend_widgets)
 
);
 

	
 
static void ShowGraphLegend()
 
{
 
	AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0);
 
}
 

	
 
/** Contains the interval of a graph's data. */
 
struct ValuesInterval {
 
	OverflowSafeInt64 highest; ///< Highest value of this interval. Must be zero or greater.
 
@@ -613,266 +613,266 @@ public:
 
		this->num_dataset = numd;
 
	}
 
};
 

	
 

	
 
/********************/
 
/* OPERATING PROFIT */
 
/********************/
 

	
 
struct OperatingProfitGraphWindow : BaseGraphWindow {
 
	OperatingProfitGraphWindow(WindowDesc *desc, WindowNumber window_number) :
 
			BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
 
	{
 
		this->InitializeWindow(window_number);
 
	}
 

	
 
	OverflowSafeInt64 GetGraphData(const Company *c, int j) override
 
	{
 
		return c->old_economy[j].income + c->old_economy[j].expenses;
 
	}
 
};
 

	
 
static const NWidgetPart _nested_operating_profit_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 160), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 160), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
 
				NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _operating_profit_desc(
 
	WDP_AUTO, "graph_operating_profit", 0, 0,
 
	WC_OPERATING_PROFIT, WC_NONE,
 
	0,
 
	_nested_operating_profit_widgets, lengthof(_nested_operating_profit_widgets)
 
);
 

	
 

	
 
void ShowOperatingProfitGraph()
 
{
 
	AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 0);
 
}
 

	
 

	
 
/****************/
 
/* INCOME GRAPH */
 
/****************/
 

	
 
struct IncomeGraphWindow : BaseGraphWindow {
 
	IncomeGraphWindow(WindowDesc *desc, WindowNumber window_number) :
 
			BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
 
	{
 
		this->InitializeWindow(window_number);
 
	}
 

	
 
	OverflowSafeInt64 GetGraphData(const Company *c, int j) override
 
	{
 
		return c->old_economy[j].income;
 
	}
 
};
 

	
 
static const NWidgetPart _nested_income_graph_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
 
				NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _income_graph_desc(
 
	WDP_AUTO, "graph_income", 0, 0,
 
	WC_INCOME_GRAPH, WC_NONE,
 
	0,
 
	_nested_income_graph_widgets, lengthof(_nested_income_graph_widgets)
 
);
 

	
 
void ShowIncomeGraph()
 
{
 
	AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 0);
 
}
 

	
 
/*******************/
 
/* DELIVERED CARGO */
 
/*******************/
 

	
 
struct DeliveredCargoGraphWindow : BaseGraphWindow {
 
	DeliveredCargoGraphWindow(WindowDesc *desc, WindowNumber window_number) :
 
			BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_COMMA)
 
	{
 
		this->InitializeWindow(window_number);
 
	}
 

	
 
	OverflowSafeInt64 GetGraphData(const Company *c, int j) override
 
	{
 
		return c->old_economy[j].delivered_cargo.GetSum<OverflowSafeInt64>();
 
	}
 
};
 

	
 
static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
 
				NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _delivered_cargo_graph_desc(
 
	WDP_AUTO, "graph_delivered_cargo", 0, 0,
 
	WC_DELIVERED_CARGO, WC_NONE,
 
	0,
 
	_nested_delivered_cargo_graph_widgets, lengthof(_nested_delivered_cargo_graph_widgets)
 
);
 

	
 
void ShowDeliveredCargoGraph()
 
{
 
	AllocateWindowDescFront<DeliveredCargoGraphWindow>(&_delivered_cargo_graph_desc, 0);
 
}
 

	
 
/***********************/
 
/* PERFORMANCE HISTORY */
 
/***********************/
 

	
 
struct PerformanceHistoryGraphWindow : BaseGraphWindow {
 
	PerformanceHistoryGraphWindow(WindowDesc *desc, WindowNumber window_number) :
 
			BaseGraphWindow(desc, WID_PHG_GRAPH, STR_JUST_COMMA)
 
	{
 
		this->InitializeWindow(window_number);
 
	}
 

	
 
	OverflowSafeInt64 GetGraphData(const Company *c, int j) override
 
	{
 
		return c->old_economy[j].performance_history;
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
 
		this->BaseGraphWindow::OnClick(pt, widget, click_count);
 
	}
 
};
 

	
 
static const NWidgetPart _nested_performance_history_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PHG_DETAILED_PERFORMANCE), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PHG_KEY), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_PHG_DETAILED_PERFORMANCE), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_PHG_KEY), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_PHG_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_PHG_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_PHG_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(WWT_EMPTY, COLOUR_BROWN, WID_PHG_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_PHG_RESIZE),
 
				NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_PHG_RESIZE),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _performance_history_desc(
 
	WDP_AUTO, "graph_performance", 0, 0,
 
	WC_PERFORMANCE_HISTORY, WC_NONE,
 
	0,
 
	_nested_performance_history_widgets, lengthof(_nested_performance_history_widgets)
 
);
 

	
 
void ShowPerformanceHistoryGraph()
 
{
 
	AllocateWindowDescFront<PerformanceHistoryGraphWindow>(&_performance_history_desc, 0);
 
}
 

	
 
/*****************/
 
/* COMPANY VALUE */
 
/*****************/
 

	
 
struct CompanyValueGraphWindow : BaseGraphWindow {
 
	CompanyValueGraphWindow(WindowDesc *desc, WindowNumber window_number) :
 
			BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
 
	{
 
		this->InitializeWindow(window_number);
 
	}
 

	
 
	OverflowSafeInt64 GetGraphData(const Company *c, int j) override
 
	{
 
		return c->old_economy[j].company_value;
 
	}
 
};
 

	
 
static const NWidgetPart _nested_company_value_graph_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
 
				NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _company_value_graph_desc(
 
	WDP_AUTO, "graph_company_value", 0, 0,
 
	WC_COMPANY_VALUE, WC_NONE,
 
	0,
 
	_nested_company_value_graph_widgets, lengthof(_nested_company_value_graph_widgets)
 
);
 

	
 
void ShowCompanyValueGraph()
 
{
 
	AllocateWindowDescFront<CompanyValueGraphWindow>(&_company_value_graph_desc, 0);
 
}
 

	
 
/*****************/
 
/* PAYMENT RATES */
 
/*****************/
 

	
 
struct PaymentRatesGraphWindow : BaseGraphWindow {
 
	uint line_height;   ///< Pixel height of each cargo type row.
 
	Scrollbar *vscroll; ///< Cargo list scrollbar.
 
@@ -933,49 +933,49 @@ struct PaymentRatesGraphWindow : BaseGra
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget != WID_CPR_MATRIX) {
 
			BaseGraphWindow::DrawWidget(r, widget);
 
			return;
 
		}
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		int x = r.left + WD_FRAMERECT_LEFT;
 
		int y = r.top;
 

	
 
		int pos = this->vscroll->GetPosition();
 
		int max = pos + this->vscroll->GetCapacity();
 

	
 
		const CargoSpec *cs;
 
		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
 
			if (pos-- > 0) continue;
 
			if (--max < 0) break;
 

	
 
			bool lowered = !HasBit(_legend_excluded_cargo, cs->Index());
 

	
 
			/* Redraw box if lowered */
 
			if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_ORANGE, lowered ? FR_LOWERED : FR_NONE);
 
			if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_BROWN, lowered ? FR_LOWERED : FR_NONE);
 

	
 
			byte clk_dif = lowered ? 1 : 0;
 
			int rect_x = clk_dif + (rtl ? r.right - 12 : r.left + WD_FRAMERECT_LEFT);
 

	
 
			GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, PC_BLACK);
 
			GfxFillRect(rect_x + 1, y + 1 + clk_dif, rect_x + 7, y + 4 + clk_dif, cs->legend_colour);
 
			SetDParam(0, cs->name);
 
			DrawString(rtl ? r.left : x + 14 + clk_dif, (rtl ? r.right - 14 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
 

	
 
			y += this->line_height;
 
		}
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_CPR_ENABLE_CARGOES:
 
				/* Remove all cargoes from the excluded lists. */
 
				_legend_excluded_cargo = 0;
 
				this->excluded_data = 0;
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_CPR_DISABLE_CARGOES: {
 
@@ -1028,80 +1028,80 @@ struct PaymentRatesGraphWindow : BaseGra
 
	{
 
		if (!gui_scope) return;
 
		this->OnHundredthTick();
 
	}
 

	
 
	void OnHundredthTick() override
 
	{
 
		this->UpdateExcludedData();
 

	
 
		int i = 0;
 
		const CargoSpec *cs;
 
		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
 
			this->colours[i] = cs->legend_colour;
 
			for (uint j = 0; j != 20; j++) {
 
				this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
 
			}
 
			i++;
 
		}
 
		this->num_dataset = i;
 
	}
 
};
 

	
 
static const NWidgetPart _nested_cargo_payment_rates_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CPR_BACKGROUND), SetMinimalSize(568, 128),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CPR_BACKGROUND), SetMinimalSize(568, 128),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_TEXT, COLOUR_GREY, WID_CPR_HEADER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL),
 
			NWidget(WWT_TEXT, COLOUR_BROWN, WID_CPR_HEADER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL),
 
			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CPR_GRAPH), SetMinimalSize(495, 0), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CPR_GRAPH), SetMinimalSize(495, 0), SetFill(1, 1), SetResize(1, 1),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_ENABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_ENABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
 
				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
 
				NWidget(NWID_HORIZONTAL),
 
					NWidget(WWT_MATRIX, COLOUR_ORANGE, WID_CPR_MATRIX), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
 
					NWidget(NWID_VSCROLLBAR, COLOUR_ORANGE, WID_CPR_MATRIX_SCROLLBAR),
 
					NWidget(WWT_MATRIX, COLOUR_BROWN, WID_CPR_MATRIX), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
 
					NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_CPR_MATRIX_SCROLLBAR),
 
				EndContainer(),
 
				NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_TEXT, COLOUR_GREY, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
 
			NWidget(WWT_TEXT, COLOUR_BROWN, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
 
			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CPR_RESIZE),
 
			NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CPR_RESIZE),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _cargo_payment_rates_desc(
 
	WDP_AUTO, "graph_cargo_payment_rates", 0, 0,
 
	WC_PAYMENT_RATES, WC_NONE,
 
	0,
 
	_nested_cargo_payment_rates_widgets, lengthof(_nested_cargo_payment_rates_widgets)
 
);
 

	
 

	
 
void ShowCargoPaymentRates()
 
{
 
	AllocateWindowDescFront<PaymentRatesGraphWindow>(&_cargo_payment_rates_desc, 0);
 
}
 

	
 
/************************/
 
/* COMPANY LEAGUE TABLE */
 
/************************/
 

	
 
static const StringID _performance_titles[] = {
 
	STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER,
 
	STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER,
 
@@ -1243,54 +1243,54 @@ public:
 
	{
 
		if (this->companies.NeedResort()) {
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
	{
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->companies.ForceRebuild();
 
		} else {
 
			this->companies.ForceResort();
 
		}
 
	}
 
};
 

	
 
static const NWidgetPart _nested_company_league_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CL_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM),
 
	NWidget(WWT_PANEL, COLOUR_BROWN, WID_CL_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM),
 
};
 

	
 
static WindowDesc _company_league_desc(
 
	WDP_AUTO, "league", 0, 0,
 
	WC_COMPANY_LEAGUE, WC_NONE,
 
	0,
 
	_nested_company_league_widgets, lengthof(_nested_company_league_widgets)
 
);
 

	
 
void ShowCompanyLeagueTable()
 
{
 
	AllocateWindowDescFront<CompanyLeagueWindow>(&_company_league_desc, 0);
 
}
 

	
 
/*****************************/
 
/* PERFORMANCE RATING DETAIL */
 
/*****************************/
 

	
 
struct PerformanceRatingDetailWindow : Window {
 
	static CompanyID company;
 
	int timeout;
 

	
 
	PerformanceRatingDetailWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
 
	{
 
@@ -1518,69 +1518,69 @@ CompanyID PerformanceRatingDetailWindow:
 
 * Make a vertical list of panels for outputting score details.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @return Panel with performance details.
 
 * @post \c *biggest_index contains the largest used index in the tree.
 
 */
 
static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
 
{
 
	const StringID performance_tips[] = {
 
		STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_STATIONS_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MIN_INCOME_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MAX_INCOME_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_DELIVERED_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_CARGO_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MONEY_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_LOAN_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
 
	};
 

	
 
	static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
 

	
 
	NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE);
 
	for (int widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum);
 
		panel->SetFill(1, 1);
 
		panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]);
 
		vert->Add(panel);
 
	}
 
	*biggest_index = WID_PRD_SCORE_LAST;
 
	return vert;
 
}
 

	
 
/** Make a number of rows with buttons for each company for the performance rating detail window. */
 
NWidgetBase *MakeCompanyButtonRowsGraphGUI(int *biggest_index)
 
{
 
	return MakeCompanyButtonRows(biggest_index, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP);
 
	return MakeCompanyButtonRows(biggest_index, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP);
 
}
 

	
 
static const NWidgetPart _nested_performance_rating_detail_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
	NWidget(WWT_PANEL, COLOUR_BROWN),
 
		NWidgetFunction(MakeCompanyButtonRowsGraphGUI), SetPadding(0, 1, 1, 2),
 
	EndContainer(),
 
	NWidgetFunction(MakePerformanceDetailPanels),
 
};
 

	
 
static WindowDesc _performance_rating_detail_desc(
 
	WDP_AUTO, "league_details", 0, 0,
 
	WC_PERFORMANCE_DETAIL, WC_NONE,
 
	0,
 
	_nested_performance_rating_detail_widgets, lengthof(_nested_performance_rating_detail_widgets)
 
);
 

	
 
void ShowPerformanceRatingDetail()
 
{
 
	AllocateWindowDescFront<PerformanceRatingDetailWindow>(&_performance_rating_detail_desc, 0);
 
}
 

	
 
void InitializeGraphGui()
 
{
 
	_legend_excluded_companies = 0;
 
	_legend_excluded_cargo = 0;
 
}
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -354,49 +354,49 @@ Point LinkGraphOverlay::GetStationMiddle
 
 * Set a new cargo mask and rebuild the cache.
 
 * @param cargo_mask New cargo mask.
 
 */
 
void LinkGraphOverlay::SetCargoMask(CargoTypes cargo_mask)
 
{
 
	this->cargo_mask = cargo_mask;
 
	this->RebuildCache();
 
	this->window->GetWidget<NWidgetBase>(this->widget_id)->SetDirty(this->window);
 
}
 

	
 
/**
 
 * Set a new company mask and rebuild the cache.
 
 * @param company_mask New company mask.
 
 */
 
void LinkGraphOverlay::SetCompanyMask(uint32 company_mask)
 
{
 
	this->company_mask = company_mask;
 
	this->RebuildCache();
 
	this->window->GetWidget<NWidgetBase>(this->widget_id)->SetDirty(this->window);
 
}
 

	
 
/** 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_NULL);
 
	return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL);
 
}
 

	
 
NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index)
 
{
 
	NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE);
 
	for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS); ++i) {
 
		NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST);
 
		wid->SetMinimalSize(50, FONT_HEIGHT_SMALL);
 
		wid->SetFill(1, 1);
 
		wid->SetResize(0, 0);
 
		panel->Add(wid);
 
	}
 
	*biggest_index = WID_LGL_SATURATION_LAST;
 
	return panel;
 
}
 

	
 
NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index)
 
{
 
	static const uint ENTRIES_PER_ROW = CeilDiv(NUM_CARGO, 5);
 
	NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE);
 
	NWidgetHorizontal *row = nullptr;
 
	for (uint i = 0; i < NUM_CARGO; ++i) {
 
		if (i % ENTRIES_PER_ROW == 0) {
 
			if (row) panel->Add(row);
src/signs_gui.cpp
Show inline comments
 
@@ -336,71 +336,71 @@ struct SignListWindow : Window, SignList
 
	static HotkeyList hotkeys;
 
};
 

	
 
/**
 
 * Handler for global hotkeys of the SignListWindow.
 
 * @param hotkey Hotkey
 
 * @return ES_HANDLED if hotkey was accepted.
 
 */
 
static EventState SignListGlobalHotkeys(int hotkey)
 
{
 
	if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
 
	Window *w = ShowSignList();
 
	if (w == nullptr) return ES_NOT_HANDLED;
 
	return w->OnHotkey(hotkey);
 
}
 

	
 
static Hotkey signlist_hotkeys[] = {
 
	Hotkey('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
 
	HOTKEY_LIST_END
 
};
 
HotkeyList SignListWindow::hotkeys("signlist", signlist_hotkeys, SignListGlobalHotkeys);
 

	
 
static const NWidgetPart _nested_sign_list_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, WID_SIL_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SIL_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
 
		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_PANEL, COLOUR_GREY, WID_SIL_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + 255 + WD_FRAMETEXT_RIGHT, 50),
 
			NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + 255 + WD_FRAMETEXT_RIGHT, 50),
 
								SetResize(1, 10), SetFill(1, 0), SetScrollbar(WID_SIL_SCROLLBAR), EndContainer(),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1),
 
					NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SIL_FILTER_TEXT), SetMinimalSize(80, 12), SetResize(1, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),
 
				NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
 
					NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_SIL_FILTER_TEXT), SetMinimalSize(80, 12), SetResize(1, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),
 
							SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
				EndContainer(),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SIL_FILTER_MATCH_CASE_BTN), SetDataTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
 
				NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SIL_FILTER_MATCH_CASE_BTN), SetDataTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(NWID_VERTICAL), SetFill(0, 1),
 
				NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SIL_SCROLLBAR),
 
				NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SIL_SCROLLBAR),
 
			EndContainer(),
 
			NWidget(WWT_RESIZEBOX, COLOUR_GREY),
 
			NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _sign_list_desc(
 
	WDP_AUTO, "list_signs", 358, 138,
 
	WC_SIGN_LIST, WC_NONE,
 
	0,
 
	_nested_sign_list_widgets, lengthof(_nested_sign_list_widgets),
 
	&SignListWindow::hotkeys
 
);
 

	
 
/**
 
 * Open the sign list window
 
 *
 
 * @return newly opened sign list window, or nullptr if the window could not be opened.
 
 */
 
Window *ShowSignList()
 
{
 
	return AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
 
}
 

	
 
/**
 
 * Actually rename the sign.
src/widget.cpp
Show inline comments
 
@@ -2842,74 +2842,75 @@ NWidgetContainer *MakeWindowNWidgetTree(
 
	NWidgetContainer *body;
 
	if (hor_cont != nullptr && hor_cont->GetWidgetOfType(WWT_CAPTION) != nullptr && hor_cont->GetWidgetOfType(WWT_SHADEBOX) != nullptr) {
 
		*shade_select = new NWidgetStacked;
 
		root->Add(*shade_select);
 
		body = new NWidgetVertical;
 
		(*shade_select)->Add(body);
 
	} else {
 
		*shade_select = nullptr;
 
		body = root;
 
	}
 

	
 
	/* Load the remaining parts into 'body'. */
 
	int biggest2 = -1;
 
	MakeNWidgets(parts, count, &biggest2, body);
 

	
 
	*biggest_index = std::max(*biggest_index, biggest2);
 
	return root;
 
}
 

	
 
/**
 
 * Make a number of rows with button-like graphics, for enabling/disabling each company.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @param widget_first The first widget index to use.
 
 * @param widget_last The last widget index to use.
 
 * @param colour The colour in which to draw the button.
 
 * @param max_length Maximal number of company buttons in one row.
 
 * @param button_tooltip The tooltip-string of every button.
 
 * @return Panel with rows of company buttons.
 
 * @post \c *biggest_index contains the largest used index in the tree.
 
 */
 
NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, int max_length, StringID button_tooltip)
 
NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip)
 
{
 
	assert(max_length >= 1);
 
	NWidgetVertical *vert = nullptr; // Storage for all rows.
 
	NWidgetHorizontal *hor = nullptr; // Storage for buttons in one row.
 
	int hor_length = 0;
 

	
 
	Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
	sprite_size.width  += WD_MATRIX_LEFT + WD_MATRIX_RIGHT;
 
	sprite_size.height += WD_MATRIX_TOP + WD_MATRIX_BOTTOM + 1; // 1 for the 'offset' of being pressed
 

	
 
	for (int widnum = widget_first; widnum <= widget_last; widnum++) {
 
		/* Ensure there is room in 'hor' for another button. */
 
		if (hor_length == max_length) {
 
			if (vert == nullptr) vert = new NWidgetVertical();
 
			vert->Add(hor);
 
			hor = nullptr;
 
			hor_length = 0;
 
		}
 
		if (hor == nullptr) {
 
			hor = new NWidgetHorizontal();
 
			hor_length = 0;
 
		}
 

	
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, button_colour, widnum);
 
		panel->SetMinimalSize(sprite_size.width, sprite_size.height);
 
		panel->SetFill(1, 1);
 
		panel->SetResize(1, 0);
 
		panel->SetDataTip(0x0, button_tooltip);
 
		hor->Add(panel);
 
		hor_length++;
 
	}
 
	*biggest_index = widget_last;
 
	if (vert == nullptr) return hor; // All buttons fit in a single row.
 

	
 
	if (hor_length > 0 && hor_length < max_length) {
 
		/* Last row is partial, add a spacer at the end to force all buttons to the left. */
 
		NWidgetSpacer *spc = new NWidgetSpacer(sprite_size.width, sprite_size.height);
 
		spc->SetFill(1, 1);
 
		spc->SetResize(1, 0);
 
		hor->Add(spc);
 
	}
 
	if (hor != nullptr) vert->Add(hor);
 
	return vert;
 
}
src/widget_type.h
Show inline comments
 
@@ -1134,27 +1134,27 @@ static inline NWidgetPart NWidget(Widget
 
	part.type = tp;
 
	part.u.cont_flags = cont_flags;
 

	
 
	return part;
 
}
 

	
 
/**
 
 * Obtain a nested widget (sub)tree from an external source.
 
 * @param func_ptr Pointer to function that returns the tree.
 
 * @ingroup NestedWidgetParts
 
 */
 
static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
 
{
 
	NWidgetPart part;
 

	
 
	part.type = WPT_FUNCTION;
 
	part.u.func_ptr = func_ptr;
 

	
 
	return part;
 
}
 

	
 
NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
 
NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
 

	
 
NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, int max_length, StringID button_tooltip);
 
NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip);
 

	
 
#endif /* WIDGET_TYPE_H */
0 comments (0 inline, 0 general)