From d35f533950fcf26af01c80a98e3dbe3f2a4da3c4 Mon Sep 17 00:00:00 2001 From: myin Date: Fri, 20 Oct 2023 18:16:28 +0200 Subject: [PATCH] update --- godot/addons/debug/Env.gd | 14 +- .../addons/godot-css-theme/ArgumentParser.gd | 216 ------------------ godot/addons/godot-css-theme/CSSParser.gd | 10 + godot/addons/godot-css-theme/LICENSE.txt | 4 +- godot/addons/godot-css-theme/ThemeApplier.gd | 12 +- godot/addons/godot-css-theme/convert.gd | 16 +- .../godot-css-theme/editor/EditorButton.gd | 9 + .../godot-css-theme/editor/css_code_edit.gd | 49 ++++ .../godot-css-theme/editor/css_editor.gd | 74 ++++++ .../godot-css-theme/editor/css_editor.tscn | 101 ++++++++ .../godot-css-theme/editor/css_syntax.tres | 84 +++++++ godot/addons/godot-css-theme/plugin.gd | 23 +- scripts/generate-theme.sh | 5 - scripts/translations.sh | 2 +- 14 files changed, 382 insertions(+), 237 deletions(-) delete mode 100644 godot/addons/godot-css-theme/ArgumentParser.gd create mode 100644 godot/addons/godot-css-theme/editor/EditorButton.gd create mode 100644 godot/addons/godot-css-theme/editor/css_code_edit.gd create mode 100644 godot/addons/godot-css-theme/editor/css_editor.gd create mode 100644 godot/addons/godot-css-theme/editor/css_editor.tscn create mode 100644 godot/addons/godot-css-theme/editor/css_syntax.tres delete mode 100644 scripts/generate-theme.sh diff --git a/godot/addons/debug/Env.gd b/godot/addons/debug/Env.gd index 524d748..ee68a36 100644 --- a/godot/addons/debug/Env.gd +++ b/godot/addons/debug/Env.gd @@ -1,20 +1,28 @@ extends Node -var log_level = Logger.Level.DEBUG -var version = "dev" : set = _set_version -var _logger = Logger.new("Env") +var log_level := Logger.Level.DEBUG +var version := "dev" : set = _set_version +var _logger := Logger.new("Env") +var _demo := false func _ready(): if is_prod(): log_level = Logger.Level.INFO + _logger.info("Running version %s on %s" % [version, OS.get_name()]) func _set_version(v: String) -> void: if v == "": return version = v + if is_prod(): + _demo = true # TODO: steam + func is_prod() -> bool: return version != "dev" func is_web() -> bool: return OS.has_feature("web") + +func is_demo() -> bool: + return _demo \ No newline at end of file diff --git a/godot/addons/godot-css-theme/ArgumentParser.gd b/godot/addons/godot-css-theme/ArgumentParser.gd deleted file mode 100644 index c90d2f9..0000000 --- a/godot/addons/godot-css-theme/ArgumentParser.gd +++ /dev/null @@ -1,216 +0,0 @@ -# ############################################################################## -#(G)odot (U)nit (T)est class (https://github.com/bitwes/Gut) -# -# ############################################################################## -# The MIT License (MIT) -# ===================== -# -# Copyright (c) 2020 Tom "Butch" Wesley -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# ############################################################################## -# Description -# ----------- -# Command line interface for the GUT unit testing tool. Allows you to run tests -# from the command line instead of running a scene. Place this script along with -# gut.gd into your scripts directory at the root of your project. Once there you -# can run this script (from the root of your project) using the following command: -# godot -s -d test/gut/gut_cmdln.gd -# -# See the readme for a list of options and examples. You can also use the -gh -# option to get more information about how to use the command line interface. -# ############################################################################## - -# ------------------------------------------------------------------------------ -# Helper class to resolve the various different places where an option can -# be set. Using the get_value method will enforce the order of precedence of: -# 1. command line value -# 2. config file value -# 3. default value -# -# The idea is that you set the base_opts. That will get you a copies of the -# hash with null values for the other types of values. Lower precedented hashes -# will punch through null values of higher precedented hashes. -# ------------------------------------------------------------------------------ -# -# Slighly modified to make it more generic - -class_name ArgumentParser - -var base_opts = null -var cmd_opts = null -var config_opts = null - -var _banner := "" -var _default_options := {} - -const CONFIG_ARG = "config_file" -const HELP_ARG = ["--help", "-h"] - -func setup(banner: String, options: Dictionary) -> bool: - if not options.has(CONFIG_ARG): return false - - _banner = banner - _default_options = options - - var opts = {} - for opt in _default_options: - var value = _default_options[opt] as Array - if value.size() != 2: return false - opts[opt] = value[0] - set_base_opts(opts) - return true - -func get_value(key): - return _nvl(cmd_opts[key], _nvl(config_opts[key], base_opts[key])) - -func set_base_opts(opts): - base_opts = opts - cmd_opts = _null_copy(opts) - config_opts = _null_copy(opts) - -# creates a copy of a hash with all values null. -func _null_copy(h): - var new_hash = {} - for key in h: - new_hash[key] = null - return new_hash - -func _nvl(a, b): - if(a == null): - return b - else: - return a - -func _string_it(h): - var to_return = '' - for key in h: - to_return += str('(',key, ':', _nvl(h[key], 'NULL'), ')') - return to_return - -func to_s(): - return str("base:\n", _string_it(base_opts), "\n", \ - "config:\n", _string_it(config_opts), "\n", \ - "cmd:\n", _string_it(cmd_opts), "\n", \ - "resolved:\n", _string_it(get_resolved_values())) - -func get_resolved_values(): - var to_return = {} - for key in base_opts: - to_return[key] = get_value(key) - return to_return - -func to_s_verbose(): - var to_return = '' - var resolved = get_resolved_values() - for key in base_opts: - to_return += str(key, "\n") - to_return += str(' default: ', _nvl(base_opts[key], 'NULL'), "\n") - to_return += str(' config: ', _nvl(config_opts[key], ' --'), "\n") - to_return += str(' cmd: ', _nvl(cmd_opts[key], ' --'), "\n") - to_return += str(' final: ', _nvl(resolved[key], 'NULL'), "\n") - - return to_return - -func _setup_options(): - var opts = OptParse.new() - opts.set_banner(_banner) - - for opt in _default_options: - var values = _default_options[opt] as Array - if values.size() != 2: continue - - opts.add(_build_cmd_option(opt), values[0], values[1]) - - return opts - -func _build_cmd_option(opt: String) -> String: - return '--%s' % opt - -# Parses options, applying them to the _tester or setting values -# in the options struct. -func _extract_command_line_options(from, to): - for opt in _default_options: - to[opt] = from.get_value(_build_cmd_option(opt)) - - -func _load_options_from_config_file(file_path, into): - # SHORTCIRCUIT - if(not FileAccess.file_exists(file_path)): - if(file_path != _default_options[CONFIG_ARG][0]): - print('ERROR: Config File "', file_path, '" does not exist.') - return -1 - else: - return 1 - - var file = FileAccess.open(file_path, FileAccess.READ) - var json = file.get_as_text() - file.close() - - var results = JSON.parse_string(json) - # SHORTCIRCUIT - if(results.error != OK): - print("\n\n",'!! ERROR parsing file: ', file_path) - print(' at line ', results.error_line, ':') - print(' ', results.error_string) - return -1 - - # Get all the options out of the config file using the option name. The - # options hash is now the default source of truth for the name of an option. - for key in into: - if(results.result.has(key)): - into[key] = results.result[key] - - return 1 - -func _print_gutconfigs(values): - var header = """Here is a sample of a full .gutconfig.json file. -You do not need to specify all values in your own file. The values supplied in -this sample are what would be used if you ran gut w/o the -gprint_gutconfig_sample -option (the resolved values where default < .gutconfig < command line).""" - print("\n", header.replace("\n", ' '), "\n\n") - var resolved = values - - # remove some options that don't make sense to be in config - resolved.erase("config_file") - resolved.erase("show_help") - -# print("Here's a config with all the properties set based off of your current command and config.") -# var text = JSON.pri(resolved) -# print(text.replace(',', ",\n")) -# -# for key in resolved: -# resolved[key] = null -# -# print("\n\nAnd here's an empty config for you fill in what you want.") -# text = JSON.print(resolved) -# print(text.replace(',', ",\n")) - -func parse() -> bool: - var o = _setup_options() - - var all_options_valid = o.parse() - _extract_command_line_options(o, cmd_opts) - var load_result = \ - _load_options_from_config_file(get_value(CONFIG_ARG), config_opts) - - if load_result == -1 or not all_options_valid: - return false - return true diff --git a/godot/addons/godot-css-theme/CSSParser.gd b/godot/addons/godot-css-theme/CSSParser.gd index eee0cab..b08cba9 100644 --- a/godot/addons/godot-css-theme/CSSParser.gd +++ b/godot/addons/godot-css-theme/CSSParser.gd @@ -72,9 +72,19 @@ func parse_text(content: String, path: String): result[class_group][actual_tag] = value else: result[""][tag] = value + + _copy_global_node_to_all_tags(result) return Stylesheet.new(result, path) +func _copy_global_node_to_all_tags(result): + if ThemeApplier.GLOBAL_NODE in result[""]: + var global = result[""][ThemeApplier.GLOBAL_NODE] + for tag in result: + if tag == "": continue + + result[tag][ThemeApplier.GLOBAL_NODE] = global + func _find_index_for_class_in_array(arr): for i in range(0, arr.size()): if "." in arr[i]: diff --git a/godot/addons/godot-css-theme/LICENSE.txt b/godot/addons/godot-css-theme/LICENSE.txt index ced500d..dbfad2c 100644 --- a/godot/addons/godot-css-theme/LICENSE.txt +++ b/godot/addons/godot-css-theme/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2022 myin142 +Copyright (c) 2021-2023 myin142 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/godot/addons/godot-css-theme/ThemeApplier.gd b/godot/addons/godot-css-theme/ThemeApplier.gd index 45e0833..43f1408 100644 --- a/godot/addons/godot-css-theme/ThemeApplier.gd +++ b/godot/addons/godot-css-theme/ThemeApplier.gd @@ -52,13 +52,21 @@ func _apply_to_theme(theme: Theme, stylesheet: Stylesheet, class_group: String) print("Set const for %s: %s" % [type, _value]) elif property == FONT_SIZE_PROPERTY: var _value = _create_value(stylesheet, value) - theme.default_font_size = _value + if node_type == GLOBAL_NODE: + theme.default_font_size = _value + else: + var type := _parse_type("--fonts-", property) + theme.set_font_size(type, node_type, _value) if _debug: print("Set font size: %s" % _value) elif property == FONT_PROPERTY: var url := stylesheet.resolve_url(value) if url: - theme.default_font = load(url) + if node_type == GLOBAL_NODE: + theme.default_font = load(url) + else: + var type := _parse_type("--fonts-", property) + theme.set_font(type, node_type, load(url)) else: print("Invalid url %s for class %s" % [value, node_type]) elif property.begins_with("--icons-"): diff --git a/godot/addons/godot-css-theme/convert.gd b/godot/addons/godot-css-theme/convert.gd index 9364b84..fe62488 100644 --- a/godot/addons/godot-css-theme/convert.gd +++ b/godot/addons/godot-css-theme/convert.gd @@ -1,3 +1,4 @@ +class_name CSSConvert extends SceneTree @@ -9,15 +10,22 @@ func _init(): var debug = options.exists("debug") print("Debug: ", debug) - var parser = CSSParser.new() + var css_file = options.get_value("input") + var output = options.get_value("output") + + convert_css(css_file, output, debug) + + quit() + +static func convert_css(css_file, output, debug = false): + var parser = CSSParser.new() if debug: print("Parsing Stylesheet") var stylesheet = parser.parse(css_file) if not stylesheet: - quit(1) return if debug: @@ -33,7 +41,7 @@ func _init(): if debug: print("Creating theme") - var output = options.get_value("output") + if not output: var last_slash = Options.find_last(css_file, "/") var file_name = css_file.substr(last_slash + 1) @@ -56,5 +64,3 @@ func _init(): print("Failed to save theme %s" % err) else: print("Saved theme %s to %s" % [theme_name, theme_output]) - - quit() diff --git a/godot/addons/godot-css-theme/editor/EditorButton.gd b/godot/addons/godot-css-theme/editor/EditorButton.gd new file mode 100644 index 0000000..ed52fa7 --- /dev/null +++ b/godot/addons/godot-css-theme/editor/EditorButton.gd @@ -0,0 +1,9 @@ +@tool +extends BaseButton + +var unfocus_color = Color("999999") + +func _ready(): + modulate = unfocus_color + mouse_entered.connect(func(): modulate = Color.WHITE) + mouse_exited.connect(func(): modulate = unfocus_color) diff --git a/godot/addons/godot-css-theme/editor/css_code_edit.gd b/godot/addons/godot-css-theme/editor/css_code_edit.gd new file mode 100644 index 0000000..2cd8e99 --- /dev/null +++ b/godot/addons/godot-css-theme/editor/css_code_edit.gd @@ -0,0 +1,49 @@ +@tool +extends CodeEdit + +const TYPE_COLOR = Color("c46060") +const FN_COLOR = Color("2e8ff0") +const NUM_COLOR = Color("b383de") +const MEM_COLOR = Color("DDDDDD") +const FN_REGION_COLOR = Color("ffac63") +const STATE_COLOR = Color("339933") + + # TODO: does not support special characters except _ +const SUPPORTED_CSS = [ + "color", "background", "font-family", "font-size", + "gap", "padding", + "border-width", "border-radius", "border-color" +] + +func _ready(): + var syntax = syntax_highlighter as CodeHighlighter + syntax.function_color = FN_COLOR + syntax.number_color = NUM_COLOR + syntax.symbol_color = TYPE_COLOR + syntax.member_variable_color = MEM_COLOR + + if syntax.keyword_colors.is_empty(): + syntax.add_keyword_color("{", Color.RED) + syntax.add_keyword_color("}", Color.RED) + + if syntax.color_regions.is_empty(): + syntax.add_color_region("(", ")", FN_REGION_COLOR) + #syntax.add_color_region(":", ";", NUM_COLOR, true) + syntax.add_color_region("--", ":", FN_COLOR) + + # Use theme to get available node types, re-import if new types get added + if syntax.member_keyword_colors.is_empty(): + syntax.add_member_keyword_color("body", TYPE_COLOR) + for type in load("res://syntax_theme.tres").get_type_list(): + syntax.add_member_keyword_color(type, TYPE_COLOR) + + for word in SUPPORTED_CSS: + syntax.add_member_keyword_color(word, FN_COLOR) + +# for k in syntax.member_keyword_colors: +# add_code_completion_option(CodeEdit.KIND_MEMBER, k, k) +# code_completion_prefixes = ["--"] +# +# +#func _on_code_completion_requested(): +# push_warning("completion") diff --git a/godot/addons/godot-css-theme/editor/css_editor.gd b/godot/addons/godot-css-theme/editor/css_editor.gd new file mode 100644 index 0000000..9baed93 --- /dev/null +++ b/godot/addons/godot-css-theme/editor/css_editor.gd @@ -0,0 +1,74 @@ +@tool +extends Control + +@export var open_key: BaseButton +@export var export_key: BaseButton +@export var code: TextEdit +@export var file_name_label: Label + +@onready var file_dialog = $FileDialog +@onready var export_dialog = $ExportDialog + +var css_file: String : set = _set_css_file +var dirty = false : set = _set_dirty + +func _set_dirty(d: bool): + dirty = d + _update_label() + +func _set_css_file(f: String): + css_file = f + dirty = false + _update_label() + +# Did not find a better way to detect this +# The default editor save event using _notification does not work, because the variables will be empty? +func _input(event: InputEvent): + if event is InputEventKey and event.keycode == KEY_S and event.ctrl_pressed: + save_file(css_file) + +func _ready(): + open_key.pressed.connect(func(): file_dialog.popup(Rect2i(0, 0, 700, 600))) + export_key.pressed.connect(func(): export_dialog.popup(Rect2i(0, 0, 700, 600))) + + file_dialog.file_selected.connect(func(p): open_file(p)) + export_dialog.file_selected.connect(func(p): export_theme(p)) + + code.text_changed.connect(func(): self.dirty = true) + code.hide() + export_key.hide() + _update_label() + +func _exit_tree(): + save_file() + +func _update_label(): + if css_file: + file_name_label.text = css_file + if dirty: + file_name_label.text += " (*)" + else: + file_name_label.text = "" + +func open_file(path): + var file = FileAccess.open(path, FileAccess.READ) + if file: + self.css_file = path + code.text = file.get_as_text() + code.show() + export_key.show() + else: + push_error("Failed to open css file: %s" % path) + +func save_file(path = css_file): + if path: + self.dirty = false + var file = FileAccess.open(path, FileAccess.WRITE) + if file: + file.store_string(code.text) + else: + push_warning("Failed to save css file to path %s" % path) + +func export_theme(path): + save_file() + CSSConvert.convert_css(css_file, path) diff --git a/godot/addons/godot-css-theme/editor/css_editor.tscn b/godot/addons/godot-css-theme/editor/css_editor.tscn new file mode 100644 index 0000000..0ffca7e --- /dev/null +++ b/godot/addons/godot-css-theme/editor/css_editor.tscn @@ -0,0 +1,101 @@ +[gd_scene load_steps=6 format=3 uid="uid://dcmut0gcayih2"] + +[ext_resource type="Script" path="res://addons/godot-css-theme/editor/css_editor.gd" id="1_d8bk4"] +[ext_resource type="Script" path="res://addons/godot-css-theme/editor/EditorButton.gd" id="2_77gh4"] +[ext_resource type="CodeHighlighter" uid="uid://blglwyagrkxdm" path="res://addons/godot-css-theme/editor/css_syntax.tres" id="3_ynjw3"] +[ext_resource type="Script" path="res://addons/godot-css-theme/editor/css_code_edit.gd" id="4_76rs7"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_kctcl"] + +[node name="CSSEditor" type="Control" node_paths=PackedStringArray("open_key", "export_key", "code", "file_name_label")] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 3 +script = ExtResource("1_d8bk4") +open_key = NodePath("VBoxContainer/MarginContainer/TopBar/Open") +export_key = NodePath("VBoxContainer/MarginContainer/TopBar/Export") +code = NodePath("VBoxContainer/Code") +file_name_label = NodePath("VBoxContainer/MarginContainer/TopBar/FileName") + +[node name="FileDialog" type="FileDialog" parent="."] +title = "Open a File" +initial_position = 2 +ok_button_text = "Open" +file_mode = 0 +filters = PackedStringArray("*.css") + +[node name="ExportDialog" type="FileDialog" parent="."] +initial_position = 2 +size = Vector2i(312, 157) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 5 + +[node name="TopBar" type="HBoxContainer" parent="VBoxContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 10 + +[node name="Open" type="Button" parent="VBoxContainer/MarginContainer/TopBar"] +modulate = Color(0.6, 0.6, 0.6, 1) +layout_mode = 2 +theme_override_styles/normal = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/hover = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/pressed = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/disabled = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/focus = SubResource("StyleBoxEmpty_kctcl") +text = "Open File" +script = ExtResource("2_77gh4") + +[node name="Export" type="Button" parent="VBoxContainer/MarginContainer/TopBar"] +visible = false +modulate = Color(0.6, 0.6, 0.6, 1) +layout_mode = 2 +theme_override_styles/normal = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/hover = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/pressed = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/disabled = SubResource("StyleBoxEmpty_kctcl") +theme_override_styles/focus = SubResource("StyleBoxEmpty_kctcl") +text = "Export Theme" +script = ExtResource("2_77gh4") + +[node name="Control" type="Control" parent="VBoxContainer/MarginContainer/TopBar"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="FileName" type="Label" parent="VBoxContainer/MarginContainer/TopBar"] +layout_mode = 2 + +[node name="Code" type="CodeEdit" parent="VBoxContainer"] +visible = false +layout_mode = 2 +size_flags_vertical = 3 +theme_override_colors/background_color = Color(0.113725, 0.133333, 0.160784, 1) +highlight_all_occurrences = true +highlight_current_line = true +draw_tabs = true +draw_spaces = true +syntax_highlighter = ExtResource("3_ynjw3") +line_folding = true +gutters_draw_line_numbers = true +gutters_draw_fold_gutter = true +indent_size = 2 +indent_use_spaces = true +indent_automatic = true +auto_brace_completion_highlight_matching = true +script = ExtResource("4_76rs7") diff --git a/godot/addons/godot-css-theme/editor/css_syntax.tres b/godot/addons/godot-css-theme/editor/css_syntax.tres new file mode 100644 index 0000000..557bb76 --- /dev/null +++ b/godot/addons/godot-css-theme/editor/css_syntax.tres @@ -0,0 +1,84 @@ +[gd_resource type="CodeHighlighter" format=3 uid="uid://blglwyagrkxdm"] + +[resource] +number_color = Color(0.701961, 0.513726, 0.870588, 1) +symbol_color = Color(0.768627, 0.376471, 0.376471, 1) +function_color = Color(0.180392, 0.560784, 0.941176, 1) +member_variable_color = Color(0.866667, 0.866667, 0.866667, 1) +keyword_colors = { +"{": Color(1, 0, 0, 1), +"}": Color(1, 0, 0, 1) +} +member_keyword_colors = { +"AcceptDialog": Color(0.768627, 0.376471, 0.376471, 1), +"BoxContainer": Color(0.768627, 0.376471, 0.376471, 1), +"Button": Color(0.768627, 0.376471, 0.376471, 1), +"CheckBox": Color(0.768627, 0.376471, 0.376471, 1), +"CheckButton": Color(0.768627, 0.376471, 0.376471, 1), +"CodeEdit": Color(0.768627, 0.376471, 0.376471, 1), +"ColorPicker": Color(0.768627, 0.376471, 0.376471, 1), +"ColorPickerButton": Color(0.768627, 0.376471, 0.376471, 1), +"ColorPresetButton": Color(0.768627, 0.376471, 0.376471, 1), +"FileDialog": Color(0.768627, 0.376471, 0.376471, 1), +"FlowContainer": Color(0.768627, 0.376471, 0.376471, 1), +"Fonts": Color(0.768627, 0.376471, 0.376471, 1), +"GraphEdit": Color(0.768627, 0.376471, 0.376471, 1), +"GraphEditMinimap": Color(0.768627, 0.376471, 0.376471, 1), +"GraphNode": Color(0.768627, 0.376471, 0.376471, 1), +"GridContainer": Color(0.768627, 0.376471, 0.376471, 1), +"HBoxContainer": Color(0.768627, 0.376471, 0.376471, 1), +"HFlowContainer": Color(0.768627, 0.376471, 0.376471, 1), +"HScrollBar": Color(0.768627, 0.376471, 0.376471, 1), +"HSeparator": Color(0.768627, 0.376471, 0.376471, 1), +"HSlider": Color(0.768627, 0.376471, 0.376471, 1), +"HSplitContainer": Color(0.768627, 0.376471, 0.376471, 1), +"HeaderLarge": Color(0.768627, 0.376471, 0.376471, 1), +"HeaderMedium": Color(0.768627, 0.376471, 0.376471, 1), +"HeaderSmall": Color(0.768627, 0.376471, 0.376471, 1), +"Icons": Color(0.768627, 0.376471, 0.376471, 1), +"ItemList": Color(0.768627, 0.376471, 0.376471, 1), +"Label": Color(0.768627, 0.376471, 0.376471, 1), +"LineEdit": Color(0.768627, 0.376471, 0.376471, 1), +"LinkButton": Color(0.768627, 0.376471, 0.376471, 1), +"MarginContainer": Color(0.768627, 0.376471, 0.376471, 1), +"MenuBar": Color(0.768627, 0.376471, 0.376471, 1), +"MenuButton": Color(0.768627, 0.376471, 0.376471, 1), +"OptionButton": Color(0.768627, 0.376471, 0.376471, 1), +"Panel": Color(0.768627, 0.376471, 0.376471, 1), +"PanelContainer": Color(0.768627, 0.376471, 0.376471, 1), +"PopupDialog": Color(0.768627, 0.376471, 0.376471, 1), +"PopupMenu": Color(0.768627, 0.376471, 0.376471, 1), +"PopupPanel": Color(0.768627, 0.376471, 0.376471, 1), +"ProgressBar": Color(0.768627, 0.376471, 0.376471, 1), +"RichTextLabel": Color(0.768627, 0.376471, 0.376471, 1), +"ScrollContainer": Color(0.768627, 0.376471, 0.376471, 1), +"SpinBox": Color(0.768627, 0.376471, 0.376471, 1), +"SplitContainer": Color(0.768627, 0.376471, 0.376471, 1), +"TabBar": Color(0.768627, 0.376471, 0.376471, 1), +"TabContainer": Color(0.768627, 0.376471, 0.376471, 1), +"TextEdit": Color(0.768627, 0.376471, 0.376471, 1), +"TooltipLabel": Color(0.768627, 0.376471, 0.376471, 1), +"TooltipPanel": Color(0.768627, 0.376471, 0.376471, 1), +"Tree": Color(0.768627, 0.376471, 0.376471, 1), +"VBoxContainer": Color(0.768627, 0.376471, 0.376471, 1), +"VFlowContainer": Color(0.768627, 0.376471, 0.376471, 1), +"VScrollBar": Color(0.768627, 0.376471, 0.376471, 1), +"VSeparator": Color(0.768627, 0.376471, 0.376471, 1), +"VSlider": Color(0.768627, 0.376471, 0.376471, 1), +"VSplitContainer": Color(0.768627, 0.376471, 0.376471, 1), +"Window": Color(0.768627, 0.376471, 0.376471, 1), +"background": Color(0.180392, 0.560784, 0.941176, 1), +"body": Color(0.768627, 0.376471, 0.376471, 1), +"border-width": Color(0.180392, 0.560784, 0.941176, 1), +"border_color": Color(0.180392, 0.560784, 0.941176, 1), +"border_radius": Color(0.180392, 0.560784, 0.941176, 1), +"color": Color(0.180392, 0.560784, 0.941176, 1), +"font-family": Color(0.180392, 0.560784, 0.941176, 1), +"font-size": Color(0.180392, 0.560784, 0.941176, 1), +"gap": Color(0.180392, 0.560784, 0.941176, 1), +"padding": Color(0.180392, 0.560784, 0.941176, 1) +} +color_regions = { +"( )": Color(1, 0.67451, 0.388235, 1), +"-- :": Color(0.180392, 0.560784, 0.941176, 1) +} diff --git a/godot/addons/godot-css-theme/plugin.gd b/godot/addons/godot-css-theme/plugin.gd index c148cbc..daa4464 100644 --- a/godot/addons/godot-css-theme/plugin.gd +++ b/godot/addons/godot-css-theme/plugin.gd @@ -1,10 +1,27 @@ @tool extends EditorPlugin +const EDITOR = preload("res://addons/godot-css-theme/editor/css_editor.tscn") -func _enter_tree(): - pass +var file_editor +func _enter_tree(): + file_editor = EDITOR.instantiate() + get_editor_interface().get_editor_main_screen().add_child(file_editor) + _make_visible(false) func _exit_tree(): - pass + get_editor_interface().get_editor_main_screen().remove_child(file_editor) + +func _has_main_screen(): + return true + +func _get_plugin_name(): + return "CSS" + +func _get_plugin_icon(): + return get_editor_interface().get_base_control().get_theme_icon("Theme", "EditorIcons") + +func _make_visible(visible): + if file_editor: + file_editor.visible = visible diff --git a/scripts/generate-theme.sh b/scripts/generate-theme.sh deleted file mode 100644 index de78ffa..0000000 --- a/scripts/generate-theme.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -cd godot -sass theme/theme.scss theme/theme.css -godot -s addons/godot-css-theme/convert.gd --input="res://theme/theme.css" \ No newline at end of file diff --git a/scripts/translations.sh b/scripts/translations.sh index feff475..53ef1ef 100644 --- a/scripts/translations.sh +++ b/scripts/translations.sh @@ -2,7 +2,7 @@ DIR="i18n" -pybabel extract -F "$DIR/babelrc" -k text -k LineEdit/placeholder_text -k tr -k items --no-location -o "$DIR/messages.pot" \ +pybabel extract -F "$DIR/babelrc" -k text -k LineEdit#placeholder_text -k tr -k tooltip_text -k items --no-location -o "$DIR/messages.pot" \ godot/src cd $DIR