Add addons
This commit is contained in:
parent
2c862b2235
commit
3367bad24f
527 changed files with 36197 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
extends TextureRect
|
||||
|
||||
## This is the DefaultBackground scene that can simply display a image
|
||||
##
|
||||
## You can create your own scenes. They can override the following methods:
|
||||
## - _update_background(@argument:String, @time:float)
|
||||
## - _fade_in(@time) (if not overriden modulate is animated)
|
||||
## - _fade_out(@time) (if not overriden modulate is animated)
|
||||
## make sure to free the scene at the end of the fade
|
||||
## - _should_do_background_update(@arg) -> bool
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
ignore_texture_size = true
|
||||
stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED
|
||||
|
||||
anchor_right = 1
|
||||
anchor_bottom = 1
|
||||
|
||||
# load the new background in here.
|
||||
# The time argument is given for when [_should_do_background_update] returns true
|
||||
# (then you have to do the transition in here)
|
||||
func _update_background(argument:String, time:float) -> void:
|
||||
texture = load(argument)
|
||||
|
||||
|
||||
# if a Background event with this scene is encountered while this background is used,
|
||||
# this decides whether to create a new instance and call fade_out or just call [_update_background] # on this scene. Default is false
|
||||
func _should_do_background_update(argument:String) -> bool:
|
||||
return false
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bgoisbbnvcfbf"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Events/Background/default_background.gd" id="1_nkdrp"]
|
||||
|
||||
[node name="DefaultBackground" type="TextureRect"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_nkdrp")
|
||||
74
Sprout/addons/dialogic/Events/Background/event_background.gd
Normal file
74
Sprout/addons/dialogic/Events/Background/event_background.gd
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
@tool
|
||||
class_name DialogicBackgroundEvent
|
||||
extends DialogicEvent
|
||||
|
||||
## Event to show scenes in the background and switch between them.
|
||||
|
||||
### Settings
|
||||
|
||||
## The scene to use. If empty, this will default to the DefaultBackground.gd scene.
|
||||
## This scene supports images and fading.
|
||||
## If you set it to a scene path, then that scene will be instanced.
|
||||
## Learn more about custom backgrounds in the Subsystem_Background.gd docs.
|
||||
var scene: String = ""
|
||||
## The argument that is passed to the background scene.
|
||||
## For the default scene it's the path to the image to show.
|
||||
var argument: String = ""
|
||||
## The time the fade animation will take. Leave at 0 for instant change.
|
||||
var fade: float = 0.0
|
||||
|
||||
|
||||
################################################################################
|
||||
## EXECUTION
|
||||
################################################################################
|
||||
|
||||
func _execute() -> void:
|
||||
dialogic.Backgrounds.update_background(scene, argument, fade)
|
||||
finish()
|
||||
|
||||
|
||||
################################################################################
|
||||
## INITIALIZE
|
||||
################################################################################
|
||||
|
||||
func _init() -> void:
|
||||
event_name = "Background"
|
||||
set_default_color('Color4')
|
||||
event_category = Category.AudioVisual
|
||||
event_sorting_index = 0
|
||||
expand_by_default = false
|
||||
|
||||
|
||||
################################################################################
|
||||
## SAVING/LOADING
|
||||
################################################################################
|
||||
|
||||
func get_shortcode() -> String:
|
||||
return "background"
|
||||
|
||||
|
||||
func get_shortcode_parameters() -> Dictionary:
|
||||
return {
|
||||
#param_name : property_info
|
||||
"scene" : {"property": "scene", "default": ""},
|
||||
"arg" : {"property": "argument", "default": ""},
|
||||
"fade" : {"property": "fade", "default": 0},
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
## EDITOR REPRESENTATION
|
||||
################################################################################
|
||||
|
||||
func build_event_editor():
|
||||
add_header_edit('argument', ValueType.File, '', '',
|
||||
{'file_filter':'*.tscn, *.scn, *.jpg, *.jpeg, *.png, *.webp, *.tga, *svg, *.bmp, *.dds, *.exr, *.hdr',
|
||||
'placeholder': "No background",
|
||||
'editor_icon':["Image", "EditorIcons"]},
|
||||
'scene == ""')
|
||||
add_header_edit('argument', ValueType.SinglelineText, 'Argument:', '', {}, 'scene != ""')
|
||||
add_body_edit("fade", ValueType.Float, "fade time: ")
|
||||
add_body_edit("scene", ValueType.File, 'scene:', '',
|
||||
{'file_filter':'*.tscn, *.scn',
|
||||
'placeholder': "Default scene",
|
||||
'editor_icon':["PackedScene", "EditorIcons"]})
|
||||
BIN
Sprout/addons/dialogic/Events/Background/icon.png
Normal file
BIN
Sprout/addons/dialogic/Events/Background/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 512 B |
34
Sprout/addons/dialogic/Events/Background/icon.png.import
Normal file
34
Sprout/addons/dialogic/Events/Background/icon.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://517mp8gfj811"
|
||||
path="res://.godot/imported/icon.png-5701ef95f478df093cee0e38709c3b42.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dialogic/Events/Background/icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-5701ef95f478df093cee0e38709c3b42.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
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
|
||||
10
Sprout/addons/dialogic/Events/Background/index.gd
Normal file
10
Sprout/addons/dialogic/Events/Background/index.gd
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
@tool
|
||||
extends DialogicIndexer
|
||||
|
||||
|
||||
func _get_events() -> Array:
|
||||
return [this_folder.path_join('event_background.gd')]
|
||||
|
||||
|
||||
func _get_subsystems() -> Array:
|
||||
return [{'name':'Backgrounds', 'script':this_folder.path_join('subsystem_backgrounds.gd')}]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class_name DialogicNode_BackgroundHolder
|
||||
extends CanvasLayer
|
||||
|
||||
|
||||
func _ready():
|
||||
add_to_group('dialogic_background_holders')
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
extends DialogicSubsystem
|
||||
|
||||
## Subsystem for managing backgrounds.
|
||||
|
||||
var default_background_scene = load(get_script().resource_path.get_base_dir().path_join('default_background.tscn'))
|
||||
####################################################################################################
|
||||
## STATE
|
||||
####################################################################################################
|
||||
|
||||
func clear_game_state():
|
||||
update_background()
|
||||
|
||||
|
||||
func load_game_state():
|
||||
update_background(dialogic.current_state_info.get('background_scene', ''), dialogic.current_state_info.get('background_argument', ''))
|
||||
|
||||
|
||||
####################################################################################################
|
||||
## MAIN METHODS
|
||||
####################################################################################################
|
||||
|
||||
## Method that adds a given scene as child of the DialogicNode_BackgroundHolder.
|
||||
## It will call [_update_background()] on that scene with the given argument [argument].
|
||||
## It will call [_fade_in()] on that scene with the given fade time.
|
||||
## Will call fade_out on previous backgrounds scene.
|
||||
##
|
||||
## If the scene is the same as the last background you can bypass another instantiating
|
||||
## and use the same scene.
|
||||
## To do so implement [_should_do_background_update()] on the custom background scene.
|
||||
## Then [_update_background()] will be called directly on that previous scene.
|
||||
func update_background(scene:String = '', argument:String = '', fade_time:float = 0.0) -> void:
|
||||
for node in get_tree().get_nodes_in_group('dialogic_background_holders'):
|
||||
if node.visible:
|
||||
var bg_set: bool = false
|
||||
if scene == dialogic.current_state_info['background_scene']:
|
||||
for old_bg in node.get_children():
|
||||
if old_bg.has_method("_should_do_background_update") and old_bg._should_do_background_update(argument):
|
||||
if old_bg.has_method('_update_background'):
|
||||
old_bg._update_background(argument, fade_time)
|
||||
bg_set = true
|
||||
if !bg_set:
|
||||
# remove previous backgrounds
|
||||
for old_bg in node.get_children():
|
||||
|
||||
if old_bg.has_method('_fade_out'):
|
||||
old_bg._fade_out(fade_time)
|
||||
elif "modulate" in old_bg:
|
||||
var tween := old_bg.create_tween()
|
||||
tween.tween_property(old_bg, "modulate", Color.TRANSPARENT, fade_time)
|
||||
tween.tween_callback(old_bg.queue_free)
|
||||
else:
|
||||
old_bg.queue_free()
|
||||
|
||||
var new_node:Node
|
||||
if scene.ends_with('.tscn'):
|
||||
new_node = load(scene).instantiate()
|
||||
elif argument:
|
||||
new_node = default_background_scene.instantiate()
|
||||
else:
|
||||
new_node = null
|
||||
|
||||
if new_node:
|
||||
node.add_child(new_node)
|
||||
|
||||
if new_node.has_method('_update_background'):
|
||||
new_node._update_background(argument, fade_time)
|
||||
|
||||
if new_node.has_method('_fade_in'):
|
||||
new_node._fade_in(fade_time)
|
||||
|
||||
elif "modulate" in new_node:
|
||||
new_node.modulate = Color.TRANSPARENT
|
||||
var tween = new_node.create_tween()
|
||||
tween.tween_property(new_node, "modulate", Color.WHITE, fade_time)
|
||||
|
||||
dialogic.current_state_info['background_scene'] = scene
|
||||
dialogic.current_state_info['background_argument'] = argument
|
||||
Loading…
Add table
Add a link
Reference in a new issue