/**
 *
 *  rct2: 0x006781B5
 */
void window_scenarioselect_open()
{
	rct_window* window;

	if (window_bring_to_front_by_class(WC_SCENARIO_SELECT) != NULL)
		return;

	// Load scenario list
	scenario_load_list();

	window = window_create_centred(
		610,
		334,
		&window_scenarioselect_events,
		WC_SCENARIO_SELECT,
		WF_10
	);
	window->widgets = window_scenarioselect_widgets;

	window->enabled_widgets = 0x04 | 0x10 | 0x20 | 0x40 | 0x80 | 0x100;
	window_init_scroll_widgets(window);
	window->viewport_focus_coordinates.var_480 = -1;
	window->var_494 = 0;

	window_scenarioselect_init_tabs();

	window->selected_tab = 0;
}
Exemple #2
0
rct_window *window_changelog_open()
{
	rct_window* window;

	window = window_bring_to_front_by_class(WC_CHANGELOG);
	if (window != NULL)
		return window;

	if (!window_changelog_read_file())
		return NULL;

	sint32 screenWidth = gScreenWidth;
	sint32 screenHeight = gScreenHeight;

	window = window_create_centred(
		screenWidth * 4 / 5,
		screenHeight * 4 / 5,
		&window_changelog_events,
		WC_CHANGELOG,
		WF_RESIZABLE
	);
	window->widgets = window_changelog_widgets;
	window->enabled_widgets = (1 << WIDX_CLOSE);

	window_init_scroll_widgets(window);
	window->min_width = MIN_WW;
	window->min_height = MIN_WH;
	window->max_width = MIN_WW;
	window->max_height = MIN_WH;
	return window;
}
Exemple #3
0
rct_window *window_changelog_open()
{
	rct_window* window;

	window = window_bring_to_front_by_class(WC_CHANGELOG);
	if (window != NULL)
		return window;

	if (!window_changelog_read_file())
		return NULL;

	int screenWidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
	int screenHeight = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);

	window = window_create_centred(
		screenWidth * 4 / 5,
		screenHeight * 4 / 5,
		&window_changelog_events,
		WC_CHANGELOG,
		WF_RESIZABLE
	);
	window->widgets = window_changelog_widgets;
	window->enabled_widgets = (1 << WIDX_CLOSE);

	window_init_scroll_widgets(window);
	window->min_width = MIN_WW;
	window->min_height = MIN_WH;
	window->max_width = MIN_WW;
	window->max_height = MIN_WH;
	return window;
}
Exemple #4
0
rct_window * window_news_options_open()
{
    rct_window* window;

    // Check if window is already open
    window = window_bring_to_front_by_class(WC_NOTIFICATION_OPTIONS);
    if (window == nullptr) {
        window = window_create_centred(
            400,
            300,
            &window_news_options_events,
            WC_NOTIFICATION_OPTIONS,
            0
        );
        window->widgets = window_news_options_widgets;
        window->enabled_widgets =
            (1 << WIDX_CLOSE) |
            (1 << WIDX_TAB_PARK) |
            (1 << WIDX_TAB_RIDE) |
            (1 << WIDX_TAB_GUEST);
        window_init_scroll_widgets(window);
        window->colours[0] = COLOUR_GREY;
        window->colours[1] = COLOUR_LIGHT_BLUE;
        window->colours[2] = COLOUR_LIGHT_BLUE;
    }

    return window;
}
Exemple #5
0
void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, int maxLength)
{
	_maxInputLength = maxLength;

	window_close_by_class(WC_TEXTINPUT);

	// Clear the text input buffer
	memset(text_input, 0, maxLength);

	// Enter in the the text input buffer any existing
	// text.
	if (existing_text != NULL)
		safe_strcpy(text_input, existing_text, maxLength);

	// In order to prevent strings that exceed the maxLength
	// from crashing the game.
	text_input[maxLength - 1] = '\0';

	// This is the text displayed above the input box
	input_text_description = description;

	// Work out the existing size of the window
	char wrapped_string[512];
	safe_strcpy(wrapped_string, text_input, 512);

	int no_lines = 0, font_height = 0;

	// String length needs to add 12 either side of box
	// +13 for cursor when max length.
	gfx_wrap_string(wrapped_string, WW - (24 + 13), &no_lines, &font_height);

	int height = no_lines * 10 + WH;

	// Window will be in the center of the screen
	rct_window* w = window_create_centred(
		WW,
		height,
		&window_text_input_events,
		WC_TEXTINPUT,
		WF_STICK_TO_FRONT
		);

	w->widgets = window_text_input_widgets;
	w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_OKAY);

	window_text_input_widgets[WIDX_TITLE].image = title;

	// Save calling window details so that the information
	// can be passed back to the correct window & widget
	calling_class = call_w->classification;
	calling_number = call_w->number;
	calling_widget = call_widget;

	platform_start_text_input(text_input, maxLength);

	window_init_scroll_widgets(w);
	w->colours[0] = call_w->colours[0];
	w->colours[1] = call_w->colours[1];
	w->colours[2] = call_w->colours[2];
}
Exemple #6
0
rct_window * custom_currency_window_open()
{
    rct_window* window;

    // Check if window is already open
    window = window_bring_to_front_by_class(WC_CUSTOM_CURRENCY_CONFIG);
    if(window != nullptr)
        return window;

    window = window_create_centred(
        400,
        100,
        &_windowCustomCurrencyEvents,
        WC_CUSTOM_CURRENCY_CONFIG,
        0
    );
    window->widgets = window_custom_currency_widgets;
    window->enabled_widgets =
        (1 << WIDX_CLOSE) |
        (1 << WIDX_RATE) |
        (1 << WIDX_RATE_UP) |
        (1 << WIDX_RATE_DOWN) |
        (1 << WIDX_SYMBOL_TEXT) |
        (1 << WIDX_AFFIX_DROPDOWN) |
        (1 << WIDX_AFFIX_DROPDOWN_BUTTON);

    window->hold_down_widgets = (1 << WIDX_RATE_UP) | (1 << WIDX_RATE_DOWN);
    window_init_scroll_widgets(window);
    window->colours[0] = COLOUR_LIGHT_BROWN;
    window->colours[1] = COLOUR_LIGHT_BROWN;
    window->colours[2] = COLOUR_LIGHT_BROWN;

    return window;
}
Exemple #7
0
rct_window *window_mapgen_open()
{
	rct_window *w;

	w = window_bring_to_front_by_class(WC_MAPGEN);
	if (w == NULL) {
		w = window_create_centred(
			300,
			200,
			window_mapgen_page_events[0],
			WC_MAPGEN,
			WF_10
		);
		w->number = 0;
		w->frame_no = 0;
	}

	w->page = WINDOW_MAPGEN_PAGE_BASE;
	window_invalidate(w);
	w->widgets = window_mapgen_page_widgets[WINDOW_MAPGEN_PAGE_BASE];
	w->enabled_widgets = window_mapgen_page_enabled_widgets[WINDOW_MAPGEN_PAGE_BASE];
	w->hold_down_widgets = window_mapgen_page_hold_down_widgets[WINDOW_MAPGEN_PAGE_BASE];
	w->event_handlers = window_mapgen_page_events[WINDOW_MAPGEN_PAGE_BASE];
	w->pressed_widgets = 0;
	w->disabled_widgets = 0;
	window_init_scroll_widgets(w);

	return w;
}
/**
 *
 *  rct2: 0x00684E04
 */
