static void shortcut_close_all_floating_windows()
{
	if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR))
		window_close_all();
	else if (RCT2_GLOBAL(0x0141F570, uint8) == 1)
		window_close_top();
}
/**
*
*  rct2: 0x0066F62C
*/
void window_editor_bottom_toolbar_jump_back_to_landscape_editor() {
	window_close_all();
	sub_6DFED0();
	scenery_set_default_placement_configuration();
	g_editor_step = EDITOR_STEP_LANDSCAPE_EDITOR;
	window_map_open();
	gfx_invalidate_screen();
}
/**
 * 
 *  rct2: 0x006AB0B6
 */
static void window_editor_object_selection_scroll_mousedown()
{
	short x, y, scrollIndex;
	rct_window *w;

	window_scrollmouse_get_registers(w, scrollIndex, x, y);

	// Used for in-game object selection cheat to prevent crashing the game
	// when windows attempt to draw objects that don't exist any more
	window_close_all_except_class(WC_EDITOR_OBJECT_SELECTION);

	uint8 object_selection_flags;
	rct_object_entry* installed_entry;
	int selected_object = get_object_from_object_selection((w->selected_tab & 0xFF), y, &object_selection_flags, &installed_entry);
	if (selected_object == -1 || (object_selection_flags & 0x20))
		return;

	window_invalidate(w);

	sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0);


	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
		if (!window_editor_object_selection_select_object(1, installed_entry))
			return;

		// Close any other open windows such as options/colour schemes to prevent a crash.
		window_close_all();
		//window_close(w);

		//This function calls window_track_list_open
		window_editor_object_selection_manage_tracks();
		return;
	}

	int ebx = 6;
	// If already selected
	if (!(object_selection_flags & 1))
		ebx = 7;

	RCT2_GLOBAL(0xF43411, uint8) = 0;
	if (!window_editor_object_selection_select_object(ebx, installed_entry)) {
		rct_string_id error_title = ebx & 1 ?
			STR_UNABLE_TO_SELECT_THIS_OBJECT :
			STR_UNABLE_TO_DE_SELECT_THIS_OBJECT;

		window_error_open(error_title, RCT2_GLOBAL(0x141E9AC, uint16));
		return;
	}

	if (!RCT2_GLOBAL(0xF43411, uint8) & 1)
		return;

	window_error_open(STR_WARNING_TOO_MANY_OBJECTS_SELECTED, STR_NOT_ALL_OBJECTS_IN_THIS_SCENERY_GROUP_COULD_BE_SELECTED);
}
/**
*
*  rct2: 0x0066F758
*/
void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() {
	if (editor_check_park()) {
		window_close_all();
		window_editor_inventions_list_open();
		g_editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP;
	} else {
		window_error_open(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16));
	}

	gfx_invalidate_screen();
}
/**
 *
 *  rct2: 0x0066F7C0
 */
void window_editor_bottom_toolbar_jump_forward_to_save_scenario()
{
    if (!scenario_prepare_for_save()) {
        window_error_open(STR_UNABLE_TO_SAVE_SCENARIO_FILE, gGameCommandErrorText);
        gfx_invalidate_screen();
        return;
    }

    window_close_all();
    window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, gS6Info.name);
}
/**
*
*  rct2: 0x0066F758
*/
void window_editor_bottom_toolbar_jump_forward_to_invention_list_set_up() {
    if (editor_check_park()) {
        window_close_all();
        window_editor_inventions_list_open();
        gS6Info.editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP;
    } else {
        window_error_open(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, gGameCommandErrorText);
    }

    gfx_invalidate_screen();
}
/**
 *
 *  rct2: 0x0066F7C0
 */
void window_editor_bottom_toolbar_jump_forward_to_save_scenario()
{
	rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;

	if (!scenario_prepare_for_save()) {
		window_error_open(STR_UNABLE_TO_SAVE_SCENARIO_FILE, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id));
		gfx_invalidate_screen();
		return;
	}

	window_close_all();
	window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, s6Info->name);
}
/**
 *
 *  rct2: 0x0066F7C0
 */
