Răsfoiți Sursa

Improved VS node coloring

Daniel J. Ramirez 8 ani în urmă
părinte
comite
60f054d3ac

+ 6 - 2
editor/editor_themes.cpp

@@ -171,6 +171,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool dark_theme = tr
 		}
 
 	bool force_filter = !(p_thumb_size == 64 && p_thumb_size == 32); // we dont need filter with original resolution
+	// generate thumb files with the given thumb size
 	if (p_thumb_size >= 64) {
 		float scale = (float)p_thumb_size / 64.0 * EDSCALE;
 		for (int i = 0; i < editor_bg_thumbs_count; i++) {
@@ -350,7 +351,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 	style_popup->set_default_margin(MARGIN_BOTTOM, default_margin_size * 2);
 	style_popup->set_border_color_all(contrast_color_1);
 	style_popup->set_border_width_all(MAX(EDSCALE, border_width));
-	style_popup->set_shadow_color(Color(0, 0, 0, dark_theme ? 0.3 : 0.1));
+	const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1);
+	style_popup->set_shadow_color(shadow_color);
 	style_popup->set_shadow_size(4 * EDSCALE);
 
 	Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
@@ -738,7 +740,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 	graphsb->set_border_width(MARGIN_TOP, 22 * EDSCALE + border_width);
 	Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(0, 0, 0, 0.4), 16, 24, 16, 5);
 	graphsbselected->set_border_width_all(border_width);
-	graphsbselected->set_border_color_all(Color(1, 1, 1, 0.9));
+	graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
+	graphsbselected->set_shadow_size(8 * EDSCALE);
+	graphsbselected->set_shadow_color(shadow_color);
 	graphsbselected->set_border_width(MARGIN_TOP, 22 * EDSCALE + border_width);
 	Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(0, 0, 0, 0.3), 16, 24, 16, 5);
 	graphsbcomment->set_border_width_all(border_width);

+ 23 - 9
modules/visual_script/visual_script_editor.cpp

@@ -491,9 +491,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
 			gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT);
 		}
 
-		if (EditorSettings::get_singleton()->has("editors/visual_script/color_" + node->get_category())) {
-			Color c = EditorSettings::get_singleton()->get("editors/visual_script/color_" + node->get_category());
-			gnode->set_self_modulate(c);
+		if (node_styles.has(node->get_category())) {
+			gnode->add_style_override("frame", node_styles[node->get_category()]);
 		}
 
 		gnode->set_meta("__vnode", node);
@@ -2743,6 +2742,27 @@ void VisualScriptEditor::_notification(int p_what) {
 		node_filter->add_icon_override("right_icon", Control::get_icon("Search", "EditorIcons"));
 		variable_editor->connect("changed", this, "_update_members");
 		signal_editor->connect("changed", this, "_update_members");
+
+		List<Pair<String, Color> > colors;
+		colors.push_back(Pair<String, Color>("functions", Color(1, 0.9, 0.9)));
+		colors.push_back(Pair<String, Color>("data", Color(0.9, 1.0, 0.9)));
+		colors.push_back(Pair<String, Color>("operators", Color(0.9, 0.9, 1.0)));
+		colors.push_back(Pair<String, Color>("flow_control", Color(1.0, 1.0, 1.0)));
+		colors.push_back(Pair<String, Color>("custom", Color(0.8, 1.0, 1.0)));
+		colors.push_back(Pair<String, Color>("constants", Color(1.0, 0.8, 1.0)));
+
+		for (List<Pair<String, Color> >::Element *E = colors.front(); E; E = E->next()) {
+			print_line(E->get().first);
+			Ref<StyleBoxFlat> sb = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("frame", "GraphNode");
+			if (sb != NULL) {
+				Ref<StyleBoxFlat> frame_style = sb->duplicate();
+				Color c = sb->get_border_color(MARGIN_TOP);
+				Color cn = E->get().second;
+				cn.a = c.a;
+				frame_style->set_border_color_all(cn);
+				node_styles[E->get().first] = frame_style;
+			}
+		}
 	}
 	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
 		left_vsplit->set_visible(is_visible_in_tree());
@@ -3366,12 +3386,6 @@ void VisualScriptEditor::free_clipboard() {
 static void register_editor_callback() {
 
 	ScriptEditor::register_create_script_editor_function(create_editor);
-	EditorSettings::get_singleton()->set("editors/visual_script/color_functions", Color(1, 0.9, 0.9));
-	EditorSettings::get_singleton()->set("editors/visual_script/color_data", Color(0.9, 1.0, 0.9));
-	EditorSettings::get_singleton()->set("editors/visual_script/color_operators", Color(0.9, 0.9, 1.0));
-	EditorSettings::get_singleton()->set("editors/visual_script/color_flow_control", Color(1.0, 1.0, 1.0));
-	EditorSettings::get_singleton()->set("editors/visual_script/color_custom", Color(0.8, 1.0, 1.0));
-	EditorSettings::get_singleton()->set("editors/visual_script/color_constants", Color(1.0, 0.8, 1.0));
 
 	ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected"));
 	ED_SHORTCUT("visual_script_editor/toggle_breakpoint", TTR("Toggle Breakpoint"), KEY_F9);

+ 1 - 0
modules/visual_script/visual_script_editor.h

@@ -136,6 +136,7 @@ class VisualScriptEditor : public ScriptEditorBase {
 		Vector<Pair<Variant::Type, String> > args;
 	};
 
+	HashMap<StringName, Ref<StyleBox>, StringNameHasher> node_styles;
 	StringName edited_func;
 
 	void _update_graph_connections();