Skip to content

Commit b31a2b5

Browse files
authored
History Default theme adjustments (#821)
* History Default theme adjustments HistoryRow now use the default theme HistoryRow themeing can now be disabled Default Background now matches default theme * Minor Optimization Replaced node searches with onready variables
1 parent fce2959 commit b31a2b5

File tree

5 files changed

+58
-28
lines changed

5 files changed

+58
-28
lines changed

addons/dialogic/Editor/SettingsEditor/Scenes/HistorySettings.tscn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ settings_key = "enable_history_logging"
6060
margin_left = 162.0
6161
margin_right = 336.0
6262
margin_bottom = 24.0
63-
text = "Use dialog theme"
63+
text = "Use default theme"
64+
default = true
6465
settings_section = "history"
6566
settings_key = "enable_dynamic_theme"
6667

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
[gd_scene format=2]
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://addons/dialogic/Example Assets/backgrounds/background-2.png" type="Texture" id=1]
24

35
[node name="DefaultBackground" type="Panel"]
4-
modulate = Color( 1, 1, 1, 0.607843 )
6+
self_modulate = Color( 1, 1, 1, 0 )
57
anchor_right = 1.0
68
anchor_bottom = 1.0
79
mouse_filter = 2
810
__meta__ = {
911
"_edit_use_anchors_": false
1012
}
13+
14+
[node name="TextureRect" type="TextureRect" parent="."]
15+
anchor_right = 1.0
16+
anchor_bottom = 1.0
17+
texture = ExtResource( 1 )
18+
expand = true
19+
stretch_mode = 1
20+
__meta__ = {
21+
"_edit_use_anchors_": false
22+
}

addons/dialogic/Example Assets/History/HistoryRow.gd

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export(NodePath) var Text_Label_Path = @"HBoxContainer/RichTextLabel"
77
var audioPath = ''
88
var AudioButton
99
var TextLabel
10+
onready var TextContainer = $HBoxContainer
11+
onready var ColorRectElement = $ColorRect
12+
onready var TextureRectElement = $TextureRect
1013

1114
"""
1215
Example of a HistoryRow. Every time dialog is logged, a new row is created.
@@ -38,44 +41,56 @@ func add_history(historyString, newAudio=''):
3841
AudioButton.focus_mode = FOCUS_NONE
3942

4043

41-
# Uses the default theme to make the font and boxes looks a bit nicer
44+
# Load Theme is called by
4245
func load_theme(theme: ConfigFile):
4346
# Text
4447
var theme_font = DialogicUtil.path_fixer_load(theme.get_value('text', 'font', 'res://addons/dialogic/Example Assets/Fonts/DefaultFont.tres'))
4548
TextLabel.set('custom_fonts/normal_font', theme_font)
4649
TextLabel.set('custom_fonts/bold_font', DialogicUtil.path_fixer_load(theme.get_value('text', 'bold_font', 'res://addons/dialogic/Example Assets/Fonts/DefaultBoldFont.tres')))
4750
TextLabel.set('custom_fonts/italics_font', DialogicUtil.path_fixer_load(theme.get_value('text', 'italic_font', 'res://addons/dialogic/Example Assets/Fonts/DefaultItalicFont.tres')))
51+
#name_label.set('custom_fonts/font', DialogicUtil.path_fixer_load(theme.get_value('name', 'font', 'res://addons/dialogic/Example Assets/Fonts/NameFont.tres')))
52+
53+
# setting the vertical alignment
54+
var alignment = theme.get_value('text', 'alignment',0)
55+
if alignment <= 2: # top
56+
TextContainer.alignment = BoxContainer.ALIGN_BEGIN
57+
elif alignment <= 5: # center
58+
TextContainer.alignment = BoxContainer.ALIGN_CENTER
59+
elif alignment <= 8: # bottom
60+
TextContainer.alignment = BoxContainer.ALIGN_END
4861

4962
var text_color = Color(theme.get_value('text', 'color', '#ffffffff'))
5063
TextLabel.set('custom_colors/default_color', text_color)
51-
64+
#name_label.set('custom_colors/font_color', text_color)
65+
5266
TextLabel.set('custom_colors/font_color_shadow', Color('#00ffffff'))
53-
67+
#name_label.set('custom_colors/font_color_shadow', Color('#00ffffff'))
68+
5469
if theme.get_value('text', 'shadow', false):
5570
var text_shadow_color = Color(theme.get_value('text', 'shadow_color', '#9e000000'))
5671
TextLabel.set('custom_colors/font_color_shadow', text_shadow_color)
57-
72+
5873
var shadow_offset = theme.get_value('text', 'shadow_offset', Vector2(2,2))
5974
TextLabel.set('custom_constants/shadow_offset_x', shadow_offset.x)
6075
TextLabel.set('custom_constants/shadow_offset_y', shadow_offset.y)
61-
76+
6277
# Margin
6378
var text_margin = theme.get_value('text', 'margin', Vector2(20, 10))
64-
TextLabel.set('margin_left', text_margin.x)
65-
TextLabel.set('margin_right', text_margin.x * -1)
66-
TextLabel.set('margin_top', text_margin.y)
67-
TextLabel.set('margin_bottom', text_margin.y * -1)
68-
79+
TextContainer.set('margin_left', text_margin.x)
80+
TextContainer.set('margin_right', text_margin.x * -1)
81+
TextContainer.set('margin_top', text_margin.y)
82+
TextContainer.set('margin_bottom', text_margin.y * -1)
83+
6984
# Backgrounds
70-
$TextureRect.texture = DialogicUtil.path_fixer_load(theme.get_value('background','image', "res://addons/dialogic/Example Assets/backgrounds/background-2.png"))
71-
$TextureRect.expand = true
72-
$ColorRect.color = Color(theme.get_value('background','color', "#ff000000"))
73-
85+
TextureRectElement.texture = DialogicUtil.path_fixer_load(theme.get_value('background','image', "res://addons/dialogic/Example Assets/backgrounds/background-2.png"))
86+
ColorRectElement.color = Color(theme.get_value('background','color', "#ff000000"))
87+
7488
if theme.get_value('background', 'modulation', false):
75-
$TextureRect.modulate = Color(theme.get_value('background', 'modulation_color', '#ffffffff'))
89+
TextureRectElement.modulate = Color(theme.get_value('background', 'modulation_color', '#ffffffff'))
7690
else:
77-
$TextureRect.modulate = Color('#ffffffff')
78-
79-
$ColorRect.visible = theme.get_value('background', 'use_color', false)
80-
$TextureRect.visible = theme.get_value('background', 'use_image', true)
91+
TextureRectElement.modulate = Color('#ffffffff')
8192

93+
ColorRectElement.visible = theme.get_value('background', 'use_color', false)
94+
TextureRectElement.visible = theme.get_value('background', 'use_image', true)
95+
96+

addons/dialogic/Example Assets/History/HistoryRow.tscn

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
[gd_scene load_steps=2 format=2]
1+
[gd_scene load_steps=3 format=2]
22

33
[ext_resource path="res://addons/dialogic/Example Assets/History/HistoryRow.gd" type="Script" id=1]
4+
[ext_resource path="res://addons/dialogic/Example Assets/backgrounds/background-2.png" type="Texture" id=2]
45

56
[node name="HistoryRow" type="PanelContainer"]
7+
self_modulate = Color( 1, 1, 1, 0 )
68
rect_min_size = Vector2( 0, 28 )
79
size_flags_horizontal = 3
810
size_flags_vertical = 0
@@ -22,14 +24,13 @@ __meta__ = {
2224
}
2325

2426
[node name="TextureRect" type="TextureRect" parent="."]
25-
visible = false
2627
margin_left = 7.0
2728
margin_top = 7.0
2829
margin_right = 51.0
29-
margin_bottom = 7.0
30-
size_flags_horizontal = 5
31-
size_flags_vertical = 0
30+
margin_bottom = 43.0
31+
texture = ExtResource( 2 )
3232
expand = true
33+
stretch_mode = 1
3334
__meta__ = {
3435
"_edit_use_anchors_": false
3536
}

addons/dialogic/Nodes/History.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ func add_history_row_event(eventData):
189189
HistoryTimeline.add_child(newHistoryRow)
190190
if(reverseTimeline):
191191
HistoryTimeline.move_child(newHistoryRow,0)
192-
newHistoryRow.load_theme(curTheme)
192+
if newHistoryRow.has_method('load_theme') and get_parent().settings.get_value('history', 'enable_dynamic_theme', false) == true:
193+
newHistoryRow.load_theme(curTheme)
193194

194195
var characterPrefix = ''
195196
if eventData.has('character') and eventData.character != '':

0 commit comments

Comments
 (0)