diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index b125cef62f..74009664a5 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3892,6 +3892,7 @@ STR_5550 :{POP16}{POP16}Year {COMMA16}, {PUSH16}{PUSH16}{MONTH} {PUSH16}{PUSH STR_5551 :Year/Day/Month STR_5552 :{POP16}{POP16}Year {COMMA16}, {PUSH16}{PUSH16}{PUSH16}{STRINGID} {MONTH} STR_5553 :Pause game when Steam overlay is open +STR_5554 :{SMALLFONT}{BLACK}Enable mountain tool ##################### # Rides/attractions # diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 75d5d689eb..54f7a2ffe2 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -2128,6 +2128,8 @@ enum { STR_STEAM_OVERLAY_PAUSE = 5553, + STR_ENABLE_MOUNTAIN_TOOL_TIP = 5554, + // 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/land.c b/src/windows/land.c index 1a68a7884c..94f9e4200b 100644 --- a/src/windows/land.c +++ b/src/windows/land.c @@ -28,31 +28,36 @@ #include "dropdown.h" #include "../interface/themes.h" -#define MINIMUM_TOOL_SIZE 0 +#define MINIMUM_TOOL_SIZE 1 #define MAXIMUM_TOOL_SIZE 64 enum WINDOW_LAND_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, WIDX_CLOSE, + WIDX_MOUNTAINMODE, + WIDX_PAINTMODE, WIDX_PREVIEW, WIDX_DECREMENT, WIDX_INCREMENT, WIDX_FLOOR, WIDX_WALL, - WIDX_PAINTMODE, }; static rct_widget window_land_widgets[] = { - { WWT_FRAME, 0, 0, 97, 0, 125, -1, STR_NONE }, // panel / background - { WWT_CAPTION, 0, 1, 96, 1, 14, STR_LAND, STR_WINDOW_TITLE_TIP }, // title bar - { WWT_CLOSEBOX, 0, 85, 95, 2, 13, 824, STR_CLOSE_WINDOW_TIP }, // close x button - { WWT_IMGBTN, 0, 10, 53, 17, 48, 5503, STR_NONE }, // preview box - { WWT_TRNBTN, 1, 11, 26, 18, 33, 0x20000000 | SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_TIP }, // decrement size - { WWT_TRNBTN, 1, 37, 52, 32, 47, 0x20000000 | SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_TIP }, // increment size - { WWT_FLATBTN, 1, 2, 48, 75, 110, 0xFFFFFFFF, STR_CHANGE_BASE_LAND_TIP }, // floor texture - { WWT_FLATBTN, 1, 49, 95, 75, 110, 0xFFFFFFFF, STR_CHANGE_VERTICAL_LAND_TIP }, // wall texture - { WWT_FLATBTN, 1, 64, 87, 21, 44, 5173, 5127 }, // paint mode + { WWT_FRAME, 0, 0, 97, 0, 143, -1, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 96, 1, 14, STR_LAND, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 85, 95, 2, 13, 824, STR_CLOSE_WINDOW_TIP }, // close x button + + { WWT_FLATBTN, 1, 19, 42, 19, 42, 5147, STR_ENABLE_MOUNTAIN_TOOL_TIP }, // mountain mode + { WWT_FLATBTN, 1, 55, 78, 19, 42, 5173, 5127 }, // paint mode + + { WWT_IMGBTN, 0, 27, 70, 48, 79, 5503, STR_NONE }, // preview box + { WWT_TRNBTN, 1, 28, 43, 49, 64, 0x20000000 | SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_TIP }, // decrement size + { WWT_TRNBTN, 1, 54, 69, 63, 78, 0x20000000 | SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_TIP }, // increment size + + { WWT_FLATBTN, 1, 2, 48, 106, 141, 0xFFFFFFFF, STR_CHANGE_BASE_LAND_TIP }, // floor texture + { WWT_FLATBTN, 1, 49, 95, 106, 141, 0xFFFFFFFF, STR_CHANGE_VERTICAL_LAND_TIP }, // wall texture { WIDGETS_END }, }; @@ -128,7 +133,7 @@ void window_land_open() if (window_find_by_class(WC_LAND) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 98, 29, 98, 126, &window_land_events, WC_LAND, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 98, 29, 98, 144, &window_land_events, WC_LAND, 0); window->widgets = window_land_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -136,6 +141,7 @@ void window_land_open() (1 << WIDX_INCREMENT) | (1 << WIDX_FLOOR) | (1 << WIDX_WALL) | + (1 << WIDX_MOUNTAINMODE) | (1 << WIDX_PAINTMODE) | (1 << WIDX_PREVIEW); window_init_scroll_widgets(window); @@ -143,7 +149,8 @@ void window_land_open() RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) = 255; RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) = 255; - LandPaintMode = false; + gLandMountainMode = false; + gLandPaintMode = false; _selectedFloorTexture = 0; _selectedWallTexture = 0; RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, money32) = MONEY32_UNDEFINED; @@ -185,8 +192,14 @@ static void window_land_mouseup(rct_window *w, int widgetIndex) // Invalidate the window window_invalidate(w); break; + case WIDX_MOUNTAINMODE: + gLandMountainMode ^= 1; + gLandPaintMode = 0; + window_invalidate(w); + break; case WIDX_PAINTMODE: - LandPaintMode ^= 1; + gLandMountainMode = 0; + gLandPaintMode ^= 1; window_invalidate(w); break; case WIDX_PREVIEW: @@ -336,7 +349,9 @@ static void window_land_invalidate(rct_window *w) w->pressed_widgets |= (1 << WIDX_FLOOR); if (RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) != 255) w->pressed_widgets |= (1 << WIDX_WALL); - if (LandPaintMode != 0) + if (gLandMountainMode) + w->pressed_widgets |= (1 << WIDX_MOUNTAINMODE); + if (gLandPaintMode) w->pressed_widgets |= (1 << WIDX_PAINTMODE); window_land_widgets[WIDX_FLOOR].image = SPR_FLOOR_TEXTURE_GRASS + _selectedFloorTexture; @@ -355,19 +370,23 @@ static void window_land_paint(rct_window *w, rct_drawpixelinfo *dpi) { int x, y, numTiles; money32 price; + rct_widget *previewWidget = &window_land_widgets[WIDX_PREVIEW]; window_draw_widgets(w, dpi); - x = w->x + (window_land_widgets[WIDX_PREVIEW].left + window_land_widgets[WIDX_PREVIEW].right) / 2; - y = w->y + (window_land_widgets[WIDX_PREVIEW].top + window_land_widgets[WIDX_PREVIEW].bottom) / 2; - // Draw number for tool sizes bigger than 7 if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) { + x = w->x + (previewWidget->left + previewWidget->right) / 2; + y = w->y + (previewWidget->top + previewWidget->bottom) / 2; gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)); + } else if (gLandMountainMode) { + x = w->x + previewWidget->left; + y = w->y + previewWidget->top; + gfx_draw_sprite(dpi, SPR_LAND_TOOL_SIZE_0, x, y, 0); } - x = w->x + (window_land_widgets[WIDX_PREVIEW].left + window_land_widgets[WIDX_PREVIEW].right) / 2 + 17; - y = w->y + window_land_widgets[WIDX_PREVIEW].bottom + 5; + x = w->x + (previewWidget->left + previewWidget->right) / 2; + y = w->y + previewWidget->bottom + 5; // Draw raise cost amount if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0) diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 620c518ea1..868068e110 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1792,7 +1792,7 @@ void top_toolbar_tool_update_land(sint16 x, sint16 y){ rct_xy16 mapTile = { .x = x, .y = y }; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); - if (tool_size == 1){ + if (tool_size == 1 && !gLandMountainMode){ int direction; screen_pos_to_map_pos(&mapTile.x, &mapTile.y, &direction); @@ -2498,7 +2498,7 @@ static void window_top_toolbar_tool_update(rct_window* w, int widgetIndex, int x top_toolbar_tool_update_scenery_clear(x, y); break; case WIDX_LAND: - if (LandPaintMode) + if (gLandPaintMode) top_toolbar_tool_update_land_paint(x, y); else top_toolbar_tool_update_land(x, y); @@ -2576,7 +2576,7 @@ money32 selection_raise_land(uint8 flags) uint32 yBounds = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) & 0xFFFF) | (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) << 16); RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_RAISE_LAND_HERE; - if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) == 0) { + if (gLandMountainMode) { return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_EDIT_LAND_SMOOTH, 1, yBounds); } else { return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_RAISE_LAND, RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16), yBounds); @@ -2598,7 +2598,7 @@ money32 selection_lower_land(uint8 flags) uint32 yBounds = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) & 0xFFFF) | (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) << 16); RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_LOWER_LAND_HERE; - if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) == 0) { + if (gLandMountainMode) { return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_EDIT_LAND_SMOOTH, 0xFFFF, yBounds); } else { return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_LOWER_LAND, RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16), yBounds); @@ -2746,7 +2746,7 @@ static void window_top_toolbar_tool_drag(rct_window* w, int widgetIndex, int x, break; case WIDX_LAND: // Custom setting to only change land style instead of raising or lowering land - if (LandPaintMode) { + if (gLandPaintMode) { if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16)&(1 << 0)){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, rct_string_id) = STR_CANT_CHANGE_LAND_TYPE; game_do_command( diff --git a/src/world/map.c b/src/world/map.c index 0926e655c0..076899d23f 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -58,7 +58,8 @@ rct_map_element **gMapElementTilePointers = (rct_map_element**)RCT2_ADDRESS_TILE rct_xy16 *gMapSelectionTiles = (rct_xy16*)0x009DE596; rct2_peep_spawn *gPeepSpawns = (rct2_peep_spawn*)RCT2_ADDRESS_PEEP_SPAWNS; -bool LandPaintMode; +bool gLandMountainMode; +bool gLandPaintMode; bool LandRightsMode; bool gClearSmallScenery; bool gClearLargeScenery; @@ -2148,6 +2149,12 @@ static money32 smooth_land_tile(int direction, uint8 flags, int x, int y, uint8 money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop, int mapRight, int mapBottom, int command) { + // Cap bounds to map + mapLeft = max(mapLeft, 32); + mapTop = max(mapTop, 32); + mapRight = min(mapRight, 255 * 32); + mapBottom = min(mapBottom, 255 * 32); + int commandType; int centreZ = map_element_height(centreX, centreY); int mapLeftRight = mapLeft | (mapRight << 16); @@ -2200,7 +2207,7 @@ money32 smooth_land(int flags, int centreX, int centreY, int mapLeft, int mapTop int size = ((mapRight - mapLeft) >> 5) + 1; sint8 initialMinZ = -2; - for (; size <= 64; size += 2) { + for (; size <= 256; size += 2) { initialMinZ += 2; sint8 minZ = (initialMinZ << 1) & 0xFF; x -= 32; @@ -2359,10 +2366,10 @@ void game_command_smooth_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, int flags = *ebx & 0xFF; int centreX = *eax & 0xFFFF; int centreY = *ecx & 0xFFFF; - int mapLeft = *edx & 0xFFFF; - int mapTop = *ebp & 0xFFFF; - int mapRight = *edx >> 16; - int mapBottom = *ebp >> 16; + int mapLeft = (sint16)(*edx & 0xFFFF); + int mapTop = (sint16)(*ebp & 0xFFFF); + int mapRight = (sint16)(*edx >> 16); + int mapBottom = (sint16)(*ebp >> 16); int command = *edi; *ebx = smooth_land(flags, centreX, centreY, mapLeft, mapTop, mapRight, mapBottom, command); } diff --git a/src/world/map.h b/src/world/map.h index d860869ec4..60d41f67bb 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -262,8 +262,10 @@ extern rct_map_element **gMapElementTilePointers; extern rct_xy16 *gMapSelectionTiles; extern rct2_peep_spawn *gPeepSpawns; +// Used in the land tool window to enable mountain tool / land smoothing +extern bool gLandMountainMode; // Used in the land tool window to allow dragging and changing land styles -extern bool LandPaintMode; +extern bool gLandPaintMode; // Used in the land rights tool window to either buy land rights or construction rights extern bool LandRightsMode; // Used in the clear scenery tool