1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 06:23:04 +01:00

implement textinput_cancel and refactor textinput event calls

This commit is contained in:
IntelOrca
2015-05-28 01:15:58 +01:00
parent 101fed0dd9
commit 6f1cd77f3c
6 changed files with 42 additions and 5 deletions

View File

@@ -230,6 +230,10 @@
#define RCT2_ADDRESS_WINDOW_DPI 0x009DEA74
#define RCT2_ADDRESS_TEXTINPUT_WIDGETINDEX 0x009DEB88
#define RCT2_ADDRESS_TEXTINPUT_WINDOWNUMBER 0x009DEB8A
#define RCT2_ADDRESS_TEXTINPUT_WINDOWCLASS 0x009DEB8C
#define RCT2_ADDRESS_DSOUND_BUFFERS 0x009E1AB0
#define RCT2_ADDRESS_NUM_DSOUND_DEVICES 0x009E2B88
#define RCT2_ADDRESS_DSOUND_DEVICES 0x009E2B8C

View File

@@ -112,7 +112,7 @@ void viewport_init_all()
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16) = -1;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) = 0;
RCT2_GLOBAL(0x009DEA50, sint16) = -1;
RCT2_CALLPROC_EBPSAFE(0x006EE3C3);
textinput_cancel();
format_string((char*)0x0141FA44, STR_CANCEL, NULL);
format_string((char*)0x0141F944, STR_OK, NULL);
}

View File

@@ -2141,3 +2141,34 @@ int window_can_resize(rct_window *w)
{
return (w->flags & WF_RESIZABLE) && (w->min_width != w->max_width || w->min_height != w->max_height);
}
void window_event_textinput_call(rct_window *w, int widgetIndex, char *text)
{
RCT2_CALLPROC_X(w->event_handlers[WE_TEXT_INPUT], 0, 0, text != NULL, widgetIndex, (int)w, (int)text, 0);
}
/**
*
* rct2: 0x006EE3C3
*/
void textinput_cancel()
{
rct_window *w;
// Close the new text input window
window_close_by_class(WC_TEXTINPUT);
// The following code is only necessary for the old Windows text input dialog. In theory this isn't used anymore, but can
// still be triggered via original code paths.
RCT2_CALLPROC_EBPSAFE(0x0040701D);
if (RCT2_GLOBAL(0x009DEB8C, uint8) != 255) {
RCT2_CALLPROC_EBPSAFE(0x006EE4E2);
w = window_find_by_number(
RCT2_GLOBAL(RCT2_ADDRESS_TEXTINPUT_WINDOWCLASS, rct_windowclass),
RCT2_GLOBAL(RCT2_ADDRESS_TEXTINPUT_WINDOWNUMBER, rct_windownumber)
);
if (w != NULL) {
window_event_textinput_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TEXTINPUT_WIDGETINDEX, uint16), NULL);
}
}
}

View File

@@ -590,8 +590,10 @@ 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 window_event_update_call(rct_window *w);
void window_event_textinput_call(rct_window *w, int widgetIndex, char *text);
void sub_6EA73F();
void textinput_cancel();
void window_move_and_snap(rct_window *w, int newWindowX, int newWindowY, int snapProximity);
int window_can_resize(rct_window *w);

View File

@@ -207,7 +207,7 @@ static void window_banner_mouseup()
window_text_input_open(w, WIDX_BANNER_TEXT, 2982, 2983, gBanners[w->number].string_idx, 0, 32);
break;
case WIDX_BANNER_NO_ENTRY:
RCT2_CALLPROC_EBPSAFE(0x006EE3C3);
textinput_cancel();
banner->flags ^= BANNER_FLAG_NO_ENTRY;
window_invalidate(w);

View File

@@ -240,7 +240,7 @@ static void window_text_input_mouseup(){
// Pass back the text that has been entered.
// ecx when zero means text input failed
if (calling_w != NULL)
RCT2_CALLPROC_X(calling_w->event_handlers[WE_TEXT_INPUT], 0, 0, 0, calling_widget, (int)calling_w, (int)text_input, 0);
window_event_textinput_call(calling_w, calling_widget, NULL);
window_close(w);
break;
case WIDX_OKAY:
@@ -248,7 +248,7 @@ static void window_text_input_mouseup(){
// Pass back the text that has been entered.
// ecx when none zero means text input success
if (calling_w != NULL)
RCT2_CALLPROC_X(calling_w->event_handlers[WE_TEXT_INPUT], 0, 0, 1, calling_widget, (int)calling_w, (int)text_input, 0);
window_event_textinput_call(calling_w, calling_widget, text_input);
window_close(w);
}
}
@@ -340,7 +340,7 @@ static void window_text_input_text(int key, rct_window* w){
// Pass back the text that has been entered.
// ecx when none zero means text input success
if (calling_w)
RCT2_CALLPROC_X(calling_w->event_handlers[WE_TEXT_INPUT], 0, 0, 1, calling_widget, (int)calling_w, (int)text_input, 0);
window_event_textinput_call(calling_w, calling_widget, text_input);
}
window_invalidate(w);