From a0f75fbda26213cf1d869219a45b807e25281cc1 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 12 Aug 2015 14:07:16 +0200 Subject: [PATCH 1/2] Turn minimum and maximum tool sizes into defines --- src/windows/clear_scenery.c | 19 +++++++++---------- src/windows/land.c | 18 +++++++++--------- src/windows/land_rights.c | 16 ++++++++-------- src/windows/water.c | 18 +++++++++--------- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/windows/clear_scenery.c b/src/windows/clear_scenery.c index bd7fbb9ead..7b3fb34120 100644 --- a/src/windows/clear_scenery.c +++ b/src/windows/clear_scenery.c @@ -27,6 +27,9 @@ #include "../interface/window.h" #include "../interface/themes.h" +#define MINIMUM_TOOL_SIZE 0 +#define MAXIMUM_TOOL_SIZE 64 + enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, @@ -52,7 +55,6 @@ rct_widget window_clear_scenery_widgets[] = { { WIDGETS_END }, }; - static int window_clear_scenery_should_close(); static void window_clear_scenery_close(rct_window *w); @@ -63,9 +65,6 @@ static void window_clear_scenery_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_clear_scenery_textinput(rct_window *w, int widgetIndex, char *text); static void window_clear_scenery_inputsize(rct_window *w); -static int _minimumSize = 1; -static int _maximumSize = 64; - static rct_window_event_list window_clear_scenery_events = { window_clear_scenery_close, window_clear_scenery_mouseup, @@ -148,14 +147,14 @@ static void window_clear_scenery_mouseup(rct_window *w, int widgetIndex) break; case WIDX_DECREMENT: // Decrement land tool size, if it stays within the limit - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(_minimumSize,RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(MINIMUM_TOOL_SIZE,RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); // Invalidate the window window_invalidate(w); break; case WIDX_INCREMENT: // Increment land tool size, if it stays within the limit - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(_maximumSize,RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(MAXIMUM_TOOL_SIZE,RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); // Invalidate the window window_invalidate(w); @@ -188,8 +187,8 @@ static void window_clear_scenery_textinput(rct_window *w, int widgetIndex, char size = strtol(text, &end, 10); if (*end == '\0') { - size=max(_minimumSize,size); - size=min(_maximumSize,size); + size=max(MINIMUM_TOOL_SIZE,size); + size=min(MAXIMUM_TOOL_SIZE,size); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size; window_invalidate(w); } @@ -197,8 +196,8 @@ static void window_clear_scenery_textinput(rct_window *w, int widgetIndex, char static void window_clear_scenery_inputsize(rct_window *w) { - ((uint16*)TextInputDescriptionArgs)[0] = _minimumSize; - ((uint16*)TextInputDescriptionArgs)[1] = _maximumSize; + ((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_TOOL_SIZE; + ((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_TOOL_SIZE; window_text_input_open(w, WIDX_PREVIEW, 5128, 5129, STR_NONE, STR_NONE, 3); } diff --git a/src/windows/land.c b/src/windows/land.c index b23022e65d..1a68a7884c 100644 --- a/src/windows/land.c +++ b/src/windows/land.c @@ -28,6 +28,9 @@ #include "dropdown.h" #include "../interface/themes.h" +#define MINIMUM_TOOL_SIZE 0 +#define MAXIMUM_TOOL_SIZE 64 + enum WINDOW_LAND_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, @@ -63,9 +66,6 @@ static void window_land_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_land_textinput(rct_window *w, int widgetIndex, char *text); static void window_land_inputsize(rct_window *w); -static int _minimumSize = 0; -static int _maximumSize = 64; - static rct_window_event_list window_land_events = { window_land_close, window_land_mouseup, @@ -173,14 +173,14 @@ static void window_land_mouseup(rct_window *w, int widgetIndex) break; case WIDX_DECREMENT: // Decrement land tool size - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(_minimumSize, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(MINIMUM_TOOL_SIZE, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); // Invalidate the window window_invalidate(w); break; case WIDX_INCREMENT: // Increment land tool size - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(_maximumSize, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(MAXIMUM_TOOL_SIZE, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); // Invalidate the window window_invalidate(w); @@ -298,8 +298,8 @@ static void window_land_textinput(rct_window *w, int widgetIndex, char *text) size = strtol(text, &end, 10); if (*end == '\0') { - size = max(_minimumSize,size); - size = min(_maximumSize,size); + size = max(MINIMUM_TOOL_SIZE,size); + size = min(MAXIMUM_TOOL_SIZE,size); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size; window_invalidate(w); @@ -308,8 +308,8 @@ static void window_land_textinput(rct_window *w, int widgetIndex, char *text) static void window_land_inputsize(rct_window *w) { - ((uint16*)TextInputDescriptionArgs)[0] = _minimumSize; - ((uint16*)TextInputDescriptionArgs)[1] = _maximumSize; + ((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_TOOL_SIZE; + ((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_TOOL_SIZE; window_text_input_open(w, WIDX_PREVIEW, 5128, 5129, STR_NONE, STR_NONE, 3); } diff --git a/src/windows/land_rights.c b/src/windows/land_rights.c index 3e4563085f..6b6b533045 100644 --- a/src/windows/land_rights.c +++ b/src/windows/land_rights.c @@ -29,8 +29,8 @@ #include "../game.h" #include "../interface/themes.h" -static int _minimumSize = 1; -static int _maximumSize = 64; +#define MINIMUM_TOOL_SIZE 0 +#define MAXIMUM_TOOL_SIZE 64 enum WINDOW_WATER_WIDGET_IDX { WIDX_BACKGROUND, @@ -135,14 +135,14 @@ static void window_land_rights_mouseup(rct_window *w, int widgetIndex) break; case WIDX_DECREMENT: // Decrement land rights tool size - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(_minimumSize, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(MINIMUM_TOOL_SIZE, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); // Invalidate the window window_invalidate(w); break; case WIDX_INCREMENT: // Decrement land rights tool size - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(_maximumSize, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(MAXIMUM_TOOL_SIZE, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); // Invalidate the window window_invalidate(w); @@ -179,8 +179,8 @@ static void window_land_rights_textinput(rct_window *w, int widgetIndex, char *t size = strtol(text, &end, 10); if (*end == '\0') { - size = max(_minimumSize,size); - size = min(_maximumSize,size); + size = max(MINIMUM_TOOL_SIZE,size); + size = min(MAXIMUM_TOOL_SIZE,size); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size; window_invalidate(w); } @@ -188,8 +188,8 @@ static void window_land_rights_textinput(rct_window *w, int widgetIndex, char *t static void window_land_rights_inputsize(rct_window *w) { - ((uint16*)TextInputDescriptionArgs)[0] = _minimumSize; - ((uint16*)TextInputDescriptionArgs)[1] = _maximumSize; + ((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_TOOL_SIZE; + ((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_TOOL_SIZE; window_text_input_open(w, WIDX_PREVIEW, 5128, 5129, STR_NONE, STR_NONE, 3); } diff --git a/src/windows/water.c b/src/windows/water.c index 0ccd77294f..cbe2803606 100644 --- a/src/windows/water.c +++ b/src/windows/water.c @@ -27,6 +27,9 @@ #include "../world/map.h" #include "../interface/themes.h" +#define MINIMUM_TOOL_SIZE 0 +#define MAXIMUM_TOOL_SIZE 64 + enum WINDOW_WATER_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, @@ -56,9 +59,6 @@ static void window_water_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_water_textinput(rct_window *w, int widgetIndex, char *text); static void window_water_inputsize(rct_window *w); -static int _minimumSize = 1; -static int _maximumSize = 64; - static rct_window_event_list window_water_events = { window_water_close, window_water_mouseup, @@ -143,14 +143,14 @@ static void window_water_mouseup(rct_window *w, int widgetIndex) break; case WIDX_DECREMENT: // Decrement land tool size - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(_minimumSize, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = max(MINIMUM_TOOL_SIZE, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)-1); // Invalidate the window window_invalidate(w); break; case WIDX_INCREMENT: // Increment land tool size - RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(_maximumSize, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); + RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = min(MAXIMUM_TOOL_SIZE, RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)+1); // Invalidate the window window_invalidate(w); @@ -171,8 +171,8 @@ static void window_water_textinput(rct_window *w, int widgetIndex, char *text) size = strtol(text, &end, 10); if (*end == '\0') { - size = max(_minimumSize,size); - size = min(_maximumSize,size); + size = max(MINIMUM_TOOL_SIZE,size); + size = min(MAXIMUM_TOOL_SIZE,size); RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size; window_invalidate(w); @@ -181,8 +181,8 @@ static void window_water_textinput(rct_window *w, int widgetIndex, char *text) static void window_water_inputsize(rct_window *w) { - ((uint16*)TextInputDescriptionArgs)[0] = _minimumSize; - ((uint16*)TextInputDescriptionArgs)[1] = _maximumSize; + ((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_TOOL_SIZE; + ((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_TOOL_SIZE; window_text_input_open(w, WIDX_PREVIEW, 5128, 5129, STR_NONE, STR_NONE, 3); } From 7db2008472cbeec39cefcda80575a6784bcb7b5f Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 12 Aug 2015 14:24:20 +0200 Subject: [PATCH 2/2] Fix minimum tool sizes --- src/windows/clear_scenery.c | 2 +- src/windows/land_rights.c | 2 +- src/windows/water.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/windows/clear_scenery.c b/src/windows/clear_scenery.c index 7b3fb34120..819340bc07 100644 --- a/src/windows/clear_scenery.c +++ b/src/windows/clear_scenery.c @@ -27,7 +27,7 @@ #include "../interface/window.h" #include "../interface/themes.h" -#define MINIMUM_TOOL_SIZE 0 +#define MINIMUM_TOOL_SIZE 1 #define MAXIMUM_TOOL_SIZE 64 enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { diff --git a/src/windows/land_rights.c b/src/windows/land_rights.c index 6b6b533045..ce0ea3cf89 100644 --- a/src/windows/land_rights.c +++ b/src/windows/land_rights.c @@ -29,7 +29,7 @@ #include "../game.h" #include "../interface/themes.h" -#define MINIMUM_TOOL_SIZE 0 +#define MINIMUM_TOOL_SIZE 1 #define MAXIMUM_TOOL_SIZE 64 enum WINDOW_WATER_WIDGET_IDX { diff --git a/src/windows/water.c b/src/windows/water.c index cbe2803606..ea3de071c3 100644 --- a/src/windows/water.c +++ b/src/windows/water.c @@ -27,7 +27,7 @@ #include "../world/map.h" #include "../interface/themes.h" -#define MINIMUM_TOOL_SIZE 0 +#define MINIMUM_TOOL_SIZE 1 #define MAXIMUM_TOOL_SIZE 64 enum WINDOW_WATER_WIDGET_IDX {