Example #1
0
static void window_dropdown_paint()
{
	rct_window *w;
	rct_drawpixelinfo *dpi;

	__asm mov w, esi
	__asm mov dpi, edi

	window_draw_widgets(w, dpi);

	_dropdown_highlighted_index = RCT2_GLOBAL(0x009DEBA2, sint16);
	{
		int i, cell_x, cell_y, l, t, r, b, item, image, colour;
		for (i = 0; i < _dropdown_num_items; i++) {
			cell_x = i % _dropdown_num_columns;
			cell_y = i / _dropdown_num_columns;

			if (gDropdownItemsFormat[i] == DROPDOWN_SEPARATOR) {
				l = w->x + 2 + (cell_x * _dropdown_item_width);
				t = w->y + 2 + (cell_y * _dropdown_item_height);
				r = l + _dropdown_item_width - 1;
				t += (_dropdown_item_height / 2);
				b = t;

				if (w->colours[0] & 0x80) {
					gfx_fill_rect(dpi, l, t, r, b, (RCT2_ADDRESS(0x009DEDF4, uint8)[w->colours[0]] | 0x02000000) + 1);
					gfx_fill_rect(dpi, l, t + 1, r, b + 1, (RCT2_ADDRESS(0x009DEDF4, uint8)[w->colours[0]] | 0x02000000) + 2);
				} else {
					gfx_fill_rect(dpi, l, t, r, b,
						*((char*)(0x00141FC47 + (w->colours[0] * 8))));
					gfx_fill_rect(dpi, l, t + 1, r, b + 1,
						*((char*)(0x00141FC4B + (w->colours[0] * 8))));
				}
			} else {
				// 
				if (i == _dropdown_highlighted_index) {
					l = w->x + 2 + (cell_x * _dropdown_item_width);
					t = w->y + 2 + (cell_y * _dropdown_item_height);
					r = l + _dropdown_item_width - 1;
					b = t + _dropdown_item_height - 1;
					gfx_fill_rect(dpi, l, t, r, b, 0x2000000 | 0x2F);
				}

				item = gDropdownItemsFormat[i];
				if (item == (uint16)-1 || item == (uint16)-2) {
					// Image item
					image = gDropdownItemsArgs[i];
					if (item == (uint16)-2 && _dropdown_highlighted_index == i)
						image++;

					gfx_draw_sprite(
						dpi,
						image,
						w->x + 2 + (cell_x * _dropdown_item_width),
						w->y + 2 + (cell_y * _dropdown_item_height)
					);
				} else {
					// Text item
					if (i < 32)
						if (gDropdownItemsChecked & (1 << i))
							item++;

					// Calculate colour
					colour = w->colours[0] & 0x7F;
					if (i == _dropdown_highlighted_index)
						colour = 2;
					if (RCT2_GLOBAL(0x009DED34, uint32) & (1 << i))
						if (i < 32)
							colour = (w->colours[0] & 0x7F) | 0x40;

					// Draw item string
					gfx_draw_string_left_clipped(
						dpi,
						item,
						(void*)(&gDropdownItemsArgs[i]), colour,
						w->x + 2 + (cell_x * _dropdown_item_width),
						w->y + 1 + (cell_y * _dropdown_item_height),
						w->width - 5
					);
				}
			}
		}
	}
}
Example #2
0
static void osinterface_resize(int width, int height)
{
	rct_drawpixelinfo *screenDPI;
	int newScreenBufferSize;
	void *newScreenBuffer;

	if (_surface != NULL)
		SDL_FreeSurface(_surface);
	if (_palette != NULL)
		SDL_FreePalette(_palette);

	_surface = SDL_CreateRGBSurface(0, width, height, 8, 0, 0, 0, 0);
	_palette = SDL_AllocPalette(256);

	if (!_surface || !_palette) {
		RCT2_ERROR("%p || %p == NULL %s", _surface, _palette, SDL_GetError());
		exit(-1);
	}

	if (SDL_SetSurfacePalette(_surface, _palette)) {
		RCT2_ERROR("SDL_SetSurfacePalette failed %s", SDL_GetError());
		exit(-1);
	}

	newScreenBufferSize = _surface->pitch * _surface->h;
	newScreenBuffer = malloc(newScreenBufferSize);
	if (_screenBuffer == NULL) {
		memset(newScreenBuffer, 0, newScreenBufferSize);
	} else {
		memcpy(newScreenBuffer, _screenBuffer, min(_screenBufferSize, newScreenBufferSize));
		if (newScreenBufferSize - _screenBufferSize > 0)
			memset((uint8*)newScreenBuffer + _screenBufferSize, 0, newScreenBufferSize - _screenBufferSize);
		free(_screenBuffer);
	}

	_screenBuffer = newScreenBuffer;
	_screenBufferSize = newScreenBufferSize;

	RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) = width;
	RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) = height;

	screenDPI = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
	screenDPI->bits = _screenBuffer;
	screenDPI->x = 0;
	screenDPI->y = 0;
	screenDPI->width = width;
	screenDPI->height = height;
	screenDPI->pitch = _surface->pitch - _surface->w;

	RCT2_GLOBAL(0x009ABDF0, uint8) = 6;
	RCT2_GLOBAL(0x009ABDF1, uint8) = 3;
	RCT2_GLOBAL(0x009ABDF2, uint8) = 1;
	RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_WIDTH, sint16) = 64;
	RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_HEIGHT, sint16) = 8;
	RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) = (width >> 6) + 1;
	RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32) = (height >> 3) + 1;

	window_resize_gui(width, height);
	//RCT2_CALLPROC_EBPSAFE(0x0066B905); // resize_gui()

	gfx_invalidate_screen();
}
Example #3
0
    NULL,
    window_tooltip_paint,
    NULL
};

void window_tooltip_reset(int x, int y)
{
    gTooltipCursorX = x;
    gTooltipCursorY = y;
    gTooltipTimeout = 0;
    gTooltipWidget.window_classification = 255;
    gInputState = INPUT_STATE_NORMAL;
    gInputFlags &= ~INPUT_FLAG_4;
}

