Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lorien/Config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ const DEFAULT_UI_SCALE_MODE := Types.UIScale.AUTO
const DEFAULT_UI_SCALE := 1.0
const DEFAULT_GRID_PATTERN := Types.GridPattern.DOTS
const DEFAULT_GRID_SIZE := 25.0
const DEFAULT_APPEARANCE_THEME := 0
29 changes: 29 additions & 0 deletions lorien/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ func _ready() -> void:
_settings_dialog.canvas_color_changed.connect(_on_canvas_color_changed)
_settings_dialog.constant_pressure_changed.connect(_on_constant_pressure_changed)

Settings.changed_theme.connect(_on_theme_changed)

# Initialize scale
_on_scale_changed()

Expand All @@ -106,6 +108,11 @@ func _ready() -> void:

# Apply state from previous session
_apply_state()

# Set theme
var themeIndex = Settings.get_value(Settings.APPEARANCE_THEME, Config.DEFAULT_APPEARANCE_THEME)
var themeName : String = Types.UIThemeArray[themeIndex]
Settings.changed_theme.emit(themeName)

# -------------------------------------------------------------------------------------------------
func _notification(what: int) -> void:
Expand Down Expand Up @@ -607,3 +614,25 @@ func _get_general_ui_scale() -> float:
elif smallest_dimension >= 1700:
return Config.DEFAULT_UI_SCALE * 1.5
return Config.DEFAULT_UI_SCALE

# --------------------------------------------------------------------------------------------------
func _on_theme_changed(path : String) -> void:
var themePath : String = str("res://UI/Themes/", path, "/theme.tres")
var toolBarPath : String = str("res://UI/Themes/", path, "/toolbar.tres")
print(themePath)
var theme : Theme = load(themePath)
var toolbarTheme : StyleBoxFlat = load(toolBarPath)
set_theme(theme)
_toolbar.set_theme(theme)
_toolbar.add_theme_stylebox_override("panel", toolbarTheme)
_toolbar.queue_redraw()
_statusbar.set_theme(theme)
_statusbar.queue_redraw()
_menubar.set_theme(theme)
_menubar.queue_redraw()
_main_menu.set_theme(theme)
print(_settings_dialog)
_settings_dialog.set_theme(theme)
_settings_dialog.queue_redraw()
queue_redraw()
print(theme)
2 changes: 1 addition & 1 deletion lorien/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://c41oe1lt7u6r8" path="res://UI/MainMenu.tscn" id="5"]
[ext_resource type="PackedScene" uid="uid://c0ral10lvpo7f" path="res://UI/Toolbar.tscn" id="6"]
[ext_resource type="PackedScene" uid="uid://ct2b6hxxjlc6h" path="res://UI/Dialogs/UnsavedChangesDialog.tscn" id="7"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="8"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="8"]
[ext_resource type="PackedScene" uid="uid://dug4jmvhrb3t1" path="res://UI/Dialogs/AboutDialog.tscn" id="9"]
[ext_resource type="PackedScene" uid="uid://cgs8d5y8yrwl0" path="res://UI/Dialogs/SettingsDialog.tscn" id="10"]
[ext_resource type="PackedScene" uid="uid://jow4q8tm6qro" path="res://UI/Dialogs/NewPaletteDialog.tscn" id="12"]
Expand Down
3 changes: 3 additions & 0 deletions lorien/Misc/Settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ var _i18n := I18nParser.new()
var locales: PackedStringArray
var language_names: PackedStringArray

#--------------------------------------------------------------------------------------------------
signal changed_theme(path: String)

# -------------------------------------------------------------------------------------------------
func _ready() -> void:
_config_file = ConfigFile.new()
Expand Down
3 changes: 3 additions & 0 deletions lorien/Misc/Types.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ enum GridPattern {
NONE
}

# -------------------------------------------------------------------------------------------------
static var UIThemeArray : Array[String] = ["dark", "light"]

