Ejemplo n.º 1
0
/**
 * Loads only the basic information from a scenario.
 *  rct2: 0x006761D6
 */
int scenario_load_basic(const char *path)
{
	FILE *file;
	rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4;
	rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;

	file = fopen(path, "rb");
	if (file != NULL) {
		// Read first chunk
		sawyercoding_read_chunk(file, (uint8*)s6Header);
		if (s6Header->type == S6_TYPE_SCENARIO) {
			// Read second chunk
			sawyercoding_read_chunk(file, (uint8*)s6Info);
			fclose(file);
			RCT2_GLOBAL(0x009AA00C, uint8) = 0;

			// Checks for a scenario string object (possibly for localisation)
			if ((s6Info->entry.flags & 0xFF) != 255) {
				if (object_get_scenario_text(&s6Info->entry)) {
					int ebp = RCT2_GLOBAL(0x009ADAF8, uint32);
					format_string(s6Info->name, RCT2_GLOBAL(ebp, sint16), NULL);
					format_string(s6Info->details, RCT2_GLOBAL(ebp + 4, sint16), NULL);
					RCT2_GLOBAL(0x009AA00C, uint8) = RCT2_GLOBAL(ebp + 6, uint8);
					object_free_scenario_text();
				}
			}
			return 1;
		}
		fclose(file);
	}

	RCT2_GLOBAL(0x009AC31B, sint8) = -1;
	RCT2_GLOBAL(0x009AC31C, sint16) = 3011;
	return 0;
}
Ejemplo n.º 2
0
/**
 * 
 *  rct2: 0x006AB079
 */
static void window_editor_object_selection_scroll_mouseover()
{
	rct_window *w;
	rct_object_entry *installedEntry;
	int selectedObject;
	short x, y, scrollIndex;
	uint8 objectSelectionFlags;

	window_scrollmouse_get_registers(w, scrollIndex, x, y);

	selectedObject = get_object_from_object_selection(
		w->selected_tab & 0xFF, y, &objectSelectionFlags, &installedEntry
	);
	if (objectSelectionFlags & 0x20)
		selectedObject = -1;

	if (selectedObject == w->selected_list_item)
		return;

	w->selected_list_item = selectedObject;
	w->var_494 = (uint32)installedEntry;
	object_free_scenario_text();
	if (selectedObject != -1)
		object_get_scenario_text(installedEntry);

	window_invalidate(w);
}
Ejemplo n.º 3
0
/**
 * Loads only the basic information from a scenario.
 *  rct2: 0x006761D6
 */