rct_window* window_editor_inventions_list_open()
{
    rct_window* w;

    w = window_bring_to_front_by_class(WC_EDITOR_INVENTION_LIST);
    if (w != nullptr)
        return w;

    research_rides_setup();

    w = window_create_centred(
        WW, WH, &window_editor_inventions_list_events, WC_EDITOR_INVENTION_LIST, WF_NO_SCROLLING | WF_RESIZABLE);
    w->widgets = window_editor_inventions_list_widgets;
    w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_RESIZE) | (1 << WIDX_TAB_1) | (1 << WIDX_RANDOM_SHUFFLE)
        | (1 << WIDX_MOVE_ITEMS_TO_BOTTOM) | (1 << WIDX_MOVE_ITEMS_TO_TOP);
    window_init_scroll_widgets(w);
    w->var_4AE = 0;
    w->selected_tab = 0;
    w->research_item = nullptr;
    _editorInventionsListDraggedItem = nullptr;

    w->min_width = WW;
    w->min_height = WH;
    w->max_width = WW * 2;
    w->max_height = WH * 2;

    return w;
}
rct_window * window_ride_refurbish_prompt_open(sint32 rideIndex)
{
    rct_window *w;

    w = window_find_by_class(WC_DEMOLISH_RIDE_PROMPT);
    if (w != nullptr)
    {
        int x = w->x;
        int y = w->y;
        window_close(w);
        w = window_create(x, y, WW, WH, &window_ride_refurbish_events, WC_DEMOLISH_RIDE_PROMPT, WF_TRANSPARENT);
    }
    else
    {
        w = window_create_centred(WW, WH, &window_ride_refurbish_events, WC_DEMOLISH_RIDE_PROMPT, WF_TRANSPARENT);
    }

    w->widgets = window_ride_refurbish_widgets;
    w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_REFURBISH);
    window_init_scroll_widgets(w);
    w->number = rideIndex;
    _demolishRideCost = -ride_get_refund_price(rideIndex);

    return w;
}
Exemple #10
0
/**
*
*  rct2: 0x0066D55B
*/
void window_music_credits_open()
{
	rct_window* window;

	// Check if window is already open
	window = window_bring_to_front_by_class(WC_MUSIC_CREDITS);
	if (window != NULL)
		return;

	window = window_create_centred(
		510,
		314,
		&window_music_credits_events,
		WC_MUSIC_CREDITS,
		0
	);

	window->widgets = window_music_credits_widgets;
	window->enabled_widgets = 1 << WIDX_CLOSE;

	window_init_scroll_widgets(window);
	window->colours[0] = COLOUR_LIGHT_BLUE;
	window->colours[1] = COLOUR_LIGHT_BLUE;
	window->colours[2] = COLOUR_LIGHT_BLUE;

}
Exemple #11
0
void window_network_status_open(const char* text)
{
	rct_window* window;

	safe_strncpy(window_network_status_text, text, sizeof(window_network_status_text));

	// Check if window is already open
	window = window_bring_to_front_by_class(WC_NETWORK_STATUS);
	if (window != NULL)
		return;

	window = window_create_centred(320, 90, &window_network_status_events, WC_NETWORK_STATUS, WF_10 | WF_TRANSPARENT);

	window->widgets = window_network_status_widgets;
	window->enabled_widgets = 1 << WIDX_CLOSE;
	window_init_scroll_widgets(window);
	window->no_list_items = 0;
	window->selected_list_item = -1;
	window->frame_no = 0;
	window->min_width = 320;
	window->min_height = 90;
	window->max_width = window->min_width;
	window->max_height = window->min_height;

	window->page = 0;
	window->list_information_type = 0;
	window->colours[0] = 7;
	window->colours[1] = 7;
	window->colours[2] = 7;
}
rct_window * window_shortcut_change_open(sint32 selected_key)
{
    // Move this to window_shortcut_change_open
    window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
    // Save the item we are selecting for new window
    gKeyboardShortcutChangeId = selected_key;
    rct_window * w = window_create_centred(WW, WH, &window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0);

    w->widgets = window_shortcut_change_widgets;
    w->enabled_widgets = (1ULL << WIDX_CLOSE);
    window_init_scroll_widgets(w);
    return w;
}
/** Based off of rct2: 0x006B486A */
void window_ride_demolish_prompt_open(int rideIndex){
	rct_window *w;

	w = window_bring_to_front_by_number(WC_DEMOLISH_RIDE_PROMPT, rideIndex);
	if (w != NULL)
		return;

	w = window_create_centred(WW, WH, (uint32*)window_ride_demolish_events, WC_DEMOLISH_RIDE_PROMPT, WF_TRANSPARENT);
	w->widgets = window_ride_demolish_widgets;
	w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_DEMOLISH);
	window_init_scroll_widgets(w);
	w->number = rideIndex;
}
/** Based off of rct2: 0x6C0A77 */
void window_staff_fire_prompt_open(rct_peep* peep){
	// Check if the confirm window already exists.
	if (window_bring_to_front_by_number(WC_FIRE_PROMPT, peep->sprite_index)) {
		return;
	}

	rct_window* w = window_create_centred(WW, WH, (uint32*)0x992C3C, 0x1A, WF_TRANSPARENT);
	w->widgets = window_staff_fire_widgets;
	w->enabled_widgets |= (1 << WIDX_CLOSE) | (1 << WIDX_YES) | (1 << WIDX_CANCEL);

	window_init_scroll_widgets(w);

	colour_scheme_update(w);

	w->number = peep->sprite_index;
}
Exemple #15
0
static rct_window *window_overwrite_prompt_open(const char *name, const char *path)
{
	rct_window *w;

	window_close_by_class(WC_LOADSAVE_OVERWRITE_PROMPT);

	w = window_create_centred(OVERWRITE_WW, OVERWRITE_WH, &window_overwrite_prompt_events, WC_LOADSAVE_OVERWRITE_PROMPT, WF_STICK_TO_FRONT);
	w->widgets = window_overwrite_prompt_widgets;
	w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_OVERWRITE_CANCEL) | (1 << WIDX_OVERWRITE_OVERWRITE);
	window_init_scroll_widgets(w);
	w->flags |= WF_TRANSPARENT;
	w->colours[0] = 154;

	safe_strcpy(_window_overwrite_prompt_name, name, sizeof(_window_overwrite_prompt_name));
	safe_strcpy(_window_overwrite_prompt_path, path, sizeof(_window_overwrite_prompt_path));

	return w;
}
/**
 *
 *  rct2: 0x006AA64E
 */