uint8* gTooltip_text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER, uint8);

void window_tooltip_show(rct_string_id id, int x, int y)
{
    rct_window *w;
    int width, height;

    w = window_find_by_class(WC_ERROR);
    if (w != NULL)
        return;

    RCT2_GLOBAL(0x0142006C, sint32) = -1;
    char* buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);

    format_string(buffer, id, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS);
    RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM;
Example #4
0
 * (at your option) any later version.
 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *****************************************************************************/

#include "addresses.h"
#include <string.h>
#include "sprite.h"

rct_sprite* g_sprite_list = RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite);

/**
 * 
 *  rct2: 0x006736C7
 */
void create_balloon(int x, int y, int z, int colour)
{
	RCT2_CALLPROC_X(0x006736C7, x, colour << 8, y, z, 0, 0, 0);
}

/*
 *
 * rct2: 0x0069EB13
 */
void reset_sprite_list(){
Example #5
0
/**
 * 
 *  rct2: 0x00683D20
 */
int screenshot_dump_bmp()
{
	BitmapFileHeader header;
	BitmapInfoHeader info;

	int i, y, index, width, height, stride;
	char *buffer, path[MAX_PATH], *row;
	HANDLE hFile;
	DWORD bytesWritten;

	// Get a free screenshot path
	if ((index = screenshot_get_next_path(path, ".bmp")) == -1)
		return -1;

	// Open file for writing
	hFile = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
		return -1;

	// Allocate buffer
	buffer = malloc(0xFFFF);
	if (buffer == NULL) {
		CloseHandle(hFile);
		return -1;
	}

	// Get image size
	width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
	height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
	stride = (width + 3) & 0xFFFFFFFC;

	// File header
	memset(&header, 0, sizeof(header));
	header.bfType = 0x4D42;
	header.bfSize = height * stride + 1038;
	header.bfOffBits = 1038;

	WriteFile(hFile, &header, sizeof(header), &bytesWritten, NULL);
	if (bytesWritten != sizeof(header)) {
		CloseHandle(hFile);
		free(buffer);
	}

	// Info header
	memset(&info, 0, sizeof(info));
	info.biSize = sizeof(info);
	info.biWidth = width;
	info.biHeight = height;
	info.biPlanes = 1;
	info.biBitCount = 8;
	info.biXPelsPerMeter = 2520;
	info.biYPelsPerMeter = 2520;
	info.biClrUsed = 246;

	WriteFile(hFile, &info, sizeof(info), &bytesWritten, NULL);
	if (bytesWritten != sizeof(info)) {
		CloseHandle(hFile);
		free(buffer);
	}

	// Palette
	memset(buffer, 0, 246 * 4);
	for (i = 0; i < 246; i++) {
		buffer[i * 4 + 0] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 0];
		buffer[i * 4 + 1] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 1];
		buffer[i * 4 + 2] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 2];
	}

	WriteFile(hFile, buffer, 246 * 4, &bytesWritten, NULL);
	if (bytesWritten != 246 * 4) {
		CloseHandle(hFile);
		free(buffer);
	}

	// Image, save upside down
	rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
	for (y = dpi->height - 1; y >= 0; y--) {
		row = dpi->bits + y * (dpi->width + dpi->pitch);

		memset(buffer, 0, stride);
		memcpy(buffer, row, dpi->width);

		WriteFile(hFile, buffer, stride, &bytesWritten, NULL);
		if (bytesWritten != stride) {
			CloseHandle(hFile);
			free(buffer);
		}
	}

	CloseHandle(hFile);
	free(buffer);

	return index;
}
Example #6
0
 *****************************************************************************/
#pragma endregion

#include "../rct2/addresses.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "drawing.h"
#include "font.h"
#include "ttf.h"

static const sint32 SpriteFontLineHeight[] = { 6, 10, 10, 18 };

#ifdef NO_RCT2
static uint8 _spriteFontCharacterWidths[896];
#else
static uint8 *_spriteFontCharacterWidths = RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8);
#endif

#ifndef NO_TTF
TTFFontSetDescriptor *gCurrentTTFFontSet;
#endif // NO_TTF

/**
 *
 *  rct2: 0x006C19AC
 */
