Ejemplo n.º 1
0
/**
 * Shows a text dropdown menu.
 *  rct2: 0x006ECFB9, although 0x006ECE50 is real version
 *
 * @param x (cx)
 * @param y (dx)
 * @param extray (di)
 * @param flags (bh)
 * @param num_items (bx)
 * @param colour (al)
 * @param custom_height (ah) requires flag set as well
 */
void window_dropdown_show_text_custom_width(
    int32_t x, int32_t y, int32_t extray, uint8_t colour, uint8_t custom_height, uint8_t flags, size_t num_items, int32_t width)
{
    rct_window* w;

    input_set_flag((INPUT_FLAGS)(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
    if (flags & DROPDOWN_FLAG_STAY_OPEN)
        input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);

    window_dropdown_close();

    // Set and calculate num items, rows and columns
    _dropdown_item_width = width;
    _dropdown_item_height = (flags & DROPDOWN_FLAG_CUSTOM_HEIGHT) ? custom_height : DROPDOWN_ITEM_HEIGHT;
    gDropdownNumItems = (int32_t)num_items;
    // There must always be at least one column to prevent dividing by zero
    if (gDropdownNumItems == 0)
    {
        _dropdown_num_columns = 1;
        _dropdown_num_rows = 0;
    }
    else
    {
        _dropdown_num_columns = (gDropdownNumItems + DROPDOWN_TEXT_MAX_ROWS - 1) / DROPDOWN_TEXT_MAX_ROWS;
        _dropdown_num_rows = (gDropdownNumItems + _dropdown_num_columns - 1) / _dropdown_num_columns;
    }

    // Text dropdowns are listed horizontally
    _dropdown_list_vertically = true;

    width = _dropdown_item_width * _dropdown_num_columns + 3;
    int32_t height = _dropdown_item_height * _dropdown_num_rows + 3;
    int32_t screenWidth = context_get_width();
    int32_t screenHeight = context_get_height();
    if (x + width > screenWidth)
        x = std::max(0, screenWidth - width);
    if (y + height > screenHeight)
        y = std::max(0, screenHeight - height);

    window_dropdown_widgets[WIDX_BACKGROUND].right = width;
    window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;

    // Create the window
    w = window_create(
        x, y + extray, window_dropdown_widgets[WIDX_BACKGROUND].right + 1, window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1,
        &window_dropdown_events, WC_DROPDOWN, WF_STICK_TO_FRONT);
    w->widgets = window_dropdown_widgets;
    if (colour & COLOUR_FLAG_TRANSLUCENT)
        w->flags |= WF_TRANSPARENT;
    w->colours[0] = colour;

    // Input state
    gDropdownHighlightedIndex = -1;
    std::fill_n(_dropdownItemsDisabled, sizeof(_dropdownItemsDisabled), false);
    std::fill_n(_dropdownItemsChecked, sizeof(_dropdownItemsChecked), false);
    gDropdownIsColour = false;
    gDropdownDefaultIndex = -1;
    input_set_state(INPUT_STATE_DROPDOWN_ACTIVE);
}
Ejemplo n.º 2
0
/**
 * Shows an image dropdown menu.
 *  rct2: 0x006ECFB9
 *
 * @param x (cx)
 * @param y (dx)
 * @param extray (di)
 * @param flags (bh)
 * @param numItems (bx)
 * @param colour (al)
 * @param itemWidth (bp)
 * @param itemHeight (ah)
 * @param numColumns (bl)
 */
void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 flags, int numItems, int itemWidth, int itemHeight, int numColumns)
{
	int width, height;
	rct_window* w;

	// Copy the formats and arguments until all use of it is decompiled
	memcpy((void*)0x009DEBA4, gDropdownItemsFormat, 40 * 2);
	memcpy((void*)0x009DEBF4, gDropdownItemsArgs, 40 * 8);

	gInputFlags &= ~(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP);
	if (flags & DROPDOWN_FLAG_STAY_OPEN)
		gInputFlags |= INPUT_FLAG_DROPDOWN_STAY_OPEN;

	// Close existing dropdown
	window_dropdown_close();

	// Set and calculate num items, rows and columns
	_dropdown_item_width = itemWidth;
	_dropdown_item_height = itemHeight;
	gDropdownNumItems = numItems;
	_dropdown_num_columns = numColumns;
	_dropdown_num_rows = gDropdownNumItems / _dropdown_num_columns;
	if (gDropdownNumItems % _dropdown_num_columns != 0)
		_dropdown_num_rows++;

	// Calculate position and size
	width = _dropdown_item_width * _dropdown_num_columns + 3;
	height = _dropdown_item_height * _dropdown_num_rows + 3;
	if (x + width > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16))
		x = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width);
	if (y + height > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16))
		y = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height);
	window_dropdown_widgets[WIDX_BACKGROUND].right = width;
	window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;

	// Create the window
	w = window_create(
		x, y + extray,
		window_dropdown_widgets[WIDX_BACKGROUND].right + 1,
		window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1,
		&window_dropdown_events,
		WC_DROPDOWN,
		WF_STICK_TO_FRONT
	);
	w->widgets = window_dropdown_widgets;
	if (colour & 0x80)
		w->flags |= WF_TRANSPARENT;
	w->colours[0] = colour;

	// Input state
	gDropdownHighlightedIndex = -1;
	gDropdownItemsDisabled = 0;
	gDropdownItemsChecked = 0;
	gDropdownIsColour = false;
	gDropdownDefaultIndex = -1;
	gInputState = INPUT_STATE_DROPDOWN_ACTIVE;
}
Ejemplo n.º 3
0
/**
 * Shows a text dropdown menu.
 *  rct2: 0x006ECFB9, although 0x006ECE50 is real version
 *
 * @param x (cx)
 * @param y (dx)
 * @param extray (di)
 * @param flags (bh)
 * @param num_items (bx)
 * @param colour (al)
 */
