Example #1
0
static void window_player_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w)
{
	rct_widget *widget;
	int x, y, imageId;

	// Tab 1
	if (!widget_is_disabled(w, WIDX_TAB_1)) {
		widget = &w->widgets[WIDX_TAB_1];
		x = widget->left + w->x;
		y = widget->top + w->y;
		imageId = SPR_PEEP_LARGE_FACE_NORMAL;
		gfx_draw_sprite(dpi, imageId, x, y, 0);
	}

	// Tab 2
	if (!widget_is_disabled(w, WIDX_TAB_2)) {
		widget = &w->widgets[WIDX_TAB_2];
		x = widget->left + w->x;
		y = widget->top + w->y;
		imageId = SPR_TAB_FINANCES_SUMMARY_0;

		if (w->page == WINDOW_PLAYER_PAGE_STATISTICS) {
			imageId += (w->frame_no / 2) & 7;
		}

		gfx_draw_sprite(dpi, imageId, x, y, 0);
	}
}
Example #2
0
/**
 * 
 *  rct2: 0x006EBC41
 */
static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, r, b, stringId;
	uint8 colour;

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

	// Get the colour
	colour = w->colours[widget->colour];
	// do not use widget color as this is already used as background for the text_button
	// colour = 2;

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

	stringId = widget->image;
	if (stringId == -1)
		return;

	if (widget->type == WWT_11 && (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex)))
		stringId++;

	if (widget->type == WWT_13) {
		if (widget_is_disabled(w, widgetIndex))
			colour |= 0x40;
		gfx_draw_string_left_clipped(
			dpi,
			stringId,
			(void*)0x013CE952,
			colour,
			l + 1,
			t,
			widget->right - widget->left - 2
		);
	} else {
		colour &= ~(1 << 7);
		if (widget_is_disabled(w, widgetIndex))
			colour |= 0x40;
		gfx_draw_string_centred_clipped(
			dpi,
			stringId,
			(void*)0x013CE952,
			colour,
			(w->x + w->x + widget->left + widget->right + 1) / 2 - 1,
			t,
			widget->right - widget->left - 2
		);
	}
}
Example #3
0
/**
 *
 *  rct2: 0x006EBC41
 */
static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

    // Get the colour
    uint8 colour = w->colours[widget->colour];
    // do not use widget colour as this is already used as background for the text_button
    // colour = 2;

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

    rct_string_id stringId = widget->text;
    if (stringId == STR_NONE)
        return;

    if (widget->type == WWT_11 && (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex)))
        // TODO: remove string addition
        stringId++;

    if (widget->type == WWT_13) {
        if (widget_is_disabled(w, widgetIndex))
            colour |= COLOUR_FLAG_INSET;
        gfx_draw_string_left_clipped(
            dpi,
            stringId,
            gCommonFormatArgs,
            colour,
            l + 1,
            t,
            widget->right - widget->left - 2
        );
    } else {
        colour &= ~(1 << 7);
        if (widget_is_disabled(w, widgetIndex))
            colour |= COLOUR_FLAG_INSET;
        gfx_draw_string_centred_clipped(
            dpi,
            stringId,
            gCommonFormatArgs,
            colour,
            (w->x + w->x + widget->left + widget->right + 1) / 2 - 1,
            t,
            widget->right - widget->left - 2
        );
    }
}
Example #4
0
/**
 * 
 *  rct2: 0x006EB951
 */