void font_sprite_initialise_characters()
{
    uint8* pCharacterWidth = _spriteFontCharacterWidths;
    for (sint32 fontSize = 0; fontSize < FONT_SIZE_COUNT; fontSize++) {
        sint32 glyphOffset = fontSize * FONT_SPRITE_GLYPH_COUNT;
/**
 * 
 *  rct2: 0x006AADA3
 */
static void window_editor_object_selection_scrollpaint()
{
	int x, y, i, colour, colour2, numObjects, type;
	short scrollIndex;
	rct_object_entry *entry;
	rct_object_filters *filter;
	rct_window *w;
	rct_drawpixelinfo *dpi;
	uint8 *itemFlags;
	uint8 source;

	window_scrollpaint_get_registers(w, dpi, scrollIndex);

	colour = RCT2_ADDRESS(0x0141FC48, uint8)[w->colours[1] * 8];
	colour = (colour << 24) | (colour << 16) | (colour << 8) | colour;
	gfx_clear(dpi, colour);

	numObjects = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, sint32);
	entry = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*);
	itemFlags = RCT2_GLOBAL(0x009ADAEC, uint8*);
	y = 0;
	for (i = 0; i < numObjects; i++) {
		filter = get_object_filter(i);
		type = entry->flags & 0x0F;
		source = (entry->flags & 0xF0) >> 4;
		if (type == w->selected_tab && !(*itemFlags & 0x20) && filter_source(entry) && filter_string(entry) && filter_chunks(entry, filter)) {
			if (y + 12 >= dpi->y && y <= dpi->y + dpi->height) {
				// Draw checkbox
				if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && !(*itemFlags & 0x20))
					gfx_fill_rect_inset(dpi, 2, y, 11, y + 10, w->colours[1], 0xE0);

				// Highlight background
				colour = 142;
				if (entry == (rct_object_entry*)w->var_494 && !(*itemFlags & 0x20)) {
					gfx_fill_rect(dpi, 0, y, w->width, y + 11, 0x2000031);
					colour = 14;
				}

				// Draw checkmark
				if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && (*itemFlags & 1)) {
					x = 2;
					RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = colour == 14 ? -2 : -1;
					colour2 = w->colours[1] & 0x7F;
					if (*itemFlags & 0x1C)
						colour2 |= 0x40;

					gfx_draw_string(dpi, (char*)0x009DED72, colour2, x, y);
				}

				// Draw text
				char *buffer = (char*)0x0141ED68;
				*buffer = colour;
				strcpy(buffer + 1, object_get_name(entry));
				if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
					while (*buffer != 0 && *buffer != 9)
						buffer++;

					*buffer = 0;
				}

				if (*itemFlags & 0x20) {
					colour = w->colours[1] & 0x7F;
					RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1;
				} else {
					colour = 0;
					RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = 224;
				}
				x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15;
				gfx_draw_string(dpi, (char*)0x0141ED68, colour, x, y);
			}
			y += 12;
		}

		entry = object_get_next(entry);
		itemFlags++;
	}
}
Example #8
0
static void window_text_input_paint(){
	rct_window *w;
	rct_drawpixelinfo *dpi;

	window_paint_get_registers(w, dpi);

	window_draw_widgets(w, dpi);

	int y = w->y + 25;
	
	int no_lines = 0;
	int font_height = 0;
	

	gfx_draw_string_centred(dpi, input_text_description, w->x + WW / 2, y, w->colours[1], &TextInputDescriptionArgs);

	y += 25;

	RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
	RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;

	char wrapped_string[512];
	strcpy(wrapped_string, text_input);

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

	gfx_fill_rect_inset(dpi, w->x + 10, y, w->x + WW - 10, y + 10 * (no_lines + 1) + 3, w->colours[1], 0x60);

	y += 1;

	char* wrap_pointer = wrapped_string;
	int char_count = 0;
	uint8 cur_drawn = 0;

	for (int line = 0; line <= no_lines; ++line){
		gfx_draw_string(dpi, wrap_pointer, w->colours[1], w->x + 12, y);

		int string_length = get_string_length(wrap_pointer);

		if (!cur_drawn && (gTextInputCursorPosition <= char_count + string_length)){
			// Make a copy of the string for measuring the width.
			char temp_string[512] = { 0 };
			memcpy(temp_string, wrap_pointer, gTextInputCursorPosition - char_count);
			int cur_x = w->x + 13 + gfx_get_string_width(temp_string);

			int width = 6;
			if ((uint32)gTextInputCursorPosition < strlen(text_input)){
				// Make a new 1 character wide string for measuring the width
				// of the character that the cursor is under.
				temp_string[1] = '\0';
				temp_string[0] = text_input[gTextInputCursorPosition];
				width = max(gfx_get_string_width(temp_string) - 2, 4);
			}

			if (w->frame_no > 15){
				uint8 colour = RCT2_ADDRESS(0x0141FC48, uint8)[w->colours[1] * 8];
				gfx_fill_rect(dpi, cur_x, y + 9, cur_x + width, y + 9, colour + 5);
			}

			cur_drawn++;
		}
		
		wrap_pointer += string_length + 1;

		if (text_input[char_count + string_length] == ' ')char_count++;
		char_count += string_length;

		y += 10;
	}
}
Example #9
0
int rct2_init()
{
	log_verbose("initialising game");

	RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) = 0;
	RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*);
	get_system_time();
	util_srand((unsigned int)time(0));
	RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short);
	RCT2_GLOBAL(0x009DEA6B, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, short);
	if (!rct2_init_directories())
		return 0;

	if (!rct2_startup_checks())
		return 0;

	config_reset_shortcut_keys();
	config_shortcut_keys_load();
	RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;
	// config_load();

	object_list_load();
	scenario_load_list();

	ride_list_item item = { 253, 0 };
	track_load_list(item);

	gfx_load_g1();
	gfx_load_g2();
	font_sprite_initialise_characters();
	if (!gOpenRCT2Headless) {
		platform_init();
		audio_init_ride_sounds_and_info();
	}
	viewport_init_all();
	news_item_init_queue();
	get_local_time();
	reset_park_entrances();
	user_string_clear_all();
	reset_sprite_list();
	ride_init_all();
	window_guest_list_init_vars_a();
	staff_reset_modes();
	map_init(150);
	park_init();
	if (!gOpenRCT2Headless)
		window_title_menu_open();
	date_reset();
	climate_reset(CLIMATE_COOL_AND_WET);
	scenery_set_default_placement_configuration();
	window_new_ride_init_vars();
	window_guest_list_init_vars_b();
	window_staff_list_init_vars();

	if (!gOpenRCT2Headless) {
		title_load();

		gfx_clear(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 10);
	}

	log_verbose("initialising game finished");
	return 1;
}
Example #10
0
/**
 *
 *  rct2: 0x0066E4EE
 */
