1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Move loadsave dialog

This commit is contained in:
Marijn van der Werf
2017-09-12 00:04:03 +02:00
parent 9b1b2b5c62
commit d18e59ff17
20 changed files with 145 additions and 65 deletions

View File

@@ -530,7 +530,11 @@ static void shortcut_quick_save_game()
save_game();
}
else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) {
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, gS6Info.name);
Intent * intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_4, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
intent_set_string(intent, INTENT_EXTRA_5, gS6Info.name);
context_open_intent(intent);
intent_release(intent);
}
}

View File

@@ -69,8 +69,6 @@ static rct_window_event_list window_error_events = {
static char _window_error_text[512];
static uint16 _window_error_num_lines;
extern "C" {
/**
*
* rct2: 0x0066792F
@@ -150,8 +148,6 @@ rct_window * window_error_open(rct_string_id title, rct_string_id message)
return w;
}
}
/**
*
* rct2: 0x00667BFE

View File

@@ -14,20 +14,21 @@
*****************************************************************************/
#pragma endregion
#include "../config/Config.h"
#include "../title/TitleScreen.h"
#include "../core/Memory.hpp"
#include "../Context.h"
#include "Intent.h"
#include <openrct2/config/Config.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/core/Memory.hpp>
#include <openrct2/Context.h>
#include <openrct2/windows/Intent.h>
#include <openrct2-ui/windows/Window.h>
#include <time.h>
#include "../core/Guard.hpp"
#include "../Editor.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../platform/platform.h"
#include "../util/util.h"
#include <openrct2/core/Guard.hpp>
#include <openrct2/Editor.h>
#include <openrct2/game.h>
#include <openrct2/interface/widget.h>
#include <openrct2/localisation/localisation.h>
#include <openrct2/platform/platform.h>
#include <openrct2/util/util.h>
#pragma region Widgets

View File

@@ -1189,9 +1189,13 @@ static void window_mapgen_heightmap_mouseup(rct_window *w, rct_widgetindex widge
// Page widgets
case WIDX_HEIGHTMAP_SELECT:
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_IMAGE, nullptr);
window_loadsave_set_loadsave_callback(window_mapgen_heightmap_loadsave_callback);
{
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_IMAGE);
intent.putExtra(INTENT_EXTRA_6, (void *) window_mapgen_heightmap_loadsave_callback);
context_open_intent(&intent);
return;
}
case WIDX_HEIGHTMAP_SMOOTH_HEIGHTMAP:
_heightmapSmoothMap = !_heightmapSmoothMap;
widget_set_checkbox_value(w, WIDX_HEIGHTMAP_SMOOTH_HEIGHTMAP, _heightmapSmoothMap);

View File

@@ -18,6 +18,8 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/core/Util.hpp>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/Context.h>
#include <openrct2/audio/audio.h>
#include <openrct2/game.h>
@@ -228,16 +230,28 @@ static void window_save_prompt_mouseup(rct_window *w, rct_widgetindex widgetInde
}
return;
} else {
switch (widgetIndex) {
switch (widgetIndex)
{
case WIDX_SAVE:
if (gScreenFlags & (SCREEN_FLAGS_EDITOR)) {
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, gS6Info.name);
} else {
save_game_as();
{
Intent * intent;
if (gScreenFlags & (SCREEN_FLAGS_EDITOR))
{
intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_4, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
intent_set_string(intent, INTENT_EXTRA_5, gS6Info.name);
}
else
{
intent = (Intent *) create_save_game_as_intent();
}
window_close(w);
window_loadsave_set_loadsave_callback(window_save_prompt_callback);
intent_set_pointer(intent, INTENT_EXTRA_6, (void *) window_save_prompt_callback);
context_open_intent(intent);
intent_release(intent);
break;
}
case WIDX_DONT_SAVE:
game_load_or_quit_no_save_prompt();
return;

View File

@@ -224,8 +224,10 @@ static void window_server_start_mouseup(rct_window *w, rct_widgetindex widgetInd
break;
case WIDX_LOAD_SERVER:
network_set_password(_password);
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, nullptr);
window_loadsave_set_loadsave_callback(window_server_start_loadsave_callback);
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME);
intent.putExtra(INTENT_EXTRA_6, (void *) window_server_start_loadsave_callback);
context_open_intent(&intent);
break;
}
}