static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	int l, t, r, b, colour, image;
	rct_widget *widget;

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

	// Get the image
	image = widget->image;
	if (image == -1)
		return;

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

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

	if (widget->type == WWT_4 || widget->type == WWT_COLORBTN || widget->type == WWT_TRNBTN || widget->type == WWT_TAB)
		if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex))
			image++;

	if (widget_is_disabled(w, widgetIndex)) {
		// Draw greyed out (light border bottom right shadow)
		colour = w->colours[widget->colour];
		colour = RCT2_ADDRESS(0x00141FC4A, uint8)[(colour & 0x7F) * 8] & 0xFF;

		uint8 palette[256];
		memset(palette, colour, 256);
		palette[0] = 0;

		RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000;
		image &= 0x7FFFF;
		gfx_draw_sprite_palette_set(dpi, image | 0x20000000, l + 1, t + 1, palette, NULL);

		// Draw greyed out (dark)
		colour = w->colours[widget->colour];
		colour = RCT2_ADDRESS(0x00141FC48, uint8)[(colour & 0x7F) * 8] & 0xFF;
		memset(palette, colour, 256);
		palette[0] = 0;

		RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000;
		gfx_draw_sprite_palette_set(dpi, image | 0x20000000, l, t, palette, NULL);
	} else {
		if (image & 0x80000000) {
			// ?
		}

		if (image & 0x40000000)
			image &= ~0x40000000;
		else
			image |= colour << 19;

		gfx_draw_sprite(dpi, image, l, t);
	}
}
Example #5
0
/**
 *
 *  rct2: 0x006EB806
 */
static void widget_tab_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

    if (widget->image == -1)
        return;

    // Draw widgets that aren't explicitly disabled.
    if (!widget_is_disabled(w, widgetIndex)) {
        widget_draw_image(dpi, w, widgetIndex);
        return;
    }

    // Do not draw hidden tabs, unless given a sprite.
    if (widget->type == WWT_TAB && widget->image != (IMAGE_TYPE_REMAP | SPR_G2_TAB_DISABLED))
        return;

    if (widget->type != WWT_TRNBTN) {
        widget_draw_image(dpi, w, widgetIndex);
        return;
    }

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

    // Get the colour and disabled image
    uint8 colour = w->colours[widget->colour] & 0x7F;
    uint32 image = widget->image + 2;

    // Draw disabled image
    gfx_draw_sprite(dpi, image | (colour << 19), l, t, 0);
}
Example #6
0
/**
 * 
 *  rct2: 0x006EBD52
 */
static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, r, b;
	uint8 colour;

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

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

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

	if (widget->image == (uint32)-2 || widget->image == (uint32)-1)
		return;

	if (widget_is_disabled(w, widgetIndex))
		colour |= 0x40;
	gfx_draw_string_left(dpi, widget->image, (void*)0x013CE952, colour, l + 1, t);
}
Example #7
0
/**
 * 
*  rct2: 0x006EBAD9
*/
static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, b;
	uint8 colour;

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

	// Resolve the absolute ltb
	l = w->x + widget->left;
	t = w->y + widget->top;
	b = w->y + widget->bottom;

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

	// checkbox
	gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60);

	// fill it when checkbox is pressed
	if (widget_is_pressed(w, widgetIndex)) {
		RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
		gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t);
	}

	// draw the text
	if (widget->image == -1)
		return;

	if (widget_is_disabled(w, widgetIndex)) {
		colour |= 0x40;
	}
	gfx_draw_string_left(dpi, widget->image, (char*)0x013CE952, colour, l + 14, t);
}
Example #8
0
/**
 *
*  rct2: 0x006EBAD9
*/
static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

    // Resolve the absolute ltb
    sint32 l = w->x + widget->left;
    sint32 t = w->y + widget->top;
    sint32 b = w->y + widget->bottom;
    sint32 yMid = (b + t) / 2;

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

    if (widget->type != WWT_24) {
        // checkbox
        gfx_fill_rect_inset(dpi, l, yMid - 5, l + 9, yMid + 4, colour, INSET_RECT_F_60);

        // fill it when checkbox is pressed
        if (widget_is_pressed(w, widgetIndex)) {
            gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
            gfx_draw_string(dpi, (char*)CheckBoxMarkString, NOT_TRANSLUCENT(colour), l, yMid - 5);
        }
    }

    // draw the text
    if (widget->text == STR_NONE)
        return;

    if (widget_is_disabled(w, widgetIndex)) {
        colour |= COLOUR_FLAG_INSET;
    }

    gfx_draw_string_left_centred(dpi, widget->text, gCommonFormatArgs, colour, l + 14, yMid);
}
Example #9
0
/**
 *
 *  rct2: 0x006EB861
 */
