diff --git a/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd b/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd index be7a9bbe..858cf183 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd @@ -63,7 +63,10 @@ func run(command_params: Array) -> int: escoria.event_manager.interrupt_running_event() if !command_params[1]: - escoria.main.scene_transition.transition_out() + escoria.main.scene_transition.transition( + "", + ESCTransitionPlayer.TRANSITION_MODE.OUT + ) yield(escoria.main.scene_transition, "transition_done") escoria.inputs_manager.clear_stack() @@ -109,7 +112,7 @@ func run(command_params: Array) -> int: return rc[0] if !command_params[1]: - escoria.main.scene_transition.transition_in() + escoria.main.scene_transition.transition() yield(escoria.main.scene_transition, "transition_done") if script.events.has("ready"): @@ -122,7 +125,7 @@ func run(command_params: Array) -> int: else: if !command_params[1]: - escoria.main.scene_transition.transition_in() + escoria.main.scene_transition.transition() yield(escoria.main.scene_transition, "transition_done") # Clear queued resources diff --git a/addons/escoria-core/game/core-scripts/esc/commands/transition.gd b/addons/escoria-core/game/core-scripts/esc/commands/transition.gd index fcb24952..7b7b78f9 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/transition.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/transition.gd @@ -1,7 +1,13 @@ -# `transition transition_name in|out` +# `transition transition_name in|out [delay]` # # Performs a transition in our out manually. # +# Parameters: +# - transition_name: Name of the transition shader from one of the transition +# directories +# - in|out: Wether to play the transition in IN- or OUT-mode +# - delay: Delay for the transition to take. Defaults to 1 second +# # @ESC extends ESCBaseCommand class_name TransitionCommand @@ -11,8 +17,8 @@ class_name TransitionCommand func configure() -> ESCCommandArgumentDescriptor: return ESCCommandArgumentDescriptor.new( 2, - [TYPE_STRING, TYPE_STRING], - [null, null] + [TYPE_STRING, TYPE_STRING, TYPE_REAL], + [null, null, 1.0] ) @@ -39,7 +45,14 @@ func validate(arguments: Array): # Run the command func run(command_params: Array) -> int: - var transition_player = escoria.main.scene_transition - transition_player.call("transition_%s" % command_params[1], command_params[0]) - var animation_finished = yield(transition_player, "transition_done") + escoria.main.scene_transition.transition( + command_params[0], + ESCTransitionPlayer.TRANSITION_MODE.OUT if command_params[1] == "out" \ + else ESCTransitionPlayer.TRANSITION_MODE.IN, + command_params[2] + ) + yield( + escoria.main.scene_transition, + "transition_done" + ) return ESCExecution.RC_OK diff --git a/addons/escoria-core/game/main.gd b/addons/escoria-core/game/main.gd index ede56dc8..5c1d0d01 100644 --- a/addons/escoria-core/game/main.gd +++ b/addons/escoria-core/game/main.gd @@ -18,11 +18,13 @@ var current_scene: Node var wait_level # Reference to the scene transition node -onready var scene_transition = $layers/curtain/scene_transition +onready var scene_transition: ESCTransitionPlayer # Connect the wait timer event func _ready() -> void: + scene_transition = ESCTransitionPlayer.new() + $layers/curtain.add_child(scene_transition) $layers/wait_timer.connect("timeout", self, "_on_wait_finished") diff --git a/addons/escoria-core/game/main.tscn b/addons/escoria-core/game/main.tscn index af90f8f9..1e6901ff 100644 --- a/addons/escoria-core/game/main.tscn +++ b/addons/escoria-core/game/main.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://addons/escoria-core/game/main.gd" type="Script" id=1] [ext_resource path="res://addons/escoria-core/game/scenes/esc_prompt/esc_prompt_popup.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_music_player.tscn" type="PackedScene" id=3] -[ext_resource path="res://addons/escoria-core/game/scenes/transitions/transition.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_sound_player.tscn" type="PackedScene" id=5] [ext_resource path="res://addons/escoria-core/game/scenes/sound/esc_speech_player.tscn" type="PackedScene" id=6] @@ -15,8 +14,6 @@ script = ExtResource( 1 ) [node name="curtain" type="CanvasLayer" parent="layers"] layer = 20 -[node name="scene_transition" parent="layers/curtain" instance=ExtResource( 4 )] - [node name="menu" type="CanvasLayer" parent="layers"] [node name="wait_timer" type="Timer" parent="layers"] diff --git a/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd b/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd new file mode 100644 index 00000000..5671e851 --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd @@ -0,0 +1,117 @@ +# A transition player for scene changes +extends ColorRect +class_name ESCTransitionPlayer + +# Emitted when the transition was played +signal transition_done + + +# The valid transition modes +enum TRANSITION_MODE { + IN, + OUT +} + + +# The tween instance to animate +var _tween: Tween + +# If the current tween was canceled +var _was_canceled: bool = false + + +# Fade in when the scene is starting +func _ready() -> void: + anchor_left = 0 + anchor_top = 0 + anchor_right = 1 + anchor_bottom = 1 + color = Color.white + mouse_filter = MOUSE_FILTER_IGNORE + _tween = Tween.new() + add_child(_tween) + _tween.connect("tween_all_completed", self, "_on_tween_completed") + + transition() + + +# Play a transition animation +# +# ## Parameters +# +# - transition_name: name of the transition to play (if empty string, uses +# the default transition) +# - mode: Mode to transition (in/out) +# - duration: The duration the transition should take +func transition( + transition_name: String = "", + mode: int = TRANSITION_MODE.IN, + duration: float = 1.0 +) -> void: + if not has_transition(transition_name): + escoria.logger.report_errors( + "transition: Transition %s not found" % transition_name, + [] + ) + + material = ResourceLoader.load(get_transition(transition_name)) + + var start = 0 + var end = 1 + + if mode == TRANSITION_MODE.OUT: + start = 1 + end = 0 + + if _tween.is_active(): + _was_canceled = true + _tween.stop_all() + _tween.remove_all() + + _tween.interpolate_property( + $".", + "material:shader_param/cutoff", + start, + end, + duration + ) + _was_canceled = false + _tween.start() + + + +# Returns the full path for a transition shader based on its name +# +# ## Parameters +# +# - name: The name of the transition to test +# +# *Returns* the full path to the shader or an empty string, if it can't be found +func get_transition(name: String) -> String: + if name.empty(): + name = ProjectSettings.get_setting( + "escoria/ui/default_transition" + ) + for directory in ProjectSettings.get_setting("escoria/ui/transition_paths"): + if ResourceLoader.exists(directory.plus_file("%s.material" % name)): + return directory.plus_file("%s.material" % name) + return "" + + +# Returns true whether the transition scene has a transition corresponding +# to name provided. +# +# ## Parameters +# +# - name: The name of the transition to test +# +# *Returns* true if a transition exists with given name. +func has_transition(name: String) -> bool: + return not get_transition(name) == "" + + +func _on_tween_completed(): + if not _was_canceled: + emit_signal("transition_done") + _tween.stop_all() + _tween.remove_all() diff --git a/addons/escoria-core/game/scenes/transitions/shaders/curtain.material b/addons/escoria-core/game/scenes/transitions/shaders/curtain.material new file mode 100644 index 00000000..b1fab907 Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/shaders/curtain.material differ diff --git a/addons/escoria-core/game/scenes/transitions/shaders/fade_black.material b/addons/escoria-core/game/scenes/transitions/shaders/fade_black.material new file mode 100644 index 00000000..92721d20 Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/shaders/fade_black.material differ diff --git a/addons/escoria-core/game/scenes/transitions/shaders/fade_white.material b/addons/escoria-core/game/scenes/transitions/shaders/fade_white.material new file mode 100644 index 00000000..973fdfbe Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/shaders/fade_white.material differ diff --git a/addons/escoria-core/game/scenes/transitions/shaders/from_center.material b/addons/escoria-core/game/scenes/transitions/shaders/from_center.material new file mode 100644 index 00000000..54b509ad Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/shaders/from_center.material differ diff --git a/addons/escoria-core/game/scenes/transitions/shaders/shards.material b/addons/escoria-core/game/scenes/transitions/shaders/shards.material new file mode 100644 index 00000000..ef86a67a Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/shaders/shards.material differ diff --git a/addons/escoria-core/game/scenes/transitions/shaders/transition.material b/addons/escoria-core/game/scenes/transitions/shaders/transition.material deleted file mode 100644 index c730e79a..00000000 Binary files a/addons/escoria-core/game/scenes/transitions/shaders/transition.material and /dev/null differ diff --git a/addons/escoria-core/game/scenes/transitions/transition.gd b/addons/escoria-core/game/scenes/transitions/transition.gd deleted file mode 100644 index cc6d0a59..00000000 --- a/addons/escoria-core/game/scenes/transitions/transition.gd +++ /dev/null @@ -1,68 +0,0 @@ -# A transition player for scene changes -extends ColorRect - -# Emitted when the transition was played -signal transition_done - - -# The name of the default transition to play -export( - String, - "fade_black", - "fade_white", - "curtain" -) var transition_name: String - - - -# Reference to the _AnimationPlayer_ node -onready var _anim_player := $AnimationPlayer - - -# Fade in when the scene is starting -func _ready() -> void: - transition_in() - - -# Transition out -# -# ## Parameters -# -# - p_transition_name: name of the transition to play (if empty string, uses -# the default transition) -func transition_out(p_transition_name: String = "") -> void: - if p_transition_name.empty(): - _anim_player.play_backwards(transition_name) - else: - _anim_player.play_backwards(p_transition_name) - yield(_anim_player, "animation_finished") - emit_signal("transition_done") - _anim_player.seek(0.0) - - -# Transition in -# -# ## Parameters -# -# - p_transition_name: name of the transition to play (if empty string, uses -# the default transition) -func transition_in(p_transition_name: String = "") -> void: - if p_transition_name.empty(): - _anim_player.play(transition_name) - else: - _anim_player.play(p_transition_name) - yield(_anim_player, "animation_finished") - emit_signal("transition_done") - _anim_player.seek(0.0) - - -# Returns true whether the transition scene has a transition corresponding -# to name provided. -# -# ## Parameters -# -# - p_name: The name of the transition to test -# -# *Returns* true if a transition exists with given name. -func has_transition(p_name: String) -> bool: - return _anim_player.has_animation(p_name) diff --git a/addons/escoria-core/game/scenes/transitions/transition.tscn b/addons/escoria-core/game/scenes/transitions/transition.tscn index 95d3eb11..4ba2bd7e 100644 --- a/addons/escoria-core/game/scenes/transitions/transition.tscn +++ b/addons/escoria-core/game/scenes/transitions/transition.tscn @@ -1,124 +1,7 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://addons/escoria-core/game/scenes/transitions/transition.gd" type="Script" id=1] -[ext_resource path="res://addons/escoria-core/game/scenes/transitions/shaders/transition.material" type="Material" id=2] - -[sub_resource type="Animation" id=1] -resource_name = "curtain" -tracks/0/type = "value" -tracks/0/path = NodePath(".:material:shader_param/cutoff") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 1 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ 0.0, 1.0 ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/color") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Color( 0, 0, 0, 1 ) ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:modulate") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] -} - -[sub_resource type="Animation" id=2] -length = 0.5 -tracks/0/type = "value" -tracks/0/path = NodePath(".:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 0.5 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ Color( 0, 0, 0, 0 ), Color( 0, 0, 0, 1 ) ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/cutoff") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 0.0 ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:material:shader_param/color") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Color( 0, 0, 0, 1 ) ] -} - -[sub_resource type="Animation" id=3] -length = 0.5 -tracks/0/type = "value" -tracks/0/path = NodePath(".:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 0.5 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] -} -tracks/1/type = "value" -tracks/1/path = NodePath(".:material:shader_param/cutoff") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ 0.0 ] -} -tracks/2/type = "value" -tracks/2/path = NodePath(".:material:shader_param/color") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 1 ) ] -} +[ext_resource path="res://addons/escoria-core/game/scenes/transitions/esc_transition_player.gd" type="Script" id=1] +[ext_resource path="res://addons/escoria-core/game/scenes/transitions/shaders/curtain.material" type="Material" id=2] [node name="scene_transition" type="ColorRect"] material = ExtResource( 2 ) @@ -129,9 +12,5 @@ script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } -transition_name = "curtain" -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] -anims/curtain = SubResource( 1 ) -anims/fade_black = SubResource( 2 ) -anims/fade_white = SubResource( 3 ) +[node name="Tween" type="Tween" parent="."] diff --git a/addons/escoria-core/plugin.gd b/addons/escoria-core/plugin.gd index db92b3af..6a7de0b7 100644 --- a/addons/escoria-core/plugin.gd +++ b/addons/escoria-core/plugin.gd @@ -92,6 +92,29 @@ func set_escoria_ui_settings(): } ProjectSettings.add_property_info(game_scene_property_info) + if !ProjectSettings.has_setting("escoria/ui/default_transition"): + ProjectSettings.set_setting( + "escoria/ui/default_transition", + "curtain" + ) + ProjectSettings.add_property_info({ + "name": "escoria/ui/default_transition", + "type": TYPE_STRING + }) + + if !ProjectSettings.has_setting("escoria/ui/transition_paths"): + ProjectSettings.set_setting( + "escoria/ui/transition_paths", + [ + "res://addons/escoria-core/game/scenes/transitions/shaders/" + ] + ) + ProjectSettings.add_property_info({ + "name": "escoria/ui/transition_paths", + "type": TYPE_STRING_ARRAY, + "hint": PROPERTY_HINT_DIR + }) + # Prepare the settings in the Escoria main category func set_escoria_main_settings(): diff --git a/docs/api/ESCItem.md b/docs/api/ESCItem.md index 6a1b6883..a344d363 100644 --- a/docs/api/ESCItem.md +++ b/docs/api/ESCItem.md @@ -349,7 +349,7 @@ Return the sprite node ### set\_angle ```gdscript -func set_angle(deg: int, immediate = true) +func set_angle(deg: int, wait: float = 0) ``` Set the angle @@ -357,13 +357,12 @@ Set the angle #### Parameters - deg: The angle degree to set -- immediate: Set the angle immediately. If false will show intermediate - angles +- wait: Wait this amount of seconds until continuing with turning around ### turn\_to ```gdscript -func turn_to(object: Node, immediate = true) +func turn_to(object: Node, wait: float = 0) ``` Turn to face another object @@ -371,8 +370,7 @@ Turn to face another object #### Parameters - deg: The angle degree to set -- immediate: Set the angle immediately. If false will show intermediate - angles +- float Wait this amount of seconds until continuing with turning around ### start\_talking diff --git a/docs/api/ESCMovable.md b/docs/api/ESCMovable.md index 5cf7de79..57434ab1 100644 --- a/docs/api/ESCMovable.md +++ b/docs/api/ESCMovable.md @@ -170,7 +170,7 @@ Update the sprite scale and lighting ### set\_angle ```gdscript -func set_angle(deg: int, immediate = true) -> var +func set_angle(deg: int, wait: float = 0) -> var ``` Sets character's angle and plays according animation. @@ -178,14 +178,12 @@ Sets character's angle and plays according animation. #### Parameters - deg int angle to set the character -- immediate - If true, direction is switched immediately. Else, successive - animations are used so that the character turns to target angle. +- wait float Wait this amount of seconds until continuing with turning around ### turn\_to ```gdscript -func turn_to(item: Node, immediate = true) -> void +func turn_to(item: Node, wait: float = 0) -> void ``` Turns the character to face another item or character. @@ -193,9 +191,7 @@ Turns the character to face another item or character. #### Parameters - item_id id of the object to face. -- immediate - If true, direction is switched immediately. Else, successive - animations are used so that the character turns to target angle. +- float Wait this amount of seconds until continuing with turning around ### get\_shortest\_way\_to\_dir diff --git a/docs/api/ESCTransitionPlayer.md b/docs/api/ESCTransitionPlayer.md new file mode 100644 index 00000000..c5a9806d --- /dev/null +++ b/docs/api/ESCTransitionPlayer.md @@ -0,0 +1,60 @@ + + +# ESCTransitionPlayer + +**Extends:** [ColorRect](../ColorRect) + +## Description + +A transition player for scene changes + +## Enumerations + +### TRANSITION\_MODE + +```gdscript +const TRANSITION_MODE: Dictionary = {"IN":0,"OUT":1} +``` + +The valid transition modes + +## Method Descriptions + +### transition + +```gdscript +func transition(transition_name: String = "", mode: int, duration: float = 1) -> void +``` + +### get\_transition + +```gdscript +func get_transition(name: String) -> String +``` + +Returns the full path for a transition shader based on its name + +## Parameters + +- name: The name of the transition to test + +*Returns* the full path to the shader or an empty string, if it can't be found + +### has\_transition + +```gdscript +func has_transition(name: String) -> bool +``` + +Returns true whether the transition scene has a transition corresponding +to name provided. + +## Parameters + +- name: The name of the transition to test + +*Returns* true if a transition exists with given name. + +## Signals + +- signal transition_done(): Emitted when the transition was played diff --git a/docs/api/SetAngleCommand.md b/docs/api/SetAngleCommand.md index 9f23bdd3..82211321 100644 --- a/docs/api/SetAngleCommand.md +++ b/docs/api/SetAngleCommand.md @@ -6,7 +6,7 @@ ## Description -`set_angle object degrees [immediate]` +`set_angle object degrees [wait]` Turns object to a degrees angle without animations. 0 sets object facing forward, 90 sets it 90 degrees clockwise ("east") etc. When turning to the @@ -15,6 +15,9 @@ destination angle, animations are played if they're defined in animations. object must be player or interactive. degrees must be between [0, 360] or an error is reported. +The wait parameter sets how long to wait for each intermediate angle. It +defaults to 0, meaning the turnaround is immediate. + @ESC ## Method Descriptions diff --git a/docs/api/TransitionCommand.md b/docs/api/TransitionCommand.md index a425971a..720c7758 100644 --- a/docs/api/TransitionCommand.md +++ b/docs/api/TransitionCommand.md @@ -6,10 +6,16 @@ ## Description -`transition transition_name in|out` +`transition transition_name in|out [delay]` Performs a transition in our out manually. +Parameters: +- transition_name: Name of the transition shader from one of the transition + directories +- in|out: Wether to play the transition in IN- or OUT-mode +- delay: Delay for the transition to take. Defaults to 1 second + @ESC ## Method Descriptions diff --git a/docs/api/TurnToCommand.md b/docs/api/TurnToCommand.md index 4ef7c0ff..224eaf83 100644 --- a/docs/api/TurnToCommand.md +++ b/docs/api/TurnToCommand.md @@ -6,12 +6,12 @@ ## Description -`turn_to object object_to_face [immediate]` +`turn_to object object_to_face [wait]` Turns object to face another object. -Set immediate to true to show directly switch to the direction and not -show intermediate angles +The wait parameter sets how long to wait for each intermediate angle. It +defaults to 0, meaning the turnaround is immediate. @ESC diff --git a/docs/api/main.gd.md b/docs/api/main.gd.md index fb0efc89..bc0e6fc8 100644 --- a/docs/api/main.gd.md +++ b/docs/api/main.gd.md @@ -37,7 +37,7 @@ The Escoria context currently in wait state ### scene\_transition ```gdscript -var scene_transition +var scene_transition: ESCTransitionPlayer ``` Reference to the scene transition node diff --git a/docs/api/transition.gd.md b/docs/api/transition.gd.md deleted file mode 100644 index 71e9c5bd..00000000 --- a/docs/api/transition.gd.md +++ /dev/null @@ -1,64 +0,0 @@ - - -# transition.gd - -**Extends:** [ColorRect](../ColorRect) - -## Description - -A transition player for scene changes - -## Property Descriptions - -### transition\_name - -```gdscript -export var transition_name: String = "" -``` - -## Method Descriptions - -### transition\_out - -```gdscript -func transition_out(p_transition_name: String = "") -> var -``` - -Transition out - -## Parameters - -- p_transition_name: name of the transition to play (if empty string, uses -the default transition) - -### transition\_in - -```gdscript -func transition_in(p_transition_name: String = "") -> var -``` - -Transition in - -## Parameters - -- p_transition_name: name of the transition to play (if empty string, uses -the default transition) - -### has\_transition - -```gdscript -func has_transition(p_name: String) -> bool -``` - -Returns true whether the transition scene has a transition corresponding -to name provided. - -## Parameters - -- p_name: The name of the transition to test - -*Returns* true if a transition exists with given name. - -## Signals - -- signal transition_done(): Emitted when the transition was played diff --git a/docs/esc.md b/docs/esc.md index 0cd87620..84426e25 100644 --- a/docs/esc.md +++ b/docs/esc.md @@ -277,7 +277,7 @@ event ends. Changes the "active" state of the object, value can be true or false. Inactive objects are hidden in the scene. -#### `set_angle object degrees [immediate]` [API-Doc](api/SetAngleCommand.md) +#### `set_angle object degrees [wait]` [API-Doc](api/SetAngleCommand.md) Turns object to a degrees angle without animations. 0 sets object facing forward, 90 sets it 90 degrees clockwise ("east") etc. When turning to the @@ -285,6 +285,9 @@ destination angle, animations are played if they're defined in animations. object must be player or interactive. degrees must be between [0, 360] or an error is reported. + +The wait parameter sets how long to wait for each intermediate angle. It +defaults to 0, meaning the turnaround is immediate. #### `set_animations object animations` [API-Doc](api/SetAnimationsCommand.md) Set the animation resource for the given ESCPlayer @@ -348,15 +351,21 @@ Sets the position of object1 to the position of object2. #### `teleport_pos object1 x y` [API-Doc](api/TeleportPosCommand.md) Sets the position of object1 to the position (x,y). -#### `transition transition_name in|out` [API-Doc](api/TransitionCommand.md) +#### `transition transition_name in|out [delay]` [API-Doc](api/TransitionCommand.md) Performs a transition in our out manually. -#### `turn_to object object_to_face [immediate]` [API-Doc](api/TurnToCommand.md) + +Parameters: +- transition_name: Name of the transition shader from one of the transition + directories +- in|out: Wether to play the transition in IN- or OUT-mode +- delay: Delay for the transition to take. Defaults to 1 second +#### `turn_to object object_to_face [wait]` [API-Doc](api/TurnToCommand.md) Turns object to face another object. -Set immediate to true to show directly switch to the direction and not -show intermediate angles +The wait parameter sets how long to wait for each intermediate angle. It +defaults to 0, meaning the turnaround is immediate. #### `wait seconds` [API-Doc](api/WaitCommand.md) Blocks execution of the current script for a number of seconds specified by the "seconds" parameter. diff --git a/game/rooms/room02/room02.tscn b/game/rooms/room02/room02.tscn index 29337383..72305cad 100644 --- a/game/rooms/room02/room02.tscn +++ b/game/rooms/room02/room02.tscn @@ -90,6 +90,7 @@ position = Vector2( 958.107, 176.401 ) global_id = "r2_button_right" esc_script = "res://game/rooms/room02/esc/button.esc" dialog_color = Color( 0, 1, 0.109804, 1 ) +animations = null [node name="Position2D" type="Position2D" parent="button_right"] position = Vector2( 29.4302, 195.411 ) @@ -104,6 +105,7 @@ position = Vector2( 288.82, 171.439 ) global_id = "r2_button" esc_script = "res://game/rooms/room02/esc/button.esc" dialog_color = Color( 0, 1, 0.109804, 1 ) +animations = null [node name="Position2D" type="Position2D" parent="button_left"] position = Vector2( 24.6681, 196.998 ) diff --git a/game/rooms/room12/esc/button.esc b/game/rooms/room12/esc/button.esc new file mode 100644 index 00000000..97b3b6a3 --- /dev/null +++ b/game/rooms/room12/esc/button.esc @@ -0,0 +1,31 @@ +:use + +say player "Default" +transition "" out +wait 1 +transition "" in + +say player "Fade white" +transition fade_white out +wait 1 +transition fade_white in + +say player "Fade black" +transition fade_black out +wait 1 +transition fade_black in + +say player "From Center" +transition from_center out +wait 1 +transition from_center in + +say player "Shards" +transition shards out +wait 1 +transition shards in + +say player "Blackout" +transition fade_black out 0.0 +wait 1 +transition fade_black in 0.0 diff --git a/game/rooms/room12/esc/room12.esc b/game/rooms/room12/esc/room12.esc index 7b583fee..27a1ac2c 100644 --- a/game/rooms/room12/esc/room12.esc +++ b/game/rooms/room12/esc/room12.esc @@ -17,7 +17,3 @@ :ready - -transition fade_white in -wait 2 -transition fade_white out diff --git a/game/rooms/room12/room12.tscn b/game/rooms/room12/room12.tscn index 3f7cd91a..26191f79 100644 --- a/game/rooms/room12/room12.tscn +++ b/game/rooms/room12/room12.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=1] [ext_resource path="res://game/rooms/room12/background.tscn" type="PackedScene" id=2] @@ -8,6 +8,7 @@ [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7] [ext_resource path="res://game/rooms/room12/r_door.tscn" type="PackedScene" id=8] +[ext_resource path="res://game/items/escitems/button.tscn" type="PackedScene" id=9] [sub_resource type="NavigationPolygon" id=1] vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 864.626, 613.518, 1143.08, 613.35, -9.16094, 803.802, 386.666, 618.012, 129.634, 615.792, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 ) @@ -75,6 +76,16 @@ esc_script = "res://game/rooms/room12/esc/right_exit.esc" position = Vector2( 1231.78, 360.624 ) script = ExtResource( 5 ) +[node name="button" parent="Hotspots" instance=ExtResource( 9 )] +pause_mode = 1 +position = Vector2( 301.706, 73.0751 ) +global_id = "r12_button" +esc_script = "res://game/rooms/room12/esc/button.esc" +animations = null + +[node name="Position2D" type="Position2D" parent="Hotspots/button"] +position = Vector2( 340.052, 298.812 ) + [node name="player_start" type="Position2D" parent="."] position = Vector2( 542.824, 468.193 ) script = ExtResource( 5 ) diff --git a/project.godot b/project.godot index cd467219..66913a52 100644 --- a/project.godot +++ b/project.godot @@ -324,6 +324,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/escoria-core/game/core-scripts/esc_tooltip.gd" }, { +"base": "ColorRect", +"class": "ESCTransitionPlayer", +"language": "GDScript", +"path": "res://addons/escoria-core/game/scenes/transitions/esc_transition_player.gd" +}, { "base": "Object", "class": "ESCUtils", "language": "GDScript", @@ -563,6 +568,7 @@ _global_script_class_icons={ "ESCStatement": "", "ESCTerrain": "res://addons/escoria-core/design/esc_terrain.svg", "ESCTooltip": "", +"ESCTransitionPlayer": "", "ESCUtils": "", "ESCWalkContext": "", "EnableTerrainCommand": "", @@ -666,6 +672,8 @@ ui/game_scene="res://addons/escoria-ui-simplemouse/game.tscn" ui/dialogs_chooser="res://game/ui/commons/dialogs/text_dialog_choice.tscn" sound/speech_folder="res://game/speech" sound/speech_extension="ogg" +ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders/" ] +ui/default_transition="curtain" [input]