示例#1
0
static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *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];
	safe_strcpy(wrapped_string, text_input, 512);

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

	int cursorX, cursorY;
	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_size(wrap_pointer) - 1;

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

			int width = 6;
			if ((uint32)gTextInput.selection_offset < 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[gTextInput.selection_offset];
				width = max(gfx_get_string_width(temp_string) - 2, 4);
			}

			if (w->frame_no > 15){
				uint8 colour = ColourMapA[w->colours[1]].mid_light;
				gfx_fill_rect(dpi, cursorX, y + 9, cursorX + 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;
	}

	if (!cur_drawn) {
		cursorX = gLastDrawStringX;
		cursorY = y - 10;
	}

	// IME composition
	if (gTextInputCompositionActive) {
		int compositionWidth = gfx_get_string_width(gTextInputComposition);
		int x = cursorX - (compositionWidth / 2);
		int y = cursorY + 13;
		int w = compositionWidth;
		int h = 10;

		gfx_fill_rect(dpi, x - 1, y - 1, x + w + 1, y + h + 1, 12);
		gfx_fill_rect(dpi, x, y, x + w, y + h, 0);
		gfx_draw_string(dpi, gTextInputComposition, 12, x, y);
	}
}
示例#2
0
void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
{
    if (!chat_available())
    {
        gChatOpen = false;
        return;
    }

    _chatLeft = 10;
    _chatRight = std::min((context_get_width() - 10), CHAT_MAX_WINDOW_WIDTH);
    _chatWidth = _chatRight - _chatLeft;
    _chatBottom = context_get_height() - 45;
    _chatTop = _chatBottom - 10;

    char lineBuffer[CHAT_INPUT_SIZE + 10];
    char* lineCh = lineBuffer;
    char* inputLine = _chatCurrentLine;
    int32_t inputLineHeight = 10;

    // Draw chat window
    if (gChatOpen)
    {
        inputLineHeight = chat_string_wrapped_get_height((void*)&inputLine, _chatWidth - 10);
        _chatTop -= inputLineHeight;

        for (int32_t i = 0; i < CHAT_HISTORY_SIZE; i++)
        {
            if (strlen(chat_history_get(i)) == 0)
            {
                continue;
            }

            safe_strcpy(lineBuffer, chat_history_get(i), sizeof(lineBuffer));

            int32_t lineHeight = chat_string_wrapped_get_height((void*)&lineCh, _chatWidth - 10);
            _chatTop -= (lineHeight + 5);
        }

        _chatHeight = _chatBottom - _chatTop;

        if (_chatTop < 50)
        {
            _chatTop = 50;
        }
        else if (_chatHeight < 150)
        { // Min height
            _chatTop = _chatBottom - 150;
            _chatHeight = 150;
        }

        gfx_set_dirty_blocks(_chatLeft, _chatTop - 5, _chatRight, _chatBottom + 5);             // Background area + Textbox
        gfx_filter_rect(dpi, _chatLeft, _chatTop - 5, _chatRight, _chatBottom + 5, PALETTE_51); // Opaque gray background
        gfx_fill_rect_inset(
            dpi, _chatLeft, _chatTop - 5, _chatRight, _chatBottom + 5, chatBackgroundColor, INSET_RECT_FLAG_FILL_NONE);
        gfx_fill_rect_inset(
            dpi, _chatLeft + 1, _chatTop - 4, _chatRight - 1, _chatBottom - inputLineHeight - 6, chatBackgroundColor,
            INSET_RECT_FLAG_BORDER_INSET);
        gfx_fill_rect_inset(
            dpi, _chatLeft + 1, _chatBottom - inputLineHeight - 5, _chatRight - 1, _chatBottom + 4, chatBackgroundColor,
            INSET_RECT_FLAG_BORDER_INSET); // Textbox
    }

    int32_t x = _chatLeft + 5;
    int32_t y = _chatBottom - inputLineHeight - 20;
    int32_t stringHeight = 0;

    // Draw chat history
    for (int32_t i = 0; i < CHAT_HISTORY_SIZE; i++, y -= stringHeight)
    {
        uint32_t expireTime = chat_history_get_time(i) + 10000;
        if (!gChatOpen && platform_get_ticks() > expireTime)
        {
            break;
        }

        safe_strcpy(lineBuffer, chat_history_get(i), sizeof(lineBuffer));

        stringHeight = chat_history_draw_string(dpi, (void*)&lineCh, x, y, _chatWidth - 10) + 5;
        gfx_set_dirty_blocks(x, y - stringHeight, x + _chatWidth, y + 20);

        if ((y - stringHeight) < 50)
        {
            break;
        }
    }

    // Draw current chat input
    if (gChatOpen)
    {
        lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE);
        lineCh = utf8_write_codepoint(lineCh, FORMAT_CELADON);

        safe_strcpy(lineCh, _chatCurrentLine, sizeof(_chatCurrentLine));
        y = _chatBottom - inputLineHeight - 5;

        lineCh = lineBuffer;
        inputLineHeight = gfx_draw_string_left_wrapped(
            dpi, (void*)&lineCh, x, y + 3, _chatWidth - 10, STR_STRING, TEXT_COLOUR_255);
        gfx_set_dirty_blocks(x, y, x + _chatWidth, y + inputLineHeight + 15);

        // TODO: Show caret if the input text has multiple lines
        if (_chatCaretTicks < 15 && gfx_get_string_width(lineBuffer) < (_chatWidth - 10))
        {
            std::memcpy(lineBuffer, _chatCurrentLine, _chatTextInputSession->SelectionStart);
            lineBuffer[_chatTextInputSession->SelectionStart] = 0;
            int32_t caretX = x + gfx_get_string_width(lineBuffer);
            int32_t caretY = y + 14;

            gfx_fill_rect(dpi, caretX, caretY, caretX + 6, caretY + 1, PALETTE_INDEX_56);
        }
    }
}
示例#3
0
static bool window_changelog_read_file()
{
	window_changelog_dispose_file();
	utf8 path[MAX_PATH];
	safe_strcpy(path, gExePath, MAX_PATH);
	safe_strcat_path(path, "changelog.txt", MAX_PATH);
	if (!readentirefile(path, (void**)&_changelogText, &_changelogTextSize)) {
		log_error("Unable to read changelog.txt");
		return false;
	}
	void* new_memory = realloc(_changelogText, _changelogTextSize + 1);
	if (new_memory == NULL) {
		log_error("Failed to reallocate memory for changelog text");
		return false;
	}
	_changelogText = (char*)new_memory;
	_changelogText[_changelogTextSize++] = 0;

	char *start = _changelogText;
	if (_changelogTextSize >= 3 && utf8_is_bom(_changelogText))
		start += 3;

	sint32 changelogLinesCapacity = 8;
	_changelogLines = malloc(changelogLinesCapacity * sizeof(char*));
	_changelogLines[0] = start;
	_changelogNumLines = 1;

	char *ch = start;
	while (*ch != 0) {
		uint8 c = *ch;
		if (c == '\n') {
			*ch++ = 0;
			_changelogNumLines++;
			if (_changelogNumLines > changelogLinesCapacity) {
				changelogLinesCapacity *= 2;
				new_memory = realloc(_changelogLines, changelogLinesCapacity * sizeof(char*));
				if (new_memory == NULL) {
					log_error("Failed to reallocate memory for change log lines");
					return false;
				}
				_changelogLines = (char**)new_memory;
			}
			_changelogLines[_changelogNumLines - 1] = ch;
		} else if (c < 32 || c > 122) {
			// A character that won't be drawn or change state.
			*ch++ = FORMAT_OUTLINE_OFF;
		} else {
			ch++;
		}
	}

	new_memory = realloc(_changelogLines, _changelogNumLines * sizeof(char*));
	if (new_memory == NULL) {
		log_error("Failed to reallocate memory for change log lines");
		return false;
	}
	_changelogLines = (char**)new_memory;

	gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
	_changelogLongestLineWidth = 0;
	for (sint32 i = 0; i < _changelogNumLines; i++) {
		sint32 width = gfx_get_string_width(_changelogLines[i]);
		_changelogLongestLineWidth = max(width, _changelogLongestLineWidth);
	}
	return true;
}
示例#4
0
void console_draw(rct_drawpixelinfo *dpi)
{
	if (!gConsoleOpen)
		return;
	int lines = 0;
	int maxLines = ((_consoleBottom - 22 - _consoleTop) / 10) - 1;
	char *ch = strchr(_consoleBuffer, 0);
	while (ch > _consoleBuffer) {
		ch--;
		if (*ch == '\n')
			lines++;
	}

	// Set font
	RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = (gConfigInterface.console_small_font ? 0 : 224);
	RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;

	// Background
	gfx_fill_rect(dpi, _consoleLeft, _consoleTop, _consoleRight, _consoleBottom, 10);

	int x = _consoleLeft + 4;
	int y = _consoleTop + 4;
	
	// Draw previous lines
	char lineBuffer[1 + 256];
	ch = _consoleViewBufferStart;
	int currentLine = 0;
	int drawLines = 0;
	while (*ch != 0) {
		// Find line break or null terminator
		char *nextLine = ch;
		while (*nextLine != 0 && *nextLine != '\n') {
			nextLine++;
		}

		currentLine++;
		if (currentLine < (lines - maxLines + 4) - _consoleScrollPos) {
			if (*nextLine == '\n') {
				ch = nextLine + 1;
				x = _consoleLeft + 4;
				//y += 10;
			}
			else {
				break;
			}
			continue;
		}

		if (drawLines >= maxLines)
			break;
		drawLines++;

		int lineLength = min(sizeof(lineBuffer) - 1, nextLine - ch);
		strncpy(lineBuffer + 1, ch, lineLength);
		lineBuffer[0] = FORMAT_GREEN;
		lineBuffer[1 + lineLength] = 0;

		gfx_draw_string(dpi, lineBuffer, 255, x, y);

		x = gLastDrawStringX;

		if (*nextLine == '\n') {
			ch = nextLine + 1;
			x = _consoleLeft + 4;
			y += 10;
		} else {
			break;
		}
	}
	x = _consoleLeft + 4;
	y = _consoleBottom - 15;
	// Draw current line
	strcpy(lineBuffer + 1, _consoleCurrentLine);
	lineBuffer[0] = FORMAT_GREEN;
	gfx_draw_string(dpi, lineBuffer, 255, x, y);

	// Draw caret
	if (_consoleCaretTicks < 15) {
		memcpy(lineBuffer, _consoleCurrentLine, gTextInputCursorPosition);
		lineBuffer[gTextInputCursorPosition] = 0;
		int caretX = x + gfx_get_string_width(lineBuffer);
		int caretY = y + 10;

		gfx_fill_rect(dpi, caretX, caretY, caretX + 6, caretY + 1, FORMAT_GREEN);
	}
	gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 21, _consoleRight, _consoleBottom - 21, 14);
	gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 20, _consoleRight, _consoleBottom - 20, 11);

	gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 1, _consoleRight, _consoleBottom - 1, 14);
	gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 0, _consoleRight, _consoleBottom - 0, 12);
}
示例#5
0
static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
{
	window_draw_widgets(w, dpi);

	sint32 y = w->y + 25;

	sint32 no_lines = 0;
	sint32 font_height = 0;


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

	y += 25;

	gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
	gCurrentFontFlags = 0;

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

	// 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], INSET_RECT_F_60);

	y += 1;

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

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

		size_t string_length = get_string_size(wrap_pointer) - 1;

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

			sint32 width = 6;
			if (gTextInput.selection_offset < strlen(text_input)){
				// Make a 1 utf8-character wide string for measuring the width
				// of the currently selected character.
				utf8 tmp[5] = { 0 }; // This is easier than setting temp_string[0..5]
				uint32 codepoint = utf8_get_next(text_input + gTextInput.selection_offset, NULL);
				utf8_write_codepoint(tmp, codepoint);
				width = max(gfx_get_string_width(tmp) - 2, 4);
			}

			if (w->frame_no > 15){
				uint8 colour = ColourMapA[w->colours[1]].mid_light;
				gfx_fill_rect(dpi, cursorX, y + 9, cursorX + 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;
	}

	if (!cur_drawn) {
		cursorX = gLastDrawStringX;
		cursorY = y - 10;
	}

	// IME composition
	if (gTextInputCompositionActive) {
		draw_ime_composition(dpi, cursorX, cursorY);
	}
}
示例#6
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;
	}
}
示例#7
0
static void widget_text_box_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    sint32 no_lines = 0;
    sint32 font_height = 0;
    char wrapped_string[TEXT_INPUT_SIZE];

    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

    // Resolve the absolute ltrb
    sint32 l = w->x + widget->left;
    sint32 t = w->y + widget->top;
    sint32 r = w->x + widget->right;
    sint32 b = w->y + widget->bottom;

    // Get the colour
    uint8 colour = w->colours[widget->colour];

    bool active = w->classification == gCurrentTextBox.window.classification &&
        w->number == gCurrentTextBox.window.number &&
        widgetIndex == gCurrentTextBox.widget_index;

    //gfx_fill_rect_inset(dpi, l, t, r, b, colour, 0x20 | (!active ? 0x40 : 0x00));
    gfx_fill_rect_inset(dpi, l, t, r, b, colour, INSET_RECT_F_60);

    gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
    gCurrentFontFlags = 0;

    if (!active || gTextInput == NULL) {

        if (w->widgets[widgetIndex].text != 0) {
            safe_strcpy(wrapped_string, w->widgets[widgetIndex].string, 512);
            gfx_wrap_string(wrapped_string, r - l - 5, &no_lines, &font_height);
            gfx_draw_string(dpi, wrapped_string, w->colours[1], l + 2, t);
        }
        return;
    }


    safe_strcpy(wrapped_string, gTextBoxInput, TEXT_INPUT_SIZE);

    // String length needs to add 12 either side of box
    // +13 for cursor when max length.
    gfx_wrap_string(wrapped_string, r - l - 5 - 6, &no_lines, &font_height);


    gfx_draw_string(dpi, wrapped_string, w->colours[1], l + 2, t);


    size_t string_length = get_string_size(wrapped_string) - 1;

    // Make a copy of the string for measuring the width.
    char temp_string[TEXT_INPUT_SIZE] = { 0 };
    memcpy(temp_string, wrapped_string, min(string_length, gTextInput->SelectionStart));
    sint32 cur_x = l + gfx_get_string_width(temp_string) + 3;

    sint32 width = 6;
    if ((uint32)gTextInput->SelectionStart < strlen(gTextBoxInput)){
        // 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] = gTextBoxInput[gTextInput->SelectionStart];
        width = max(gfx_get_string_width(temp_string) - 2, 4);
    }

    if (gTextBoxFrameNo <= 15){
        colour = ColourMapA[w->colours[1]].mid_light;
        gfx_fill_rect(dpi, cur_x, t + 9, cur_x + width, t + 9, colour + 5);
    }
}
示例#8
0
/**
 *
 *  rct2: 0x0066508C, 0x00665540
 */
