From 31e8e604fe01bc86d68745c4b258eeb07a8c72be Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Thu, 25 Jun 2015 14:27:09 -0400 Subject: [PATCH] Added Get button to command editor --- data/language/english_uk.txt | 1 + src/interface/console.c | 1 - src/windows/title_command_editor.c | 44 +++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index de37c6b724..85da216410 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3779,3 +3779,4 @@ STR_5442 :reserved STR_5443 :Speed{MOVE_X}{87}{STRINGID} STR_5444 :Speed: STR_5445 :Speed +STR_5446 :Get diff --git a/src/interface/console.c b/src/interface/console.c index 71f32c03c9..27bccea426 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -516,7 +516,6 @@ static int cc_get(const char **argv, int argc) int interactionType; rct_map_element *mapElement; rct_xy16 mapCoord = { 0 }; - get_map_coordinates_from_pos(w->viewport->view_width / 2, w->viewport->view_height / 2, VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, &interactionType, &mapElement, NULL); mapCoord.x -= 16; mapCoord.x /= 32; diff --git a/src/windows/title_command_editor.c b/src/windows/title_command_editor.c index f7174892ea..3fe009bbe8 100644 --- a/src/windows/title_command_editor.c +++ b/src/windows/title_command_editor.c @@ -62,6 +62,7 @@ enum WINDOW_WATER_WIDGET_IDX { WIDX_TEXTBOX_Y, WIDX_INPUT, WIDX_INPUT_DROPDOWN, + WIDX_GET, WIDX_OKAY, WIDX_CANCEL }; @@ -92,6 +93,8 @@ static rct_widget window_title_command_editor_widgets[] = { { WWT_DROPDOWN, 1, 16, WW-17, BY2, BY2+11, STR_NONE, STR_NONE }, // Save dropdown { WWT_DROPDOWN_BUTTON, 1, WW-28, WW-18, BY2+1, BY2+10, 876, STR_NONE }, + + { WWT_DROPDOWN_BUTTON, 1, WS+WHA+3, WW-WS-1, BY2-14, BY2-3, 5446, STR_NONE }, // Get location/zoom/etc { WWT_DROPDOWN_BUTTON, 1, 10, 80, WH-21, WH-10, STR_OK, STR_NONE }, // OKAY { WWT_DROPDOWN_BUTTON, 1, WW-80, WW-10, WH-21, WH-10, STR_CANCEL, STR_NONE }, // Cancel @@ -112,6 +115,7 @@ static void window_title_command_editor_inputsize(rct_window *w); static int get_command_info_index(int index); static TITLE_COMMAND_ORDER get_command_info(int index); static rct_xy16 get_location(); +static uint8 get_zoom(); static void* window_title_command_editor_events[] = { window_title_command_editor_close, @@ -181,6 +185,16 @@ static rct_xy16 get_location() return mapCoord; } +static uint8 get_zoom() +{ + uint8 zoom = 0; + rct_window *w = window_get_main(); + if (w != NULL) { + zoom = w->viewport->zoom; + } + return zoom; +} + void window_title_command_editor_open(int index, bool insert) { rct_window* window; @@ -206,6 +220,7 @@ void window_title_command_editor_open(int index, bool insert) (1 << WIDX_TEXTBOX_Y) | (1 << WIDX_INPUT) | (1 << WIDX_INPUT_DROPDOWN) | + (1 << WIDX_GET) | (1 << WIDX_OKAY) | (1 << WIDX_CANCEL); window_init_scroll_widgets(window); @@ -244,6 +259,8 @@ static void window_title_command_editor_mouseup() { rct_window *w, *title_editor_w; short widgetIndex; + rct_xy16 mapCoord; + uint8 zoom; window_widget_get_registers(w, widgetIndex); @@ -261,6 +278,21 @@ static void window_title_command_editor_mouseup() case WIDX_TEXTBOX_Y: window_start_textbox(w, widgetIndex, 1170, (uint32)textbox2Buffer, 4); break; + case WIDX_GET: + if (command.command == TITLE_SCRIPT_LOCATION) { + mapCoord = get_location(); + command.x = (uint8)mapCoord.x; + command.y = (uint8)mapCoord.y; + _itoa(command.x, textbox1Buffer, 10); + _itoa(command.y, textbox2Buffer, 10); + } + else if (command.command == TITLE_SCRIPT_ZOOM) { + zoom = get_zoom(); + command.zoom = zoom; + _itoa(command.zoom, textbox1Buffer, 10); + } + window_invalidate(w); + break; case WIDX_OKAY: if (_window_title_command_editor_insert) { title_sequence_insert_command(gCurrentTitleSequence, _window_title_command_editor_index, command); @@ -487,6 +519,7 @@ static void window_title_command_editor_invalidate() window_title_command_editor_widgets[WIDX_TEXTBOX_Y].type = WWT_EMPTY; window_title_command_editor_widgets[WIDX_INPUT].type = WWT_EMPTY; window_title_command_editor_widgets[WIDX_INPUT_DROPDOWN].type = WWT_EMPTY; + window_title_command_editor_widgets[WIDX_GET].type = WWT_EMPTY; switch (command.command) { case TITLE_SCRIPT_LOAD: case TITLE_SCRIPT_SPEED: @@ -496,13 +529,22 @@ static void window_title_command_editor_invalidate() case TITLE_SCRIPT_LOCATION: window_title_command_editor_widgets[WIDX_TEXTBOX_X].type = WWT_TEXT_BOX; window_title_command_editor_widgets[WIDX_TEXTBOX_Y].type = WWT_TEXT_BOX; + window_title_command_editor_widgets[WIDX_GET].type = WWT_DROPDOWN_BUTTON; break; case TITLE_SCRIPT_ROTATE: - case TITLE_SCRIPT_ZOOM: case TITLE_SCRIPT_WAIT: window_title_command_editor_widgets[WIDX_TEXTBOX_FULL].type = WWT_TEXT_BOX; break; + case TITLE_SCRIPT_ZOOM: + window_title_command_editor_widgets[WIDX_GET].type = WWT_DROPDOWN_BUTTON; + window_title_command_editor_widgets[WIDX_TEXTBOX_FULL].type = WWT_TEXT_BOX; + break; } + + if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) == SCREEN_FLAGS_TITLE_DEMO) + w->disabled_widgets |= (1 << WIDX_GET); + else + w->disabled_widgets &= ~(1 << WIDX_GET); } static void window_title_command_editor_paint()