mirror of
https://github.com/tonytins/citylimits.git
synced 2025-03-15 12:21:22 +00:00
Decoupling more hardcoded data
- Created a json helper to streamline decoupling of hardcoded data - Removed non-existent VR bridge reference - News ticker files are no longer hardcoded to the game. - Removed hardcoded city and mayor names using Json helper
This commit is contained in:
parent
f8a0f97767
commit
65cc08fab6
13 changed files with 309 additions and 417 deletions
4
json/saves/defualt.json
Normal file
4
json/saves/defualt.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"city": "Metropolis",
|
||||
"mayor": "Defacto"
|
||||
}
|
|
@ -4,4 +4,4 @@ With the exception of certain policies, the majority of the lore in City Limits
|
|||
|
||||
## Extra Lore
|
||||
|
||||
Additionally, I've added my own turn of events with the ``extra_lore.json`` file. Internally, this is known as "Caseyverse" and has a global node of the same name. That node is designed so the game can function without it through the use of the ``if_caseyverse()`` function (which checks for that json file, at the moment) and any future related functions that deal with events.
|
||||
Additionally, I've added my own turn of events with the ``extra_lore.json`` file. Internally, this is known as "Caseyverse" and has a global node of the same name. That node is designed so the game can function without it through the use of the ``is_caseyverse()`` function (which checks for that json file, at the moment) and any future related functions that deal with events.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"ticker": [
|
||||
"This Space For Rent.",
|
||||
"[outlet]: Don't Blame Us If You're Not Paying Attention",
|
||||
"[outlet]: Information With As Few Words As Possible.",
|
||||
"This Space For Rent.",
|
||||
"[outlet]: Properly Spelled Words From Beginning To End.",
|
||||
"[outlet]: Journalistic Integrity Without All The Advertising.",
|
||||
"[outlet]: No Advertisements Since Before The Beginning."
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
"competing_outlet": "Citizen Telegram",
|
||||
"ticker": [
|
||||
"Some cats look to [other_outlet] for answers behind Kitty Kibble shortage.",
|
||||
"Some cats look to [competing_outlet] for answers behind Kitty Kibble shortage.",
|
||||
"Kit Welsh awarded for his medical breakthroughs in [city].",
|
||||
"Ishard has frozen another one of Big Boston's numbers racket.",
|
||||
"Can Ishard solve the Kitty Kibble shortage?",
|
||||
"Who is Ishard? And where did he come from?",
|
||||
"Big Boston gets frozen in his tracks again thanks to Ishard."
|
||||
"Big Boston gets frozen in his tracks again thanks to Ishard.",
|
||||
"[competing_outlet] suggests that Ishard is a fraud.",
|
||||
"[competing_outlet] supports Kitty Kibble hoax theory, despite lack of evidence."
|
||||
]
|
||||
}
|
11
json/ticker/meta.json
Normal file
11
json/ticker/meta.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"primary_outlet": "Pawprint Press",
|
||||
"secondary_outlet": "FNN",
|
||||
"competing_outlet": "Citizen Telegram",
|
||||
"ticker_files": [
|
||||
"adverts.json",
|
||||
"sammy.json",
|
||||
"kittykibble.json",
|
||||
"citylife.json"
|
||||
]
|
||||
}
|
|
@ -22,8 +22,8 @@ SimData="*res://scripts/autoload/sim_data.gd"
|
|||
SimEvents="*res://scripts/autoload/sim_events.gd"
|
||||
SimTime="*res://scripts/autoload/sim_time.gd"
|
||||
ZoneData="*res://scripts/autoload/zone_data.gd"
|
||||
VRBridge="*res://scripts/autoload/vr_bridge.gd"
|
||||
Caseyverse="*res://scripts/autoload/caseyverse.gd"
|
||||
JsonHelper="*res://scripts/autoload/jsonhelper.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
262
scenes/game.tscn
262
scenes/game.tscn
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=45 format=2]
|
||||
[gd_scene load_steps=46 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/maps/MapOne.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://assets/ticker/pawprint-logo.svg" type="Texture" id=2]
|
||||
|
@ -44,6 +44,7 @@
|
|||
[ext_resource path="res://assets/symbols/fontawesome/city.svg" type="Texture" id=42]
|
||||
[ext_resource path="res://assets/symbols/fontawesome/envelope.svg" type="Texture" id=43]
|
||||
[ext_resource path="res://scenes/windows/Ordinance.tscn" type="PackedScene" id=44]
|
||||
[ext_resource path="res://scripts/ticker.gd" type="Script" id=45]
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
script = ExtResource( 20 )
|
||||
|
@ -55,24 +56,25 @@ __meta__ = {
|
|||
"_editor_description_": "Calculation based on: https://gaming.stackexchange.com/questions/110529/real-world-time-in-a-simcity-day-on-various-speeds"
|
||||
}
|
||||
|
||||
[node name="RotateNews" type="Timer" parent="."]
|
||||
wait_time = 5.0
|
||||
autostart = true
|
||||
|
||||
[node name="MapOne" parent="." instance=ExtResource( 1 )]
|
||||
|
||||
[node name="Controls" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Windows" type="Control" parent="Controls"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
[node name="Control Panel" type="Control" parent="Controls"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
script = ExtResource( 45 )
|
||||
|
||||
[node name="Windows" type="Control" parent="Controls/Control Panel"]
|
||||
anchor_right = 25.65
|
||||
anchor_bottom = 12.9
|
||||
script = ExtResource( 37 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="Console" parent="Controls/Windows" instance=ExtResource( 6 )]
|
||||
[node name="Console" parent="Controls/Control Panel/Windows" instance=ExtResource( 6 )]
|
||||
anchor_left = 0.590492
|
||||
anchor_top = 0.0604199
|
||||
anchor_right = 0.985023
|
||||
|
@ -80,9 +82,9 @@ anchor_bottom = 0.312087
|
|||
rect_min_size = Vector2( 400, 150 )
|
||||
resizable = true
|
||||
|
||||
[node name="CityPlanner" parent="Controls/Windows" instance=ExtResource( 4 )]
|
||||
[node name="CityPlanner" parent="Controls/Control Panel/Windows" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="TaxWindow" parent="Controls/Windows" instance=ExtResource( 32 )]
|
||||
[node name="TaxWindow" parent="Controls/Control Panel/Windows" instance=ExtResource( 32 )]
|
||||
visible = false
|
||||
anchor_left = 0.297863
|
||||
anchor_top = 0.409167
|
||||
|
@ -90,7 +92,7 @@ anchor_right = 0.702137
|
|||
anchor_bottom = 0.590833
|
||||
margin_bottom = 3.05176e-05
|
||||
|
||||
[node name="AdvisorMeet" parent="Controls/Windows" instance=ExtResource( 21 )]
|
||||
[node name="AdvisorMeet" parent="Controls/Control Panel/Windows" instance=ExtResource( 21 )]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
|
@ -100,7 +102,7 @@ margin_top = -138.5
|
|||
margin_right = 234.609
|
||||
margin_bottom = 138.5
|
||||
|
||||
[node name="ToolsWindow" type="WindowDialog" parent="Controls/Windows"]
|
||||
[node name="ToolsWindow" type="WindowDialog" parent="Controls/Control Panel/Windows"]
|
||||
anchor_left = 0.402435
|
||||
anchor_top = 0.315697
|
||||
anchor_right = 0.60263
|
||||
|
@ -110,53 +112,53 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="CenterCtr" type="CenterContainer" parent="Controls/Windows/ToolsWindow"]
|
||||
[node name="CenterCtr" type="CenterContainer" parent="Controls/Control Panel/Windows/ToolsWindow"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VertCtr" type="VBoxContainer" parent="Controls/Windows/ToolsWindow/CenterCtr"]
|
||||
[node name="VertCtr" type="VBoxContainer" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr"]
|
||||
margin_left = 12.0
|
||||
margin_top = 24.0
|
||||
margin_top = 9.0
|
||||
margin_right = 192.0
|
||||
margin_bottom = 196.0
|
||||
margin_bottom = 181.0
|
||||
|
||||
[node name="LargeCtr" type="HBoxContainer" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
[node name="LargeCtr" type="HBoxContainer" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
margin_right = 180.0
|
||||
margin_bottom = 42.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
[node name="TextureButton" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
margin_right = 42.0
|
||||
margin_bottom = 42.0
|
||||
texture_normal = ExtResource( 28 )
|
||||
|
||||
[node name="TextureButton2" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
[node name="TextureButton2" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
margin_left = 46.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 42.0
|
||||
texture_normal = ExtResource( 26 )
|
||||
texture_pressed = ExtResource( 27 )
|
||||
|
||||
[node name="NuclearBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
[node name="NuclearBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
margin_left = 92.0
|
||||
margin_right = 134.0
|
||||
margin_bottom = 42.0
|
||||
texture_normal = ExtResource( 23 )
|
||||
texture_pressed = ExtResource( 25 )
|
||||
|
||||
[node name="CoalBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
[node name="CoalBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/LargeCtr"]
|
||||
margin_left = 138.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 42.0
|
||||
texture_normal = ExtResource( 19 )
|
||||
texture_pressed = ExtResource( 18 )
|
||||
|
||||
[node name="SmallCtr" type="HBoxContainer" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
[node name="SmallCtr" type="HBoxContainer" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
margin_top = 46.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 80.0
|
||||
|
@ -164,27 +166,27 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="PoliceBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/SmallCtr"]
|
||||
[node name="PoliceBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/SmallCtr"]
|
||||
margin_right = 34.0
|
||||
margin_bottom = 34.0
|
||||
texture_normal = ExtResource( 29 )
|
||||
texture_pressed = ExtResource( 16 )
|
||||
|
||||
[node name="FireBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/SmallCtr"]
|
||||
[node name="FireBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/SmallCtr"]
|
||||
margin_left = 38.0
|
||||
margin_right = 72.0
|
||||
margin_bottom = 34.0
|
||||
texture_normal = ExtResource( 33 )
|
||||
texture_pressed = ExtResource( 11 )
|
||||
|
||||
[node name="ParkBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/SmallCtr"]
|
||||
[node name="ParkBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/SmallCtr"]
|
||||
margin_left = 76.0
|
||||
margin_right = 110.0
|
||||
margin_bottom = 34.0
|
||||
texture_normal = ExtResource( 24 )
|
||||
texture_pressed = ExtResource( 22 )
|
||||
|
||||
[node name="ToolsCtr" type="HBoxContainer" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
[node name="ToolsCtr" type="HBoxContainer" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
margin_top = 84.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 118.0
|
||||
|
@ -192,13 +194,13 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="InfoBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/ToolsCtr"]
|
||||
[node name="InfoBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/ToolsCtr"]
|
||||
margin_right = 34.0
|
||||
margin_bottom = 34.0
|
||||
texture_normal = ExtResource( 15 )
|
||||
texture_pressed = ExtResource( 14 )
|
||||
|
||||
[node name="BulldozeBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/ToolsCtr"]
|
||||
[node name="BulldozeBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/ToolsCtr"]
|
||||
margin_left = 38.0
|
||||
margin_right = 72.0
|
||||
margin_bottom = 34.0
|
||||
|
@ -208,7 +210,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ZonesCtr" type="HBoxContainer" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
[node name="ZonesCtr" type="HBoxContainer" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr"]
|
||||
margin_top = 122.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 172.0
|
||||
|
@ -216,29 +218,33 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ResBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/ZonesCtr"]
|
||||
[node name="ResBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/ZonesCtr"]
|
||||
margin_right = 34.0
|
||||
margin_bottom = 50.0
|
||||
texture_normal = ExtResource( 9 )
|
||||
texture_pressed = ExtResource( 10 )
|
||||
|
||||
[node name="ComBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/ZonesCtr"]
|
||||
[node name="ComBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/ZonesCtr"]
|
||||
margin_left = 38.0
|
||||
margin_right = 72.0
|
||||
margin_bottom = 50.0
|
||||
texture_normal = ExtResource( 5 )
|
||||
texture_pressed = ExtResource( 30 )
|
||||
|
||||
[node name="IndBtn" type="TextureButton" parent="Controls/Windows/ToolsWindow/CenterCtr/VertCtr/ZonesCtr"]
|
||||
[node name="IndBtn" type="TextureButton" parent="Controls/Control Panel/Windows/ToolsWindow/CenterCtr/VertCtr/ZonesCtr"]
|
||||
margin_left = 76.0
|
||||
margin_right = 110.0
|
||||
margin_bottom = 50.0
|
||||
texture_normal = ExtResource( 13 )
|
||||
texture_pressed = ExtResource( 12 )
|
||||
|
||||
[node name="Credits" parent="Controls/Windows" instance=ExtResource( 34 )]
|
||||
[node name="Credits" parent="Controls/Control Panel/Windows" instance=ExtResource( 34 )]
|
||||
anchor_left = 0.393762
|
||||
anchor_top = 0.292636
|
||||
anchor_right = 0.605263
|
||||
anchor_bottom = 0.78876
|
||||
|
||||
[node name="PauseIndicator" type="TextureRect" parent="Controls/Windows"]
|
||||
[node name="PauseIndicator" type="TextureRect" parent="Controls/Control Panel/Windows"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
@ -249,9 +255,9 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Ordinance" parent="Controls/Windows" instance=ExtResource( 44 )]
|
||||
[node name="Ordinance" parent="Controls/Control Panel/Windows" instance=ExtResource( 44 )]
|
||||
|
||||
[node name="VRMode" type="Button" parent="Controls/Windows"]
|
||||
[node name="VRMode" type="Button" parent="Controls/Control Panel/Windows"]
|
||||
visible = false
|
||||
anchor_left = 0.919922
|
||||
anchor_top = 0.0197812
|
||||
|
@ -262,15 +268,56 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="Status" type="Panel" parent="Controls/Windows"]
|
||||
anchor_top = 0.863333
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.00833
|
||||
[node name="NewsWindow" type="WindowDialog" parent="Controls/Control Panel/Windows"]
|
||||
visible = true
|
||||
anchor_left = 0.0877193
|
||||
anchor_top = 0.234496
|
||||
anchor_right = 0.69883
|
||||
anchor_bottom = 0.656977
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="SettingsBtn" type="Button" parent="Controls/Windows/Status"]
|
||||
[node name="News" type="ItemList" parent="Controls/Control Panel/Windows/NewsWindow"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = 53.0
|
||||
|
||||
[node name="Brand" type="HSplitContainer" parent="Controls/Control Panel/Windows/NewsWindow"]
|
||||
anchor_left = 0.0175719
|
||||
anchor_top = 0.0242718
|
||||
anchor_right = 0.982428
|
||||
anchor_bottom = 0.23301
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="NewsBrand" type="TextureRect" parent="Controls/Control Panel/Windows/NewsWindow/Brand"]
|
||||
margin_right = 288.0
|
||||
margin_bottom = 45.505
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="NewsMotto" type="Label" parent="Controls/Control Panel/Windows/NewsWindow/Brand"]
|
||||
margin_left = 300.0
|
||||
margin_top = 15.0
|
||||
margin_right = 604.964
|
||||
margin_bottom = 29.0
|
||||
align = 2
|
||||
valign = 1
|
||||
|
||||
[node name="Status" type="Panel" parent="Controls/Control Panel"]
|
||||
anchor_top = 12.95
|
||||
anchor_right = 25.65
|
||||
anchor_bottom = 15.25
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="RotateNews" type="Timer" parent="Controls/Control Panel/Status"]
|
||||
wait_time = 5.0
|
||||
autostart = true
|
||||
|
||||
[node name="SettingsBtn" type="Button" parent="Controls/Control Panel/Status"]
|
||||
anchor_left = 0.0115391
|
||||
anchor_top = 0.0555202
|
||||
anchor_right = 0.0525548
|
||||
|
@ -282,7 +329,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="StatCtr" type="HBoxContainer" parent="Controls/Windows/Status"]
|
||||
[node name="StatCtr" type="HBoxContainer" parent="Controls/Control Panel/Status"]
|
||||
anchor_left = 0.0566406
|
||||
anchor_top = 0.0750188
|
||||
anchor_right = 0.996094
|
||||
|
@ -294,90 +341,90 @@ __meta__ = {
|
|||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="ButtonCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr"]
|
||||
[node name="ButtonCtr" type="HBoxContainer" parent="Controls/Control Panel/Status/StatCtr"]
|
||||
margin_left = 233.0
|
||||
margin_right = 515.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
custom_constants/separation = 10
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TaxBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="TaxBtn" type="Button" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_right = 42.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
hint_tooltip = "RCI"
|
||||
size_flags_horizontal = 4
|
||||
icon = ExtResource( 40 )
|
||||
|
||||
[node name="ToolsBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="ToolsBtn" type="Button" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_left = 52.0
|
||||
margin_right = 94.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
hint_tooltip = "Tools"
|
||||
size_flags_horizontal = 4
|
||||
icon = ExtResource( 42 )
|
||||
|
||||
[node name="AdvsiorBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="AdvsiorBtn" type="Button" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_left = 104.0
|
||||
margin_right = 146.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
hint_tooltip = "Meet"
|
||||
size_flags_horizontal = 4
|
||||
icon = ExtResource( 43 )
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="VSeparator" type="VSeparator" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_left = 156.0
|
||||
margin_right = 160.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="TurtleBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="TurtleBtn" type="Button" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_left = 170.0
|
||||
margin_right = 211.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
hint_tooltip = "Slow"
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 8 )
|
||||
|
||||
[node name="CheetaBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="CheetaBtn" type="Button" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_left = 221.0
|
||||
margin_right = 268.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
hint_tooltip = "Fast"
|
||||
toggle_mode = true
|
||||
icon = ExtResource( 7 )
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="Controls/Windows/Status/StatCtr/ButtonCtr"]
|
||||
[node name="VSeparator2" type="VSeparator" parent="Controls/Control Panel/Status/StatCtr/ButtonCtr"]
|
||||
margin_left = 278.0
|
||||
margin_right = 282.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="NameDate" type="VBoxContainer" parent="Controls/Windows/Status/StatCtr"]
|
||||
[node name="NameDate" type="VBoxContainer" parent="Controls/Control Panel/Status/StatCtr"]
|
||||
margin_left = 565.0
|
||||
margin_right = 653.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
alignment = 1
|
||||
|
||||
[node name="CityNameLbl" type="Label" parent="Controls/Windows/Status/StatCtr/NameDate"]
|
||||
margin_top = 3.0
|
||||
[node name="CityNameLbl" type="Label" parent="Controls/Control Panel/Status/StatCtr/NameDate"]
|
||||
margin_top = 4.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 17.0
|
||||
margin_bottom = 18.0
|
||||
text = "City Name"
|
||||
align = 1
|
||||
|
||||
[node name="YearCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/NameDate"]
|
||||
margin_top = 21.0
|
||||
[node name="YearCtr" type="HBoxContainer" parent="Controls/Control Panel/Status/StatCtr/NameDate"]
|
||||
margin_top = 22.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 35.0
|
||||
margin_bottom = 36.0
|
||||
|
||||
[node name="CalIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/NameDate/YearCtr"]
|
||||
[node name="CalIcon" type="TextureRect" parent="Controls/Control Panel/Status/StatCtr/NameDate/YearCtr"]
|
||||
margin_right = 10.0
|
||||
margin_bottom = 14.0
|
||||
texture = ExtResource( 36 )
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="CalendarLbl" type="Label" parent="Controls/Windows/Status/StatCtr/NameDate/YearCtr"]
|
||||
[node name="CalendarLbl" type="Label" parent="Controls/Control Panel/Status/StatCtr/NameDate/YearCtr"]
|
||||
margin_left = 14.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 14.0
|
||||
|
@ -386,103 +433,58 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PopBudget" type="VBoxContainer" parent="Controls/Windows/Status/StatCtr"]
|
||||
[node name="PopBudget" type="VBoxContainer" parent="Controls/Control Panel/Status/StatCtr"]
|
||||
margin_left = 703.0
|
||||
margin_right = 729.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 40.0
|
||||
alignment = 1
|
||||
|
||||
[node name="BudgetCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/PopBudget"]
|
||||
margin_top = 3.0
|
||||
[node name="BudgetCtr" type="HBoxContainer" parent="Controls/Control Panel/Status/StatCtr/PopBudget"]
|
||||
margin_top = 4.0
|
||||
margin_right = 26.0
|
||||
margin_bottom = 17.0
|
||||
margin_bottom = 18.0
|
||||
|
||||
[node name="CoinsIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/PopBudget/BudgetCtr"]
|
||||
[node name="CoinsIcon" type="TextureRect" parent="Controls/Control Panel/Status/StatCtr/PopBudget/BudgetCtr"]
|
||||
margin_right = 14.0
|
||||
margin_bottom = 14.0
|
||||
texture = ExtResource( 41 )
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="BudgetLbl" type="Label" parent="Controls/Windows/Status/StatCtr/PopBudget/BudgetCtr"]
|
||||
[node name="BudgetLbl" type="Label" parent="Controls/Control Panel/Status/StatCtr/PopBudget/BudgetCtr"]
|
||||
margin_left = 18.0
|
||||
margin_right = 26.0
|
||||
margin_bottom = 14.0
|
||||
text = "0"
|
||||
|
||||
[node name="PopCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/PopBudget"]
|
||||
margin_top = 21.0
|
||||
[node name="PopCtr" type="HBoxContainer" parent="Controls/Control Panel/Status/StatCtr/PopBudget"]
|
||||
margin_top = 22.0
|
||||
margin_right = 26.0
|
||||
margin_bottom = 35.0
|
||||
margin_bottom = 36.0
|
||||
|
||||
[node name="PopIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/PopBudget/PopCtr"]
|
||||
[node name="PopIcon" type="TextureRect" parent="Controls/Control Panel/Status/StatCtr/PopBudget/PopCtr"]
|
||||
margin_right = 14.0
|
||||
margin_bottom = 14.0
|
||||
texture = ExtResource( 3 )
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="PopLbl" type="Label" parent="Controls/Windows/Status/StatCtr/PopBudget/PopCtr"]
|
||||
[node name="PopLbl" type="Label" parent="Controls/Control Panel/Status/StatCtr/PopBudget/PopCtr"]
|
||||
margin_left = 18.0
|
||||
margin_right = 26.0
|
||||
margin_bottom = 14.0
|
||||
text = "0"
|
||||
|
||||
[node name="NewsBtn" type="Button" parent="Controls/Windows/Status"]
|
||||
[node name="NewsBtn" type="Button" parent="Controls/Control Panel/Status"]
|
||||
anchor_left = 0.0078125
|
||||
anchor_top = 0.633158
|
||||
anchor_right = 0.989258
|
||||
anchor_bottom = 0.888972
|
||||
text = "News"
|
||||
flat = true
|
||||
align = 0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="NewsWindow" type="WindowDialog" parent="Controls/Windows"]
|
||||
anchor_left = 0.0878906
|
||||
anchor_top = 0.235
|
||||
anchor_right = 0.699219
|
||||
anchor_bottom = 0.578333
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="News" type="ItemList" parent="Controls/Windows/NewsWindow"]
|
||||
anchor_left = 0.0111821
|
||||
anchor_top = 0.23301
|
||||
anchor_right = 0.988818
|
||||
anchor_bottom = 0.961165
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="Brand" type="HSplitContainer" parent="Controls/Windows/NewsWindow"]
|
||||
anchor_left = 0.0175719
|
||||
anchor_top = 0.0242718
|
||||
anchor_right = 0.982428
|
||||
anchor_bottom = 0.23301
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="NewsBrand" type="TextureRect" parent="Controls/Windows/NewsWindow/Brand"]
|
||||
margin_right = 288.0
|
||||
margin_bottom = 43.0
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="NewsMotto" type="Label" parent="Controls/Windows/NewsWindow/Brand"]
|
||||
margin_left = 300.0
|
||||
margin_top = 14.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 28.0
|
||||
align = 2
|
||||
valign = 1
|
||||
|
||||
[connection signal="timeout" from="DayCycle" to="." method="_on_DayCycle_timeout"]
|
||||
[connection signal="timeout" from="RotateNews" to="Controls/Windows" method="_on_RotateNews_timeout"]
|
||||
[connection signal="pressed" from="Controls/Windows/VRMode" to="." method="_on_VRMode_pressed"]
|
||||
[connection signal="pressed" from="Controls/Windows/Status/StatCtr/ButtonCtr/TaxBtn" to="Controls/Windows" method="_on_TaxBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Windows/Status/StatCtr/ButtonCtr/ToolsBtn" to="Controls/Windows" method="_on_ToolsBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/Windows/Status/StatCtr/ButtonCtr/AdvsiorBtn" to="Controls/Windows" method="_on_AdvsiorBtn_pressed"]
|
||||
[connection signal="toggled" from="Controls/Windows/Status/StatCtr/ButtonCtr/TurtleBtn" to="." method="_on_TurtleBtn_toggled"]
|
||||
[connection signal="toggled" from="Controls/Windows/Status/StatCtr/ButtonCtr/CheetaBtn" to="." method="_on_CheetaBtn_toggled"]
|
||||
[connection signal="pressed" from="Controls/Windows/Status/NewsBtn" to="Controls/Windows" method="_on_NewsBtn_pressed"]
|
||||
[connection signal="timeout" from="Controls/Control Panel/Status/RotateNews" to="Controls/Control Panel" method="_on_RotateNews_timeout"]
|
||||
[connection signal="pressed" from="Controls/Control Panel/Status/NewsBtn" to="Controls/Control Panel" method="_on_NewsBtn_pressed"]
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
extends Node
|
||||
|
||||
const caseyverse_path = "res://json/ticker/extra_lore.json"
|
||||
const news_outlets = "res://json/ticker/extra_lore.json"
|
||||
const is_caseyverse_path = "res://is_caseyverse.txt"
|
||||
|
||||
func is_caseyverse():
|
||||
var file = File.new()
|
||||
if file.file_exists(is_caseyverse_path):
|
||||
return true
|
||||
|
||||
func competing_outlet():
|
||||
var file = File.new()
|
||||
if is_caseyverse():
|
||||
file.open(caseyverse_path, File.READ)
|
||||
var result = parse_json(file.get_as_text())
|
||||
return result["competing_outlet"]
|
||||
|
|
11
scripts/autoload/jsonhelper.gd
Normal file
11
scripts/autoload/jsonhelper.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends Node
|
||||
|
||||
func key_value(json_path, json_file, key, is_dictionary = false):
|
||||
var file = File.new()
|
||||
var news_outlets_path = str(json_path + json_file);
|
||||
if file.file_exists(news_outlets_path):
|
||||
file.open(news_outlets_path, File.READ)
|
||||
var result = parse_json(file.get_as_text())
|
||||
if is_dictionary == true:
|
||||
result.clear()
|
||||
return result[key]
|
|
@ -1,7 +1,10 @@
|
|||
extends Node
|
||||
|
||||
var city_name: String = "Furtropolis" # Hard-coded, for now
|
||||
var mayor_name: String = "Defecto"
|
||||
const DEFAULT_CITY = "defualt.json"
|
||||
const SAVE_PATH = "res://json/saves/"
|
||||
|
||||
var city_name: String = ""
|
||||
var mayor_name: String = ""
|
||||
var population: int = 0
|
||||
var budget: int = 20000
|
||||
var expenses: int
|
||||
|
@ -65,6 +68,13 @@ enum Ordinances {
|
|||
TIRE_RECYCLE
|
||||
}
|
||||
|
||||
func _ready():
|
||||
if city_name == "":
|
||||
city_name = JsonHelper.key_value(SAVE_PATH, DEFAULT_CITY, "city")
|
||||
|
||||
if mayor_name == "":
|
||||
mayor_name = JsonHelper.key_value(SAVE_PATH, DEFAULT_CITY, "mayor")
|
||||
|
||||
#func starting_budget(lev = Level.EASY):
|
||||
# match lev:
|
||||
# Level.EASY:
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
extends Node2D
|
||||
|
||||
onready var rotate_news = $RotateNews
|
||||
onready var day_cycle = $DayCycle
|
||||
onready var turtle_btn = $Controls/Status/StatCtr/ButtonCtr/TurtleBtn
|
||||
onready var cheeta_btn = $Controls/Status/StatCtr/ButtonCtr/CheetaBtn
|
||||
#onready var turtle_btn = $Controls/Status/StatCtr/ButtonCtr/TurtleBtn
|
||||
#onready var cheeta_btn = $Controls/Status/StatCtr/ButtonCtr/CheetaBtn
|
||||
|
||||
func _ready():
|
||||
SimEvents.connect("rotate_news", self, "_rotate_news")
|
||||
SimEvents.connect("send_alert", self, "_stop_news")
|
||||
|
||||
func _stop_news():
|
||||
rotate_news.stop()
|
||||
|
||||
func _resume_rotation():
|
||||
rotate_news.start()
|
||||
|
||||
func _on_DayCycle_timeout():
|
||||
|
||||
# Increment the number days until it reaches 30
|
||||
|
@ -35,16 +28,12 @@ func _on_DayCycle_timeout():
|
|||
if SimTime.prev_month == 12:
|
||||
SimTime.new_year()
|
||||
|
||||
func _on_TurtleBtn_toggled(button_pressed):
|
||||
if button_pressed:
|
||||
day_cycle.wait_time = 12
|
||||
cheeta_btn.pressed = false
|
||||
|
||||
func _on_CheetaBtn_toggled(button_pressed):
|
||||
if button_pressed:
|
||||
day_cycle.wait_time = 2
|
||||
turtle_btn.pressed = false
|
||||
|
||||
func _on_VRMode_pressed():
|
||||
# get_tree().change_scene("res://scenes/VR Game.tscn")
|
||||
pass
|
||||
#func _on_TurtleBtn_toggled(button_pressed):
|
||||
# if button_pressed:
|
||||
# day_cycle.wait_time = 12
|
||||
# cheeta_btn.pressed = false
|
||||
#
|
||||
#func _on_CheetaBtn_toggled(button_pressed):
|
||||
# if button_pressed:
|
||||
# day_cycle.wait_time = 2
|
||||
# turtle_btn.pressed = false
|
||||
|
|
|
@ -1,31 +1,52 @@
|
|||
#extends Panel
|
||||
#
|
||||
#const ticker_path = "res://json/ticker/"
|
||||
#
|
||||
#onready var ticker_text = $Ticker
|
||||
#
|
||||
#var news_file: String = ""
|
||||
#var rng = RandomNumberGenerator.new()
|
||||
#var all_news = []
|
||||
#var speices = [
|
||||
# "Cat",
|
||||
# "Fennec",
|
||||
# "Fox"
|
||||
#]
|
||||
#var json_files = [
|
||||
# "adverts.json",
|
||||
# "sammy.json",
|
||||
# "kittykibble.json"
|
||||
#]
|
||||
#
|
||||
#func _index_news():
|
||||
# var news = _load_json()
|
||||
# all_news.clear()
|
||||
# all_news = news["ticker"]
|
||||
#
|
||||
# randomize()
|
||||
# all_news.shuffle()
|
||||
#
|
||||
extends Control
|
||||
|
||||
const TICKER_PATH = "res://json/ticker/"
|
||||
const FNN_LOGO = "res://assets/ticker/fnn.png"
|
||||
const META_FILE = "meta.json"
|
||||
|
||||
onready var ticker_text = $Status/NewsBtn
|
||||
onready var ticker_box = $Windows/NewsWindow/News
|
||||
onready var ticker_window = $Windows/NewsWindow
|
||||
onready var news_brand = $Windows/NewsWindow/Brand/NewsBrand
|
||||
onready var news_motto = $Windows/NewsWindow/Brand/NewsMotto
|
||||
|
||||
var news_file: String = ""
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var all_news: Array = []
|
||||
var speices: Array = [
|
||||
"Cat",
|
||||
"Fennec",
|
||||
"Fox"
|
||||
]
|
||||
|
||||
var json_files: Array = []
|
||||
|
||||
func _load_json():
|
||||
var file = File.new()
|
||||
if file.file_exists(news_file):
|
||||
file.open(news_file, file.READ)
|
||||
var result = parse_json(file.get_as_text())
|
||||
return result
|
||||
|
||||
func _index_news():
|
||||
var news = _load_json()
|
||||
all_news.clear()
|
||||
all_news = news["ticker"]
|
||||
randomize()
|
||||
all_news.shuffle()
|
||||
|
||||
func _init():
|
||||
json_files = JsonHelper.key_value(TICKER_PATH, META_FILE, "ticker_files")
|
||||
|
||||
func _ready():
|
||||
if SimData.city_name == "Furtropolis" or "Furville":
|
||||
news_brand.texture = load(FNN_LOGO)
|
||||
|
||||
if Caseyverse.is_caseyverse():
|
||||
json_files.append("extra_lore.json")
|
||||
|
||||
_randomize_news(json_files)
|
||||
|
||||
#func _process(delta):
|
||||
# var prev_json_Files = json_files
|
||||
#
|
||||
|
@ -47,71 +68,79 @@
|
|||
# prev_json_Files = json_files
|
||||
# for files in city_life:
|
||||
# json_files.append(files)
|
||||
#
|
||||
#func _array_check(list1, list2):
|
||||
# for item in list1:
|
||||
# if item in list2:
|
||||
# return true
|
||||
#
|
||||
# return false
|
||||
#
|
||||
#func _load_json():
|
||||
# var file = File.new()
|
||||
# if file.file_exists(news_file):
|
||||
# file.open(news_file, file.READ)
|
||||
# var result = parse_json(file.get_as_text())
|
||||
# return result
|
||||
#
|
||||
#func _ready():
|
||||
# SimData.city_name = SimData.city_name.capitalize()
|
||||
# SimData.mayor_name = SimData.mayor_name.capitalize()
|
||||
# SimEvents.connect("send_alert", self, "_start_alert")
|
||||
# SimEvents.connect("rotate_news", self, "_rotate_news")
|
||||
# _random_news(json_files)
|
||||
#
|
||||
#func _start_alert(message):
|
||||
|
||||
func _array_check(list1, list2):
|
||||
for item in list1:
|
||||
if item in list2:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _start_alert(message):
|
||||
# if ticker_text.items.size() > 1:
|
||||
# ticker_text.clear()
|
||||
#
|
||||
# SimData.on_alert = true
|
||||
# news_file = str(ticker_path + "ticker_alerts.json")
|
||||
# news_file = str(TICKER_PATH + "ticker_alerts.json")
|
||||
# ticker_text.add_item(all_news)
|
||||
#
|
||||
#func _random_news(files: Array):
|
||||
# for file in files:
|
||||
# news_file = str(ticker_path + file)
|
||||
# _load_json()
|
||||
# _index_news()
|
||||
#
|
||||
# rng.randomize()
|
||||
# randomize()
|
||||
# all_news.shuffle()
|
||||
#
|
||||
# var news_range = rng.randi_range(0, all_news.size() - 1)
|
||||
# var news_text: String = all_news[news_range]
|
||||
#
|
||||
# if SimData.city_name == "Furtropolis" or "Furville" and "[outlet]" in news_text:
|
||||
# # FNN = Furtropolis/Furry News Network
|
||||
# news_text = news_text.replace("[outlet]", "FNN")
|
||||
# else:
|
||||
# news_text = news_text.replace("[outlet]", "Pawprint Press")
|
||||
#
|
||||
# if "[species]" in news_text:
|
||||
# speices.shuffle()
|
||||
# var speices_range = rng.randi_range(speices.size() - 1)
|
||||
# news_text = news_text.replace("[species]", speices[speices_range])
|
||||
#
|
||||
# if "[city]" in news_text:
|
||||
# news_text = news_text.replace("[city]", SimData.city_name)
|
||||
#
|
||||
# if "[mayor]" in news_text:
|
||||
# news_text = news_text.replace("[mayor]", SimData.mayor_name)
|
||||
#
|
||||
# if ticker_text.items.size() > 3:
|
||||
# ticker_text.clear()
|
||||
#
|
||||
# ticker_text.clear()
|
||||
# ticker_text.add_item(news_text)
|
||||
#
|
||||
#func _on_RotateNews_timeout():
|
||||
# _random_news(json_files)
|
||||
|
||||
pass
|
||||
|
||||
func _randomize_news(files: Array):
|
||||
for file in files:
|
||||
news_file = str(TICKER_PATH + file)
|
||||
_load_json()
|
||||
_index_news()
|
||||
|
||||
rng.randomize()
|
||||
randomize()
|
||||
files.shuffle()
|
||||
|
||||
var news_range = rng.randi_range(0, all_news.size() - 1)
|
||||
var news_text: String = all_news[news_range]
|
||||
|
||||
if Caseyverse.is_caseyverse():
|
||||
news_text = news_text.replace("[competing_outlet]", JsonHelper.key_value(TICKER_PATH, META_FILE, "competing_outlet"))
|
||||
|
||||
# If city name Furtropolis or Furville use Pawprint Press
|
||||
if SimData.city_name != "Furtropolis" or "Furville":
|
||||
news_text = news_text.replace("[outlet]", JsonHelper.key_value(TICKER_PATH, META_FILE, "secondary_outlet"))
|
||||
else:
|
||||
# FNN = Furtropolis/Furry News Network
|
||||
news_text = news_text.replace("[outlet]", JsonHelper.key_value(TICKER_PATH, META_FILE, "primary_outlet"))
|
||||
|
||||
if "[species]" in news_text:
|
||||
speices.shuffle()
|
||||
var speices_range = rng.randi_range(speices.size() - 1)
|
||||
news_text = news_text.replace("[species]", speices[speices_range])
|
||||
|
||||
if "[city]" in news_text:
|
||||
news_text = news_text.replace("[city]", SimData.city_name)
|
||||
|
||||
if "[mayor]" in news_text:
|
||||
news_text = news_text.replace("[mayor]", SimData.mayor_name)
|
||||
|
||||
if ticker_box.items.size() > 15:
|
||||
ticker_box.clear()
|
||||
|
||||
# Prevent duplicates
|
||||
var prev_news_text = ticker_text.text
|
||||
if news_text == prev_news_text:
|
||||
_randomize_news(json_files)
|
||||
else:
|
||||
json_files.shuffle()
|
||||
_add_news(news_text)
|
||||
|
||||
func _add_news(news_item):
|
||||
ticker_text.text = news_item
|
||||
ticker_box.add_item(news_item)
|
||||
|
||||
func _on_NewsBtn_pressed():
|
||||
ticker_window.show()
|
||||
|
||||
func _on_RotateNews_timeout():
|
||||
rng.randomize()
|
||||
randomize()
|
||||
all_news.shuffle()
|
||||
json_files.shuffle()
|
||||
_randomize_news(json_files)
|
||||
|
|
|
@ -5,175 +5,16 @@ onready var tax_window = $TaxWindow
|
|||
onready var advsior_meet_window = $AdvisorMeet
|
||||
onready var tools_window = $ToolsWindow
|
||||
|
||||
const ticker_path = "res://json/ticker/"
|
||||
const fnn_logo = "res://assets/ticker/fnn.png"
|
||||
|
||||
onready var ticker_text = $Status/NewsBtn
|
||||
onready var ticker_box = $NewsWindow/News
|
||||
onready var ticker_window = $NewsWindow
|
||||
onready var news_brand = $NewsWindow/Brand/NewsBrand
|
||||
onready var news_motto = $NewsWindow/Brand/NewsMotto
|
||||
|
||||
var other_outlet: String = ""
|
||||
var news_file: String = ""
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var all_news = []
|
||||
var speices = [
|
||||
"Cat",
|
||||
"Fennec",
|
||||
"Fox"
|
||||
]
|
||||
|
||||
var json_files = [
|
||||
"adverts.json",
|
||||
"sammy.json",
|
||||
"kittykibble.json",
|
||||
"citylife.json"
|
||||
]
|
||||
|
||||
func _competing_outlet():
|
||||
var file = File.new()
|
||||
var caseyverse_path = str(ticker_path + "caseyverse.json");
|
||||
if file.file_exists(caseyverse_path):
|
||||
file.open(caseyverse_path)
|
||||
var result = parse_json(file.get_as_text())
|
||||
result.clear()
|
||||
return result["competing_outlet"]
|
||||
|
||||
func _load_json():
|
||||
var file = File.new()
|
||||
if file.file_exists(news_file):
|
||||
file.open(news_file, file.READ)
|
||||
var result = parse_json(file.get_as_text())
|
||||
return result
|
||||
|
||||
func _index_news():
|
||||
var news = _load_json()
|
||||
all_news.clear()
|
||||
all_news = news["ticker"]
|
||||
randomize()
|
||||
all_news.shuffle()
|
||||
|
||||
func _ready():
|
||||
SimData.city_name = SimData.city_name.capitalize()
|
||||
SimData.mayor_name = SimData.mayor_name.capitalize()
|
||||
|
||||
if SimData.city_name == "Furtropolis" and Caseyverse.is_caseyverse():
|
||||
news_brand.texture = load(fnn_logo)
|
||||
|
||||
SimEvents.emit_signal("advisor_message", SimData.Advisors.CITY_PLANNER, 0)
|
||||
|
||||
SimEvents.connect("send_alert", self, "_start_alert")
|
||||
SimEvents.connect("rotate_news", self, "_rotate_news")
|
||||
|
||||
if Caseyverse.is_caseyverse():
|
||||
json_files.append("extra_lore.json")
|
||||
|
||||
_randomize_news(json_files)
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_pressed("ui_cheats"):
|
||||
debug_console.show()
|
||||
|
||||
var prev_json_Files = json_files
|
||||
|
||||
# var city_life = [
|
||||
# "citylife.json"
|
||||
# ]
|
||||
#
|
||||
# if _array_check(city_life, json_files):
|
||||
# match SimData.has_power:
|
||||
# true:
|
||||
# prev_json_Files = json_files
|
||||
# for files in city_life:
|
||||
# json_files.append(files)
|
||||
#
|
||||
# false:
|
||||
# prev_json_Files = json_files
|
||||
# for files in city_life:
|
||||
# json_files.remove(files)
|
||||
|
||||
|
||||
func _array_check(list1, list2):
|
||||
for item in list1:
|
||||
if item in list2:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _start_alert(message):
|
||||
# if ticker_text.items.size() > 1:
|
||||
# ticker_text.clear()
|
||||
#
|
||||
# SimData.on_alert = true
|
||||
# news_file = str(ticker_path + "ticker_alerts.json")
|
||||
# ticker_text.add_item(all_news)
|
||||
|
||||
pass
|
||||
|
||||
func _randomize_news(files: Array):
|
||||
for file in files:
|
||||
news_file = str(ticker_path + file)
|
||||
_load_json()
|
||||
_index_news()
|
||||
|
||||
rng.randomize()
|
||||
randomize()
|
||||
files.shuffle()
|
||||
|
||||
var news_range = rng.randi_range(0, all_news.size() - 1)
|
||||
var news_text: String = all_news[news_range]
|
||||
|
||||
if Caseyverse.is_caseyverse():
|
||||
news_text = news_text.replace("[other_outlet]", Caseyverse.competing_outlet())
|
||||
|
||||
if SimData.city_name == "Furtropolis" or "Furville" and Caseyverse.is_caseyverse():
|
||||
# FNN = Furtropolis/Furry News Network
|
||||
news_text = news_text.replace("[outlet]", "FNN")
|
||||
else:
|
||||
news_text = news_text.replace("[outlet]", "Pawprint Press")
|
||||
|
||||
if "[species]" in news_text:
|
||||
speices.shuffle()
|
||||
var speices_range = rng.randi_range(speices.size() - 1)
|
||||
news_text = news_text.replace("[species]", speices[speices_range])
|
||||
|
||||
if "[city]" in news_text:
|
||||
news_text = news_text.replace("[city]", SimData.city_name)
|
||||
|
||||
if "[mayor]" in news_text:
|
||||
news_text = news_text.replace("[mayor]", SimData.mayor_name)
|
||||
|
||||
if ticker_box.items.size() > 15:
|
||||
ticker_box.clear()
|
||||
|
||||
# Prevent duplicates
|
||||
var prev_news_text = ticker_text.text
|
||||
if news_text == prev_news_text:
|
||||
_randomize_news(json_files)
|
||||
else:
|
||||
json_files.shuffle()
|
||||
_add_news(news_text)
|
||||
|
||||
func _add_news(news_item):
|
||||
ticker_text.text = news_item
|
||||
ticker_box.add_item(news_item)
|
||||
|
||||
func _on_RotateNews_timeout():
|
||||
rng.randomize()
|
||||
randomize()
|
||||
all_news.shuffle()
|
||||
json_files.shuffle()
|
||||
_randomize_news(json_files)
|
||||
|
||||
func _on_TaxBtn_pressed():
|
||||
tax_window.show()
|
||||
|
||||
func _on_AdvsiorBtn_pressed():
|
||||
advsior_meet_window.show()
|
||||
|
||||
func _on_ToolsBtn_pressed():
|
||||
tools_window.show()
|
||||
|
||||
func _on_NewsBtn_pressed():
|
||||
ticker_window.show()
|
||||
|
|
Loading…
Add table
Reference in a new issue