View File

@@ -330,8 +330,10 @@ static void window_title_editor_mouseup(rct_window *w, rct_widgetindex widgetInd
//////////////////////////////////////////////////////////////////////////////////////////////////////
case WIDX_TITLE_EDITOR_ADD_SAVE:
if (!_isSequenceReadOnly && !_isSequencePlaying && !commandEditorOpen) {
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, nullptr);
window_loadsave_set_loadsave_callback(window_title_editor_add_park_callback);
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME);
intent.putExtra(INTENT_EXTRA_6, (void *) window_title_editor_add_park_callback);
context_open_intent(&intent);
}
break;
case WIDX_TITLE_EDITOR_REMOVE_SAVE:

View File

@@ -149,7 +149,7 @@ static bool _showLockedInformation = false;
*
* rct2: 0x006781B5
*/
static void _window_scenarioselect_open(scenarioselect_callback callback)
rct_window * window_scenarioselect_open(scenarioselect_callback callback)
{
rct_window* window;
sint32 windowWidth;
@@ -157,8 +157,9 @@ static void _window_scenarioselect_open(scenarioselect_callback callback)
_callback = callback;
if (window_bring_to_front_by_class(WC_SCENARIO_SELECT) != nullptr)
return;
window = window_bring_to_front_by_class(WC_SCENARIO_SELECT);
if (window != nullptr)
return window;
// Load scenario list
scenario_repository_scan();
@@ -188,6 +189,8 @@ static void _window_scenarioselect_open(scenarioselect_callback callback)
window_init_scroll_widgets(window);
window->viewport_focus_coordinates.var_480 = -1;
window->highlighted_scenario = nullptr;
return window;
}
/**
@@ -700,11 +703,3 @@ static bool is_locking_enabled(rct_window *w)
}
return true;
}
extern "C"
{
void window_scenarioselect_open(scenarioselect_callback callback)
{
_window_scenarioselect_open(callback);
}
}

View File

@@ -20,6 +20,8 @@
#include <openrct2/interface/window.h>
typedef void (*loadsave_callback)(sint32 result, const utf8 * path);
rct_window * window_about_open();
rct_window * window_changelog_open();
rct_window * window_cheats_open();
@@ -79,6 +81,9 @@ rct_window * window_guest_list_open_with_filter(sint32 type, sint32 index);
rct_window * window_staff_fire_prompt_open(rct_peep* peep);
void window_title_editor_open(sint32 tab);
void window_title_command_editor_open(struct TitleSequence * sequence, sint32 command, bool insert);
void window_scenarioselect_open(scenarioselect_callback callback);
rct_window * window_scenarioselect_open(scenarioselect_callback callback);
rct_window * window_error_open(rct_string_id title, rct_string_id message);
rct_window * window_loadsave_open(sint32 type, char *defaultName);
void window_loadsave_set_loadsave_callback(loadsave_callback cb);

View File

@@ -100,8 +100,10 @@ namespace Editor
void ConvertSaveToScenario()
{
tool_cancel();
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, NULL);
window_loadsave_set_loadsave_callback(ConvertSaveToScenarioCallback);
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME);
intent.putExtra(INTENT_EXTRA_5, (void *) ConvertSaveToScenarioCallback);
context_open_intent(&intent);
}
static void ConvertSaveToScenarioCallback(sint32 result, const utf8 * path)

View File

@@ -918,7 +918,10 @@ static void game_load_or_quit(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx
*/
static void load_landscape()
{
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE, NULL);
Intent * intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE);
context_open_intent(intent);
intent_release(intent);
}
static void utf8_to_rct2_self(char *buffer, size_t length)
@@ -1216,12 +1219,25 @@ void save_game()
save_game_as();
}
}
void save_game_as()
void * create_save_game_as_intent()
{
char name[MAX_PATH];
safe_strcpy(name, path_get_filename(gScenarioSavePath), MAX_PATH);
path_remove_extension(name);
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME, name);
Intent * intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_4, LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME);
intent_set_string(intent, INTENT_EXTRA_5, name);
return intent;
}
void save_game_as()
{
Intent * intent = (Intent *) create_save_game_as_intent();
context_open_intent(intent);
intent_release(intent);
}
static sint32 compare_autosave_file_paths (const void * a, const void * b ) {
@@ -1396,8 +1412,11 @@ void game_load_or_quit_no_save_prompt()
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) {
load_landscape();
} else {
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, NULL);
window_loadsave_set_loadsave_callback(game_load_or_quit_no_save_prompt_callback);
Intent * intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME);
intent_set_pointer(intent, INTENT_EXTRA_6, game_load_or_quit_no_save_prompt_callback);
context_open_intent(intent);
intent_release(intent);
}
break;
case PM_SAVE_BEFORE_QUIT:

