static void window_themes_mouseup(rct_window *w, rct_widgetindex widgetIndex) { size_t activeAvailableThemeIndex; const utf8 * activeThemeName; switch (widgetIndex) { case WIDX_THEMES_CLOSE: window_close(w); break; case WIDX_THEMES_DUPLICATE_BUTTON:; activeAvailableThemeIndex = theme_manager_get_active_available_theme_index(); activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex); window_text_input_open(w, widgetIndex, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_THEMES_PROMPT_ENTER_THEME_NAME, STR_STRING, (uintptr_t)activeThemeName, 64); break; case WIDX_THEMES_DELETE_BUTTON: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_delete(); } break; case WIDX_THEMES_RENAME_BUTTON: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { activeAvailableThemeIndex = theme_manager_get_active_available_theme_index(); activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex); window_text_input_open(w, widgetIndex, STR_TRACK_MANAGE_RENAME, STR_THEMES_PROMPT_ENTER_THEME_NAME, STR_STRING, (uintptr_t)activeThemeName, 64); } break; } }
void window_themes_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y) { if (y / _row_height < get_colour_scheme_tab_count()) { sint32 y2 = y % _row_height; _colour_index_1 = y / _row_height; _colour_index_2 = ((x - _button_offset_x) / 12); rct_windowclass wc = get_window_class_tab_index(_colour_index_1); sint32 numColours = theme_desc_get_num_colours(wc); if (_colour_index_2 < numColours) { if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 && y2 >= _button_offset_y && y2 < _button_offset_y + 11) { if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_THEMES_DESC_CANT_CHANGE_THIS_THEME); } else { window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].type = WWT_COLOURBTN; window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].left = _button_offset_x + _colour_index_2 * 12 + window_themes_widgets[WIDX_THEMES_LIST].left; window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].top = _colour_index_1 * _row_height + _button_offset_y - w->scrolls[0].v_top + window_themes_widgets[WIDX_THEMES_LIST].top; window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].right = window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].left + 12; window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].bottom = window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].top + 12; uint8 colour = theme_get_colour(wc, _colour_index_2); window_dropdown_show_colour(w, &(window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK]), w->colours[1], colour); widget_invalidate(w, WIDX_THEMES_LIST); } } else if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 - 1 && y2 >= _check_offset_y && y2 < _check_offset_y + 11) { if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_THEMES_DESC_CANT_CHANGE_THIS_THEME); } else { uint8 colour = theme_get_colour(wc, _colour_index_2); if (colour & COLOUR_FLAG_TRANSLUCENT) { colour &= ~COLOUR_FLAG_TRANSLUCENT; } else { colour |= COLOUR_FLAG_TRANSLUCENT; } theme_set_colour(wc, _colour_index_2, colour); colour_scheme_update_all(); window_invalidate_all(); } } } } }
static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex) { int colour; uint8 paletteIndex = ColourMapA[w->colours[1]].mid_light; gfx_clear(dpi, paletteIndex); rct_string_id highlighted_format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_WHITE_STRING : STR_WINDOW_COLOUR_2_STRINGID; rct_string_id unhighlighted_format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_WHITE_STRING : STR_BLACK_STRING; bool wide = gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN; rct_widget *listWidget = &w->widgets[WIDX_SCENARIOLIST]; int listWidth = listWidget->right - listWidget->left - 12; int y = 0; for (sc_list_item *listItem = _listItems; listItem->type != LIST_ITEM_TYPE_END; listItem++) { if (y > dpi->y + dpi->height) { continue; } switch (listItem->type) { case LIST_ITEM_TYPE_HEADING:; const int horizontalRuleMargin = 4; draw_category_heading(w, dpi, horizontalRuleMargin, listWidth - horizontalRuleMargin, y + 2, listItem->heading.string_id); y += 18; break; case LIST_ITEM_TYPE_SCENARIO:; // Draw hover highlight const scenario_index_entry *scenario = listItem->scenario.scenario; bool isHighlighted = w->highlighted_scenario == scenario; if (isHighlighted) { gfx_filter_rect(dpi, 0, y, w->width, y + 23, PALETTE_DARKEN_1); } bool isCompleted = scenario->highscore != NULL; bool isDisabled = listItem->scenario.is_locked; // Draw scenario name char buffer[64]; safe_strcpy(buffer, scenario->name, sizeof(buffer)); rct_string_id format = isDisabled ? STR_STRINGID : (isHighlighted ? highlighted_format : unhighlighted_format); set_format_arg(0, rct_string_id, STR_STRING); set_format_arg(2, char *, buffer); colour = isDisabled ? w->colours[1] | COLOUR_FLAG_INSET : COLOUR_BLACK; if (isDisabled) { gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK; } gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 1, colour, gCommonFormatArgs); // Check if scenario is completed if (isCompleted) { // Draw completion tick gfx_draw_sprite(dpi, SPR_MENU_CHECKMARK, wide ? 500 : 395, y + 1, 0); // Draw completion score const utf8 *completedByName = "???"; if (!str_is_null_or_empty(scenario->highscore->name)) { completedByName = scenario->highscore->name; } safe_strcpy(buffer, completedByName, 64); set_format_arg(0, rct_string_id, STR_COMPLETED_BY); set_format_arg(2, rct_string_id, STR_STRING); set_format_arg(4, char *, buffer); gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 11, COLOUR_BLACK, gCommonFormatArgs); } y += 24; break; } } }
static void window_scenarioselect_paint(rct_window *w, rct_drawpixelinfo *dpi) { int i, x, y, format; rct_widget *widget; const scenario_index_entry *scenario; window_draw_widgets(w, dpi); format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_SMALL_WINDOW_COLOUR_2_STRINGID : STR_WINDOW_COLOUR_2_STRINGID; // Text for each tab for (i = 0; i < 8; i++) { widget = &window_scenarioselect_widgets[WIDX_TAB1 + i]; if (widget->type == WWT_EMPTY) continue; x = (widget->left + widget->right) / 2 + w->x; y = (widget->top + widget->bottom) / 2 + w->y - 3; if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN) { set_format_arg(0, rct_string_id, ScenarioOriginStringIds[i]); } else { // old-style set_format_arg(0, rct_string_id, ScenarioCategoryStringIds[i]); } gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, 87, format, COLOUR_AQUAMARINE); } // Return if no scenario highlighted scenario = w->highlighted_scenario; if (scenario == NULL) { if (_showLockedInformation) { // Show locked information x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4; y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5; gfx_draw_string_centred_clipped(dpi, STR_SCENARIO_LOCKED, NULL, COLOUR_BLACK, x + 85, y, 170); y += 15; y += gfx_draw_string_left_wrapped(dpi, NULL, x, y, 170, STR_SCENARIO_LOCKED_DESC, COLOUR_BLACK) + 5; } return; } // Scenario path if (gConfigGeneral.debugging_tools) { utf8 path[MAX_PATH]; gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; shorten_path(path, sizeof(path), scenario->path, w->width - 6); const utf8 *pathPtr = path; gfx_draw_string_left(dpi, STR_STRING, (void*)&pathPtr, w->colours[1], w->x + 3, w->y + w->height - 3 - 11); } // Scenario name x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4; y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5; set_format_arg(0, rct_string_id, STR_STRING); set_format_arg(2, const char *, scenario->name); gfx_draw_string_centred_clipped(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, x + 85, y, 170); y += 15; // Scenario details set_format_arg(0, rct_string_id, STR_STRING); set_format_arg(2, const char *, scenario->details); y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, 170, STR_BLACK_STRING, COLOUR_BLACK) + 5; // Scenario objective set_format_arg(0, rct_string_id, ObjectiveNames[scenario->objective_type]); set_format_arg(2, short, scenario->objective_arg_3); set_format_arg(4, short, date_get_total_months(MONTH_OCTOBER, scenario->objective_arg_1)); set_format_arg(6, int, scenario->objective_arg_2); y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, 170, STR_OBJECTIVE, COLOUR_BLACK) + 5; // Scenario score if (scenario->highscore != NULL) { // TODO: Should probably be translateable const utf8 *completedByName = "???"; if (!str_is_null_or_empty(scenario->highscore->name)) { completedByName = scenario->highscore->name; } set_format_arg(0, rct_string_id, STR_STRING); set_format_arg(2, const char *, completedByName); set_format_arg(2 + sizeof(const char *), money32, scenario->highscore->company_value); y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, 170, STR_COMPLETED_BY_WITH_COMPANY_VALUE, COLOUR_BLACK); } }
void window_themes_invalidate(rct_window *w) { sint32 pressed_widgets = w->pressed_widgets & ~( (1LL << WIDX_THEMES_SETTINGS_TAB) | (1LL << WIDX_THEMES_MAIN_UI_TAB) | (1LL << WIDX_THEMES_PARK_TAB) | (1LL << WIDX_THEMES_TOOLS_TAB) | (1LL << WIDX_THEMES_RIDE_PEEPS_TAB) | (1LL << WIDX_THEMES_EDITORS_TAB) | (1LL << WIDX_THEMES_MISC_TAB) | (1LL << WIDX_THEMES_PROMPTS_TAB) | (1LL << WIDX_THEMES_FEATURES_TAB) ); rct_widgetindex widgetIndex = _selected_tab + WIDX_THEMES_SETTINGS_TAB; w->pressed_widgets = pressed_widgets | (1 << widgetIndex); if (window_find_by_class(WC_DROPDOWN) == NULL) { _colour_index_1 = -1; _colour_index_2 = -1; } window_themes_widgets[WIDX_THEMES_BACKGROUND].right = w->width - 1; window_themes_widgets[WIDX_THEMES_BACKGROUND].bottom = w->height - 1; window_themes_widgets[WIDX_THEMES_TAB_CONTENT_PANEL].right = w->width - 1; window_themes_widgets[WIDX_THEMES_TAB_CONTENT_PANEL].bottom = w->height - 1; window_themes_widgets[WIDX_THEMES_TITLE].right = w->width - 2; window_themes_widgets[WIDX_THEMES_CLOSE].left = w->width - 2 - 0x0B; window_themes_widgets[WIDX_THEMES_CLOSE].right = w->width - 2 - 0x0B + 0x0A; window_themes_widgets[WIDX_THEMES_LIST].right = w->width - 4; window_themes_widgets[WIDX_THEMES_LIST].bottom = w->height - 0x0F; window_themes_widgets[WIDX_THEMES_LIST].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_RIDE_LIGHTS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_PARK_LIGHTS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_SCENARIO_FONT].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_DUPLICATE_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_DELETE_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RENAME_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_PRESETS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_COLOURBTN_MASK].type = WWT_EMPTY; if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS) { window_themes_widgets[WIDX_THEMES_LIST].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_RIDE_LIGHTS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_PARK_LIGHTS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_SCENARIO_FONT].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_DUPLICATE_BUTTON].type = WWT_DROPDOWN_BUTTON; window_themes_widgets[WIDX_THEMES_DELETE_BUTTON].type = WWT_DROPDOWN_BUTTON; window_themes_widgets[WIDX_THEMES_RENAME_BUTTON].type = WWT_DROPDOWN_BUTTON; window_themes_widgets[WIDX_THEMES_PRESETS].type = WWT_DROPDOWN; window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].type = WWT_DROPDOWN_BUTTON; } else if (_selected_tab == WINDOW_THEMES_TAB_FEATURES) { window_themes_widgets[WIDX_THEMES_LIST].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_RIDE_LIGHTS].type = WWT_CHECKBOX; window_themes_widgets[WIDX_THEMES_RCT1_PARK_LIGHTS].type = WWT_CHECKBOX; window_themes_widgets[WIDX_THEMES_RCT1_SCENARIO_FONT].type = WWT_CHECKBOX; window_themes_widgets[WIDX_THEMES_DUPLICATE_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_DELETE_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RENAME_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_PRESETS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].type = WWT_EMPTY; widget_set_checkbox_value(w, WIDX_THEMES_RCT1_RIDE_LIGHTS, theme_get_flags() & UITHEME_FLAG_USE_LIGHTS_RIDE); widget_set_checkbox_value(w, WIDX_THEMES_RCT1_PARK_LIGHTS, theme_get_flags() & UITHEME_FLAG_USE_LIGHTS_PARK); widget_set_checkbox_value(w, WIDX_THEMES_RCT1_SCENARIO_FONT, theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT); } else { window_themes_widgets[WIDX_THEMES_LIST].type = WWT_SCROLL; window_themes_widgets[WIDX_THEMES_RCT1_RIDE_LIGHTS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_PARK_LIGHTS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RCT1_SCENARIO_FONT].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_DUPLICATE_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_DELETE_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_RENAME_BUTTON].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_PRESETS].type = WWT_EMPTY; window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].type = WWT_EMPTY; } }
static void window_themes_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget) { sint16 newSelectedTab; sint32 num_items; switch (widgetIndex) { case WIDX_THEMES_SETTINGS_TAB: case WIDX_THEMES_MAIN_UI_TAB: case WIDX_THEMES_PARK_TAB: case WIDX_THEMES_TOOLS_TAB: case WIDX_THEMES_RIDE_PEEPS_TAB: case WIDX_THEMES_EDITORS_TAB: case WIDX_THEMES_MISC_TAB: case WIDX_THEMES_PROMPTS_TAB: case WIDX_THEMES_FEATURES_TAB: newSelectedTab = widgetIndex - WIDX_THEMES_SETTINGS_TAB; if (_selected_tab == newSelectedTab) break; _selected_tab = (uint8)newSelectedTab; w->scrolls[0].v_top = 0; w->frame_no = 0; window_event_resize_call(w); window_invalidate(w); break; case WIDX_THEMES_PRESETS_DROPDOWN: theme_manager_load_available_themes(); num_items = (sint32)theme_manager_get_num_available_themes(); widget--; for (sint32 i = 0; i < num_items; i++) { gDropdownItemsFormat[i] = STR_OPTIONS_DROPDOWN_ITEM; gDropdownItemsArgs[i] = (uintptr_t)theme_manager_get_available_theme_name(i); } window_dropdown_show_text_custom_width( w->x + widget->left, w->y + widget->top, widget->bottom - widget->top + 1, w->colours[1], 0, DROPDOWN_FLAG_STAY_OPEN, num_items, widget->right - widget->left - 3 ); dropdown_set_checked((sint32)theme_manager_get_active_available_theme_index(), true); break; case WIDX_THEMES_RCT1_RIDE_LIGHTS: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_LIGHTS_RIDE); theme_save(); window_invalidate_all(); } break; case WIDX_THEMES_RCT1_PARK_LIGHTS: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_LIGHTS_PARK); theme_save(); window_invalidate_all(); } break; case WIDX_THEMES_RCT1_SCENARIO_FONT: if (theme_get_flags() & UITHEME_FLAG_PREDEFINED) { window_error_open(STR_THEMES_ERR_CANT_CHANGE_THIS_THEME, STR_NONE); } else { theme_set_flags(theme_get_flags() ^ UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT); theme_save(); window_invalidate_all(); } break; } }