void window_editor_object_selection_open()
{
	rct_window* window;

	window = window_bring_to_front_by_class(WC_EDITOR_OBJECT_SELECTION);
	if (window != NULL)
		return;

	RCT2_CALLPROC_EBPSAFE(0x006AB211);
	RCT2_CALLPROC_EBPSAFE(0x006AA770);

	// Not really where its called, but easy way to change default objects for now
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR)
		window_editor_object_selection_select_default_objects();

	window = window_create_centred(
		600,
		400,
		(uint32*)window_editor_object_selection_events,
		WC_EDITOR_OBJECT_SELECTION,
		WF_10
	);
	window->widgets = window_editor_object_selection_widgets;

	window->enabled_widgets =
		(1 << WIDX_DROPDOWN1) |
		(1 << WIDX_DROPDOWN2) |
		(1 << WIDX_FILTER_DROPDOWN) |
		(1 << WIDX_FILTER_STRING_BUTTON) |
		(1 << WIDX_FILTER_CLEAR_BUTTON) |
		(1 << WIDX_CLOSE);

	_filter_flags = FILTER_ALL;
	memset(_filter_string, 0, sizeof(_filter_string));

	for (int i = WIDX_TAB_1; i <= WIDX_TAB_11; i++)
		window->enabled_widgets |= (1LL << i);
	window_init_scroll_widgets(window);

	window->var_4AE = 0;
	window->selected_tab = 0;
	window->selected_list_item = -1;
	window->var_494 = 0xFFFFFFFF;
}
/**
 *
 *  rct2: 0x006781B5
 */