static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex)
{
	int i, x, y, yy, press;

	y = 0;
	for (i = 11; i < 61; i++) {
		rct_news_item * const newsItem = news_item_get(i);
		if (news_item_is_empty(i))
			break;
		if (y >= dpi->y + dpi->height)
			break;
		if (y + 42 < dpi->y) {
			y += 42;
			continue;
		}

		// Background
		gfx_fill_rect_inset(dpi, -1, y, 383, y + 41, w->colours[1], 0x24);

		// Date text
		RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_DATE_DAY_1 + newsItem->day - 1;
		RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint16) = STR_MONTH_MARCH + (newsItem->month_year % 8);
		gfx_draw_string_left(dpi, 2235, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 2, 4, y);

		// Item text
		utf8 buffer[400];
		utf8 *ch = buffer;
		ch = utf8_write_codepoint(ch, FORMAT_SMALLFONT);
		memcpy(ch, newsItem->text, 256);
		ch = buffer;
		gfx_draw_string_left_wrapped(dpi, &ch, 2, y + 10, 325, 1170, 14);

		// Subject button
		if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) && !(newsItem->flags & 1)) {
			x = 328;
			yy = y + 14;

			press = 0;
			if (w->news.var_480 != -1) {
				const uint8 idx = 11 + w->news.var_480;
				news_item_is_valid_idx(idx);
				if (i == idx && w->news.var_482 == 1)
					press = 0x20;
			}
			gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);

			switch (newsItem->type) {
			case NEWS_ITEM_RIDE:
				gfx_draw_sprite(dpi, SPR_RIDE, x, yy, 0);
				break;
			case NEWS_ITEM_PEEP:
			case NEWS_ITEM_PEEP_ON_RIDE:
			{
				rct_drawpixelinfo cliped_dpi;
				if (!clip_drawpixelinfo(&cliped_dpi, dpi, x + 1, yy + 1, 22, 22)) {
					break;
				}

				rct_peep* peep = GET_PEEP(newsItem->assoc);
				int clip_x = 10, clip_y = 19;

				// If normal peep set sprite to normal (no food)
				// If staff set sprite to staff sprite
				int sprite_type = 0;
				if (peep->type == PEEP_TYPE_STAFF){
					sprite_type = peep->sprite_type;
					if (peep->staff_type == STAFF_TYPE_ENTERTAINER){
						clip_y += 3;
					}
				}

				uint32 image_id = g_sprite_entries[sprite_type].sprite_image->base_image;
				image_id += 0xA0000001;
				image_id |= (peep->tshirt_colour << 19) | (peep->trousers_colour << 24);

				gfx_draw_sprite(&cliped_dpi, image_id, clip_x, clip_y, 0);
				break;
			}
			case NEWS_ITEM_MONEY:
				gfx_draw_sprite(dpi, SPR_FINANCE, x, yy, 0);
				break;
			case NEWS_ITEM_RESEARCH:
				gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY, x, yy, 0);
				break;
			case NEWS_ITEM_PEEPS:
				gfx_draw_sprite(dpi, SPR_GUESTS, x, yy, 0);
				break;
			case NEWS_ITEM_AWARD:
				gfx_draw_sprite(dpi, SPR_AWARD, x, yy, 0);
				break;
			case NEWS_ITEM_GRAPH:
				gfx_draw_sprite(dpi, SPR_GRAPH, x, yy, 0);
				break;
			}
		}

		// Location button
		if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 1) && !(newsItem->flags & 1)) {
			x = 352;
			yy = y + 14;

			press = 0;
			if (w->news.var_480 != -1) {
				const uint8 idx = 11 + w->news.var_480;
				news_item_is_valid_idx(idx);
				if (i == idx && w->news.var_482 == 2)
					press = 0x20;
			}
			gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);
			gfx_draw_sprite(dpi, SPR_LOCATE, x, yy, 0);
		}

		y += 42;
	}
}
Example #11
0
	RCT2_CALLPROC_EBPSAFE(0x0066B905);
}

