Need scripted way to a add button to vanilla interface windows
phobos2077 opened this issue · 1 comments
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).
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.