void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colour, uint8 flags, int num_items, int width)
{
	rct_window* w;

	// Copy the formats and arguments until all use of it is decompiled
	memcpy((void*)0x009DEBA4, gDropdownItemsFormat, 40 * 2);
	memcpy((void*)0x009DEBF4, gDropdownItemsArgs, 40 * 8);

	gInputFlags &= ~(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP);
	if (flags & DROPDOWN_FLAG_STAY_OPEN)
		gInputFlags |= INPUT_FLAG_DROPDOWN_STAY_OPEN;

	window_dropdown_close();
	_dropdown_num_columns = 1;
	_dropdown_item_width = width;
	_dropdown_item_height = 10;
	if (flags & 0x40)
		_dropdown_item_height = flags & 0x3F;

	// Set the widgets
	gDropdownNumItems = num_items;
	_dropdown_num_rows = num_items;

	width = _dropdown_item_width * _dropdown_num_columns + 3;
	int height = _dropdown_item_height * _dropdown_num_rows + 3;
	if (x + width > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16))
		x = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width);
	if (y + height > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16))
		y = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height);

	window_dropdown_widgets[WIDX_BACKGROUND].bottom = _dropdown_item_height * num_items + 3;
	window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;

	// Create the window
	w = window_create(
		x, y + extray,
		window_dropdown_widgets[WIDX_BACKGROUND].right + 1,
		window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1,
		&window_dropdown_events,
		WC_DROPDOWN,
		0x02
	);
	w->widgets = window_dropdown_widgets;
	if (colour & 0x80)
		w->flags |= WF_TRANSPARENT;
	w->colours[0] = colour;

	// Input state
	gDropdownHighlightedIndex = -1;
	gDropdownItemsDisabled = 0;
	gDropdownItemsChecked = 0;
	gDropdownIsColour = false;
	gDropdownDefaultIndex = -1;
	gInputState = INPUT_STATE_DROPDOWN_ACTIVE;
}
Ejemplo n.º 4
0
/**
 * Shows a text dropdown menu.
 *  rct2: 0x006ECFB9, although 0x006ECE50 is real version
 *
 * @param x (cx)
 * @param y (dx)
 * @param extray (di)
 * @param flags (bh)
 * @param num_items (bx)
 * @param colour (al)
 */
