This commit is contained in:
Forrest 2026-10-04 17:30:48 -04:00
parent 4298caf5cb
commit 2e6638b744
19 changed files with 484 additions and 185 deletions

View file

@ -4,17 +4,19 @@ extends Control
## sweeps full while it cools down and flashes when it is ready again, the patch hint with its
## progress, and once the Sprint upgrade is bought a sprint line (ready, seconds left, or
## recharging); plus a red screen tint when the scarecrow is hit. Bottom-right, the weapons:
## the three by number, the one in hand marked, the ones not bought yet greyed out (from the
## workbench), the pumpkin bomb's recharge, and how to switch.
## the main ones by number, the one in hand marked, and how to switch; under them the off-hand
## (pumpkin bombs, marked when one is ready, else its recharge) and its button. The ones not
## bought yet are greyed out (from the workbench).
const PIP := Vector2(22.0, 16.0)
const PIP_GAP := 5.0
const FEAR_RADIUS := 26.0
## Extra height of the panel for the sprint line.
const SPRINT_ROW := 30.0
## The weapon panel, from the bottom-right corner, and its rows.
const WEAPONS := Rect2(-340.0, -176.0, 304.0, 150.0)
## The weapon panel, from the bottom-right corner, its rows, and where its off-hand part starts.
const WEAPONS := Rect2(-340.0, -220.0, 304.0, 194.0)
const WEAPON_ROW := 30.0
const OFFHAND_TOP := 122.0
var kit: Scarecrow
## This machine's scarecrow's weapons.
@ -31,6 +33,8 @@ var _sprint_label: Label
var _weapon_title: Label
var _weapon_rows: Array[Label] = []
var _weapon_hint: Label
var _offhand_title: Label
var _offhand_rows: Array[Label] = []
var _hit: float = 0.0
var _ready_flash: float = 0.0
@ -72,11 +76,15 @@ func _ready() -> void:
_patch_label = _label(20)
_sprint_label = _label(20)
_weapon_title = _label(18)
_weapon_title.text = "Weapon"
for i in ScarecrowCombat.WEAPON_NAMES.size():
_weapon_title.text = "Main weapon"
for i in ScarecrowCombat.MAIN_WEAPONS.size():
_weapon_rows.append(_label(20))
_weapon_hint = _label(16)
_weapon_hint.text = "Switch: Tab / 1-3 / d-pad down"
_weapon_hint.text = "Switch: Tab / 1-2 / d-pad down"
_offhand_title = _label(18)
_offhand_title.text = "Off-hand right mouse / LT"
for i in ScarecrowCombat.OFFHAND_WEAPONS.size():
_offhand_rows.append(_label(20))
func _process(delta: float) -> void:
@ -123,29 +131,42 @@ func _process(delta: float) -> void:
func _update_weapons() -> void:
var shown := combat != null
_weapon_title.visible = shown
_weapon_hint.visible = shown
for l in _weapon_rows:
for l: Label in [_weapon_title, _weapon_hint, _offhand_title] + _weapon_rows + _offhand_rows:
l.visible = shown
if not shown:
return
var at := _weapons_rect().position
_weapon_title.position = at + Vector2(12.0, 6.0)
for i in _weapon_rows.size():
var l := _weapon_rows[i]
var text := "%d %s" % [i + 1, ScarecrowCombat.WEAPON_NAMES[i]]
var color := Color(0.95, 0.95, 0.95)
if not combat.owns(i):
text += " (workbench)"
color = Color(0.55, 0.55, 0.55)
elif i == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0:
text += " %.0f s" % ceilf(combat.bomb_left)
if i == combat.weapon:
color = Color(1.0, 0.85, 0.3)
l.text = text
l.add_theme_color_override("font_color", color)
l.position = at + Vector2(30.0, 30.0 + i * WEAPON_ROW)
for k in _weapon_rows.size():
var w := ScarecrowCombat.MAIN_WEAPONS[k]
_weapon_row(_weapon_rows[k], "%d %s" % [k + 1, ScarecrowCombat.WEAPON_NAMES[w]], w, w == combat.weapon)
_weapon_rows[k].position = at + Vector2(30.0, 30.0 + k * WEAPON_ROW)
_weapon_hint.position = at + Vector2(12.0, 30.0 + _weapon_rows.size() * WEAPON_ROW + 2.0)
_offhand_title.position = at + Vector2(12.0, OFFHAND_TOP + 6.0)
for k in _offhand_rows.size():
var w := ScarecrowCombat.OFFHAND_WEAPONS[k]
var text := ScarecrowCombat.WEAPON_NAMES[w]
if w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.owns(w) and combat.bomb_left > 0.0:
text += " %.0f s" % ceilf(combat.bomb_left)
_weapon_row(_offhand_rows[k], text, w, _offhand_lit(w))
_offhand_rows[k].position = at + Vector2(30.0, OFFHAND_TOP + 30.0 + k * WEAPON_ROW)
## A weapon's row: greyed out until it's bought, gold when it's in hand (lit).
func _weapon_row(l: Label, text: String, w: int, lit: bool) -> void:
var color := Color(0.95, 0.95, 0.95)
if not combat.owns(w):
text += " (workbench)"
color = Color(0.55, 0.55, 0.55)
elif lit:
color = Color(1.0, 0.85, 0.3)
l.text = text
l.add_theme_color_override("font_color", color)
## Whether the off-hand weapon is in the off-hand and ready (a pumpkin bomb not recharging).
func _offhand_lit(w: int) -> bool:
return w == combat.offhand and not (w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0)
func _weapons_rect() -> Rect2:
@ -178,15 +199,23 @@ func _draw() -> void:
if combat != null:
var w := _weapons_rect()
draw_rect(w, Color(0.0, 0.0, 0.0, 0.42))
var row := Rect2(w.position + Vector2(6.0, 32.0 + combat.weapon * WEAPON_ROW), Vector2(w.size.x - 12.0, WEAPON_ROW - 2.0))
draw_rect(row, Color(1.0, 0.85, 0.3, 0.18))
draw_rect(Rect2(row.position, Vector2(4.0, row.size.y)), Color(1.0, 0.85, 0.3))
_draw_lit_row(w, 32.0 + ScarecrowCombat.MAIN_WEAPONS.find(combat.weapon) * WEAPON_ROW)
var off := ScarecrowCombat.OFFHAND_WEAPONS.find(combat.offhand)
if off >= 0 and _offhand_lit(combat.offhand):
_draw_lit_row(w, OFFHAND_TOP + 32.0 + off * WEAPON_ROW)
if kit.patching:
var bar := Rect2(base + Vector2(FEAR_RADIUS * 2.0 + 14.0, 92.0), Vector2(210.0, 8.0))
draw_rect(bar, Color(0.1, 0.1, 0.1, 0.9))
draw_rect(Rect2(bar.position, Vector2(bar.size.x * kit.patch_elapsed / kit.config.patch_time, bar.size.y)), Color(0.45, 1.0, 0.4))
## The marked row of the weapon panel w, top pixels down.
func _draw_lit_row(w: Rect2, top: float) -> void:
var row := Rect2(w.position + Vector2(6.0, top), Vector2(w.size.x - 12.0, WEAPON_ROW - 2.0))
draw_rect(row, Color(1.0, 0.85, 0.3, 0.18))
draw_rect(Rect2(row.position, Vector2(4.0, row.size.y)), Color(1.0, 0.85, 0.3))
func _base() -> Vector2:
return Vector2(36.0, size.y - 126.0 - (SPRINT_ROW if _sprint_shown() else 0.0))