diff options
| author | volzhs <volzhs@gmail.com> | 2017-09-26 20:08:25 +0900 | 
|---|---|---|
| committer | volzhs <volzhs@gmail.com> | 2017-09-26 20:08:25 +0900 | 
| commit | 3e0d18b9c00609523b6d3090cfdcad8f618a7b3f (patch) | |
| tree | c7af66a2a2596529d024bfc890df424e8a575773 | |
| parent | 59c3f61d57e745db2eb5ee2eab9c4cac17105f7b (diff) | |
Update theme property respectively
| -rw-r--r-- | editor/editor_settings.cpp | 6 | ||||
| -rw-r--r-- | editor/editor_settings.h | 5 | ||||
| -rw-r--r-- | editor/editor_themes.cpp | 55 | ||||
| -rw-r--r-- | editor/settings_config_dialog.cpp | 2 | 
4 files changed, 48 insertions, 20 deletions
| diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index e1333d9d82..325f30a453 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -54,7 +54,7 @@ EditorSettings *EditorSettings::get_singleton() {  	return singleton.ptr();  } -bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { +bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool p_emit_signal) {  	_THREAD_SAFE_METHOD_ @@ -90,7 +90,9 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {  		}  	} -	emit_signal("settings_changed"); +	if (p_emit_signal) { +		emit_signal("settings_changed"); +	}  	return true;  } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 6a814c41a5..19cf367d57 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -85,7 +85,7 @@ private:  	HashMap<String, VariantContainer> props;  	String resource_path; -	bool _set(const StringName &p_name, const Variant &p_value); +	bool _set(const StringName &p_name, const Variant &p_value, bool p_emit_signal = true);  	bool _get(const StringName &p_name, Variant &r_ret) const;  	void _get_property_list(List<PropertyInfo> *p_list) const; @@ -126,6 +126,9 @@ public:  		NOTIFICATION_EDITOR_SETTINGS_CHANGED = 10000  	}; +	void set_manually(const StringName &p_name, const Variant &p_value, bool p_emit_signal = false) { +		_set(p_name, p_value, p_emit_signal); +	}  	bool has(String p_var) const;  	static EditorSettings *get_singleton();  	void erase(String p_var); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index c38d357cea..b33c36867a 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -227,8 +227,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {  	const float default_contrast = 0.25;  	//Theme settings -	Color accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#000000")); -	Color base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#000000")); +	Color accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#699ce8")); +	Color base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#323b4f"));  	float contrast = EDITOR_DEF("interface/theme/contrast", default_contrast);  	int preset = EDITOR_DEF("interface/theme/preset", 0); @@ -240,33 +240,54 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {  	Color script_bg_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); +	Color preset_accent_color; +	Color preset_base_color; +	float preset_contrast;  	switch (preset) {  		case 0: { // Default -			accent_color = Color::html("#699ce8"); -			base_color = Color::html("#323b4f"); -			contrast = default_contrast; +			preset_accent_color = Color::html("#699ce8"); +			preset_base_color = Color::html("#323b4f"); +			preset_contrast = default_contrast;  		} break;  		case 1: { // Grey -			accent_color = Color::html("#3e3e3e"); -			base_color = Color::html("#3d3d3d"); -			contrast = 0.2; +			preset_accent_color = Color::html("#3e3e3e"); +			preset_base_color = Color::html("#3d3d3d"); +			preset_contrast = 0.2;  		} break;  		case 2: { // Godot 2 -			accent_color = Color::html("#86ace2"); -			base_color = Color::html("#3C3A44"); -			contrast = 0.25; +			preset_accent_color = Color::html("#86ace2"); +			preset_base_color = Color::html("#3C3A44"); +			preset_contrast = 0.25;  		} break;  		case 3: { // Arc -			accent_color = Color::html("#5294e2"); -			base_color = Color::html("#383c4a"); -			contrast = 0.25; +			preset_accent_color = Color::html("#5294e2"); +			preset_base_color = Color::html("#383c4a"); +			preset_contrast = 0.25;  		} break;  		case 4: { // Light -			accent_color = Color::html("#2070ff"); -			base_color = Color::html("#ffffff"); -			contrast = 0.08; +			preset_accent_color = Color::html("#2070ff"); +			preset_base_color = Color::html("#ffffff"); +			preset_contrast = 0.08;  		} break; +		default: { // Custom +			accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#699ce8")); +			base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#323b4f")); +			contrast = EDITOR_DEF("interface/theme/contrast", default_contrast); +		} +	} + +	if (preset != 5) { +		accent_color = preset_accent_color; +		base_color = preset_base_color; +		contrast = preset_contrast; +		EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", accent_color); +		EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color); +		EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast);  	} +	EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset); +	EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color); +	EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color); +	EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast);  	//Colors  	int AUTO_COLOR = 0; diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c90626976d..aada90173a 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -58,6 +58,8 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) {  	// color theme is changed  	if (full_name == "text_editor/theme/color_theme") {  		property_editor->get_property_editor()->update_tree(); +	} else if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") { +		EditorSettings::get_singleton()->set_manually("interface/theme/preset", 5); // set preset to Custom  	}  } |