First work on dialogic, resized guild, and started implementing portraits.

This commit is contained in:
2025-08-14 10:26:24 -04:00
parent 95a7db036b
commit 3aeb3d44e6
959 changed files with 47688 additions and 46 deletions

View File

@@ -0,0 +1,34 @@
@tool
extends DialogicCharacterEditorMainSection
## Character editor tab that allows setting a custom style fot the character.
func _init() -> void:
hint_text = 'If a character style is set, dialogic will switch to this style, whenever the character speaks. \nFor this it\'s best to use a variation of the same layout to avoid instancing a lot.'
func _get_title() -> String:
return "Style"
func _ready() -> void:
%StyleName.resource_icon = get_theme_icon("PopupMenu", "EditorIcons")
%StyleName.get_suggestions_func = get_style_suggestions
func _load_character(character:DialogicCharacter) -> void:
%StyleName.set_value(character.custom_info.get('style', ''))
func _save_changes(character:DialogicCharacter) -> DialogicCharacter:
character.custom_info['style'] = %StyleName.current_value
return character
func get_style_suggestions(filter:String="") -> Dictionary:
var styles: Array = ProjectSettings.get_setting('dialogic/layout/style_list', [])
var suggestions := {}
suggestions["No Style"] = {'value': "", 'editor_icon': ["EditorHandleDisabled", "EditorIcons"]}
for i in styles:
var style: DialogicStyle = load(i)
suggestions[style.name] = {'value': style.name, 'editor_icon': ["PopupMenu", "EditorIcons"]}
return suggestions

View File

@@ -0,0 +1 @@
uid://c4k61ht01cl4i