/**
*
*  rct2: 0x006838BD
*/
void update_palette_effects()
{
	if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 1) {
		// change palette to lighter color during lightning
		int palette = 1532;
		if (RCT2_GLOBAL(0x009ADAE0, sint32) != -1) {
			palette = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 2, int);
		}
		rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette];
		int xoffset = g1_element.x_offset;
		xoffset = xoffset * 4;
		for (int i = 0; i < g1_element.width; i++) {
			RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 0] = -((0xFF - g1_element.offset[(i * 3) + 0]) / 2) - 1;
			RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 1] = -((0xFF - g1_element.offset[(i * 3) + 1]) / 2) - 1;
			RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 2] = -((0xFF - g1_element.offset[(i * 3) + 2]) / 2) - 1;
		}
		RCT2_GLOBAL(0x014241BC, uint32) = 2;
		osinterface_update_palette(RCT2_ADDRESS(0x01424680, uint8), 10, 236);
		RCT2_GLOBAL(0x014241BC, uint32) = 0;
		RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8)++;
	} else {
		if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) {
			// change palette back to normal after lightning
			int palette = 1532;
Example #12
0
#include "../interface/colour.h"
#include "../localisation/localisation.h"
#include "drawing.h"

/* size: 0xA12 */
typedef struct {
    rct_string_id string_id;	// 0x00
    uint32 string_args_0;		// 0x02
    uint32 string_args_1;		// 0x06
    uint16 position;			// 0x0A
    uint16 mode;				// 0x0C
    uint32 id;					// 0x0E
    uint8 bitmap[64 * 8 * 5];	// 0x12
} rct_draw_scroll_text;

rct_draw_scroll_text *gDrawScrollTextList = RCT2_ADDRESS(RCT2_ADDRESS_DRAW_SCROLL_LIST, rct_draw_scroll_text);
uint8 *gCharacterBitmaps = RCT2_ADDRESS(RCT2_ADDRESS_CHARACTER_BITMAP, uint8);

void scrolling_text_set_bitmap_for_sprite(utf8 *text, int scroll, uint8 *bitmap, sint16 *scrollPositionOffsets);
void scrolling_text_set_bitmap_for_ttf(utf8 *text, int scroll, uint8 *bitmap, sint16 *scrollPositionOffsets);

void scrolling_text_initialise_bitmaps()
{
    uint8 drawingSurface[64];
    rct_drawpixelinfo dpi = {
        .bits = (uint8 *)&drawingSurface,
        .x = 0,
        .y = 0,
        .width = 8,
        .height = 8,
        .pitch = 0,
/**
 *
 *  rct2: 0x006DFED0
 */
static void sub_6DFED0()
{
	for (int i = 0; i < 56; i++)
		RCT2_ADDRESS(0x01357BD0, sint32)[i] = -1;
}
Example #14
0
/**
 * 
 * rct2: 0x006CB481
 */
rct_window *window_construction_open()
{
	//int eax, ebx, ecx, edx, esi, edi, ebp;
	//RCT2_CALLFUNC_X(0x006CB481, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
	//return (rct_window*)esi;

	int ride_id = RCT2_GLOBAL(0xF440A7, uint8);
	sub_6b2fa9(ride_id);

	rct_window *w;
	rct_ride* ride = GET_RIDE(ride_id);
	if (ride->type == RIDE_TYPE_MAZE){
		w = window_create(0, 29, 166, 200, (uint32*)window_construction_maze_events, WC_RIDE_CONSTRUCTION, WF_9);

		w->widgets = (rct_widget*)0x9D7D04;
		w->enabled_widgets = 0x6F0001C4;

		window_init_scroll_widgets(w);

		w->colours[0] = 24;
		w->colours[1] = 24;
		w->colours[2] = 24;

		w->number = ride_id;

		window_push_others_right(w);
		show_gridlines();
		return w;
	}

	w = window_create(0, 29, 166, 394, (uint32*)window_construction_events, WC_RIDE_CONSTRUCTION, WF_9);

	w->widgets = (rct_widget*)0x9D7A90;
	w->enabled_widgets = 0x67EFFFFFC4;

	window_init_scroll_widgets(w);

	w->colours[0] = 24;
	w->colours[1] = 24;
	w->colours[2] = 24;

	w->number = ride_id;

	window_push_others_right(w);
	show_gridlines();

	RCT2_GLOBAL(0xF44070, uint32) = 0x80000000;
	RCT2_GLOBAL(0xF440CD, uint8) = 8;
	RCT2_GLOBAL(0xF440CE, uint8) = 18;
	RCT2_GLOBAL(0xF440CF, uint8) = 4;

	if (ride->type == RIDE_TYPE_REVERSE_FREEFALL_COASTER){
		RCT2_GLOBAL(0xF440CE, uint8) = 30;
	}

	if (ride->type == RIDE_TYPE_AIR_POWERED_VERTICAL_COASTER){
		RCT2_GLOBAL(0xF440CE, uint8) = 30;
	}

	RCT2_GLOBAL(0xF440A0,uint16) = RCT2_ADDRESS(0x0097CC68, uint8)[ride->type * 2] | 0x100;
	RCT2_GLOBAL(0x00F440B2, uint8) = 0;
	RCT2_GLOBAL(0x00F440B3, uint8) = 0;
	RCT2_GLOBAL(0x00F440B4, uint8) = 0;
	RCT2_GLOBAL(0x00F440B5, uint8) = 0;

	if (RCT2_ADDRESS(0x0097D4F2, uint16)[ride->type * 4] & 0x8000)
		RCT2_GLOBAL(0x00F440B5, uint8) |= 2;

	RCT2_GLOBAL(0x00F440B6, uint8) = 0;
	RCT2_GLOBAL(0x00F440B7, uint8) = 0;

	RCT2_GLOBAL(0x00F440AE, uint8) = 0;
	RCT2_GLOBAL(0x00F440A6, uint8) = 4;
	RCT2_GLOBAL(0x00F440B0, uint8) = 0;
	RCT2_GLOBAL(0x00F440B1, uint8) = 0;
	RCT2_GLOBAL(0x00F44159, uint8) = 0;
	RCT2_GLOBAL(0x00F4415C, uint8) = 0;
	return w;
}
Example #15
0
	ride_init_all();
	window_guest_list_init_vars_a();
	sub_6BD3A4();// RCT2_CALLPROC_EBPSAFE(0x006BD3A4); //Peep?
	map_init();
	park_init();
	RCT2_CALLPROC_EBPSAFE(0x0066B5C0); // 0x0066B5C0 (part of 0x0066B3E8) screen_game_create_windows()
	date_reset();
	climate_reset(CLIMATE_COOL_AND_WET);
	RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
	window_new_ride_init_vars();
	window_guest_list_init_vars_b();
	window_staff_init_vars();

	title_load();

	gfx_clear(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 10);
	RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) = gGeneral_config.play_intro ? 8 : 255;
}

// rct2: 0x00683499
void rct2_init_directories()
{
	// check install directory
	if ( !osinterface_directory_exists(gGeneral_config.game_path) ) {
		osinterface_show_messagebox("Invalid RCT2 installation path. Please correct in config.ini.");
		exit(-1);
	}

	strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char), gGeneral_config.game_path);

	strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
Example #16
0
/**
 *
 *  rct2: 0x006CF387
 */
