From c60463c8a7e4314e433435e99ea2045967ca943b Mon Sep 17 00:00:00 2001 From: Broxzier Date: Thu, 3 Nov 2016 00:01:10 +0100 Subject: [PATCH] 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: