Made dialog a separate view

This commit is contained in:
2024-06-24 12:04:29 -07:00
parent 89b82333bb
commit 223b4aa1dc
7 changed files with 1568 additions and 67 deletions

View File

@@ -14,12 +14,12 @@ font_size = 32
outline_size = 5
outline_color = Color(0, 0, 0, 1)
[sub_resource type="Gradient" id="5"]
[sub_resource type="Gradient" id="Gradient_itcyp"]
offsets = PackedFloat32Array(0, 0.0820312)
colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1)
[sub_resource type="GradientTexture2D" id="6"]
gradient = SubResource("5")
gradient = SubResource("Gradient_itcyp")
width = 2372
height = 1239
@@ -36,7 +36,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0.1, 0.5),
"transitions": PackedFloat32Array(1, 3.13834),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
"values": [Color(1, 1, 1, 0.368627), Color(1, 1, 1, 0)]
}
[sub_resource type="Animation" id="8"]
@@ -110,6 +110,6 @@ position_smoothing_speed = 0.5
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Node2D2" parent="CanvasLayer" instance=ExtResource("7_fj12q")]
[node name="dialogue" parent="." instance=ExtResource("7_fj12q")]
position = Vector2(328, 106)
scale = Vector2(0.75, 0.75)

View File

@@ -26,13 +26,15 @@ class Say:
var text
var subject : Node2D = null
var done = false
var stop = true
var started = false
var t
func step_type():
return "Say " + text
func init(scene):
super(scene)
subject.play_animation("talk", 0)
#subject.play_animation("talk", 0)
func do(delta):
if !started:
@@ -43,15 +45,18 @@ class Say:
subject.add_child(t)
var label: Label = subject.find_child("talk-label")
label.set_text(text)
subject.find_child("label-root").show()
print ("SHOWING")
#label.set_text(text)
#subject.find_child("label-root").show()
await scene.find_child("dialogue").say(text)
print ("SHOWING" + text)
await t.timeout
print ("HIDING")
print ("HIDING" + text)
subject.remove_child(t)
subject.find_child("label-root").hide()
subject.stop_animation()
subject.play_animation_raw("idle_" + subject.facing)
if stop:
await scene.find_child("dialogue").done_say()
#subject.find_child("label-root").hide()
#subject.stop_animation()
#subject.play_animation_raw("idle_" + subject.facing)
done = true
started = true
@@ -327,10 +332,11 @@ func walk_path(subject, path):
walk_to.path = path
return walk_to
func say(subject, text):
func say(subject, text, stop=true):
var say = Say.new()
say.subject = subject
say.text = text
say.stop = stop
return say
func walk_to_deferred(named_from, named_to):

File diff suppressed because one or more lines are too long

27
portrait.gd Normal file
View File

@@ -0,0 +1,27 @@
extends Node2D
@onready var animplayer:AnimationPlayer = $SubViewport/Fade/AnimationPlayer
# Called when the node enters the scene tree for the first time.
func _ready():
$CanvasLayer.hide()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func say(line):
if !$CanvasLayer.visible:
animplayer.play("fade_in")
await get_tree().process_frame
$CanvasLayer.show()
await animplayer.animation_finished
$"SubViewport/talk-label".text = line
func done_say():
$"SubViewport/talk-label".text = ""
animplayer.play_backwards("fade_in")
await animplayer.animation_finished
$CanvasLayer.hide()

22
portrait.gdshader Normal file
View File

@@ -0,0 +1,22 @@
shader_type canvas_item;
void fragment() {
vec4 col = texture(TEXTURE, UV) * 0.16;
col += texture(TEXTURE, UV + vec2(TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.075;
col += texture(TEXTURE, UV + vec2(-TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.075;
col += texture(TEXTURE, UV + vec2(2.0 * TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.06;
col += texture(TEXTURE, UV + vec2(2.0 * -TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.06;
col += texture(TEXTURE, UV + vec2(3.0 * TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.045;
col += texture(TEXTURE, UV + vec2(3.0 * -TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.045;
col += texture(TEXTURE, UV + vec2(4.0 * TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.025;
col += texture(TEXTURE, UV + vec2(4.0 * -TEXTURE_PIXEL_SIZE.x, 0.0)) * 0.025;
col += texture(TEXTURE, UV + vec2(0.0, TEXTURE_PIXEL_SIZE.y)) * 0.075;
col += texture(TEXTURE, UV + vec2(0.0, -TEXTURE_PIXEL_SIZE.y)) * 0.075;
col += texture(TEXTURE, UV + vec2(0.0, 2.0 * TEXTURE_PIXEL_SIZE.y)) * 0.06;
col += texture(TEXTURE, UV + vec2(0.0, 2.0 * -TEXTURE_PIXEL_SIZE.y)) * 0.06;
col += texture(TEXTURE, UV + vec2(0.0, 3.0 * TEXTURE_PIXEL_SIZE.y)) * 0.045;
col += texture(TEXTURE, UV + vec2(0.0, 3.0 * -TEXTURE_PIXEL_SIZE.y)) * 0.045;
col += texture(TEXTURE, UV + vec2(0.0, 4.0 * TEXTURE_PIXEL_SIZE.y)) * 0.025;
col += texture(TEXTURE, UV + vec2(0.0, 4.0 * -TEXTURE_PIXEL_SIZE.y)) * 0.025;
COLOR = col;
}

File diff suppressed because one or more lines are too long

View File

@@ -26,7 +26,7 @@ func _on_entered_from_pasture():
func _on_entranceexit_interacted():
start_main_script(ScriptBuilder.init(
ScriptBuilder.say(self.ego, "Looks light a hot air balloon.")
ScriptBuilder.say(self.ego, "Looks light a hot air balloon.", false)
)
.and_then(ScriptBuilder.say(self.ego, "Just like gramps"))
.build(self, "_on_script_complete"))