/** * 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); }
void window_tooltip_reset(int32_t x, int32_t y) { gTooltipCursorX = x; gTooltipCursorY = y; gTooltipTimeout = 0; gTooltipWidget.window_classification = 255; input_set_state(INPUT_STATE_NORMAL); input_set_flag(INPUT_FLAG_4, false); }
/* Parse input. */ void input_parse(struct window_pane *wp) { struct input_ctx *ictx = &wp->ictx; const struct input_transition *itr; struct evbuffer *evb = wp->event->input; u_char *buf; size_t len, off; if (EVBUFFER_LENGTH(evb) == 0) return; wp->window->flags |= WINDOW_ACTIVITY; wp->window->flags &= ~WINDOW_SILENCE; /* * Open the screen. Use NULL wp if there is a mode set as don't want to * update the tty. */ if (wp->mode == NULL) screen_write_start(&ictx->ctx, wp, &wp->base); else screen_write_start(&ictx->ctx, NULL, &wp->base); ictx->wp = wp; buf = EVBUFFER_DATA(evb); len = EVBUFFER_LENGTH(evb); notify_input(wp, evb); off = 0; /* Parse the input. */ while (off < len) { ictx->ch = buf[off++]; log_debug("%s: '%c' %s", __func__, ictx->ch, ictx->state->name); /* Find the transition. */ itr = ictx->state->transitions; while (itr->first != -1 && itr->last != -1) { if (ictx->ch >= itr->first && ictx->ch <= itr->last) break; itr++; } if (itr->first == -1 || itr->last == -1) { /* No transition? Eh? */ fatalx("No transition from state!"); } /* * Execute the handler, if any. Don't switch state if it * returns non-zero. */ if (itr->handler != NULL && itr->handler(ictx) != 0) continue; /* And switch state, if necessary. */ if (itr->state != NULL) input_set_state(wp, itr); /* If not in ground state, save input. */ if (ictx->state != &input_state_ground) evbuffer_add(ictx->since_ground, &ictx->ch, 1); } /* Close the screen. */ screen_write_stop(&ictx->ctx); evbuffer_drain(evb, len); }