Working dialogue system
This commit is contained in:
parent
7134891e55
commit
c0c68c8662
16 changed files with 267 additions and 103 deletions
7
scripts/Base/Menu/dialogue.gd
Normal file
7
scripts/Base/Menu/dialogue.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
extends NinePatchRect
|
||||
|
||||
@onready var dialogue = $DialogueView
|
||||
|
||||
func send_message(msg: Message):
|
||||
var new_msg = tr(msg.fact + "_RECEIVED")
|
||||
dialogue.append_text(new_msg)
|
||||
|
|
@ -1,7 +1,19 @@
|
|||
extends MenuAction
|
||||
|
||||
class_name MessageSenderAction
|
||||
|
||||
var dialogue
|
||||
## Message which will be send on click
|
||||
var msg: Message
|
||||
|
||||
## Gets message and translates it on display.
|
||||
## Shown message should end with _LOCAL
|
||||
func _ready():
|
||||
var item_id = get_parent().menu.item_ids[id]
|
||||
msg = Message.create(item_id, tr(item_id + "_LOCAL"))
|
||||
text = msg.shown
|
||||
super._ready()
|
||||
|
||||
func action():
|
||||
dialogue.send_message(msg)
|
||||
get_parent().transit_menu(id)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ func load_menu():
|
|||
actions[i].set_script(menu.item_data[i].load_script())
|
||||
Menu.Action.ComboAction:
|
||||
actions[i].set_script(menu.item_data[i].load_script())
|
||||
actions[i].id = i
|
||||
if "id" in actions[i]:
|
||||
actions[i].id = i
|
||||
if "dialogue" in actions[i]:
|
||||
actions[i].dialogue = $"../../Dialogue"
|
||||
|
||||
## Called with transit_button, changes current menu
|
||||
func transit_menu(id: int):
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
class_name Message
|
||||
|
||||
## Fact value
|
||||
var fact: String
|
||||
@export var fact: String
|
||||
## Display value
|
||||
var shown: String
|
||||
@export var shown: String
|
||||
|
||||
## Returns message with set fact and shown strings
|
||||
static func create(fact: String, shown: String) -> Message:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue