Ejemplo n.º 1
0
/**
 *
 *  rct2: 0x0066DDF2
 */
static void window_save_prompt_mouseup(rct_window *w, sint32 widgetIndex)
{
	if (gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) {
		switch (widgetIndex) {
		case WQIDX_OK:
			game_load_or_quit_no_save_prompt();
			break;
		case WQIDX_CLOSE:
		case WQIDX_CANCEL:
			window_close(w);
			break;
		}
		return;
	} else {
		switch (widgetIndex) {
		case WIDX_SAVE:
			if (gScreenFlags & (SCREEN_FLAGS_EDITOR)) {
				window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, gS6Info.name);
			} else {
				save_game_as();
			}
			window_close(w);
			gLoadSaveCallback = window_save_prompt_callback;
			break;
		case WIDX_DONT_SAVE:
			game_load_or_quit_no_save_prompt();
			return;
		case WIDX_CLOSE:
		case WIDX_CANCEL:
			window_close(w);
			return;
		}
	}
}
Ejemplo n.º 2
0
/**
 *
 *  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);
}
static void shortcut_quick_save_game()
{
	// Do a quick save in playing mode and a regular save in Scenario Editor mode. In other cases, don't do anything.
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) == SCREEN_FLAGS_PLAYING) {
		tool_cancel();
		save_game();
	}
	else if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) {
		rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;
		window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, s6Info->name);
	}
}
Ejemplo n.º 4
0
/**
 *
 *  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;
	}
}
Ejemplo n.º 6
0
/**
 *
 *  rct2: 0x006D2804, 0x006D264D
 */
