UI and other changes

This commit is contained in:
Forrest 2026-10-07 13:41:38 -04:00
parent 87b5c11fcf
commit 215e24e246
79 changed files with 70023 additions and 2201 deletions

View file

@ -12,7 +12,8 @@ extends RefCounted
## supply shed's own shop (#6): weapons (corn_shooter, pumpkin_bomb) bought at its counter
## (ShedCounter), not the workbench, with the walk-in pouch deposit unaffected. And a pouch per
## scarecrow (#16): filled, deposited, and spent from by its own avatar slot, one shared capacity.
## And upgrade levels and timed shed stock (#26, _tiers and _stock).
## And upgrade levels and timed shed stock (#26, _tiers and _stock). And the HUD's backpack and
## pouch panel (ResourceHud).
const P := CampaignController.Phase
const DT := 1.0 / 60.0
@ -38,6 +39,7 @@ func run(r: GameTestRunner) -> void:
sim.waves.enabled = false
var player := farm.get_node("Player") as PlayerCharacter
_layout(r, sim)
_pouch_hud(r, farm, sim)
_gathering(r, sim, player)
_deposit_and_night(r, sim, player)
_patch_cost(r, sim)
@ -384,7 +386,7 @@ func _tiers(r: GameTestRunner) -> void:
## Timed shed stock (#26): each shed item arrives on its day ("from_day"; day N is the day before
## night N) and can't be bought before it. Its row shows just its name, greyed, and "Arrives on
## day N"; a hidden one shows "?" and its day until it arrives, then the bare "?" until revealed.
## Debug F8 (CampaignDebug.unlock_all): on day 1, every upgrade and shop item goes to its last
## Debug F4 (CampaignDebug.unlock_all): on day 1, every upgrade and shop item goes to its last
## level for free, each level's effect applied; a retry from the morning review keeps it, one from
## later in the day goes back to the morning without it.
func _unlock_all(r: GameTestRunner) -> void:
@ -400,14 +402,14 @@ func _unlock_all(r: GameTestRunner) -> void:
var shed: Dictionary = s.resources.shed.duplicate()
var damage := Upgrades.value(cfg, s, "shot_damage")
var key := InputEventKey.new()
key.physical_keycode = KEY_F8
key.physical_keycode = KEY_F4
key.pressed = true
debug._unhandled_input(key)
var all_max := true
for id: String in cfg.upgrades:
all_max = all_max and Upgrades.maxed(cfg, s, id) and Upgrades.blocker(c, id) == "Done"
r.check(all_max and s.night == 1 and Upgrades.levels_bought(cfg, s) == Upgrades.levels_total(cfg),
"F8 on the first morning: every upgrade and shop item at its last level (%d levels), hidden and not-yet-arrived ones too"
"F4 on the first morning: every upgrade and shop item at its last level (%d levels), hidden and not-yet-arrived ones too"
% Upgrades.levels_bought(cfg, s))
r.check(s.resources.shed == shed and int(s.night_events.get("upgrades_bought", 0)) == 0, "free, and not counted as bought")
r.check(s.scarecrow_max_hp == hp + 6 and s.scarecrow_hp == hp + 6 and s.resources.pouch_capacity == pouch + 16
@ -576,6 +578,44 @@ func _gathering(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> voi
_step(sim, 1)
## The HUD's backpack: "used/capacity", a red dot once something new is carried (gone once the pouch
## is opened, or emptied), and the pouch panel (I / R3) with what's carried and what the shed holds.
func _pouch_hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
var hud := farm.get_node("Hud/ResourceHud") as ResourceHud
var res := sim.campaign.state.resources
var keep_shed: Dictionary = res.shed.duplicate()
var keep_pouch: Dictionary = res.pouch.duplicate()
for m in ResourceStore.MATERIALS:
res.pouch[m] = 0
hud._process(0.0)
hud.open = false
r.check(not hud.new_items and hud.count_text() == "0/%d" % res.pouch_capacity, "an empty pouch: '%s', no dot" % hud.count_text())
res.add_to_pouch("wood", 3)
res.shed["scrap"] = 7
hud._process(0.0)
r.check(hud.count_text() == "3/%d" % res.pouch_capacity and hud.new_items, "the backpack counts what's carried ('%s'), with a dot for the new wood" % hud.count_text())
var press := InputEventAction.new()
press.action = &"pouch"
press.pressed = true
hud._unhandled_input(press)
var rows := hud.rows()
r.check(hud.open and not hud.new_items and rows.size() == ResourceStore.MATERIALS.size()
and rows[0] == {"material": "wood", "pouch": 3, "shed": int(res.shed["wood"])} and int(rows[1]["shed"]) == 7,
"I opens the pouch: what's carried and the shed's stock of each, and the dot goes: %s" % [rows])
hud._unhandled_input(press)
r.check(not hud.open, "and closes it again")
res.add_to_pouch("straw", 1)
hud._process(0.0)
var dot := hud.new_items
res.deposit()
hud._process(0.0)
r.check(dot and not hud.new_items, "emptying the pouch clears the dot")
for m in ResourceStore.MATERIALS:
res.shed[m] = int(keep_shed.get(m, 0))
res.pouch[m] = int(keep_pouch.get(m, 0))
hud._process(0.0)
func _deposit_and_night(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
var c := sim.campaign
var res := c.state.resources