Changeset - r27930:570b530b18db
[Not reviewed]
master
0 9 0
Rubidium - 15 months ago 2023-09-17 14:24:29
rubidium@openttd.org
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.
9 files changed with 15 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -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
src/rail_gui.cpp
Show inline comments
 
@@ -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);
 
	}
src/road_gui.cpp
Show inline comments
 
@@ -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);
 
	}
src/terraform_gui.cpp
Show inline comments
 
@@ -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 ScenarioEditorLandscapeGeneration
 
		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
src/widget_type.h
Show inline comments
 
@@ -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. */
src/widgets/airport_widget.h
Show inline comments
 
@@ -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. */
src/widgets/rail_widget.h
Show inline comments
 
@@ -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. */
src/widgets/road_widget.h
Show inline comments
 
@@ -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. */
src/widgets/terraform_widget.h
Show inline comments
 
@@ -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 */
0 comments (0 inline, 0 general)