Major clean up and reorganization

- Upgraded to Godot 4
- Just remembered the basic principles are based on a tile editor, and dramatically simplified from there. Derp.
- New state machine and license display add-ons.
- Re-licensed under the GPL because Micropolis' assets aren't under a separate one.
This commit is contained in:
Tony Bark 2023-03-14 06:17:27 -04:00
parent 55ed76c914
commit c980445340
337 changed files with 5129 additions and 7661 deletions

View file

@ -1,39 +0,0 @@
extends Area2D
onready var zone = $Sprite
onready var quarters = $Quarters
onready var animator = $AnimationPlayer
var can_grab = false
var grabbed_offset = Vector2()
func _ready():
zone.frame = 0
#func _drag_drop(event):
# if event is InputEventMouseButton and can_grab:
# # Substract from the player's budget and disable grabbing
# if SimData.budget >= cost:
# SimData.budget -= cost
# can_grab = false
# grabbed_offset = position - get_global_mouse_position()
#func _input(event):
# _drag_drop(event)
func _process(delta):
if SimData.has_power == true:
animator.play("Animante")
else:
animator.stop()
# if can_grab:
# position = get_global_mouse_position() + grabbed_offset
#func _animante_sprite(animante: bool = true):
# if zone.hframes > 1 or zone.vframes > 1 and animante:
# animator.play("Animante")
# else:
# animator.stop()
#func _grab_zone():
# can_grab = true

View file

@ -1,96 +0,0 @@
extends AcceptDialog
var dialogue_file
# "character" would be "name" but it's already used by the base class
var character
var rank
var avatar
var dialogue_keys = []
var dialogue_name = ""
var dialogue_text = ""
onready var avatar_texture = $Container/Advisor/Avatar
onready var rank_label = $Container/Advisor/RankLbl
onready var name_label = $Container/Advisor/NameLbl
onready var description_label = $Container/DescriptionLbl
enum JsonFile {
ANNOUNCEMENTS,
ANALYSIS
}
func _ready():
SimEvents.connect("advisor_message", self, "_advisor_dialogue")
SimEvents.connect("policy_analysis", self, "_analysis_dialouge")
func _init_advisor(file, advisor):
match advisor:
SimData.Advisors.CITY_PLANNER:
match file:
JsonFile.ANNOUNCEMENTS:
dialogue_file = "res://json/advisors/cityplanner.json"
JsonFile.ANALYSIS:
dialogue_file = "res://json/policies/cityplanner_analysis.json"
avatar_texture.texture = preload("res://assets/avatars/cindy.png")
name_label.text = "Cindy Diamond"
rank_label.text = "City Planner"
SimData.Advisors.FINANCIAL:
match file:
JsonFile.ANNOUNCEMENTS:
dialogue_file = "res://json/advisors/finacial.json"
JsonFile.ANALYSIS:
dialogue_file = "res://json/policies/finacial_analysis.json"
avatar_texture.texture = preload("res://assets/avatars/kit.png")
name_label.text = "Kit Welsh"
rank_label.text = "Financial Advisor"
SimData.Advisors.TRANSPORT:
match file:
JsonFile.ANNOUNCEMENTS:
dialogue_file = "res://json/advisors/transport.json"
JsonFile.ANALYSIS:
dialogue_file = "res://json/policies/transport_analysis.json"
avatar_texture.texture = preload("res://assets/avatars/zc.png")
name_label.text = "Zack Casey"
rank_label.text = "Transportation Advisor"
func _launch_advisor_window(key):
# _index_dialogue()
# var message: String = dialogue_keys[key].text
#
# if "[name]" in message:
# message = message.replace("[name]", SimData.mayor_name)
#
# if "[city]" in message:
# message = message.replace("[city]", SimData.city_name)
#
# description_label.text = message
# window_title = dialogue_keys[key].name
# show()
pass
func _advisor_dialogue(advisor, message):
_init_advisor(JsonFile.ANNOUNCEMENTS, advisor)
_launch_advisor_window(message)
func _analysis_dialouge(advisor, policy):
_init_advisor(JsonFile.ANALYSIS, advisor)
_launch_advisor_window(policy)
func _index_dialogue():
var dialogue = _load_dialogue()
dialogue_keys.clear()
for key in dialogue:
dialogue_keys.append(dialogue[key])
func _load_dialogue():
var file = File.new()
if file.file_exists(dialogue_file):
file.open(dialogue_file, file.READ)
var dialogue = parse_json(file.get_as_text())
return dialogue

