@@ -7,6 +7,9 @@ export(NodePath) var Text_Label_Path = @"HBoxContainer/RichTextLabel"
77var audioPath = ''
88var AudioButton
99var 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
4245func 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+
0 commit comments