static void widget_flat_button_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    if (!widget_is_disabled(w, widgetIndex) && widget_is_highlighted(w, widgetIndex)) {
        widget_button_draw(dpi, w, widgetIndex);
        return;
    }

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

    // Check if the button is pressed down
    if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex)) {
        if (widget->image == -2) {
            // Draw border with no fill
            gfx_fill_rect_inset(dpi, l, t, r, b, colour, INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_NONE);
            return;
        }

        // Draw the border with fill
        gfx_fill_rect_inset(dpi, l, t, r, b, colour, INSET_RECT_FLAG_BORDER_INSET);
    }

    // Draw image
    widget_draw_image(dpi, w, widgetIndex);
}
Example #10
0
/**
 *
 *  rct2: 0x006EBB85
 */
static void widget_closebox_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // 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;

    // Check if the button is pressed down
    uint8 press = 0;
    if (w->flags & WF_10)
        press |= INSET_RECT_FLAG_FILL_MID_LIGHT;
    if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex))
        press |= INSET_RECT_FLAG_BORDER_INSET;

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

    // Draw the button
    gfx_fill_rect_inset(dpi, l, t, r, b, colour, press);

    if (widget->text == STR_NONE)
        return;

    l = w->x + (widget->left + widget->right) / 2 - 1;
    t = w->y + max(widget->top, (widget->top + widget->bottom) / 2 - 5);

    if (widget_is_disabled(w, widgetIndex))
        colour |= COLOUR_FLAG_INSET;

    gfx_draw_string_centred_clipped(dpi, widget->text, gCommonFormatArgs, colour, l, t, widget->right - widget->left - 2);
}
Example #11
0
/**
 * 
 *  rct2: 0x006EB535
 */
static void widget_groupbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, r, b, textRight;
	uint8 colour;

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

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

	// Text
	if (widget->image != (uint32)-1) {
		colour = w->colours[widget->colour] & 0x7F;
		if (widget_is_disabled(w, widgetIndex))
			colour |= 0x40;
		gfx_draw_string_left(dpi, widget->image, (void*)0x013CE952, colour, l, t);
		textRight = gLastDrawStringX + 1;
	}

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

	// Get the colour
	colour = w->colours[widget->colour] & 0x7F;

	// Border left of text
	gfx_fill_rect(dpi, l, t, l + 4, t, RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8]);
	gfx_fill_rect(dpi, l + 1, t + 1, l + 4, t + 1, RCT2_ADDRESS(0x0141FC4B, uint8)[colour * 8]);

	// Border right of text
	gfx_fill_rect(dpi, textRight, t, r - 1, t, RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8]);
	gfx_fill_rect(dpi, textRight, t + 1, r - 2, t + 1, RCT2_ADDRESS(0x0141FC4B, uint8)[colour * 8]);

	// Border right
	gfx_fill_rect(dpi, r - 1, t + 1, r - 1, b - 1, RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8]);
	gfx_fill_rect(dpi, r, t, r, b, RCT2_ADDRESS(0x0141FC4B, uint8)[colour * 8]);

	// Border bottom
	gfx_fill_rect(dpi, l, b - 1, r - 2, b - 1, RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8]);
	gfx_fill_rect(dpi, l, b, r - 1, b, RCT2_ADDRESS(0x0141FC4B, uint8)[colour * 8]);

	// Border left
	gfx_fill_rect(dpi, l, t + 1, l, b - 2, RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8]);
	gfx_fill_rect(dpi, l + 1, t + 2, l + 1, b - 2, RCT2_ADDRESS(0x0141FC4B, uint8)[colour * 8]);
}
static void shortcut_rotate_construction_object()
{
	rct_window *w;

	// Rotate scenery
	w = window_find_by_class(WC_SCENERY);
	if (w != NULL && !widget_is_disabled(w, 25) && w->widgets[25].type != WWT_EMPTY) {
		window_event_mouse_up_call(w, 25);
		return;
	}

	// Rotate construction track piece
	w = window_find_by_class(WC_RIDE_CONSTRUCTION);
	if (w != NULL && !widget_is_disabled(w, 32) && w->widgets[32].type != WWT_EMPTY) {
		// Check if building a maze...
		if (w->widgets[32].tooltip != 1761) {
			window_event_mouse_up_call(w, 32);
			return;
		}
	}

	// Rotate track design preview
	w = window_find_by_class(WC_TRACK_DESIGN_LIST);
	if (w != NULL && !widget_is_disabled(w, 5) && w->widgets[5].type != WWT_EMPTY) {
		window_event_mouse_up_call(w, 5);
		return;
	}

	// Rotate track design placement
	w = window_find_by_class(WC_TRACK_DESIGN_PLACE);
	if (w != NULL && !widget_is_disabled(w, 3) && w->widgets[3].type != WWT_EMPTY) {
		window_event_mouse_up_call(w, 3);
		return;
	}

	// Rotate park entrance
	w = window_find_by_class(WC_MAP);
	if (w != NULL && !widget_is_disabled(w, 20) && w->widgets[20].type != WWT_EMPTY) {
		window_event_mouse_up_call(w, 20);
		return;
	}
}
Example #13
0
/**
 *
 *  rct2: 0x006EB535
 */
