Skip to content

Commit

Permalink
Merge to fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jowan-Spooner committed Jul 26, 2024
2 parents 224d8e9 + 7f1b837 commit 5673960
Show file tree
Hide file tree
Showing 208 changed files with 3,795 additions and 1,985 deletions.
6 changes: 3 additions & 3 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# These are supported funding model platforms

github: coppolaemilio
patreon: coppolaemilio
github: jowan-spooner
patreon: jowanspooner
open_collective: # Replace with a single Open Collective username
ko_fi: coppolaemilio
ko_fi: jowan_spooner
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ If applicable, add screenshots to help explain your problem.

**System (please complete the following information):**
- OS: [e.g. Windows, Linux]
- Godot Version: [e.g. 3.2.3]
- Dialogic Version: [e.g. 1.0]
- Godot Version: [e.g. 4.2.2]
- Dialogic Version: [e.g. 2.0 Alpha 14, please be specific!]

## Solutions

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 - 2023 Emilio Coppola
Copyright (c) 2020 - present Emilio Coppola

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions Tests/Unit/guess_special_resource_test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ extends GdUnitTestSuite
## as space-delimited prefix.
func test_fade_in_animation_paths() -> void:
const TYPE := "PortraitAnimation"
var fade_in_1 := DialogicResourceUtil.guess_special_resource(TYPE, "fade in", "")
var fade_in_2 := DialogicResourceUtil.guess_special_resource(TYPE, "fade in out", "")
var fade_in_3 := DialogicResourceUtil.guess_special_resource(TYPE, "fade out", "")
var fade_in_1: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade in").get('path', "")
var fade_in_2: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade cross").get('path', "")
var fade_in_3: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade out").get('path', "")

var is_any_fade_in_empty := fade_in_1.is_empty() or fade_in_2.is_empty() or fade_in_3.is_empty()
assert(is_any_fade_in_empty == false, "Fade In/Out animations are empty.")
Expand All @@ -18,22 +18,22 @@ func test_fade_in_animation_paths() -> void:
## Test if invalid animation paths will return empty strings.
func test_invalid_animation_path() -> void:
const TYPE := "PortraitAnimation"
var invalid_animation_1 := DialogicResourceUtil.guess_special_resource(TYPE, "fade i", "")
var invalid_animation_1: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade i").get('path', "")
assert(invalid_animation_1.is_empty() == true, "Invalid animation 1's path is not empty.")


var invalid_animation_2 := DialogicResourceUtil.guess_special_resource(TYPE, "fade", "")
var invalid_animation_2: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade").get('path', "")
assert(invalid_animation_2.is_empty() == true, "Invalid animation 2's path is not empty.")


## Test if invalid types will return empty strings.
func test_invalid_type_path() -> void:
const INVALID_TYPE := "Portait Animation"
var invalid_animation := DialogicResourceUtil.guess_special_resource(INVALID_TYPE, "fade in", "")
var invalid_animation: String = DialogicResourceUtil.guess_special_resource(INVALID_TYPE, "fade in").get('path', "")
assert(invalid_animation.is_empty() == true, "Invalid animation 1's path is not empty.")

const VALID_TYPE := "PortraitAnimation"
var valid_animation_path := DialogicResourceUtil.guess_special_resource(VALID_TYPE, "fade in", "")
var valid_animation_path: String = DialogicResourceUtil.guess_special_resource(VALID_TYPE, "fade in").get('path', "")
assert(valid_animation_path.is_empty() == false, "Valids animation's path is empty.")

