mirror of https://github.com/OpenRCT2/OpenRCT2.git
fix and refactor window event calls
This commit is contained in:
parent
0cef1c9517
commit
5a4b940fc2
|
@ -692,7 +692,7 @@ static void input_widget_over_flatbutton_invalidate()
|
|||
if (w == NULL)
|
||||
return;
|
||||
|
||||
window_event_helper(w, 0, WE_INVALIDATE);
|
||||
window_event_invalidate_call(w);
|
||||
if (w->widgets[RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)].type == WWT_FLATBTN) {
|
||||
widget_invalidate_by_number(
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass),
|
||||
|
@ -773,7 +773,7 @@ static void input_widget_left(int x, int y, rct_window *w, int widgetIndex)
|
|||
RCT2_GLOBAL(0x009DE528, uint16) = 1;
|
||||
|
||||
widget_invalidate_by_number(windowClass, windowNumber, widgetIndex);
|
||||
window_event_helper(w, widgetIndex, WE_MOUSE_DOWN);
|
||||
window_event_mouse_down_call(w, widgetIndex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -943,7 +943,7 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w
|
|||
if (w->var_020 & (1ULL << widgetIndex) &&
|
||||
RCT2_GLOBAL(0x9DE528, uint16) >= 0x10 &&
|
||||
(!(RCT2_GLOBAL(0x9DE528, uint16) & 0x3))){
|
||||
window_event_helper(w, widgetIndex, WE_MOUSE_DOWN);
|
||||
window_event_mouse_down_call(w, widgetIndex);
|
||||
}
|
||||
|
||||
if (RCT2_GLOBAL(0x9DE518, uint32) & 1) return;
|
||||
|
@ -1014,7 +1014,7 @@ void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_w
|
|||
break;
|
||||
|
||||
widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex);
|
||||
window_event_helper(w, widgetIndex, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(w, widgetIndex);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ static void shortcut_pause_game()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 0, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ static void shortcut_zoom_view_out()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 2, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static void shortcut_zoom_view_in()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 3, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ static void shortcut_rotate_view()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 4, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ static void shortcut_adjust_land()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 7, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ static void shortcut_adjust_water()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 8, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ static void shortcut_build_scenery()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 9, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ static void shortcut_build_paths()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 10, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ static void shortcut_build_new_ride()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 11, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ static void shortcut_show_research_information()
|
|||
RCT2_CALLPROC_EBPSAFE(0x006B3CFF);
|
||||
window = window_find_by_class(WC_CONSTRUCT_RIDE);
|
||||
if (window != NULL)
|
||||
window_event_helper(window, 10, WE_MOUSE_DOWN);
|
||||
window_event_mouse_up_call(window, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ static void shortcut_show_rides_list()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 12, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ static void shortcut_show_park_information()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 13, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 13);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ static void shortcut_show_guest_list()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 15, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ static void shortcut_show_staff_list()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 14, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 14);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ static void shortcut_show_map()
|
|||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != NULL) {
|
||||
window_invalidate(window);
|
||||
window_event_helper(window, 6, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(window, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1585,12 +1585,53 @@ void window_guest_list_init_vars_b()
|
|||
RCT2_GLOBAL(0x00F1AF20, uint16) = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for window events so C functions can call them
|
||||
*/
|
||||
void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event)
|
||||
void window_event_mouse_up_call(rct_window* w, int widgetIndex)
|
||||
{
|
||||
RCT2_CALLPROC_X(w->event_handlers[event], 0, 0, 0, widgetIndex, (int)w, (int)&(w->event_handlers[widgetIndex]), 0);
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_UP], 0, 0, 0, widgetIndex, (int)w, (int)&(w->event_handlers[widgetIndex]), 0);
|
||||
}
|
||||
|
||||
void window_event_resize_call(rct_window* w)
|
||||
{
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0);
|
||||
}
|
||||
|
||||
void window_event_mouse_down_call(rct_window *w, int widgetIndex)
|
||||
{
|
||||
int address = w->event_handlers[WE_MOUSE_DOWN];
|
||||
rct_widget *widget = &w->widgets[widgetIndex];
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm {
|
||||
push address
|
||||
push widget
|
||||
push w
|
||||
push widgetIndex
|
||||
mov edi, widget
|
||||
mov edx, widgetIndex
|
||||
mov esi, w
|
||||
call[esp + 12]
|
||||
add esp, 16
|
||||
}
|
||||
#else
|
||||
__asm__("\
|
||||
push %[address]\n\
|
||||
mov edi, %[widget] \n\
|
||||
mov eax, %[w] \n\
|
||||
mov edx, %[widgetIndex] \n\
|
||||
push edi \n\
|
||||
push eax \n\
|
||||
push edx \n\
|
||||
mov esi, %[w] \n\
|
||||
call [esp+12] \n\
|
||||
add esp, 16 \n\
|
||||
" :[address] "+m" (address), [w] "+m" (w), [widget] "+m" (widget), [widgetIndex] "+m" (widgetIndex): : "eax", "esi", "edx", "edi"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void window_event_invalidate_call(rct_window* w)
|
||||
{
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -538,7 +538,10 @@ void window_map_tooltip_update_visibility();
|
|||
|
||||
void window_staff_list_init_vars();
|
||||
|
||||
void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event);
|
||||
void window_event_mouse_up_call(rct_window* w, int widgetIndex);
|
||||
void window_event_resize_call(rct_window* w);
|
||||
void window_event_mouse_down_call(rct_window* w, int widgetIndex);
|
||||
void window_event_invalidate_call(rct_window* w);
|
||||
|
||||
void sub_6EA73F();
|
||||
|
||||
|
|
|
@ -608,7 +608,7 @@ static void ride_clear_for_construction(int rideIndex)
|
|||
|
||||
w = window_find_by_number(WC_RIDE, rideIndex);
|
||||
if (w != NULL)
|
||||
window_event_helper(w, 0, WE_RESIZE);
|
||||
window_event_resize_call(w);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -609,7 +609,7 @@ static void window_track_place_tooldown()
|
|||
} else {
|
||||
sub_6CC3FB(rideIndex);
|
||||
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
|
||||
window_event_helper(w, 29, WE_MOUSE_UP);
|
||||
window_event_mouse_up_call(w, 29);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue