|
|
|
@@ -0,0 +1,365 @@
|
|
|
|
|
## The in-game HUD (A9), in the paper-and-ink motifs of docs/STYLE.md: a painted tide
|
|
|
|
|
## post at top centre (the tide is the match's clock), who is standing and the kill feed
|
|
|
|
|
## at top right, health and armour at bottom left, the boathook and five slots at bottom
|
|
|
|
|
## centre, materials and build mode at bottom right.
|
|
|
|
|
##
|
|
|
|
|
## Laid out for a 1280x720 canvas; the project's canvas_items stretch scales it to any
|
|
|
|
|
## screen. Nothing relies on colour alone: health and armour carry numbers, words and
|
|
|
|
|
## different patterns, tiers are pips, and the tide's danger is a word and a notch.
|
|
|
|
|
## show_state() takes a HudState and draws only that.
|
|
|
|
|
class_name Hud
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
const FONT_SMALL: int = 13
|
|
|
|
|
const FONT_BODY: int = 16
|
|
|
|
|
const FONT_TITLE: int = 22
|
|
|
|
|
const MARGIN: float = 18.0
|
|
|
|
|
|
|
|
|
|
var state: HudState = HudState.new()
|
|
|
|
|
|
|
|
|
|
var _tide: TidePost
|
|
|
|
|
var _standing: Label
|
|
|
|
|
var _feed: VBoxContainer
|
|
|
|
|
var _vitals: Vitals
|
|
|
|
|
var _hotbar: HBoxContainer
|
|
|
|
|
var _materials: VBoxContainer
|
|
|
|
|
var _build: Label
|
|
|
|
|
## When a feed line was first shown (msec), so lines fade after HudState.FEED_SECONDS.
|
|
|
|
|
var _feed_seen: Dictionary = {}
|
|
|
|
|
## Captures turn this off to keep every line of the feed.
|
|
|
|
|
var fade_feed: bool = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
name = "Hud"
|
|
|
|
|
set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
|
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
|
|
|
|
_tide = TidePost.new()
|
|
|
|
|
_tide.set_anchors_preset(Control.PRESET_CENTER_TOP)
|
|
|
|
|
_tide.custom_minimum_size = Vector2(330.0, 104.0)
|
|
|
|
|
_tide.size = _tide.custom_minimum_size
|
|
|
|
|
_tide.position = Vector2(-165.0, MARGIN - 6.0)
|
|
|
|
|
add_child(_tide)
|
|
|
|
|
|
|
|
|
|
_standing = _label(FONT_TITLE, Palette.PAPER)
|
|
|
|
|
_standing.set_anchors_preset(Control.PRESET_TOP_RIGHT)
|
|
|
|
|
_standing.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
|
|
|
|
_standing.position = Vector2(-320.0 - MARGIN, MARGIN)
|
|
|
|
|
_standing.size = Vector2(320.0, 30.0)
|
|
|
|
|
add_child(_standing)
|
|
|
|
|
|
|
|
|
|
_feed = VBoxContainer.new()
|
|
|
|
|
_feed.set_anchors_preset(Control.PRESET_TOP_RIGHT)
|
|
|
|
|
_feed.position = Vector2(-380.0 - MARGIN, MARGIN + 36.0)
|
|
|
|
|
_feed.size = Vector2(380.0, 140.0)
|
|
|
|
|
_feed.alignment = BoxContainer.ALIGNMENT_BEGIN
|
|
|
|
|
_feed.add_theme_constant_override("separation", 2)
|
|
|
|
|
add_child(_feed)
|
|
|
|
|
|
|
|
|
|
_vitals = Vitals.new()
|
|
|
|
|
_vitals.set_anchors_preset(Control.PRESET_BOTTOM_LEFT)
|
|
|
|
|
_vitals.custom_minimum_size = Vector2(270.0, 76.0)
|
|
|
|
|
_vitals.size = _vitals.custom_minimum_size
|
|
|
|
|
_vitals.position = Vector2(MARGIN, -76.0 - MARGIN)
|
|
|
|
|
add_child(_vitals)
|
|
|
|
|
|
|
|
|
|
_hotbar = HBoxContainer.new()
|
|
|
|
|
_hotbar.set_anchors_preset(Control.PRESET_CENTER_BOTTOM)
|
|
|
|
|
_hotbar.add_theme_constant_override("separation", 6)
|
|
|
|
|
_hotbar.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
|
|
|
_hotbar.size = Vector2(6.0 * 86.0 + 5.0 * 6.0, 84.0)
|
|
|
|
|
_hotbar.position = Vector2(-_hotbar.size.x * 0.5, -84.0 - MARGIN)
|
|
|
|
|
add_child(_hotbar)
|
|
|
|
|
|
|
|
|
|
_build = _label(FONT_BODY, Palette.PAPER)
|
|
|
|
|
_build.set_anchors_preset(Control.PRESET_CENTER_BOTTOM)
|
|
|
|
|
_build.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
|
|
|
_build.size = Vector2(520.0, 24.0)
|
|
|
|
|
_build.position = Vector2(-260.0, -84.0 - MARGIN - 30.0)
|
|
|
|
|
add_child(_build)
|
|
|
|
|
|
|
|
|
|
_materials = VBoxContainer.new()
|
|
|
|
|
_materials.set_anchors_preset(Control.PRESET_BOTTOM_RIGHT)
|
|
|
|
|
_materials.size = Vector2(190.0, 84.0)
|
|
|
|
|
_materials.position = Vector2(-190.0 - MARGIN, -84.0 - MARGIN)
|
|
|
|
|
_materials.add_theme_constant_override("separation", 2)
|
|
|
|
|
add_child(_materials)
|
|
|
|
|
show_state(state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Shows `shown`, and nothing that isn't in it.
|
|
|
|
|
func show_state(shown: HudState) -> void:
|
|
|
|
|
state = shown
|
|
|
|
|
_tide.tide = shown.tide
|
|
|
|
|
_tide.visible = not shown.tide.is_empty()
|
|
|
|
|
_tide.queue_redraw()
|
|
|
|
|
_standing.visible = shown.total > 0
|
|
|
|
|
_standing.text = "%d of %d standing" % [shown.standing, shown.total]
|
|
|
|
|
|
|
|
|
|
var now: int = Time.get_ticks_msec()
|
|
|
|
|
var lines: Array[Dictionary] = []
|
|
|
|
|
for line: Dictionary in shown.feed:
|
|
|
|
|
var key: String = String(line["text"])
|
|
|
|
|
if not _feed_seen.has(key):
|
|
|
|
|
_feed_seen[key] = now
|
|
|
|
|
if fade_feed and now - int(_feed_seen[key]) > int(HudState.FEED_SECONDS * 1000.0):
|
|
|
|
|
continue
|
|
|
|
|
lines.append(line)
|
|
|
|
|
_fit_labels(_feed, lines.size(), HORIZONTAL_ALIGNMENT_RIGHT)
|
|
|
|
|
for index: int in lines.size():
|
|
|
|
|
var label: Label = _feed.get_child(index) as Label
|
|
|
|
|
label.text = String(lines[index]["text"])
|
|
|
|
|
label.add_theme_color_override("font_color", Palette.OILSKIN if lines[index]["you"] else Palette.PAPER)
|
|
|
|
|
if shown.feed.is_empty():
|
|
|
|
|
_feed_seen.clear()
|
|
|
|
|
|
|
|
|
|
_vitals.visible = shown.playing
|
|
|
|
|
_vitals.health = shown.health
|
|
|
|
|
_vitals.armor = shown.armor
|
|
|
|
|
_vitals.queue_redraw()
|
|
|
|
|
|
|
|
|
|
_hotbar.visible = shown.playing
|
|
|
|
|
while _hotbar.get_child_count() < shown.slots.size():
|
|
|
|
|
var box: SlotBox = SlotBox.new()
|
|
|
|
|
box.custom_minimum_size = Vector2(86.0, 84.0)
|
|
|
|
|
_hotbar.add_child(box)
|
|
|
|
|
for index: int in _hotbar.get_child_count():
|
|
|
|
|
var box: SlotBox = _hotbar.get_child(index) as SlotBox
|
|
|
|
|
box.visible = index < shown.slots.size()
|
|
|
|
|
if box.visible:
|
|
|
|
|
box.slot = shown.slots[index]
|
|
|
|
|
box.number = index
|
|
|
|
|
box.queue_redraw()
|
|
|
|
|
|
|
|
|
|
_materials.visible = shown.playing
|
|
|
|
|
_fit_labels(_materials, Materials.NAMES.size(), HORIZONTAL_ALIGNMENT_RIGHT)
|
|
|
|
|
for code: int in Materials.NAMES.size():
|
|
|
|
|
var count: int = shown.materials[code] if code < shown.materials.size() else 0
|
|
|
|
|
(_materials.get_child(code) as Label).text = "%s %d" % [Materials.NAMES[code].replace("_", " ").capitalize(), count]
|
|
|
|
|
|
|
|
|
|
_build.visible = shown.playing and not shown.build.is_empty()
|
|
|
|
|
if _build.visible:
|
|
|
|
|
var build: Dictionary = shown.build
|
|
|
|
|
_build.text = "BUILDING · %s in %s · costs %d%s" % [String(build["kind"]).capitalize(), String(build["material"]).replace("_", " "),
|
|
|
|
|
int(build["cost"]), "" if build["affordable"] else " · NOT ENOUGH"]
|
|
|
|
|
_build.add_theme_color_override("font_color", Palette.PAPER if build["affordable"] else Palette.WARNING)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Keeps exactly `count` labels in `box`, adding or removing at the end.
|
|
|
|
|
func _fit_labels(box: BoxContainer, count: int, align: HorizontalAlignment) -> void:
|
|
|
|
|
while box.get_child_count() < count:
|
|
|
|
|
var label: Label = _label(FONT_BODY, Palette.PAPER)
|
|
|
|
|
label.horizontal_alignment = align
|
|
|
|
|
box.add_child(label)
|
|
|
|
|
while box.get_child_count() > count:
|
|
|
|
|
var last: Node = box.get_child(box.get_child_count() - 1)
|
|
|
|
|
box.remove_child(last)
|
|
|
|
|
last.free()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _label(font_size: int, colour: Color) -> Label:
|
|
|
|
|
var label: Label = Label.new()
|
|
|
|
|
label.add_theme_font_size_override("font_size", font_size)
|
|
|
|
|
label.add_theme_color_override("font_color", colour)
|
|
|
|
|
label.add_theme_color_override("font_outline_color", Palette.OUTLINE)
|
|
|
|
|
label.add_theme_constant_override("outline_size", 5)
|
|
|
|
|
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
return label
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## A paper panel with an ink border and an offset ink shadow, like a printed card.
|
|
|
|
|
static func draw_card(item: CanvasItem, rect: Rect2, raised: bool = false) -> void:
|
|
|
|
|
item.draw_rect(Rect2(rect.position + Vector2(3.0, 3.0), rect.size), Color(Palette.INK, 0.55))
|
|
|
|
|
item.draw_rect(rect, Color(Palette.PAPER, 0.93))
|
|
|
|
|
item.draw_rect(rect, Palette.INK, false, 3.0 if raised else 1.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func draw_text(item: CanvasItem, at: Vector2, text: String, font_size: int, colour: Color = Palette.INK,
|
|
|
|
|
width: float = -1.0, align: HorizontalAlignment = HORIZONTAL_ALIGNMENT_LEFT) -> void:
|
|
|
|
|
var font: Font = ThemeDB.fallback_font
|
|
|
|
|
item.draw_string(font, at, text, align, width, font_size, colour)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func roman(value: int) -> String:
|
|
|
|
|
const NUMERALS: Array[String] = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
|
|
|
|
|
return NUMERALS[value] if value >= 0 and value < NUMERALS.size() else str(value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The tide post: a notched wooden post with the sea filled to its level, the next
|
|
|
|
|
## level's notch, and the player's own height, beside the phase and the time to the rise.
|
|
|
|
|
class TidePost:
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
var tide: Dictionary = {}
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
|
if tide.is_empty():
|
|
|
|
|
return
|
|
|
|
|
var card: Rect2 = Rect2(Vector2.ZERO, size)
|
|
|
|
|
Hud.draw_card(self, card)
|
|
|
|
|
var sea: float = tide["sea"]
|
|
|
|
|
var next: float = tide["next"]
|
|
|
|
|
var feet: float = tide["feet"]
|
|
|
|
|
var low: float = floorf(sea - 3.0)
|
|
|
|
|
var high: float = maxf(next, sea) + 5.0
|
|
|
|
|
if not is_nan(feet):
|
|
|
|
|
high = maxf(high, minf(feet + 2.0, low + 40.0))
|
|
|
|
|
var post: Rect2 = Rect2(16.0, 10.0, 26.0, size.y - 20.0)
|
|
|
|
|
var to_y: Callable = func(level: float) -> float:
|
|
|
|
|
return post.end.y - clampf((level - low) / (high - low), 0.0, 1.0) * post.size.y
|
|
|
|
|
draw_rect(post, Palette.PLANK_BLEACHED)
|
|
|
|
|
# Water up to the sea, with a wave cut across its top.
|
|
|
|
|
var water_top: float = to_y.call(sea)
|
|
|
|
|
draw_rect(Rect2(post.position.x, water_top, post.size.x, post.end.y - water_top), Palette.SEA_INK)
|
|
|
|
|
var wave: PackedVector2Array = PackedVector2Array()
|
|
|
|
|
for step: int in 7:
|
|
|
|
|
wave.append(Vector2(post.position.x + post.size.x * step / 6.0, water_top + (2.5 if step % 2 == 0 else -2.5)))
|
|
|
|
|
draw_polyline(wave, Palette.PAPER, 1.5)
|
|
|
|
|
# Notches each metre, longer each five.
|
|
|
|
|
var metre: float = ceilf(low)
|
|
|
|
|
while metre <= high:
|
|
|
|
|
var y: float = to_y.call(metre)
|
|
|
|
|
var long: bool = int(metre) % 5 == 0
|
|
|
|
|
draw_line(Vector2(post.position.x, y), Vector2(post.position.x + (12.0 if long else 6.0), y), Palette.INK, 1.0)
|
|
|
|
|
metre += 1.0
|
|
|
|
|
draw_rect(post, Palette.INK, false, 1.5)
|
|
|
|
|
# The next level: a rust notch cut into both sides, with a dashed line across.
|
|
|
|
|
if next > sea + 0.05:
|
|
|
|
|
var next_y: float = to_y.call(next)
|
|
|
|
|
draw_dashed_line(Vector2(post.position.x - 6.0, next_y), Vector2(post.end.x + 6.0, next_y), Palette.WARNING, 2.0, 4.0)
|
|
|
|
|
draw_colored_polygon(PackedVector2Array([Vector2(post.position.x - 10.0, next_y - 5.0), Vector2(post.position.x - 2.0, next_y), Vector2(post.position.x - 10.0, next_y + 5.0)]), Palette.WARNING)
|
|
|
|
|
# The player's own height: a yellow pointer on the right of the post.
|
|
|
|
|
if not is_nan(feet):
|
|
|
|
|
var feet_y: float = to_y.call(feet)
|
|
|
|
|
draw_colored_polygon(PackedVector2Array([Vector2(post.end.x + 2.0, feet_y), Vector2(post.end.x + 12.0, feet_y - 6.0), Vector2(post.end.x + 12.0, feet_y + 6.0)]), Palette.OILSKIN)
|
|
|
|
|
draw_polyline(PackedVector2Array([Vector2(post.end.x + 2.0, feet_y), Vector2(post.end.x + 12.0, feet_y - 6.0), Vector2(post.end.x + 12.0, feet_y + 6.0), Vector2(post.end.x + 2.0, feet_y)]), Palette.INK, 1.0)
|
|
|
|
|
|
|
|
|
|
var x: float = post.end.x + 26.0
|
|
|
|
|
var width: float = size.x - x - 10.0
|
|
|
|
|
Hud.draw_text(self, Vector2(x, 30.0), "TIDE %s of %s" % [Hud.roman(int(tide["phase"])), Hud.roman(int(tide["phases"]))], Hud.FONT_TITLE)
|
|
|
|
|
var stage: int = tide["stage"]
|
|
|
|
|
var timing: String
|
|
|
|
|
match stage:
|
|
|
|
|
Tide.HOLD:
|
|
|
|
|
var seconds: int = ceili(float(tide["rise_in"]))
|
|
|
|
|
timing = "Rises in %d:%02d" % [seconds / 60, seconds % 60]
|
|
|
|
|
Tide.RISE:
|
|
|
|
|
timing = "RISING"
|
|
|
|
|
Tide.SUDDEN_DEATH:
|
|
|
|
|
timing = "HIGH WATER · last land"
|
|
|
|
|
_:
|
|
|
|
|
timing = "Slack water"
|
|
|
|
|
Hud.draw_text(self, Vector2(x, 54.0), timing, Hud.FONT_BODY, Palette.WARNING if stage != Tide.HOLD else Palette.INK, width)
|
|
|
|
|
Hud.draw_text(self, Vector2(x, 74.0), "Sea %.1f m · next %.1f m" % [sea, next], Hud.FONT_SMALL, Palette.INK, width)
|
|
|
|
|
if not is_nan(feet):
|
|
|
|
|
var above: float = feet - next
|
|
|
|
|
var line: String = "You: %.1f m above the next line" % above if above >= 0.0 else "You: %.1f m BELOW the next line" % -above
|
|
|
|
|
Hud.draw_text(self, Vector2(x, 92.0), line, Hud.FONT_SMALL, Palette.INK if above >= 0.0 else Palette.WARNING, width)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Health and armour bars: each a number, a word, notches every quarter and its own
|
|
|
|
|
## pattern, so they read without colour. Low health adds LOW and rust hatching.
|
|
|
|
|
class Vitals:
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
var health: int = 0
|
|
|
|
|
var armor: int = 0
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
|
Hud.draw_card(self, Rect2(Vector2.ZERO, size))
|
|
|
|
|
_bar(Rect2(76.0, 12.0, size.x - 88.0, 22.0), "HEALTH", health, Tuning.PLAYER_MAX_HEALTH, false)
|
|
|
|
|
_bar(Rect2(76.0, 44.0, size.x - 88.0, 18.0), "ARMOUR", armor, Tuning.PLAYER_MAX_ARMOR, true)
|
|
|
|
|
|
|
|
|
|
func _bar(rect: Rect2, word: String, value: int, most: int, striped: bool) -> void:
|
|
|
|
|
var low: bool = not striped and value <= most / 4
|
|
|
|
|
Hud.draw_text(self, Vector2(10.0, rect.position.y + rect.size.y * 0.5 + 5.0), word, Hud.FONT_SMALL)
|
|
|
|
|
draw_rect(rect, Color(Palette.INK, 0.15))
|
|
|
|
|
var filled: Rect2 = Rect2(rect.position, Vector2(rect.size.x * clampf(float(value) / most, 0.0, 1.0), rect.size.y))
|
|
|
|
|
var fill: Color = Palette.WARNING if low else (Palette.SEA_PAINT if striped else Palette.OCHRE_RED.lerp(Palette.TAR, 0.1))
|
|
|
|
|
draw_rect(filled, fill)
|
|
|
|
|
if striped or low:
|
|
|
|
|
# Armour is hatched one way; low health the other.
|
|
|
|
|
var step: float = 6.0
|
|
|
|
|
var x: float = filled.position.x - filled.size.y
|
|
|
|
|
while x < filled.end.x:
|
|
|
|
|
var a: Vector2 = Vector2(x, filled.end.y) if striped else Vector2(x, filled.position.y)
|
|
|
|
|
var b: Vector2 = Vector2(x + filled.size.y, filled.position.y) if striped else Vector2(x + filled.size.y, filled.end.y)
|
|
|
|
|
var clipped: PackedVector2Array = _clip(a, b, filled)
|
|
|
|
|
if clipped.size() == 2:
|
|
|
|
|
draw_line(clipped[0], clipped[1], Color(Palette.INK, 0.45), 1.5)
|
|
|
|
|
x += step
|
|
|
|
|
for quarter: int in range(1, 4):
|
|
|
|
|
var qx: float = rect.position.x + rect.size.x * quarter / 4.0
|
|
|
|
|
draw_line(Vector2(qx, rect.position.y), Vector2(qx, rect.position.y + 5.0), Palette.INK, 1.0)
|
|
|
|
|
draw_rect(rect, Palette.INK, false, 1.5)
|
|
|
|
|
var text: String = "%d%s" % [value, " LOW" if low else ""]
|
|
|
|
|
Hud.draw_text(self, Vector2(rect.position.x + 6.0, rect.position.y + rect.size.y * 0.5 + 5.0), text, Hud.FONT_BODY,
|
|
|
|
|
Palette.PAPER if value > most / 3 else Palette.INK)
|
|
|
|
|
|
|
|
|
|
static func _clip(a: Vector2, b: Vector2, rect: Rect2) -> PackedVector2Array:
|
|
|
|
|
# Clips the segment to the rect's x range (the y range always fits).
|
|
|
|
|
var from: Vector2 = a
|
|
|
|
|
var to: Vector2 = b
|
|
|
|
|
if to.x < rect.position.x or from.x > rect.end.x:
|
|
|
|
|
return PackedVector2Array()
|
|
|
|
|
if from.x < rect.position.x:
|
|
|
|
|
from = from.lerp(to, (rect.position.x - from.x) / (to.x - from.x))
|
|
|
|
|
if to.x > rect.end.x:
|
|
|
|
|
to = from.lerp(to, (rect.end.x - from.x) / (to.x - from.x))
|
|
|
|
|
return PackedVector2Array([from, to])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## One hotbar slot: its key number, the item's name, count or rounds, and tier pips.
|
|
|
|
|
## The held one is raised, has a heavier border and an oilskin band.
|
|
|
|
|
class SlotBox:
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
var slot: Dictionary = {}
|
|
|
|
|
var number: int = 0
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
|
var selected: bool = bool(slot.get("selected", false))
|
|
|
|
|
var rect: Rect2 = Rect2(Vector2(0.0, 0.0 if selected else 8.0), size - Vector2(0.0, 8.0))
|
|
|
|
|
if bool(slot.get("empty", true)):
|
|
|
|
|
draw_rect(rect, Color(Palette.INK, 0.35))
|
|
|
|
|
draw_rect(rect, Color(Palette.PAPER_DIM, 0.8), false, 1.0)
|
|
|
|
|
Hud.draw_text(self, rect.position + Vector2(6.0, 16.0), str(number), Hud.FONT_SMALL, Palette.PAPER_DIM)
|
|
|
|
|
return
|
|
|
|
|
Hud.draw_card(self, rect, selected)
|
|
|
|
|
if selected:
|
|
|
|
|
draw_rect(Rect2(rect.position, Vector2(rect.size.x, 6.0)), Palette.OILSKIN)
|
|
|
|
|
draw_rect(Rect2(rect.position, Vector2(rect.size.x, 6.0)), Palette.INK, false, 1.0)
|
|
|
|
|
Hud.draw_text(self, rect.position + Vector2(5.0, 15.0), str(number), Hud.FONT_SMALL - 2, Palette.INK)
|
|
|
|
|
# The name on up to two lines, split between words, so nothing is cut off.
|
|
|
|
|
var words: PackedStringArray = String(slot.get("name", "")).split(" ")
|
|
|
|
|
var first: String = words[0] if words.size() > 0 else ""
|
|
|
|
|
var rest: String = " ".join(words.slice(1)) if words.size() > 1 else ""
|
|
|
|
|
var width: float = rect.size.x - 8.0
|
|
|
|
|
Hud.draw_text(self, rect.position + Vector2(4.0, 31.0), first, Hud.FONT_SMALL, Palette.INK, width, HORIZONTAL_ALIGNMENT_CENTER)
|
|
|
|
|
if not rest.is_empty():
|
|
|
|
|
Hud.draw_text(self, rect.position + Vector2(4.0, 45.0), rest, Hud.FONT_SMALL, Palette.INK, width, HORIZONTAL_ALIGNMENT_CENTER)
|
|
|
|
|
var amount: String = ""
|
|
|
|
|
if int(slot.get("rounds", -1)) >= 0:
|
|
|
|
|
amount = "%d | %d" % [int(slot["rounds"]), int(slot["reserve"])]
|
|
|
|
|
elif int(slot.get("count", 0)) > 1:
|
|
|
|
|
amount = "x%d" % int(slot["count"])
|
|
|
|
|
if not amount.is_empty():
|
|
|
|
|
Hud.draw_text(self, rect.position + Vector2(4.0, 60.0), amount, Hud.FONT_SMALL, Palette.INK, width, HORIZONTAL_ALIGNMENT_CENTER)
|
|
|
|
|
var tier: int = int(slot.get("tier", -1))
|
|
|
|
|
if tier >= 0:
|
|
|
|
|
# Pips: filled up to the tier, out of four, so tier reads without colour.
|
|
|
|
|
for pip: int in Tuning.WEAPON_TIERS.size():
|
|
|
|
|
var centre: Vector2 = rect.position + Vector2(rect.size.x * 0.5 + (pip - 1.5) * 11.0, rect.size.y - 7.0)
|
|
|
|
|
if pip <= tier:
|
|
|
|
|
draw_circle(centre, 3.5, Palette.GILT if tier >= 2 else Palette.INK)
|
|
|
|
|
draw_arc(centre, 3.5, 0.0, TAU, 12, Palette.INK, 1.0)
|