bool track_design_save(uint8 rideIndex)
{
    rct_ride* ride = get_ride(rideIndex);

    if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_TESTED)){
        window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText);
        return false;
    }

    if (!ride_has_ratings(ride)) {
        window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText);
        return false;
    }

    if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_TRACK)) {
        window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText);
        return false;
    }

    _trackDesign = track_design_save_to_td6(rideIndex);
    if (_trackDesign == NULL) {
        window_error_open(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText);
        return false;
    }

    if (gTrackDesignSaveMode) {
        if (!track_design_save_copy_scenery_to_td6(_trackDesign)) {
            free(_trackDesign->track_elements);
            free(_trackDesign->entrance_elements);
            free(_trackDesign);
            return false;
        }
    }

    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);

    return true;
}
Ejemplo n.º 7
0
static void window_title_editor_mouseup(rct_window *w, sint32 widgetIndex)
{
	bool commandEditorOpen = (window_find_by_class(WC_TITLE_COMMAND_EDITOR) != NULL);
	switch (widgetIndex) {
	case WIDX_TITLE_EDITOR_CLOSE:
		window_close(w);
		break;

	//////////////////////////////////////////////////////////////////////////////////////////////////////
	// Presets tab
	//////////////////////////////////////////////////////////////////////////////////////////////////////
	case WIDX_TITLE_EDITOR_NEW_BUTTON:
		if (!commandEditorOpen) {
			// TODO: This should probably be 'NEW'
			window_text_input_open(w, widgetIndex, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE, STR_NONE, 0, 64);
		}
		break;
	case WIDX_TITLE_EDITOR_DUPLICATE_BUTTON:
		if (!commandEditorOpen && _editingTitleSequence != NULL) {
			window_text_input_open(w, widgetIndex, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE, STR_STRING, (uintptr_t)_editingTitleSequence->Name, 64);
		}
		break;
	case WIDX_TITLE_EDITOR_DELETE_BUTTON:
		if (window_title_editor_check_can_edit()) {
			title_sequence_manager_delete(_selectedTitleSequence);
			window_title_editor_load_sequence(0);
		}
		break;
	case WIDX_TITLE_EDITOR_RENAME_SAVE_BUTTON:
		if (window_title_editor_check_can_edit() && _editingTitleSequence != NULL) {
			window_text_input_open(w, widgetIndex, STR_TRACK_MANAGE_RENAME, STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE, STR_STRING, (uintptr_t)_editingTitleSequence->Name, 64);
		}
		break;

	//////////////////////////////////////////////////////////////////////////////////////////////////////
	// Editor tab
	//////////////////////////////////////////////////////////////////////////////////////////////////////
	case WIDX_TITLE_EDITOR_ADD_SAVE:
		if (!_isSequenceReadOnly && !_isSequencePlaying && !commandEditorOpen) {
			window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, NULL);
			gLoadSaveCallback = window_title_editor_add_park_callback;
		}
		break;
	case WIDX_TITLE_EDITOR_REMOVE_SAVE:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item != -1) {
				TitleSequenceRemovePark(_editingTitleSequence, w->selected_list_item);
				if (w->selected_list_item >= (sint16)_editingTitleSequence->NumSaves) {
					w->selected_list_item--;
				}
			}
		}
		break;
	case WIDX_TITLE_EDITOR_RENAME_SAVE:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item != -1) {
				window_text_input_open(w, widgetIndex, STR_FILEBROWSER_RENAME_SAVE_TITLE, STR_TITLE_EDITOR_ENTER_NAME_FOR_SAVE, STR_STRING, (uintptr_t)_editingTitleSequence->Saves[w->selected_list_item], 52 - 1);
			}
		}
		break;
	case WIDX_TITLE_EDITOR_LOAD_SAVE:
		if (w->selected_list_item >= 0 && w->selected_list_item < (sint16)_editingTitleSequence->NumSaves) {
			TitleSequenceParkHandle * handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
			if (handle->IsScenario) {
				scenario_load_rw(handle->RWOps);
				scenario_begin();
			} else {
				game_load_sv6(handle->RWOps);
				game_load_init();
			}
			TitleSequenceCloseParkHandle(handle);
			window_title_editor_open(WINDOW_TITLE_EDITOR_TAB_SAVES);
		}
		break;

	//////////////////////////////////////////////////////////////////////////////////////////////////////
	// Commands tab
	//////////////////////////////////////////////////////////////////////////////////////////////////////
	case WIDX_TITLE_EDITOR_INSERT:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item != -1) {
				window_title_command_editor_open(_editingTitleSequence, w->selected_list_item + 1, true);
			} else {
				window_title_command_editor_open(_editingTitleSequence, (sint32)_editingTitleSequence->NumCommands, true);
			}
		}
		break;
	case WIDX_TITLE_EDITOR_EDIT:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item != -1 && w->selected_list_item < (sint16)_editingTitleSequence->NumCommands) {
				window_title_command_editor_open(_editingTitleSequence, w->selected_list_item, false);
			}
		}
		break;
	case WIDX_TITLE_EDITOR_DELETE:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item != -1 && w->selected_list_item < (sint16)_editingTitleSequence->NumCommands) {
				for (sint32 i = w->selected_list_item; i < (sint16)_editingTitleSequence->NumCommands - 1; i++) {
					_editingTitleSequence->Commands[i] = _editingTitleSequence->Commands[i + 1];
				}
				_editingTitleSequence->NumCommands--;
				if (w->selected_list_item >= (sint16)_editingTitleSequence->NumCommands) {
					w->selected_list_item--;
				}
				TileSequenceSave(_editingTitleSequence);
			}
		}
		break;
	case WIDX_TITLE_EDITOR_SKIP_TO:
	{
		sint32 position = w->selected_list_item;
		if (_isSequencePlaying && position != -1 && position < (sint32)_editingTitleSequence->NumCommands) {
			ITitleSequencePlayer * player = window_title_editor_get_player();
			title_sequence_player_seek(player, position);
			title_sequence_player_update(player);
		}
		break;
	}
	case WIDX_TITLE_EDITOR_MOVE_DOWN:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item != -1 && w->selected_list_item < (sint16)_editingTitleSequence->NumCommands - 1) {
				TitleCommand * a = &_editingTitleSequence->Commands[w->selected_list_item];
				TitleCommand * b = &_editingTitleSequence->Commands[w->selected_list_item + 1];
				TitleCommand tmp = *a;
				*a = *b;
				*b = tmp;
				w->selected_list_item++;
				TileSequenceSave(_editingTitleSequence);
			}
		}
		break;
	case WIDX_TITLE_EDITOR_MOVE_UP:
		if (window_title_editor_check_can_edit()) {
			if (w->selected_list_item > 0 && w->selected_list_item < (sint16)_editingTitleSequence->NumCommands) {
				TitleCommand * a = &_editingTitleSequence->Commands[w->selected_list_item - 1];
				TitleCommand * b = &_editingTitleSequence->Commands[w->selected_list_item];
				TitleCommand tmp = *b;
				*b = *a;
				*a = tmp;
				w->selected_list_item--;
				TileSequenceSave(_editingTitleSequence);
			}
		}
		break;
	case WIDX_TITLE_EDITOR_REPLAY:
		if (_isSequencePlaying) {
			ITitleSequencePlayer * player = window_title_editor_get_player();
			title_sequence_player_reset(player);
			title_sequence_player_update(player);
		}
		break;
	case WIDX_TITLE_EDITOR_STOP:
		if (_isSequencePlaying) {
			gTitleCurrentSequence = 0;
			_isSequencePlaying = false;
		}
		break;
	case WIDX_TITLE_EDITOR_PLAY:
		if (!_isSequencePlaying && (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)) {
			gTitleCurrentSequence = (uint16)_selectedTitleSequence;
			_isSequencePlaying = true;
		}
		break;
	case WIDX_TITLE_EDITOR_SKIP:
		if (_isSequencePlaying) {
			ITitleSequencePlayer * player = window_title_editor_get_player();
			sint32 position = title_sequence_player_get_current_position(player) + 1;
			if (position >= (sint32)_editingTitleSequence->NumCommands) {
				position = 0;
			}
			title_sequence_player_seek(player, position);
			title_sequence_player_update(player);
		}
		break;
	}
}
Ejemplo n.º 8
0
/**
 * 
 *  rct2: 0x006AAFAB
 */
