mirror of
https://github.com/tonytins/citylimits
synced 2025-06-25 09:24:44 -04:00
Json-based dialog
- Json-based dialog using code from the JRPG demo - Moved advisor scenes to their own directory - Year now has a "Y" prefix - Docs directory
This commit is contained in:
parent
80adf6b1d5
commit
addbf91a36
8 changed files with 227 additions and 99 deletions
|
@ -1,19 +1,43 @@
|
|||
extends AcceptDialog
|
||||
|
||||
export(String, FILE, "*.json") var dialogue_file
|
||||
export var advisor_name: String
|
||||
export var rank: String
|
||||
export(Texture) var avatar
|
||||
export var dialog = 0
|
||||
|
||||
var dialogue_keys = []
|
||||
var dialogue_name = ""
|
||||
var dialogue_text = ""
|
||||
|
||||
onready var avatar_texture = $Container/Advisor/Avatar
|
||||
onready var rank_label = $Container/Advisor/RankLbl
|
||||
onready var name_label = $Container/Advisor/NameLbl
|
||||
onready var description_label = $Container/DescriptionLbl
|
||||
|
||||
export var advisor_name: String
|
||||
export var rank: String
|
||||
export var title: String
|
||||
export(String, MULTILINE) var description
|
||||
export(Texture) var avatar
|
||||
func start_dialogue():
|
||||
index_dialogue()
|
||||
description_label.text = dialogue_keys[dialog].text
|
||||
self.window_title = dialogue_keys[dialog].name
|
||||
|
||||
|
||||
func index_dialogue():
|
||||
var dialogue = load_dialogue(dialogue_file)
|
||||
dialogue_keys.clear()
|
||||
for key in dialogue:
|
||||
dialogue_keys.append(dialogue[key])
|
||||
|
||||
func load_dialogue(file_path):
|
||||
var file = File.new()
|
||||
if file.file_exists(file_path):
|
||||
file.open(file_path, file.READ)
|
||||
var dialogue = parse_json(file.get_as_text())
|
||||
return dialogue
|
||||
|
||||
func _ready():
|
||||
self.window_title = title
|
||||
description_label.text = description
|
||||
load_dialogue(dialogue_file)
|
||||
self.show()
|
||||
start_dialogue()
|
||||
avatar_texture.texture = avatar
|
||||
name_label.text = advisor_name
|
||||
rank_label.text = rank
|
||||
|
|
|
@ -9,4 +9,4 @@ func _ready():
|
|||
|
||||
func _process(delta):
|
||||
money.text = str(SimData.budget)
|
||||
year.text = str(SimData.year)
|
||||
year.text = "Y" + str(SimData.year)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue