From 9d74b49ab62908d4acf53dde444413886b8b28e5 Mon Sep 17 00:00:00 2001 From: Radio Date: Thu, 4 Jun 2026 15:15:11 +0300 Subject: escoria setup and old branch archives --- .../scenes/transitions/esc_transition_player.gd | 195 +++++++++++++++++++++ .../transitions/esc_transition_player.gd.uid | 1 + .../game/scenes/transitions/masks/curtain.png | Bin 0 -> 149684 bytes .../scenes/transitions/masks/curtain.png.import | 40 +++++ .../game/scenes/transitions/masks/from_center.png | Bin 0 -> 139993 bytes .../transitions/masks/from_center.png.import | 40 +++++ .../game/scenes/transitions/masks/shards.png | Bin 0 -> 82906 bytes .../scenes/transitions/masks/shards.png.import | 40 +++++ .../scenes/transitions/shaders/curtain.material | Bin 0 -> 594 bytes .../scenes/transitions/shaders/fade_black.material | Bin 0 -> 478 bytes .../scenes/transitions/shaders/fade_white.material | Bin 0 -> 477 bytes .../transitions/shaders/from_center.material | Bin 0 -> 598 bytes .../scenes/transitions/shaders/shards.material | Bin 0 -> 593 bytes .../game/scenes/transitions/transition.tscn | 12 ++ 14 files changed, 328 insertions(+) create mode 100644 addons/escoria-core/game/scenes/transitions/esc_transition_player.gd create mode 100644 addons/escoria-core/game/scenes/transitions/esc_transition_player.gd.uid create mode 100644 addons/escoria-core/game/scenes/transitions/masks/curtain.png create mode 100644 addons/escoria-core/game/scenes/transitions/masks/curtain.png.import create mode 100644 addons/escoria-core/game/scenes/transitions/masks/from_center.png create mode 100644 addons/escoria-core/game/scenes/transitions/masks/from_center.png.import create mode 100644 addons/escoria-core/game/scenes/transitions/masks/shards.png create mode 100644 addons/escoria-core/game/scenes/transitions/masks/shards.png.import create mode 100644 addons/escoria-core/game/scenes/transitions/shaders/curtain.material create mode 100644 addons/escoria-core/game/scenes/transitions/shaders/fade_black.material create mode 100644 addons/escoria-core/game/scenes/transitions/shaders/fade_white.material create mode 100644 addons/escoria-core/game/scenes/transitions/shaders/from_center.material create mode 100644 addons/escoria-core/game/scenes/transitions/shaders/shards.material create mode 100644 addons/escoria-core/game/scenes/transitions/transition.tscn (limited to 'addons/escoria-core/game/scenes/transitions') 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 0000000..40b0b61 --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd @@ -0,0 +1,195 @@ +## A transition player for scene changes +extends ColorRect +class_name ESCTransitionPlayer + +## Emitted when the transition was played[br] +## [br] +## #### Parameters[br] +## [br] +## | Name | Type | Description | Required? |[br] +## |:-----|:-----|:------------|:----------|[br] +## |transition_id|`Variant`|Identifier of the transition that completed.|yes|[br] +## [br] +signal transition_done(transition_id) + +## The valid transition modes +enum TRANSITION_MODE { + IN, + OUT +} + +## Id to represent instant/no transitions +const TRANSITION_ID_INSTANT = -1 + +## Instant transition type +const TRANSITION_INSTANT = "instant" + +## Id of the transition. Allows keeping track of the actual transition +## being played or finished +var transition_id: int = 0 + +## The tween instance to animate +var _tween: Tween3 + +## If the current tween was canceled +var _was_canceled: bool = false + +## Fade in when the scene is starting[br] +## [br] +## #### Parameters[br] +## [br] +## None. +## [br] +## #### Returns[br] +## [br] +## Returns nothing. +func _ready() -> void: + anchor_left = 0 + anchor_top = 0 + anchor_right = 1 + anchor_bottom = 1 + color = Color.WHITE + color.a = 0 + mouse_filter = MOUSE_FILTER_IGNORE + _tween = Tween3.new(self) + +## Play a transition animation[br] +## [br] +## #### Parameters[br] +## [br] +## | Name | Type | Description | Required? |[br] +## |:-----|:-----|:------------|:----------|[br] +## |transition_name|`String`|Name of the transition to play (if empty string, uses the default transition).|no|[br] +## |mode|`int`|Mode to transition (in/out).|no|[br] +## |duration|`float`|The duration the transition should take.|no|[br] +## [br] +## #### Returns[br] +## [br] +## Returns the transition id. (`int`) +func transition( + transition_name: String = "", + mode: int = TRANSITION_MODE.IN, + duration: float = 1.0 +) -> int: + + # We put this here instead of the constructor since if we have it in the + # constructor, the transition will ALWAYS happen on game start, which might + # not be desired if 'false' is used for automatic_transitions in a + # change_scene call in :init. + if not _tween.finished.is_connected(_on_tween_completed): + _tween.finished.connect(_on_tween_completed) + + if transition_name.is_empty(): + transition_name = ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.DEFAULT_TRANSITION + ) + + if not has_transition(transition_name): + escoria.logger.error( + self, + "transition: Transition %s not found" % transition_name + ) + + # If this is an "instant" transition, we need to set the alpha of the base + # ColorRect to 0, since the transition materials used have a final state + # that sets this scene's root (ColorRect) alpha to 0. + if transition_name == TRANSITION_INSTANT: + color.a = 0 + return TRANSITION_ID_INSTANT + + var material_path = get_transition(transition_name) + + material = ResourceLoader.load(get_transition(transition_name)) + transition_id += 1 + + var start = 0.0 + var end = 1.0 + + if mode == TRANSITION_MODE.OUT: + start = 1.0 + end = 0.0 + + if _tween.is_running(): + _was_canceled = true + _tween.stop() + _tween.reset() + transition_done.emit(transition_id-1) + + _tween.interpolate_property( + $".", + "material:shader_parameter/cutoff", + start, + end, + duration + ) + _was_canceled = false + _tween.play() + return transition_id + + +## The full path for a transition shader based on its name[br] +## [br] +## #### Parameters[br] +## [br] +## | Name | Type | Description | Required? |[br] +## |:-----|:-----|:------------|:----------|[br] +## |name|`String`|Transition name whose material path should be resolved.|yes|[br] +## [br] +## #### Returns[br] +## [br] +## Returns the full path for a transition shader based on its name the full path to the shader or an empty string if it can't be found. (`String`) +func get_transition(name: String) -> String: + for directory in ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.TRANSITION_PATHS + ): + if ResourceLoader.exists(directory.path_join("%s.material" % name)): + return directory.path_join("%s.material" % name) + return "" + + +## True whether the transition scene has a transition corresponding to name provided.[br] +## [br] +## #### Parameters[br] +## [br] +## | Name | Type | Description | Required? |[br] +## |:-----|:-----|:------------|:----------|[br] +## |name|`String`|Transition name to check for availability.|yes|[br] +## [br] +## #### Returns[br] +## [br] +## Returns true whether the transition scene has a transition corresponding to name provided. true if a transition exists with given name. (`bool`) +func has_transition(name: String) -> bool: + return name == TRANSITION_INSTANT or get_transition(name) != "" + + +## Resets the current material's cutoff parameter instantly.[br] +## [br] +## #### Parameters[br] +## [br] +## None. +## [br] +## #### Returns[br] +## [br] +## Returns nothing. +func reset_shader_cutoff() -> void: + if not is_instance_valid(material): + return + + material.set_shader_parameter("cutoff", 1.0) + + +## Called when the tween completes the transition.[br] +## [br] +## #### Parameters[br] +## [br] +## None. +## [br] +## #### Returns[br] +## [br] +## Returns nothing. +func _on_tween_completed(): + if not _was_canceled: + _tween.stop() + _tween.reset() + escoria.logger.debug(self, "Transition %s done." % str(transition_id)) + transition_done.emit(transition_id) diff --git a/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd.uid b/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd.uid new file mode 100644 index 0000000..435545c --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/esc_transition_player.gd.uid @@ -0,0 +1 @@ +uid://bo0xyume0yqcc diff --git a/addons/escoria-core/game/scenes/transitions/masks/curtain.png b/addons/escoria-core/game/scenes/transitions/masks/curtain.png new file mode 100644 index 0000000..befa82a Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/masks/curtain.png differ diff --git a/addons/escoria-core/game/scenes/transitions/masks/curtain.png.import b/addons/escoria-core/game/scenes/transitions/masks/curtain.png.import new file mode 100644 index 0000000..4766f6d --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/masks/curtain.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://djebg0o8s418r" +path="res://.godot/imported/curtain.png-fd4a78beb232b0a99b1a008eb4a104fd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/escoria-core/game/scenes/transitions/masks/curtain.png" +dest_files=["res://.godot/imported/curtain.png-fd4a78beb232b0a99b1a008eb4a104fd.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 diff --git a/addons/escoria-core/game/scenes/transitions/masks/from_center.png b/addons/escoria-core/game/scenes/transitions/masks/from_center.png new file mode 100644 index 0000000..1c28b7a Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/masks/from_center.png differ diff --git a/addons/escoria-core/game/scenes/transitions/masks/from_center.png.import b/addons/escoria-core/game/scenes/transitions/masks/from_center.png.import new file mode 100644 index 0000000..9d28061 --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/masks/from_center.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bvkmesi350a3d" +path="res://.godot/imported/from_center.png-5a7489c4008ce50848f1d5c7238d9315.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/escoria-core/game/scenes/transitions/masks/from_center.png" +dest_files=["res://.godot/imported/from_center.png-5a7489c4008ce50848f1d5c7238d9315.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 diff --git a/addons/escoria-core/game/scenes/transitions/masks/shards.png b/addons/escoria-core/game/scenes/transitions/masks/shards.png new file mode 100644 index 0000000..1d62b47 Binary files /dev/null and b/addons/escoria-core/game/scenes/transitions/masks/shards.png differ diff --git a/addons/escoria-core/game/scenes/transitions/masks/shards.png.import b/addons/escoria-core/game/scenes/transitions/masks/shards.png.import new file mode 100644 index 0000000..180b89a --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/masks/shards.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dpfnq2e14vwbg" +path="res://.godot/imported/shards.png-a75d64f3ee4c4b3daca9792e71d7f91f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/escoria-core/game/scenes/transitions/masks/shards.png" +dest_files=["res://.godot/imported/shards.png-a75d64f3ee4c4b3daca9792e71d7f91f.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 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 0000000..7ad0fab 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 0000000..d0a7528 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 0000000..8cc21c9 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 0000000..acf5a47 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 0000000..f9027b1 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/transition.tscn b/addons/escoria-core/game/scenes/transitions/transition.tscn new file mode 100644 index 0000000..84c8dbb --- /dev/null +++ b/addons/escoria-core/game/scenes/transitions/transition.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://dep0fi7t7av8"] + +[ext_resource type="Script" uid="uid://bo0xyume0yqcc" path="res://addons/escoria-core/game/scenes/transitions/esc_transition_player.gd" id="1"] +[ext_resource type="Material" uid="uid://bwr4fkt0w426g" path="res://addons/escoria-core/game/scenes/transitions/shaders/curtain.material" id="2"] + +[node name="scene_transition" type="ColorRect"] +material = ExtResource("2") +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +script = ExtResource("1") -- cgit v1.3