diff --git a/.gdignore b/.gdignore deleted file mode 100644 index 20c56a4..0000000 --- a/.gdignore +++ /dev/null @@ -1,2 +0,0 @@ -**.md -screenshot.png \ No newline at end of file diff --git a/assets/fnn.png.import b/assets/fnn.png.import deleted file mode 100644 index 8176bd3..0000000 --- a/assets/fnn.png.import +++ /dev/null @@ -1,35 +0,0 @@ -[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 deleted file mode 100644 index 27d2e74..0000000 Binary files a/assets/ticker/fnn.png and /dev/null differ diff --git a/assets/ticker/fnn.png.import b/assets/ticker/fnn.png.import deleted file mode 100644 index 9f208ae..0000000 --- a/assets/ticker/fnn.png.import +++ /dev/null @@ -1,35 +0,0 @@ -[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 deleted file mode 100644 index 94024e5..0000000 --- a/assets/ticker/pawprint-logo.svg +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/ticker/pawprint-logo.svg.import b/assets/ticker/pawprint-logo.svg.import deleted file mode 100644 index d4a931f..0000000 --- a/assets/ticker/pawprint-logo.svg.import +++ /dev/null @@ -1,35 +0,0 @@ -[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 deleted file mode 100644 index 3186dbe..0000000 --- a/assets/ticker_black.tres +++ /dev/null @@ -1,4 +0,0 @@ -[gd_resource type="StyleBoxFlat" format=2] - -[resource] -bg_color = Color( 0, 0, 0, 1 ) diff --git a/is_caseyverse.txt b/is_caseyverse.txt deleted file mode 100644 index e69de29..0000000 diff --git a/json/ticker/README.md b/json/ticker/README.md deleted file mode 100644 index 266ae4d..0000000 --- a/json/ticker/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100644 index dec5895..0000000 --- a/json/ticker/extra_lore.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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 b82229c..f7d38b6 100644 --- a/project.godot +++ b/project.godot @@ -23,7 +23,6 @@ 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 f0f96bd..071e64b 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://assets/ticker/pawprint-logo.svg" type="Texture" id=2] +[ext_resource path="res://scripts/ticker.gd" type="Script" 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 = 5.0 +wait_time = 6.0 autostart = true [node name="MapOne" parent="." instance=ExtResource( 1 )] @@ -101,6 +101,7 @@ margin_right = 234.609 margin_bottom = 138.5 [node name="ToolsWindow" type="WindowDialog" parent="Controls/Windows"] +visible = true anchor_left = 0.402435 anchor_top = 0.315697 anchor_right = 0.60263 @@ -263,18 +264,20 @@ __meta__ = { } [node name="Status" type="Panel" parent="Controls/Windows"] -anchor_top = 0.863333 +anchor_top = 0.908333 anchor_right = 1.0 -anchor_bottom = 1.00833 +anchor_bottom = 1.0 +script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": true } [node name="SettingsBtn" type="Button" parent="Controls/Windows/Status"] anchor_left = 0.0115391 -anchor_top = 0.0555202 +anchor_top = 0.193259 anchor_right = 0.0525548 -anchor_bottom = 0.533132 +anchor_bottom = 0.670871 +margin_top = -9.53674e-07 hint_tooltip = "Meet" size_flags_horizontal = 4 icon = ExtResource( 35 ) @@ -284,9 +287,10 @@ __meta__ = { [node name="StatCtr" type="HBoxContainer" parent="Controls/Windows/Status"] anchor_left = 0.0566406 -anchor_top = 0.0750188 -anchor_right = 0.996094 -anchor_bottom = 0.516879 +anchor_top = 0.208955 +anchor_right = 0.601562 +anchor_bottom = 0.746269 +margin_top = 9.53674e-07 custom_constants/separation = 50 alignment = 1 script = ExtResource( 38 ) @@ -295,9 +299,9 @@ __meta__ = { } [node name="ButtonCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr"] -margin_left = 233.0 -margin_right = 515.0 -margin_bottom = 38.0 +margin_left = 30.0 +margin_right = 312.0 +margin_bottom = 36.0 custom_constants/separation = 10 alignment = 1 __meta__ = { @@ -306,7 +310,7 @@ __meta__ = { [node name="TaxBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_right = 42.0 -margin_bottom = 38.0 +margin_bottom = 36.0 hint_tooltip = "RCI" size_flags_horizontal = 4 icon = ExtResource( 40 ) @@ -314,7 +318,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 = 38.0 +margin_bottom = 36.0 hint_tooltip = "Tools" size_flags_horizontal = 4 icon = ExtResource( 42 ) @@ -322,7 +326,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 = 38.0 +margin_bottom = 36.0 hint_tooltip = "Meet" size_flags_horizontal = 4 icon = ExtResource( 43 ) @@ -330,12 +334,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 = 38.0 +margin_bottom = 36.0 [node name="TurtleBtn" type="Button" parent="Controls/Windows/Status/StatCtr/ButtonCtr"] margin_left = 170.0 margin_right = 211.0 -margin_bottom = 38.0 +margin_bottom = 36.0 hint_tooltip = "Slow" toggle_mode = true icon = ExtResource( 8 ) @@ -343,7 +347,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 = 38.0 +margin_bottom = 36.0 hint_tooltip = "Fast" toggle_mode = true icon = ExtResource( 7 ) @@ -351,25 +355,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 = 38.0 +margin_bottom = 36.0 [node name="NameDate" type="VBoxContainer" parent="Controls/Windows/Status/StatCtr"] -margin_left = 565.0 -margin_right = 653.0 -margin_bottom = 38.0 +margin_left = 362.0 +margin_right = 450.0 +margin_bottom = 36.0 alignment = 1 [node name="CityNameLbl" type="Label" parent="Controls/Windows/Status/StatCtr/NameDate"] -margin_top = 3.0 +margin_top = 2.0 margin_right = 88.0 -margin_bottom = 17.0 +margin_bottom = 16.0 text = "City Name" align = 1 [node name="YearCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/NameDate"] -margin_top = 21.0 +margin_top = 20.0 margin_right = 88.0 -margin_bottom = 35.0 +margin_bottom = 34.0 [node name="CalIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/NameDate/YearCtr"] margin_right = 10.0 @@ -387,15 +391,15 @@ __meta__ = { } [node name="PopBudget" type="VBoxContainer" parent="Controls/Windows/Status/StatCtr"] -margin_left = 703.0 -margin_right = 729.0 -margin_bottom = 38.0 +margin_left = 500.0 +margin_right = 526.0 +margin_bottom = 36.0 alignment = 1 [node name="BudgetCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/PopBudget"] -margin_top = 3.0 +margin_top = 2.0 margin_right = 26.0 -margin_bottom = 17.0 +margin_bottom = 16.0 [node name="CoinsIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/PopBudget/BudgetCtr"] margin_right = 14.0 @@ -410,9 +414,9 @@ margin_bottom = 14.0 text = "0" [node name="PopCtr" type="HBoxContainer" parent="Controls/Windows/Status/StatCtr/PopBudget"] -margin_top = 21.0 +margin_top = 20.0 margin_right = 26.0 -margin_bottom = 35.0 +margin_bottom = 34.0 [node name="PopIcon" type="TextureRect" parent="Controls/Windows/Status/StatCtr/PopBudget/PopCtr"] margin_right = 14.0 @@ -426,63 +430,18 @@ margin_right = 26.0 margin_bottom = 14.0 text = "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 +[node name="Ticker" type="ItemList" parent="Controls/Windows/Status"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 622.0 __meta__ = { -"_edit_use_anchors_": true +"_edit_use_anchors_": false } -[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 deleted file mode 100644 index 27f8a28..0000000 --- a/scripts/autoload/caseyverse.gd +++ /dev/null @@ -1,16 +0,0 @@ -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 257b82b..2f774f9 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 rotate_news +signal resume_news # Policies signal clean_air_act diff --git a/scripts/game.gd b/scripts/game.gd index c689e29..1a5d16c 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("rotate_news", self, "_rotate_news") + SimEvents.connect("resume_news", self, "_resume_rotation") SimEvents.connect("send_alert", self, "_stop_news") func _stop_news(): diff --git a/scripts/ticker.gd b/scripts/ticker.gd index 4f43400..11c0e38 100644 --- a/scripts/ticker.gd +++ b/scripts/ticker.gd @@ -1,117 +1,116 @@ -#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) +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.replace("[outlet]", "FNN") + elif "[outlet]" in 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.replace("[species]", speices[speices_range]) + + if "[city]" in news_text: + news_text.replace("[city]", SimData.city_name) + + if "[mayor]" in 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) diff --git a/scripts/windows.gd b/scripts/windows.gd index b15cacb..9370b74 100644 --- a/scripts/windows.gd +++ b/scripts/windows.gd @@ -5,166 +5,12 @@ 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() @@ -174,6 +20,3 @@ func _on_AdvsiorBtn_pressed(): func _on_ToolsBtn_pressed(): tools_window.show() - -func _on_NewsBtn_pressed(): - ticker_window.show()