void window_scenarioselect_open(scenarioselect_callback callback)
{
	rct_window* window;
	int windowWidth;
	int windowHeight = 334;

	_callback = callback;

	if (window_bring_to_front_by_class(WC_SCENARIO_SELECT) != NULL)
		return;

	// Load scenario list
	scenario_repository_scan();

	// Shrink the window if we're showing scenarios by difficulty level.
	if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_DIFFICULTY) {
		windowWidth = 610;
	} else {
		windowWidth = 733;
	}

	window = window_create_centred(
		windowWidth,
		windowHeight,
		&window_scenarioselect_events,
		WC_SCENARIO_SELECT,
		WF_10
	);
	window->widgets = window_scenarioselect_widgets;
	window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2)
							| (1 << WIDX_TAB3) | (1 << WIDX_TAB4) | (1 << WIDX_TAB5)
							| (1 << WIDX_TAB6) | (1 << WIDX_TAB7) | (1 << WIDX_TAB8);

	window_scenarioselect_init_tabs(window);
	initialise_list_items(window);

	window_init_scroll_widgets(window);
	window->viewport_focus_coordinates.var_480 = -1;
	window->highlighted_scenario = NULL;
}
/**
 *
 *  rct2: 0x00670138
 */
void window_editor_scenario_options_open()
{
	rct_window *w;

	w = window_bring_to_front_by_class(WC_EDITOR_SCENARIO_OPTIONS);
	if (w != NULL)
		return;

	w = window_create_centred(
		280,
		148,
		window_editor_scenario_options_page_events[0],
		WC_EDITOR_SCENARIO_OPTIONS,
		WF_NO_SCROLLING
	);
	w->widgets = window_editor_scenario_options_widgets[0];
	w->enabled_widgets = window_editor_scenario_options_page_enabled_widgets[0];
	w->hold_down_widgets = window_editor_scenario_options_page_hold_down_widgets[0];
	window_init_scroll_widgets(w);
	w->var_4AE = 0;
	w->page = 0;
}
Exemple #19
0
/**
 *
 *  rct2: 0x0066D2AC
 */