static void window_track_list_paint()
{
	rct_window *w;
	rct_drawpixelinfo *dpi;
	rct_widget *widget;
	rct_track_design *trackDesign = NULL;
	uint8 *image, *trackDesignList = RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, uint8);
	uint16 holes, speed, drops, dropHeight, inversions;
	fixed32_2dp rating;
	int trackIndex, x, y, colour, gForces, airTime;
	rct_g1_element tmpElement, *subsituteElement;

	window_paint_get_registers(w, dpi);

	window_draw_widgets(w, dpi);

	trackIndex = w->track_list.var_482;
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
		if (*trackDesignList == 0 || trackIndex == -1)
			return;
	} else if (trackIndex-- == 0) {
		return;
	}

	// Track preview
	widget = &window_track_list_widgets[WIDX_TRACK_PREVIEW];
	x = w->x + widget->left + 1;
	y = w->y + widget->top + 1;
	colour = RCT2_GLOBAL(0x0141FC44 + (w->colours[0] * 8), uint8);
	gfx_fill_rect(dpi, x, y, x + 369, y + 216, colour);

	trackDesign = track_get_info(trackIndex, &image);
	if (trackDesign == NULL)
		return;

	rct_track_td6* track_td6 = &trackDesign->track_td6;

	subsituteElement = &g1Elements[0];
	tmpElement = *subsituteElement;
	subsituteElement->offset = image;
	subsituteElement->width = 370;
	subsituteElement->height = 217;
	subsituteElement->x_offset = 0;
	subsituteElement->y_offset = 0;
	subsituteElement->flags = G1_FLAG_BMP;
	gfx_draw_sprite(dpi, 0, x, y, 0);
	*subsituteElement = tmpElement;

	x = w->x + (widget->left + widget->right) / 2;
	y = w->y + widget->bottom - 12;

	RCT2_GLOBAL(0x00F44153, uint8) = 0;
	// Warnings
	if ((track_td6->track_flags & 4) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER)) {
		// Vehicle design not available
		gfx_draw_string_centred_clipped(dpi, STR_VEHICLE_DESIGN_UNAVAILABLE, NULL, 0, x, y, 368);
		y -= 10;
	}

	if (track_td6->track_flags & 1) {
		RCT2_GLOBAL(0x00F44153, uint8) = 1;
		if (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_SCENERY_TOGGLE, uint8) == 0) {
			// Scenery not available
			gfx_draw_string_centred_clipped(dpi, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, NULL, 0, x, y, 368);
			y -= 10;
		}
	}

	// Track design name
	window_track_list_format_name((char*)0x009BC677, trackDesignList + (trackIndex * 128), FORMAT_WINDOW_COLOUR_1, 1);
	gfx_draw_string_centred_clipped(dpi, 3165, NULL, 0, x, y, 368);

	// Information
	x = w->x + widget->left + 1;
	y = w->y + widget->bottom + 2;

	if (track_td6->var_6C & 0x80000000) {
		// Six flags logo
		gfx_draw_sprite(dpi, SPR_SIX_FLAGS, w->x + widget->right - 50, y + 4, 0);
	}

	// Stats
	rating = track_td6->excitement * 10;
	gfx_draw_string_left(dpi, STR_TRACK_LIST_EXCITEMENT_RATING, &rating, 0, x, y);
	y += 10;

	rating = track_td6->intensity * 10;
	gfx_draw_string_left(dpi, STR_TRACK_LIST_INTENSITY_RATING, &rating, 0, x, y);
	y += 10;

	rating = track_td6->nausea * 10;
	gfx_draw_string_left(dpi, STR_TRACK_LIST_NAUSEA_RATING, &rating, 0, x, y);
	y += 14;

	if (track_td6->type != RIDE_TYPE_MAZE) {
		if (track_td6->type == RIDE_TYPE_MINI_GOLF) {
			// Holes
			holes = track_td6->holes & 0x1F;
			gfx_draw_string_left(dpi, STR_HOLES, &holes, 0, x, y);
			y += 10;
		} else {
			// Maximum speed
			speed = ((track_td6->max_speed << 16) * 9) >> 18;
			gfx_draw_string_left(dpi, STR_MAX_SPEED, &speed, 0, x, y);
			y += 10;

			// Average speed
			speed = ((track_td6->average_speed << 16) * 9) >> 18;
			gfx_draw_string_left(dpi, STR_AVERAGE_SPEED, &speed, 0, x, y);
			y += 10;
		}

		// Ride length
		RCT2_GLOBAL(0x013CE952 + 0, uint16) = 1345;
		RCT2_GLOBAL(0x013CE952 + 2, uint16) = track_td6->ride_length;
		gfx_draw_string_left_clipped(dpi, STR_TRACK_LIST_RIDE_LENGTH, (void*)0x013CE952, 0, x, y, 214);
		y += 10;
	}

	if (ride_type_has_flag(track_td6->type, RIDE_TYPE_FLAG_HAS_G_FORCES)) {
		// Maximum positive vertical Gs
		gForces = track_td6->max_positive_vertical_g * 32;
		gfx_draw_string_left(dpi, STR_MAX_POSITIVE_VERTICAL_G, &gForces, 0, x, y);
		y += 10;

		// Maximum negative verical Gs
		gForces = track_td6->max_negative_vertical_g * 32;
		gfx_draw_string_left(dpi, STR_MAX_NEGATIVE_VERTICAL_G, &gForces, 0, x, y);
		y += 10;

		// Maximum lateral Gs
		gForces = track_td6->max_lateral_g * 32;
		gfx_draw_string_left(dpi, STR_MAX_LATERAL_G, &gForces, 0, x, y);
		y += 10;

		// If .TD6
		if (track_td6->version_and_colour_scheme / 4 >= 2) {
			if (track_td6->total_air_time != 0) {
				// Total air time
				airTime = track_td6->total_air_time * 25;
				gfx_draw_string_left(dpi, STR_TOTAL_AIR_TIME, &airTime, 0, x, y);
				y += 10;
			}
		}
	}
	
	if (ride_type_has_flag(track_td6->type, RIDE_TYPE_FLAG_HAS_DROPS)) {
		// Drops
		drops = track_td6->drops & 0x3F;
		gfx_draw_string_left(dpi, STR_DROPS, &drops, 0, x, y);
		y += 10;

		// Drop height is multiplied by 0.75
		dropHeight = (track_td6->highest_drop_height + (track_td6->highest_drop_height / 2)) / 2;
		gfx_draw_string_left(dpi, STR_HIGHEST_DROP_HEIGHT, &drops, 0, x, y);
		y += 10;
	}

	if (track_td6->type != RIDE_TYPE_MINI_GOLF) {
		inversions = track_td6->inversions & 0x1F;
		if (inversions != 0) {
			// Inversions
			gfx_draw_string_left(dpi, STR_INVERSIONS, &inversions, 0, x, y);
			y += 10;
		}
	}
	y += 4;

	if (track_td6->space_required_x != 0xFF) {
		// Space required
		RCT2_GLOBAL(0x013CE952 + 0, uint16) = track_td6->space_required_x;
		RCT2_GLOBAL(0x013CE952 + 2, uint16) = track_td6->space_required_y;
		gfx_draw_string_left(dpi, STR_TRACK_LIST_SPACE_REQUIRED, (void*)0x013CE952, 0, x, y);
		y += 10;
	}

	if (track_td6->cost != 0) {
		gfx_draw_string_left(dpi, STR_TRACK_LIST_COST_AROUND, &track_td6->cost, 0, x, y);
		y += 14;
	}
}
Example #17
0
#include "audio.h"
#include "gfx.h"
#include "osinterface.h"
#include "rct2.h"
#include "widget.h"
#include "window.h"
#include "viewport.h"
#include "sprite.h"

