]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Resources/dialogic_layout_base.gd
Updated export config options
[wolf-seeking-sheep.git] / addons / dialogic / Resources / dialogic_layout_base.gd
1 @tool
2 class_name DialogicLayoutBase
3 extends Node
4
5 ## Base class that should be extended by custom layouts.
6
7
8 ## Method that adds a node as a layer
9 func add_layer(layer:DialogicLayoutLayer) -> Node:
10         add_child(layer)
11         return layer
12
13
14 ## Method that returns the given child
15 func get_layer(index:int) -> Node:
16         return get_child(index)
17
18
19 ## Method to return all the layers
20 func get_layers() -> Array:
21         var layers := []
22         for child in get_children():
23                 if child is DialogicLayoutLayer:
24                         layers.append(child)
25         return layers
26
27
28 ## Method that is called to load the export overrides.
29 ## This happens when the style is first introduced,
30 ## but also when switching to a different style using the same scene!
31 func apply_export_overrides() -> void:
32         _apply_export_overrides()
33         for child in get_children():
34                 if child.has_method('_apply_export_overrides'):
35                         child._apply_export_overrides()
36
37
38 ## Returns a setting on this base.
39 ## This is useful so that layers can share settings like base_color, etc.
40 func get_global_setting(setting:StringName, default:Variant) -> Variant:
41         if setting in self:
42                 return get(setting)
43
44         if str(setting).to_lower() in self:
45                 return get(setting.to_lower())
46
47         if 'global_'+str(setting) in self:
48                 return get('global_'+str(setting))
49
50         return default
51
52
53 ## To be overwritten. Apply the settings to your scene here.
54 func _apply_export_overrides() -> void:
55         pass
56
57
58 #region HANDLE PERSISTENT DATA
59 ################################################################################
60
61 func _enter_tree() -> void:
62         _load_persistent_info(Engine.get_meta("dialogic_persistent_style_info", {}))
63
64
65 func _exit_tree() -> void:
66         Engine.set_meta("dialogic_persistent_style_info", _get_persistent_info())
67
68
69 ## To be overwritten. Return any info that a later used style might want to know.
70 func _get_persistent_info() -> Dictionary:
71         return {}
72
73
74 ## To be overwritten. Apply any info that a previous style might have stored and this style should use.
75 func _load_persistent_info(info: Dictionary) -> void:
76         pass
77
78 #endregion