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
@@ -39,7 +39,7 @@ public:
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_TT_SIGNS:
|
||||
@@ -51,13 +51,13 @@ public:
|
||||
case WID_TT_STRUCTURES:
|
||||
case WID_TT_CATENARY:
|
||||
case WID_TT_TEXT: {
|
||||
uint i = widget - WID_TT_BEGIN;
|
||||
int i = widget - WID_TT_BEGIN;
|
||||
if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + WidgetDimensions::scaled.fullbevel.left, r.top + WidgetDimensions::scaled.fullbevel.top);
|
||||
break;
|
||||
}
|
||||
case WID_TT_BUTTONS: {
|
||||
const Rect fr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) {
|
||||
for (WidgetID i = WID_TT_BEGIN; i < WID_TT_END; i++) {
|
||||
if (i == WID_TT_TEXT) continue; // Loading and cost/income text has no invisibility button.
|
||||
|
||||
const Rect wr = this->GetWidget<NWidgetBase>(i)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel);
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
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_TT_BEGIN && widget < WID_TT_END) {
|
||||
if (_ctrl_pressed) {
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) {
|
||||
for (WidgetID i = WID_TT_BEGIN; i < WID_TT_END; i++) {
|
||||
this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN)));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user