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

Need scripted way to a add button to vanilla interface windows #545

Open
phobos2077 opened this issue Jun 1, 2024 · 1 comment
Open

Comments

@phobos2077
Copy link
Collaborator

In the vain of interface_art_draw and interface_print, need a way to add button to a built-in interface window, such as the main interface panel (iface).

AddButton and related opcodes deal with managed windows and buttons. These exist as a higher abstraction layer, separate list of windows w/ buttons, but they use the same low-level windows that the game itself uses underneath. Need a way to hack into that.

Just drawing button is not enough, need a way to click on it too.

Potential workaround

I can try using MOUSECLICK hook or get_mouse_buttons to detect clicks and then just draw the button FRM using existing functions. A "fake" button. But this should be better than creating separate small window that sits on top of vanilla window (this causes huge pain with overlapping under different sfall/hrp configurations).

@phobos2077
Copy link
Collaborator Author

phobos2077 commented Jun 2, 2024

My potential workaround worked pretty well. Although, I had to use global_script_repeat(1) when button is pressed to detect when it's out and un-press it. Also needed to add get_window_attribute option 5 to return window ID that I can then compare with get_window_under_mouse to make sure there's no other window overlapping when I press the mouse. Although this ID is the same between runs, it changes when switching to external HRP or using certain HRP options. As a workaround for this workaround, I used get_game_mode to know if any window is open, but this is not robust.

I still think a metarule to add button may be useful in future, as a more robust, efficient and straightforward way to extend vanilla UI with new interactive elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant