Skip to content

Commit

Permalink
Adjust static typing spaces
Browse files Browse the repository at this point in the history
As Cake pointed out
var inferred := 123
var explicit: int = 123

So I tried to enforce that on the layers.
  • Loading branch information
Jowan-Spooner committed Jan 9, 2024
1 parent d293c91 commit 73995f9
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ extends DialogicLayoutBase

## The default layout base scene.

@export var canvas_layer : int = 1
@export var canvas_layer: int = 1

@export_subgroup("Global")
@export var global_bg_color : Color = Color(0, 0, 0, 0.9)
@export var global_font_color : Color = Color("white")
@export_file('*.ttf') var global_font : String = ""
@export var global_font_size : int = 18
@export var global_bg_color: Color = Color(0, 0, 0, 0.9)
@export var global_font_color: Color = Color("white")
@export_file('*.ttf') var global_font: String = ""
@export var global_font_size: int = 18


func _apply_export_overrides() -> void:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ extends DialogicLayoutLayer

@export_group('Text')
enum Alignment {LEFT, CENTER, RIGHT}
@export var title_alignment : Alignment = Alignment.LEFT
@export var text_alignment : Alignment = Alignment.LEFT
@export var extra_alignment : Alignment = Alignment.RIGHT
@export var title_alignment: Alignment = Alignment.LEFT
@export var text_alignment: Alignment = Alignment.LEFT
@export var extra_alignment: Alignment = Alignment.RIGHT

@export_subgroup("Colors")
enum TextColorModes {GLOBAL, ENTRY, CUSTOM}
@export var title_color_mode : TextColorModes = TextColorModes.ENTRY
@export var title_custom_color : Color = Color.WHITE
@export var text_color_mode : TextColorModes = TextColorModes.ENTRY
@export var text_custom_color : Color = Color.WHITE
@export var extra_color_mode : TextColorModes = TextColorModes.ENTRY
@export var extra_custom_color : Color = Color.WHITE
@export var title_color_mode: TextColorModes = TextColorModes.ENTRY
@export var title_custom_color: Color = Color.WHITE
@export var text_color_mode: TextColorModes = TextColorModes.ENTRY
@export var text_custom_color: Color = Color.WHITE
@export var extra_color_mode: TextColorModes = TextColorModes.ENTRY
@export var extra_custom_color: Color = Color.WHITE


@export_group("Font")
@export var font_use_global : bool = true
@export_file('*.ttf') var font_custom : String = ""
@export var font_use_global: bool = true
@export_file('*.ttf') var font_custom: String = ""

@export_subgroup('Sizes')
@export var font_title_size : int = 18
@export var font_text_size : int = 17
@export var font_extra_size : int = 15
@export var font_title_size: int = 18
@export var font_text_size: int = 17
@export var font_extra_size: int = 15


@export_group("Box")
@export_subgroup("Color")
enum ModulateModes {BASE_COLOR_ONLY, ENTRY_COLOR_ON_BOX, GLOBAL_BG_COLOR}
@export var box_modulate_mode : ModulateModes = ModulateModes.ENTRY_COLOR_ON_BOX
@export var box_base_modulate : Color = Color.WHITE
@export var box_modulate_mode: ModulateModes = ModulateModes.ENTRY_COLOR_ON_BOX
@export var box_base_modulate: Color = Color.WHITE
@export_subgroup("Size")
@export var box_width : int = 200
@export var box_width: int = 200

func get_pointer() -> Control:
return $Pointer
Expand Down Expand Up @@ -68,8 +68,8 @@ func _ready() -> void:
return

get_pointer().hide()
var text_system : Node = DialogicUtil.autoload().get(&'Text')
var _error : int = 0
var text_system: Node = DialogicUtil.autoload().get(&'Text')
var _error: int = 0
_error = text_system.connect(&'animation_textbox_hide', get_pointer().hide)
_error = text_system.connect(&'meta_hover_started', _on_dialogic_display_dialog_text_meta_hover_started)
_error = text_system.connect(&'meta_hover_ended', _on_dialogic_display_dialog_text_meta_hover_ended)
Expand All @@ -78,7 +78,7 @@ func _ready() -> void:

## Method that shows the bubble and fills in the info
func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void:
var info : Dictionary = DialogicUtil.autoload().get(&'Glossary').call(&'get_entry', meta)
var info: Dictionary = DialogicUtil.autoload().get(&'Glossary').call(&'get_entry', meta)

if not info:
return
Expand Down Expand Up @@ -111,7 +111,7 @@ func _process(_delta : float) -> void:
if Engine.is_editor_hint():
return

var pointer : Control = get_pointer()
var pointer: Control = get_pointer()
if pointer.visible:
pointer.global_position = pointer.get_global_mouse_position()

Expand All @@ -134,15 +134,15 @@ func _apply_export_overrides() -> void:
elif ResourceLoader.exists(font_custom):
font = load(font_custom)

var title : Label = get_title()
var title: Label = get_title()
if font:
title.add_theme_font_override(&"font", font)
title.horizontal_alignment = title_alignment as HorizontalAlignment

# Apply font & sizes
title.add_theme_font_size_override(&"font_size", font_title_size)
var labels : Array[RichTextLabel] = [get_text(), get_extra()]
var sizes : PackedInt32Array = [font_text_size, font_extra_size]
var labels: Array[RichTextLabel] = [get_text(), get_extra()]
var sizes: PackedInt32Array = [font_text_size, font_extra_size]
for i : int in len(labels):
if font:
labels[i].add_theme_font_override(&'normal_font', font)
Expand All @@ -155,10 +155,10 @@ func _apply_export_overrides() -> void:


# Apply text colors
var controls : Array[Control] = [get_title(), get_text(), get_extra()]
var global_settings : Array[StringName] = [&'font_color', &'default_color', &'default_color']
var color_modes : Array[TextColorModes] = [title_color_mode, text_color_mode, extra_color_mode]
var custom_colors : PackedColorArray = [title_custom_color, text_custom_color, extra_custom_color]
var controls: Array[Control] = [get_title(), get_text(), get_extra()]
var global_settings: Array[StringName] = [&'font_color', &'default_color', &'default_color']
var color_modes: Array[TextColorModes] = [title_color_mode, text_color_mode, extra_color_mode]
var custom_colors: PackedColorArray = [title_custom_color, text_custom_color, extra_custom_color]
for i : int in len(controls):
match color_modes[i]:
TextColorModes.GLOBAL:
Expand All @@ -167,7 +167,7 @@ func _apply_export_overrides() -> void:
controls[i].add_theme_color_override(global_settings[i], custom_colors[i])

# Apply box size
var panel : PanelContainer = get_panel()
var panel: PanelContainer = get_panel()
panel.size.x = box_width
panel.position.x = -box_width/2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ extends DialogicLayoutLayer

@export_group('Look')
@export_subgroup('Font')
@export var font_use_global_size : bool = true
@export var font_custom_size : int = 15
@export var font_use_global_fonts : bool = true
@export_file('*.ttf') var font_custom_normal : String = ""
@export_file('*.ttf') var font_custom_bold : String = ""
@export_file('*.ttf') var font_custom_italics : String = ""
@export var font_use_global_size: bool = true
@export var font_custom_size: int = 15
@export var font_use_global_fonts: bool = true
@export_file('*.ttf') var font_custom_normal: String = ""
@export_file('*.ttf') var font_custom_bold: String = ""
@export_file('*.ttf') var font_custom_italics: String = ""

@export_subgroup('Buttons')
@export var show_open_button: bool = true
Expand All @@ -32,7 +32,7 @@ var scroll_to_bottom_flag: bool = false
@export_group('Private')
@export var HistoryItem: PackedScene = null

var history_item_theme : Theme = null
var history_item_theme: Theme = null