static void window_editor_object_selection_mouseup()
{
	rct_window *w;
	short widgetIndex;

	window_widget_get_registers(w, widgetIndex);

	switch (widgetIndex) {
	case WIDX_CLOSE:
		if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_EDITOR) {
			game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 1, 0);
		}
		else {
			// Used for in-game object selection cheat
			window_close(w);
		}
		break;

	case WIDX_TAB_1:
	case WIDX_TAB_2:
	case WIDX_TAB_3:
	case WIDX_TAB_4:
	case WIDX_TAB_5:
	case WIDX_TAB_6:
	case WIDX_TAB_7:
	case WIDX_TAB_8:
	case WIDX_TAB_9:
	case WIDX_TAB_10:
	case WIDX_TAB_11:
		window_editor_object_set_page(w, widgetIndex - WIDX_TAB_1);
		break;
	case WIDX_FILTER_RIDE_TAB_ALL:
		_filter_flags |= 0x7E0;
		filter_update_counts();

		w->selected_list_item = -1;
		w->var_494 = 0xFFFFFFFF;
		w->scrolls[0].v_top = 0;
		object_free_scenario_text();
		window_invalidate(w);
		break;
	case WIDX_FILTER_RIDE_TAB_TRANSPORT:
	case WIDX_FILTER_RIDE_TAB_GENTLE:
	case WIDX_FILTER_RIDE_TAB_COASTER:
	case WIDX_FILTER_RIDE_TAB_THRILL:
	case WIDX_FILTER_RIDE_TAB_WATER:
	case WIDX_FILTER_RIDE_TAB_STALL:
		_filter_flags &= ~0x7E0;
		_filter_flags |= (1 << (widgetIndex - WIDX_FILTER_RIDE_TAB_TRANSPORT + 5));

		filter_update_counts();

		w->selected_list_item = -1;
		w->var_494 = 0xFFFFFFFF;
		w->scrolls[0].v_top = 0;
		object_free_scenario_text();
		window_invalidate(w);
		break;

	case WIDX_DROPDOWN1:
		w->list_information_type ^= 1;
		window_invalidate(w);
		break;

	case WIDX_DROPDOWN2:
		if (w->selected_list_item != -1) {
			w->selected_list_item = -1;
			object_free_scenario_text();
		}
		window_invalidate(w);

		window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK, NULL);
		break;
	case WIDX_FILTER_STRING_BUTTON:
		//window_text_input_open(w, widgetIndex, 5275, 5276, 1170, (uint32)_filter_string, 40);
		window_start_textbox(w, widgetIndex, 1170, (uint32)_filter_string, 40);
		break;
	case WIDX_FILTER_CLEAR_BUTTON:
		memset(_filter_string, 0, sizeof(_filter_string));

		w->scrolls->v_top = 0;

		window_invalidate(w);
		break;
	}
}