Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Jowan-Spooner committed May 26, 2024
2 parents 6a0404a + 43f9b54 commit 8ef636d
Show file tree
Hide file tree
Showing 141 changed files with 3,087 additions and 1,550 deletions.
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
blank_issues_enabled: true
contact_links:
- name: Dialogic 1 Repository
url: https://github.com/dialogic-godot/dialogic-1/issues
about: Please post anything related to Dialogc 1.x (Godot 3.x) on the Dialogic 1 Repository!

14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img width="1280" alt="cover" src="https://user-images.githubusercontent.com/2206700/189457799-6327bab0-b085-4421-8640-6a18e395d17d.png">
</p>

<h1 align="center">Dialogic</h1>
<h1 align="center">Dialogic 2</h1>

<p align="center">
Create <b>Dialogs</b>, <b>Visual Novels</b>, <b>RPGs</b>, and <b>manage Characters</b> with Godot to create your Game!
Expand All @@ -12,8 +12,8 @@
<a href="https://discord.gg/DjcDgDaTMe" target="_blank" style="text-decoration:none"><img alt="Discord" src="https://img.shields.io/discord/628713677239091231?logo=discord&labelColor=CFC9C8&color=646FA9"></a>
<a href="https://godotengine.org/download/" target="_blank" style="text-decoration:none"><img alt="Godot v4.2+" src="https://img.shields.io/badge/Godot-v4.2+-%23478cbf?labelColor=CFC9C8&color=49A9B4" /></a>
<a href="https://docs.dialogic.pro/introduction.html" target="_blank" style="text-decoration:none"><img alt="Dialogic 2 Documentation" src="https://img.shields.io/badge/documention-online-green?labelColor=CFC9C8&color=6BCD69"></a>
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/dialogic-godot/dialogic/unit_test.yml?labelColor=CFC9C8&color=DBDCB8">
<img alt="Latest Dialogic Release" src="https://img.shields.io/github/v/release/dialogic-godot/dialogic?include_prereleases&labelColor=CFC9C8&color=CBA18C">
<a href="https://github.com/dialogic-godot/dialogic/actions/workflows/unit_test.yml" target="_blank style="text-decoration:none"><img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/dialogic-godot/dialogic/unit_test.yml?labelColor=CFC9C8&color=DBDCB8"></a>
<a href="https://github.com/dialogic-godot/dialogic/releases" target="_blank" style="text-decoration:none"><img alt="Latest Dialogic Release" src="https://img.shields.io/github/v/release/dialogic-godot/dialogic?include_prereleases&labelColor=CFC9C8&color=CBA18C"></a>
</p>

## Table of Contents
Expand All @@ -28,9 +28,7 @@

Dialogic 2 **requires at least Godot 4.2**.

It's a major rewrite compared to the previous Dialogic 1.

