Skip to content

Commit

Permalink
fix(Theme): themes will now be properly set on UI components
Browse files Browse the repository at this point in the history
This fixes issues seen with setting themes on startup. The theme will
now only be set if an effective theme exists, or a theme is changed.
  • Loading branch information
ShadowApex committed Aug 17, 2024
1 parent 1b93b7f commit 89d20cc
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 51 deletions.
11 changes: 9 additions & 2 deletions core/ui/components/card_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,22 @@ func _ready() -> void:
label.vertical_alignment = vertical_alignment
label.autowrap_mode = autowrap_mode
label.uppercase = uppercase


if Engine.is_editor_hint():
return

# Connect signals
pressed.connect(_play_sound.bind(select_audio_stream))
focus_entered.connect(_on_focus)
focus_exited.connect(_on_unfocus)
mouse_entered.connect(_on_focus)
mouse_exited.connect(_on_unfocus)
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
Expand Down
15 changes: 1 addition & 14 deletions core/ui/components/card_button.tscn
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://c71ayw7pcw6u6"]
[gd_scene load_steps=2 format=3 uid="uid://c71ayw7pcw6u6"]

[ext_resource type="Script" path="res://core/ui/components/card_button.gd" id="1_62nf7"]

[sub_resource type="Image" id="Image_u87yt"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_ax6fu"]
image = SubResource("Image_u87yt")

[node name="CardButton" type="PanelContainer"]
clip_children = 2
offset_right = 103.0
Expand All @@ -26,7 +14,6 @@ script = ExtResource("1_62nf7")
unique_name_in_owner = true
visible = false
layout_mode = 2
texture = SubResource("ImageTexture_ax6fu")
expand_mode = 1
stretch_mode = 6

Expand Down
11 changes: 9 additions & 2 deletions core/ui/components/card_icon_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,22 @@ var select_audio_stream = load(select_audio)
func _ready() -> void:
# Configure the icon
icon.texture = texture


if Engine.is_editor_hint():
return

# Connect signals
pressed.connect(_play_sound.bind(select_audio_stream))
focus_entered.connect(_on_focus)
focus_exited.connect(_on_unfocus)
mouse_entered.connect(_on_focus)
mouse_exited.connect(_on_unfocus)
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
Expand Down
6 changes: 5 additions & 1 deletion core/ui/components/card_input_icon_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ var logger := Log.get_logger("CardInputIconButton")
func _ready() -> void:
# Connect signals
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
Expand Down
11 changes: 9 additions & 2 deletions core/ui/components/card_mapping_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,17 @@ func _ready() -> void:
target_label.vertical_alignment = vertical_alignment
target_label.autowrap_mode = autowrap_mode
target_label.uppercase = uppercase


if Engine.is_editor_hint():
return

# Connect signals
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


## Set the source input icon's icon mapping
Expand Down
15 changes: 1 addition & 14 deletions core/ui/components/card_mapping_button.tscn
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
[gd_scene load_steps=8 format=3 uid="uid://dbll03tbmw3ps"]
[gd_scene load_steps=6 format=3 uid="uid://dbll03tbmw3ps"]

[ext_resource type="Script" path="res://core/ui/components/card_mapping_button.gd" id="1_qi6wi"]
[ext_resource type="Script" path="res://core/ui/components/input_icon.gd" id="2_d8vnj"]
[ext_resource type="PackedScene" uid="uid://c5sfkhrfbao71" path="res://core/systems/effects/play_audio_effect.tscn" id="2_o51i2"]
[ext_resource type="PackedScene" uid="uid://bw8113ocotx2r" path="res://core/systems/effects/fade_effect.tscn" id="3_h1m7y"]
[ext_resource type="Texture2D" uid="uid://da6kcs5mhssov" path="res://assets/ui/icons/arrow-right-bold.svg" id="4_gjhmn"]

[sub_resource type="Image" id="Image_6pbp1"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_sa6yd"]
image = SubResource("Image_6pbp1")

[node name="CardMappingButton" type="MarginContainer"]
editor_description = "Button used for mapping gamepad inputs"
anchors_preset = 15
Expand Down Expand Up @@ -57,7 +45,6 @@ theme_type_variation = &"CardButton"
unique_name_in_owner = true
visible = false
layout_mode = 2
texture = SubResource("ImageTexture_sa6yd")
expand_mode = 1
stretch_mode = 6

Expand Down
12 changes: 8 additions & 4 deletions core/ui/components/dropdown.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ signal item_selected(index: int)

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
focus_entered.connect(_grab_focus)
label.text = title
description_label.text = description
option_button.disabled = disabled
if Engine.is_editor_hint():
return
option_button.focus_neighbor_bottom = focus_neighbor_bottom
option_button.focus_neighbor_left = focus_neighbor_left
option_button.focus_neighbor_right = focus_neighbor_right
option_button.focus_neighbor_top = focus_neighbor_top
option_button.focus_previous = focus_previous
option_button.focus_next = focus_next
focus_entered.connect(_grab_focus)

# Hide labels if nothing is specified
if title == "":
Expand All @@ -76,10 +78,12 @@ func _ready() -> void:
option_button.select(focused_item)
option_button.item_selected.emit(focused_item)
option_popup.visible = false
if event.is_action_pressed("ogui_east") \
or event.is_action_pressed("ogui_back") \
or event.is_action_pressed("ogui_east_ov"):
get_viewport().set_input_as_handled()
if event.is_action_released("ogui_east") \
or event.is_action_released("ogui_back") \
or event.is_action_released("ogui_east_ov"):
option_popup.visible = false
get_viewport().set_input_as_handled()
option_popup.window_input.connect(on_option_button_input)


Expand Down
7 changes: 6 additions & 1 deletion core/ui/components/expandable_card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ func _ready() -> void:
focus_exited.connect(_on_unfocus)
pressed.connect(_on_pressed)
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()

label.text = title

# Do nothing if running in the editor
Expand Down
3 changes: 3 additions & 0 deletions core/ui/components/input_icon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ var internal_children: Array[Node] = []
texture_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED

func _ready():
# Don't run in the editor
if Engine.is_editor_hint():
return
# Add the children
self.add_child(label)
# Only listen for input type changes if no mapping is forced
Expand Down
7 changes: 6 additions & 1 deletion core/ui/components/plugin_store_card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ func _ready() -> void:
focus_entered.connect(_on_focus)
focus_exited.connect(_on_unfocus)
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()

update_button.visible = PluginLoader.is_upgradable(plugin_id)
action_button.pressed.connect(_on_install_button)
update_button.pressed.connect(_on_update_button)
Expand Down
2 changes: 1 addition & 1 deletion core/ui/components/search_bar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class_name SearchBar

signal search_submitted(text: String)

var state_machine := load("res://assets/state/state_machines/global_state_machine.tres") as StateMachine
var state_machine := load("res://assets/state/state_machines/menu_state_machine.tres") as StateMachine
var library_state := load("res://assets/state/states/library.tres")

var keyboard_context := KeyboardContext.new(KeyboardContext.TYPE.GODOT, self)
Expand Down
8 changes: 6 additions & 2 deletions core/ui/components/slider.gd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func _ready() -> void:
slider.focus_neighbor_top = focus_neighbor_top
slider.focus_previous = focus_previous
slider.focus_next = focus_next

# Wire up all slider signals
var on_drag_ended := func(changed: bool):
drag_ended.emit(changed)
Expand All @@ -98,7 +98,11 @@ func _ready() -> void:

# Set color based on theme
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
Expand Down
17 changes: 12 additions & 5 deletions core/ui/components/status.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,24 @@ var color: String = "green":

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
focus_entered.connect(_on_focus.bind(true))
focus_exited.connect(_on_focus.bind(false))
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

label.text = title
description_label.text = description
description_label.visible = description != ""
texture_rect.texture = status_texture_map[status]
texture_rect.modulate = get_theme_color(color, "Status")

if Engine.is_editor_hint():
return

focus_entered.connect(_on_focus.bind(true))
focus_exited.connect(_on_focus.bind(false))
theme_changed.connect(_on_theme_changed)

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
# Get the style from the set theme so it can be set on the panel container
Expand Down
4 changes: 4 additions & 0 deletions core/ui/components/tabs_header.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func _ready() -> void:
tab.text = tab_text
container.add_child(tab)

# Don't run in the editor
if Engine.is_editor_hint():
return

# Set the currently selected tab
_on_tab_changed(tabs_state.current_tab)

Expand Down
6 changes: 5 additions & 1 deletion core/ui/components/text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ func _ready() -> void:
focus_entered.connect(_on_focus.bind(true))
focus_exited.connect(_on_focus.bind(false))
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
Expand Down
6 changes: 5 additions & 1 deletion core/ui/components/toggle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func _ready() -> void:
focus_entered.connect(_on_focus.bind(true))
focus_exited.connect(_on_focus.bind(false))
theme_changed.connect(_on_theme_changed)
_on_theme_changed()

# Find the parent theme and update if required
var effective_theme := ThemeUtils.get_effective_theme(self)
if effective_theme:
_on_theme_changed()


func _on_theme_changed() -> void:
Expand Down

0 comments on commit 89d20cc

Please sign in to comment.