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/json/ticker/README.md b/json/ticker/README.md index f6f31df..830babd 100644 --- a/json/ticker/README.md +++ b/json/ticker/README.md @@ -2,6 +2,22 @@ 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 +## Configuration -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. +The news ticker is completely configurable. News can be added or removed from the game without having to touch the code. The configuration is stored in the `config.json` file. + +```json +{ + "outlet": "Pawprint Press", + "competing_outlet": "Citizen Telegram", + "ticker_files": [ + "adverts.json", + "sammy.json", + "kittykibble.json", + "citylife.json", + "extra_lore.json" + ] +} +``` + +The ``outlet`` is the city's news brand, the ``competing_outlet`` is part of the optional ``extra_lore.json`` file, and ```ticker_files``` is an array of filenames that contain the news itself. diff --git a/json/ticker/meta.json b/json/ticker/config.json similarity index 61% rename from json/ticker/meta.json rename to json/ticker/config.json index bbe811e..f7278b3 100644 --- a/json/ticker/meta.json +++ b/json/ticker/config.json @@ -1,11 +1,11 @@ { - "primary_outlet": "Pawprint Press", - "secondary_outlet": "FNN", + "outlet": "Pawprint Press", "competing_outlet": "Citizen Telegram", "ticker_files": [ "adverts.json", "sammy.json", "kittykibble.json", - "citylife.json" + "citylife.json", + "extra_lore.json" ] } \ No newline at end of file diff --git a/project.godot b/project.godot index b8b6a44..9db388f 100644 --- a/project.godot +++ b/project.godot @@ -22,7 +22,6 @@ 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" -Caseyverse="*res://scripts/autoload/caseyverse.gd" JsonHelper="*res://scripts/autoload/jsonhelper.gd" [display] diff --git a/scenes/game.tscn b/scenes/game.tscn index a5cd17e..217a1a7 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=46 format=2] +[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://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] @@ -269,42 +268,24 @@ __meta__ = { } [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 +anchor_bottom = 0.591085 +window_title = "News" __meta__ = { "_edit_use_anchors_": true } [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 +anchor_left = 0.00797449 +anchor_top = 0.0412844 +anchor_right = 0.992026 +anchor_bottom = 0.967889 __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 diff --git a/scripts/ticker.gd b/scripts/ticker.gd index 41cd451..7405cdd 100644 --- a/scripts/ticker.gd +++ b/scripts/ticker.gd @@ -2,13 +2,11 @@ extends Control const TICKER_PATH = "res://json/ticker/" const FNN_LOGO = "res://assets/ticker/fnn.png" -const META_FILE = "meta.json" +const CONFIG_FILE = "config.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() @@ -35,15 +33,8 @@ func _index_news(): 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") +func _ready(): + ticker_window.window_title = JsonHelper.key_value(TICKER_PATH, CONFIG_FILE, "outlet") _randomize_news(json_files) @@ -87,6 +78,9 @@ func _start_alert(message): pass func _randomize_news(files: Array): + if all_news == null: + json_files = JsonHelper.key_value(TICKER_PATH, CONFIG_FILE, "ticker_files") + for file in files: news_file = str(TICKER_PATH + file) _load_json() @@ -99,15 +93,11 @@ func _randomize_news(files: Array): 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 "[competing_outlet]" in news_text: + news_text = news_text.replace("[competing_outlet]", JsonHelper.key_value(TICKER_PATH, CONFIG_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 "[outlet]" in news_text: + news_text = news_text.replace("[outlet]", JsonHelper.key_value(TICKER_PATH, CONFIG_FILE, "outlet")) if "[species]" in news_text: speices.shuffle() @@ -120,16 +110,12 @@ func _randomize_news(files: Array): if "[mayor]" in news_text: news_text = news_text.replace("[mayor]", SimData.mayor_name) - if ticker_box.items.size() > 15: + # Prevent stack overflaw + if ticker_box.items.size() > 10: 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) + _randomize_news(json_files) + _add_news(news_text) func _add_news(news_item): ticker_text.text = news_item