View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=3 format=3 uid="uid://fgplvp0f3giu"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/Style/character_settings_style.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="2_a46q0"]
[node name="Style" type="VBoxContainer"]
offset_right = 280.0
offset_bottom = 79.0
script = ExtResource("2")
[node name="Style" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="Label" type="Label" parent="Style"]
layout_mode = 2
size_flags_vertical = 0
text = "Style:"
[node name="StyleName" parent="Style" instance=ExtResource("2_a46q0")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3

View File

@@ -0,0 +1,71 @@
@tool
class_name DialogicStyleEvent
extends DialogicEvent
## Event that allows changing the currently displayed style.
### Settings
## The name of the style to change to. Can be set on the DialogicNode_Style.
var style_name := ""
################################################################################
## EXECUTE
################################################################################
func _execute() -> void:
dialogic.Styles.change_style(style_name)
# we need to wait till the new layout is ready before continuing
await dialogic.get_tree().process_frame
finish()
################################################################################
## INITIALIZE
################################################################################
func _init() -> void:
event_name = "Change Style"
set_default_color('Color8')
event_category = "Visuals"
event_sorting_index = 1
################################################################################
## SAVING/LOADING
################################################################################
func get_shortcode() -> String:
return "style"
func get_shortcode_parameters() -> Dictionary:
return {
#param_name : property_info
"name" : {"property": "style_name", "default": "", 'suggestions':get_style_suggestions},
}
################################################################################
## EDITOR REPRESENTATION
################################################################################
func build_event_editor() -> void:
add_header_edit('style_name', ValueType.DYNAMIC_OPTIONS, {
'left_text' :'Use style',
'placeholder' : 'Default',
'suggestions_func' : get_style_suggestions,
'editor_icon' : ["PopupMenu", "EditorIcons"],
'autofocus' : true})
func get_style_suggestions(_filter := "") -> Dictionary:
var styles: Array = ProjectSettings.get_setting('dialogic/layout/style_list', [])
var suggestions := {}
suggestions['<Default Style>'] = {'value':'', 'editor_icon':["MenuBar", "EditorIcons"]}
for i in styles:
var style: DialogicStyle = load(i)
suggestions[style.name] = {'value': style.name, 'editor_icon': ["PopupMenu", "EditorIcons"]}
return suggestions

View File

@@ -0,0 +1 @@
uid://cqkdgqb73w58a

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cnpi18qcnme4i"
path="res://.godot/imported/icon.png-ee52cc92a2b11ac2a101ff92d2eaaa7c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Modules/Style/icon.png"
dest_files=["res://.godot/imported/icon.png-ee52cc92a2b11ac2a101ff92d2eaaa7c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,14 @@
@tool
extends DialogicIndexer
func _get_events() -> Array:
return [this_folder.path_join('event_style.gd')]
func _get_subsystems() -> Array:
return [{'name':'Styles', 'script':this_folder.path_join('subsystem_styles.gd')}]
func _get_character_editor_sections() -> Array:
return [this_folder.path_join('character_settings_style.tscn')]

View File

@@ -0,0 +1 @@
uid://h2xx37cxrk2m

View File

@@ -0,0 +1,13 @@
class_name DialogicNode_StyleLayer
extends Control
## Control node that is hidden and shown based on the current dialogic style.
## The name this layer listens to
@export var layer_name: String = 'Default'
func _ready() -> void:
if layer_name.is_empty():
layer_name = name
add_to_group('dialogic_style_layer')

View File

@@ -0,0 +1 @@
uid://bwwdb7bqqrrdv

View File

@@ -0,0 +1,175 @@
extends DialogicSubsystem
## Subsystem that manages loading layouts with specific styles applied.
signal style_changed(info:Dictionary)
#region STATE
####################################################################################################
func clear_game_state(_clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
pass
func load_game_state(load_flag := LoadFlags.FULL_LOAD) -> void:
if load_flag == LoadFlags.ONLY_DNODES:
return
load_style(dialogic.current_state_info.get('style', ''))
#endregion
#region MAIN METHODS
####################################################################################################
## This helper method calls load_style, but with the [parameter state_reload] as true,
## which is commonly wanted if you expect a game to already be in progress.
func change_style(style_name := "", is_base_style := true) -> Node:
return load_style(style_name, null, is_base_style, true)
## Loads a style. Consider using the simpler [method change_style] if you want to change the style while another style is already in use.
## [br] If [param state_reload] is true, the current state will be loaded into a new layout scenes nodes.
## That should not be done before calling start() or load() as it would be unnecessary or cause double-loading.
func load_style(style_name := "", parent: Node = null, is_base_style := true, state_reload := false) -> Node:
var style := DialogicUtil.get_style_by_name(style_name)
var signal_info := {'style':style_name}
dialogic.current_state_info['style'] = style_name
# is_base_style should only be wrong on temporary changes like character styles
if is_base_style:
dialogic.current_state_info['base_style'] = style_name
var previous_layout := get_layout_node()
if is_instance_valid(previous_layout) and previous_layout.has_meta('style'):
signal_info['previous'] = previous_layout.get_meta('style').name
# If this is the same style and scene, do nothing
if previous_layout.get_meta('style') == style:
return previous_layout
# If this has the same scene setup, just apply the new overrides
elif previous_layout.get_meta('style') == style.get_inheritance_root():
DialogicUtil.apply_scene_export_overrides(previous_layout, style.get_layer_inherited_info("").overrides)
var index := 0
for layer in previous_layout.get_layers():
DialogicUtil.apply_scene_export_overrides(
layer,
style.get_layer_inherited_info(style.get_layer_id_at_index(index)).overrides)
index += 1
previous_layout.set_meta('style', style)
style_changed.emit(signal_info)
return
else:
parent = previous_layout.get_parent()
previous_layout.get_parent().remove_child(previous_layout)
previous_layout.queue_free()
# if this is another style:
var new_layout := create_layout(style, parent)
if state_reload:
# Preserve process_mode on style changes
if previous_layout:
new_layout.process_mode = previous_layout.process_mode
new_layout.ready.connect(reload_current_info_into_new_style)
style_changed.emit(signal_info)
return new_layout
## Method that adds a layout scene with all the necessary layers.
## The layout scene will be added to the tree root and returned.
func create_layout(style: DialogicStyle, parent: Node = null) -> DialogicLayoutBase:
# Load base scene
var base_scene: DialogicLayoutBase
var base_layer_info := style.get_layer_inherited_info("")
if base_layer_info.path.is_empty():
base_scene = DialogicUtil.get_default_layout_base().instantiate()
else:
base_scene = load(base_layer_info.path).instantiate()
base_scene.name = "DialogicLayout_"+style.name.to_pascal_case()
# Apply base scene overrides
DialogicUtil.apply_scene_export_overrides(base_scene, base_layer_info.overrides)
# Load layers
for layer_id in style.get_layer_inherited_list():
var layer := style.get_layer_inherited_info(layer_id)
if not ResourceLoader.exists(layer.path):
continue
var layer_scene: DialogicLayoutLayer = null
if ResourceLoader.load_threaded_get_status(layer.path) == ResourceLoader.THREAD_LOAD_LOADED:
layer_scene = ResourceLoader.load_threaded_get(layer.path).instantiate()
else:
layer_scene = load(layer.path).instantiate()
base_scene.add_layer(layer_scene)
# Apply layer overrides
DialogicUtil.apply_scene_export_overrides(layer_scene, layer.overrides)
base_scene.set_meta('style', style)
if parent == null:
parent = dialogic.get_parent()
parent.call_deferred("add_child", base_scene)
dialogic.get_tree().set_meta('dialogic_layout_node', base_scene)
return base_scene
## When changing to a different layout scene,
## we have to load all the info from the current_state_info (basically
func reload_current_info_into_new_style() -> void:
for subsystem in dialogic.get_children():
subsystem.load_game_state(LoadFlags.ONLY_DNODES)
## Returns the style currently in use
func get_current_style() -> String:
if has_active_layout_node():
var style: DialogicStyle = get_layout_node().get_meta('style', null)
if style:
return style.name
return ''
func has_active_layout_node() -> bool:
return (
get_tree().has_meta('dialogic_layout_node')
and is_instance_valid(get_tree().get_meta('dialogic_layout_node'))
and not get_tree().get_meta('dialogic_layout_node').is_queued_for_deletion()
)
func get_layout_node() -> DialogicLayoutBase:
if has_active_layout_node():
return get_tree().get_meta('dialogic_layout_node')
return null
## Similar to get_tree().get_first_node_in_group('group_name') but filtered to the active layout node subtree
func get_first_node_in_layout(group_name: String) -> Node:
var layout_node := get_layout_node()
if null == layout_node:
return null
var nodes := get_tree().get_nodes_in_group(group_name)
for node in nodes:
if layout_node.is_ancestor_of(node):
return node
return null
#endregion

View File

@@ -0,0 +1 @@
uid://brdi5knpa43hi