commit 1f46566945933b8cec00561ac6ea2cae27116ca9 Author: Chris Bell Date: Mon Jan 13 15:44:59 2025 -0600 Init diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb48c87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Godot 4+ specific ignores +.godot/ +/android/ + +.idea/ diff --git a/addons/wpgtk_theme/README.md b/addons/wpgtk_theme/README.md new file mode 100644 index 0000000..c9ff9b0 --- /dev/null +++ b/addons/wpgtk_theme/README.md @@ -0,0 +1,26 @@ +# Godot WPGTK Theme Plugin + +## What is this? +This is a plugin for Godot Engine that was made to use with [WPGTK](https://github.com/deviantfero/wpgtk) package available for Linux to change the editors color scheme. + +Technically speaking, it is a plugin that listens to the 'config/wpgtk-colors.txt' configuration file and updates the editor's theme accordingly, so in theory any application that can change the contents of that file will also work, but the installation guide here is only for setting it up with WPGTK. + +## Prerequisites +- Linux with [WPGTK](https://github.com/deviantfero/wpgtk) installed +- Godot Engine 4.0 or later + +## Installation +### Option 1: Git repository +1. Clone or download this repository and copy the addons/wpgtk_theme folder to the addons folder of your Godot project. +2. Enable the plugin in the project settings. + +### Option 2: Asset Library +1. Search for "WPGTK Theme" in the Asset Library tab of the editor. +2. Click on the "Download" button. +3. Enable the plugin in the project settings. + +### Setup +1. Open WPGTK and select 'Add Template'. +2. Find the folder of the current godot project and select the file `addons/config/wpgtk-colors.txt`. +3. Copy the contents of 'addons/config/wpgtk-colots.base' to the newly created base file in your WPGTK config templates folder (This is usually '~/.config/wpg/templates'). +4. Use WPGTK to set your colors. The editor will update automatically. \ No newline at end of file diff --git a/addons/wpgtk_theme/config/wpgtk-colors-cache.txt b/addons/wpgtk_theme/config/wpgtk-colors-cache.txt new file mode 100644 index 0000000..1488f5c --- /dev/null +++ b/addons/wpgtk_theme/config/wpgtk-colors-cache.txt @@ -0,0 +1 @@ +{"active":"#036f8d","color0":"#000910","color1":"#036E8F","color10":"#027398","color11":"#56768B","color12":"#1088A2","color13":"#048CB1","color14":"#10A9CE","color15":"#a7d9e9","color2":"#027398","color3":"#56768B","color4":"#1088A2","color5":"#048CB1","color6":"#10A9CE","color7":"#a7d9e9","color8":"#7497a3","color9":"#036E8F","inactive":"#024c60"} \ No newline at end of file diff --git a/addons/wpgtk_theme/config/wpgtk-colors.txt b/addons/wpgtk_theme/config/wpgtk-colors.txt new file mode 100644 index 0000000..daa93aa --- /dev/null +++ b/addons/wpgtk_theme/config/wpgtk-colors.txt @@ -0,0 +1,20 @@ +{ + "color0": "#000910", + "color1": "#036E8F", + "color2": "#027398", + "color3": "#56768B", + "color4": "#1088A2", + "color5": "#048CB1", + "color6": "#10A9CE", + "color7": "#a7d9e9", + "color8": "#7497a3", + "color9": "#036E8F", + "color10": "#027398", + "color11": "#56768B", + "color12": "#1088A2", + "color13": "#048CB1", + "color14": "#10A9CE", + "color15": "#a7d9e9", + "active": "#036f8d", + "inactive": "#024c60", +} \ No newline at end of file diff --git a/addons/wpgtk_theme/config/wpgtk-colors.txt.bak b/addons/wpgtk_theme/config/wpgtk-colors.txt.bak new file mode 100644 index 0000000..2c125e7 --- /dev/null +++ b/addons/wpgtk_theme/config/wpgtk-colors.txt.bak @@ -0,0 +1,20 @@ +{ + "color0": "#000910", + "color1": "#036E8F", + "color2": "#027398", + "color3": "#56768B", + "color4": "#1088A2", + "color5": "#048CB1", + "color6": "#10A9CE", + "color7": "#a7d9e9", + "color8": "#7497a3", + "color9": "#036E8F", + "color10": "#027398", + "color11": "#56768B", + "color12": "#1088A2", + "color13": "#048CB1", + "color14": "#10A9CE", + "color15": "#a7d9e9", + "active": "#015b79", + "inactive": "#013f53", +} \ No newline at end of file diff --git a/addons/wpgtk_theme/config/wpgtk-colors.txt.base b/addons/wpgtk_theme/config/wpgtk-colors.txt.base new file mode 100644 index 0000000..e5e8798 --- /dev/null +++ b/addons/wpgtk_theme/config/wpgtk-colors.txt.base @@ -0,0 +1,20 @@ +{{ + "color0": "{color0}", + "color1": "{color1}", + "color2": "{color2}", + "color3": "{color3}", + "color4": "{color4}", + "color5": "{color5}", + "color6": "{color6}", + "color7": "{color7}", + "color8": "{color8}", + "color9": "{color9}", + "color10": "{color10}", + "color11": "{color11}", + "color12": "{color12}", + "color13": "{color13}", + "color14": "{color14}", + "color15": "{color15}", + "active": "{active}", + "inactive": "{inactive}", +}} \ No newline at end of file diff --git a/addons/wpgtk_theme/plugin.cfg b/addons/wpgtk_theme/plugin.cfg new file mode 100644 index 0000000..c13d0b9 --- /dev/null +++ b/addons/wpgtk_theme/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="WPGTKEditorTheme" +description="A plugin that changes the editor's colors to match WPGTK colors." +author="Bellsworne Tech" +version="1.0" +script="wpgtk_theme.gd" diff --git a/addons/wpgtk_theme/wpgtk_theme.gd b/addons/wpgtk_theme/wpgtk_theme.gd new file mode 100644 index 0000000..723f1f9 --- /dev/null +++ b/addons/wpgtk_theme/wpgtk_theme.gd @@ -0,0 +1,97 @@ +@tool +extends EditorPlugin + +# Colors file format example: +#{ +# "color0": "#121212", +# "color1": "#6D6253", +# "color2": "#756755", +# "color3": "#85725A", +# "color4": "#897A67", +# "color5": "#958774", +# "color6": "#A4917A", +# "color7": "#cbc6be", +# "color8": "#8e8a85", +# "color9": "#6D6253", +# "color10": "#756755", +# "color11": "#85725A", +# "color12": "#897A67", +# "color13": "#958774", +# "color14": "#A4917A", +# "color15": "#cbc6be", +# "active": "#6a5b48", +# "inactive": "#493e31", +#} + +var _menu_item_name: String = " Update WPGTK Theme" +var _colors_file_path: String = "res://addons/wpgtk_theme/config/wpgtk-colors.txt" +var _cache_colors_file_path: String = "res://addons/wpgtk_theme/config/wpgtk-colors-cache.txt" +var _config_colors: Dictionary = {} +var auto_update: bool = true +var _last_modified_time: int = 0 + +func _enter_tree() -> void: + add_tool_menu_item(_menu_item_name, _button_pressed) + set_process(true) + _last_modified_time = FileAccess.get_modified_time(_colors_file_path) + + +func _exit_tree() -> void: + remove_tool_menu_item(_menu_item_name) + set_process(false) + + +func _process(delta: float) -> void: + if !auto_update: return + var current_modified_time: int = FileAccess.get_modified_time(_colors_file_path) + #print("Previous modified time: ", _last_modified_time, " Current modified time: ", current_modified_time) + if current_modified_time != _last_modified_time: + print("Colors file has been modified") + _last_modified_time = current_modified_time + _load_colors() + +func _button_pressed() -> void: + _load_colors() + + +func _load_colors() -> void: + var file: FileAccess = FileAccess.open(_colors_file_path, FileAccess.READ) + if file == null: + printerr("Error loading colors file: ", FileAccess.get_open_error()) + return + + var cache_file: FileAccess = FileAccess.open(_cache_colors_file_path, FileAccess.READ_WRITE) + if cache_file == null: + printerr("Error loading cache colors file: ", FileAccess.get_open_error()) + return + + _config_colors.clear() + _config_colors = JSON.parse_string(file.get_as_text()) + var _config_colors_cache: Dictionary = JSON.parse_string(cache_file.get_as_text()) + + # Check if the colors from the cache are the same + if str(_config_colors_cache) == str(_config_colors): + print("Colors are the same, no need to update") + return + + # Save the new colors to the cache file + _config_colors_cache = _config_colors.duplicate() + cache_file.store_string(JSON.stringify(_config_colors_cache)) + + file.close() + cache_file.close() + + # Convert hex colors to Color objects + var colors_copy: Dictionary = _config_colors.duplicate() + for key: String in colors_copy.keys(): + _config_colors[key] = Color(_config_colors[key]) + + _update_theme() + + +func _update_theme() -> void: + var editor_settings: EditorSettings = EditorInterface.get_editor_settings() + editor_settings.set("interface/theme/base_color", _config_colors["inactive"]) + editor_settings.set("interface/theme/accent_color", _config_colors["active"]) + EditorInterface.restart_editor() # Restart the editor to apply the new colors, not sure why this is needed, but its the only way I found to make it work + diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..ba372ef --- /dev/null +++ b/project.godot @@ -0,0 +1,19 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="wpgtk Theme Test" +run/main_scene="res://scenes/main.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") + +[editor_plugins] + +enabled=PackedStringArray("res://addons/wpgtk_theme/plugin.cfg")