updates
This commit is contained in:
parent
215e24e246
commit
bbd8012fff
16 changed files with 510 additions and 213 deletions
|
|
@ -1,93 +1,144 @@
|
|||
class_name ReviewPanel
|
||||
extends CenterContainer
|
||||
## The morning screen (the untimed MORNING phase), between one night and the next day:
|
||||
## * Last night's results (from the night's log entry): per category what was taken,
|
||||
## recovered, and lost; enemies defeated by type and how many got away with loot; damage
|
||||
## (the scarecrow's, structures hit, broken, and repaired); materials gathered and spent
|
||||
## over the day and night.
|
||||
## * This morning: what's left (crops, animals, supplies, the scarecrow's health), what needs
|
||||
## repair (damaged structures keep their health bars on the farm), the pen's gate, the
|
||||
## materials on hand, and tonight's plan.
|
||||
## "Start the day" (focused, so Enter / A work) ends it. The first morning explains the vacation
|
||||
## instead of results.
|
||||
## The morning screen (the untimed MORNING phase), between one night and the next day: a wooden
|
||||
## sign, hand-drawn (Sketch) over the dimmed farm, the day on its top beam and a sheet of paper
|
||||
## nailed under it with last night's results (from the night's log entry):
|
||||
## * per category (crops, animals, supplies): what was taken, recovered, and lost;
|
||||
## * the enemies defeated, by type;
|
||||
## * the materials gathered over the day and night.
|
||||
## Each row has its icon; a type or material with none isn't listed. "Start the day" (focused,
|
||||
## so Enter / A work) ends it. The first morning explains the vacation instead of results.
|
||||
|
||||
const CATEGORIES := ["Crops", "Animals", "Supplies"]
|
||||
const GOLD := Color(0.95, 0.82, 0.45)
|
||||
const GREY := Color(0.7, 0.72, 0.68)
|
||||
const RED := Color(1.0, 0.5, 0.42)
|
||||
const ENEMY_TYPES := [EnemySystem.TYPE_CROW, EnemySystem.TYPE_THIEF, EnemySystem.TYPE_BREAKER, EnemySystem.TYPE_UFO]
|
||||
## The sign's layout around its paper: the posts and beam ends either side of it, the top beam
|
||||
## (the title is written on it), and the bottom beam.
|
||||
const SIDE := 64.0
|
||||
const BEAM := 92.0
|
||||
const BOTTOM := 70.0
|
||||
const WIDTH := 880.0
|
||||
|
||||
var campaign: CampaignController
|
||||
var structures: StructureSystem
|
||||
## Set by FarmSim: whether the pen is open, and tonight's plan.
|
||||
var animals: AnimalSystem
|
||||
## Set by FarmSim: the night plans (last night's title).
|
||||
var waves: WaveDirector
|
||||
|
||||
var _board: PanelContainer
|
||||
var _title: Label
|
||||
var _last_head: Label
|
||||
var _rule: HSeparator
|
||||
var _grid: GridContainer
|
||||
var _cells := {} # "Crops/taken" -> Label
|
||||
var _results: Label
|
||||
var _rule: HSeparator
|
||||
var _morning_head: Label
|
||||
var _body: Label
|
||||
var _lists: HBoxContainer
|
||||
var _enemies := {} # type -> [icon, name, count]
|
||||
var _no_enemies: Label
|
||||
var _materials := {} # material -> [icon, name, count]
|
||||
var _no_materials: Label
|
||||
var _intro: Label
|
||||
var _start: Button
|
||||
|
||||
|
||||
func setup(p_campaign: CampaignController, p_structures: StructureSystem) -> void:
|
||||
func setup(p_campaign: CampaignController) -> void:
|
||||
campaign = p_campaign
|
||||
structures = p_structures
|
||||
campaign.phase_changed.connect(func(_p: CampaignController.Phase, _prev: CampaignController.Phase) -> void: refresh())
|
||||
refresh()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
var panel := PanelContainer.new()
|
||||
panel.add_theme_stylebox_override("panel", backing())
|
||||
add_child(panel)
|
||||
var margin := MarginContainer.new()
|
||||
for side in ["left", "right", "top", "bottom"]:
|
||||
margin.add_theme_constant_override("margin_" + side, 30)
|
||||
panel.add_child(margin)
|
||||
theme = UiTheme.sketch()
|
||||
_board = PanelContainer.new()
|
||||
var margins := StyleBoxEmpty.new()
|
||||
margins.content_margin_left = SIDE
|
||||
margins.content_margin_right = SIDE
|
||||
margins.content_margin_bottom = BOTTOM
|
||||
_board.add_theme_stylebox_override("panel", margins)
|
||||
_board.draw.connect(_draw_board)
|
||||
add_child(_board)
|
||||
var column := VBoxContainer.new()
|
||||
column.add_theme_constant_override("separation", 0)
|
||||
_board.add_child(column)
|
||||
_title = Label.new()
|
||||
Sketch.style(_title, 48)
|
||||
_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_title.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
_title.custom_minimum_size = Vector2(0.0, BEAM)
|
||||
column.add_child(_title)
|
||||
var sheet := MarginContainer.new()
|
||||
for side: String in ["left", "right"]:
|
||||
sheet.add_theme_constant_override("margin_" + side, 48)
|
||||
sheet.add_theme_constant_override("margin_top", 26)
|
||||
sheet.add_theme_constant_override("margin_bottom", 32)
|
||||
column.add_child(sheet)
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 12)
|
||||
margin.add_child(box)
|
||||
_title = _label(box, 38)
|
||||
_last_head = _label(box, 26, GOLD)
|
||||
_grid = GridContainer.new()
|
||||
_grid.columns = 4
|
||||
_grid.add_theme_constant_override("h_separation", 48)
|
||||
_grid.add_theme_constant_override("v_separation", 2)
|
||||
box.add_child(_grid)
|
||||
for head in ["", "Taken", "Recovered", "Lost"]:
|
||||
_label(_grid, 20, GREY).text = head
|
||||
for cat: String in CATEGORIES:
|
||||
_label(_grid, 22).text = cat
|
||||
for col in ["taken", "recovered", "lost"]:
|
||||
var l := _label(_grid, 22)
|
||||
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
_cells["%s/%s" % [cat, col]] = l
|
||||
_results = _label(box, 21)
|
||||
_results.custom_minimum_size = Vector2(760.0, 0.0)
|
||||
_results.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
box.custom_minimum_size = Vector2(WIDTH, 0.0)
|
||||
box.add_theme_constant_override("separation", 10)
|
||||
sheet.add_child(box)
|
||||
_last_head = _ink(box, 38)
|
||||
_last_head.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_rule = HSeparator.new()
|
||||
_rule.add_theme_stylebox_override("separator", SketchBox.new(Color(0, 0, 0, 0), Color(Sketch.PAPER_INK, 0.5), 2.0, true))
|
||||
box.add_child(_rule)
|
||||
_morning_head = _label(box, 26, GOLD)
|
||||
_morning_head.text = "This morning"
|
||||
_body = _label(box, 21)
|
||||
_body.custom_minimum_size = Vector2(760.0, 0.0)
|
||||
_body.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_grid = GridContainer.new()
|
||||
_grid.columns = 5
|
||||
_grid.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
_grid.add_theme_constant_override("h_separation", 18)
|
||||
_grid.add_theme_constant_override("v_separation", 4)
|
||||
box.add_child(_grid)
|
||||
_grid.add_child(Control.new())
|
||||
_grid.add_child(Control.new())
|
||||
for head: String in ["Taken", "Recovered", "Lost"]:
|
||||
var l := _ink(_grid, 28, Sketch.PAPER_DIM)
|
||||
l.text = head
|
||||
l.custom_minimum_size = Vector2(150.0, 0.0)
|
||||
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
for i in CATEGORIES.size():
|
||||
var cat: String = CATEGORIES[i]
|
||||
_grid.add_child(SketchIcon.new(LootSystem.CATEGORY_KEYS[i], 52.0))
|
||||
var label := _ink(_grid, 32)
|
||||
label.text = cat
|
||||
label.custom_minimum_size = Vector2(150.0, 0.0)
|
||||
for col: String in ["taken", "recovered", "lost"]:
|
||||
var l := _ink(_grid, 34)
|
||||
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_cells["%s/%s" % [cat, col]] = l
|
||||
box.add_child(_spacer(8.0))
|
||||
_lists = HBoxContainer.new()
|
||||
_lists.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
_lists.add_theme_constant_override("separation", 90)
|
||||
box.add_child(_lists)
|
||||
var enemies := _list(_lists, "Enemies defeated")
|
||||
for t: int in ENEMY_TYPES:
|
||||
var plural := EnemySystem.PLURALS[t]
|
||||
_enemies[t] = _list_row(enemies, EnemySystem.TYPE_NAMES[t], plural[0].to_upper() + plural.substr(1))
|
||||
_no_enemies = _ink(enemies, 30, Sketch.PAPER_DIM)
|
||||
_no_enemies.text = "None"
|
||||
var materials := _list(_lists, "Materials gathered")
|
||||
for m in ResourceStore.MATERIALS:
|
||||
_materials[m] = _list_row(materials, m, m.capitalize())
|
||||
_no_materials = _ink(materials, 30, Sketch.PAPER_DIM)
|
||||
_no_materials.text = "Nothing"
|
||||
_intro = _ink(box, 28)
|
||||
_intro.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_intro.add_theme_constant_override("paragraph_spacing", 14)
|
||||
_start = Button.new()
|
||||
_start.text = "Start the day"
|
||||
_start.custom_minimum_size = Vector2(260.0, 56.0)
|
||||
_start.add_theme_font_size_override("font_size", 24)
|
||||
_start.custom_minimum_size = Vector2(300.0, 62.0)
|
||||
_start.add_theme_font_size_override("font_size", 32)
|
||||
_start.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
var wood := {
|
||||
"normal": SketchBox.new(Sketch.WOOD, Sketch.INK, 2.5),
|
||||
"hover": SketchBox.new(Sketch.WOOD.lightened(0.15), Sketch.INK, 2.5),
|
||||
"pressed": SketchBox.new(Sketch.WOOD.darkened(0.2), Sketch.GOLD, 2.5),
|
||||
}
|
||||
for key: String in wood:
|
||||
_start.add_theme_stylebox_override(key, wood[key])
|
||||
_start.pressed.connect(func() -> void: campaign.begin_day())
|
||||
box.add_child(_spacer(6.0))
|
||||
box.add_child(_start)
|
||||
visible = false
|
||||
|
||||
|
||||
## The dark, nearly opaque panel behind the morning screen, the menus, and the end screens.
|
||||
## The dark, nearly opaque panel behind the menus and the end screens.
|
||||
static func backing() -> StyleBoxFlat:
|
||||
var bg := StyleBoxFlat.new()
|
||||
bg.bg_color = Color(0.1, 0.12, 0.1)
|
||||
|
|
@ -107,40 +158,25 @@ func refresh() -> void:
|
|||
var s := campaign.state
|
||||
var nights := campaign.config.campaign_nights
|
||||
var first := s.night_log.is_empty()
|
||||
for n: Control in [_last_head, _grid, _results, _rule, _morning_head]:
|
||||
for n: Control in [_last_head, _rule, _grid, _lists]:
|
||||
n.visible = not first
|
||||
var lines: Array[String] = []
|
||||
_intro.visible = first
|
||||
if first:
|
||||
_title.text = "The farmers are away"
|
||||
lines.append("Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights)
|
||||
lines.append("By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.")
|
||||
lines.append("At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days.")
|
||||
_intro.text = "\n".join([
|
||||
"Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights,
|
||||
"By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.",
|
||||
"At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days.",
|
||||
])
|
||||
else:
|
||||
var e: Dictionary = s.night_log[s.night_log.size() - 1]
|
||||
_title.text = "Morning of day %d of %d" % [s.night, nights]
|
||||
var plan := waves.plan_for(int(e["night"])) if waves != null else null
|
||||
_last_head.text = "Night %d: %s" % [e["night"], plan.title] if plan != null and plan.title != "" else "Night %d" % e["night"]
|
||||
_fill_grid(e)
|
||||
_results.text = "\n".join(result_lines(e, s))
|
||||
lines.append("Left: %d of %d crops, %d of %d animals, %d supplies. Scarecrow: %d of %d HP." % [s.crops, s.crops_total,
|
||||
s.animals, s.animals_total, s.supplies, s.scarecrow_hp, s.scarecrow_max_hp])
|
||||
lines.append(_damage_line())
|
||||
if animals != null and animals.pen_open and s.animals > 0:
|
||||
lines.append("The pen is open: put a gate in its opening (B) before nightfall, or the animals in it will get out and roam loose.")
|
||||
var r := s.resources
|
||||
if s.coop: # each scarecrow carries its own
|
||||
lines.append("In the shed: %s. %s's pouch: %s. %s's pouch: %s." % [_or_none(ResourceStore.describe(r.shed)),
|
||||
Avatar.NAMES[0], _or_none(ResourceStore.describe(r.pouch_of(0))), Avatar.NAMES[1], _or_none(ResourceStore.describe(r.pouch_of(1)))])
|
||||
else:
|
||||
lines.append("In the shed: %s. In the pouch: %s." % [_or_none(ResourceStore.describe(r.shed)), _or_none(ResourceStore.describe(r.pouch))])
|
||||
var plan := waves.tonight() if waves != null else null
|
||||
if plan != null and plan.title != "":
|
||||
if structures != null and structures.has_workbench():
|
||||
lines.append("Tonight: %s. Upgrades: %d of %d levels." % [plan.title, Upgrades.levels_bought(campaign.config, s),
|
||||
Upgrades.levels_total(campaign.config)])
|
||||
else: # #9: the Workbench hasn't been granted yet -- it arrives once Night 1 is survived
|
||||
lines.append("Tonight: %s. The work area will be set up once you survive tonight." % plan.title)
|
||||
_body.text = "\n".join(lines)
|
||||
_fill_list(_enemies, _no_enemies, func(t: int) -> int: return int(e.get("killed_" + EnemySystem.TYPE_NAMES[t], 0)))
|
||||
_fill_list(_materials, _no_materials, func(m: String) -> int: return int(e.get("gathered_" + m, 0)))
|
||||
_board.queue_redraw()
|
||||
_start.grab_focus.call_deferred()
|
||||
|
||||
|
||||
|
|
@ -152,6 +188,16 @@ func grid_text() -> String:
|
|||
return "\n".join(rows)
|
||||
|
||||
|
||||
## The enemies listed, "Crows 12, Aliens 3" (or "None"), for tests.
|
||||
func enemies_text() -> String:
|
||||
return _list_text(_enemies, _no_enemies)
|
||||
|
||||
|
||||
## The materials listed, "Wood 8, Straw 4" (or "Nothing"), for tests.
|
||||
func materials_text() -> String:
|
||||
return _list_text(_materials, _no_materials)
|
||||
|
||||
|
||||
## Per category: (taken, recovered, lost) in a night's log entry. Animals taken include those
|
||||
## that got out of an open pen (loose, not lost).
|
||||
static func category_counts(e: Dictionary) -> Dictionary:
|
||||
|
|
@ -162,30 +208,6 @@ static func category_counts(e: Dictionary) -> Dictionary:
|
|||
}
|
||||
|
||||
|
||||
## Enemies, damage, and materials of a night's log entry.
|
||||
static func result_lines(e: Dictionary, s: FarmState) -> Array[String]:
|
||||
var out: Array[String] = []
|
||||
var enemies := "Enemies defeated: %s." % Assessment.enemies_line(e)
|
||||
if int(e["escaped"]) > 0:
|
||||
enemies = enemies.trim_suffix(".") + "; %d got away with loot." % int(e["escaped"])
|
||||
out.append(enemies)
|
||||
var damage := PackedStringArray()
|
||||
damage.append("the scarecrow took %d" % int(e["scarecrow_damage"]) if int(e["scarecrow_damage"]) > 0 else "the scarecrow wasn't hurt")
|
||||
if int(e["patches"]) > 0:
|
||||
damage.append("patched up %d %s" % [int(e["patches"]), "time" if int(e["patches"]) == 1 else "times"])
|
||||
if int(e["structures_damaged"]) > 0:
|
||||
damage.append("structures took %d damage" % int(e["structures_damaged"]))
|
||||
if int(e["structures_destroyed"]) > 0:
|
||||
damage.append("%d broken" % int(e["structures_destroyed"]))
|
||||
if int(e["repairs"]) > 0:
|
||||
damage.append("%d repaired" % int(e["repairs"]))
|
||||
out.append("Damage: %s." % ", ".join(damage))
|
||||
out.append("Materials: gathered %s; spent %s." % [Assessment.materials_line(e, "gathered_"), Assessment.materials_line(e, "spent_")])
|
||||
if s != null and int(e["structures_built"]) + int(e["upgrades_bought"]) > 0:
|
||||
out.append("Built %d, upgrades bought %d." % [int(e["structures_built"]), int(e["upgrades_bought"])])
|
||||
return out
|
||||
|
||||
|
||||
func _fill_grid(e: Dictionary) -> void:
|
||||
var counts := category_counts(e)
|
||||
for cat: String in CATEGORIES:
|
||||
|
|
@ -193,31 +215,113 @@ func _fill_grid(e: Dictionary) -> void:
|
|||
for k in 3:
|
||||
var l: Label = _cells["%s/%s" % [cat, ["taken", "recovered", "lost"][k]]]
|
||||
l.text = str(c[k])
|
||||
l.add_theme_color_override("font_color", RED if k == 2 and int(c[k]) > 0 else Color(0.92, 0.92, 0.88))
|
||||
var color := Sketch.PAPER_INK if int(c[k]) > 0 else Sketch.PAPER_DIM
|
||||
l.add_theme_color_override("font_color", Sketch.PAPER_RED if k == 2 and int(c[k]) > 0 else color)
|
||||
|
||||
|
||||
func _damage_line() -> String:
|
||||
if structures == null or structures.count() == 0:
|
||||
return "Nothing built yet."
|
||||
var damaged := {}
|
||||
for e in campaign.state.structures:
|
||||
if int(e["hp"]) < structures.max_hp(e["type"]):
|
||||
damaged[e["type"]] = int(damaged.get(e["type"], 0)) + 1
|
||||
if damaged.is_empty():
|
||||
return "No repairs needed."
|
||||
var parts: Array[String] = []
|
||||
for t in damaged:
|
||||
parts.append("%d %s%s" % [damaged[t], StructureSystem.NAMES[t].to_lower(), "s" if int(damaged[t]) > 1 else ""])
|
||||
return "Needs repair (marked with health bars): %s." % ", ".join(parts)
|
||||
## Shows the rows of rows (key -> [icon, name, count]) with a count above 0 (count_of(key)), or
|
||||
## none when there aren't any.
|
||||
func _fill_list(rows: Dictionary, none: Label, count_of: Callable) -> void:
|
||||
var any := false
|
||||
for key: Variant in rows:
|
||||
var n: int = count_of.call(key)
|
||||
for c: Control in rows[key]:
|
||||
c.visible = n > 0
|
||||
(rows[key][2] as Label).text = str(n)
|
||||
any = any or n > 0
|
||||
none.visible = not any
|
||||
|
||||
|
||||
func _label(parent: Node, font_size: int, color: Color = Color(0.92, 0.92, 0.88)) -> Label:
|
||||
func _list_text(rows: Dictionary, none: Label) -> String:
|
||||
var parts := PackedStringArray()
|
||||
for key: Variant in rows:
|
||||
var cells: Array = rows[key]
|
||||
if (cells[2] as Control).visible:
|
||||
parts.append("%s %s" % [(cells[1] as Label).text, (cells[2] as Label).text])
|
||||
return ", ".join(parts) if not parts.is_empty() else none.text
|
||||
|
||||
|
||||
## A headed table of icon, name, and count; returns the grid the rows go in.
|
||||
func _list(parent: Control, heading: String) -> GridContainer:
|
||||
var column := VBoxContainer.new()
|
||||
column.add_theme_constant_override("separation", 4)
|
||||
parent.add_child(column)
|
||||
var head := _ink(column, 30, Sketch.PAPER_DIM)
|
||||
head.text = heading
|
||||
var grid := GridContainer.new()
|
||||
grid.columns = 3
|
||||
grid.add_theme_constant_override("h_separation", 14)
|
||||
grid.add_theme_constant_override("v_separation", 0)
|
||||
column.add_child(grid)
|
||||
return grid
|
||||
|
||||
|
||||
func _list_row(grid: GridContainer, icon: String, text: String) -> Array:
|
||||
var i := SketchIcon.new(icon, 46.0)
|
||||
grid.add_child(i)
|
||||
var l := _ink(grid, 30)
|
||||
l.text = text
|
||||
l.custom_minimum_size = Vector2(150.0, 0.0)
|
||||
var n := _ink(grid, 32)
|
||||
n.custom_minimum_size = Vector2(44.0, 0.0)
|
||||
n.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
return [i, l, n]
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.35)) # dims the farm behind
|
||||
|
||||
|
||||
## The sign behind the board's contents: two posts, the paper between them, a beam across its top
|
||||
## (under the title) and one across its bottom, nails, and leaves.
|
||||
func _draw_board() -> void:
|
||||
var b := _board
|
||||
var w := b.size.x
|
||||
var h := b.size.y
|
||||
var paper := Rect2(SIDE - 14.0, BEAM - 26.0, w - 2.0 * SIDE + 28.0, h - BEAM - BOTTOM + 52.0)
|
||||
var posts: Array[float] = [SIDE + 34.0, w - SIDE - 34.0]
|
||||
for k in 2:
|
||||
b.draw_set_transform(Vector2(posts[k], h * 0.5 + 8.0), PI * 0.5)
|
||||
Sketch.plank(b, Rect2(-h * 0.5 - 44.0, -27.0, h + 88.0, 54.0), Sketch.WOOD.darkened(0.08), 601.0 + k)
|
||||
b.draw_set_transform_matrix(Transform2D.IDENTITY)
|
||||
Sketch.paper(b, paper, 611.0)
|
||||
Sketch.plank(b, Rect2(0.0, h - BOTTOM - 4.0, w, 62.0), Sketch.WOOD.darkened(0.04), 621.0)
|
||||
Sketch.plank(b, Rect2(-24.0, 0.0, w + 48.0, BEAM), Sketch.WOOD, 631.0)
|
||||
for x: float in [paper.position.x + 26.0, paper.end.x - 26.0]:
|
||||
Sketch.nail(b, Vector2(x, paper.position.y + 46.0))
|
||||
for k in 2:
|
||||
Sketch.nail(b, Vector2(posts[k], BEAM * 0.5), 6.0)
|
||||
Sketch.nail(b, Vector2(posts[k], h - BOTTOM + 27.0), 6.0)
|
||||
Sketch.leaf(b, Vector2(28.0, 18.0), 46.0, -2.5, 641.0)
|
||||
Sketch.leaf(b, Vector2(34.0, 22.0), 40.0, -1.4, 642.0)
|
||||
Sketch.leaf(b, Vector2(w - 26.0, 16.0), 50.0, -0.5, 643.0)
|
||||
Sketch.leaf(b, Vector2(w - 30.0, 24.0), 38.0, 0.4, 644.0, Sketch.LEAF.lightened(0.12))
|
||||
Sketch.leaf(b, Vector2(posts[0] - 20.0, h - BOTTOM + 40.0), 42.0, 2.6, 645.0, Sketch.LEAF.darkened(0.1))
|
||||
|
||||
|
||||
static func _spacer(height: float) -> Control:
|
||||
var c := Control.new()
|
||||
c.custom_minimum_size = Vector2(0.0, height)
|
||||
return c
|
||||
|
||||
|
||||
## A Label in ink on the paper (no outline).
|
||||
func _ink(parent: Node, font_size: int, color: Color = Sketch.PAPER_INK) -> Label:
|
||||
var l := Label.new()
|
||||
l.add_theme_font_size_override("font_size", font_size)
|
||||
l.add_theme_color_override("font_color", color)
|
||||
Sketch.style(l, font_size, color, 0)
|
||||
parent.add_child(l)
|
||||
return l
|
||||
|
||||
|
||||
static func _or_none(text: String) -> String:
|
||||
return text if text != "" else "nothing"
|
||||
## An icon (Sketch.ICONS) drawn in a square, side long, centered in the control.
|
||||
class SketchIcon extends Control:
|
||||
var id := ""
|
||||
|
||||
func _init(p_id: String, side: float) -> void:
|
||||
id = p_id
|
||||
custom_minimum_size = Vector2(side, side)
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
func _draw() -> void:
|
||||
var side := minf(size.x, size.y)
|
||||
Sketch.icon(self, id, Rect2((size - Vector2(side, side)) * 0.5, Vector2(side, side)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue