From 8c54b1208b14ff4ce9f658012fb6d0efa0e936b2 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Sun, 23 Oct 2016 20:40:23 +0200 Subject: [PATCH 1/7] Add copy/paste functionality to tile inspector --- resources/g2/78.png | Bin 0 -> 170 bytes resources/g2/79.png | Bin 0 -> 307 bytes src/sprites.h | 2 ++ src/windows/tile_inspector.c | 68 +++++++++++++++++++++++++++++------ 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 resources/g2/78.png create mode 100644 resources/g2/79.png diff --git a/resources/g2/78.png b/resources/g2/78.png new file mode 100644 index 0000000000000000000000000000000000000000..7e0f3d7906cfe9d534d1bf1b3c17376f2c485b2c GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|CT0c(hPjegvl$o|I0Jk_T>t<7ugt*k{{8=z z#-8687#J8!g8YIR9G=}sV_;zL_jGX#sff!xxskWQK*0H;_u&|GCf0pQ!55b_%=4)5 z5^5GuxMNd$(~jAy^QwQ^#@?jkS2PZ~%7^ENM#dbCYuw?*GQYKEx?&4&y~=@m)(oBb Xnz{e~-1xx2z`)??>gTe~DWM4fAapw& literal 0 HcmV?d00001 diff --git a/resources/g2/79.png b/resources/g2/79.png new file mode 100644 index 0000000000000000000000000000000000000000..40207ca8ad3904a8f964aa5dfc900222aaba9c02 GIT binary patch literal 307 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rag4rT@hhR<1ZI2jli!UKFlT-CM1-+%u6|NsB@ z@Bf#(Yn#inZ$Et4T%J9@xw+h3d;a?M>e}I#Z{G%~S?vFRdv^2m>HoWp_fHT1f4cqr z;nnuR!T)bB-rVfGef$0X`t0c9;{T5i|Nne{dT7~d1_lPUk|4ie1~AB5#y*jOfuYsY z#WAEJZs`S2zC#8AE`hfjzrFD}Q}Dm|nBH<_p9qDIOKl&a_B;?<}-JNMa8F^ zi(UGdB#ZCgxFwxhTIU;b?PE)g&d(XLe`X05mwgbvW&Aw!o%b2l53Ms-+c;lV|IYdM zMCftZ{ulLa#kz}^ES+*cf@9-zPxflags &= ~MAP_ELEMENT_FLAG_LAST_TILE; + if (lastForTile) { + pastedElement->flags |= MAP_ELEMENT_FLAG_LAST_TILE; + } + + // Make pasted element selected + const rct_map_element *mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY); + w->selected_list_item = (sint16)(pastedElement - mapElement); +} + static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, int cornerIndex) { const uint8 originalSlope = mapElement->properties.surface.slope; const bool diagonal = (originalSlope & 0x10) >> 4; @@ -1009,6 +1037,17 @@ static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) { w->selected_list_item = -1; window_invalidate(w); break; + case WIDX_BUTTON_COPY: + window_tile_inspector_copy_element(w); + map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); + widget_invalidate(w, WIDX_BUTTON_PASTE); + break; + case WIDX_BUTTON_PASTE: + window_tile_inspector_paste_element(w); + map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); + windowTileInspectorElementCount++; + widget_invalidate(w, WIDX_LIST); + break; case WIDX_BUTTON_MOVE_DOWN: window_tile_inspector_swap_elements(w->selected_list_item, w->selected_list_item + 1); w->selected_list_item++; @@ -1445,6 +1484,14 @@ static void window_tile_inspector_auto_set_buttons(rct_window *w) { widget_set_enabled(w, WIDX_BUTTON_MOVE_DOWN, (w->selected_list_item != -1 && w->selected_list_item < windowTileInspectorElementCount - 1)); widget_invalidate(w, WIDX_BUTTON_MOVE_DOWN); + // Copy button + widget_set_enabled(w, WIDX_BUTTON_COPY, w->selected_list_item >= 0); + widget_invalidate(w, WIDX_BUTTON_COPY); + + // Paste button + widget_set_enabled(w, WIDX_BUTTON_PASTE, windowTileInspectorTileSelected && windowTileInspectorElementCopied); + widget_invalidate(w, WIDX_BUTTON_PASTE); + // Page widgets switch (w->page) { case PAGE_FENCE: { @@ -1452,6 +1499,7 @@ static void window_tile_inspector_auto_set_buttons(rct_window *w) { const uint8 fenceType = mapElement->properties.fence.type; const rct_wall_scenery_entry wallEntry = get_wall_entry(fenceType)->wall; const bool canBeSloped = !(wallEntry.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE); + // Fence slope dropdown widget_set_enabled(w, WIDX_FENCE_DROPDOWN_SLOPE, canBeSloped); widget_invalidate(w, WIDX_FENCE_DROPDOWN_SLOPE); widget_set_enabled(w, WIDX_FENCE_DROPDOWN_SLOPE_BUTTON, canBeSloped); From ecc9637bbd4e01f497f1610270118f7d35e0ebc9 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Sun, 30 Oct 2016 21:15:31 +0100 Subject: [PATCH 2/7] Clearing tile inspector clipboard when loading a park --- src/game.c | 2 ++ src/interface/window.h | 1 + src/windows/tile_inspector.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/game.c b/src/game.c index 3e207ba8c5..e78d51f2c2 100644 --- a/src/game.c +++ b/src/game.c @@ -899,6 +899,8 @@ void game_load_init() window_update_all(); gGameSpeed = 1; + + window_tile_inspector_clear_clipboard(); } /** diff --git a/src/interface/window.h b/src/interface/window.h index 1b0cae79bc..ad3f8fe329 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -709,6 +709,7 @@ void window_themes_open(); void window_title_editor_open(int tab); void window_title_command_editor_open(int command, bool insert); void window_tile_inspector_open(); +void window_tile_inspector_clear_clipboard(); void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, rct_string_id existing_text, uintptr_t existing_args, int maxLength); void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, int maxLength); rct_window *window_mapgen_open(); diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index a02fd33ee9..36085c0312 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -579,6 +579,10 @@ void window_tile_inspector_open() { window_tile_inspector_auto_set_buttons(window); } +void window_tile_inspector_clear_clipboard() { + windowTileInspectorElementCopied = false; +} + static rct_map_element* window_tile_inspector_get_selected_element(rct_window *w) { assert(w->selected_list_item >= 0 && w->selected_list_item < windowTileInspectorElementCount); return map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + w->selected_list_item; From 2c334a1882645354992c4bb6ed9650e98cad5ee5 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Mon, 31 Oct 2016 22:58:52 +0100 Subject: [PATCH 3/7] Clearing clipboard on load, and better UI feedback. --- resources/g2/79.png | Bin 307 -> 1143 bytes src/editor.c | 4 ++++ src/game.c | 3 +-- src/scenario.c | 2 +- src/title.c | 1 + src/windows/tile_inspector.c | 3 ++- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/g2/79.png b/resources/g2/79.png index 40207ca8ad3904a8f964aa5dfc900222aaba9c02..a69189ee3e8590bcc659e22c5e66389056dd4aae 100644 GIT binary patch literal 1143 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rag4rT@hhR<1ZI2jliBuiW)N`mv#O3D+9QW+dm z@{>{(JaZG%Q-e|yQz{EjrrIztFe_z-M3hAM`dB6B=jtVb)aX^@7BGN-jeSKyVsdtB zi9%9pdS;%j()-=}l@u~lY?Z=IeGPmIoKrJ0J*tXQgRA^PlB=?lEmM^2?G$V(tSWK~ za#KqZ6)JLb@`|l0Y?Z*~TICg6frRyy6u?SKvTcwn`GuBNuFf>#! zGt)CPF*P$Y)KM@pFf`IPFw!?L(={})GBvX@GFN~CB|8P1qLehNAQv~NT}3Hrwn`Z# zB?VUc`sL;2dgaD?`9+T7#d8;`MLTPi3R$GdIlgbLHwFq;OmQDX>KlDb#X~h zD#E>34K5C;EJ)Q4N-fSWElN%eN=;J+xv9X)xhOTUB)=#mKR*W+iUAqUdYPFiR<7peZU%_oohzU-Up!8{{fJpeMc`3F^ zMN0N|hB;+93=9l50X`wF@8ADdW?=Z=ZEP;j{(rIm|LxiPr-%PP-M;GCjW(6MCi!B{$NAG?4|9@)*hr+h?cm2=IGPY3OQoZfgy~WE`Whu{| znRO}j^TN%0J{c`N5|?;0uY=RD@Zt9+sdW1ve7#fqvkwSb2FKcK{Z^kV{-PxIIA`MD z?&GBw1K#J!T)6)0zs!#RH;orZ{*g?v`#$BHm2<_Geg?at=gaEfIscvrJuch-qQ0$Ickz;?Q|?D_Y<%u1e|`V* i@9WNlncsAN#(HXwh@kf50Pil4+dN(UT-G@yGywqKdWqox diff --git a/src/editor.c b/src/editor.c index 376522948e..9fba9c8134 100644 --- a/src/editor.c +++ b/src/editor.c @@ -113,6 +113,7 @@ void editor_load() mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; load_palette(); gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); gScreenAge = 0; safe_strcpy(gScenarioName, language_get_string(STR_MY_NEW_SCENARIO), 64); @@ -197,6 +198,7 @@ void trackdesigner_load() mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; load_palette(); gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); } /** @@ -237,6 +239,7 @@ void trackmanager_load() mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; load_palette(); gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); } /** @@ -483,6 +486,7 @@ static void editor_finalise_main_view() gWindowUpdateTicks = 0; load_palette(); gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); } /** diff --git a/src/game.c b/src/game.c index e78d51f2c2..8af31d74d6 100644 --- a/src/game.c +++ b/src/game.c @@ -896,11 +896,10 @@ void game_load_init() load_palette(); gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); window_update_all(); gGameSpeed = 1; - - window_tile_inspector_clear_clipboard(); } /** diff --git a/src/scenario.c b/src/scenario.c index 0109daa7e6..959639e4e9 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -294,8 +294,8 @@ void scenario_begin() gParkFlags |= PARK_FLAGS_18; load_palette(); - gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); gScreenAge = 0; gGameSpeed = 1; } diff --git a/src/title.c b/src/title.c index 0273d38eb7..2cef6b894b 100644 --- a/src/title.c +++ b/src/title.c @@ -220,6 +220,7 @@ static int title_load_park(const char *path) news_item_init_queue(); load_palette(); gfx_invalidate_screen(); + window_tile_inspector_clear_clipboard(); gScreenAge = 0; gGameSpeed = 1; return 1; diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index 36085c0312..cab403b119 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -1044,7 +1044,8 @@ static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) { case WIDX_BUTTON_COPY: window_tile_inspector_copy_element(w); map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); - widget_invalidate(w, WIDX_BUTTON_PASTE); + window_tile_inspector_auto_set_buttons(w); + window_invalidate(w); break; case WIDX_BUTTON_PASTE: window_tile_inspector_paste_element(w); From 109f1d094e1038de12f59c6f3bc77b00b3aab815 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Tue, 1 Nov 2016 23:43:39 +0100 Subject: [PATCH 4/7] [ci-skip] Function opening brackets on own line --- src/windows/tile_inspector.c | 90 ++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index cab403b119..b4895a87c8 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -547,7 +547,8 @@ static uint64 windowTileInspectorDisabledWidgets[] = { (1ULL << WIDX_BUTTON_ROTATE), }; -void window_tile_inspector_open() { +void window_tile_inspector_open() +{ rct_window* window; // Check if window is already open @@ -579,16 +580,19 @@ void window_tile_inspector_open() { window_tile_inspector_auto_set_buttons(window); } -void window_tile_inspector_clear_clipboard() { +void window_tile_inspector_clear_clipboard() +{ windowTileInspectorElementCopied = false; } -static rct_map_element* window_tile_inspector_get_selected_element(rct_window *w) { +static rct_map_element* window_tile_inspector_get_selected_element(rct_window *w) +{ assert(w->selected_list_item >= 0 && w->selected_list_item < windowTileInspectorElementCount); return map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + w->selected_list_item; } -static void window_tile_inspector_load_tile(rct_window* w) { +static void window_tile_inspector_load_tile(rct_window* w) +{ rct_map_element *element = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY); int numItems = 0; do { @@ -608,7 +612,8 @@ static void window_tile_inspector_load_tile(rct_window* w) { window_invalidate(w); } -static void window_tile_inspector_insert_corrupt_element(rct_window *w) { +static void window_tile_inspector_insert_corrupt_element(rct_window *w) +{ // Create new corrupt element rct_map_element *curruptElement = map_element_insert(windowTileInspectorTileX, windowTileInspectorTileY, -1, 0); // Ugly hack: -1 guarantees this to be placed first windowTileInspectorElementCount++; @@ -628,7 +633,8 @@ static void window_tile_inspector_insert_corrupt_element(rct_window *w) { map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); } -static void window_tile_inspector_remove_element(int index) { +static void window_tile_inspector_remove_element(int index) +{ assert(index < windowTileInspectorElementCount); rct_map_element *const mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + index; map_element_remove(mapElement); @@ -636,7 +642,8 @@ static void window_tile_inspector_remove_element(int index) { map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); } -static void window_tile_inspector_rotate_element(int index) { +static void window_tile_inspector_rotate_element(int index) +{ uint8 newRotation, pathEdges, pathCorners; assert(index < windowTileInspectorElementCount); @@ -674,7 +681,8 @@ static void window_tile_inspector_rotate_element(int index) { } // Swap element with its parent -static void window_tile_inspector_swap_elements(sint16 first, sint16 second) { +static void window_tile_inspector_swap_elements(sint16 first, sint16 second) +{ rct_map_element *mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY); rct_map_element *const firstElement = mapElement + first; rct_map_element *const secondElement = mapElement + second; @@ -702,7 +710,8 @@ static void window_tile_inspector_swap_elements(sint16 first, sint16 second) { map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); } -static void window_tile_inspector_sort_elements(rct_window *w) { +static void window_tile_inspector_sort_elements(rct_window *w) +{ const rct_map_element *const firstElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY); // Bubble sort @@ -721,13 +730,15 @@ static void window_tile_inspector_sort_elements(rct_window *w) { } } -static void window_tile_inspector_copy_element(rct_window *w) { +static void window_tile_inspector_copy_element(rct_window *w) +{ // Copy value, in case the element gets moved tileInspectorCopiedElement = *window_tile_inspector_get_selected_element(w); windowTileInspectorElementCopied = true; } -static void window_tile_inspector_paste_element(rct_window *w) { +static void window_tile_inspector_paste_element(rct_window *w) +{ rct_map_element *const pastedElement = map_element_insert(windowTileInspectorTileX, windowTileInspectorTileY, tileInspectorCopiedElement.base_height, 0); bool lastForTile = map_element_is_last_for_tile(pastedElement); *pastedElement = tileInspectorCopiedElement; @@ -741,7 +752,8 @@ static void window_tile_inspector_paste_element(rct_window *w) { w->selected_list_item = (sint16)(pastedElement - mapElement); } -static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, int cornerIndex) { +static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, int cornerIndex) +{ const uint8 originalSlope = mapElement->properties.surface.slope; const bool diagonal = (originalSlope & 0x10) >> 4; @@ -774,7 +786,8 @@ static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElem // Copied from track.c (track_remove), and modified for raising/lowering // Not sure if this should be in this file, track.c, or maybe another one -static void window_tile_inspector_track_block_height_offset(rct_map_element *mapElement, uint8 offset) { +static void window_tile_inspector_track_block_height_offset(rct_map_element *mapElement, uint8 offset) +{ uint8 type = mapElement->properties.track.type; sint16 originX = windowTileInspectorTileX << 5; sint16 originY = windowTileInspectorTileY << 5; @@ -875,7 +888,8 @@ static void window_tile_inspector_track_block_height_offset(rct_map_element *map // Sets chainlift for entire block // Basically a copy of the above function, with just two different lines... should probably be combined somehow -static void window_tile_inspector_track_block_set_lift(rct_map_element *mapElement, bool chain) { +static void window_tile_inspector_track_block_set_lift(rct_map_element *mapElement, bool chain) +{ uint8 type = mapElement->properties.track.type; sint16 originX = windowTileInspectorTileX << 5; sint16 originY = windowTileInspectorTileY << 5; @@ -974,7 +988,8 @@ static void window_tile_inspector_track_block_set_lift(rct_map_element *mapEleme } } -static void window_tile_inspector_quarter_tile_set(rct_map_element *const mapElement, const int index) { +static void window_tile_inspector_quarter_tile_set(rct_map_element *const mapElement, const int index) +{ // index is widget index relative to WIDX_SCENERY_CHECK_QUARTER_N, so a value from 0-3 assert(index >= 0 && index < 4); @@ -991,7 +1006,8 @@ static void window_tile_inspector_quarter_tile_set(rct_map_element *const mapEle map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); } -static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) { +static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) +{ switch (widgetIndex) { case WIDX_CLOSE: tool_cancel(); @@ -1331,7 +1347,8 @@ static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) { } // switch page } -static void window_tile_inspector_resize(rct_window *w) { +static void window_tile_inspector_resize(rct_window *w) +{ w->min_width = WW; w->min_height = MIN_WH; if (w->width < w->min_width) { @@ -1344,7 +1361,8 @@ static void window_tile_inspector_resize(rct_window *w) { } } -static void window_tile_inspector_mousedown(int widgetIndex, rct_window *w, rct_widget* widget) { +static void window_tile_inspector_mousedown(int widgetIndex, rct_window *w, rct_widget* widget) +{ switch (w->page) { case PAGE_FENCE: switch (widgetIndex) { @@ -1378,7 +1396,8 @@ static void window_tile_inspector_mousedown(int widgetIndex, rct_window *w, rct_ } } -static void window_tile_inspector_update(rct_window *w) { +static void window_tile_inspector_update(rct_window *w) +{ // Check if the mouse is hovering over the list if (!widget_is_highlighted(w, WIDX_LIST)) { windowTileInspectorHighlightedIndex = -1; @@ -1389,7 +1408,8 @@ static void window_tile_inspector_update(rct_window *w) { window_close(w); } -static void window_tile_inspector_dropdown(rct_window *w, int widgetIndex, int dropdownIndex) { +static void window_tile_inspector_dropdown(rct_window *w, int widgetIndex, int dropdownIndex) +{ if (dropdownIndex == -1) { return; } @@ -1417,7 +1437,8 @@ static void window_tile_inspector_dropdown(rct_window *w, int widgetIndex, int d } } -static void window_tile_inspector_tool_update(rct_window* w, int widgetIndex, int x, int y) { +static void window_tile_inspector_tool_update(rct_window* w, int widgetIndex, int x, int y) +{ map_invalidate_selection_rect(); gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; @@ -1442,7 +1463,8 @@ static void window_tile_inspector_tool_update(rct_window* w, int widgetIndex, in map_invalidate_selection_rect(); } -static void window_tile_inspector_tool_down(rct_window* w, int widgetIndex, int x, int y) { +static void window_tile_inspector_tool_down(rct_window* w, int widgetIndex, int x, int y) +{ short mapX = x; short mapY = y; int direction; @@ -1459,19 +1481,22 @@ static void window_tile_inspector_tool_down(rct_window* w, int widgetIndex, int window_tile_inspector_auto_set_buttons(w); } -static void window_tile_inspector_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height) { +static void window_tile_inspector_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height) +{ *width = WW - 30; *height = windowTileInspectorElementCount * LIST_ITEM_HEIGHT; } -static void window_tile_inspector_set_page(rct_window *w, const int page) { +static void window_tile_inspector_set_page(rct_window *w, const int page) +{ w->page = page; w->widgets = tileInspectorWidgets[page]; w->enabled_widgets = windowTileInspectorEnabledWidgets[page]; w->disabled_widgets = windowTileInspectorDisabledWidgets[page]; } -static void window_tile_inspector_auto_set_buttons(rct_window *w) { +static void window_tile_inspector_auto_set_buttons(rct_window *w) +{ // X and Y spinners widget_set_enabled(w, WIDX_SPINNER_X_INCREASE, (windowTileInspectorTileSelected && (windowTileInspectorTileX < 255))); widget_set_enabled(w, WIDX_SPINNER_X_DECREASE, (windowTileInspectorTileSelected && (windowTileInspectorTileX > 0))); @@ -1514,7 +1539,8 @@ static void window_tile_inspector_auto_set_buttons(rct_window *w) { } // switch page } -static void window_tile_inspector_scrollmousedown(rct_window *w, int scrollIndex, int x, int y) { +static void window_tile_inspector_scrollmousedown(rct_window *w, int scrollIndex, int x, int y) +{ // Because the list items are displayed in reverse order, subtract the calculated index from the amount of elements const sint16 index = windowTileInspectorElementCount - (y - 1) / LIST_ITEM_HEIGHT - 1; int page; @@ -1537,7 +1563,8 @@ static void window_tile_inspector_scrollmousedown(rct_window *w, int scrollIndex window_invalidate(w); } -static void window_tile_inspector_scrollmouseover(rct_window *w, int scrollIndex, int x, int y) { +static void window_tile_inspector_scrollmouseover(rct_window *w, int scrollIndex, int x, int y) +{ sint16 index = windowTileInspectorElementCount - (y - 1) / LIST_ITEM_HEIGHT - 1; if (index < 0 || index >= windowTileInspectorElementCount) windowTileInspectorHighlightedIndex = -1; @@ -1547,7 +1574,8 @@ static void window_tile_inspector_scrollmouseover(rct_window *w, int scrollIndex widget_invalidate(w, WIDX_LIST); } -static void window_tile_inspector_invalidate(rct_window *w) { +static void window_tile_inspector_invalidate(rct_window *w) +{ colour_scheme_update(w); w->widgets[WIDX_BACKGROUND].bottom = w->height - 1; @@ -1753,7 +1781,8 @@ static void window_tile_inspector_invalidate(rct_window *w) { } } -static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) { +static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) +{ window_draw_widgets(w, dpi); // Set medium font size @@ -2112,7 +2141,8 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) { } } -static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex) { +static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex) +{ int x = 3; int y = LIST_ITEM_HEIGHT * (windowTileInspectorElementCount - 1); int i = 0; From c60463c8a7e4314e433435e99ea2045967ca943b Mon Sep 17 00:00:00 2001 From: Broxzier Date: Thu, 3 Nov 2016 00:01:10 +0100 Subject: [PATCH 5/7] Show error message when map element limit is reached --- data/language/en-GB.txt | 2 ++ src/localisation/string_ids.h | 2 ++ src/windows/tile_inspector.c | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index a025a57d68..dbd149fca7 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4299,6 +4299,8 @@ STR_5987 :Unable to create folder STR_5988 :{SMALLFONT}{BLACK}No remaining land rights for sale STR_5989 :{SMALLFONT}{BLACK}No remaining construction rights for sale STR_5990 :{SMALLFONT}{BLACK}No remaining land rights or construction rights for sale +STR_5991 :Can't paste element... +STR_5992 :The map elements limit has been reached ############# # Scenarios # diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index f82c024184..d5888ef560 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -3639,6 +3639,8 @@ enum { STR_NO_LAND_RIGHTS_FOR_SALE_TIP = 5988, STR_NO_CONSTRUCTION_RIGHTS_FOR_SALE_TIP = 5989, STR_NO_LAND_OR_CONSTRUCTION_RIGHTS_FOR_SALE_TIP = 5990, + STR_CANT_PASTE = 5991, + STR_MAP_ELEMENT_LIMIT_REACHED = 5992, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index b4895a87c8..5179ff1e5b 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -15,6 +15,7 @@ #pragma endregion #include "dropdown.h" +#include "error.h" #include "../input.h" #include "../interface/themes.h" #include "../interface/viewport.h" @@ -740,6 +741,13 @@ static void window_tile_inspector_copy_element(rct_window *w) static void window_tile_inspector_paste_element(rct_window *w) { rct_map_element *const pastedElement = map_element_insert(windowTileInspectorTileX, windowTileInspectorTileY, tileInspectorCopiedElement.base_height, 0); + if (pastedElement == NULL) { + // map_element_insert displays an error message on failure + window_error_open(STR_CANT_PASTE, STR_MAP_ELEMENT_LIMIT_REACHED); + return; + } + + windowTileInspectorElementCount++; bool lastForTile = map_element_is_last_for_tile(pastedElement); *pastedElement = tileInspectorCopiedElement; pastedElement->flags &= ~MAP_ELEMENT_FLAG_LAST_TILE; @@ -1066,7 +1074,6 @@ static void window_tile_inspector_mouseup(rct_window *w, int widgetIndex) case WIDX_BUTTON_PASTE: window_tile_inspector_paste_element(w); map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); - windowTileInspectorElementCount++; widget_invalidate(w, WIDX_LIST); break; case WIDX_BUTTON_MOVE_DOWN: From 9c1998320d37941cfe23d46477280a828ed9348a Mon Sep 17 00:00:00 2001 From: Broxzier Date: Wed, 9 Nov 2016 20:34:00 +0100 Subject: [PATCH 6/7] Add tooltips to copy and paste buttons --- data/language/en-GB.txt | 2 ++ src/localisation/string_ids.h | 2 ++ src/windows/tile_inspector.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index dbd149fca7..a3b0387632 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4301,6 +4301,8 @@ STR_5989 :{SMALLFONT}{BLACK}No remaining construction rights for sale STR_5990 :{SMALLFONT}{BLACK}No remaining land rights or construction rights for sale STR_5991 :Can't paste element... STR_5992 :The map elements limit has been reached +STR_5993 :{SMALLFONT}{BLACK}Copy selected element +STR_5994 :{SMALLFONT}{BLACK}Paste copied element ############# # Scenarios # diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index d5888ef560..170ac486b6 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -3641,6 +3641,8 @@ enum { STR_NO_LAND_OR_CONSTRUCTION_RIGHTS_FOR_SALE_TIP = 5990, STR_CANT_PASTE = 5991, STR_MAP_ELEMENT_LIMIT_REACHED = 5992, + STR_TILE_INSPECTOR_COPY_TIP = 5993, + STR_TILE_INSPECTOR_PASTE_TIP = 5994, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index 5179ff1e5b..fbb1156aab 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -262,8 +262,8 @@ enum WINDOW_TILE_INSPECTOR_WIDGET_IDX { { WWT_CLOSEBOX, 1, BX - BS * 2, BW - BS * 2, BH - 11, BH, STR_DOWN, STR_MOVE_SELECTED_ELEMENT_DOWN_TIP }, /* Move up */ \ { WWT_FLATBTN, 1, BX - BS * 3, BW - BS * 3, BY, BH, SPR_ROTATE_ARROW, STR_ROTATE_SELECTED_ELEMENT_TIP }, /* Rotate button */ \ { WWT_FLATBTN, 1, BX - BS * 4, BW - BS * 4, BY, BH, SPR_G2_SORT, STR_TILE_INSPECTOR_SORT_TIP }, /* Sort button */ \ - { WWT_FLATBTN, 1, BX - BS * 5, BW - BS * 5, BY, BH, SPR_G2_COPY, STR_TILE_INSPECTOR_SORT_TIP }, /* Copy button */ \ - { WWT_FLATBTN, 1, BX - BS * 6, BW - BS * 6, BY, BH, SPR_G2_PASTE, STR_TILE_INSPECTOR_SORT_TIP }, /* Paste button */ \ + { WWT_FLATBTN, 1, BX - BS * 5, BW - BS * 5, BY, BH, SPR_G2_COPY, STR_TILE_INSPECTOR_COPY_TIP }, /* Copy button */ \ + { WWT_FLATBTN, 1, BX - BS * 6, BW - BS * 6, BY, BH, SPR_G2_PASTE, STR_TILE_INSPECTOR_PASTE_TIP }, /* Paste button */ \ /* Column headers */ \ { WWT_13, 1, COL_X_TYPE, COL_X_BH - 1, 42, 42 + 13, STR_NONE, STR_NONE }, /* Type */ \ { WWT_13, 1, COL_X_BH, COL_X_CH - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_BASE_HEIGHT }, /* Base height */ \ From ebc0a81e720ba48f3458d3a89456566f8f07e15d Mon Sep 17 00:00:00 2001 From: Broxzier Date: Sat, 12 Nov 2016 11:27:59 +0100 Subject: [PATCH 7/7] Guests turn around when trying to enter a copied park entrance --- src/peep/peep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/peep/peep.c b/src/peep/peep.c index 6d667d4af5..f1eab85c60 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -8080,11 +8080,10 @@ static int peep_interact_with_entrance(rct_peep* peep, sint16 x, sint16 y, rct_m } uint8 entranceIndex = 0; - while (1){ + for (entranceIndex = 0; entranceIndex < 4; entranceIndex++) { if (gParkEntranceX[entranceIndex] == (x & 0xFFE0) && gParkEntranceY[entranceIndex] == (y & 0xFFE0)) break; - entranceIndex++; } sint16 z = gParkEntranceZ[entranceIndex] / 8;