Custom module

This commit is contained in:
Marco 2025-03-19 15:56:18 +01:00
commit 0b1ea343dc
25 changed files with 598 additions and 33 deletions

View 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

View file

@ -0,0 +1 @@
uid://igc188fln1wv

View 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)

View file

@ -0,0 +1 @@
uid://bo6kn3exqjn4v

View 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

View file

@ -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")

View file

@ -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