static void widget_groupbox_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

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

    // Text
    if (widget->text != STR_NONE) {
        uint8 colour = w->colours[widget->colour] & 0x7F;
        if (widget_is_disabled(w, widgetIndex))
            colour |= 0x40;
        gfx_draw_string_left(dpi, widget->text, gCommonFormatArgs, colour, l, t);
        textRight = l + gfx_get_string_width(gCommonStringFormatBuffer) + 1;
    }

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

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

    // Border left of text
    gfx_fill_rect(dpi, l, t, l + 4, t, ColourMapA[colour].mid_dark);
    gfx_fill_rect(dpi, l + 1, t + 1, l + 4, t + 1, ColourMapA[colour].lighter);

    // Border right of text
    gfx_fill_rect(dpi, textRight, t, r - 1, t, ColourMapA[colour].mid_dark);
    gfx_fill_rect(dpi, textRight, t + 1, r - 2, t + 1, ColourMapA[colour].lighter);

    // Border right
    gfx_fill_rect(dpi, r - 1, t + 1, r - 1, b - 1, ColourMapA[colour].mid_dark);
    gfx_fill_rect(dpi, r, t, r, b, ColourMapA[colour].lighter);

    // Border bottom
    gfx_fill_rect(dpi, l, b - 1, r - 2, b - 1, ColourMapA[colour].mid_dark);
    gfx_fill_rect(dpi, l, b, r - 1, b, ColourMapA[colour].lighter);

    // Border left
    gfx_fill_rect(dpi, l, t + 1, l, b - 2, ColourMapA[colour].mid_dark);
    gfx_fill_rect(dpi, l + 1, t + 2, l + 1, b - 2, ColourMapA[colour].lighter);
}
Example #14
0
/**
 *
 *  rct2: 0x006EB951
 */
static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

    // Get the image
    sint32 image = widget->image;
    if (image == SPR_NONE)
        return;

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

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

    if (widget->type == WWT_4 || widget->type == WWT_COLOURBTN || widget->type == WWT_TRNBTN || widget->type == WWT_TAB)
        if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex))
            image++;

    if (widget_is_disabled(w, widgetIndex)) {
        // Draw greyed out (light border bottom right shadow)
        colour = w->colours[widget->colour];
        colour = ColourMapA[NOT_TRANSLUCENT(colour)].lighter;
        gfx_draw_sprite_solid(dpi, image, l + 1, t + 1, colour);

        // Draw greyed out (dark)
        colour = w->colours[widget->colour];
        colour = ColourMapA[NOT_TRANSLUCENT(colour)].mid_light;
        gfx_draw_sprite_solid(dpi, image, l, t, colour);
    } else {
        if (image & IMAGE_TYPE_REMAP_2_PLUS) {
            // ?
        }

        if (image & IMAGE_TYPE_TRANSPARENT)
            image &= ~IMAGE_TYPE_TRANSPARENT;
        else
            image |= colour << 19;

        gfx_draw_sprite(dpi, image, l, t, 0);
    }
}
Example #15
0
/**
 *
 *  rct2: 0x006EB806
 */