func get_show_history_button() -> Button:
return $ShowHistory
Expand All @@ -56,7 +56,7 @@ func _ready() -> void:


func _apply_export_overrides() -> void:
var history_subsystem : Node = DialogicUtil.autoload().get(&'History')
var history_subsystem: Node = DialogicUtil.autoload().get(&'History')
if history_subsystem != null:
get_show_history_button().visible = show_open_button and history_subsystem.get(&'simple_history_enabled')
else:
Expand Down Expand Up @@ -96,10 +96,10 @@ func _on_show_history_pressed() -> void:


func show_history() -> void:
for child : Node in get_history_log().get_children():
for child: Node in get_history_log().get_children():
child.queue_free()

for info : Dictionary in DialogicUtil.autoload().get(&'History').call(&'get_simple_history'):
for info: Dictionary in DialogicUtil.autoload().get(&'History').call(&'get_simple_history'):
var history_item : Node = HistoryItem.instantiate()
history_item.set(&'theme', history_item_theme)
match info.event_type:
Expand All @@ -117,7 +117,7 @@ func show_history() -> void:
continue
history_item.call(&'load_info', '[i]'+info['text'])
"Choice":
var choices_text : String = ""
var choices_text: String = ""
if show_all_choices:
for i : String in info['all_choices']:
if i.ends_with('#disabled'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,56 @@ enum LimitedAlignments {LEFT=0, RIGHT=1}

@export_group('Text')
@export_subgroup("Text")
@export var text_alignment :Alignments= Alignments.LEFT
@export var text_alignment: Alignments = Alignments.LEFT
@export_subgroup('Size')
@export var text_use_global_size : bool = true
@export var text_custom_size : int = 15
@export var text_use_global_size: bool = true
@export var text_custom_size: int = 15
@export_subgroup('Color')
@export var text_use_global_color : bool = true
@export var text_custom_color : Color = Color.WHITE
@export var text_use_global_color: bool = true
@export var text_custom_color: Color = Color.WHITE
@export_subgroup('Fonts')
@export var use_global_fonts : bool = true
@export_file('*.ttf') var custom_normal_font:String = ""
@export_file('*.ttf') var custom_bold_font:String = ""
@export_file('*.ttf') var custom_italic_font:String = ""
@export_file('*.ttf') var custom_bold_italic_font:String = ""
@export var use_global_fonts: bool = true
@export_file('*.ttf') var custom_normal_font: String = ""
@export_file('*.ttf') var custom_bold_font: String = ""
@export_file('*.ttf') var custom_italic_font: String = ""
@export_file('*.ttf') var custom_bold_italic_font: String = ""

@export_group('Name Label')
@export_subgroup("Color")
enum NameLabelColorModes {GLOBAL_COLOR, CHARACTER_COLOR, CUSTOM_COLOR}
@export var name_label_color_mode : NameLabelColorModes = NameLabelColorModes.GLOBAL_COLOR
@export var name_label_custom_color : Color = Color.WHITE
@export var name_label_color_mode: NameLabelColorModes = NameLabelColorModes.GLOBAL_COLOR
@export var name_label_custom_color: Color = Color.WHITE
@export_subgroup("Behaviour")
@export var name_label_alignment : Alignments = Alignments.LEFT
@export var name_label_hide_when_no_character : bool = false
@export var name_label_alignment: Alignments = Alignments.LEFT
@export var name_label_hide_when_no_character: bool = false
@export_subgroup("Font & Size")
@export var name_label_use_global_size : bool = true
@export var name_label_custom_size : int = 15
@export var name_label_use_global_font : bool = true
@export_file('*.ttf') var name_label_customfont : String = ""
@export var name_label_use_global_size: bool = true
@export var name_label_custom_size: int = 15
@export var name_label_use_global_font: bool = true
@export_file('*.ttf') var name_label_customfont: String = ""

@export_group('Box')
@export_subgroup("Box")
@export_file('*.tres') var box_panel : String = this_folder.path_join("default_stylebox.tres")
@export var box_modulate_global_color : bool = true
@export var box_modulate_custom_color : Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658)
@export var box_size : Vector2 = Vector2(600, 160)
@export var box_distance : int = 25
@export_file('*.tres') var box_panel: String = this_folder.path_join("default_stylebox.tres")
@export var box_modulate_global_color: bool = true
@export var box_modulate_custom_color: Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658)
@export var box_size: Vector2 = Vector2(600, 160)
@export var box_distance: int = 25