assert(not invalid_animation == valid_animation_path, "Valid and invalid animation paths are equal.")
Expand Down
9 changes: 7 additions & 2 deletions addons/dialogic/Core/DialogicGameHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ var Backgrounds := preload("res://addons/dialogic/Modules/Background/subsystem_b
var Portraits := preload("res://addons/dialogic/Modules/Character/subsystem_portraits.gd").new():
get: return get_subsystem("Portraits")

var PortraitContainers := preload("res://addons/dialogic/Modules/Character/subsystem_containers.gd").new():
get: return get_subsystem("PortraitContainers")

var Choices := preload("res://addons/dialogic/Modules/Choice/subsystem_choices.gd").new():
get: return get_subsystem("Choices")

Expand Down Expand Up @@ -166,7 +169,7 @@ func _ready() -> void:
## -> returns the layout node
func start(timeline:Variant, label:Variant="") -> Node:
# If we don't have a style subsystem, default to just start_timeline()
if !has_subsystem('Styles'):
if not has_subsystem('Styles'):
printerr("[Dialogic] You called Dialogic.start() but the Styles subsystem is missing!")
clear(ClearFlags.KEEP_VARIABLES)
start_timeline(timeline, label)
Expand All @@ -184,7 +187,6 @@ func start(timeline:Variant, label:Variant="") -> Node:
scene.ready.connect(clear.bind(ClearFlags.KEEP_VARIABLES))
scene.ready.connect(start_timeline.bind(timeline, label))
else:
clear(ClearFlags.KEEP_VARIABLES)
start_timeline(timeline, label)

return scene
Expand Down Expand Up @@ -321,6 +323,9 @@ func get_full_state() -> Dictionary:
current_state_info['current_event_idx'] = -1
current_state_info['current_timeline'] = null

for subsystem in get_children():
(subsystem as DialogicSubsystem).save_game_state()

return current_state_info.duplicate(true)


Expand Down
95 changes: 65 additions & 30 deletions addons/dialogic/Core/DialogicResourceUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class_name DialogicResourceUtil
static var label_cache := {}
static var event_cache: Array[DialogicEvent] = []

static var special_resources : Array[Dictionary] = []
static var special_resources := {}


static func update() -> void:
Expand Down Expand Up @@ -173,43 +173,78 @@ static func update_event_cache() -> Array:
################################################################################

static func update_special_resources() -> void:
special_resources = []
special_resources.clear()
for indexer in DialogicUtil.get_indexers():
special_resources.append_array(indexer._get_special_resources())
var additions := indexer._get_special_resources()
for resource_type in additions:
if not resource_type in special_resources:
special_resources[resource_type] = {}
special_resources[resource_type].merge(additions[resource_type])


static func list_special_resources_of_type(type:String) -> Array:
static func list_special_resources(type:String, filter := {}) -> Dictionary:
if special_resources.is_empty():
update_special_resources()
return special_resources.filter(func(x:Dictionary): return type == x.get('type','')).map(func(x:Dictionary): return x.get('path', ''))
if type in special_resources:
if filter.is_empty():
return special_resources[type]
else:
var results := {}
for i in special_resources[type]:
if match_resource_filter(special_resources[type][i], filter):
results[i] = special_resources[type][i]
return results
return {}


static func match_resource_filter(dict:Dictionary, filter:Dictionary) -> bool:
for i in filter:
if not i in dict:
return false
if typeof(filter[i]) == TYPE_ARRAY:
if not dict[i] in filter[i]:
return false
else:
if not dict[i] == filter[i]:
return false
return true


static func guess_special_resource(type: String, string: String, default := {}, filter := {}, ignores:PackedStringArray=[]) -> Dictionary:
if string.is_empty():
return default


static func guess_special_resource(type: String, name: String, default := "") -> String:
if special_resources.is_empty():
update_special_resources()

if name.begins_with('res://'):
return name

for path: String in list_special_resources_of_type(type):
var pretty_path := DialogicUtil.pretty_name(path).to_lower()
var pretty_name := name.to_lower()

if pretty_path == pretty_name:
return path

elif pretty_name.ends_with(" in"):
pretty_name = pretty_name + " out"

if pretty_path == pretty_name:
return path

elif pretty_name.ends_with(" out"):
pretty_name = pretty_name.replace("out", "in out")

if pretty_path == pretty_name:
return path

var resources := list_special_resources(type, filter)
if resources.is_empty():
printerr("[Dialogic] No ", type, "s found, but attempted to use one.")
return default

if string.begins_with('res://'):
for i in resources.values():
if i.path == string:
return i
printerr("[Dialogic] Unable to find ", type, " at path '", string, "'.")
return default

string = string.to_lower()

if string in resources:
return resources[string]

if not ignores.is_empty():
var regex := RegEx.create_from_string(r" ?\b(" + "|".join(ignores) + r")\b")
for name in resources:
if regex.sub(name, "") == regex.sub(string, ""):
return resources[name]

## As a last effort check against the unfiltered list
if string in special_resources[type]:
push_warning("[Dialogic] Using ", type, " '", string,"' when not supposed to.")
return special_resources[type][string]

printerr("[Dialogic] Unable to identify ", type, " based on string '", string, "'.")
return default

#endregion
Expand Down
Loading

0 comments on commit 5673960

Please sign in to comment.