static void widget_tab_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, r, b;
	uint32 image;
	uint8 colour;

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

	// 
	if (widget->image == -1)
		return;

	// Check if tab is disabled
	if (!widget_is_disabled(w, widgetIndex)) {
		widget_draw_image(dpi, w, widgetIndex);
		return;
	}

	if (widget->type == WWT_TAB)
		return;

	if (widget->type != WWT_TRNBTN) {
		widget_draw_image(dpi, w, widgetIndex);
		return;
	}

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

	// Get the colour and image
	colour = w->colours[widget->colour] << 19;
	image = widget->image + 2;

	// Draw coloured image
	gfx_draw_sprite(dpi, image | colour, l, t);
}
Example #16
0
/**
 *
 *  rct2: 0x006EBD52
 */
static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    rct_widget *widget = &w->widgets[widgetIndex];

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

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

    // TODO: -2 seems odd
    if (widget->text == (rct_string_id)-2 || widget->text == STR_NONE)
        return;

    if (widget_is_disabled(w, widgetIndex))
        colour |= COLOUR_FLAG_INSET;
    gfx_draw_string_left_clipped(dpi, widget->text, gCommonFormatArgs, colour, l + 1, t, r - l);
}
Example #17
0
/**
 * 
 *  rct2: 0x006EBB85
 */
static void widget_closebox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, r, b, press;
	uint8 colour;

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

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

	// Check if the button is pressed down
	press = 0;
	if (w->flags & 0x400)
		press |= 0x80;
	if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex))
		press |= 0x20;

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

	// Draw the button
	gfx_fill_rect_inset(dpi, l, t, r, b, colour, press);

	if (widget->image == -1)
		return;

	l = w->x + (widget->left + widget->right) / 2 - 1;
	t = w->y + max(widget->top, (widget->top + widget->bottom) / 2 - 5);

	if (widget_is_disabled(w, widgetIndex))
		colour |= 0x40;

	gfx_draw_string_centred_clipped(dpi, widget->image, (void*)0x013CE952, colour, l, t, widget->right - widget->left - 2);
}
Example #18
0
/**
 * 
 *  rct2: 0x006EB861
 */
static void widget_flat_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	int l, t, r, b, press;
	uint32 image;
	uint8 colour;

	if (!widget_is_disabled(w, widgetIndex) && widget_is_highlighted(w, widgetIndex)) {
		widget_button_draw(dpi, w, widgetIndex);
		return;
	}

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

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

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

	// Check if the button is pressed down
	if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex)) {
		if (widget->image == -2) {
			// Draw border with no fill
			gfx_fill_rect_inset(dpi, l, t, r, b, colour, 0x20 | 0x10);
			return;
		}

		// Draw the border with fill
		gfx_fill_rect_inset(dpi, l, t, r, b, colour, 0x20);
	}

	// Draw image
	widget_draw_image(dpi, w, widgetIndex);
}
Example #19
0
/**
 * 
 *  rct2: 0x006E95F9
 */
