diff --git a/economy.gd b/economy.gd index 5232656..075095b 100644 --- a/economy.gd +++ b/economy.gd @@ -3,6 +3,7 @@ extends Node signal productions_update(p: Array[Production]) @warning_ignore("unused_signal") signal production_log(producer: Currency, p: Production) +signal log(s: String) @export var currencies: Array[Production] @export var members: Array @@ -78,12 +79,15 @@ func simulate(): update_currencies() for e in events: if e.requirements_satisfied() and e.will_happen(): + if e.log_message != "" and not e.skip_log: + Economy.log.emit(e.log_message) var outcome := e.outcome() for o in outcome: if o == null: continue produce(o) - production_log.emit(null, o) + if e.log_message == "" and not e.skip_log: + production_log.emit(null, o) if e.timeline != null: GameState.add_letter.emit(e.into_letter()) if randf() < 0.01: diff --git a/event.gd b/event.gd index 47d04c0..347d636 100644 --- a/event.gd +++ b/event.gd @@ -16,6 +16,7 @@ enum EventNature { @export var nature: EventNature = EventNature.Random @export var email_source: Currency = preload("res://currency/sentient/town_crier.tres") @export var email_subject: String = "Something is amok!" +@export var log_message: String = "" func requirements_satisfied() -> bool: for requirement in requirements: diff --git a/gui/production_ledger.gd b/gui/production_ledger.gd index 5c6bf50..0c0f192 100644 --- a/gui/production_ledger.gd +++ b/gui/production_ledger.gd @@ -5,6 +5,19 @@ extends VBoxContainer func _ready() -> void: Economy.production_log.connect(append) + Economy.log.connect(log) + +func log(s: String): + var display := preload("res://gui/production_log.tscn").instantiate() + display.set_color(new_message_color) + for child in get_children(): + if child is ProductionLog and child.is_old: + child.set_color(old_message_color) + display.generic = true + display.generic_text = s + add_child(display) + move_child(display, 0) + func append(producer: Currency, production: Production): var display := preload("res://gui/production_log.tscn").instantiate() diff --git a/gui/production_log.gd b/gui/production_log.gd index e9737ed..ffec435 100644 --- a/gui/production_log.gd +++ b/gui/production_log.gd @@ -3,27 +3,38 @@ class_name ProductionLog @export var producer: Currency = null @export var production: Production +@export var generic: bool = false +@export var generic_text: String = "" + var is_old: bool = false func _ready() -> void: - if producer != null: - %producer.text = producer.name - %Production.visible = true + if generic: + %GenericMessage.visible = true + %GenericMessage.text = generic_text + %Production.visible = false %Production2.visible = false else: - %Production.visible = false - %Production2.visible = true - %amount.text = str(abs(production.amount)) - %amount2.text = str(abs(production.amount)) - if production.amount > 0: - %type.text = "produced " - %producer2.text = "You gained " - else: - %type.text = "consumed " - %producer2.text = "You lost " - - %production.text = production.currency.name - %production2.text = production.currency.name + if producer != null: + %producer.text = producer.name + %GenericMessage.visible = false + %Production.visible = true + %Production2.visible = false + else: + %GenericMessage.visible = false + %Production.visible = false + %Production2.visible = true + %amount.text = str(abs(production.amount)) + %amount2.text = str(abs(production.amount)) + if production.amount > 0: + %type.text = "produced " + %producer2.text = "You gained " + else: + %type.text = "consumed " + %producer2.text = "You lost " + if production != null: + %production.text = production.currency.name + %production2.text = production.currency.name make_old.call_deferred() func make_old(): diff --git a/gui/production_log.tscn b/gui/production_log.tscn index 96500af..712acba 100644 --- a/gui/production_log.tscn +++ b/gui/production_log.tscn @@ -5,6 +5,10 @@ [node name="ProductionLog" type="MarginContainer" unique_id=253822540] script = ExtResource("1_ei3g1") +[node name="GenericMessage" type="Label" parent="." unique_id=712313778] +unique_name_in_owner = true +layout_mode = 2 + [node name="Production" type="HBoxContainer" parent="." unique_id=1073672077] unique_name_in_owner = true layout_mode = 2 diff --git a/random events/a_pig_flew.tres b/random events/a_pig_flew.tres index 564f117..9613926 100644 --- a/random events/a_pig_flew.tres +++ b/random events/a_pig_flew.tres @@ -1,6 +1,7 @@ [gd_resource type="Resource" script_class="Event" format=3 uid="uid://ddjairvlvswck"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_puqnt"] +[ext_resource type="Resource" uid="uid://chsv8oeajty8j" path="res://currency/sentient/town_crier.tres" id="1_unbcn"] [ext_resource type="Resource" uid="uid://b5qok0rcalr" path="res://currency/sentient/cow.tres" id="2_tqpw4"] [ext_resource type="Resource" uid="uid://dsohovjbf3s2p" path="res://currency/sentient/chicken.tres" id="3_unbcn"] [ext_resource type="Resource" uid="uid://rdrcyvuvrp2m" path="res://currency/sentient/pig.tres" id="4_k6ytv"] diff --git a/random events/bar_crawl.tres b/random events/bar_crawl.tres index 85df42d..b43fe49 100644 --- a/random events/bar_crawl.tres +++ b/random events/bar_crawl.tres @@ -1,6 +1,7 @@ [gd_resource type="Resource" script_class="Event" format=3 uid="uid://s2n6eankt20p"] [ext_resource type="Resource" uid="uid://dv834343s36af" path="res://currency/sentient/drunk.tres" id="1_dvejf"] +[ext_resource type="Resource" uid="uid://chsv8oeajty8j" path="res://currency/sentient/town_crier.tres" id="1_ilimp"] [ext_resource type="Script" uid="uid://diwdxofo6exg3" path="res://event.gd" id="1_qbpgq"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="2_iq8td"] [ext_resource type="Resource" uid="uid://bfc53d345i1h5" path="res://test/bar_crawl.dtl" id="4_iq8td"] diff --git a/random events/blood_rain.tres b/random events/blood_rain.tres index 247d312..e910dc8 100644 --- a/random events/blood_rain.tres +++ b/random events/blood_rain.tres @@ -2,6 +2,7 @@ [ext_resource type="Script" uid="uid://diwdxofo6exg3" path="res://event.gd" id="1_dxq8u"] [ext_resource type="Resource" uid="uid://by3dayfdpobpt" path="res://currency/inanimate/blood.tres" id="1_jlulm"] +[ext_resource type="Resource" uid="uid://chsv8oeajty8j" path="res://currency/sentient/town_crier.tres" id="1_tqf2y"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="2_arfor"] [ext_resource type="Resource" uid="uid://ikwdxjpxukej" path="res://test/blood_rain.dtl" id="4_arfor"] diff --git a/random events/dino.tres b/random events/dino.tres index 9b37ce4..f912979 100644 --- a/random events/dino.tres +++ b/random events/dino.tres @@ -2,6 +2,7 @@ [ext_resource type="Resource" uid="uid://clx8tbrad4m7c" path="res://currency/sentient/dinosaur.tres" id="1_0jmdm"] [ext_resource type="Script" uid="uid://diwdxofo6exg3" path="res://event.gd" id="1_sui6i"] +[ext_resource type="Resource" uid="uid://chsv8oeajty8j" path="res://currency/sentient/town_crier.tres" id="1_sy7r4"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="2_1x1ll"] [ext_resource type="Resource" uid="uid://25iq6i8ltb6v" path="res://test/dino.dtl" id="4_1x1ll"] diff --git a/random events/drought.tres b/random events/drought.tres index 298608d..31f638f 100644 --- a/random events/drought.tres +++ b/random events/drought.tres @@ -1,6 +1,7 @@ [gd_resource type="Resource" script_class="Event" format=3 uid="uid://vtlqhmhi0yeq"] [ext_resource type="Resource" uid="uid://b8b6yr444ecdk" path="res://currency/inanimate/water.tres" id="1_d7ltk"] +[ext_resource type="Resource" uid="uid://chsv8oeajty8j" path="res://currency/sentient/town_crier.tres" id="1_unbv5"] [ext_resource type="Script" uid="uid://diwdxofo6exg3" path="res://event.gd" id="1_ut0k2"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="2_rh8yf"] [ext_resource type="Resource" uid="uid://damk3l2oj6gkd" path="res://test/drought.dtl" id="4_rh8yf"]