int scenario_load_basic(const char *path, rct_s6_header *header, rct_s6_info *info)
{
	FILE *file;

	log_verbose("loading scenario details, %s", path);

	file = fopen(path, "rb");
	if (file != NULL) {
		// Read first chunk
		sawyercoding_read_chunk(file, (uint8*)header);
		if (header->type == S6_TYPE_SCENARIO) {
			// Read second chunk
			sawyercoding_read_chunk(file, (uint8*)info);
			fclose(file);
			RCT2_GLOBAL(0x009AA00C, uint8) = 0;

			// Checks for a scenario string object (possibly for localisation)
			if ((info->entry.flags & 0xFF) != 255) {
				if (object_get_scenario_text(&info->entry)) {
					rct_stex_entry* stex_entry = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TEXT_TEMP_CHUNK, rct_stex_entry*);
					format_string(info->name, stex_entry->scenario_name, NULL);
					format_string(info->details, stex_entry->details, NULL);
					RCT2_GLOBAL(0x009AA00C, uint8) = stex_entry->var_06;
					object_free_scenario_text();
				}
			}
Ejemplo n.º 4
0
/**
 * 
 *  rct2: 0x006AB199
 */
static void window_editor_object_selection_close()
{
	rct_window* w;
	window_get_register(w);

	//if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_EDITOR))
	//	return;

	RCT2_CALLPROC_EBPSAFE(0x6ABB66);
	editor_load_selected_objects();
	reset_loaded_objects();
	object_free_scenario_text();
	RCT2_CALLPROC_EBPSAFE(0x6AB316);
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_EDITOR) {
		research_populate_list_random();
		research_remove_non_separate_vehicle_types();
	}
	else {
		// Used for in-game object selection cheat
		research_reset_items();
		research_populate_list_researched();
		gSilentResearch = true;
		sub_684AC3();
		gSilentResearch = false;
	}
	window_new_ride_init_vars();
}
Ejemplo n.º 5
0
static void window_editor_object_set_page(rct_window *w, int page)
{
	if (w->selected_tab == page)
		return;

	w->selected_tab = page;
	w->selected_list_item = -1;
	w->var_494 = 0xFFFFFFFF;
	w->scrolls[0].v_top = 0;
	object_free_scenario_text();
	window_invalidate(w);
}
Ejemplo n.º 6
0
/**
 * Loads only the basic information from a scenario.
 *  rct2: 0x006761D6
 */
int scenario_load_basic(const char *path, rct_s6_header *header, rct_s6_info *info)
{
	SDL_RWops* rw;

	log_verbose("loading scenario details, %s", path);

	rw = SDL_RWFromFile(path, "rb");
	if (rw != NULL) {
		// Read first chunk
		sawyercoding_read_chunk(rw, (uint8*)header);
		if (header->type == S6_TYPE_SCENARIO) {
			// Read second chunk
			sawyercoding_read_chunk(rw, (uint8*)info);
			SDL_RWclose(rw);
			RCT2_GLOBAL(0x009AA00C, uint8) = 0;

			// Get filename
			utf8 filename[MAX_PATH];
			const char *temp_filename = path_get_filename(path);
			int len = strnlen(temp_filename, MAX_PATH);
			safe_strncpy(filename, temp_filename, MAX_PATH);
			if (len == MAX_PATH)
			{
				filename[MAX_PATH - 1] = '\0';
				log_warning("truncated string %s", filename);
			}
			path_remove_extension(filename);

			rct_string_id localisedStringIds[3];
			if (language_get_localised_scenario_strings(filename, localisedStringIds)) {
				if (localisedStringIds[0] != (rct_string_id)STR_NONE) {
					safe_strncpy(info->name, language_get_string(localisedStringIds[0]), 64);
				}
				if (localisedStringIds[2] != (rct_string_id)STR_NONE) {
					safe_strncpy(info->details, language_get_string(localisedStringIds[2]), 256);
				}
			} else {
				// Checks for a scenario string object (possibly for localisation)
				if ((info->entry.flags & 0xFF) != 255) {
					if (object_get_scenario_text(&info->entry)) {
						rct_stex_entry* stex_entry = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TEXT_TEMP_CHUNK, rct_stex_entry*);
						format_string(info->name, stex_entry->scenario_name, NULL);
						format_string(info->details, stex_entry->details, NULL);
						RCT2_GLOBAL(0x009AA00C, uint8) = stex_entry->var_06;
						object_free_scenario_text();
					}
				}
			}
Ejemplo n.º 7
0
static void scenario_translate(scenario_index_entry *scenarioEntry, const rct_object_entry *stexObjectEntry)
{
    rct_string_id localisedStringIds[3];
    if (language_get_localised_scenario_strings(scenarioEntry->name, localisedStringIds)) {
        if (localisedStringIds[0] != STR_NONE) {
            safe_strcpy(scenarioEntry->name, language_get_string(localisedStringIds[0]), 64);
        }
        if (localisedStringIds[2] != STR_NONE) {
            safe_strcpy(scenarioEntry->details, language_get_string(localisedStringIds[2]), 256);
        }
    } else {
        // Checks for a scenario string object (possibly for localisation)
        if ((stexObjectEntry->flags & 0xFF) != 255) {
            if (object_get_scenario_text((rct_object_entry*)stexObjectEntry)) {
                rct_stex_entry* stex_entry = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TEXT_TEMP_CHUNK, rct_stex_entry*);
                format_string(scenarioEntry->name, stex_entry->scenario_name, NULL);
                format_string(scenarioEntry->details, stex_entry->details, NULL);
                object_free_scenario_text();
            }
        }
    }
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;
	}
}