static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
{
	// RCT2_CALLPROC_X(0x006E95F9, x, y, state, widgetIndex, w, widget, 0);

	rct_windowclass windowClass = 255;
	rct_windownumber windowNumber = 0;
	rct_widget *widget;

	if (w != NULL) {
		windowClass = w->classification;
		windowNumber = w->number;
		widget = &w->widgets[widgetIndex];
	}

	window_close_by_id(WC_ERROR, 0);
	window_close_by_id(WC_TOOLTIP, 0);

	w = window_find_by_id(windowClass, windowNumber);
	if (w == NULL)
		return;

	window_bring_to_front(w);
	if (widgetIndex == -1)
		return;

	switch (widget->type) {
	case WWT_FRAME:
	case WWT_RESIZE:
		if (!(w->flags & WF_RESIZABLE))
			break;
		if (w->min_width == w->max_width && w->min_height == w->max_height)
			break;
		if (x < w->x + w->width - 19 || y < w->y + w->height - 19)
			break;

		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESIZING;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber;
		break;
	case WWT_VIEWPORT:
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_LEFT;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber;
		if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)))
			break;

		w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber));
		if (w == NULL)
			break;

		RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0);
		RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 4);
		break;
	case WWT_CAPTION:
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_DRAGGING;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber;
		break;
	case WWT_SCROLL:
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_SCROLL_LEFT;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber;
		RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) = y;

		int eax, ebx, ecx, edx, esi, edi, ebp;
		eax = x;
		ebx = y;
		esi = w;
		edi = widget;
		RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part
		eax &= 0xFFFF;
		ebx &= 0xFFFF;
		ecx &= 0xFFFF;
		edx &= 0xFFFF;

		RCT2_GLOBAL(0x009DE548, uint16) = ecx;
		RCT2_GLOBAL(0x009DE54C, uint32) = edx;
		RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, w, widget, 0);
		switch (ecx) {
		case SCROLL_PART_VIEW:
			RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, w, widget, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_LEFT:
			// 0x006E9A60
			RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_RIGHT:
			// 0x006E9ABF
			RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH:
			// 0x006E9B47
			RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH:
			// 0x006E9BB7
			RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_TOP:
			// 0x006E9C37
			RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_BOTTOM:
			// 0x006E9C96
			RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_TOP_TROUGH:
			// 0x006E9D1E
			RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH:
			// 0x006E9D8E
			RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, w, 0, 0);
			break;
		}
		break;
	default:
		if (!widget_is_enabled(w, widgetIndex))
			break;
		if (widget_is_disabled(w, widgetIndex))
			break;

		sound_play_panned(4, w->x + (widget->left + widget->right) / 2);
		
		// Set new cursor down widget
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, rct_windowclass) = widgetIndex;
		RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 0);
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_WIDGET_PRESSED;
		RCT2_GLOBAL(0x009DE528, uint16) = 1;

		widget_invalidate(windowClass, windowNumber, widgetIndex);
		RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, w, widget, 0);
		break;
	}
}
Example #20
0
/**
 *
 *  rct2: 0x006E95F9
 */
static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex)
{
	rct_windowclass windowClass = 255;
	rct_windownumber windowNumber = 0;
	rct_widget *widget;

	if (w != NULL) {
		windowClass = w->classification;
		windowNumber = w->number;
	}

	window_close_by_class(WC_ERROR);
	window_close_by_class(WC_TOOLTIP);

	// Window might have changed position in the list, therefore find it again
	w = window_find_by_number(windowClass, windowNumber);
	if (w == NULL)
		return;

	w = window_bring_to_front(w);
	if (widgetIndex == -1)
		return;

	if (windowClass != gCurrentTextBox.window.classification ||
		windowNumber != gCurrentTextBox.window.number ||
		widgetIndex != gCurrentTextBox.widget_index) {
		window_cancel_textbox();
	}

	widget = &w->widgets[widgetIndex];

	switch (widget->type) {
	case WWT_FRAME:
	case WWT_RESIZE:
		if (window_can_resize(w) && (x >= w->x + w->width - 19 && y >= w->y + w->height - 19))
			input_window_resize_begin(w, widgetIndex, x, y);
		break;
	case WWT_VIEWPORT:
		_inputState = INPUT_STATE_VIEWPORT_LEFT;
		gInputDragLastX = x;
		gInputDragLastY = y;
		_dragWidget.window_classification = windowClass;
		_dragWidget.window_number = windowNumber;
		if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) {
			w = window_find_by_number(
				gCurrentToolWidget.window_classification,
				gCurrentToolWidget.window_number
				);
			if (w != NULL) {
				window_event_tool_down_call(w, gCurrentToolWidget.widget_index, x, y);
				_inputFlags |= INPUT_FLAG_4;
			}
		}
		break;
	case WWT_CAPTION:
		input_window_position_begin(w, widgetIndex, x, y);
		break;
	case WWT_SCROLL:
		input_scroll_begin(w, widgetIndex, x, y);
		break;
	default:
		if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) {
			audio_play_sound_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0);

			// Set new cursor down widget
			gPressedWidget.window_classification = windowClass;
			gPressedWidget.window_number = windowNumber;
			gPressedWidget.widget_index = widgetIndex;
			_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
			_inputState = INPUT_STATE_WIDGET_PRESSED;
			_clickRepeatTicks = 1;

			widget_invalidate_by_number(windowClass, windowNumber, widgetIndex);
			window_event_mouse_down_call(w, widgetIndex);
		}
		break;
	}
}