Browse Source

Move VIEWPORT_COL to theme

luboslenco 8 tháng trước cách đây
mục cha
commit
fa6fc0836a

+ 1 - 0
armorcore/sources/iron_ui.c

@@ -2587,4 +2587,5 @@ void ui_theme_default(ui_theme_t *t) {
 	t->FULL_TABS = false;
 	t->ROUND_CORNERS = true;
 	t->SHADOWS = true;
+	t->VIEWPORT_COL = 0xff080808;
 }

+ 1 - 0
armorcore/sources/iron_ui.h

@@ -50,6 +50,7 @@ typedef struct ui_theme {
 	/*bool*/int FULL_TABS; // Make tabs take full window width
 	/*bool*/int ROUND_CORNERS;
 	/*bool*/int SHADOWS;
+	int VIEWPORT_COL;
 } ui_theme_t;
 
 typedef struct ui_options {

+ 1 - 0
armorcore/sources/ts/ui.ts

@@ -532,4 +532,5 @@ let ui_theme_keys: string[] = [
 	"FULL_TABS",
 	"ROUND_CORNERS",
 	"SHADOWS",
+	"VIEWPORT_COL"
 ];

+ 2 - 1
base/assets/themes/light.json

@@ -25,5 +25,6 @@
 	"LINK_STYLE": 0,
 	"FULL_TABS": 0,
 	"ROUND_CORNERS": 1,
-	"SHADOWS": 1
+	"SHADOWS": 1,
+	"VIEWPORT_COL": 4289374890
 }

+ 5 - 41
base/sources/box_preferences.ts

@@ -6,7 +6,6 @@ let box_preferences_theme_handle: ui_handle_t;
 let box_preferences_preset_handle: ui_handle_t;
 let box_preferences_locales: string[] = null;
 let box_preferences_themes: string[] = null;
-let box_preferences_world_color: i32 = 0xff080808;
 let _box_preferences_f: string;
 let _box_preferences_h: ui_handle_t;
 let _box_preferences_i: i32;
@@ -241,47 +240,8 @@ function box_preferences_show() {
 
 			ui_end_sticky();
 
-			let i: i32 = 0;
-			let hlist: ui_handle_t = ui_handle(__ID__);
-
-			// Viewport color
-			let h: ui_handle_t = ui_nest(hlist, i++);
-			if (h.init) {
-				h.color = box_preferences_world_color;
-			}
-			let row: f32[] = [1 / 8, 7 / 8];
-			ui_row(row);
-			ui_text("", 0, h.color);
-			if (ui.is_hovered && ui.input_released) {
-				_box_preferences_h = h;
-				ui_menu_draw(function (ui: ui_t) {
-					ui.changed = false;
-					ui_color_wheel(_box_preferences_h, false, -1, 11 * ui.ops.theme.ELEMENT_H * ui_SCALE(ui), true);
-					if (ui.changed) {
-						ui_menu_keep_open = true;
-					}
-				});
-			}
-			let val: u32 = h.color;
-			h.text = i32_to_string_hex(val);
-			ui_text_input(h, "VIEWPORT_COL");
-			h.color = parse_int_hex(h.text);
-
-			if (box_preferences_world_color != h.color) {
-				box_preferences_world_color = h.color;
-				let b: u8_array_t = u8_array_create(4);
-				b[0] = color_get_rb(box_preferences_world_color);
-				b[1] = color_get_gb(box_preferences_world_color);
-				b[2] = color_get_bb(box_preferences_world_color);
-				b[3] = 255;
-				context_raw.empty_envmap = image_from_bytes(b, 1, 1);
-				context_raw.ddirty = 2;
-				if (!context_raw.show_envmap) {
-					scene_world._.envmap = context_raw.empty_envmap;
-				}
-			}
-
 			// Theme fields
+			let hlist: ui_handle_t = ui_handle(__ID__);
 			let u32_theme: u32_ptr = base_theme;
 			for (let i: i32 = 0; i < ui_theme_keys.length; ++i) {
 				let key: string = ui_theme_keys[i];
@@ -307,6 +267,10 @@ function box_preferences_show() {
 							}
 						});
 					}
+
+					if (key == "VIEWPORT_COL" && ui_base_viewport_col != val) {
+						ui_base_set_viewport_col(val);
+					}
 				}
 
 				ui.changed = false;

+ 20 - 6
base/sources/ui_base.ts

@@ -15,6 +15,7 @@ let ui_base_redo_tap_time: f32 = 0.0;
 let ui_base_hwnds: ui_handle_t[] = ui_base_init_hwnds();
 let ui_base_htabs: ui_handle_t[] = ui_base_init_htabs();
 let ui_base_hwnd_tabs: tab_draw_array_t[] = ui_base_init_hwnd_tabs();
+let ui_base_viewport_col: i32;
 
 ///if is_lab
 let ui_base_default_sidebar_mini_w: i32 = 0;
@@ -122,12 +123,7 @@ function ui_base_init() {
 	}
 
 	if (context_raw.empty_envmap == null) {
-		let b: u8_array_t = u8_array_create(4);
-		b[0] = 8;
-		b[1] = 8;
-		b[2] = 8;
-		b[3] = 255;
-		context_raw.empty_envmap = image_from_bytes(b, 1, 1);
+		ui_base_make_empty_envmap(base_theme.VIEWPORT_COL);
 	}
 	if (context_raw.preview_envmap == null) {
 		let b: u8_array_t = u8_array_create(4);
@@ -1595,3 +1591,21 @@ function ui_base_tag_ui_redraw() {
 	ui_base_hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 	ui_toolbar_handle.redraws = 2;
 }
+
+function ui_base_make_empty_envmap(col: i32) {
+	ui_base_viewport_col = col;
+	let b: u8_array_t = u8_array_create(4);
+	b[0] = color_get_rb(col);
+	b[1] = color_get_gb(col);
+	b[2] = color_get_bb(col);
+	b[3] = 255;
+	context_raw.empty_envmap = image_from_bytes(b, 1, 1);
+}
+
+function ui_base_set_viewport_col(col: i32) {
+	ui_base_make_empty_envmap(col);
+	context_raw.ddirty = 2;
+	if (!context_raw.show_envmap) {
+		scene_world._.envmap = context_raw.empty_envmap;
+	}
+}