View File

@@ -181,6 +181,7 @@ void pause_toggle();
bool game_is_paused();
bool game_is_not_paused();
void save_game();
void * create_save_game_as_intent();
void save_game_as();
void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, const utf8 * path, bool loadTitleFirst);
void handle_park_load_failure(const ParkLoadResult * result, const utf8 * path);

View File

@@ -604,7 +604,6 @@ typedef enum {
} TOOL_IDX;
typedef void (*modal_callback)(sint32 result);
typedef void (*loadsave_callback)(sint32 result, const utf8 * path);
typedef void (*scenarioselect_callback)(const utf8 *path);
typedef void (*close_callback)();
@@ -746,8 +745,6 @@ void window_tile_inspector_clear_clipboard();
void window_text_input_open(rct_window* call_w, rct_widgetindex call_widget, rct_string_id title, rct_string_id description, rct_string_id existing_text, uintptr_t existing_args, sint32 maxLength);
void window_text_input_raw_open(rct_window* call_w, rct_widgetindex call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, sint32 maxLength);
rct_window *window_loadsave_open(sint32 type, char *defaultName);
rct_window * window_object_load_error_open(utf8 * path, size_t numMissingObjects, const rct_object_entry * missingObjects);
rct_window * window_editor_main_open();
@@ -819,8 +816,6 @@ bool scenery_tool_is_active();
//Cheat: in-game land ownership editor
void toggle_ingame_land_ownership_editor();
void window_loadsave_set_loadsave_callback(loadsave_callback cb);
void window_ride_construction_keyboard_shortcut_turn_left();
void window_ride_construction_keyboard_shortcut_turn_right();
void window_ride_construction_keyboard_shortcut_use_track_default();

View File

@@ -180,8 +180,12 @@ bool track_design_save(uint8 rideIndex)
utf8 track_name[256];
format_string(track_name, sizeof(track_name), ride->name, &ride->name_arguments);
window_loadsave_open(LOADSAVETYPE_TRACK | LOADSAVETYPE_SAVE, track_name);
window_loadsave_set_loadsave_callback(track_design_save_callback);
Intent * intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_4, LOADSAVETYPE_SAVE | LOADSAVETYPE_TRACK);
intent_set_string(intent, INTENT_EXTRA_6, track_name);
intent_set_pointer(intent, INTENT_EXTRA_6, track_design_save_callback);
context_open_intent(intent);
intent_release(intent);
return true;
}

View File