#define RCT2_FIRST_WINDOW		(RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window))
#define RCT2_LAST_WINDOW		(RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*) - 1)
#define RCT2_NEW_WINDOW			(RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*))

#define MAX_NUMBER_WINDOWS 11

rct_window* g_window_list = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window);

static void window_all_wheel_input();
static int window_draw_split(rct_window *w, int left, int top, int right, int bottom);

int window_get_widget_index(rct_window *w, rct_widget *widget)
{
	rct_widget *widget2;

	int i = 0;
	for (widget2 = w->widgets; widget2->type != WWT_LAST; widget2++, i++)
		if (widget == widget2)
			return i;
	return -1;
}
Example #18
0
/**
 *
 *  rct2: 0x006CF8CD
 */
static void window_track_list_scrollpaint()
{
	rct_window *w;
	rct_drawpixelinfo *dpi;
	rct_string_id stringId, stringId2;
	int i, x, y, colour;
	uint8 *trackDesignItem, *trackDesignList = RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, uint8);

	window_paint_get_registers(w, dpi);

	colour = RCT2_GLOBAL(0x00141FC48 + (w->colours[0] * 8), uint8);
	colour = (colour << 24) | (colour << 16) | (colour << 8) | colour;
	gfx_clear(dpi, colour);

	i = 0;
	x = 0;
	y = 0;

	trackDesignItem = trackDesignList;
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
		if (*trackDesignItem == 0) {
			// No track designs
			gfx_draw_string_left(dpi, STR_NO_TRACK_DESIGNS_OF_THIS_TYPE, NULL, 0, x, y - 1);
			return;
		}
	} else {
		// Build custom track item
		if (i == w->track_list.var_482) {
			// Highlight
			gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
			stringId = 1193;
		} else {
			stringId = 1191;
		}

		stringId2 = STR_BUILD_CUSTOM_DESIGN;
		gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
		y += 10;
		i++;
	}

	while (*trackDesignItem != 0) {
		if (y + 10 >= dpi->y && y < dpi->y + dpi->height) {
			if (i == w->track_list.var_482) {
				// Highlight
				gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
				stringId = 1193;
			} else {
				stringId = 1191;
			}

			// Draw track name
			window_track_list_format_name((char *)language_get_string(3165), trackDesignItem, 0, 1);
			stringId2 = 3165;
			gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
		}
		y += 10;
		i++;
		trackDesignItem += 128;
	}
}
Example #19
0
/**
 * 
 *  rct2: 0x00683D20
 */
int screenshot_dump_bmp()
{
	BitmapFileHeader header;
	BitmapInfoHeader info;

	int i, y, index, width, height, stride;
	char *buffer, path[MAX_PATH], *row;
	FILE *fp;
	unsigned int bytesWritten;

	// Get a free screenshot path
	if ((index = screenshot_get_next_path(path, ".bmp")) == -1)
		return -1;

	// Open binary file for writing
	if ((fp = fopen(path, "wb")) == NULL){
		return -1;
	}

	// Allocate buffer
	buffer = malloc(0xFFFF);
	if (buffer == NULL) {
		//CloseHandle(hFile);
		fclose(fp);
		return -1;
	}

	// Get image size
	width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
	height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
	stride = (width + 3) & 0xFFFFFFFC;

	// File header
	memset(&header, 0, sizeof(header));
	header.bfType = 0x4D42;
	header.bfSize = height * stride + 1038;
	header.bfOffBits = 1038;

	bytesWritten = fwrite(&header, sizeof(BitmapFileHeader), 1, fp);
	if (bytesWritten != 1) {
		fclose(fp);
		free(buffer);
	}

	// Info header
	memset(&info, 0, sizeof(info));
	info.biSize = sizeof(info);
	info.biWidth = width;
	info.biHeight = height;
	info.biPlanes = 1;
	info.biBitCount = 8;
	info.biXPelsPerMeter = 2520;
	info.biYPelsPerMeter = 2520;
	info.biClrUsed = 246;

	bytesWritten=fwrite(&info, sizeof(BitmapInfoHeader), 1, fp); 
	if (bytesWritten != 1) {
		fclose(fp);
		free(buffer);
	}

	// Palette
	memset(buffer, 0, 246 * 4);
	for (i = 0; i < 246; i++) {
		buffer[i * 4 + 0] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 0];
		buffer[i * 4 + 1] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 1];
		buffer[i * 4 + 2] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 2];
	}

	bytesWritten = fwrite(buffer, sizeof(char), 246*4,  fp);
	if (bytesWritten != 246*4){
		fclose(fp);
		free(buffer);
	}

	// Image, save upside down
	rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
	for (y = dpi->height - 1; y >= 0; y--) {
		row = dpi->bits + y * (dpi->width + dpi->pitch);

		memset(buffer, 0, stride);
		memcpy(buffer, row, dpi->width);

		bytesWritten=fwrite(buffer, sizeof(char), stride, fp);
		if (bytesWritten != stride){
			fclose(fp);
			free(buffer);
		}
	}

	fclose(fp);
	free(buffer);

	return index;
}
/**
 * 
 *  rct2: 0x006AAB56
 */