@export_group('Portrait')
@export_subgroup('Portrait')
@export var portrait_stretch_factor : float = 0.3
@export var portrait_position : LimitedAlignments = LimitedAlignments.LEFT
@export var portrait_bg_modulate : Color = Color(0, 0, 0, 0.5137255191803)
@export var portrait_stretch_factor: float = 0.3
@export var portrait_position: LimitedAlignments = LimitedAlignments.LEFT
@export var portrait_bg_modulate: Color = Color(0, 0, 0, 0.5137255191803)


## Called by dialogic whenever export overrides might change
func _apply_export_overrides() -> void:
## FONT SETTINGS
var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText
var dialog_text: DialogicNode_DialogText = %DialogicNode_DialogText
dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment

var text_size : int = text_custom_size
var text_size: int = text_custom_size
if text_use_global_size:
text_size = get_global_setting(&'font_size', text_custom_size)

Expand All @@ -65,12 +65,12 @@ func _apply_export_overrides() -> void:
dialog_text.add_theme_font_size_override(&"bold_italics_font_size", text_size)


var text_color : Color = text_custom_color
var text_color: Color = text_custom_color
if text_use_global_color:
text_color = get_global_setting(&'font_color', text_custom_color)
dialog_text.add_theme_color_override(&"default_color", text_color)

var normal_font : String = custom_normal_font
var normal_font: String = custom_normal_font
if use_global_fonts and ResourceLoader.exists(get_global_setting(&'font', '') as String):
normal_font = get_global_setting(&'font', '')

Expand All @@ -84,8 +84,8 @@ func _apply_export_overrides() -> void:
dialog_text.add_theme_font_override(&"bold_italics_font", load(custom_bold_italic_font) as Font)

## BOX SETTINGS
var panel : PanelContainer = %Panel
var portrait_panel : Panel = %PortraitPanel
var panel: PanelContainer = %Panel
var portrait_panel: Panel = %PortraitPanel
if box_modulate_global_color:
panel.self_modulate = get_global_setting(&'bg_color', box_modulate_custom_color)
else:
Expand All @@ -98,19 +98,19 @@ func _apply_export_overrides() -> void:
panel.add_theme_stylebox_override(&'panel', stylebox)

## PORTRAIT SETTINGS
var portrait_background_color : ColorRect = %PortraitBackgroundColor
var portrait_background_color: ColorRect = %PortraitBackgroundColor
portrait_background_color.color = portrait_bg_modulate

portrait_panel.get_parent().move_child(portrait_panel, portrait_position)

## NAME LABEL SETTINGS
var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel
var name_label: DialogicNode_NameLabel = %DialogicNode_NameLabel
if name_label_use_global_size:
name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_size) as int)
else:
name_label.add_theme_font_size_override(&"font_size", name_label_custom_size)

var name_label_font : String = name_label_customfont
var name_label_font: String = name_label_customfont
if name_label_use_global_font and ResourceLoader.exists(get_global_setting(&'font', '') as String):
name_label_font = get_global_setting(&'font', '')
if !name_label_font.is_empty():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extends DialogicLayoutLayer


func _apply_export_overrides() -> void:
var layer_theme : Theme = get(&'theme')
var layer_theme: Theme = get(&'theme')
if layer_theme == null:
layer_theme = Theme.new()

Expand Down
Loading

0 comments on commit 73995f9

Please sign in to comment.