@@ -290,7 +290,10 @@ void window_editor_bottom_toolbar_jump_forward_to_save_scenario()
}
window_close_all();
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, gS6Info.name);
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO);
intent.putExtra(INTENT_EXTRA_5, gS6Info.name);
context_open_intent(&intent);
}
/**

View File

@@ -804,13 +804,18 @@ static void window_editor_object_selection_mouseup(rct_window *w, rct_widgetinde
break;
case WIDX_INSTALL_TRACK:
if (w->selected_list_item != -1) {
{
if (w->selected_list_item != -1)
{
w->selected_list_item = -1;
}
window_invalidate(w);
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK, nullptr);
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK);
context_open_intent(&intent);
break;
}
case WIDX_FILTER_STRING_BUTTON:
//window_text_input_open(w, widgetIndex, STR_OBJECT_SEARCH, STR_OBJECT_SEARCH_DESC, STR_STRING, (uint32)_filter_string, 40);
window_start_textbox(w, widgetIndex, STR_STRING, _filter_string, 40);

View File

@@ -13,9 +13,9 @@ Intent::putExtra(uint32 key, uint32 value)
return this;
}
Intent *
Intent::putExtra(uint32 key, uintptr_t value)
Intent::putExtra(uint32 key, void * value)
{
_Pointers.insert(std::make_pair(key, value));
_Pointers.insert(std::make_pair(key, (uintptr_t) value));
return this;
}
@@ -74,5 +74,20 @@ extern "C" {
{
intent->putExtra(key, value);
}
void intent_set_string(Intent *intent, uint32 key, utf8string value)
{
intent->putExtra(key, value);
}
void intent_set_pointer(Intent *intent, uint32 key, void *value)
{
intent->putExtra(key, value);
}
void intent_set_uint(Intent *intent, uint32 key, uint32 value)
{
intent->putExtra(key, value);
}
}

View File

@@ -31,7 +31,7 @@ public:
uint32 GetUIntExtra(uint32 key);
sint32 GetSIntExtra(uint32 key);
Intent * putExtra(uint32 key, uint32 value);
Intent * putExtra(uint32 key, uintptr_t value);
Intent * putExtra(uint32 key, void * value);
Intent * putExtra(uint32 key, sint32 value);
Intent * putExtra(uint32 key, utf8string value);
};
@@ -52,12 +52,18 @@ extern "C" {
INTENT_EXTRA_2,
INTENT_EXTRA_3,
INTENT_EXTRA_4,
INTENT_EXTRA_5,
INTENT_EXTRA_6,
INTENT_EXTRA_7,
};
Intent *intent_create(rct_windowclass clss);
void intent_release(Intent * intent);
void intent_set_string(Intent *, uint32 key, utf8string value);
void intent_set_pointer(Intent *, uint32 key, uintptr_t value);
void intent_set_pointer(Intent *, uint32 key, void * value);
void intent_set_sint(Intent *, uint32 key, sint32 value);
void intent_set_uint(Intent *, uint32 key, uint32 value);
#ifdef __cplusplus

View File

@@ -472,7 +472,7 @@ void window_staff_overview_mouseup(rct_window *w, rct_widgetindex widgetIndex)
case WIDX_FIRE:
{
auto intent = Intent(WC_FIRE_PROMPT);
intent.putExtra(INTENT_EXTRA_3, (uintptr_t) peep);
intent.putExtra(INTENT_EXTRA_3, peep);
context_open_intent(&intent);
break;
}

View File

@@ -543,8 +543,12 @@ static void window_top_toolbar_dropdown(rct_window *w, rct_widgetindex widgetInd
switch (dropdownIndex) {
case DDIDX_NEW_GAME:
window_scenarioselect_open(window_top_toolbar_scenarioselect_callback);
{
auto intent = Intent(WC_SCENARIO_SELECT);
intent.putExtra(INTENT_EXTRA_7, (void *) window_top_toolbar_scenarioselect_callback);
context_open_intent(&intent);
break;
}
case DDIDX_LOAD_GAME:
game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 0, 0);
break;
@@ -554,7 +558,10 @@ static void window_top_toolbar_dropdown(rct_window *w, rct_widgetindex widgetInd
break;
case DDIDX_SAVE_GAME_AS:
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) {
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, gS6Info.name);
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_4, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
intent.putExtra(INTENT_EXTRA_5, gS6Info.name);
context_open_intent(&intent);
}
else {
tool_cancel();