static void window_editor_object_selection_paint()
{
	int i, x, y, width, numSelected, totalSelectable, type;
	rct_window *w;
	rct_drawpixelinfo *dpi;
	rct_widget *widget;
	rct_object_entry *highlightedEntry;
	rct_string_id stringId;
	uint8 *text, source;
	char *datName, *name, *stringBuffer;

	window_paint_get_registers(w, dpi);

	/*if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
		gfx_fill_rect_inset(dpi,
			w->x + w->widgets[WIDX_FILTER_RIDE_TAB_ALL].left - 1,
			w->y + w->widgets[WIDX_FILTER_RIDE_TAB_ALL].bottom,
			w->x + w->widgets[WIDX_FILTER_RIDE_TAB_STALL].right + 1,
			w->y + w->widgets[WIDX_FILTER_RIDE_TAB_ALL].bottom + 2,
			w->colours[1],
			0x10
			);
	}*/

	window_draw_widgets(w, dpi);

	// Draw tabs
	for (i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) {
		widget = &w->widgets[WIDX_TAB_1 + i];
		if (widget->type == WWT_EMPTY)
			continue;

		x = w->x + widget->left;
		y = w->y + widget->top;
		gfx_draw_sprite(dpi, 5458 + i, x, y, 0);
	}

	const int ride_tabs[] = { 5458, 0x200015A1, 5542, 0x200015AA, 5557 + 5, 5551, 5530, 5327 };

	// Draw ride tabs
	if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
		for (i = 0; i < 7; i++) {
		widget = &w->widgets[WIDX_FILTER_RIDE_TAB_ALL + i];
			if (widget->type == WWT_EMPTY)
				continue;

			x = w->x + widget->left;
			y = w->y + widget->top;
			gfx_draw_sprite(dpi, ride_tabs[i] | (w->colours[1] << 19), x, y, 0);
		}

	}

	// Preview background
	widget = &w->widgets[WIDX_PREVIEW];
	gfx_fill_rect(
		dpi,
		w->x + widget->left + 1,
		w->y + widget->top + 1,
		w->x + widget->right - 1,
		w->y + widget->bottom - 1,
		RCT2_ADDRESS(0x0141FC44, uint8)[w->colours[1] * 8]
	);

	// Draw number of selected items
	if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER)) {
		x = w->x + 3;
		y = w->y + w->height - 13;

		numSelected = RCT2_ADDRESS(0x00F433F7, uint16)[w->selected_tab];
		totalSelectable = object_entry_group_counts[w->selected_tab];
		if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER)
			totalSelectable = 4;

		RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = numSelected;
		RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint16) = totalSelectable;
		gfx_draw_string_left(dpi, 3164, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y);
	}

	rct_stex_entry* stex_entry = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TEXT_TEMP_CHUNK, rct_stex_entry*);

	/*gfx_fill_rect_inset(dpi,
		w->x + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].left,
		w->y + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].top,
		w->x + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].right,
		w->y + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].bottom,
		w->colours[1],
		0x30
		);

	RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&_filter_string;
	gfx_draw_string_left_clipped(
		dpi,
		1170,
		(void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS,
		w->colours[1],
		w->x + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].left + 1,
		w->y + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].top,
		w->x + window_editor_object_selection_widgets[WIDX_FILTER_STRING_BUTTON].right
		);*/

	if (w->selected_list_item == -1 || stex_entry == NULL)
		return;

	highlightedEntry = (rct_object_entry*)w->var_494;
	type = highlightedEntry->flags & 0x0F;

	// Draw preview
	widget = &w->widgets[WIDX_PREVIEW];
	x = w->x + (widget->left + widget->right) / 2 + 1;
	y = w->y + (widget->top + widget->bottom) / 2 + 1;
	object_paint(type, 3, type, x, y, 0, (int)dpi, (int)stex_entry);

	// Draw name of object
	x = w->x + (widget->left + widget->right) / 2 + 1;
	y = w->y + widget->bottom + 3;
	width = w->width - w->widgets[WIDX_LIST].right - 6;

	// Skip object dat name
	text = (char*)(highlightedEntry + 1);
	datName = text;
	do {
		text++;
	} while (*(text - 1) != 0);
	text += 4;
	name = text;

	RCT2_GLOBAL(0x009BC677, uint8) = 14;

	stringId = 3165;
	stringBuffer = (char*)language_get_string(3165) + 1;
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) {
		// Skip name
		do {
			text++;
		} while (*(text - 1) != 0);
		text += 4;
		text += *text * 16 + 1;
		text += *text * 16 + 1;

		if (RCT2_GLOBAL(text, uint32) & 0x1000000) {
			strcpy(stringBuffer, name);
		} else {
			int eax = *text;
			if (*text == 0xFF) {
				eax = *(text + 1);
				if (*(text + 1) == 0xFF)
					eax = *(text + 2);
			}
			format_string(stringBuffer, eax + 2, NULL);
		}
	} else {
		strcpy(stringBuffer, name);
	}
	gfx_draw_string_centred_clipped(dpi, stringId, NULL, 0, x, y, width);
	
	// Draw description of object
	x = w->x + w->widgets[WIDX_LIST].right + 4;
	y += 15;
	object_paint(type, 259, type, x, y, (int)w, (int)dpi, (int)stex_entry);

	// Draw object source
	source = (highlightedEntry->flags & 0xF0) >> 4;
	switch (source) {
	case 8: stringId = 2741; break;
	case 1: stringId = 5262; break;
	case 2: stringId = 5263; break;
	default: stringId = 5264; break;
	}
	gfx_draw_string_right(dpi, stringId, NULL, 2, w->x + w->width - 5, w->y + w->height - 3 - 12 - 14);

	// 
	if (w->selected_tab == WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS) {
		y = w->y + w->height - 3 - 12 - 14 - 14;

		rct_ride_type *rideType = (rct_ride_type*)stex_entry;
		for (int i = 0; i < 3; i++) {
			if (rideType->ride_type[i] == 255)
				continue;

			stringId = 2 + rideType->ride_type[i];
			gfx_draw_string_right(dpi, stringId, NULL, 2, w->x + w->width - 5, y);
			y -= 11;
		}
	}

	//stringId = highlightedEntry->checksum
	// gfx_draw_string_right(dpi, stringId, NULL, 2, w->x + w->width - 5, w->y + w->height - 3 - 12 - 14);

	// Draw object dat name
	stringId = 3165;
	strcpy(stringBuffer, datName);
	gfx_draw_string_right(dpi, stringId, NULL, 0, w->x + w->width - 5, w->y + w->height - 3 - 12);
}