mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:55:35 +00:00
Custom module
This commit is contained in:
parent
e43f67c872
commit
0b1ea343dc
25 changed files with 598 additions and 33 deletions
37
Dialogue/CustomScenes/DefaultImageScene/DialogicImage.gd
Normal file
37
Dialogue/CustomScenes/DefaultImageScene/DialogicImage.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
extends Node
|
||||
class_name DialogicImage
|
||||
|
||||
## This is the base class for dialogic images.
|
||||
## Extend it and override it's methods when you create a custom image.
|
||||
## You can take a look at the default background to get an idea of how it's working.
|
||||
|
||||
|
||||
## The subviewport container that holds this background. Set when instanced.
|
||||
var viewport_container: SubViewportContainer
|
||||
## The viewport that holds this background. Set when instanced.
|
||||
var viewport: SubViewport
|
||||
|
||||
|
||||
## Load the new background in here.
|
||||
## The time argument is given for when [_should_do_background_update] returns true
|
||||
## (then you have to do a transition in here)
|
||||
func _update_image(_argument:String, _time:float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## 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_image_update(_argument:String) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
## Called by dialogic when first created.
|
||||
## If you return false (by default) it will attempt to animate the "modulate" property.
|
||||
func _custom_fade_in(_time:float) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
## Called by dialogic before removing (done by dialogic).
|
||||
## If you return false (by default) it will attempt to animate the "modulate" property.
|
||||
func _custom_fade_out(_time:float) -> bool:
|
||||
return false
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://igc188fln1wv
|
||||
29
Dialogue/CustomScenes/DefaultImageScene/default_image.gd
Normal file
29
Dialogue/CustomScenes/DefaultImageScene/default_image.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
extends DialogicImage
|
||||
|
||||
## The default background scene.
|
||||
## Extend the DialogicBackground class to create your own background scene.
|
||||
|
||||
@onready var image_node: TextureRect = $Image
|
||||
@onready var color_node: ColorRect = $ColorRect
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
#image_node.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
#image_node.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED
|
||||
image_node.expand_mode = TextureRect.EXPAND_KEEP_SIZE
|
||||
image_node.stretch_mode = TextureRect.STRETCH_KEEP_CENTERED
|
||||
|
||||
image_node.anchor_right = 1
|
||||
image_node.anchor_bottom = 1
|
||||
|
||||
|
||||
func _update_image(argument:String, _time:float) -> void:
|
||||
if argument.begins_with('res://'):
|
||||
image_node.texture = load(argument)
|
||||
color_node.color = Color.TRANSPARENT
|
||||
elif argument.is_valid_html_color():
|
||||
image_node.texture = null
|
||||
color_node.color = Color(argument, 1)
|
||||
else:
|
||||
image_node.texture = null
|
||||
color_node.color = Color.from_string(argument, Color.TRANSPARENT)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bo6kn3exqjn4v
|
||||
25
Dialogue/CustomScenes/DefaultImageScene/default_image.tscn
Normal file
25
Dialogue/CustomScenes/DefaultImageScene/default_image.tscn
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bjymtmtnuct1c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bo6kn3exqjn4v" path="res://Dialogue/CustomScenes/DefaultImageScene/default_image.gd" id="1_ph6py"]
|
||||
|
||||
[node name="DefaultImage" type="Node"]
|
||||
script = ExtResource("1_ph6py")
|
||||
metadata/_custom_type_script = "uid://igc188fln1wv"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Image" type="TextureRect" parent="."]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 0
|
||||
stretch_mode = 3
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://jypfiwjsk8wh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bisx1nk1bjyjc" path="res://addons/dialogic/Modules/Background/node_background_holder.gd" id="1_4gfgy"]
|
||||
[ext_resource type="Script" uid="uid://hiekbi2rsq1j" path="res://Dialogue/Styles/Layers/Image_Layer/Image/node_image_holder.gd" id="1_og2vk"]
|
||||
|
||||
[node name="DialogicImage" type="Node2D"]
|
||||
|
||||
[node name="DialogicNode_BackgroundHolder" type="ColorRect" parent="."]
|
||||
[node name="DialogicNode_ImageHolder" type="ColorRect" parent="."]
|
||||
offset_left = 126.0
|
||||
offset_top = 41.0
|
||||
offset_right = 209.0
|
||||
offset_bottom = 124.0
|
||||
script = ExtResource("1_4gfgy")
|
||||
script = ExtResource("1_og2vk")
|
||||
|
|
|
|||
|
|
@ -1,22 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://1qx7a3isffve"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://xwj105ltniqb" path="res://addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.gd" id="1_2qy85"]
|
||||
[ext_resource type="Script" uid="uid://bo6kn3exqjn4v" path="res://Dialogue/CustomScenes/DefaultImageScene/default_image.gd" id="1_sosx8"]
|
||||
|
||||
[node name="DefaultBackground" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 180.0
|
||||
offset_top = 20.0
|
||||
offset_right = -60.0
|
||||
offset_bottom = -60.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_2qy85")
|
||||
[node name="DefaultBackground" type="Node"]
|
||||
script = ExtResource("1_sosx8")
|
||||
metadata/_custom_type_script = "uid://igc188fln1wv"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
|
@ -24,10 +14,9 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
|
||||
[node name="Image" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
grow_horizontal = 0
|
||||
mouse_filter = 0
|
||||
stretch_mode = 3
|
||||
|
|
|
|||
91
Dialogue/Styles/Briefing_Style.tres
Normal file
91
Dialogue/Styles/Briefing_Style.tres
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
[gd_resource type="Resource" script_class="DialogicStyle" load_steps=22 format=3 uid="uid://1360okdjnu04"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dh4po8pgey4yv" path="res://addons/dialogic/Resources/dialogic_style_layer.gd" id="1_1na1v"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1k5m0w3r40xf" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn" id="2_yysma"]
|
||||
[ext_resource type="PackedScene" uid="uid://cy1y14inwkplb" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn" id="3_tapfv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cn674foxwedqu" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Input/full_advance_input_layer.tscn" id="4_c3ltj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bkycr7efsukaj" path="res://Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/custom_visual_novel_textbox.tscn" id="5_rmqst"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsbwnp5hegnu3" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.tscn" id="6_eh3mk"]
|
||||
[ext_resource type="PackedScene" uid="uid://dhk6j6eb6e3q" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.tscn" id="7_tsnk8"]
|
||||
[ext_resource type="PackedScene" uid="uid://cvgf4c6gg0tsy" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.tscn" id="8_ipd3l"]
|
||||
[ext_resource type="PackedScene" uid="uid://lx24i8fl6uo" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn" id="9_sowdg"]
|
||||
[ext_resource type="Script" uid="uid://dfja8ptqdlfix" path="res://addons/dialogic/Resources/dialogic_style.gd" id="10_lggnn"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvoym0jf534us" path="res://Dialogue/Styles/Layers/Image_Layer/Image/custom_image.tscn" id="10_yysma"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1umci"]
|
||||
script = ExtResource("1_1na1v")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_k5ph0"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("2_yysma")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pd24n"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("3_tapfv")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_msgpj"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("4_c3ltj")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_20kch"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("5_rmqst")
|
||||
overrides = {
|
||||
"box_margin_bottom": "1.0",
|
||||
"box_panel": "\"res://Resources/Styles/PixelStyleBoxRed.tres\"",
|
||||
"box_size": "Vector2(300, 50)",
|
||||
"name_label_box_offset": "Vector2(0, 8)",
|
||||
"name_label_box_panel": "\"res://Resources/Styles/PixelStyleBoxRed.tres\"",
|
||||
"name_label_custom_font_size": "11.0",
|
||||
"next_indicator_size": "Vector2(12, 12)",
|
||||
"text_size": "6.0"
|
||||
}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7dp66"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("6_eh3mk")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_63vmy"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("7_tsnk8")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_disj7"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("8_ipd3l")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6rqr5"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("9_sowdg")
|
||||
overrides = {}
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tapfv"]
|
||||
script = ExtResource("1_1na1v")
|
||||
scene = ExtResource("10_yysma")
|
||||
overrides = {}
|
||||
|
||||
[resource]
|
||||
script = ExtResource("10_lggnn")
|
||||
name = "Briefing_Style"
|
||||
layer_list = Array[String](["10", "18", "11", "12", "13", "14", "15", "16", "17"])
|
||||
layer_info = {
|
||||
"": SubResource("Resource_1umci"),
|
||||
"10": SubResource("Resource_k5ph0"),
|
||||
"11": SubResource("Resource_pd24n"),
|
||||
"12": SubResource("Resource_msgpj"),
|
||||
"13": SubResource("Resource_20kch"),
|
||||
"14": SubResource("Resource_7dp66"),
|
||||
"15": SubResource("Resource_63vmy"),
|
||||
"16": SubResource("Resource_disj7"),
|
||||
"17": SubResource("Resource_6rqr5"),
|
||||
"18": SubResource("Resource_tapfv")
|
||||
}
|
||||
base_overrides = {}
|
||||
layers = Array[ExtResource("1_1na1v")]([])
|
||||
metadata/_latest_layer = "18"
|
||||
25
Dialogue/Styles/Layers/Image_Layer/Image/custom_image.tscn
Normal file
25
Dialogue/Styles/Layers/Image_Layer/Image/custom_image.tscn
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bvoym0jf534us"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ct3rq3r2th80u" path="res://Dialogue/Styles/Layers/Image_Layer/Image/image_layer.gd" id="1_3ircq"]
|
||||
[ext_resource type="Script" uid="uid://hiekbi2rsq1j" path="res://Dialogue/Styles/Layers/Image_Layer/Image/node_image_holder.gd" id="2_3ircq"]
|
||||
|
||||
[node name="ImageLayer" type="Control"]
|
||||
layout_direction = 2
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_3ircq")
|
||||
|
||||
[node name="DialogicNode_ImageHolder" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
color = Color(1, 1, 1, 0)
|
||||
script = ExtResource("2_3ircq")
|
||||
2
Dialogue/Styles/Layers/Image_Layer/Image/image_layer.gd
Normal file
2
Dialogue/Styles/Layers/Image_Layer/Image/image_layer.gd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@tool
|
||||
extends DialogicLayoutLayer
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ct3rq3r2th80u
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class_name DialogicNode_ImageHolder
|
||||
extends DialogicNode_BackgroundHolder
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group('dialogic_image_holders')
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://hiekbi2rsq1j
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
[gd_resource type="Resource" script_class="DialogicStyle" load_steps=20 format=3 uid="uid://b6omw5u7u4f3"]
|
||||
[gd_resource type="Resource" script_class="DialogicStyle" load_steps=21 format=3 uid="uid://b6omw5u7u4f3"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cqpb3ie51rwl5" path="res://addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.tscn" id="1_1vg82"]
|
||||
[ext_resource type="Script" uid="uid://dh4po8pgey4yv" path="res://addons/dialogic/Resources/dialogic_style_layer.gd" id="1_47mos"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1k5m0w3r40xf" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn" id="2_obap8"]
|
||||
[ext_resource type="PackedScene" uid="uid://cy1y14inwkplb" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn" id="3_kxjow"]
|
||||
|
|
@ -13,6 +14,7 @@
|
|||
|
||||
[sub_resource type="Resource" id="Resource_mqh25"]
|
||||
script = ExtResource("1_47mos")
|
||||
scene = ExtResource("1_1vg82")
|
||||
overrides = {
|
||||
"global_font": "\"res://fonts/Silver.ttf\"",
|
||||
"global_font_size": "19.0"
|
||||
|
|
@ -84,4 +86,4 @@ layer_info = {
|
|||
}
|
||||
base_overrides = {}
|
||||
layers = Array[ExtResource("1_47mos")]([])
|
||||
metadata/_latest_layer = "13"
|
||||
metadata/_latest_layer = "10"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
[style name="VN"]
|
||||
Welcome to the Resistance, Cirno.
|
||||
[background arg="res://Sprites/Briefing/Refinery.png" fade="0.0"]
|
||||
This is your objective
|
||||
[background arg="res://Sprites/UI/TitleBackground.png" fade="0.0"]
|
||||
[style name="Briefing_Style"]
|
||||
join Colonel center [animation="Fade In"]
|
||||
Colonel: Welcome to the Resistance, Cirno.
|
||||
update Colonel left [move_time="0.4"]
|
||||
[image scene="res://Dialogue/CustomScenes/dialogic_windowed_image.tscn" arg="res://Sprites/Briefing/RefinerySmall.png" fade="0.0"]
|
||||
Colonel: This is your objective
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
[sub_resource type="Resource" id="Resource_6wo78"]
|
||||
script = ExtResource("4_u1i8n")
|
||||
EggIndex = 0
|
||||
StartingEquipment = []
|
||||
StartingEquipment = Array[ExtResource("5_u1i8n")]([])
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rff8l"]
|
||||
size = Vector2(30, 52.5)
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ WaitForCompletion = true
|
|||
|
||||
[sub_resource type="Resource" id="Resource_s3g2w"]
|
||||
script = ExtResource("46_i0omr")
|
||||
TimelineName = &"timeline"
|
||||
TimelineName = &"Mission1_Briefing"
|
||||
WaitForCompletion = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_068l7"]
|
||||
|
|
@ -1101,7 +1101,7 @@ position = Vector2(-2000, -736)
|
|||
[node name="ControlPad8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
|
||||
position = Vector2(-2027, -735)
|
||||
Targets = [NodePath("../HorizontalForceField")]
|
||||
Requirements = [ExtResource("84_ma1ta")]
|
||||
Requirements = Array[ExtResource("6_8tdlb")]([ExtResource("84_ma1ta")])
|
||||
|
||||
[node name="Ammo6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")]
|
||||
position = Vector2(-872, -220)
|
||||
|
|
|
|||
|
|
@ -35,4 +35,3 @@ func _custom_fade_in(_time:float) -> bool:
|
|||
## If you return false (by default) it will attempt to animate the "modulate" property.
|
||||
func _custom_fade_out(_time:float) -> bool:
|
||||
return false
|
||||
|
||||
|
|
|
|||
156
addons/dialogic_additions/ShowImage/event_show_image.gd
Normal file
156
addons/dialogic_additions/ShowImage/event_show_image.gd
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
@tool
|
||||
class_name DialogicShowImageEvent
|
||||
extends DialogicEvent
|
||||
|
||||
## Event to show scenes in the image 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 := ""
|
||||
## The argument that is passed to the background scene.
|
||||
## For the default scene it's the path to the image to show.
|
||||
var argument := ""
|
||||
## The time the fade animation will take. Leave at 0 for instant change.
|
||||
var fade: float = 0.0
|
||||
## Name of the transition to use.
|
||||
var transition := ""
|
||||
|
||||
## Helpers for visual editor
|
||||
enum ArgumentTypes {IMAGE, CUSTOM}
|
||||
var _arg_type := ArgumentTypes.IMAGE :
|
||||
get:
|
||||
if argument.begins_with("res://"):
|
||||
return ArgumentTypes.IMAGE
|
||||
else:
|
||||
return _arg_type
|
||||
set(value):
|
||||
if value == ArgumentTypes.CUSTOM:
|
||||
if argument.begins_with("res://"):
|
||||
argument = " "+argument
|
||||
_arg_type = value
|
||||
|
||||
enum SceneTypes {DEFAULT, CUSTOM}
|
||||
var _scene_type := SceneTypes.DEFAULT :
|
||||
get:
|
||||
if scene.is_empty():
|
||||
return _scene_type
|
||||
else:
|
||||
return SceneTypes.CUSTOM
|
||||
set(value):
|
||||
if value == SceneTypes.DEFAULT:
|
||||
scene = ""
|
||||
_scene_type = value
|
||||
|
||||
#region EXECUTION
|
||||
################################################################################
|
||||
|
||||
func _execute() -> void:
|
||||
var final_fade_duration := fade
|
||||
|
||||
if dialogic.Inputs.auto_skip.enabled:
|
||||
var time_per_event: float = dialogic.Inputs.auto_skip.time_per_event
|
||||
final_fade_duration = min(fade, time_per_event)
|
||||
|
||||
dialogic.get_subsystem("ShowImage").update_image(scene, argument, final_fade_duration, transition)
|
||||
|
||||
finish()
|
||||
|
||||
#endregion
|
||||
|
||||
#region INITIALIZE
|
||||
################################################################################
|
||||
|
||||
func _init() -> void:
|
||||
event_name = "Image"
|
||||
set_default_color('Color8')
|
||||
event_category = "Visuals"
|
||||
event_sorting_index = 0
|
||||
|
||||
#endregion
|
||||
|
||||
#region SAVE & LOAD
|
||||
################################################################################
|
||||
|
||||
func get_shortcode() -> String:
|
||||
return "image"
|
||||
|
||||
|
||||
func get_shortcode_parameters() -> Dictionary:
|
||||
return {
|
||||
#param_name : property_info
|
||||
"scene" : {"property": "scene", "default": ""},
|
||||
"arg" : {"property": "argument", "default": ""},
|
||||
"fade" : {"property": "fade", "default": 0},
|
||||
"transition" : {"property": "transition", "default": "",
|
||||
"suggestions": get_transition_suggestions},
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region EDITOR REPRESENTATION
|
||||
################################################################################
|
||||
|
||||
func build_event_editor() -> void:
|
||||
add_header_edit('_scene_type', ValueType.FIXED_OPTIONS, {
|
||||
'left_text' :'Show',
|
||||
'options': [
|
||||
{
|
||||
'label': 'Image',
|
||||
'value': SceneTypes.DEFAULT,
|
||||
'icon': ["GuiRadioUnchecked", "EditorIcons"]
|
||||
},
|
||||
{
|
||||
'label': 'Custom Scene',
|
||||
'value': SceneTypes.CUSTOM,
|
||||
'icon': ["PackedScene", "EditorIcons"]
|
||||
}
|
||||
]})
|
||||
add_header_label("with image", "_scene_type == SceneTypes.DEFAULT")
|
||||
add_header_edit("scene", ValueType.FILE,
|
||||
{'file_filter':'*.tscn, *.scn; Scene Files',
|
||||
'placeholder': "Custom scene",
|
||||
'editor_icon': ["PackedScene", "EditorIcons"],
|
||||
}, '_scene_type == SceneTypes.CUSTOM')
|
||||
add_header_edit('_arg_type', ValueType.FIXED_OPTIONS, {
|
||||
'left_text' : 'with',
|
||||
'options': [
|
||||
{
|
||||
'label': 'Image',
|
||||
'value': ArgumentTypes.IMAGE,
|
||||
'icon': ["Image", "EditorIcons"]
|
||||
},
|
||||
{
|
||||
'label': 'Custom Argument',
|
||||
'value': ArgumentTypes.CUSTOM,
|
||||
'icon': ["String", "EditorIcons"]
|
||||
}
|
||||
], "symbol_only": true}, "_scene_type == SceneTypes.CUSTOM")
|
||||
add_header_edit('argument', ValueType.FILE,
|
||||
{'file_filter':'*.jpg, *.jpeg, *.png, *.webp, *.tga, *svg, *.bmp, *.dds, *.exr, *.hdr; Supported Image Files',
|
||||
'placeholder': "No Image",
|
||||
'editor_icon': ["Image", "EditorIcons"],
|
||||
},
|
||||
'_arg_type == ArgumentTypes.IMAGE or _scene_type == SceneTypes.DEFAULT')
|
||||
add_header_edit('argument', ValueType.SINGLELINE_TEXT, {}, '_arg_type == ArgumentTypes.CUSTOM')
|
||||
|
||||
add_body_edit("transition", ValueType.DYNAMIC_OPTIONS,
|
||||
{'left_text':'Transition:',
|
||||
'empty_text':'Simple Fade',
|
||||
'suggestions_func':get_transition_suggestions,
|
||||
'editor_icon':["PopupMenu", "EditorIcons"]})
|
||||
add_body_edit("fade", ValueType.NUMBER, {'left_text':'Fade time:'})
|
||||
|
||||
|
||||
func get_transition_suggestions(_filter:String="") -> Dictionary:
|
||||
var transitions := DialogicResourceUtil.list_special_resources("BackgroundTransition")
|
||||
var suggestions := {}
|
||||
for i in transitions:
|
||||
suggestions[DialogicUtil.pretty_name(i)] = {'value': DialogicUtil.pretty_name(i), 'editor_icon': ["PopupMenu", "EditorIcons"]}
|
||||
return suggestions
|
||||
|
||||
#endregion
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dqkhnb7pxqwew
|
||||
8
addons/dialogic_additions/ShowImage/index.gd
Normal file
8
addons/dialogic_additions/ShowImage/index.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@tool
|
||||
extends DialogicIndexer
|
||||
|
||||
func _get_events() -> Array:
|
||||
return [this_folder.path_join('event_show_image.gd')]
|
||||
|
||||
func _get_subsystems() -> Array:
|
||||
return [{'name':'ShowImage', 'script':this_folder.path_join('subsystem_show_image.gd')}]
|
||||
1
addons/dialogic_additions/ShowImage/index.gd.uid
Normal file
1
addons/dialogic_additions/ShowImage/index.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dgkon3jaqokyk
|
||||
186
addons/dialogic_additions/ShowImage/subsystem_show_image.gd
Normal file
186
addons/dialogic_additions/ShowImage/subsystem_show_image.gd
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
extends DialogicSubsystem
|
||||
## Subsystem for managing images.
|
||||
##
|
||||
## This subsystem has many different helper methods for managing backgrounds.
|
||||
## For instance, you can listen to image changes via
|
||||
## [signal image_changed].
|
||||
|
||||
|
||||
## Whenever a new background is set, this signal is emitted and contains a
|
||||
## dictionary with the following keys: [br]
|
||||
## [br]
|
||||
## Key | Value Type | Value [br]
|
||||
## ----------- | ------------- | ----- [br]
|
||||
## `scene` | [type String] | The scene path of the new background. [br]
|
||||
## `argument` | [type String] | Information given to the background on its update routine. [br]
|
||||
## `fade_time` | [type float] | The time the background may take to transition in. [br]
|
||||
## `same_scene`| [type bool] | If the new background uses the same Godot scene. [br]
|
||||
signal image_changed(info: Dictionary)
|
||||
|
||||
## The default background scene Dialogic will use.
|
||||
var default_background_scene: PackedScene = load("res://Dialogue/CustomScenes/DefaultImageScene/default_image.tscn")
|
||||
## The default transition Dialogic will use.
|
||||
var default_transition: String = "res://addons/dialogic/Modules/Background/Transitions/Defaults/simple_fade.gd"
|
||||
|
||||
|
||||
#region STATE
|
||||
####################################################################################################
|
||||
|
||||
## Empties the current background state.
|
||||
func clear_game_state(_clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
|
||||
update_image()
|
||||
|
||||
## Loads the background state from the current state info.
|
||||
func load_game_state(_load_flag := LoadFlags.FULL_LOAD) -> void:
|
||||
update_image(dialogic.current_state_info.get('image_scene', ''), dialogic.current_state_info.get('image_argument', ''), 0.0, default_transition, true)
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region MAIN METHODS
|
||||
####################################################################################################
|
||||
|
||||
## Method that adds a given scene as child of the DialogicNode_ImageHolder.
|
||||
## 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_image(scene := "", argument := "", fade_time := 0.0, transition_path:=default_transition, force := false) -> void:
|
||||
var background_holder: DialogicNode_ImageHolder
|
||||
if dialogic.has_subsystem('Styles'):
|
||||
background_holder = dialogic.Styles.get_first_node_in_layout('dialogic_image_holders')
|
||||
else:
|
||||
background_holder = get_tree().get_first_node_in_group('dialogic_image_holders')
|
||||
|
||||
var info := {'scene':scene, 'argument':argument, 'fade_time':fade_time, 'same_scene':false}
|
||||
if background_holder == null:
|
||||
image_changed.emit(info)
|
||||
return
|
||||
|
||||
|
||||
var bg_set := false
|
||||
|
||||
# First try just updating the existing scene.
|
||||
if scene == dialogic.current_state_info.get('image_scene', ''):
|
||||
|
||||
if not force and argument == dialogic.current_state_info.get('image_argument', ''):
|
||||
return
|
||||
|
||||
for old_bg in background_holder.get_children():
|
||||
if !old_bg.has_meta('node') or not old_bg.get_meta('node') is DialogicImage:
|
||||
continue
|
||||
|
||||
var prev_bg_node: DialogicImage = old_bg.get_meta('node')
|
||||
if prev_bg_node._should_do_image_update(argument):
|
||||
prev_bg_node._update_image(argument, fade_time)
|
||||
bg_set = true
|
||||
info['same_scene'] = true
|
||||
|
||||
dialogic.current_state_info['image_scene'] = scene
|
||||
dialogic.current_state_info['image_argument'] = argument
|
||||
|
||||
if bg_set:
|
||||
image_changed.emit(info)
|
||||
return
|
||||
|
||||
var old_viewport: SubViewportContainer = null
|
||||
if background_holder.has_meta('current_viewport'):
|
||||
old_viewport = background_holder.get_meta('current_viewport', null)
|
||||
|
||||
var new_viewport: SubViewportContainer
|
||||
if scene.ends_with('.tscn') and ResourceLoader.exists(scene):
|
||||
new_viewport = add_image_node(load(scene), background_holder)
|
||||
elif argument:
|
||||
new_viewport = add_image_node(default_background_scene, background_holder)
|
||||
else:
|
||||
new_viewport = null
|
||||
|
||||
var trans_script: Script = load(DialogicResourceUtil.guess_special_resource("BackgroundTransition", transition_path, {"path":default_transition}).path)
|
||||
var trans_node := Node.new()
|
||||
trans_node.set_script(trans_script)
|
||||
trans_node = (trans_node as DialogicBackgroundTransition)
|
||||
trans_node.bg_holder = background_holder
|
||||
trans_node.time = fade_time
|
||||
|
||||
if old_viewport:
|
||||
trans_node.prev_scene = old_viewport.get_meta('node', null)
|
||||
trans_node.prev_texture = old_viewport.get_child(0).get_texture()
|
||||
old_viewport.get_meta('node')._custom_fade_out(fade_time)
|
||||
old_viewport.hide()
|
||||
# TODO We have to call this again here because of https://github.com/godotengine/godot/issues/23729
|
||||
old_viewport.get_child(0).render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
||||
trans_node.transition_finished.connect(old_viewport.queue_free)
|
||||
if new_viewport:
|
||||
trans_node.next_scene = new_viewport.get_meta('node', null)
|
||||
trans_node.next_texture = new_viewport.get_child(0).get_texture()
|
||||
new_viewport.get_meta('node')._update_image(argument, fade_time)
|
||||
new_viewport.get_meta('node')._custom_fade_in(fade_time)
|
||||
else:
|
||||
background_holder.remove_meta('current_viewport')
|
||||
|
||||
add_child(trans_node)
|
||||
if fade_time == 0:
|
||||
trans_node.transition_finished.emit()
|
||||
_on_transition_finished(background_holder, trans_node)
|
||||
else:
|
||||
trans_node.transition_finished.connect(_on_transition_finished.bind(background_holder, trans_node))
|
||||
# We need to break this connection if the background_holder get's removed during the transition
|
||||
background_holder.tree_exited.connect(trans_node.disconnect.bind("transition_finished", _on_transition_finished))
|
||||
trans_node._fade()
|
||||
|
||||
image_changed.emit(info)
|
||||
|
||||
|
||||
func _on_transition_finished(background_node:DialogicNode_ImageHolder, transition_node:DialogicBackgroundTransition) -> void:
|
||||
if background_node.has_meta("current_viewport"):
|
||||
if background_node.get_meta("current_viewport").get_meta("node", null) == transition_node.next_scene:
|
||||
background_node.get_meta("current_viewport").show()
|
||||
background_node.material = null
|
||||
background_node.color = Color.TRANSPARENT
|
||||
transition_node.queue_free()
|
||||
|
||||
|
||||
## Adds sub-viewport with the given background scene as child to
|
||||
## Dialogic scene.
|
||||
func add_image_node(scene:PackedScene, parent:DialogicNode_ImageHolder) -> SubViewportContainer:
|
||||
var v_con := SubViewportContainer.new()
|
||||
var viewport := SubViewport.new()
|
||||
var b_scene := scene.instantiate()
|
||||
if not b_scene is DialogicImage:
|
||||
printerr("[Dialogic] Given background scene was not of type DialogicImage! Make sure the scene has a script that extends DialogicImage.")
|
||||
v_con.queue_free()
|
||||
viewport.queue_free()
|
||||
b_scene.queue_free()
|
||||
return null
|
||||
|
||||
parent.add_child(v_con)
|
||||
v_con.hide()
|
||||
v_con.stretch = true
|
||||
v_con.size = parent.size
|
||||
v_con.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
|
||||
v_con.add_child(viewport)
|
||||
viewport.transparent_bg = true
|
||||
viewport.disable_3d = true
|
||||
viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
||||
viewport.canvas_item_default_texture_filter = ProjectSettings.get_setting("rendering/textures/canvas_textures/default_texture_filter")
|
||||
|
||||
viewport.add_child(b_scene)
|
||||
b_scene.viewport = viewport
|
||||
b_scene.viewport_container = v_con
|
||||
|
||||
parent.set_meta('current_viewport', v_con)
|
||||
v_con.set_meta('node', b_scene)
|
||||
|
||||
return v_con
|
||||
|
||||
|
||||
## Whether a image is set.
|
||||
func has_image() -> bool:
|
||||
return !dialogic.current_state_info.get('image_scene', '').is_empty() or !dialogic.current_state_info.get('image_argument','').is_empty()
|
||||
|
||||
#endregion
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cmulwa1r03x6g
|
||||
|
|
@ -83,7 +83,7 @@ directories/dtl_directory={
|
|||
"tutorial_teleporter_2": "res://Dialogue/Timelines/Tutorial/tutorial_teleporter_2.dtl"
|
||||
}
|
||||
glossary/default_case_sensitive=true
|
||||
layout/style_list=["res://Dialogue/Styles/Textbox_style.tres", "res://Dialogue/Styles/VN.tres", "res://Dialogue/Styles/Intro_Syle.tres", "res://Dialogue/Styles/custom_test.tres", "res://Dialogue/Styles/speakerstyletest.tres", "res://Dialogue/Styles/Terminal_Style.tres"]
|
||||
layout/style_list=["res://Dialogue/Styles/Textbox_style.tres", "res://Dialogue/Styles/VN.tres", "res://Dialogue/Styles/Terminal_Style.tres", "res://Dialogue/Styles/Briefing_Style.tres"]
|
||||
layout/default_style="res://Dialogue/Styles/Textbox_style.tres"
|
||||
variables={}
|
||||
extensions_folder="res://addons/dialogic_additions"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue