Esempio n. 1
0
static void window_themes_mouseup(rct_window *w, rct_widgetindex widgetIndex)
{
    size_t activeAvailableThemeIndex;
    const utf8 * activeThemeName;

    switch (widgetIndex) {
    case WIDX_THEMES_CLOSE:
        window_close(w);
        break;
    case WIDX_THEMES_DUPLICATE_BUTTON:;
        activeAvailableThemeIndex = theme_manager_get_active_available_theme_index();
        activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex);
        window_text_input_open(w, widgetIndex, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_THEMES_PROMPT_ENTER_THEME_NAME, STR_STRING, (uintptr_t)activeThemeName, 64);
        break;
    case WIDX_THEMES_DELETE_BUTTON:
        if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) {
            window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE);
        } else {
            theme_delete();
        }
        break;
    case WIDX_THEMES_RENAME_BUTTON:
        if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) {
            window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE);
        } else {
            activeAvailableThemeIndex = theme_manager_get_active_available_theme_index();
            activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex);
            window_text_input_open(w, widgetIndex, STR_TRACK_MANAGE_RENAME, STR_THEMES_PROMPT_ENTER_THEME_NAME, STR_STRING, (uintptr_t)activeThemeName, 64);
        }
        break;
    }
}
Esempio n. 2
0
/**
 *
 *  rct2: 0x6ba4d6
 */
static void window_banner_mouseup(rct_window *w, sint32 widgetIndex)
{
	rct_banner* banner = &gBanners[w->number];
	sint32 x = banner->x << 5;
	sint32 y = banner->y << 5;

	rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32);

	while (1){
		if ((map_element_get_type(map_element) == MAP_ELEMENT_TYPE_BANNER) &&
			(map_element->properties.banner.index == w->number)) break;
		map_element++;
	}

	switch (widgetIndex) {
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_BANNER_DEMOLISH:
		game_do_command(x, 1, y, map_element->base_height | (map_element->properties.banner.position << 8), GAME_COMMAND_REMOVE_BANNER, 0, 0);
		break;
	case WIDX_BANNER_TEXT:
		window_text_input_open(w, WIDX_BANNER_TEXT, STR_BANNER_TEXT, STR_ENTER_BANNER_TEXT, gBanners[w->number].string_idx, 0, 32);
		break;
	case WIDX_BANNER_NO_ENTRY:
		textinput_cancel();
		game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, banner->colour, GAME_COMMAND_SET_BANNER_STYLE, banner->text_colour, banner->flags ^ BANNER_FLAG_NO_ENTRY);
		break;
	}
}
Esempio n. 3
0
/**
 *
 *  rct2: 0x00699AAF
 */
static void window_guest_list_mouseup(rct_window* w, rct_widgetindex widgetIndex)
{
    switch (widgetIndex)
    {
        case WIDX_CLOSE:
            window_close(w);
            break;
        case WIDX_MAP:
            context_open_window(WC_MAP);
            break;
        case WIDX_TRACKING:
            _window_guest_list_tracking_only = !_window_guest_list_tracking_only;
            if (_window_guest_list_tracking_only)
                w->pressed_widgets |= (1 << WIDX_TRACKING);
            else
                w->pressed_widgets &= ~(1 << WIDX_TRACKING);
            window_invalidate(w);
            w->scrolls[0].v_top = 0;
            break;
        case WIDX_FILTER_BY_NAME:
            if (strnlen(_window_guest_list_filter_name, sizeof(_window_guest_list_filter_name)) > 0)
            {
                // Unset the search filter.
                _window_guest_list_filter_name[0] = '\0';
                w->pressed_widgets &= ~(1 << WIDX_FILTER_BY_NAME);
            }
            else
            {
                window_text_input_open(
                    w, WIDX_FILTER_BY_NAME, STR_GUESTS_FILTER_BY_NAME, STR_GUESTS_ENTER_NAME_TO_SEARCH, STR_STRING,
                    (uintptr_t)&_window_guest_list_filter_name, sizeof(_window_guest_list_filter_name));
            }
            break;
    }
}
Esempio n. 4
0
static void window_mapgen_base_mouseup(rct_window *w, int widgetIndex)
{
	mapgen_settings mapgenSettings;

	switch (widgetIndex) {
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_TAB_1:
	case WIDX_TAB_2:
	case WIDX_TAB_3:
		window_mapgen_set_page(w, widgetIndex - WIDX_TAB_1);
		break;
	case WIDX_GENERATE:
		mapgenSettings.mapSize = _mapSize;
		mapgenSettings.height = _baseHeight + 2;
		mapgenSettings.waterLevel = _waterLevel + 2;
		mapgenSettings.floor = _floorTexture;
		mapgenSettings.wall = _wallTexture;

		mapgen_generate_blank(&mapgenSettings);
		gfx_invalidate_screen();
		break;
	case WIDX_MAP_SIZE:
		((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_MAP_SIZE_PRACTICAL;
		((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_MAP_SIZE_PRACTICAL;
		// Practical map size is 2 lower than the technical map size
		window_text_input_open(w, WIDX_MAP_SIZE, 5130, 5131, 5182, _mapSize - 2, 4);
		break;
	case WIDX_BASE_HEIGHT:
		((uint16*)TextInputDescriptionArgs)[0] = (BASESIZE_MIN - 12) / 2;
		((uint16*)TextInputDescriptionArgs)[1] = (BASESIZE_MAX - 12) / 2;
		window_text_input_open(w, WIDX_BASE_HEIGHT, 5183, 5184, 5182, (_baseHeight - 12) / 2, 3);
		break;
	case WIDX_WATER_LEVEL:
		((uint16*)TextInputDescriptionArgs)[0] = (WATERLEVEL_MIN - 12) / 2;
		((uint16*)TextInputDescriptionArgs)[1] = (WATERLEVEL_MAX - 12) / 2;
		window_text_input_open(w, WIDX_WATER_LEVEL, 5185, 5186, 5182, (_waterLevel - 12) / 2, 3);
		break;
	}
}
Esempio n. 5
0
static void custom_currency_window_mouseup(rct_window *w, rct_widgetindex widgetIndex)
{
    switch(widgetIndex) {
    case WIDX_RATE:
        window_text_input_open(
            w,
            WIDX_RATE,
            STR_RATE_INPUT_TITLE,
            STR_RATE_INPUT_DESC,
            STR_FORMAT_INTEGER,
            (uint32)CurrencyDescriptors[CURRENCY_CUSTOM].rate,
            CURRENCY_RATE_MAX_NUM_DIGITS
        );
        break;
    }
}
Esempio n. 6
0
static void window_title_editor_add_park_callback(sint32 result, const utf8 * path)
{
    uint32 extension = get_file_extension_type(path);
    if (extension != FILE_EXTENSION_SV4 && extension != FILE_EXTENSION_SV6)
        return;

    const utf8 * filename = path_get_filename(path);
    if (save_filename_exists(filename))
    {
        free(_renameSavePath);
        _renameSavePath = _strdup(filename);
        // set_format_arg(0, intptr_t, (intptr_t)&_renameSavePath);
        rct_window * w = window_find_by_class(WC_TITLE_EDITOR);
        window_text_input_open(w, WIDX_TITLE_EDITOR_RENAME_SAVE, STR_FILEBROWSER_RENAME_SAVE_TITLE, STR_ERROR_EXISTING_NAME, STR_STRING, (uintptr_t)_renameSavePath, 52 - 1);
        return;
    }

    TitleSequenceAddPark(_editingTitleSequence, path, filename);
}
Esempio n. 7
0
/* rct2: 0x6ba4d6*/
static void window_banner_mouseup()
{
	short widgetIndex;
	rct_window *w;

	window_widget_get_registers(w, widgetIndex);

	rct_banner* banner = &gBanners[w->number];
	int x = banner->x << 5;
	int y = banner->y << 5;

	rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER(((y << 8) | x) >> 5);

	while (1){
		if (((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_BANNER) &&
			(map_element->properties.banner.index == w->number)) break;
		map_element++;
	}

	switch (widgetIndex) {
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_BANNER_DEMOLISH:
		game_do_command(x, 1, y, map_element->base_height | (map_element->properties.banner.position << 8), GAME_COMMAND_51, 0, 0);
		break;
	case WIDX_BANNER_TEXT:
		window_text_input_open(w, WIDX_BANNER_TEXT, 2982, 2983, gBanners[w->number].string_idx, 0);
		break;
	case WIDX_BANNER_NO_ENTRY:
		RCT2_CALLPROC_EBPSAFE(0x006EE3C3);
		banner->flags ^= BANNER_FLAG_NO_ENTRY;
		window_invalidate(w);

		map_element->properties.banner.flags = 0xFF;
		if (banner->flags & BANNER_FLAG_NO_ENTRY){
			map_element->properties.banner.flags &= ~(1 << map_element->properties.banner.position);
		}
		break;
	}
}
Esempio n. 8
0
static void window_mapgen_simplex_mouseup(rct_window *w, int widgetIndex)
{
	mapgen_settings mapgenSettings;

	switch (widgetIndex) {
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_TAB_1:
	case WIDX_TAB_2:
	case WIDX_TAB_3:
		window_mapgen_set_page(w, widgetIndex - WIDX_TAB_1);
		break;
	case WIDX_SIMPLEX_MAP_SIZE:
		((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_MAP_SIZE_PRACTICAL;
		((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_MAP_SIZE_PRACTICAL;
		// Practical map size is 2 lower than the technical map size
		window_text_input_open(w, WIDX_SIMPLEX_MAP_SIZE, 5130, 5131, 5182, _mapSize - 2, 4);
		break;
	case WIDX_GENERATE:
		mapgenSettings.mapSize = _mapSize;

		mapgenSettings.height = _baseHeight;
		mapgenSettings.waterLevel = _waterLevel + 2;
		mapgenSettings.floor = _floorTexture;
		mapgenSettings.wall = _wallTexture;
		mapgenSettings.trees = 0;

		mapgenSettings.simplex_low = _simplex_low;
		mapgenSettings.simplex_high = _simplex_high;
		mapgenSettings.simplex_base_freq = ((float)_simplex_base_freq) / 100.00f;
		mapgenSettings.simplex_octaves = _simplex_octaves;

		mapgen_generate(&mapgenSettings);
		gfx_invalidate_screen();
		break;
	}
}
Esempio n. 9
0
static void window_land_rights_inputsize(rct_window *w)
{
	((uint16*)TextInputDescriptionArgs)[0] = MINIMUM_TOOL_SIZE;
	((uint16*)TextInputDescriptionArgs)[1] = MAXIMUM_TOOL_SIZE;
	window_text_input_open(w, WIDX_PREVIEW, 5128, 5129, STR_NONE, STR_NONE, 3);
}
Esempio n. 10
0
static void window_clear_scenery_inputsize(rct_window *w)
{
	TextInputDescriptionArgs[0] = MINIMUM_TOOL_SIZE;
	TextInputDescriptionArgs[1] = MAXIMUM_TOOL_SIZE;
	window_text_input_open(w, WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, STR_NONE, STR_NONE, 3);
}
Esempio n. 11
0
static void window_land_inputsize(rct_window *w)
{
	((uint16*)TextInputDescriptionArgs)[0] = 0;
	((uint16*)TextInputDescriptionArgs)[1] = 64;
	window_text_input_open(w, WIDX_PREVIEW, 5128, 5129, STR_NONE, STR_NONE, 3);
}
Esempio n. 12
0
static void window_title_editor_mouseup(rct_window * w, rct_widgetindex widgetIndex)
{
    bool commandEditorOpen = (window_find_by_class(WC_TITLE_COMMAND_EDITOR) != nullptr);
    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 != nullptr)
        {
            window_text_input_open(w, widgetIndex, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE, STR_STRING, (uintptr_t)_sequenceName, 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_BUTTON:
        if (window_title_editor_check_can_edit() && _editingTitleSequence != nullptr)
        {
            window_text_input_open(w, widgetIndex, STR_TRACK_MANAGE_RENAME, STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE, STR_STRING, (uintptr_t)_sequenceName, 64);
        }
        break;

    //////////////////////////////////////////////////////////////////////////////////////////////////////
    // Editor tab
    //////////////////////////////////////////////////////////////////////////////////////////////////////
    case WIDX_TITLE_EDITOR_ADD_SAVE:
        if (!_isSequenceReadOnly && !title_is_previewing_sequence() && !commandEditorOpen)
        {
            auto intent = Intent(WC_LOADSAVE);
            intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME);
            intent.putExtra(INTENT_EXTRA_CALLBACK, (void *) window_title_editor_add_park_callback);
            context_open_intent(&intent);
        }
        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)
        {
            auto handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
            auto stream = (IStream *)handle->Stream;
            auto hintPath = String::ToStd(handle->HintPath);

            bool isScenario = ParkImporter::ExtensionIsScenario(hintPath);
            auto objectMgr = OpenRCT2::GetContext()->GetObjectManager();
            auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
            auto result = parkImporter->LoadFromStream(stream, isScenario);
            objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
            parkImporter->Import();

            if (isScenario)
                scenario_begin();
            else
                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--;
                }
                TitleSequenceSave(_editingTitleSequence);
            }
        }
        break;
    case WIDX_TITLE_EDITOR_SKIP_TO:
    {
        sint32 position = w->selected_list_item;
        if (title_is_previewing_sequence() && 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++;
                TitleSequenceSave(_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--;
                TitleSequenceSave(_editingTitleSequence);
            }
        }
        break;
    case WIDX_TITLE_EDITOR_REPLAY:
        if (title_is_previewing_sequence())
        {
            ITitleSequencePlayer * player = window_title_editor_get_player();
            title_sequence_player_reset(player);
            title_sequence_player_update(player);
        }
        break;
    case WIDX_TITLE_EDITOR_STOP:
        if (title_is_previewing_sequence())
        {
            title_stop_previewing_sequence();
        }
        break;
    case WIDX_TITLE_EDITOR_PLAY:
        if (!title_is_previewing_sequence() || _selectedTitleSequence != title_get_current_sequence())
        {
            if (!title_preview_sequence(_selectedTitleSequence))
            {
                context_show_error(STR_ERR_FAILED_TO_LOAD_TITLE_SEQUENCE, STR_NONE);
            }
            else if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
            {
                gPreviewingTitleSequenceInGame = true;
            }
        }
        break;
    case WIDX_TITLE_EDITOR_SKIP:
        if (title_is_previewing_sequence())
        {
            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;
    }
}
Esempio n. 13
0
static void window_loadsave_select(rct_window *w, const char *path)
{
	SDL_RWops* rw;
	switch (_loadsaveType & 0x0F) {
	case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME) :
		if (gLoadSaveTitleSequenceSave) {
			utf8 newName[MAX_PATH];
			char *extension = (char*)path_get_extension(path);
			safe_strcpy(newName, path_get_filename(path), MAX_PATH);
			if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
				strcat(newName, ".sv6");
			if (title_sequence_save_exists(gCurrentTitleSequence, newName)) {
				RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&_listItems[w->selected_list_item].name;
				window_text_input_open(w, WIDX_SCROLL, 5435, 5404, 1170, (uint32)_listItems[w->selected_list_item].name, TITLE_SEQUENCE_MAX_SAVE_LENGTH - 1);
			}
			else {
				title_sequence_add_save(gCurrentTitleSequence, path, newName);
				window_close(w);
			}
			window_loadsave_invoke_callback(MODAL_RESULT_OK);
		} else if (game_load_save(path)) {
			safe_strcpy(gScenarioSavePath, path, MAX_PATH);
			gFirstTimeSave = 0;

			window_close(w);
			gfx_invalidate_screen();
			window_loadsave_invoke_callback(MODAL_RESULT_OK);
		} else {
			// 1050, not the best message...
			window_error_open(STR_LOAD_GAME, 1050);
			window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
		}
		break;
	case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME) :
		rw = SDL_RWFromFile(path, "wb+");
		if (rw != NULL) {
			int success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 1 : 0);
			SDL_RWclose(rw);
			if (success) {
				safe_strcpy(gScenarioSavePath, path, MAX_PATH);
				gFirstTimeSave = 0;

				window_close_by_class(WC_LOADSAVE);
				gfx_invalidate_screen();

				window_loadsave_invoke_callback(MODAL_RESULT_OK);
			} else {
				window_error_open(STR_SAVE_GAME, 1047);
				window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
			}
		} else {
			window_error_open(STR_SAVE_GAME, 1047);
			window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
		}
		break;
	case (LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE) :
		if (editor_load_landscape(path)) {
			gfx_invalidate_screen();
			window_loadsave_invoke_callback(MODAL_RESULT_OK);
		} else {
			// 1050, not the best message...
			window_error_open(STR_LOAD_LANDSCAPE, 1050);
			window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
		}
		break;
	case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE) :
		rw = SDL_RWFromFile(path, "wb+");
		if (rw != NULL) {
			scenario_set_filename(path);
			int success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 3 : 2);
			SDL_RWclose(rw);
			if (success) {
				window_close_by_class(WC_LOADSAVE);
				gfx_invalidate_screen();
				window_loadsave_invoke_callback(MODAL_RESULT_OK);
			} else {
				window_error_open(STR_SAVE_LANDSCAPE, 1049);
				window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
			}
		} else {
			window_error_open(STR_SAVE_LANDSCAPE, 1049);
			window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
		}
		break;
	case (LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO) :
	{
		rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;
		int parkFlagsBackup = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32);
		RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_18;
		s6Info->editor_step = 255;
		rw = SDL_RWFromFile(path, "wb+");
		int success = 0;
		if (rw != NULL) {
			scenario_set_filename(path);
			success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 3 : 2);
			SDL_RWclose(rw);
		}
		RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = parkFlagsBackup;

		if (success) {
			window_close_by_class(WC_LOADSAVE);
			window_loadsave_invoke_callback(MODAL_RESULT_OK);
			title_load();
		} else {
			window_error_open(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO, STR_SCENARIO_SAVE_FAILED);
			s6Info->editor_step = EDITOR_STEP_OBJECTIVE_SELECTION;
			window_loadsave_invoke_callback(MODAL_RESULT_FAIL);
		}
		break;
	}
	case (LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK) :
		window_install_track_open(path);
		window_close_by_class(WC_LOADSAVE);
		window_loadsave_invoke_callback(MODAL_RESULT_OK);
		break;
	}
}
Esempio n. 14
0
static void window_loadsave_mouseup(rct_window *w, int widgetIndex)
{
	int result = 0;
	char path[MAX_PATH], filter[MAX_PATH];

	switch (widgetIndex){
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_UP:
	{
		char directory[MAX_PATH];
		int includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
		
		safe_strcpy(directory, _parentDirectory, sizeof(directory));
		window_loadsave_populate_list(w, includeNewItem, directory, _extension);
		window_init_scroll_widgets(w);
		w->no_list_items = _listItemsCount;
		break;
	}
	case WIDX_NEW:
	{		
		rct_string_id templateStringId = 3165;
		char *templateString;
		
		templateString = (char *)language_get_string(templateStringId);
		strcpy(templateString, _defaultName);
		window_text_input_open(w, WIDX_NEW, STR_NONE, 2710, templateStringId, 0, 64);
		break;
	}
	case WIDX_BROWSE:
		safe_strcpy(path, _directory, MAX_PATH);
		if (_type & LOADSAVETYPE_SAVE) {
			strcat(path, _defaultName);
		}

		memset(filter, '\0', MAX_PATH);
		safe_strcpy(filter, "*", MAX_PATH);
		strncat(filter, _extension, MAX_PATH - strnlen(filter, MAX_PATH) - 1);

		file_dialog_desc desc;
		memset(&desc, 0, sizeof(desc));
		desc.initial_directory = _directory;
		if (_type & LOADSAVETYPE_SAVE) {
			desc.default_filename = path;
		}

		switch (_type) {
		case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME) :
			desc.type = FD_OPEN;
			desc.title = language_get_string(STR_FILE_DIALOG_TITLE_LOAD_GAME);
			desc.filters[0].name = language_get_string(STR_OPENRCT2_SAVED_GAME);
			desc.filters[0].pattern = "*.sv4;*.sv6";
			break;
		case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME) :
			desc.type = FD_SAVE;
			desc.title = language_get_string(STR_FILE_DIALOG_TITLE_SAVE_GAME);
			desc.filters[0].name = language_get_string(STR_OPENRCT2_SAVED_GAME);
			desc.filters[0].pattern = "*.sv6";
			break;
		case (LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE) :
			desc.type = FD_OPEN;
			desc.title = language_get_string(STR_FILE_DIALOG_TITLE_LOAD_LANDSCAPE);
			desc.filters[0].name = language_get_string(STR_OPENRCT2_LANDSCAPE_FILE);
			desc.filters[0].pattern = "*.sc4;*.sv4;*.sc6;*.sv6";
			break;
		case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE) :
			desc.type = FD_SAVE;
			desc.title = language_get_string(STR_FILE_DIALOG_TITLE_SAVE_LANDSCAPE);
			desc.filters[0].name = language_get_string(STR_OPENRCT2_LANDSCAPE_FILE);
			desc.filters[0].pattern = "*.sc6";
			break;
		case (LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO) :
			desc.type = FD_SAVE;
			desc.title = language_get_string(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO);
			desc.filters[0].name = language_get_string(STR_OPENRCT2_SCENARIO_FILE);
			desc.filters[0].pattern = "*.sc6";
			break;
		case (LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK) :
			desc.type = FD_OPEN;
			desc.title = language_get_string(STR_FILE_DIALOG_TITLE_INSTALL_NEW_TRACK_DESIGN);
			desc.filters[0].name = language_get_string(STR_OPENRCT2_TRACK_DESIGN_FILE);
			desc.filters[0].pattern = "*.td4;*.td6";
			break;
		}

		result = platform_open_common_file_dialog(path, &desc);
		if (result) {
			window_loadsave_select(w, path);
		}
		break;
	case WIDX_SORT_NAME:
		if (gConfigGeneral.load_save_sort == SORT_NAME_ASCENDING){
			gConfigGeneral.load_save_sort = SORT_NAME_DESCENDING;
		} else {
			gConfigGeneral.load_save_sort = SORT_NAME_ASCENDING;
		}
		config_save_default();
		window_loadsave_sort_list(0, _listItemsCount - 1);
		window_invalidate(w);
		break;
	case WIDX_SORT_DATE:
		if (gConfigGeneral.load_save_sort == SORT_DATE_DESCENDING){
			gConfigGeneral.load_save_sort = SORT_DATE_ASCENDING;
		} else {
			gConfigGeneral.load_save_sort = SORT_DATE_DESCENDING;
		}
		config_save_default();
		window_loadsave_sort_list(0, _listItemsCount - 1);
		window_invalidate(w);
		break;
	}
}
Esempio n. 15
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;
	}
}