void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colour, uint8 flags, int num_items, int width)
{
	rct_window* w;
	int i, string_width, max_string_width;
	char buffer[256];

	// Copy the formats and arguments until all use of it is decompiled
	memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2);
	memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4);

	RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02);
	if (flags & 0x80)
		RCT2_GLOBAL(0x009DE518, uint32) |= 0x02;

	window_dropdown_close();
	_dropdown_num_columns = 1;
	_dropdown_item_width = width;
	_dropdown_item_height = 10;
	if (flags & 0x40)
		_dropdown_item_height = flags & 0x3F;
	
	// Set the widgets
	_dropdown_num_items = num_items;
	_dropdown_num_rows = num_items;
	window_dropdown_widgets[WIDX_BACKGROUND].bottom = _dropdown_item_height * num_items + 3;
	window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;

	// Create the window
	w = window_create(
		x, y + extray,
		window_dropdown_widgets[WIDX_BACKGROUND].right + 1,
		window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1,
		window_dropdown_events,
		WC_DROPDOWN,
		0x02
	);
	w->widgets = window_dropdown_widgets;
	if (colour & 0x80)
		w->flags |= WF_TRANSPARENT;
	w->colours[0] = colour;

	// Input state
	_dropdown_highlighted_index = -1;
	RCT2_GLOBAL(0x009DED34, sint32) = 0;
	gDropdownItemsChecked = 0;
	RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = INPUT_STATE_DROPDOWN_ACTIVE;

	// Copy the following properties until all use of it is decompiled
	RCT2_GLOBAL(0x009DEBA0, sint16) = _dropdown_num_items;
	RCT2_GLOBAL(0x009DED44, sint32) = _dropdown_num_columns;
	RCT2_GLOBAL(0x009DED48, sint32) = _dropdown_num_rows;
	RCT2_GLOBAL(0x009DED40, sint32) = _dropdown_item_width;
	RCT2_GLOBAL(0x009DED3C, sint32) = _dropdown_item_height;
	RCT2_GLOBAL(0x009DEBA2, sint16) = _dropdown_highlighted_index;
}
Ejemplo n.º 5
0
/**
 * Shows an image dropdown menu.
 *  rct2: 0x006ECFB9
 *
 * @param x (cx)
 * @param y (dx)
 * @param extray (di)
 * @param flags (bh)
 * @param numItems (bx)
 * @param colour (al)
 * @param itemWidth (bp)
 * @param itemHeight (ah)
 * @param numColumns (bl)
 */
void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 flags, int numItems, int itemWidth, int itemHeight, int numColumns)
{
	int i, width, height;
	rct_window* w;

	// Copy the formats and arguments until all use of it is decompiled
	memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2);
	memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4);

	RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02);
	if (flags & 0x80)
		RCT2_GLOBAL(0x009DE518, uint32) |= 0x02;

	// Close existing dropdown
	window_dropdown_close();

	// Set and calculate num items, rows and columns
	_dropdown_item_width = itemWidth;
	_dropdown_item_height = itemHeight;
	_dropdown_num_items = numItems;
	_dropdown_num_columns = numColumns;
	_dropdown_num_rows = _dropdown_num_items / _dropdown_num_columns;
	if (_dropdown_num_items % _dropdown_num_columns != 0)
		_dropdown_num_rows++;

	// Calculate position and size
	width = _dropdown_item_width * _dropdown_num_columns + 3;
	height = _dropdown_item_height * _dropdown_num_rows + 3;
	if (x + width > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16))
		x = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - width);
	if (y + height > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16))
		y = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - height);
	window_dropdown_widgets[WIDX_BACKGROUND].right = width;
	window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;

	// Create the window
	w = window_create(
		x, y + extray,
		window_dropdown_widgets[WIDX_BACKGROUND].right + 1,
		window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1,
		window_dropdown_events,
		WC_DROPDOWN,
		WF_STICK_TO_FRONT
	);
	w->widgets = window_dropdown_widgets;
	if (colour & 0x80)
		w->flags |= WF_TRANSPARENT;
	w->colours[0] = colour;

	// Input state
	_dropdown_highlighted_index = -1;
	RCT2_GLOBAL(0x009DED34, sint32) = 0;
	gDropdownItemsChecked = 0;
	RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = INPUT_STATE_DROPDOWN_ACTIVE;

	// Copy the following properties until all use of it is decompiled
	RCT2_GLOBAL(0x009DEBA0, sint16) = _dropdown_num_items;
	RCT2_GLOBAL(0x009DED44, sint32) = _dropdown_num_columns;
	RCT2_GLOBAL(0x009DED48, sint32) = _dropdown_num_rows;
	RCT2_GLOBAL(0x009DED40, sint32) = _dropdown_item_width;
	RCT2_GLOBAL(0x009DED3C, sint32) = _dropdown_item_height;
	RCT2_GLOBAL(0x009DEBA2, sint16) = _dropdown_highlighted_index;
}