Codechange: Replace mishmash of types for widget index with WidgetID.
Indices were stored as int, but often passed around as uint/uint8_t and casts. Now they should all use WidgetID.
This commit is contained in:

committed by
Peter Nelson

parent
fd84f73323
commit
a0dfb76e34
@@ -258,7 +258,7 @@ struct DepotWindow : Window {
|
||||
VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none.
|
||||
VehicleType type;
|
||||
bool generate_list;
|
||||
int hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
|
||||
WidgetID hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
|
||||
VehicleList vehicle_list;
|
||||
VehicleList wagon_list;
|
||||
uint unitnumber_digits;
|
||||
@@ -363,7 +363,7 @@ struct DepotWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget != WID_D_MATRIX) return;
|
||||
|
||||
@@ -421,7 +421,7 @@ struct DepotWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
void SetStringParameters(WidgetID widget) const override
|
||||
{
|
||||
if (widget != WID_D_CAPTION) return;
|
||||
|
||||
@@ -653,7 +653,7 @@ struct DepotWindow : Window {
|
||||
this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING));
|
||||
}
|
||||
|
||||
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_D_MATRIX: {
|
||||
@@ -757,7 +757,7 @@ struct DepotWindow : Window {
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
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_D_MATRIX: // List
|
||||
@@ -839,7 +839,7 @@ struct DepotWindow : Window {
|
||||
Command<CMD_RENAME_DEPOT>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDepotIndex(), str);
|
||||
}
|
||||
|
||||
bool OnRightClick([[maybe_unused]] Point pt, int widget) override
|
||||
bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override
|
||||
{
|
||||
if (widget != WID_D_MATRIX) return false;
|
||||
|
||||
@@ -974,7 +974,7 @@ struct DepotWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseDrag(Point pt, int widget) override
|
||||
void OnMouseDrag(Point pt, WidgetID widget) override
|
||||
{
|
||||
if (this->sel == INVALID_VEHICLE) return;
|
||||
if (widget != this->hovered_widget) {
|
||||
@@ -1025,7 +1025,7 @@ struct DepotWindow : Window {
|
||||
this->SetWidgetDirty(widget);
|
||||
}
|
||||
|
||||
void OnDragDrop(Point pt, int widget) override
|
||||
void OnDragDrop(Point pt, WidgetID widget) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_D_MATRIX: {
|
||||
|
Reference in New Issue
Block a user