OpenRCT2/OpenRCT2

OpenRCT2 does not allow image updates for `WindowWidgetType::ImgBtn`

Closed this issue · 1 comments

Operating System

macOS 14.4.1 (23E224)

OpenRCT2 build

OpenRCT2, v0.4.11 (893392d on develop, DEBUG)

Base game

RollerCoaster Tycoon Classic

Area(s) with this issue?

This bug is a graphical glitch or error

Describe the issue

OpenRCT2 only allows button image updates for WindowWidgetType::FlatBtn but not WindowWidgetType::ImgBtn.
Seen here:

uint32_t image_get() const
{
auto widget = GetWidget();
if (widget != nullptr && widget->type == WindowWidgetType::FlatBtn)
{
if (GetTargetAPIVersion() <= API_VERSION_63_G2_REORDER)
{
return LegacyIconIndex(widget->image.GetIndex());
}
return widget->image.GetIndex();
}
return 0;
}
void image_set(DukValue value)
{
auto widget = GetWidget();
if (widget != nullptr && widget->type == WindowWidgetType::FlatBtn)
{
widget->image = ImageId(ImageFromDuk(value));
Invalidate();
}
}

Steps to reproduce

  1. Using Basssiiie's FlexUI, create a button widget with properties border = true, image=compute(<store-containing-sprite-id>, value => return value), and an onClick callback function that changes the sprite ID on each click.
  2. Load the plugin and click the button. The image does not update.
  3. Close and reopen the window. Now the image is updated.
  4. Change border to false. Now the image updates on each click.

Attachments

No response

To add to this. It's not necessary to use FlexUI to reproduce the bug. You can also make a vanilla button widget with border: true, and then attempt to update it with findWidget("my-button").image = 5000;. 🙂 Furthermore, getting the image id will also always return 0 for buttons with a border.