static void _window_about_open()
{
    rct_window* window;

    // Check if window is already open
    window = window_bring_to_front_by_class(WC_ABOUT);
    if (window != NULL)
        return;

    window = window_create_centred(
        WW,
        WH,
        window_about_page_events[WINDOW_ABOUT_PAGE_OPENRCT2],
        WC_ABOUT,
        0
    );

    window_about_set_page(window, WINDOW_ABOUT_PAGE_OPENRCT2);

    window_init_scroll_widgets(window);
    window->colours[0] = COLOUR_GREY;
    window->colours[1] = COLOUR_LIGHT_BLUE;
    window->colours[2] = COLOUR_LIGHT_BLUE;
}
Exemple #20
0
/**
 * 
 *  rct2: 0x0066D2AC
 */
void window_about_open()
{
	rct_window* window;

	// Check if window is already open
	window = window_bring_to_front_by_class(WC_ABOUT);
	if (window != NULL)
		return;

	window = window_create_centred(
		400,
		330,
		(uint32*)window_about_events,
		WC_ABOUT,
		0
	);
	window->widgets = window_about_widgets;
	window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_MUSIC_CREDITS) | (1 << WIDX_PUBLISHER_CREDITS);

	window_init_scroll_widgets(window);
	window->colours[0] = 7;
	window->colours[1] = 7;
	window->colours[2] = 7;
}
Exemple #21
0
rct_window *window_loadsave_open(int type, char *defaultName)
{
	gLoadSaveCallback = NULL;
	gLoadSaveTitleSequenceSave = false;
	char path[MAX_PATH], *ch;
	int includeNewItem;
	rct_window* w;
	_type = type;
	_defaultName[0] = '\0';

	if (!str_is_null_or_empty(defaultName)) {
		safe_strcpy(_defaultName, defaultName, sizeof(_defaultName));
	}

	w = window_bring_to_front_by_class(WC_LOADSAVE);
	if (w == NULL) {
		w = window_create_centred(WW, WH, &window_loadsave_events, WC_LOADSAVE, WF_STICK_TO_FRONT);
		w->widgets = window_loadsave_widgets;
		w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_UP) | (1 << WIDX_NEW) | (1 << WIDX_SORT_NAME) | (1 << WIDX_SORT_DATE) | (1 << WIDX_BROWSE);
		w->colours[0] = 7;
		w->colours[1] = 7;
		w->colours[2] = 7;
	}

	_loadsaveType = type;
	switch (type & 0x0F) {
	case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME):
		w->widgets[WIDX_TITLE].image = STR_FILE_DIALOG_TITLE_LOAD_GAME;
		break;
	case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME) :
		w->widgets[WIDX_TITLE].image = STR_FILE_DIALOG_TITLE_SAVE_GAME;
		break;
	case (LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE) :
		w->widgets[WIDX_TITLE].image = STR_FILE_DIALOG_TITLE_LOAD_LANDSCAPE;
		break;
	case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE) :
		w->widgets[WIDX_TITLE].image = STR_FILE_DIALOG_TITLE_SAVE_LANDSCAPE;
		break;
	case (LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO) :
		w->widgets[WIDX_TITLE].image = STR_FILE_DIALOG_TITLE_SAVE_SCENARIO;
		break;
	case (LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK) :
		w->widgets[WIDX_TITLE].image = STR_FILE_DIALOG_TITLE_INSTALL_NEW_TRACK_DESIGN;
		break;
	default:
		log_error("Unsupported load / save type: %d", type & 0x0F);
		return NULL;
	}

	w->no_list_items = 0;
	w->selected_list_item = -1;

	includeNewItem = (type & 0x01) == LOADSAVETYPE_SAVE;
	switch (type & 0x0E) {
	case LOADSAVETYPE_GAME:
		platform_get_user_directory(path, "save");
		if (!platform_ensure_directory_exists(path)) {
			log_error("Unable to create save directory.");
			window_close(w);
			return NULL;
		}

		window_loadsave_populate_list(w, includeNewItem, path, ".sv6");
		break;
	case LOADSAVETYPE_LANDSCAPE:
		platform_get_user_directory(path, "landscape");
		if (!platform_ensure_directory_exists(path)) {
			log_error("Unable to create landscapes directory.");
			window_close(w);
			return NULL;
		}

		window_loadsave_populate_list(w, includeNewItem, path, ".sc6");
		break;
	case LOADSAVETYPE_SCENARIO:
		platform_get_user_directory(path, "scenario");
		if (!platform_ensure_directory_exists(path)) {
			log_error("Unable to create scenarios directory.");
			window_close(w);
			return NULL;
		}

		window_loadsave_populate_list(w, includeNewItem, path, ".sc6");
		break;
	case LOADSAVETYPE_TRACK:
		/*
		Uncomment when user tracks are separated

		platform_get_user_directory(path, "tracks");
		if (!platform_ensure_directory_exists(path)) {
		log_error("Unable to create tracks directory.");
		window_close(w);
		return NULL;
		}
		*/

		safe_strcpy(path, RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char), MAX_PATH);
		ch = strchr(path, '*');
		if (ch != NULL)
			*ch = 0;

		window_loadsave_populate_list(w, includeNewItem, path, ".td?");
		break;
	}
	w->no_list_items = _listItemsCount;
	window_init_scroll_widgets(w);
	return w;
}
Exemple #22
0
/**
 *
 *  rct2: 0x0066DCBE
 */
