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:
Tony Bark 2021-05-20 15:05:58 -04:00
parent 80adf6b1d5
commit addbf91a36
8 changed files with 227 additions and 99 deletions

6
dialog/cityplanner.json Normal file
View file

@ -0,0 +1,6 @@
{
"1": {
"name": "Roll up your sleeves, Mayor!",
"text": "Welcome to City Limits! I'm Zack, and I'll be your city planner."
}
}

0
docs/.gdignore Normal file
View file

View file

@ -12,10 +12,9 @@ script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": true
}
dialogue_file = "res://dialog/cityplanner.json"
advisor_name = "Zack Casey"
rank = "City Planner"
title = "Welcome!"
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis facilisis purus. Donec hendrerit lectus ex, eget feugiat felis egestas a. Proin ut ornare libero. Mauris non maximus sapien. Ut gravida, metus quis finibus suscipit, lacus ante lobortis libero, sed faucibus lacus nulla hendrerit magna. Nunc tempus purus vel lectus sollicitudin faucibus ut non magna. Pellentesque id varius eros, nec dapibus tellus. Sed vitae lacus dignissim, malesuada est eget, rhoncus velit."
avatar = ExtResource( 1 )
[node name="Container" type="HSplitContainer" parent="."]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=21 format=2]
[gd_scene load_steps=29 format=2]
[ext_resource path="res://scenes/Map.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/Advise.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/advisors/Advise.tscn" type="PackedScene" id=2]
[ext_resource path="res://scripts/city_status.gd" type="Script" id=3]
[ext_resource path="res://sprites/ui/icpolhi.png" type="Texture" id=4]
[ext_resource path="res://sprites/ui/iccom.png" type="Texture" id=5]
@ -20,6 +20,14 @@
[ext_resource path="res://sprites/ui/iccoalhi.png" type="Texture" id=18]
[ext_resource path="res://sprites/ui/iccoal.png" type="Texture" id=19]
[ext_resource path="res://scripts/game.gd" type="Script" id=20]
[ext_resource path="res://sprites/ui/demandg.png" type="Texture" id=21]
[ext_resource path="res://sprites/ui/icparkhi.png" type="Texture" id=22]
[ext_resource path="res://sprites/ui/icnuc.png" type="Texture" id=23]
[ext_resource path="res://sprites/ui/icpark.png" type="Texture" id=24]
[ext_resource path="res://sprites/ui/icnuchi.png" type="Texture" id=25]
[ext_resource path="res://sprites/ui/icseap.png" type="Texture" id=26]
[ext_resource path="res://sprites/ui/icseaphi.png" type="Texture" id=27]
[ext_resource path="res://sprites/ui/icstad.png" type="Texture" id=28]
[node name="Game" type="Node2D"]
script = ExtResource( 20 )
@ -33,11 +41,13 @@ autostart = true
[node name="Controls" type="CanvasLayer" parent="."]
[node name="GUI" type="Control" parent="Controls"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 0.518677
anchor_left = -0.000731155
anchor_top = -0.000954026
anchor_right = 0.999269
anchor_bottom = 0.999044
margin_left = -0.172424
margin_top = 2.77234
margin_right = 0.518677
margin_right = -0.172424
margin_bottom = 2.77234
__meta__ = {
"_edit_use_anchors_": false
@ -45,88 +55,114 @@ __meta__ = {
[node name="AdvsiorNotice" parent="Controls/GUI" instance=ExtResource( 2 )]
[node name="Status" type="Panel" parent="Controls/GUI"]
anchor_left = 0.540039
anchor_top = 0.825
anchor_right = 1.00781
anchor_bottom = 1.01167
[node name="StatusPanel" type="Panel" parent="Controls/GUI"]
anchor_left = 0.517578
anchor_top = 0.830002
anchor_right = 0.640625
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": true
}
[node name="Cotnainer" type="HSplitContainer" parent="Controls/GUI/Status"]
[node name="StatusCtr" type="CenterContainer" parent="Controls/GUI/StatusPanel"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 4.0
dragger_visibility = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Status" type="VBoxContainer" parent="Controls/GUI/Status/Cotnainer"]
[node name="StatBox" type="HBoxContainer" parent="Controls/GUI/StatusPanel/StatusCtr"]
margin_left = 8.0
margin_top = 25.0
margin_right = 117.0
margin_bottom = 75.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="InfoBox" type="VBoxContainer" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox"]
margin_right = 66.0
margin_bottom = 108.0
margin_bottom = 50.0
alignment = 1
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CityNameLbl" type="Label" parent="Controls/GUI/Status/Cotnainer/Status"]
margin_top = 29.0
[node name="CityNameLbl" type="Label" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox/InfoBox"]
margin_right = 66.0
margin_bottom = 43.0
margin_bottom = 14.0
text = "City Name"
align = 1
[node name="YearLbl" type="Label" parent="Controls/GUI/Status/Cotnainer/Status"]
margin_top = 47.0
[node name="YearLbl" type="Label" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox/InfoBox"]
margin_top = 18.0
margin_right = 66.0
margin_bottom = 61.0
text = "2000"
margin_bottom = 32.0
text = "Y1980"
align = 1
[node name="Money" type="HBoxContainer" parent="Controls/GUI/Status/Cotnainer/Status"]
margin_top = 65.0
[node name="Money" type="HBoxContainer" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox/InfoBox"]
margin_top = 36.0
margin_right = 66.0
margin_bottom = 79.0
margin_bottom = 50.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CurrencyLbl" type="Label" parent="Controls/GUI/Status/Cotnainer/Status/Money"]
[node name="CurrencyLbl" type="Label" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox/InfoBox/Money"]
margin_left = 23.0
margin_right = 30.0
margin_bottom = 14.0
text = "§"
[node name="MoneyLbl" type="Label" parent="Controls/GUI/Status/Cotnainer/Status/Money"]
[node name="MoneyLbl" type="Label" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox/InfoBox/Money"]
margin_left = 34.0
margin_right = 42.0
margin_bottom = 14.0
text = "0"
[node name="Toolbar" type="Panel" parent="Controls/GUI/Status/Cotnainer"]
margin_left = 78.0
margin_right = 471.0
margin_bottom = 108.0
[node name="RciBox" type="CenterContainer" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox"]
margin_left = 70.0
margin_right = 109.0
margin_bottom = 50.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Tabs" type="TabContainer" parent="Controls/GUI/Status/Cotnainer/Toolbar"]
anchor_left = 0.00118311
anchor_top = 0.0191102
anchor_right = 1.00118
anchor_bottom = 1.01911
margin_top = -4.76837e-07
[node name="RciBtn" type="TextureButton" parent="Controls/GUI/StatusPanel/StatusCtr/StatBox/RciBox"]
margin_top = 1.0
margin_right = 39.0
margin_bottom = 48.0
texture_normal = ExtResource( 21 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BuyPanel" type="Panel" parent="Controls/GUI"]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -370.0
margin_top = -101.999
margin_right = -0.000244141
margin_bottom = 0.00109863
__meta__ = {
"_edit_use_anchors_": true
}
[node name="Zones" type="Tabs" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs"]
[node name="Tabs" type="TabContainer" parent="Controls/GUI/BuyPanel"]
anchor_left = 0.00144509
anchor_top = -0.0294118
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": true
}
[node name="Zones" type="Tabs" parent="Controls/GUI/BuyPanel/Tabs"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
@ -134,34 +170,34 @@ margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
[node name="ZoneCtr" type="HBoxContainer" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Zones"]
[node name="ZonesCtr" type="HBoxContainer" parent="Controls/GUI/BuyPanel/Tabs/Zones"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ResBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Zones/ZoneCtr"]
[node name="ResBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Zones/ZonesCtr"]
margin_right = 34.0
margin_bottom = 71.0
margin_bottom = 69.0
texture_normal = ExtResource( 9 )
texture_pressed = ExtResource( 10 )
[node name="ComBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Zones/ZoneCtr"]
[node name="ComBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Zones/ZonesCtr"]
margin_left = 38.0
margin_right = 72.0
margin_bottom = 71.0
margin_bottom = 69.0
texture_normal = ExtResource( 5 )
texture_pressed = ExtResource( 8 )
[node name="IndBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Zones/ZoneCtr"]
[node name="IndBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Zones/ZonesCtr"]
margin_left = 76.0
margin_right = 110.0
margin_bottom = 71.0
margin_bottom = 69.0
texture_normal = ExtResource( 13 )
texture_pressed = ExtResource( 12 )
[node name="Depts" type="Tabs" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs"]
[node name="Small" type="Tabs" parent="Controls/GUI/BuyPanel/Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
@ -170,48 +206,77 @@ margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
[node name="DepCtr" type="HBoxContainer" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Depts"]
anchor_left = -0.00119347
anchor_right = 0.998807
[node name="SmallCtr" type="HBoxContainer" parent="Controls/GUI/BuyPanel/Tabs/Small"]
anchor_right = 1.0
anchor_bottom = 1.41667
margin_bottom = -10.0
__meta__ = {
"_edit_use_anchors_": true
}
[node name="PoliceBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Small/SmallCtr"]
margin_right = 34.0
margin_bottom = 34.0
texture_normal = ExtResource( 4 )
texture_pressed = ExtResource( 16 )
[node name="FireBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Small/SmallCtr"]
margin_left = 38.0
margin_right = 72.0
margin_bottom = 34.0
texture_normal = ExtResource( 6 )
texture_pressed = ExtResource( 11 )
[node name="ParkBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Small/SmallCtr"]
margin_left = 76.0
margin_right = 110.0
margin_bottom = 34.0
texture_normal = ExtResource( 24 )
texture_pressed = ExtResource( 22 )
[node name="Large" type="Tabs" parent="Controls/GUI/BuyPanel/Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
[node name="LargeCtr" type="HBoxContainer" parent="Controls/GUI/BuyPanel/Tabs/Large"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PoliceBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Depts/DepCtr"]
margin_right = 34.0
margin_bottom = 75.0
texture_normal = ExtResource( 4 )
texture_pressed = ExtResource( 16 )
[node name="TextureButton" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Large/LargeCtr"]
margin_right = 42.0
margin_bottom = 69.0
texture_normal = ExtResource( 28 )
[node name="FireBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Depts/DepCtr"]
margin_left = 38.0
margin_right = 72.0
margin_bottom = 75.0
texture_normal = ExtResource( 6 )
texture_pressed = ExtResource( 11 )
[node name="TextureButton2" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Large/LargeCtr"]
margin_left = 46.0
margin_right = 88.0
margin_bottom = 69.0
texture_normal = ExtResource( 26 )
texture_pressed = ExtResource( 27 )
[node name="Power" type="Tabs" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
[node name="NuclearBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Large/LargeCtr"]
margin_left = 92.0
margin_right = 134.0
margin_bottom = 69.0
texture_normal = ExtResource( 23 )
texture_pressed = ExtResource( 25 )
[node name="PowerCtr" type="HBoxContainer" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Power"]
margin_right = 40.0
margin_bottom = 40.0
[node name="CoalBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Power/PowerCtr"]
margin_left = 75.7088
margin_right = 117.709
margin_bottom = 75.0
[node name="CoalBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Large/LargeCtr"]
margin_left = 138.0
margin_right = 180.0
margin_bottom = 69.0
texture_normal = ExtResource( 19 )
texture_pressed = ExtResource( 18 )
[node name="Tools" type="Tabs" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs"]
[node name="Tools" type="Tabs" parent="Controls/GUI/BuyPanel/Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
@ -220,23 +285,23 @@ margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
[node name="ToolsCtr" type="HBoxContainer" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Tools"]
anchor_right = 5.875
anchor_bottom = 2.45833
[node name="ToolsCtr" type="HBoxContainer" parent="Controls/GUI/BuyPanel/Tabs/Tools"]
anchor_right = 1.33228
anchor_bottom = 2.83333
__meta__ = {
"_edit_use_anchors_": true
}
[node name="InfoBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Tools/ToolsCtr"]
[node name="InfoBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Tools/ToolsCtr"]
margin_right = 34.0
margin_bottom = 59.0
margin_bottom = 68.0
texture_normal = ExtResource( 15 )
texture_pressed = ExtResource( 14 )
[node name="BulldozeBtn" type="TextureButton" parent="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Tools/ToolsCtr"]
[node name="BulldozeBtn" type="TextureButton" parent="Controls/GUI/BuyPanel/Tabs/Tools/ToolsCtr"]
margin_left = 38.0
margin_right = 72.0
margin_bottom = 59.0
margin_bottom = 68.0
texture_normal = ExtResource( 17 )
texture_pressed = ExtResource( 7 )
__meta__ = {
@ -244,5 +309,5 @@ __meta__ = {
}
[connection signal="timeout" from="Quarters" to="." method="_on_Quarters_timeout"]
[connection signal="pressed" from="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Zones/ZoneCtr/ResBtn" to="Map" method="_on_ResBtn_pressed"]
[connection signal="pressed" from="Controls/GUI/Status/Cotnainer/Toolbar/Tabs/Power/PowerCtr/CoalBtn" to="Map" method="_on_CoalBtn_pressed"]
[connection signal="pressed" from="Controls/GUI/BuyPanel/Tabs/Zones/ZonesCtr/ResBtn" to="Map" method="_on_ResBtn_pressed"]
[connection signal="pressed" from="Controls/GUI/BuyPanel/Tabs/Large/LargeCtr/CoalBtn" to="Map" method="_on_CoalBtn_pressed"]

View file

@ -4,7 +4,7 @@
[ext_resource path="res://sprites/coal.png" type="Texture" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 24.1295, 23.9406 )
extents = Vector2( 32.2297, 31.8602 )
[sub_resource type="Animation" id=2]
resource_name = "Animante"

34
screenshot.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/screenshot.png-024a21af5d37bf0f0dd0e2bccdd149d0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://screenshot.png"
dest_files=[ "res://.import/screenshot.png-024a21af5d37bf0f0dd0e2bccdd149d0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

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

View file

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