static void ride_entrance_exit_paint(paint_session* session, uint8_t direction, int32_t height, const TileElement* tile_element)
{
    uint8_t is_exit = tile_element->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT;

    if (gTrackDesignSaveMode || (session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
    {
        if (tile_element->AsEntrance()->GetRideIndex() != gTrackDesignSaveRideIndex)
            return;
    }

#ifdef __ENABLE_LIGHTFX__
    if (lightfx_is_available())
    {
        if (!is_exit)
        {
            lightfx_add_3d_light_magic_from_drawing_tile(session->MapPosition, 0, 0, height + 45, LIGHTFX_LIGHT_TYPE_LANTERN_3);
        }

        switch (tile_element->GetDirection())
        {
            case 0:
                lightfx_add_3d_light_magic_from_drawing_tile(
                    session->MapPosition, 16, 0, height + 16, LIGHTFX_LIGHT_TYPE_LANTERN_2);
                break;
            case 1:
                lightfx_add_3d_light_magic_from_drawing_tile(
                    session->MapPosition, 0, -16, height + 16, LIGHTFX_LIGHT_TYPE_LANTERN_2);
                break;
            case 2:
                lightfx_add_3d_light_magic_from_drawing_tile(
                    session->MapPosition, -16, 0, height + 16, LIGHTFX_LIGHT_TYPE_LANTERN_2);
                break;
            case 3:
                lightfx_add_3d_light_magic_from_drawing_tile(
                    session->MapPosition, 0, 16, height + 16, LIGHTFX_LIGHT_TYPE_LANTERN_2);
                break;
        };
    }
#endif

    Ride* ride = get_ride(tile_element->AsEntrance()->GetRideIndex());
    auto stationObj = ride_get_station_object(ride);
    if (stationObj == nullptr || stationObj->BaseImageId == 0)
    {
        return;
    }

    uint8_t colour_1, colour_2;
    uint32_t transparant_image_id = 0, image_id = 0;
    if (stationObj->Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)
    {
        colour_1 = GlassPaletteIds[ride->track_colour[0].main];
        transparant_image_id = (colour_1 << 19) | IMAGE_TYPE_TRANSPARENT;
    }

    colour_1 = ride->track_colour[0].main;
    colour_2 = ride->track_colour[0].additional;
    image_id = (colour_1 << 19) | (colour_2 << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS;

    session->InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
    _unk9E32BC = 0;

    if (tile_element->IsGhost())
    {
        session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
        image_id = CONSTRUCTION_MARKER;
        _unk9E32BC = image_id;
        if (transparant_image_id)
            transparant_image_id = image_id;
    }

    if (is_exit)
    {
        image_id |= stationObj->BaseImageId + direction + 8;
    }
    else
    {
        image_id |= stationObj->BaseImageId + direction;
    }

    // Format modified to stop repeated code

    // Each entrance is split into 2 images for drawing
    // Certain entrance styles have another 2 images to draw for coloured windows

    int8_t ah = is_exit ? 0x23 : 0x33;

    int16_t lengthY = (direction & 1) ? 28 : 2;
    int16_t lengthX = (direction & 1) ? 2 : 28;

    sub_98197C(session, image_id, 0, 0, lengthX, lengthY, ah, height, 2, 2, height);

    if (transparant_image_id)
    {
        if (is_exit)
        {
            transparant_image_id |= stationObj->BaseImageId + direction + 24;
        }
        else
        {
            transparant_image_id |= stationObj->BaseImageId + direction + 16;
        }

        sub_98199C(session, transparant_image_id, 0, 0, lengthX, lengthY, ah, height, 2, 2, height);
    }

    image_id += 4;

    sub_98197C(
        session, image_id, 0, 0, lengthX, lengthY, ah, height, (direction & 1) ? 28 : 2, (direction & 1) ? 2 : 28, height);

    if (transparant_image_id)
    {
        transparant_image_id += 4;
        sub_98199C(
            session, transparant_image_id, 0, 0, lengthX, lengthY, ah, height, (direction & 1) ? 28 : 2,
            (direction & 1) ? 2 : 28, height);
    }

    if (direction & 1)
    {
        paint_util_push_tunnel_right(session, height, TUNNEL_6);
    }
    else
    {
        paint_util_push_tunnel_left(session, height, TUNNEL_6);
    }

    if (!is_exit && !(tile_element->IsGhost()) && tile_element->AsEntrance()->GetRideIndex() != RIDE_ID_NULL
        && stationObj->ScrollingMode != SCROLLING_MODE_NONE)
    {
        set_format_arg(0, uint32_t, 0);
        set_format_arg(4, uint32_t, 0);

        rct_string_id string_id = STR_RIDE_ENTRANCE_CLOSED;

        if (ride->status == RIDE_STATUS_OPEN && !(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN))
        {
            set_format_arg(0, rct_string_id, ride->name);
            set_format_arg(2, uint32_t, ride->name_arguments);

            string_id = STR_RIDE_ENTRANCE_NAME;
        }

        utf8 entrance_string[256];
        if (gConfigGeneral.upper_case_banners)
        {
            format_string_to_upper(entrance_string, sizeof(entrance_string), string_id, gCommonFormatArgs);
        }
        else
        {
            format_string(entrance_string, sizeof(entrance_string), string_id, gCommonFormatArgs);
        }

        gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY;

        uint16_t string_width = gfx_get_string_width(entrance_string);
        uint16_t scroll = (gCurrentTicks / 2) % string_width;

        sub_98199C(
            session, scrolling_text_setup(session, string_id, scroll, stationObj->ScrollingMode), 0, 0, 0x1C, 0x1C, 0x33,
            height + stationObj->Height, 2, 2, height + stationObj->Height);
    }

    image_id = _unk9E32BC;
    if (image_id == 0)
    {
        image_id = SPRITE_ID_PALETTE_COLOUR_1(COLOUR_SATURATED_BROWN);
    }
    wooden_a_supports_paint_setup(session, direction & 1, 0, height, image_id, nullptr);

    paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);

    height += is_exit ? 40 : 56;
    paint_util_set_general_support_height(session, height, 0x20);
}
示例#9
0
/**
 *
 *  rct2: 0x006658ED
 */
static void park_entrance_paint(paint_session* session, uint8_t direction, int32_t height, const TileElement* tile_element)
{
    if (gTrackDesignSaveMode || (session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
        return;

#ifdef __ENABLE_LIGHTFX__
    if (lightfx_is_available())
    {
        lightfx_add_3d_light_magic_from_drawing_tile(session->MapPosition, 0, 0, 155, LIGHTFX_LIGHT_TYPE_LANTERN_3);
    }
#endif

    session->InteractionType = VIEWPORT_INTERACTION_ITEM_PARK;
    _unk9E32BC = 0;
    uint32_t image_id, ghost_id = 0;
    if (tile_element->IsGhost())
    {
        session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
        ghost_id = CONSTRUCTION_MARKER;
        _unk9E32BC = ghost_id;
    }

    // Index to which part of the entrance
    // Middle, left, right
    uint8_t part_index = tile_element->AsEntrance()->GetSequenceIndex();
    PathSurfaceEntry* path_entry = nullptr;

    // The left and right of the park entrance often have this set to 127.
    // So only attempt to get the footpath type if we're dealing with the middle bit of the entrance.
    if (part_index == 0)
        path_entry = get_path_surface_entry(tile_element->AsEntrance()->GetPathType());

    rct_entrance_type* entrance;
    uint8_t di = ((direction / 2 + part_index / 2) & 1) ? 0x1A : 0x20;

    switch (part_index)
    {
        case 0:
            if (path_entry != nullptr)
            {
                image_id = (path_entry->image + 5 * (1 + (direction & 1))) | ghost_id;
                sub_98197C(session, image_id, 0, 0, 32, 0x1C, 0, height, 0, 2, height);
            }

            entrance = (rct_entrance_type*)object_entry_get_chunk(OBJECT_TYPE_PARK_ENTRANCE, 0);
            if (entrance == nullptr)
            {
                return;
            }
            image_id = (entrance->image_id + direction * 3) | ghost_id;
            sub_98197C(session, image_id, 0, 0, 0x1C, 0x1C, 0x2F, height, 2, 2, height + 32);

            if ((direction + 1) & (1 << 1))
                break;
            if (ghost_id != 0)
                break;

            {
                rct_string_id park_text_id = STR_BANNER_TEXT_CLOSED;
                set_format_arg(0, uint32_t, 0);
                set_format_arg(4, uint32_t, 0);

                if (gParkFlags & PARK_FLAGS_PARK_OPEN)
                {
                    set_format_arg(0, rct_string_id, gParkName);
                    set_format_arg(2, uint32_t, gParkNameArgs);

                    park_text_id = STR_BANNER_TEXT_FORMAT;
                }

                utf8 park_name[256];
                if (gConfigGeneral.upper_case_banners)
                {
                    format_string_to_upper(park_name, sizeof(park_name), park_text_id, gCommonFormatArgs);
                }
                else
                {
                    format_string(park_name, sizeof(park_name), park_text_id, gCommonFormatArgs);
                }

                gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY;

                uint16_t string_width = gfx_get_string_width(park_name);
                uint16_t scroll = (gCurrentTicks / 2) % string_width;

                if (entrance->scrolling_mode == SCROLLING_MODE_NONE)
                    break;

                int32_t stsetup = scrolling_text_setup(session, park_text_id, scroll, entrance->scrolling_mode + direction / 2);
                int32_t text_height = height + entrance->text_height;
                sub_98199C(session, stsetup, 0, 0, 0x1C, 0x1C, 0x2F, text_height, 2, 2, text_height);
            }
            break;
        case 1:
        case 2:
            entrance = (rct_entrance_type*)object_entry_get_chunk(OBJECT_TYPE_PARK_ENTRANCE, 0);
            if (entrance == nullptr)
            {
                return;
            }
            image_id = (entrance->image_id + part_index + direction * 3) | ghost_id;
            sub_98197C(session, image_id, 0, 0, 0x1A, di, 0x4F, height, 3, 3, height);
            break;
    }

    image_id = ghost_id;
    if (image_id == 0)
    {
        image_id = SPRITE_ID_PALETTE_COLOUR_1(COLOUR_SATURATED_BROWN);
    }
    wooden_a_supports_paint_setup(session, direction & 1, 0, height, image_id, nullptr);

    paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
    paint_util_set_general_support_height(session, height + 80, 0x20);
}