void window_save_prompt_open()
{
	int stringId, width, height;
	rct_window* window;
	unsigned short prompt_mode;
	rct_widget *widgets;
	uint64 enabled_widgets;

	prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16);
	if (prompt_mode == PM_QUIT)
		prompt_mode = PM_SAVE_BEFORE_QUIT;

	// do not show save prompt if we're in the title demo and click on load game
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) {
		game_load_or_quit_no_save_prompt();
		return;
	}

	if (!gConfigGeneral.confirmation_prompt) {
		/* game_load_or_quit_no_save_prompt() will exec requested task and close this window
		* immediately again.
		* TODO restructure these functions when we're sure game_load_or_quit_no_save_prompt()
		* and game_load_or_quit() are not called by the original binary anymore.
		*/

		if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) {
			if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) {
				RCT2_CALLPROC_EBPSAFE(0x0066EE54);
				game_load_or_quit_no_save_prompt();
				return;
			}
			else {
				tutorial_stop();
				game_load_or_quit_no_save_prompt();
				return;
			}
		}

		if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) < 3840) {
			game_load_or_quit_no_save_prompt();
			return;
		}
	}

	// Check if window is already open
	window = window_bring_to_front_by_class(WC_SAVE_PROMPT);
	if (window){
		window_close(window);
	}

	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) {
		widgets = window_quit_prompt_widgets;
		enabled_widgets =
			(1 << WQIDX_CLOSE) |
			(1 << WQIDX_OK) |
			(1 << WQIDX_CANCEL);
		width = 177;
		height = 34;
	} else {
		widgets = window_save_prompt_widgets;
		enabled_widgets =
			(1 << WIDX_CLOSE) |
			(1 << WIDX_SAVE) |
			(1 << WIDX_DONT_SAVE) |
			(1 << WIDX_CANCEL);
		width = 260;
		height = 50;
	}

	window = window_create_centred(
		width,
		height,
		&window_save_prompt_events,
		WC_SAVE_PROMPT,
		WF_TRANSPARENT | WF_STICK_TO_FRONT
	);

	window->widgets = widgets;
	window->enabled_widgets = enabled_widgets;
	window_init_scroll_widgets(window);

	// Pause the game
	RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) |= 2;
	audio_pause_sounds();
	window_invalidate_by_class(WC_TOP_TOOLBAR);

	stringId = prompt_mode + STR_LOAD_GAME_PROMPT_TITLE;
	if (stringId == STR_LOAD_GAME_PROMPT_TITLE && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
		stringId = STR_LOAD_LANDSCAPE_PROMPT_TITLE;
	if (stringId == STR_QUIT_GAME_PROMPT_TITLE && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
		stringId = STR_QUIT_SCENARIO_EDITOR;
	window_save_prompt_widgets[WIDX_TITLE].image = stringId;
	window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING;
}
Exemple #23
0
/**
 *
 *  rct2: 0x0066DCBE
 */
void window_save_prompt_open()
{
	sint32 width, height;
	rct_string_id stringId;
	rct_window* window;
	uint8 prompt_mode;
	rct_widget *widgets;
	uint64 enabled_widgets;

	prompt_mode = gSavePromptMode;
	if (prompt_mode == PM_QUIT)
		prompt_mode = PM_SAVE_BEFORE_QUIT;

	// do not show save prompt if we're in the title demo and click on load game
	if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) {
		game_load_or_quit_no_save_prompt();
		return;
	}

	if (!gConfigGeneral.confirmation_prompt) {
		/* game_load_or_quit_no_save_prompt() will exec requested task and close this window
		* immediately again.
		* TODO restructure these functions when we're sure game_load_or_quit_no_save_prompt()
		* and game_load_or_quit() are not called by the original binary anymore.
		*/

		if (gScreenAge < 3840) {
			game_load_or_quit_no_save_prompt();
			return;
		}
	}

	// Check if window is already open
	window = window_bring_to_front_by_class(WC_SAVE_PROMPT);
	if (window){
		window_close(window);
	}

	if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) {
		widgets = window_quit_prompt_widgets;
		enabled_widgets =
			(1 << WQIDX_CLOSE) |
			(1 << WQIDX_OK) |
			(1 << WQIDX_CANCEL);
		width = 177;
		height = 34;
	} else {
		widgets = window_save_prompt_widgets;
		enabled_widgets =
			(1 << WIDX_CLOSE) |
			(1 << WIDX_SAVE) |
			(1 << WIDX_DONT_SAVE) |
			(1 << WIDX_CANCEL);
		width = 260;
		height = 50;
	}

	if (prompt_mode >= countof(window_save_prompt_labels)) {
		log_warning("Invalid save prompt mode %u", prompt_mode);
		return;
	}
	window = window_create_centred(
		width,
		height,
		&window_save_prompt_events,
		WC_SAVE_PROMPT,
		WF_TRANSPARENT | WF_STICK_TO_FRONT
	);

	window->widgets = widgets;
	window->enabled_widgets = enabled_widgets;
	window_init_scroll_widgets(window);

	// Pause the game
	gGamePaused |= GAME_PAUSED_MODAL;
	audio_pause_sounds();
	window_invalidate_by_class(WC_TOP_TOOLBAR);

	stringId = window_save_prompt_labels[prompt_mode][0];
	if (stringId == STR_LOAD_GAME_PROMPT_TITLE && gScreenFlags & 2)
		stringId = STR_LOAD_LANDSCAPE_PROMPT_TITLE;
	if (stringId == STR_QUIT_GAME_PROMPT_TITLE && gScreenFlags & 2)
		stringId = STR_QUIT_SCENARIO_EDITOR;
	window_save_prompt_widgets[WIDX_TITLE].text = stringId;
	window_save_prompt_widgets[WIDX_LABEL].text = window_save_prompt_labels[prompt_mode][1];
}