mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 14:24:33 +01:00
Finished ini file loading and removed warnings
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "../sprites.h"
|
||||
#include "dropdown.h"
|
||||
#include "../interface/colour_schemes.h"
|
||||
#include "error.h"
|
||||
|
||||
enum {
|
||||
WINDOW_COLOUR_SCHEMES_TAB_MAIN_UI,
|
||||
@@ -55,6 +56,7 @@ static void window_colour_schemes_update(rct_window *w);
|
||||
static void window_colour_schemes_scrollgetsize();
|
||||
static void window_colour_schemes_scrollmousedown();
|
||||
static void window_colour_schemes_scrollmouseover();
|
||||
static void window_colour_schemes_textinput();
|
||||
static void window_colour_schemes_tooltip();
|
||||
static void window_colour_schemes_invalidate();
|
||||
static void window_colour_schemes_paint();
|
||||
@@ -81,7 +83,7 @@ static void* window_colour_schemes_events[] = {
|
||||
window_colour_schemes_scrollmousedown,
|
||||
window_colour_schemes_emptysub,
|
||||
window_colour_schemes_scrollmouseover,
|
||||
window_colour_schemes_emptysub,
|
||||
window_colour_schemes_textinput,
|
||||
window_colour_schemes_emptysub,
|
||||
window_colour_schemes_emptysub,
|
||||
window_colour_schemes_tooltip,
|
||||
@@ -107,6 +109,9 @@ enum WINDOW_STAFF_LIST_WIDGET_IDX {
|
||||
WIDX_COLOUR_SCHEMES_SETTINGS_TAB,
|
||||
WIDX_COLOUR_SCHEMES_PRESETS,
|
||||
WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN,
|
||||
WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON,
|
||||
WIDX_COLOUR_SCHEMES_DELETE_BUTTON,
|
||||
WIDX_COLOUR_SCHEMES_RENAME_BUTTON,
|
||||
WIDX_COLOUR_SCHEMES_COLORBTN_MASK,
|
||||
WIDX_COLOUR_SCHEMES_LIST,
|
||||
};
|
||||
@@ -126,6 +131,9 @@ static rct_widget window_colour_schemes_widgets[] = {
|
||||
{ WWT_TAB, 1, 220, 250, 17, 43, 0x02000144E, 5235 }, // settings tab
|
||||
{ WWT_DROPDOWN, 1, 125, 299, 60, 71, STR_NONE, STR_NONE }, // Preset colour schemes
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 288, 298, 61, 70, 876, STR_NONE },
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 10, 100, 82, 93, 5239, STR_NONE }, // Duplicate button
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 110, 200, 82, 93, 3349, STR_NONE }, // Delete button
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 210, 300, 82, 93, 3348, STR_NONE }, // Rename button
|
||||
{ WWT_COLORBTN, 1, 0, 0, 0, 0, STR_NONE, STR_NONE }, // color button mask
|
||||
{ WWT_SCROLL, 1, 3, 316, 60, 266, 2, STR_NONE }, // staff list
|
||||
{ WIDGETS_END },
|
||||
@@ -290,6 +298,19 @@ static int get_colour_scheme_tab_count()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_colour_scheme_index() {
|
||||
switch (_selected_tab) {
|
||||
case 0: return colour_scheme_get_index_by_class(window_colour_schemes_tab_1_classes[_color_index_1]);
|
||||
case 1: return colour_scheme_get_index_by_class(window_colour_schemes_tab_2_classes[_color_index_1]);
|
||||
case 2: return colour_scheme_get_index_by_class(window_colour_schemes_tab_3_classes[_color_index_1]);
|
||||
case 3: return colour_scheme_get_index_by_class(window_colour_schemes_tab_4_classes[_color_index_1]);
|
||||
case 4: return colour_scheme_get_index_by_class(window_colour_schemes_tab_5_classes[_color_index_1]);
|
||||
case 5: return colour_scheme_get_index_by_class(window_colour_schemes_tab_6_classes[_color_index_1]);
|
||||
case 6: return colour_scheme_get_index_by_class(window_colour_schemes_tab_7_classes[_color_index_1]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void window_colour_schemes_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w)
|
||||
{
|
||||
int sprite_idx;
|
||||
@@ -325,7 +346,10 @@ void window_colour_schemes_open()
|
||||
(1 << WIDX_COLOUR_SCHEMES_SETTINGS_TAB) |
|
||||
(1 << WIDX_COLOUR_SCHEMES_COLORBTN_MASK) |
|
||||
(1 << WIDX_COLOUR_SCHEMES_PRESETS) |
|
||||
(1 << WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN);
|
||||
(1 << WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN) |
|
||||
(1 << WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON) |
|
||||
(1 << WIDX_COLOUR_SCHEMES_DELETE_BUTTON) |
|
||||
(1 << WIDX_COLOUR_SCHEMES_RENAME_BUTTON);
|
||||
|
||||
window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_LIST].type = WWT_SCROLL;
|
||||
|
||||
@@ -368,15 +392,32 @@ static void window_colour_schemes_resize()
|
||||
|
||||
window_get_register(w);
|
||||
|
||||
w->min_width = 320;
|
||||
w->min_height = 270;
|
||||
if (w->width < w->min_width) {
|
||||
w->width = w->min_width;
|
||||
window_invalidate(w);
|
||||
if (_selected_tab == WINDOW_COLOUR_SCHEMES_TAB_SETTINGS) {
|
||||
window_set_resize(w, 320, 107, 320, 107);
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
if (w->height < w->min_height) {
|
||||
w->height = w->min_height;
|
||||
window_invalidate(w);
|
||||
else {
|
||||
w->min_width = 320;
|
||||
w->min_height = 270;
|
||||
w->max_width = 320;
|
||||
w->max_height = 450;
|
||||
|
||||
if (w->width < w->min_width) {
|
||||
w->width = w->min_width;
|
||||
window_invalidate(w);
|
||||
}
|
||||
if (w->height < w->min_height) {
|
||||
w->height = w->min_height;
|
||||
window_invalidate(w);
|
||||
}
|
||||
if (w->width > w->max_width) {
|
||||
w->width = w->max_width;
|
||||
window_invalidate(w);
|
||||
}
|
||||
if (w->height > w->max_height) {
|
||||
w->height = w->max_height;
|
||||
window_invalidate(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,24 +435,30 @@ static void window_colour_schemes_mousedown(int widgetIndex, rct_window* w, rct_
|
||||
case WIDX_COLOUR_SCHEMES_MISC_TAB:
|
||||
case WIDX_COLOUR_SCHEMES_PROMPTS_TAB:
|
||||
case WIDX_COLOUR_SCHEMES_SETTINGS_TAB:
|
||||
/*if (widgetIndex == WIDX_COLOUR_SCHEMES_SETTINGS_TAB) {
|
||||
window_set_resize(w, 320, 100, 320, 100);
|
||||
w->flags &= ~WF_RESIZABLE;
|
||||
}
|
||||
else if (_selected_tab == WINDOW_COLOUR_SCHEMES_TAB_SETTINGS) {
|
||||
w->flags |= WF_RESIZABLE;
|
||||
window_set_resize(w, 320, 270, 320, 450);
|
||||
}*/
|
||||
newSelectedTab = widgetIndex - WIDX_COLOUR_SCHEMES_MAIN_UI_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_COLOUR_SCHEMES_PRESETS_DROPDOWN:
|
||||
num_items = gConfigColourSchemes.num_presets;
|
||||
|
||||
widget--;
|
||||
for (i = 0; i < num_items; i++) {
|
||||
//gDropdownItemsFormat[i] = 2777;
|
||||
//gDropdownItemsArgs[i] = 1170 | ((uint64)(intptr_t)gConfigColourSchemes.presets[i].name << 16);
|
||||
//gDropdownItemsFormat[i] = 1170;
|
||||
//gDropdownItemsArgs[i] = ((uint64)&gConfigColourSchemes.presets[i].name) << 32;
|
||||
gDropdownItemsFormat[i] = 1170;
|
||||
gDropdownItemsArgs[i] = &gConfigColourSchemes.presets[i].name;
|
||||
gDropdownItemsFormat[i] = 2777;
|
||||
gDropdownItemsArgs[i] = (uint64)&gConfigColourSchemes.presets[i].name;
|
||||
}
|
||||
|
||||
window_dropdown_show_text_custom_width(
|
||||
@@ -426,6 +473,25 @@ static void window_colour_schemes_mousedown(int widgetIndex, rct_window* w, rct_
|
||||
|
||||
gDropdownItemsChecked = 1 << gCurrentColourSchemePreset;
|
||||
break;
|
||||
case WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON:
|
||||
window_text_input_open(w, widgetIndex, 5239, 5240, 1170, (rct_string_id)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name, 64);
|
||||
break;
|
||||
case WIDX_COLOUR_SCHEMES_DELETE_BUTTON:
|
||||
if (gCurrentColourSchemePreset >= 2) {
|
||||
colour_scheme_delete_preset(gCurrentColourSchemePreset);
|
||||
}
|
||||
else {
|
||||
window_error_open(5241, STR_NONE);
|
||||
}
|
||||
break;
|
||||
case WIDX_COLOUR_SCHEMES_RENAME_BUTTON:
|
||||
if (gCurrentColourSchemePreset >= 2) {
|
||||
window_text_input_open(w, widgetIndex, 3348, 5240, 1170, (rct_string_id)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name, 64);
|
||||
}
|
||||
else {
|
||||
window_error_open(5241, STR_NONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,15 +505,20 @@ static void window_colour_schemes_dropdown()
|
||||
case WIDX_COLOUR_SCHEMES_LIST:
|
||||
if (dropdownIndex != -1) {
|
||||
get_colour_scheme_tab()->colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80;
|
||||
gConfigColourSchemes.presets[gCurrentColourSchemePreset].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80;
|
||||
window_invalidate_all();
|
||||
_color_index_1 = -1;
|
||||
_color_index_2 = -1;
|
||||
|
||||
if (gCurrentColourSchemePreset >= 2)
|
||||
colour_schemes_save_preset(gCurrentColourSchemePreset);
|
||||
}
|
||||
break;
|
||||
case WIDX_COLOUR_SCHEMES_PRESETS_DROPDOWN:
|
||||
if (dropdownIndex != -1) {
|
||||
colour_scheme_change_preset(dropdownIndex);
|
||||
}
|
||||
config_save_default();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -464,8 +535,6 @@ void window_colour_schemes_update(rct_window *w)
|
||||
}
|
||||
|
||||
void window_colour_schemes_scrollgetsize() {
|
||||
int spriteIndex;
|
||||
rct_peep *peep;
|
||||
rct_window *w;
|
||||
|
||||
window_get_register(w);
|
||||
@@ -493,18 +562,14 @@ void window_colour_schemes_scrollgetsize() {
|
||||
}
|
||||
|
||||
void window_colour_schemes_scrollmousedown() {
|
||||
int i, spriteIndex;
|
||||
short x, y, scrollIndex;
|
||||
uint8 selectedTab;
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
|
||||
window_scrollmouse_get_registers(w, scrollIndex, x, y);
|
||||
|
||||
if (_selected_tab == 7)
|
||||
return;
|
||||
|
||||
selectedTab = _selected_tab;
|
||||
if (y / _row_height < get_colour_scheme_tab_count()) {
|
||||
int y2 = y % _row_height;
|
||||
_color_index_1 = y / _row_height;
|
||||
@@ -518,10 +583,17 @@ void window_colour_schemes_scrollmousedown() {
|
||||
window_dropdown_show_colour(w, &(window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_COLORBTN_MASK]), w->colours[1], get_colour_scheme_tab()->colours[_color_index_2]);
|
||||
}
|
||||
else if (x >= _button_offset_x && x < _button_offset_x + 12 * 6 - 1 && y2 >= _check_offset_y && y2 < _check_offset_y + 11) {
|
||||
if (get_colour_scheme_tab()->colours[_color_index_2] & 0x80)
|
||||
if (get_colour_scheme_tab()->colours[_color_index_2] & 0x80) {
|
||||
get_colour_scheme_tab()->colours[_color_index_2] &= 0x7F;
|
||||
else
|
||||
|
||||
gConfigColourSchemes.presets[gCurrentColourSchemePreset].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] &= 0x7F;
|
||||
}
|
||||
else {
|
||||
get_colour_scheme_tab()->colours[_color_index_2] |= 0x80;
|
||||
gConfigColourSchemes.presets[gCurrentColourSchemePreset].colour_schemes[get_colour_scheme_index()].colours[_color_index_2] |= 0x80;
|
||||
}
|
||||
if (gCurrentColourSchemePreset >= 2)
|
||||
colour_schemes_save_preset(gCurrentColourSchemePreset);
|
||||
window_invalidate_all();
|
||||
}
|
||||
}
|
||||
@@ -529,7 +601,6 @@ void window_colour_schemes_scrollmousedown() {
|
||||
}
|
||||
|
||||
void window_colour_schemes_scrollmouseover() {
|
||||
int i;
|
||||
short x, y, scrollIndex;
|
||||
rct_window *w;
|
||||
|
||||
@@ -539,6 +610,57 @@ void window_colour_schemes_scrollmouseover() {
|
||||
// return;
|
||||
}
|
||||
|
||||
static bool valid_characters(const char *name)
|
||||
{
|
||||
for (int i = 0; name[i] != '\0'; i++) {
|
||||
if (name[i] == '\\' || name[i] == '/' || name[i] == ':' || name[i] == '?' || name[i] == '*' || name[i] == '<' || name[i] == '>' || name[i] == '|')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void window_colour_schemes_textinput()
|
||||
{
|
||||
rct_window *w;
|
||||
short widgetIndex;
|
||||
uint8 result;
|
||||
char *text;
|
||||
|
||||
window_textinput_get_registers(w, widgetIndex, result, text);
|
||||
|
||||
if (!result || text[0] == 0)
|
||||
return;
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON:
|
||||
case WIDX_COLOUR_SCHEMES_RENAME_BUTTON:
|
||||
if (valid_characters(text)) {
|
||||
bool nameTaken = false;
|
||||
for (int i = 0; i < gConfigColourSchemes.num_presets; i++) {
|
||||
if (strcmp(gConfigColourSchemes.presets[i].name, text) == 0) {
|
||||
window_error_open(5242, STR_NONE);
|
||||
nameTaken = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nameTaken) {
|
||||
if (widgetIndex == WIDX_COLOUR_SCHEMES_DUPLICATE_BUTTON) {
|
||||
colour_scheme_create_preset(text);
|
||||
}
|
||||
else {
|
||||
colour_scheme_rename_preset(gCurrentColourSchemePreset, text);
|
||||
}
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
}
|
||||
}
|
||||
else {
|
||||
window_error_open(5243, STR_NONE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void window_colour_schemes_tooltip()
|
||||
{
|
||||
RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST;
|
||||
@@ -582,8 +704,6 @@ void window_colour_schemes_invalidate()
|
||||
}
|
||||
|
||||
void window_colour_schemes_paint() {
|
||||
int i;
|
||||
uint8 selectedTab;
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
|
||||
@@ -599,13 +719,13 @@ void window_colour_schemes_paint() {
|
||||
gfx_draw_string_left(dpi, 5237, w, w->colours[1], w->x + 220, 58 - 12 + w->y + 1);
|
||||
}
|
||||
else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = &gConfigColourSchemes.presets[gCurrentColourSchemePreset].name;
|
||||
gfx_draw_string_left(dpi, 5238, NULL, 12, w->x + 10, w->y + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].top + 1);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint32) = (uint32)&gConfigColourSchemes.presets[gCurrentColourSchemePreset].name;
|
||||
gfx_draw_string_left(dpi, 5238, NULL, w->colours[1], w->x + 10, w->y + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].top + 1);
|
||||
gfx_draw_string_left(
|
||||
dpi,
|
||||
1170,
|
||||
(void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS,
|
||||
12,
|
||||
w->colours[1],
|
||||
w->x + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].left + 1,
|
||||
w->y + window_colour_schemes_widgets[WIDX_COLOUR_SCHEMES_PRESETS].top
|
||||
);
|
||||
@@ -618,7 +738,7 @@ void window_colour_schemes_paint() {
|
||||
*/
|
||||
void window_colour_schemes_scrollpaint()
|
||||
{
|
||||
int spriteIndex, y;
|
||||
int y;
|
||||
uint8 selectedTab;
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
|
||||
@@ -724,7 +724,7 @@ void window_staff_unknown_05(){
|
||||
void window_staff_stats_invalidate(){
|
||||
rct_window* w;
|
||||
window_get_register(w);
|
||||
colour_scheme_update_by_class(w, WC_STAFF);
|
||||
colour_scheme_update_by_class(w, (rct_windowclass)WC_STAFF);
|
||||
|
||||
if (window_staff_page_widgets[w->page] != w->widgets){
|
||||
w->widgets = window_staff_page_widgets[w->page];
|
||||
@@ -757,7 +757,7 @@ void window_staff_stats_invalidate(){
|
||||
void window_staff_options_invalidate(){
|
||||
rct_window* w;
|
||||
window_get_register(w);
|
||||
colour_scheme_update_by_class(w, WC_STAFF);
|
||||
colour_scheme_update_by_class(w, (rct_windowclass)WC_STAFF);
|
||||
|
||||
if (window_staff_page_widgets[w->page] != w->widgets){
|
||||
w->widgets = window_staff_page_widgets[w->page];
|
||||
@@ -830,7 +830,7 @@ void window_staff_options_invalidate(){
|
||||
void window_staff_overview_invalidate(){
|
||||
rct_window* w;
|
||||
window_get_register(w);
|
||||
colour_scheme_update_by_class(w, WC_STAFF);
|
||||
colour_scheme_update_by_class(w, (rct_windowclass)WC_STAFF);
|
||||
|
||||
if (window_staff_page_widgets[w->page] != w->widgets){
|
||||
w->widgets = window_staff_page_widgets[w->page];
|
||||
|
||||
Reference in New Issue
Block a user