Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/ci-build.yml # .github/workflows/release-linux.yml # .github/workflows/release-macos.yml # .github/workflows/release-windows.yml # .gitignore # COMPILING.md # src/company_gui.cpp # src/date_gui.cpp # src/engine.cpp # src/engine_func.h # src/fileio.cpp # src/linkgraph/linkgraph_gui.h # src/newgrf_debug_gui.cpp # src/newgrf_gui.cpp # src/order_gui.cpp # src/osk_gui.cpp # src/rail_gui.cpp # src/road_gui.cpp # src/script/api/script_event_types.hpp # src/sl/oldloader_sl.cpp # src/smallmap_gui.cpp # src/station_cmd.cpp # src/toolbar_gui.cpp # src/town_gui.cpp # src/transparency_gui.cpp # src/vehicle_gui.cpp # src/widget.cpp # src/widget_type.h # src/widgets/dropdown.cpp # src/widgets/dropdown_func.h # src/widgets/dropdown_type.h # src/widgets/group_widget.h # src/widgets/vehicle_widget.h # src/window.cpp # src/window_gui.h # src/window_type.h
This commit is contained in:
@@ -59,7 +59,7 @@ struct GraphLegendWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return;
|
||||
|
||||
@@ -79,7 +79,7 @@ struct GraphLegendWindow : Window {
|
||||
DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return;
|
||||
|
||||
@@ -110,25 +110,22 @@ struct GraphLegendWindow : Window {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
static std::unique_ptr<NWidgetBase> MakeNWidgetCompanyLines()
|
||||
{
|
||||
NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE);
|
||||
auto vert = std::make_unique<NWidgetVertical>(NC_EQUALSIZE);
|
||||
vert->SetPadding(2, 2, 2, 2);
|
||||
uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height;
|
||||
|
||||
for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
|
||||
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum);
|
||||
for (WidgetID widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
|
||||
auto panel = std::make_unique<NWidgetBackground>(WWT_PANEL, COLOUR_BROWN, widnum);
|
||||
panel->SetMinimalSize(246, sprite_height + WidgetDimensions::unscaled.framerect.Vertical());
|
||||
panel->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL);
|
||||
panel->SetFill(1, 1);
|
||||
panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
|
||||
vert->Add(panel);
|
||||
vert->Add(std::move(panel));
|
||||
}
|
||||
*biggest_index = WID_GL_LAST_COMPANY;
|
||||
return vert;
|
||||
}
|
||||
|
||||
@@ -197,7 +194,7 @@ protected:
|
||||
uint16 x_values_start;
|
||||
uint16 x_values_increment;
|
||||
|
||||
int graph_widget;
|
||||
WidgetID graph_widget;
|
||||
StringID format_str_y_axis;
|
||||
byte colours[GRAPH_MAX_DATASETS];
|
||||
OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months
|
||||
@@ -489,7 +486,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) :
|
||||
BaseGraphWindow(WindowDesc *desc, WidgetID widget, StringID format_str_y_axis) :
|
||||
Window(desc),
|
||||
format_str_y_axis(format_str_y_axis)
|
||||
{
|
||||
@@ -513,7 +510,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
if (widget != this->graph_widget) return;
|
||||
|
||||
@@ -549,7 +546,7 @@ public:
|
||||
size->height = std::max<uint>(size->height, size->width / 3);
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget != this->graph_widget) return;
|
||||
|
||||
@@ -561,7 +558,7 @@ public:
|
||||
return INVALID_DATAPOINT;
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
/* Clicked on legend? */
|
||||
if (widget == WID_CV_KEY_BUTTON) ShowGraphLegend();
|
||||
@@ -747,7 +744,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow {
|
||||
Scrollbar *vscroll; ///< Cargo list scrollbar.
|
||||
uint legend_width; ///< Width of legend 'blob'.
|
||||
|
||||
ExcludingCargoBaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis):
|
||||
ExcludingCargoBaseGraphWindow(WindowDesc *desc, WidgetID widget, StringID format_str_y_axis):
|
||||
BaseGraphWindow(desc, widget, format_str_y_axis)
|
||||
{}
|
||||
|
||||
@@ -757,7 +754,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow {
|
||||
this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 9 / 6;
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
virtual void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
if (widget != WID_ECBG_MATRIX) {
|
||||
BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
|
||||
@@ -779,7 +776,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow {
|
||||
resize->height = this->line_height;
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const override
|
||||
virtual void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget != WID_ECBG_MATRIX) {
|
||||
BaseGraphWindow::DrawWidget(r, widget);
|
||||
@@ -816,7 +813,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count) override
|
||||
virtual void OnClick(Point pt, WidgetID widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_CV_KEY_BUTTON:
|
||||
@@ -897,7 +894,7 @@ struct DeliveredCargoGraphWindow : ExcludingCargoBaseGraphWindow {
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count) override
|
||||
virtual void OnClick(Point pt, WidgetID widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_DCG_BY_COMPANY:
|
||||
@@ -1060,7 +1057,7 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow {
|
||||
return c->old_economy[j].performance_history;
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
|
||||
this->BaseGraphWindow::OnClick(pt, widget, click_count);
|
||||
@@ -1266,7 +1263,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
if (widget != WID_CPR_MATRIX) {
|
||||
BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
|
||||
@@ -1290,7 +1287,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||
resize->height = this->line_height;
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget != WID_CPR_MATRIX) {
|
||||
BaseGraphWindow::DrawWidget(r, widget);
|
||||
@@ -1327,7 +1324,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_CPR_ENABLE_CARGOES:
|
||||
@@ -1412,7 +1409,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||
this->num_dataset = i;
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
void SetStringParameters(WidgetID widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_CPR_FOOTER:
|
||||
@@ -1534,7 +1531,7 @@ struct PerformanceRatingDetailWindow : Window {
|
||||
uint score_detail_left;
|
||||
uint score_detail_right;
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_PRD_SCORE_FIRST:
|
||||
@@ -1592,7 +1589,7 @@ struct PerformanceRatingDetailWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
/* No need to draw when there's nothing to draw */
|
||||
if (this->company == INVALID_COMPANY) return;
|
||||
@@ -1670,7 +1667,7 @@ struct PerformanceRatingDetailWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
/* Check which button is clicked */
|
||||
if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) {
|
||||
@@ -1729,11 +1726,9 @@ CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
static std::unique_ptr<NWidgetBase> MakePerformanceDetailPanels()
|
||||
{
|
||||
const StringID performance_tips[] = {
|
||||
STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP,
|
||||
@@ -1750,21 +1745,20 @@ static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
|
||||
|
||||
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_BROWN, widnum);
|
||||
auto vert = std::make_unique<NWidgetVertical>(NC_EQUALSIZE);
|
||||
for (WidgetID widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) {
|
||||
auto panel = std::make_unique<NWidgetBackground>(WWT_PANEL, COLOUR_BROWN, widnum);
|
||||
panel->SetFill(1, 1);
|
||||
panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]);
|
||||
vert->Add(panel);
|
||||
vert->Add(std::move(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)
|
||||
std::unique_ptr<NWidgetBase> MakeCompanyButtonRowsGraphGUI()
|
||||
{
|
||||
return MakeCompanyButtonRows(biggest_index, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP);
|
||||
return MakeCompanyButtonRows(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[] = {
|
||||
@@ -1836,7 +1830,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
|
||||
this->legend_excluded_cargo = 0;
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
void SetStringParameters(WidgetID widget) const override
|
||||
{
|
||||
if (widget == WID_SCG_CAPTION) {
|
||||
SetDParam(0, this->station_id);
|
||||
@@ -1858,7 +1852,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
if (widget < WID_SCG_MATRIX) {
|
||||
BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
|
||||
@@ -1880,7 +1874,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
|
||||
resize->height = this->line_height;
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget < WID_SCG_MATRIX) {
|
||||
BaseGraphWindow::DrawWidget(r, widget);
|
||||
@@ -1921,7 +1915,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
void OnClick(Point pt, WidgetID widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SCG_ENABLE_CARGOES:
|
||||
|
Reference in New Issue
Block a user