Codechange: use better location for the "invalid" action sentinel value

It used to be a random sentinel for end-of-(widget-)list that was used to tell
that no action has taken place yet. Since the last action is practically the
widget that was pressed, add the sentinel to that enumeration.
This commit is contained in:
Rubidium 2023-09-17 16:24:29 +02:00 committed by rubidium42
parent 09a7902d36
commit 3a2509198f
9 changed files with 15 additions and 7 deletions

View File

@ -87,7 +87,7 @@ struct BuildAirToolbarWindow : Window {
this->InitNested(window_number);
this->OnInvalidateData();
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
this->last_user_action = WIDGET_LIST_END;
this->last_user_action = INVALID_WID_AT;
}
void Close() override

View File

@ -414,7 +414,7 @@ struct BuildRailToolbarWindow : Window {
this->InitNested(TRANSPORT_RAIL);
this->SetupRailToolbar(railtype);
this->DisableWidget(WID_RAT_REMOVE);
this->last_user_action = WIDGET_LIST_END;
this->last_user_action = INVALID_WID_RAT;
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}

View File

@ -324,7 +324,7 @@ struct BuildRoadToolbarWindow : Window {
}
this->OnInvalidateData();
this->last_started_action = WIDGET_LIST_END;
this->last_started_action = INVALID_WID_ROT;
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}

View File

@ -161,7 +161,7 @@ struct TerraformToolbarWindow : Window {
/* This is needed as we like to have the tree available on OnInit. */
this->CreateNestedTree();
this->FinishInitNested(window_number);
this->last_user_action = WIDGET_LIST_END;
this->last_user_action = INVALID_WID_TT;
}
~TerraformToolbarWindow()
@ -542,7 +542,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
NWidgetStacked *show_desert = this->GetWidget<NWidgetStacked>(WID_ETT_SHOW_PLACE_DESERT);
show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE);
this->FinishInitNested(window_number);
this->last_user_action = WIDGET_LIST_END;
this->last_user_action = INVALID_WID_ETT;
}
void OnPaint() override

View File

@ -17,8 +17,6 @@
#include "gfx_type.h"
#include "window_type.h"
static const int WIDGET_LIST_END = -1; ///< indicate the end of widgets' list for vararg functions
/** Bits of the #WWT_MATRIX widget data. */
enum MatrixWidgetValues {
/* Number of column bits of the WWT_MATRIX widget data. */

View File

@ -14,6 +14,8 @@
enum AirportToolbarWidgets {
WID_AT_AIRPORT, ///< Build airport button.
WID_AT_DEMOLISH, ///< Demolish button.
INVALID_WID_AT = -1,
};
/** Widgets of the #BuildAirportWindow class. */

View File

@ -28,6 +28,8 @@ enum RailToolbarWidgets {
WID_RAT_BUILD_TUNNEL, ///< Build a tunnel.
WID_RAT_REMOVE, ///< Bulldozer to remove rail.
WID_RAT_CONVERT_RAIL, ///< Convert other rail to this type.
INVALID_WID_RAT = -1,
};
/** Widgets of the #BuildRailStationWindow class. */

View File

@ -26,6 +26,8 @@ enum RoadToolbarWidgets {
WID_ROT_BUILD_TUNNEL, ///< Build tunnel.
WID_ROT_REMOVE, ///< Remove road.
WID_ROT_CONVERT_ROAD, ///< Convert road.
INVALID_WID_ROT = -1,
};
/** Widgets of the #BuildRoadDepotWindow class. */

View File

@ -22,6 +22,8 @@ enum TerraformToolbarWidgets {
WID_TT_PLANT_TREES, ///< Plant trees button (note: opens separate window, no place-push-button).
WID_TT_PLACE_SIGN, ///< Place sign button.
WID_TT_PLACE_OBJECT, ///< Place object button.
INVALID_WID_TT = -1,
};
/** Widgets of the #ScenarioEditorLandscapeGenerationWindow class. */
@ -42,6 +44,8 @@ enum EditorTerraformToolbarWidgets {
WID_ETT_DECREASE_SIZE, ///< Downwards arrow button to decrease terraforming size.
WID_ETT_NEW_SCENARIO, ///< Button for generating a new scenario.
WID_ETT_RESET_LANDSCAPE, ///< Button for removing all company-owned property.
INVALID_WID_ETT = -1,
};
#endif /* WIDGETS_TERRAFORM_WIDGET_H */