Pixel-Composer/objects/o_dialog_preference/Draw_64.gml

80 lines
2.7 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
if !ready exit;
#region base UI
2023-11-13 15:42:14 +01:00
DIALOG_DRAW_BG
2022-11-03 11:44:49 +01:00
if(sFOCUS)
2023-11-13 15:42:14 +01:00
DIALOG_DRAW_FOCUS
2022-01-13 05:24:03 +01:00
2023-06-10 13:59:45 +02:00
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
2023-06-05 18:27:53 +02:00
draw_text(dialog_x + ui(56), dialog_y + ui(20), __txt("Preferences"));
2022-11-03 11:44:49 +01:00
2023-02-28 09:43:01 +01:00
var bx = dialog_x + ui(24);
var by = dialog_y + ui(18);
2023-06-05 18:27:53 +02:00
if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, sFOCUS, sHOVER, destroy_on_click_out? __txt("Pin") : __txt("Unpin"),
2023-02-28 09:43:01 +01:00
THEME.pin, !destroy_on_click_out, destroy_on_click_out? COLORS._main_icon : COLORS._main_icon_light) == 2)
destroy_on_click_out = !destroy_on_click_out;
2022-01-13 05:24:03 +01:00
#endregion
#region page
sp_page.setFocusHover(sFOCUS, sHOVER);
sp_page.draw(dialog_x + ui(padding), dialog_y + ui(title_height));
2022-01-13 05:24:03 +01:00
#endregion
#region draw
section_current = "";
2023-02-28 09:43:01 +01:00
var px = dialog_x + ui(padding + page_width);
var py = dialog_y + ui(title_height);
var pw = dialog_w - ui(padding + page_width + padding);
var ph = dialog_h - ui(title_height + padding);
2023-11-13 15:42:14 +01:00
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
2022-01-13 05:24:03 +01:00
tb_search.auto_update = true;
tb_search.no_empty = false;
tb_search.font = f_p1;
2022-11-03 11:44:49 +01:00
tb_search.active = sFOCUS;
tb_search.hover = sHOVER;
tb_search.draw(dialog_x + dialog_w - ui(padding - 8), dialog_y + ui(title_height) / 2, ui(200), ui(28), search_text, mouse_ui, fa_right, fa_center);
2023-02-28 09:43:01 +01:00
draw_sprite_ui_uniform(THEME.search, 0, dialog_x + dialog_w - ui(padding + 208), dialog_y + ui(title_height) / 2, 1, COLORS._main_text_sub);
2022-01-13 05:24:03 +01:00
if(page_current == 0) {
current_list = pref_global;
2023-06-21 20:36:53 +02:00
sp_pref.setFocusHover(sFOCUS, sHOVER);
2023-02-28 09:43:01 +01:00
sp_pref.draw(px, py);
2023-04-07 21:25:27 +02:00
} else if(page_current == 1) {
2023-01-04 02:30:04 +01:00
current_list = pref_appr;
2023-06-21 20:36:53 +02:00
sp_pref.setFocusHover(sFOCUS, sHOVER);
2023-02-28 09:43:01 +01:00
sp_pref.draw(px, py);
2023-04-07 21:25:27 +02:00
} else if(page_current == 2) {
2022-11-18 03:20:31 +01:00
var _w = ui(200);
var _h = TEXTBOX_HEIGHT;
2023-06-05 18:27:53 +02:00
var _x = dialog_x + dialog_w - ui(8);
var bx = _x - ui(48);
var _txt = __txtx("pref_reset_color", "Reset colors");
var b = buttonInstant(THEME.button_hide, bx, py, ui(32), ui(32), mouse_ui, sFOCUS, sHOVER, _txt, THEME.refresh);
2022-11-18 03:20:31 +01:00
if(b == 2) {
2023-12-08 10:11:48 +01:00
var path = $"{DIRECTORY}Themes/{PREFERENCES.theme}/override.json";
2023-12-08 03:50:09 +01:00
if(file_exists_empty(path)) file_delete(path);
2023-10-31 05:30:42 +01:00
loadColor(PREFERENCES.theme);
2022-11-18 03:20:31 +01:00
}
2023-02-28 09:43:01 +01:00
var x1 = dialog_x + ui(padding + page_width);
2022-11-18 03:20:31 +01:00
var x2 = _x - ui(32);
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(x1 + ui(8), py + _h / 2, __txt("Theme"));
2023-06-21 20:36:53 +02:00
sb_theme.setFocusHover(sFOCUS, sHOVER);
2023-10-31 05:30:42 +01:00
sb_theme.draw(x2 - ui(24) - _w, py, _w, _h, PREFERENCES.theme);
2022-11-18 03:20:31 +01:00
2023-06-21 20:36:53 +02:00
sp_colors.setFocusHover(sFOCUS, sHOVER);
2023-02-28 09:43:01 +01:00
sp_colors.draw(px, py + ui(40));
2023-04-07 21:25:27 +02:00
} else if(page_current == 3) {
2022-12-10 05:06:01 +01:00
if(mouse_press(mb_left, sFOCUS))
2022-11-18 03:20:31 +01:00
hk_editing = noone;
2022-01-13 05:24:03 +01:00
2023-06-21 20:36:53 +02:00
sp_hotkey.setFocusHover(sFOCUS, sHOVER);
2023-02-28 09:43:01 +01:00
sp_hotkey.draw(px, py);
2022-01-13 05:24:03 +01:00
}
#endregion