[If you are looking for the Godot 3.5 version you can find it here.](https://github.com/dialogic-godot/dialogic/tree/dialogic-1)
[If you are looking for the Godot 3.x version (Dialogic 1.x) you can find it here.](https://github.com/dialogic-godot/dialogic-1)

## Installation
Follow the installation instructions on our [Getting Started](https://docs.dialogic.pro/getting-started.html#1-installation--activation) documentation.
Expand All @@ -51,7 +49,7 @@ If you need help or want to share your Dialogic projects, take a look at the fol
- Ask questions on [GitHub Discussions](https://github.com/dialogic-godot/dialogic/discussions)

## Testing
Dialogic uses [Unit Tests](https://en.wikipedia.org/wiki/Unit_testing) to ensure specific parts function as expected. These tests run on every git push and pull request. The framework to do these tests is called [gdUnit4](https://github.com/MikeSchulze/gdUnit4) and our tests reside in the [addons/dialogic/Tests/Unit](https://github.com/dialogic-godot/dialogic/tree/main/addons/dialogic/Tests/Unit) path. We recommend installing the `gdUnit4` add-on from the `AssetLib`, with this add-on, you can run tests locally.
Dialogic uses [Unit Tests](https://en.wikipedia.org/wiki/Unit_testing) to ensure specific parts function as expected. These tests run on every git push and pull request. The framework to do these tests is called [gdUnit4](https://github.com/MikeSchulze/gdUnit4) and our tests reside in the [/Tests/Unit](https://github.com/dialogic-godot/dialogic/tree/main/Tests/Unit) path. We recommend installing the `gdUnit4` add-on from the `AssetLib`, with this add-on, you can run tests locally.

To get started, take a look at the existing files in the path and read the documentation to [create your first test](https://mikeschulze.github.io/gdUnit4/first_steps/firstTest/).

Expand All @@ -70,7 +68,7 @@ Changelogs will accommodate for these changes and inform you on how to update yo
## Credits
Made by [Emilio Coppola](https://github.com/coppolaemilio) and [Jowan-Spooner](https://github.com/Jowan-Spooner).

Contributors: [zaknafean](https://github.com/zaknafean), [thebardsrc](https://github.com/thebardsrc), [and more!](https://github.com/dialogic-godot/dialogic/graphs/contributors).
Contributors: [CakeVR](https://github.com/CakeVR), [Exelia](https://github.com/exelia-antonov), [zaknafean](https://github.com/zaknafean), [and more!](https://github.com/dialogic-godot/dialogic/graphs/contributors).

Special thanks: [Arnaud](https://github.com/arnaudvergnet), [AnidemDex](https://github.com/AnidemDex), [ellogwen](https://github.com/ellogwen), [Tim Krief](https://github.com/timkrief), [Toen](https://twitter.com/ToenAndreMC), Òscar, [Francisco Presencia](https://francisco.io/), [M7mdKady14](https://github.com/M7mdKady14).

Expand Down
40 changes: 40 additions & 0 deletions Tests/Unit/guess_special_resource_test.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
extends GdUnitTestSuite

## Check if transition animations can be accessed with "in", "out, "in out"
## 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 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.")

var are_all_fade_in_equal := fade_in_1 == fade_in_2 and fade_in_2 == fade_in_3
assert(are_all_fade_in_equal == true, "Fade In/Out animations returned different paths.")


## 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", "")
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", "")
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", "")
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", "")
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.")

88 changes: 55 additions & 33 deletions addons/dialogic/Core/DialogicGameHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,64 +22,77 @@ enum States {
enum ClearFlags {
FULL_CLEAR = 0, ## Clears all subsystems
KEEP_VARIABLES = 1, ## Clears all subsystems and info except for variables
TIMLEINE_INFO_ONLY = 2 ## Doesn't clear subsystems but current timeline and index
TIMELINE_INFO_ONLY = 2 ## Doesn't clear subsystems but current timeline and index
}

## Reference to the currently executed timeline.
var current_timeline: DialogicTimeline = null
## Copy of the [member current_timeline]'s events.
var current_timeline_events: Array = []

## Index of the event the timeline handeling is currently at.
## Index of the event the timeline handling is currently at.
var current_event_idx: int = 0
## Contains all information that subsystems consider
## relevant for the current situation
## Contains all information that subsystems consider relevant for
## the current situation
var current_state_info: Dictionary = {}
## Current state (see [member States] enum)

## Current state (see [member States] enum).
var current_state := States.IDLE:
get:
return current_state

set(new_state):
current_state = new_state
emit_signal('state_changed', new_state)
state_changed.emit(new_state)

## Emitted when [member current_state] change.
signal state_changed(new_state:States)

## When `true`, many dialogic processes won't continue until it's false again.
## When `true`, many dialogic processes won't continue until it's `false` again.
var paused := false:
set(value):
paused = value

if paused:

for subsystem in get_children():

if subsystem is DialogicSubsystem:
(subsystem as DialogicSubsystem).pause()

dialogic_paused.emit()

else:
for subsystem in get_children():

if subsystem is DialogicSubsystem:
(subsystem as DialogicSubsystem).resume()

dialogic_resumed.emit()

## Emitted when [member paused] changes to true.
## Emitted when [member paused] changes to `true`.
signal dialogic_paused
## Emitted when [member paused] changes to false.
## Emitted when [member paused] changes to `false`.
signal dialogic_resumed


## Emitted when dialog ends (by a timeline end being reached OR end_timeline() being called).
## Emitted when the timeline ends.
## This can be a timeline ending or [method end_timeline] being called.
signal timeline_ended
## Emitted when a timeline was started with [method start] or [method start_timeline].
## Emitted when a timeline starts by calling either [method start]
## or [method start_timeline].
signal timeline_started
## Emitted when an event has just been executed (not necessarily when the event finished).
signal event_handled(resource:DialogicEvent)
## Emitted when an event starts being executed.
## The event may not have finished executing yet.
signal event_handled(resource: DialogicEvent)

## Emitted when the `Signal Event` was reached
signal signal_event(argument:Variant)
## Emitted when `[signal]` effect was reached in text.
signal text_signal(argument:String)
## Emitted when a [class SignalEvent] event was reached.
signal signal_event(argument: Variant)
## Emitted when a signal event gets fired from a [class TextEvent] event.
signal text_signal(argument: String)


# Careful, this section is repopulated automatically at certain moments
# Careful, this section is repopulated automatically at certain moments.
#region SUBSYSTEMS

var Audio := preload("res://addons/dialogic/Modules/Audio/subsystem_audio.gd").new():
Expand Down Expand Up @@ -168,6 +181,7 @@ func start(timeline:Variant, label:Variant="") -> Node:
scene = self.Styles.load_style()
else:
scene = self.Styles.get_layout_node()
scene.show()

if not scene.is_node_ready():
scene.ready.connect(clear.bind(ClearFlags.KEEP_VARIABLES))
Expand Down Expand Up @@ -222,21 +236,21 @@ func preload_timeline(timeline_resource:Variant) -> Variant:
if timeline_resource == null:
printerr("[Dialogic] There was an error preloading this timeline. Check the filename, and the timeline for errors")
return null
else:
await (timeline_resource as DialogicTimeline).process()
return timeline_resource

await (timeline_resource as DialogicTimeline).process()

return timeline_resource


## Clears and stops the current timeline.
func end_timeline() -> void:
clear(ClearFlags.TIMLEINE_INFO_ONLY)
await clear(ClearFlags.TIMELINE_INFO_ONLY)
_on_timeline_ended()
timeline_ended.emit()


## Handles the next event.
func handle_next_event(ignore_argument:Variant = "") -> void:
func handle_next_event(_ignore_argument: Variant = "") -> void:
handle_event(current_event_idx+1)


Expand Down Expand Up @@ -272,25 +286,26 @@ func handle_event(event_index:int) -> void:
event_handled.emit(current_timeline_events[event_index])


## Resets dialogics state fully or partially.
## By using the clear flags from the [member ClearFlags] enum you can specify what info should be kept.
## For example at timeline end usually it doesn't clear node or subsystem info
func clear(clear_flags:=ClearFlags.FULL_CLEAR) -> bool:

if !clear_flags & ClearFlags.TIMLEINE_INFO_ONLY:
## Resets Dialogic's state fully or partially.
## By using the clear flags from the [member ClearFlags] enum you can specify
## what info should be kept.
## For example, at timeline end usually it doesn't clear node or subsystem info.
func clear(clear_flags := ClearFlags.FULL_CLEAR) -> void:
if !clear_flags & ClearFlags.TIMELINE_INFO_ONLY:
for subsystem in get_children():
if subsystem is DialogicSubsystem:
(subsystem as DialogicSubsystem).clear_game_state(clear_flags)

# Resetting variables
if current_timeline:
current_timeline.clean()
var timeline := current_timeline

current_timeline = null
current_event_idx = -1
current_timeline_events = []
current_state = States.IDLE
return true

# Resetting variables
if timeline:
await timeline.clean()

#endregion

Expand Down Expand Up @@ -395,4 +410,11 @@ func _on_timeline_ended() -> void:
@warning_ignore("unsafe_method_access")
self.Styles.get_layout_node().hide()


func print_debug_moment() -> void:
if not current_timeline:
return

printerr("\tAt event ", current_event_idx+1, " (",current_timeline_events[current_event_idx].event_name, ' Event) in timeline "', DialogicResourceUtil.get_unique_identifier(current_timeline.resource_path), '" (',current_timeline.resource_path,').')
print("\n")
#endregion
26 changes: 22 additions & 4 deletions addons/dialogic/Core/DialogicResourceUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static func update_event_cache() -> Array:
for indexer in DialogicUtil.get_indexers():
# build event cache
for event in indexer._get_events():
if not FileAccess.file_exists(event):
if not ResourceLoader.exists(event):
continue
if not 'event_end_branch.gd' in event and not 'event_text.gd' in event:
event_cache.append(load(event).new())
Expand Down Expand Up @@ -184,14 +184,32 @@ static func list_special_resources_of_type(type:String) -> Array:
return special_resources.filter(func(x:Dictionary): return type == x.get('type','')).map(func(x:Dictionary): return x.get('path', ''))


static func guess_special_resource(type:String, name:String, default:="") -> String:
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 in list_special_resources_of_type(type):
if DialogicUtil.pretty_name(path).to_lower() == name.to_lower():

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

return default

#endregion
Expand Down
Loading

0 comments on commit 8ef636d

Please sign in to comment.