# -------------------------------------------------------------------------------------------------
enum UITheme {
DARK,
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/ColorPalettePicker.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=11 format=3 uid="uid://dsxmmndtd4r2c"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1"]
[ext_resource type="Script" path="res://UI/ColorPalettePicker.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://bu10tixbxmwus" path="res://Assets/Icons/edit.png" id="3"]
[ext_resource type="Texture2D" uid="uid://bmutnbt040e0b" path="res://Assets/Icons/plus.png" id="4"]
Expand Down
8 changes: 8 additions & 0 deletions lorien/UI/Components/FlatTextureButton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func _ready() -> void:
mouse_exited.connect(_on_mouse_exited)
toggled.connect(_on_toggled)
_update_tint()
Settings.changed_theme.connect(_on_theme_changed)

# -------------------------------------------------------------------------------------------------
func _exit_tree() -> void:
Expand Down Expand Up @@ -52,3 +53,10 @@ func _update_tint() -> void:
self_modulate = hover_tint
else:
self_modulate = _normal_tint

func _on_theme_changed(path : String) -> void:
if path == "dark":
_normal_tint = Color.WHITE
else:
_normal_tint = Color.BLACK
self_modulate = _normal_tint
11 changes: 11 additions & 0 deletions lorien/UI/Components/KeybindItem.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var _last_event: InputEventKey = null

# -------------------------------------------------------------------------------------------------
func _ready() -> void:
Settings.changed_theme.connect(_on_theme_changed)

_button.pressed.connect(func() -> void:
_last_event = null
_rebinding = true
Expand Down Expand Up @@ -50,3 +52,12 @@ func _input(event: InputEvent) -> void:
if _pressed_key_counter == 0:
_rebinding = false
_do_rebind()

# -------------------------------------------------------------------------------------------------
func _on_theme_changed(path : String) -> void:
var themePath : String = str("res://UI/Themes/", path, "/theme.tres")
var toolBarPath : String = str("res://UI/Themes/", path, "/toolbar.tres")
print(themePath)
var theme : Theme = load(themePath)
set_theme(theme)
queue_redraw()
2 changes: 1 addition & 1 deletion lorien/UI/Components/KeybindItem.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://ct7pvupldkei5"]

[ext_resource type="Script" path="res://UI/Components/KeybindItem.gd" id="1_1rkxe"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1_cuavq"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1_cuavq"]

[node name="KeybindItem" type="HBoxContainer"]
offset_right = 170.0
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Dialogs/AboutDialog.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://dug4jmvhrb3t1"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1_usj82"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1_usj82"]
[ext_resource type="Script" path="res://UI/Dialogs/AboutDialog.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://b6io62g8b730e" path="res://Assets/icon.png" id="3"]

Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Dialogs/AlertDialog.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://bi7pkm1cg1s4w"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1"]
[ext_resource type="Script" path="res://UI/Dialogs/AlertDialog.gd" id="2_a4x41"]

[node name="AlertDialog" type="AcceptDialog"]
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Dialogs/ExitDialog.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://by1hug8oa5vft"]

[ext_resource type="Script" path="res://UI/Dialogs/UnsavedChangesDialog.gd" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="3"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="3"]

[node name="ExitDialog" type="Window"]
title = "Unsaved Changes"
Expand Down
10 changes: 7 additions & 3 deletions lorien/UI/Dialogs/SettingsDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ signal grid_size_changed(size: int)
signal grid_pattern_changed(pattern: Types.GridPattern)
signal constant_pressure_changed(state: bool)


# -------------------------------------------------------------------------------------------------
@onready var _general_tab: Button = %GeneralTab
@onready var _appearance_tab: Button = %AppearanceTab
Expand Down Expand Up @@ -96,7 +97,7 @@ func _set_values() -> void:
var stabilizer_strength: float = Settings.get_value(Settings.GENERAL_STABILIZER_STRENGTH, Config.DEFAULT_STABILIZER_STRENGTH)

var canvas_color: Color = Settings.get_value(Settings.APPEARANCE_CANVAS_COLOR, Config.DEFAULT_CANVAS_COLOR)
var ui_theme: Types.UITheme = Settings.get_value(Settings.APPEARANCE_THEME, Types.UITheme.DARK)
var ui_theme: Types.UITheme = Settings.get_value(Settings.APPEARANCE_THEME, Config.DEFAULT_APPEARANCE_THEME)
var ui_scale: float = Settings.get_value(Settings.APPEARANCE_UI_SCALE, Config.DEFAULT_UI_SCALE)
var ui_scale_mode: Types.UIScale = Settings.get_value(Settings.APPEARANCE_UI_SCALE_MODE, Config.DEFAULT_UI_SCALE_MODE)
var grid_pattern: Types.GridPattern = Settings.get_value(Settings.APPEARANCE_GRID_PATTERN, Config.DEFAULT_GRID_PATTERN)
Expand All @@ -108,6 +109,7 @@ func _set_values() -> void:
match ui_theme:
Types.UITheme.DARK: _theme.selected = THEME_DARK_INDEX
Types.UITheme.LIGHT: _theme.selected = THEME_LIGHT_INDEX

match ui_scale_mode:
Types.UIScale.AUTO:
_ui_scale_mode.selected = UI_SCALE_AUTO_INDEX
Expand Down Expand Up @@ -269,8 +271,10 @@ func _on_theme_selected(index: int) -> void:
THEME_DARK_INDEX: ui_theme = Types.UITheme.DARK
THEME_LIGHT_INDEX: ui_theme = Types.UITheme.LIGHT

Settings.set_value(Settings.APPEARANCE_THEME, ui_theme)
_restart_label.show()
var themeName : String = Types.UIThemeArray[index]

Settings.set_value(Settings.APPEARANCE_THEME, index)
Settings.changed_theme.emit(themeName)

# -------------------------------------------------------------------------------------------------
func _on_brush_rounding_selected(index: int) -> void:
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Dialogs/SettingsDialog.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=6 format=3 uid="uid://cgs8d5y8yrwl0"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1_n5v21"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1_n5v21"]
[ext_resource type="Script" path="res://UI/Dialogs/SettingsDialog.gd" id="2"]

[sub_resource type="StyleBoxEmpty" id="1"]
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Dialogs/UnsavedChangesDialog.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://ct2b6hxxjlc6h"]

[ext_resource type="Script" path="res://UI/Dialogs/UnsavedChangesDialog.gd" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="3"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="3"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ythkr"]

Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/MainMenu.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://c41oe1lt7u6r8"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1"]
[ext_resource type="Script" path="res://UI/MainMenu.gd" id="2"]

[node name="MainMenu" type="PopupMenu"]
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Menubar.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://e4oiel4oqq0b"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1"]
[ext_resource type="Script" path="res://UI/Menubar.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://r233fnxk5qkf" path="res://Assets/Icons/menu.png" id="3"]
[ext_resource type="Script" path="res://UI/Components/FlatTextureButton.gd" id="4"]
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Statusbar.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://bwer12t6vfkg1"]

[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/theme_dark.tres" id="1"]
[ext_resource type="Theme" uid="uid://u5qnpgxqykiv" path="res://UI/Themes/dark/theme.tres" id="1"]
[ext_resource type="Script" path="res://UI/Statusbar.gd" id="2"]

[node name="Statusbar" type="Panel"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_resource type="Theme" load_steps=29 format=4 uid="uid://u5qnpgxqykiv"]
[gd_resource type="Theme" load_steps=28 format=4 uid="uid://u5qnpgxqykiv"]

[ext_resource type="Texture2D" uid="uid://bp1yka17gbjtu" path="res://Assets/Icons/close.png" id="1_qgxa7"]
[ext_resource type="StyleBox" uid="uid://kdduww61cjw" path="res://UI/Themes/tab_inactive_dark.tres" id="2_n6mkw"]
[ext_resource type="StyleBox" uid="uid://dtn7ehcyfik4a" path="res://UI/Themes/tab_active_dark.tres" id="3_rqnin"]
[ext_resource type="StyleBox" uid="uid://kdduww61cjw" path="res://UI/Themes/dark/tab_inactive.tres" id="2_n6mkw"]
[ext_resource type="StyleBox" uid="uid://dtn7ehcyfik4a" path="res://UI/Themes/dark/tab_active.tres" id="3_rqnin"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5j3ky"]
content_margin_left = 8.0
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions lorien/UI/Themes/light/tab_active.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://df8d16wfmjt31"]

[resource]
content_margin_left = 8.0
content_margin_top = 6.0
content_margin_right = 8.0
content_margin_bottom = 6.0
bg_color = Color(0.207843, 0.211765, 0.227451, 1)
border_color = Color(1, 1, 1, 0.75)
corner_radius_top_left = 6
corner_radius_top_right = 6
8 changes: 8 additions & 0 deletions lorien/UI/Themes/light/tab_inactive.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://c1igpcht4hbro"]

[resource]
content_margin_left = 8.0
content_margin_top = 6.0
content_margin_right = 8.0
content_margin_bottom = 6.0
bg_color = Color(0.6, 0.6, 0.6, 0)
Loading