Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenRCT2 does not allow image updates for WindowWidgetType::ImgBtn #22007

Closed
mrmagic2020 opened this issue May 10, 2024 · 1 comment
Closed
Labels
bug Something went wrong. plug-in Related to the plugin system of OpenRCT2.

Comments

@mrmagic2020
Copy link

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

@mrmagic2020 mrmagic2020 added the bug Something went wrong. label May 10, 2024
@Basssiiie
Copy link
Member

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.

@Gymnasiast Gymnasiast added the plug-in Related to the plugin system of OpenRCT2. label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong. plug-in Related to the plugin system of OpenRCT2.
Projects
None yet
Development

No branches or pull requests

3 participants