View file

@ -1,10 +0,0 @@
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

View file

@ -1,11 +0,0 @@
extends Node
func key_value(json_path, json_file, key, is_dictionary = false):
var file = File.new()
var full_path = str(json_path + json_file);
if file.file_exists(full_path):
file.open(full_path, File.READ)
var result = parse_json(file.get_as_text())
if is_dictionary == true:
result.clear()
return result[key]

View file

@ -1,7 +0,0 @@
extends Node
var power_grid: int # Number of power stations in the area. Helps provide redundancies.
var power_capacity: int
var current_power_cap: int
var prev_power_cap: int
var has_power: bool

View file

@ -1,88 +0,0 @@
extends Node
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
var on_alert: bool = false
var has_ctower: bool = false # Central Tower
var power_grid: int # Number of power stations in the area. Helps provide redundancies.
var power_capacity: int
var current_power_cap: int
var prev_power_cap: int
var has_power: bool
var res_tax: int = 5
var res_income: int
var ticker_files: Array = [
"adverts.json",
"sammy.json"
]
var prev_ticker_files: Array = []
enum GameSpeed {
SLOW,
MEDIUM,
FAST
}
enum Level {
EASY,
MEDIUM,
HARD
}
enum Advisors {
CITY_PLANNER,
FINANCIAL,
TRANSPORT
}
enum Ordinances {
# Education
CPR_TRAINING,
PRO_READING,
NHOOD_WATCH,
# Financial
PARKING_FINES,
GAMBLING,
SALES_TAX,
# Promo
ANNUAL_CARNIVAL,
BUSINESS_ADS,
CITY_BEAUTY,
TOURIST_ADS
# Health & Safety
FREE_CLINICS,
JUNIOR_SPORTS,
SMOKING_BAN,
VOLUNTEER_FIRE,
SMOKE_DETECTOR,
# Environment
ENERGY_CONSERVATION,
HOMELESS_SHELTERS,
CLEAN_AIR_ACT,
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:
# budget = 20000
# Level.MEDIUM:
# budget = 10000
# Level.HARD:
# budget = 5000

View file

@ -1,18 +0,0 @@
extends Node
signal has_power
signal budget
signal game_speed
# Policies and Advisors
signal policy_message(policy)
signal policy_analysis(advisor, policy)
signal advisor_message(advisor, message)
# News
signal send_alert(message)
signal rotate_news
# Policies
signal clean_air_act
signal energy_saving

View file

@ -1,32 +0,0 @@
extends Node
var year: int = 2000 setget increment_year
var prev_year: int
var month: int = 1 setget increment_month
var prev_month: int
var day: int = 1 setget increment_day
var prev_day: int
func new_year():
prev_year = year
prev_day = day
prev_month = month
increment_year(1)
day = 1
month = 1
func reset_day():
prev_day = day
day = 1
func increment_day(new_day):
prev_day = day
day += new_day
func increment_year(new_year):
prev_year = year
year += new_year
func increment_month(new_month):
prev_month = month
month += new_month

View file

@ -1,13 +0,0 @@
extends Node
var res_tax: int = 1
var comm_tax: int = 1
var indust_tax: int = 1
var res_income: int
var comm_income: int
var ind_income: int
var fire_tax: int
var police_tax: int
var power_tax: int

View file

@ -1,65 +0,0 @@
extends Camera2D
export var panSpeed = 10.0
export var speed = 25.0
export var zoomspeed = 50.0
export var zoommargin = 0.3
export var zoomMin = 0.5
export var zoomMax = 3.0
export var marginX = 200.0
export var marginY = 100.0
var mousepos = Vector2()
var zoompos = Vector2()
var zoomfactor = 1.0
func _ready():
pass
func _process(delta):
# Smooth Movement
var inputx = (int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left")))
var inputy = (int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up")))
position.x = lerp(position.x, position.x + inputx * speed * zoom.x, speed * delta)
position.y = lerp(position.y, position.y + inputy * speed * zoom.y, speed * delta)
# Edge scrolling via. Ctrl + Right Click
if Input.is_key_pressed(KEY_CONTROL):
# check mouse postion
if mousepos.x < marginX:
position.x = lerp(position.x, position.x - abs(mousepos.x - marginX) / marginX * panSpeed * zoom.x, panSpeed * delta)
elif mousepos.x > OS.window_size.x - marginX:
position.x = lerp(position.x, position.x + abs(mousepos.x - OS.window_size.x + marginX) / marginX * panSpeed * zoom.x, panSpeed * delta)
if mousepos.y < marginY:
position.y = lerp(position.y, position.y - abs(mousepos.y - marginY) / marginY * panSpeed * zoom.y, panSpeed * delta)
elif mousepos.y > OS.window_size.y - marginY:
position.y = lerp(position.y, position.y + abs(mousepos.y - OS.window_size.y + marginX) / marginX * panSpeed * zoom.y, panSpeed * delta)
# Zooming
zoom.x = lerp(zoom.x, zoom.x * zoomfactor, zoomspeed * delta)
zoom.y = lerp(zoom.y, zoom.y * zoomfactor, zoomspeed * delta)
zoom.x = clamp(zoom.x, zoomMin, zoomMax)
zoom.y = clamp(zoom.y, zoomMin, zoomMax)
func _input(event):
if abs(zoompos.x - get_global_mouse_position().x) > zoommargin:
zoomfactor = 1.0
if abs(zoompos.y - get_global_mouse_position().y) > zoommargin:
zoomfactor = 1.0
if event is InputEventMouseButton:
if event.is_pressed():
if event.button_index == BUTTON_WHEEL_UP:
zoomfactor -= 0.01
zoompos = get_global_mouse_position()
if event.button_index == BUTTON_WHEEL_DOWN:
zoomfactor += 0.01
zoompos = get_global_mouse_position()
if event is InputEventMouse:
mousepos = event.position

View file

@ -1,12 +0,0 @@
extends HBoxContainer
onready var city_name = $NameDate/CityNameLbl
onready var budget = $PopBudget/BudgetCtr/BudgetLbl
onready var calendar = $NameDate/YearCtr/CalendarLbl
func _process(delta):
city_name.text = SimData.city_name
budget.text = str(SimData.budget)
var day = "%02d" % SimTime.day
var month = "%02d" % SimTime.month
calendar.text = str(day) + "/" + str(month) + "/" + str(SimTime.year)

View file

@ -1,40 +0,0 @@
extends Node
enum {
ARG_INT,
ARG_STRING,
ARG_BOOL,
ARG_FLOAT
}
const valid_commands = [
["money", [ARG_STRING] ],
["whereyoufrom", [ARG_STRING] ],
["whatyearisit", [ARG_STRING] ],
["show_policy", [ARG_INT]],
["set_month", [ARG_INT]],
["set_year", [ARG_INT]]
]
func set_month(month):
SimTime.month = month
func set_year(year):
SimTime.year = year
func show_policy(policy):
SimEvents.emit_signal("policy_message", policy)
func _budget_print(value: int):
return "Budget increased to " + str(value)
func money(value):
SimData.budget += int(value)
func whereyoufrom(value):
SimData.city_name = str(value)
return "Changed city name to: " + str(value)
func whatyearisit(value):
SimData.year = int(value)
return "Change year to: " + str(value)

View file

@ -1,64 +0,0 @@
extends WindowDialog
onready var input_box = $Input
onready var output_box = $Output
onready var command_handler = $CommandHandler
func _ready():
input_box.grab_focus()
func process_command(text: String):
var words = text.split(" ")
words = Array(words)
for i in range(words.count("")):
words.erase("")
if words.size() == 0:
return
var cmd_word = words.pop_front()
for cmd in command_handler.valid_commands:
if cmd[0] == cmd_word:
if words.size() != cmd[1].size():
output_text(str('Failure executing command "', cmd_word,
'", expected ', cmd[1].size(), ' parameters'))
return
for i in range(words.size()):
if not check_type(words[i], cmd[1][i]):
output_text(str('Failure executing command "', cmd_word,
'", parameter ', (i + 1), ' ("', words[i], '") is of the wrong type'))
return
output_text(command_handler.callv(cmd_word, words))
return
output_text(str('Command: "', cmd_word, '" does not exist'))
func check_type(string: String, type):
if type == command_handler.ARG_INT:
return string.is_valid_integer()
if type == command_handler.ARG_FLOAT:
return string.is_valid_float()
if type == command_handler.ARG_STRING:
return true
if type == command_handler.ARG_BOOL:
return (string == "true" or string == "false")
return false
func output_text(text):
output_box.text = str(output_box.text + "\n", text)
func _on_Input_text_entered(new_text):
input_box.clear()
process_command(new_text)
func _on_SubmitBtn_pressed():
input_box.clear()
process_command(input_box.text)

22
scripts/editor.gd Normal file
View file

@ -0,0 +1,22 @@
extends Node2D
var can_place: bool = true
var is_placed: bool
@onready var level = get_node("/root/main/Level")
var current_item
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
global_position = get_global_mouse_position()
if (current_item != null and can_place and Input.is_action_just_pressed("mb_left")):
var new_item = current_item.instantiate()
level.add_child(new_item)
new_item.global_position = get_global_mouse_position()

View file

@ -1,39 +0,0 @@
extends Node2D
onready var day_cycle = $DayCycle
#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 _on_DayCycle_timeout():
# Increment the number days until it reaches 30
if SimTime.prev_day < 30:
SimTime.increment_day(1)
# Reset the number of days to 1 on day 30 and increment the month
if SimTime.prev_day == 30:
SimTime.reset_day()
# Increment month up until the 12th
if SimTime.prev_month != 12:
SimTime.increment_month(1)
SimEvents.emit_signal("budget")
# Increment the year on the 12th month
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

150
scripts/license_gui.gd Normal file
View file

@ -0,0 +1,150 @@
extends Control
@export var load_locations: Array[String]
@export var export_locations: Array[String]
@onready var tree: Tree = $Tree
@onready var text: TextEdit = $Text
@onready var license_manager: LicenseManager = $LicenseManager
@onready var op_locations: OptionButton = $op_locations
var root: TreeItem
var engine: TreeItem
var game: TreeItem
var licenses: TreeItem
var copyright: String
var location_index: int = 0
# key = identifier
# value = TreeItem
var licenses_dict = {}
func _ready() -> void:
if not DirAccess.dir_exists_absolute("res://licenses/license_links/"):
DirAccess.make_dir_recursive_absolute("res://licenses/license_links/")
refresh_after_location_change()
reload_license_manager()
func refresh_after_location_change():
text.clear()
if load_locations.size() == 0:
load_locations.append('res://licenses')
export_locations.clear()
export_locations.append('user://licenses/game/')
location_index = 0
op_locations.clear()
for i in load_locations.size():
op_locations.add_item(load_locations[i])
func reload_license_manager():
text.clear()
license_manager.exclude_engine = location_index > 0
tree.clear()
license_manager.load_dir = load_locations[location_index]
license_manager.export_dir = export_locations[location_index]
license_manager.load_license_information()
copyright = license_manager.get_combined_copyright()
root = tree.create_item()
var combined = tree.create_item(root)
combined.set_text(0, "All Components")
combined.set_meta('mode', 'combined')
game = tree.create_item()
var _name = 'Game' if location_index == 0 else 'Mod'
if _name == 'Game' and ProjectSettings.has_setting('application/config/name'):
_name = ProjectSettings.get_setting('application/config/name')
game.set_text(0, _name)
game.set_meta('mode', 'parent')
if not license_manager.exclude_engine:
engine = tree.create_item()
engine.set_text(0, 'Godot Engine')
engine.set_meta('mode', 'parent')
licenses = tree.create_item()
licenses.set_text(0, 'Licenses')
licenses.set_meta('mode', 'parent')
var item: TreeItem
var used_licenses = {}
for parent_component in license_manager.license_links.by_parent:
for link in license_manager.license_links.by_parent[parent_component].values():
if link is LicenseLink:
match parent_component:
"Game":
item = tree.create_item(game)
"Godot Engine":
item = tree.create_item(engine)
var valid_ids = license_manager.get_all_valid_licenses(link)
for id in valid_ids:
used_licenses[id] = valid_ids[id]
item.set_text(0, link.componet_name)
item.set_meta('mode', 'link')
item.set_meta('link', link)
for license in used_licenses.values():
if license is License:
item = tree.create_item(licenses)
item.set_text(0, license.identifier)
item.set_meta('mode', 'license')
item.set_meta('license', license)
licenses_dict[license.identifier] = item
func _on_tree_item_selected() -> void:
var item = tree.get_selected()
var mode = item.get_meta('mode')
match mode:
'combined':
text.text = copyright
'parent':
pass
'link':
var link = item.get_meta('link') as LicenseLink
text.text = link.to_formatted_string(link.component_of == 'Godot Engine')
'license':
var license = item.get_meta('license') as License
text.text = license.terms
func _on_tree_item_activated() -> void:
var item = tree.get_selected()
var mode = item.get_meta('mode')
match mode:
'parent':
item.collapsed = not item.collapsed
'link':
var link = item.get_meta('link') as LicenseLink
for id in link.license_identifiers:
if licenses_dict.has(id):
var to = licenses_dict[id]
to.select(0)
tree.scroll_to_item(to)
break
func _on_btn_open_data_dir_pressed() -> void:
OS.shell_open(OS.get_user_data_dir())
func _on_button_pressed() -> void:
license_manager.export()
func _on_op_locations_item_selected(index: int) -> void:
location_index = index
reload_license_manager()

View file

@ -1,70 +0,0 @@
extends WindowDialog
var dialogue_file = "res://dialog/policies/proposels.json"
var dialogue_keys = []
var dialogue_name = ""
var dialogue_text = ""
var policy_id
onready var ordinance_label = $OrdinanceLbl
onready var description_label = $DescPanel/DescriptionLbl
func _start_dialogue(policy):
match policy:
[SimData.Ordinances.ENERGY_CONSERVATION, 1]:
policy_id = 1
_launch_policy_window(1)
[SimData.Ordinances.CLEAN_AIR_ACT, 3]:
policy_id = 2
_launch_policy_window(2)
[SimData.Ordinances.TIRE_RECYCLE, 3]:
policy_id = 3
_launch_policy_window(3)
func _launch_policy_window(key):
_index_dialogue()
var message: String = dialogue_keys[key].text
if "[name]" in message:
message = message.replace("[name]", SimData.mayor_name)
if "[city]" in message:
message = message.replace("[city]", SimData.city_name)
description_label.text = message
window_title = dialogue_keys[key].name
show()
func _index_dialogue():
var dialogue = _load_dialogue()
dialogue_keys.clear()
for key in dialogue:
dialogue_keys.append(dialogue[key])
func _load_dialogue():
var file = File.new()
if file.file_exists(dialogue_file):
file.open(dialogue_file, file.READ)
var dialogue = parse_json(file.get_as_text())
return dialogue
func _ready():
SimEvents.connect("policy_message", self, "_start_dialogue")
func _on_IgnoreBtn_pressed():
policy_id = 0
description_label.text = ""
ordinance_label.text = ""
hide()
func _on_EnectBtn_pressed():
match policy_id:
1: SimEvents.emit_signal("energy_saving")
2: SimEvents.emit_signal("clean_air_act")
func _on_AnalysisBtn_pressed():
match policy_id:
1: SimEvents.emit_signal("policy_analysis", SimData.Advisors.CITY_PLANNER, policy_id)
2: SimEvents.emit_signal("policy_analysis", SimData.Advisors.CITY_PLANNER, policy_id)
3: SimEvents.emit_signal("policy_analysis", SimData.Advisors.CITY_PLANNER, policy_id)

View file

@ -1,16 +0,0 @@
extends "res://scripts/zone.gd"
func _ready():
SimEvents.connect("has_power", self, "_power_zones")
func _power_zones():
SimData.power_grid += 1
if SimData.power_grid <= 1:
SimData.has_power = true
func _input(event):
_drag_drop(event)
if can_grab == false:
SimEvents.emit_signal("has_power")

View file

@ -1,20 +0,0 @@
extends ConditionLeaf
export var cost: int = 10000
export var income: int = 100
export var expense: int = 0
func tick(actor, blackboard):
if SimData.has_power:
if SimData.budget >= expense:
SimData.budget -= expense
SimData.expenses = expense
if SimData.has_power:
var total_income = SimData.res_tax * income
SimData.budget += total_income
SimData.res_income = total_income
return SUCCESS
return FAILURE

View file

@ -1,5 +0,0 @@
extends ConditionLeaf
func tick(actor, blackboard):
SimData.has_power = true
return RUNNING

View file

@ -1,18 +0,0 @@
extends ConditionLeaf
export var cost: int = 10000
export var income: int = 100
export var expense: int = 0
func tick(actor, blackboard):
if SimData.has_power:
if SimData.budget >= expense:
SimData.budget -= expense
SimData.expenses = expense
if SimData.has_power:
var total_income = SimData.res_tax * income
SimData.budget += total_income
SimData.res_income = total_income
return RUNNING

View file

@ -1,15 +0,0 @@
extends Panel
onready var city_name = $Container/CityNameEdit
onready var mayor_name = $Container/MayorNameEdit
onready var budget = $Container/BudgetMenu
func _ready():
city_name.text = SimData.city_name
mayor_name.text = SimData.mayor_name
func _on_CreateBtn_pressed():
SimData.city_name = city_name.text
SimData.mayor_name = mayor_name.text
get_tree().change_scene("res://scenes/Game.tscn")

View file

@ -1,42 +0,0 @@
extends WindowDialog
onready var res_slider = $TaxSlidersCtr/ResCtr/ResSlider
onready var com_slider = $TaxSlidersCtr/ComCtr/ComSlider
onready var ind_slider = $TaxSlidersCtr/IndCtr/IndSlider
onready var res_rate = $PrecentCtr/ResPctLbl
onready var com_rate = $PrecentCtr/ComPctLbl
onready var ind_rate = $PrecentCtr/IndPctLbl
onready var annual_income = $IncomeCtr/IcnomeLbl
func _ready():
if ZoneData.res_tax >= 0:
res_slider.value = ZoneData.res_tax
res_rate.text = str(ZoneData.res_tax) + "%"
if ZoneData.res_tax >= 0:
com_slider.value = ZoneData.comm_tax
com_rate.text = str(ZoneData.comm_tax) + "%"
if ZoneData.indust_tax >= 0:
ind_slider.value = ZoneData.indust_tax
ind_rate.text = str(ZoneData.indust_tax) + "%"
func _process(delta):
var total_income = int(ZoneData.res_income + ZoneData.comm_income + ZoneData.ind_income)
if SimTime.prev_month < SimTime.month and total_income > 1:
annual_income.text = str(total_income) + "/mo"
func _on_ResSlider_value_changed(value):
ZoneData.res_tax = int(value)
res_rate.text = str(value) + "%"
func _on_ComSlider_value_changed(value):
ZoneData.comm_tax = int(value)
com_rate.text = str(value) + "%"
func _on_IndSlider_value_changed(value):
ZoneData.indust_tax = int(value)
ind_rate.text = str(value) + "%"

View file

@ -1,123 +0,0 @@
extends Control
#const TICKER_PATH = "res://json/ticker/"
#const FNN_LOGO = "res://assets/ticker/fnn.png"
#const CONFIG_FILE = "config.json"
#
#onready var ticker_text = $Status/NewsBtn
#onready var ticker_box = $Windows/NewsWindow/News
#onready var ticker_window = $Windows/NewsWindow
#
#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 _ready():
# ticker_window.window_title = JsonHelper.key_value(TICKER_PATH, CONFIG_FILE, "outlet")
#
# _randomize_news(json_files)
#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 _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):
# 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()
# _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 "[competing_outlet]" in news_text:
# news_text = news_text.replace("[competing_outlet]", JsonHelper.key_value(TICKER_PATH, CONFIG_FILE, "competing_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()
# 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)
#
# # Prevent stack overflaw
# if ticker_box.items.size() > 10:
# ticker_box.clear()
#
# _randomize_news(json_files)
# _add_news(news_text)
#
#func _add_news(news_item):
# ticker_text.text = news_item
# ticker_box.add_item(news_item)
#

View file

@ -1,4 +0,0 @@
extends Panel

View file

@ -1,5 +0,0 @@
extends Spatial
onready var node_viewport = $Viewport
onready var node_quad = $Quad
onready var node_area = $Quad/Area

View file

@ -1,29 +0,0 @@
extends Control
onready var debug_console = $Console
onready var tax_window = $TaxWindow
onready var advsior_meet_window = $AdvisorMeet
onready var tools_window = $ToolsWindow
onready var verLabel = $VersionLbl
func _ready():
# To get version string
var version = ProjectSettings.get_setting("application/config/version")
# To get build number
var build = ProjectSettings.get_setting("application/config/build")
verLabel.text = version + " (Build " + str(build) + ")"
SimData.city_name = SimData.city_name.capitalize()
SimData.mayor_name = SimData.mayor_name.capitalize()
SimEvents.emit_signal("advisor_message", SimData.Advisors.CITY_PLANNER, 0)
SimEvents.connect("send_alert", self, "_start_alert")
SimEvents.connect("rotate_news", self, "_rotate_news")
func _process(delta):
if Input.is_action_pressed("ui_cheats"):
debug_console.show()