got general dialogue to work

This commit is contained in:
Bram Dingelstad 2021-11-20 12:20:33 +01:00
parent cde04c66ac
commit d5e515e4c1
8 changed files with 67 additions and 36 deletions

View file

@ -3,5 +3,33 @@ extends Control
func _ready():
pass
func continue_dialogue():
if $Tween.is_active():
$Tween.remove_all()
$RichTextLabel.percent_visible = 1.0
return
$Wol.resume()
func _on_Wol_line(line):
prints('got a line', line)
print(var2str(line))
$RichTextLabel.text = line.text
$Tween.remove_all()
$Tween.interpolate_property(
$RichTextLabel,
'percent_visible',
.0,
1.0,
.02 * line.text.length()
)
$Tween.start()
func _on_Wol_options(options):
prints('got some options', options)
func _input(event):
if event is InputEventKey and event.scancode == KEY_ENTER and event.pressed:
print('Pressed enter!')
continue_dialogue()

View file

@ -28,6 +28,9 @@ custom_fonts/normal_font = ExtResource( 1 )
text = "Here is where the dialogue will go.
Run the scene in order to see how \"wol\" works."
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
@ -45,4 +48,7 @@ margin_bottom = 66.0
custom_fonts/font = ExtResource( 1 )
text = "This is a dialogue option"
[node name="Tween" type="Tween" parent="."]
[connection signal="line" from="Wol" to="." method="_on_Wol_line"]
[connection signal="options" from="Wol" to="." method="_on_Wol_options"]

View file

@ -68,7 +68,9 @@ func set_path(_path):
path = _path
func _handle_line(line):
call_deferred('emit_signal', 'line', line)
var id = line.id
var string = program.wolStrings[id]
call_deferred('emit_signal', 'line', string)
return WolGlobals.HandlerState.PauseExecution
func _handle_command(command):

View file

@ -1,7 +1,8 @@
extends Object
# class_name DialogueLine
var id : String
var substitutions : Array = []#String
var id = ''
var substitutions = []
func _init(id: String):
func _init(id):
self.id = id

View file

@ -1,16 +1,16 @@
extends Object
class_name WolLine
var text : String
var nodeName : String
var lineNumber : int
var fileName : String
var implicit : bool
var meta : Array = []
func _init(text:String, nodeName:String, lineNumber:int, fileName:String, implicit:bool, meta:Array):
self.text = text
self.nodeName = nodeName
self.fileName = fileName
self.implicit = implicit
self.meta = meta
var text = ''
var nodeName = ''
var lineNumber = -1
var fileName = ''
var implicit = false
var meta = []
func _init(text, nodeName, lineNumber, fileName, implicit, meta):
self.text = text
self.nodeName = nodeName
self.fileName = fileName
self.implicit = implicit
self.meta = meta

View file

@ -1,19 +1,12 @@
extends Node
var programName : String
var wolStrings : Dictionary = {}
var wolNodes : Dictionary = {}
var programName = ''
var wolStrings = {}
var wolNodes = {}
func get_node_tags(name:String)->Array:
func get_node_tags(name):
return wolNodes[name].tags
func get_wol_string(key:String)->String:
return wolStrings[key]
func get_node_text(name:String)->String:
var key = wolNodes[name].sourceId
return get_wol_string(key)
#possible support for line tags
func get_untagged_strings()->Dictionary:
return {}
@ -25,6 +18,5 @@ func include(other):
pass
func dump(library):
print("not yet implemented")
pass

View file

@ -265,6 +265,7 @@ func run_instruction(instruction)->bool:
var name : String = instruction.operands[0].value
var loaded = _dialogue._variableStorage.get_value(name)
_state.push_value(loaded)
WolGlobals.ByteCode.StoreVariable:
#store top stack value to variable
var top = _state.peek_value()
@ -298,13 +299,14 @@ func run_instruction(instruction)->bool:
# add an option to current state
var key = instruction.operands[0].value
var line = Line.new(key, _program.wolStrings[key])
var line = Line.new(key)
if instruction.operands.size() > 2:
pass #formated text options
# line to show and node name
_state.currentOptions.append(SimpleEntry.new(line,instruction.operands[1].value))
WolGlobals.ByteCode.ShowOptions:
#show options - stop if none
if _state.currentOptions.size() == 0:

View file

@ -6,7 +6,7 @@ position: -1892,-1013
<<load_situation The Revolver>>
<<animation elevator door open>>
Masami: Gina, this way!
Masami: Gina, this way! #line:5d7a7c
Gina: Patience! Im coming.
>Still, she didnt pick up her pace and kept hesitantly looking around.<
Masami: Everything should be fine, lets just go. We won.
@ -14,7 +14,7 @@ Masami: Unless you are planning on backstabbing me at the finish line, that is.
Gina: How funny. You are not that special.
Masami: Har har. Now start walking or Ill carry you out the front door.
Masami: I dont want to give Monokuma the time to come up with a new death game for two while we are trying to get through the exit.
Gina:
Gina: ...
<<zoom to vault door>>
@ -29,8 +29,8 @@ Masami: The reception desk?
<<zoom to gun>>
Masami: A paper and
Masami: Thats a gun.
Masami: A paper and...
Masami: ... Thats a gun.
Gina: A revolver, in fact. Such an old fashioned choice of firearm. Though, I appreciate the aesthetic. How pretty.
Masami: I dont like this. Why is it here?
>I took the paper from the table and briskly unfolded it.<