diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index a929f01b7f..537c625534 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -198,7 +198,6 @@ - diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 783f64ca6f..ccc255778a 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -357,7 +357,6 @@ Source\Windows - Source\Interface @@ -386,7 +385,7 @@ Source\Localisation - + Source\Windows @@ -486,9 +485,6 @@ Source\Windows - - Source\Windows - Source\Windows diff --git a/src/editor.c b/src/editor.c index 166f476196..4ac6935df8 100644 --- a/src/editor.c +++ b/src/editor.c @@ -41,6 +41,7 @@ #include "world/climate.h" #include "world/map.h" #include "world/park.h" +#include "world/scenery.h" #include "world/sprite.h" static void set_all_land_owned(); @@ -196,7 +197,7 @@ void editor_convert_save_to_scenario() window_invalidate(w); sub_69E9A7(); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; load_palette(); @@ -566,7 +567,7 @@ static void sub_6A2B62() window_invalidate(w); sub_69E9A7(); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; load_palette(); @@ -953,7 +954,7 @@ static int editor_read_s6(const char *path) window_invalidate(w); sub_69E9A7(); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; load_palette(); diff --git a/src/game.c b/src/game.c index f80cdb61fe..64d1330934 100644 --- a/src/game.c +++ b/src/game.c @@ -51,6 +51,7 @@ #include "world/climate.h" #include "world/map_animation.h" #include "world/park.h" +#include "world/scenery.h" #include "world/sprite.h" #include "world/water.h" @@ -691,7 +692,7 @@ int game_load_save(const char *path) window_invalidate(mainWindow); sub_69E9A7(); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; if (RCT2_GLOBAL(0x0013587C4, uint32) == 0) // this check is not in scenario play diff --git a/src/rct2.c b/src/rct2.c index 16f0ba06a1..dd4c16a942 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -43,6 +43,7 @@ #include "world/map.h" #include "world/park.h" #include "world/climate.h" +#include "world/scenery.h" #include "world/sprite.h" typedef struct tm tm_t; @@ -109,7 +110,7 @@ int rct2_init() RCT2_CALLPROC_EBPSAFE(0x0066B5C0); // 0x0066B5C0 (part of 0x0066B3E8) screen_game_create_windows() date_reset(); climate_reset(CLIMATE_COOL_AND_WET); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); diff --git a/src/scenario.c b/src/scenario.c index 2752c46ba4..c5a69d7c11 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -38,6 +38,7 @@ #include "util/util.h" #include "world/map.h" #include "world/park.h" +#include "world/scenery.h" #include "world/sprite.h" #include "world/water.h" @@ -258,7 +259,7 @@ int scenario_load_and_play_from_path(const char *path) if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & PARK_FLAGS_NO_MONEY_SCENARIO) RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= PARK_FLAGS_NO_MONEY; sub_684AC3(); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); news_item_init_queue(); if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) window_park_objective_open(); diff --git a/src/title.c b/src/title.c index d7fbbd9f44..7a7c8938b4 100644 --- a/src/title.c +++ b/src/title.c @@ -37,6 +37,7 @@ #include "world/climate.h" #include "world/map.h" #include "world/park.h" +#include "world/scenery.h" #include "world/sprite.h" static const int gOldMusic = 0; @@ -107,7 +108,7 @@ void title_load() park_init(); date_reset(); climate_reset(CLIMATE_COOL_AND_WET); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); @@ -206,7 +207,7 @@ static void title_update_showcase() sub_69E9A7(); window_new_ride_init_vars(); sub_684AC3(); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); news_item_init_queue(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; diff --git a/src/windows/editor_bottom_toolbar.c b/src/windows/editor_bottom_toolbar.c index a7de4e9800..c829456427 100644 --- a/src/windows/editor_bottom_toolbar.c +++ b/src/windows/editor_bottom_toolbar.c @@ -31,6 +31,7 @@ #include "../platform/platform.h" #include "../title.h" #include "../util/util.h" +#include "../world/scenery.h" #include "error.h" enum { @@ -167,7 +168,7 @@ void window_editor_bottom_toolbar_jump_back_to_object_selection() { void window_editor_bottom_toolbar_jump_back_to_landscape_editor() { window_close_all(); RCT2_CALLPROC_EBPSAFE(0x006DFED0); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); g_editor_step = EDITOR_STEP_LANDSCAPE_EDITOR; window_map_open(); gfx_invalidate_screen(); @@ -228,7 +229,7 @@ void window_editor_bottom_toolbar_jump_forward_from_object_selection() RCT2_CALLPROC_EBPSAFE(0x0066F6E3); } else { RCT2_CALLPROC_EBPSAFE(0x006DFED0); - RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + scenery_set_default_placement_configuration(); RCT2_GLOBAL(0x00141F570, uint8) = 1; window_map_open(); gfx_invalidate_screen(); diff --git a/src/windows/map.c b/src/windows/map.c index f93f5e0f5e..2efeb2caf7 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -25,7 +25,7 @@ #include "../interface/viewport.h" #include "../interface/window.h" #include "../sprites.h" -#include "../windows/scenery.h" +#include "../world/scenery.h" enum WINDOW_MAP_WIDGET_IDX { diff --git a/src/windows/mapgen.c b/src/windows/mapgen.c index 18f75088e6..0728125fc9 100644 --- a/src/windows/mapgen.c +++ b/src/windows/mapgen.c @@ -25,8 +25,8 @@ #include "../interface/viewport.h" #include "../interface/window.h" #include "../sprites.h" -#include "../windows/scenery.h" #include "../world/mapgen.h" +#include "../world/scenery.h" #include "dropdown.h" enum { diff --git a/src/windows/scenery.c b/src/windows/scenery.c index 363d2ab73d..7982964f20 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -32,7 +32,11 @@ #include "../world/scenery.h" #include "../world/sprite.h" #include "dropdown.h" -#include "scenery.h" + +#define WINDOW_SCENERY_WIDTH 634 +#define WINDOW_SCENERY_HEIGHT 142 +#define SCENERY_BUTTON_WIDTH 66 +#define SCENERY_BUTTON_HEIGHT 80 enum { WINDOW_SCENERY_TAB_1, @@ -174,7 +178,10 @@ static rct_widget window_scenery_widgets[] = { { WIDGETS_END }, }; -static sint16 window_scenery_tab_entries[0x14][SCENERY_ENTRIES_BY_TAB + 1]; +// rct2: 0x00F64F2C +sint16 window_scenery_tab_entries[20][SCENERY_ENTRIES_BY_TAB + 1]; + +void window_scenery_update_scroll(rct_window *w); /** * Was part of 0x006DFA00 @@ -221,7 +228,8 @@ void init_scenery_entry(rct_scenery_entry *sceneryEntry, int index, uint8 scener * * rct2: 0x006DFA00 */ -void init_scenery() { +void init_scenery() +{ bool enabledScenerySets[0x14] = { false }; for (int scenerySetIndex = 0; scenerySetIndex < 0x14; scenerySetIndex++) { @@ -367,6 +375,37 @@ void init_scenery() { window_invalidate_by_class(WC_SCENERY); } +/** + * + * rct2: 0x006DFEE4 + */ +void scenery_set_default_placement_configuration() +{ + window_scenery_rotation = 3; + window_scenery_primary_colour = 26; + window_scenery_secondary_colour = 18; + window_scenery_tertiary_colour = 24; + init_scenery(); + + for (int i = 0; i < 20; i++) + window_scenery_selected_scenery_by_tab[i] = -1; + + for (int i = 0; i < 20; i++) { + if (window_scenery_tab_entries[i][0] != -1) { + window_scenery_active_tab_index = i; + return; + } + } + + for (int i = 0; i < 16; i++) { + rct_widget *tabWidget = &window_scenery_widgets[WIDX_SCENERY_TAB_1 + i]; + if (tabWidget->type != WWT_EMPTY) { + window_scenery_active_tab_index = i; + return; + } + } +} + /** * * rct2: 0x006E0FEF @@ -416,7 +455,7 @@ void window_scenery_open() (1 << WIDX_SCENERY_BUILD_CLUSTER_BUTTON); window_init_scroll_widgets(window); - RCT2_CALLPROC_X(0x006E1EB4, 0, 0, 0, 0, (int)window, 0, 0); + window_scenery_update_scroll(window); show_gridlines(); window_scenery_rotation = 3; RCT2_GLOBAL(0x00F64F12, uint8) = 0; diff --git a/src/windows/scenery.h b/src/windows/scenery.h deleted file mode 100644 index f9868e5709..0000000000 --- a/src/windows/scenery.h +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2014 Dániel Tar -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef _WINDOW_SCENERY_H_ -#define _WINDOW_SCENERY_H_ - -#define WINDOW_SCENERY_WIDTH 0x27A -#define WINDOW_SCENERY_HEIGHT 0x8E -#define SCENERY_BUTTON_WIDTH 66 -#define SCENERY_BUTTON_HEIGHT 80 -#define SCENERY_ENTRIES_BY_TAB 128 - -#define window_scenery_active_tab_index RCT2_GLOBAL(0x00F64EDC, uint8) -#define window_scenery_selected_scenery_by_tab RCT2_ADDRESS(0x00F64EDD, sint16) -#define window_scenery_is_build_cluster_tool_on RCT2_GLOBAL(0x00F64F1A, uint8) -#define window_scenery_is_repaint_scenery_tool_on RCT2_GLOBAL(0x00F64F19, uint8) -#define window_scenery_rotation RCT2_GLOBAL(0x00F64F05, uint8) -#define window_scenery_primary_colour RCT2_GLOBAL(0x00F64F06, uint8) -#define window_scenery_secondary_colour RCT2_GLOBAL(0x00F64F07, uint8) -#define window_scenery_tertiary_colour RCT2_GLOBAL(0x00F64F08, uint8) - -#endif \ No newline at end of file diff --git a/src/windows/staff.c b/src/windows/staff.c index fb8c70e1f2..4c9f71d0b8 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -1318,9 +1318,8 @@ void window_staff_options_mousedown(int widgetIndex, rct_window* w, rct_widget* init_scenery(); int ebx = 0; - for (int i = 0; i < 19;++i){ - sint16* ebp = RCT2_ADDRESS(0xF64F2C, sint16*)[i]; - if (*ebp != -1){ + for (int i = 0; i < 19; i++) { + if (window_scenery_tab_entries[i][0] != -1) { rct_scenery_set_entry* scenery_entry = g_scenerySetEntries[i]; ebx |= scenery_entry->var_10A; } diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 058084866a..85b933d396 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -29,8 +29,8 @@ #include "../interface/window.h" #include "../interface/viewport.h" #include "../localisation/localisation.h" +#include "../world/scenery.h" #include "dropdown.h" -#include "scenery.h" enum { WIDX_PAUSE, diff --git a/src/world/scenery.h b/src/world/scenery.h index fe6ba1ef6a..5740eb5765 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -135,6 +135,8 @@ enum { PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW = 1 << 5 }; +#define SCENERY_ENTRIES_BY_TAB 128 + #define g_smallSceneryEntries ((rct_scenery_entry**)object_entry_groups[OBJECT_TYPE_SMALL_SCENERY].chunks) #define g_largeSceneryEntries ((rct_scenery_entry**)object_entry_groups[OBJECT_TYPE_LARGE_SCENERY].chunks) #define g_wallSceneryEntries ((rct_scenery_entry**)object_entry_groups[OBJECT_TYPE_WALLS].chunks) @@ -142,8 +144,20 @@ enum { #define g_pathBitSceneryEntries ((rct_scenery_entry**)object_entry_groups[OBJECT_TYPE_PATH_BITS].chunks) #define g_scenerySetEntries ((rct_scenery_set_entry**)object_entry_groups[OBJECT_TYPE_SCENERY_SETS].chunks) +#define window_scenery_active_tab_index RCT2_GLOBAL(0x00F64EDC, uint8) +#define window_scenery_selected_scenery_by_tab RCT2_ADDRESS(0x00F64EDD, sint16) +#define window_scenery_is_build_cluster_tool_on RCT2_GLOBAL(0x00F64F1A, uint8) +#define window_scenery_is_repaint_scenery_tool_on RCT2_GLOBAL(0x00F64F19, uint8) +#define window_scenery_rotation RCT2_GLOBAL(0x00F64F05, uint8) +#define window_scenery_primary_colour RCT2_GLOBAL(0x00F64F06, uint8) +#define window_scenery_secondary_colour RCT2_GLOBAL(0x00F64F07, uint8) +#define window_scenery_tertiary_colour RCT2_GLOBAL(0x00F64F08, uint8) + +extern sint16 window_scenery_tab_entries[20][SCENERY_ENTRIES_BY_TAB + 1]; + void init_scenery(); void scenery_update_tile(int x, int y); void scenery_update_age(int x, int y, rct_map_element *mapElement); +void scenery_set_default_placement_configuration(); #endif \ No newline at end of file