diff --git a/.gdignore b/.gdignore new file mode 100644 index 0000000..20c56a4 --- /dev/null +++ b/.gdignore @@ -0,0 +1,2 @@ +**.md +screenshot.png \ No newline at end of file diff --git a/assets/fnn.png.import b/assets/fnn.png.import new file mode 100644 index 0000000..8176bd3 --- /dev/null +++ b/assets/fnn.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/fnn.png-4b0621cc5794588bb47068090a8f4966.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/fnn.png" +dest_files=[ "res://.import/fnn.png-4b0621cc5794588bb47068090a8f4966.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/ticker/fnn.png b/assets/ticker/fnn.png new file mode 100644 index 0000000..27d2e74 Binary files /dev/null and b/assets/ticker/fnn.png differ diff --git a/assets/ticker/fnn.png.import b/assets/ticker/fnn.png.import new file mode 100644 index 0000000..9f208ae --- /dev/null +++ b/assets/ticker/fnn.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/fnn.png-5c63f68777d5a929666ef2d1f774ecb5.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ticker/fnn.png" +dest_files=[ "res://.import/fnn.png-5c63f68777d5a929666ef2d1f774ecb5.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/ticker/pawprint-logo.svg b/assets/ticker/pawprint-logo.svg new file mode 100644 index 0000000..94024e5 --- /dev/null +++ b/assets/ticker/pawprint-logo.svg @@ -0,0 +1,165 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/ticker/pawprint-logo.svg.import b/assets/ticker/pawprint-logo.svg.import new file mode 100644 index 0000000..d4a931f --- /dev/null +++ b/assets/ticker/pawprint-logo.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/pawprint-logo.svg-f33569ddfdeabc9ffb0b78f564117520.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ticker/pawprint-logo.svg" +dest_files=[ "res://.import/pawprint-logo.svg-f33569ddfdeabc9ffb0b78f564117520.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/ticker_black.tres b/assets/ticker_black.tres new file mode 100644 index 0000000..3186dbe --- /dev/null +++ b/assets/ticker_black.tres @@ -0,0 +1,4 @@ +[gd_resource type="StyleBoxFlat" format=2] + +[resource] +bg_color = Color( 0, 0, 0, 1 ) diff --git a/is_caseyverse.txt b/is_caseyverse.txt new file mode 100644 index 0000000..e69de29 diff --git a/json/ticker/README.md b/json/ticker/README.md new file mode 100644 index 0000000..266ae4d --- /dev/null +++ b/json/ticker/README.md @@ -0,0 +1,7 @@ +# News Ticker + +With the exception of certain policies, the majority of the lore in City Limits comes from the news ticker. During regular gameplay (when there isn't any disasters or financial problems), the news ticker provides fictional turn of events that happen in the city, such as the Kitty Kibble shortage from SimCity 3000. + +## 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. diff --git a/json/ticker/extra_lore.json b/json/ticker/extra_lore.json new file mode 100644 index 0000000..dec5895 --- /dev/null +++ b/json/ticker/extra_lore.json @@ -0,0 +1,11 @@ +{ + "competing_outlet": "Citizen Telegram", + "ticker": [ + "Some cats look to [other_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." + ] +} \ No newline at end of file diff --git a/project.godot b/project.godot index f7d38b6..b82229c 100644 --- a/project.godot +++ b/project.godot @@ -23,6 +23,7 @@ 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" [display] diff --git a/scenes/game.tscn b/scenes/game.tscn index 170eba9..f0f96bd 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=45 format=2] [ext_resource path="res://scenes/maps/MapOne.tscn" type="PackedScene" id=1] -[ext_resource path="res://scripts/ticker.gd" type="Script" id=2] +[ext_resource path="res://assets/ticker/pawprint-logo.svg" type="Texture" id=2] [ext_resource path="res://assets/symbols/fontawesome/population.svg" type="Texture" id=3] [ext_resource path="res://scenes/windows/Advisor.tscn" type="PackedScene" id=4] [ext_resource path="res://assets/ui/iccom.png" type="Texture" id=5] @@ -56,7 +56,7 @@ __meta__ = { } [node name="RotateNews" type="Timer" parent="."] -wait_time = 6.0 +wait_time = 5.0 autostart = true [node name="MapOne" parent="." instance=ExtResource( 1 )] @@ -263,19 +263,18 @@ __meta__ = { } [node name="Status" type="Panel" parent="Controls/Windows"] -anchor_top = 0.908333 +anchor_top = 0.863333 anchor_right = 1.0 -anchor_bottom = 1.0 -script = ExtResource( 2 ) +anchor_bottom = 1.00833 __meta__ = { "_edit_use_anchors_": true } [node name="SettingsBtn" type="Button" parent="Controls/Windows/Status"] anchor_left = 0.0115391 -anchor_top = 0.193259 +anchor_top = 0.0555202 anchor_right = 0.0525548 -anchor_bottom = 0.670871 +anchor_bottom = 0.533132 hint_tooltip = "Meet" size_flags_horizontal = 4 icon = ExtResource( 35 ) @@ -285,9 +284,9 @@ __meta__ = { [node name="StatCtr" type="HBoxContainer" parent="Controls/Windows/Status"] anchor_left = 0.0566406 -anchor_top = 0.208955 -anchor_right = 0.601562 -anchor_bottom = 0.746269 +anchor_top = 0.0750188 +anchor_right = 0.996094 +anchor_bottom = 0.516879 custom_constants/separation = 50 alignment = 1 script = ExtResource( 38 ) @@ -296,9 +295,9 @@ __meta__ = { } [node name="ButtonCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr"] -margin_left = 30.0 -margin_right = 312.0 -margin_bottom = 36.0 +margin_left = 233.0 +margin_right = 515.0 +margin_bottom = 38.0 custom_constants/separation = 10 alignment = 1 __meta__ = { @@ -307,7 +306,7 @@ __meta__ = { [node name="TaxBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_right = 42.0 -margin_bottom = 36.0 +margin_bottom = 38.0 hint_tooltip = "RCI" size_flags_horizontal = 4 icon = ExtResource( 40 ) @@ -315,7 +314,7 @@ icon = ExtResource( 40 ) [node name="ToolsBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 52.0 margin_right = 94.0 -margin_bottom = 36.0 +margin_bottom = 38.0 hint_tooltip = "Tools" size_flags_horizontal = 4 icon = ExtResource( 42 ) @@ -323,7 +322,7 @@ icon = ExtResource( 42 ) [node name="AdvsiorBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 104.0 margin_right = 146.0 -margin_bottom = 36.0 +margin_bottom = 38.0 hint_tooltip = "Meet" size_flags_horizontal = 4 icon = ExtResource( 43 ) @@ -331,12 +330,12 @@ icon = ExtResource( 43 ) [node name="VSeparator" type="VSeparator" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 156.0 margin_right = 160.0 -margin_bottom = 36.0 +margin_bottom = 38.0 [node name="TurtleBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 170.0 margin_right = 211.0 -margin_bottom = 36.0 +margin_bottom = 38.0 hint_tooltip = "Slow" toggle_mode = true icon = ExtResource( 8 ) @@ -344,7 +343,7 @@ icon = ExtResource( 8 ) [node name="CheetaBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 221.0 margin_right = 268.0 -margin_bottom = 36.0 +margin_bottom = 38.0 hint_tooltip = "Fast" toggle_mode = true icon = ExtResource( 7 ) @@ -352,25 +351,25 @@ icon = ExtResource( 7 ) [node name="VSeparator2" type="VSeparator" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 278.0 margin_right = 282.0 -margin_bottom = 36.0 +margin_bottom = 38.0 [node name="NameDate" type="VBoxContainer" parent="Controls/Windows/Status/StatCtr"] -margin_left = 362.0 -margin_right = 450.0 -margin_bottom = 36.0 +margin_left = 565.0 +margin_right = 653.0 +margin_bottom = 38.0 alignment = 1 [node name="CityNameLbl" type="Label" parent="Controls/Windows/Status/StatCtr/NameDate"] -margin_top = 2.0 +margin_top = 3.0 margin_right = 88.0 -margin_bottom = 16.0 +margin_bottom = 17.0 text = "City Name" align = 1 [node name="YearCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/NameDate"] -margin_top = 20.0 +margin_top = 21.0 margin_right = 88.0 -margin_bottom = 34.0 +margin_bottom = 35.0 [node name="CalIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/NameDate/YearCtr"] margin_right = 10.0 @@ -388,15 +387,15 @@ __meta__ = { } [node name="PopBudget" type="VBoxContainer" parent="Controls/Windows/Status/StatCtr"] -margin_left = 500.0 -margin_right = 526.0 -margin_bottom = 36.0 +margin_left = 703.0 +margin_right = 729.0 +margin_bottom = 38.0 alignment = 1 [node name="BudgetCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/PopBudget"] -margin_top = 2.0 +margin_top = 3.0 margin_right = 26.0 -margin_bottom = 16.0 +margin_bottom = 17.0 [node name="CoinsIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/PopBudget/BudgetCtr"] margin_right = 14.0 @@ -411,9 +410,9 @@ margin_bottom = 14.0 text = "0" [node name="PopCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/PopBudget"] -margin_top = 20.0 +margin_top = 21.0 margin_right = 26.0 -margin_bottom = 34.0 +margin_bottom = 35.0 [node name="PopIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/PopBudget/PopCtr"] margin_right = 14.0 @@ -427,18 +426,63 @@ margin_right = 26.0 margin_bottom = 14.0 text = "0" -[node name="Ticker" type="ItemList" parent="Controls/Windows/Status"] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 622.0 +[node name="NewsBtn" type="Button" parent="Controls/Windows/Status"] +anchor_left = 0.0078125 +anchor_top = 0.633158 +anchor_right = 0.989258 +anchor_bottom = 0.888972 +text = "News" +flat = true __meta__ = { -"_edit_use_anchors_": false +"_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"] diff --git a/scripts/autoload/caseyverse.gd b/scripts/autoload/caseyverse.gd new file mode 100644 index 0000000..27f8a28 --- /dev/null +++ b/scripts/autoload/caseyverse.gd @@ -0,0 +1,16 @@ +extends Node + +const caseyverse_path = "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"] diff --git a/scripts/autoload/sim_events.gd b/scripts/autoload/sim_events.gd index 2f774f9..257b82b 100644 --- a/scripts/autoload/sim_events.gd +++ b/scripts/autoload/sim_events.gd @@ -11,7 +11,7 @@ signal advisor_message(advisor, message) # News signal send_alert(message) -signal resume_news +signal rotate_news # Policies signal clean_air_act diff --git a/scripts/game.gd b/scripts/game.gd index 1a5d16c..c689e29 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -6,7 +6,7 @@ onready var turtle_btn = $Controls/Status/StatCtr/ButtonCtr/TurtleBtn onready var cheeta_btn = $Controls/Status/StatCtr/ButtonCtr/CheetaBtn func _ready(): - SimEvents.connect("resume_news", self, "_resume_rotation") + SimEvents.connect("rotate_news", self, "_rotate_news") SimEvents.connect("send_alert", self, "_stop_news") func _stop_news(): diff --git a/scripts/ticker.gd b/scripts/ticker.gd index eec012e..4f43400 100644 --- a/scripts/ticker.gd +++ b/scripts/ticker.gd @@ -1,116 +1,117 @@ -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" -] - -func _index_news(): - var news = _load_json() - all_news.clear() - all_news = news["ticker"] - - randomize() - all_news.shuffle() - -func _process(delta): - var prev_json_Files = json_files - - var city_life = [ - "citylife.json", - "kittykibble.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.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("resume_news", self, "_resume_ticker") - _random_news(json_files) - -func _start_alert(message): - if ticker_text.items.size() > 3: - ticker_text.clear() - - SimData.on_alert = true - 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.add_item(news_text) - -func _resume_ticker(): - _random_news(json_files) - -func _on_RotateNews_timeout(): - _random_news(json_files) +#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() +# +#func _process(delta): +# var prev_json_Files = json_files +# +# var city_life = [ +# "citylife.json", +# "kittykibble.json", +# "international.json", +# "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.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): +# 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) +# +#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) diff --git a/scripts/windows.gd b/scripts/windows.gd index 9370b74..b15cacb 100644 --- a/scripts/windows.gd +++ b/scripts/windows.gd @@ -5,12 +5,166 @@ 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() @@ -20,3 +174,6 @@ func _on_AdvsiorBtn_pressed(): func _on_ToolsBtn_pressed(): tools_window.show() + +func _on_NewsBtn_pressed(): + ticker_window.show()