Skip to content

Commit 19e8ca0

Browse files
authored
- added the ability to customize the focus property of a choice button. (#1165)
1 parent edef752 commit 19e8ca0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

addons/dialogic/Editor/ThemeEditor/ThemeEditor.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ onready var n : Dictionary = {
129129
# Button modifiers (Inherited scenes)
130130
'button_normal': $"VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer/Normal",
131131
'button_hover': $"VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer/Hover",
132+
'button_focus': $"VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer/Focus",
132133
'button_pressed': $"VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer/Pressed",
133134
'button_disabled': $"VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer/Disabled",
134135

@@ -234,11 +235,13 @@ func _ready() -> void:
234235
# Choice button style modifiers
235236
n['button_normal'].connect('picking_background', self, '_on_ButtonTextureButton_pressed')
236237
n['button_hover'].connect('picking_background', self, '_on_ButtonTextureButton_pressed')
238+
n['button_focus'].connect('picking_background', self, '_on_ButtonTextureButton_pressed')
237239
n['button_pressed'].connect('picking_background', self, '_on_ButtonTextureButton_pressed')
238240
n['button_disabled'].connect('picking_background', self, '_on_ButtonTextureButton_pressed')
239241

240242
n['button_normal'].connect('style_modified', self, '_on_choice_style_modified')
241243
n['button_hover'].connect('style_modified', self, '_on_choice_style_modified')
244+
n['button_focus'].connect('style_modified', self, '_on_choice_style_modified')
242245
n['button_pressed'].connect('style_modified', self, '_on_choice_style_modified')
243246
n['button_disabled'].connect('style_modified', self, '_on_choice_style_modified')
244247

@@ -407,6 +410,7 @@ func load_theme(filename):
407410
var hover_style = [true, Color( 0.698039, 0.698039, 0.698039, 1 ), false, Color.black, true, default_background, false, Color.white]
408411
n['button_normal'].load_style(theme.get_value('buttons', 'normal', default_style))
409412
n['button_hover'].load_style(theme.get_value('buttons', 'hover', hover_style))
413+
n['button_focus'].load_style(theme.get_value('buttons', 'focus', hover_style))
410414
n['button_pressed'].load_style(theme.get_value('buttons', 'pressed', default_style))
411415
n['button_disabled'].load_style(theme.get_value('buttons', 'disabled', default_style))
412416

addons/dialogic/Editor/ThemeEditor/ThemeEditor.tscn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,15 @@ margin_top = 32.0
15351535
margin_right = -4.0
15361536
margin_bottom = -4.0
15371537

1538+
[node name="Focus" parent="VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer" instance=ExtResource( 6 )]
1539+
visible = false
1540+
anchor_right = 1.0
1541+
anchor_bottom = 1.0
1542+
margin_left = 4.0
1543+
margin_top = 32.0
1544+
margin_right = -4.0
1545+
margin_bottom = -4.0
1546+
15381547
[node name="Pressed" parent="VBoxContainer/TabContainer/Choice Buttons/Column/TabContainer" instance=ExtResource( 6 )]
15391548
visible = false
15401549
anchor_right = 1.0

addons/dialogic/Nodes/DialogNode.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,20 +1198,24 @@ func get_classic_choice_button(label: String):
11981198

11991199
var style_normal = theme.get_value('buttons', 'normal', default_style)
12001200
var style_hover = theme.get_value('buttons', 'hover', hover_style)
1201+
var style_focus = theme.get_value('buttons', 'focus', hover_style)
12011202
var style_pressed = theme.get_value('buttons', 'pressed', default_style)
12021203
var style_disabled = theme.get_value('buttons', 'disabled', default_style)
12031204

12041205
# Text color
12051206
var default_color = Color(theme.get_value('text', 'color', '#ffffff'))
12061207
button.set('custom_colors/font_color', default_color)
12071208
button.set('custom_colors/font_color_hover', default_color.lightened(0.2))
1209+
button.set('custom_colors/font_color_focus', default_color.lightened(0.2))
12081210
button.set('custom_colors/font_color_pressed', default_color.darkened(0.2))
12091211
button.set('custom_colors/font_color_disabled', default_color.darkened(0.8))
12101212

12111213
if style_normal[0]:
12121214
button.set('custom_colors/font_color', style_normal[1])
12131215
if style_hover[0]:
12141216
button.set('custom_colors/font_color_hover', style_hover[1])
1217+
if style_focus[0]:
1218+
button.set('custom_colors/font_color_focus', style_focus[1])
12151219
if style_pressed[0]:
12161220
button.set('custom_colors/font_color_pressed', style_pressed[1])
12171221
if style_disabled[0]:
@@ -1221,6 +1225,7 @@ func get_classic_choice_button(label: String):
12211225
# Style normal
12221226
button_style_setter('normal', style_normal, button, theme)
12231227
button_style_setter('hover', style_hover, button, theme)
1228+
button_style_setter('focus', style_focus, button, theme)
12241229
button_style_setter('pressed', style_pressed, button, theme)
12251230
button_style_setter('disabled', style_disabled, button, theme)
12261231
return button

0 commit comments

Comments
 (0)