void window_editor_bottom_toolbar_jump_forward_to_save_scenario()
{
	rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;
	int parkFlagsBackup, success;
	char path[256];

	if (!scenario_prepare_for_save()) {
		window_error_open(STR_UNABLE_TO_SAVE_SCENARIO_FILE, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id));
		gfx_invalidate_screen();
		return;
	}

	window_close_all();

	window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, s6Info->name);
	return;

	if (!show_save_scenario_dialog(path)) {
		gfx_invalidate_screen();
		return;
	}

	//
	s6Info->editor_step = 255;

	// Ensure path has .SC6 extension
	path_set_extension(path, ".SC6");

	// Save the scenario
	parkFlagsBackup = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32);
	RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_18;
	SDL_RWops* rw = SDL_RWFromFile(path, "wb+");
	if (rw != NULL) {
		success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 3 : 2);
		SDL_RWclose(rw);
	}
	RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = parkFlagsBackup;

	if (success) {
		title_load();
	} else {
		window_error_open(STR_SCENARIO_SAVE_FAILED, -1);
		s6Info->editor_step = EDITOR_STEP_OBJECTIVE_SELECTION;
	}
}
/**
*
*  rct2: 0x0066f7a8
*/
void window_editor_bottom_toolbar_jump_forward_to_objective_selection() {
	window_close_all();
	window_editor_objective_options_open();
	g_editor_step = EDITOR_STEP_OBJECTIVE_SELECTION;
	gfx_invalidate_screen();
}
/**
*
*  rct2: 0x0066F64E
*/
void window_editor_bottom_toolbar_jump_back_to_options_selection() {
	window_close_all();
	window_editor_scenario_options_open();
	g_editor_step = EDITOR_STEP_OPTIONS_SELECTION;
	gfx_invalidate_screen();
}
/**
*
*  rct2: 0x0066F64E
*/
void window_editor_bottom_toolbar_jump_back_to_invention_list_set_up() {
	window_close_all();
	window_editor_inventions_list_open();
	g_editor_step = EDITOR_STEP_INVENTIONS_LIST_SET_UP;
	gfx_invalidate_screen();
}
/**
*
*  rct2: 0x0066F619
*/
void window_editor_bottom_toolbar_jump_back_to_object_selection() {
	window_close_all();
	g_editor_step = EDITOR_STEP_OBJECT_SELECTION;
	gfx_invalidate_screen();
}
Exemple #13
0
void handle_shortcut_command(int shortcutIndex)
{
	rct_window *window;

	switch (shortcutIndex) {
	case SHORTCUT_CLOSE_TOP_MOST_WINDOW:
		window_close_top();
		break;
	case SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2))
			window_close_all();
		else if (RCT2_GLOBAL(0x0141F570, uint8) == 1)
			window_close_top();
		break;
	case SHORTCUT_CANCEL_CONSTRUCTION_MODE:
		window = window_find_by_id(WC_ERROR, 0);
		if (window != NULL)
			window_close(window);
		else if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))
			tool_cancel();
		break;
	case SHORTCUT_PAUSE_GAME:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 10)) {
			window = window_find_by_id(WC_TOP_TOOLBAR, 0);
			if (window != NULL) {
				window_invalidate(window);
				window_event_helper(window, 0, WE_MOUSE_UP);
			}
		}
		break;
	case SHORTCUT_ZOOM_VIEW_OUT:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 2, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_ZOOM_VIEW_IN:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 3, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_ROTATE_VIEW:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 4, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_ROTATE_CONSTRUCTION_OBJECT:
		RCT2_CALLPROC_EBPSAFE(0x006E4182);
		break;
	case SHORTCUT_UNDERGROUND_VIEW_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 0, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_REMOVE_BASE_LAND_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 1, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 2, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_SEE_THROUGH_RIDES_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 4, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 5, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 6, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_INVISIBLE_PEOPLE_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 7, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 9, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 10, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE:
		RCT2_CALLPROC_X(0x0066CF8A, 11, 0, 0, 0, 0, 0, 0);
		break;
	case SHORTCUT_ADJUST_LAND:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 7, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_ADJUST_WATER:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 8, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_BUILD_SCENERY:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 9, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_BUILD_PATHS:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 10, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_BUILD_NEW_RIDE:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 11, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_SHOW_FINANCIAL_INFORMATION:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C))
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800))
				RCT2_CALLPROC_EBPSAFE(0x0069DDF1);
		break;
	case SHORTCUT_SHOW_RESEARCH_INFORMATION:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
			// Open new ride window
			RCT2_CALLPROC_EBPSAFE(0x006B3CFF);
			window = window_find_by_id(WC_CONSTRUCT_RIDE, 0);
			if (window != NULL)
				window_event_helper(window, 10, WE_MOUSE_DOWN);
		}
		break;
	case SHORTCUT_SHOW_RIDES_LIST:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
			window = window_find_by_id(WC_TOP_TOOLBAR, 0);
			if (window != NULL) {
				window_invalidate(window);
				window_event_helper(window, 12, WE_MOUSE_UP);
			}
		}
		break;
	case SHORTCUT_SHOW_PARK_INFORMATION:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
			window = window_find_by_id(WC_TOP_TOOLBAR, 0);
			if (window != NULL) {
				window_invalidate(window);
				window_event_helper(window, 13, WE_MOUSE_UP);
			}
		}
		break;
	case SHORTCUT_SHOW_GUEST_LIST:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
			window = window_find_by_id(WC_TOP_TOOLBAR, 0);
			if (window != NULL) {
				window_invalidate(window);
				window_event_helper(window, 15, WE_MOUSE_UP);
			}
		}
		break;
	case SHORTCUT_SHOW_STAFF_LIST:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
		  window = window_find_by_id(WC_TOP_TOOLBAR, 0);
			if (window != NULL) {
				window_invalidate(window);
				window_event_helper(window, 14, WE_MOUSE_UP);
			}
		}
		break;
	case SHORTCUT_SHOW_RECENT_MESSAGES:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E))
			window_news_open();
		break;
	case SHORTCUT_SHOW_MAP:
		if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
			if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
				window = window_find_by_id(WC_TOP_TOOLBAR, 0);
				if (window != NULL) {
					window_invalidate(window);
					window_event_helper(window, 6, WE_MOUSE_UP);
				}
			}
		}
		break;
	case SHORTCUT_SCREENSHOT:
		RCT2_CALLPROC_EBPSAFE(0x006E4034); // set screenshot countdown to 2
		break;
	}
}