Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs/api/scripts.fp.ui.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions scripts/fp/drive/drive_hud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func setup() -> void:
_chip = PanelContainer.new()
_chip.name = "DriveChip"
_chip.mouse_filter = Control.MOUSE_FILTER_IGNORE
_chip.add_theme_stylebox_override("panel", S.box(Color(0.04, 0.05, 0.08, 0.6), 8, 10, 6))
_chip.add_theme_stylebox_override("panel", S.box(Color(0.04, 0.05, 0.08, 0.6), S.RADIUS, 10, 6))
var h := HBoxContainer.new()
h.mouse_filter = Control.MOUSE_FILTER_IGNORE
h.add_theme_constant_override("separation", 9)
Expand All @@ -41,7 +41,7 @@ func setup() -> void:


func _build_speedo() -> void:
_speedo = S.panel(S.PANEL_BG, 10, 16, 8)
_speedo = S.panel(S.PANEL_BG, S.RADIUS_PANEL, 16, 8)
_speedo.name = "Speedometer"
var v := VBoxContainer.new()
v.mouse_filter = Control.MOUSE_FILTER_IGNORE
Expand All @@ -51,7 +51,7 @@ func _build_speedo() -> void:
row.mouse_filter = Control.MOUSE_FILTER_IGNORE
row.add_theme_constant_override("separation", 8)
v.add_child(row)
_speed = S.plain("0", 40, S.WHITE, S.title())
_speed = S.plain("0", 40, S.WHITE, S.display())
_speed.name = "Speed"
_speed.custom_minimum_size = Vector2(84, 0)
_speed.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
Expand Down
7 changes: 4 additions & 3 deletions scripts/fp/phone/phone_ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func setup() -> void:
name = "BuildPhone"
mouse_filter = Control.MOUSE_FILTER_IGNORE
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_panel = S.panel(Color(0.03, 0.04, 0.07, 0.9), 22, 16, 14, Color(1, 1, 1, 0.14))
_panel = S.panel(Color(0.03, 0.04, 0.07, 0.9), S.RADIUS_PANEL, 16, 14, Color(1, 1, 1, 0.14))
_panel.name = "Phone"
_panel.custom_minimum_size = Vector2(WIDTH, 0)
var v := VBoxContainer.new()
Expand All @@ -44,8 +44,9 @@ func setup() -> void:
_treasury = S.plain("", 15, S.GOOD, S.bold())
_treasury.name = "Treasury"
top.add_child(_treasury)
_district = S.plain("", 18, S.WHITE, S.title())
_district = S.plain("", 15, S.WHITE, S.display())
_district.name = "District"
_district.uppercase = true
_district.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
v.add_child(_district)
_mayor = S.plain("", 13, S.TEXT_DIM, S.font())
Expand Down Expand Up @@ -126,7 +127,7 @@ func show_state(st: Dictionary) -> void:
var bg := Color(0.0, 0.88, 1.0, 0.16) if on else Color(1, 1, 1, 0.05)
var line := S.ACCENT if on else Color(0, 0, 0, 0)
(_tools[id] as PanelContainer).add_theme_stylebox_override(
"panel", S.box(bg, 8, 8, 5, line, 1 if on else 0)
"panel", S.box(bg, S.RADIUS, 8, 5, line, 1 if on else 0)
)
_building.text = str(st.get("building", ""))
_building.visible = not _building.text.is_empty()
Expand Down
15 changes: 10 additions & 5 deletions scripts/fp/ui/hud_caption.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ func setup(p_ctx: FpContext) -> void:
_box.offset_top = -SAFE - 90.0
_box.offset_bottom = -SAFE
add_child(_box)
_title = S.label("", 34, S.WHITE, S.title(), 0)
_title = S.label("", 30, S.WHITE, S.display(), 0)
_title.name = "District"
_title.uppercase = true
_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
_title.add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5))
_title.add_theme_constant_override("shadow_offset_y", 2)
_title.add_theme_constant_override("shadow_outline_size", 6)
_box.add_child(_title)
_rule = ColorRect.new()
_rule.mouse_filter = Control.MOUSE_FILTER_IGNORE
_rule.color = Color(1, 1, 1, 0.55)
_rule.color = S.ACCENT
_rule.custom_minimum_size = Vector2(56, 2)
_rule.size_flags_horizontal = Control.SIZE_SHRINK_END
_box.add_child(_rule)
_sub = S.label("", 16, S.TEXT, S.font(), 3)
_sub = S.caps_label("", 13, S.TEXT, 3)
_sub.name = "Mayor"
_sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
_box.add_child(_sub)
Expand All @@ -70,7 +71,9 @@ func setup(p_ctx: FpContext) -> void:
if ctx.bus != null:
ctx.bus.player_tile_changed.connect(func(_x: int, _y: int) -> void: check())
ctx.bus.world_ready.connect(arrive)
ctx.bus.conversation_changed.connect(func(_id: String, on: bool) -> void: _in_conversation = on)
ctx.bus.conversation_changed.connect(
func(_id: String, on: bool) -> void: _in_conversation = on
)
arrive.call_deferred()


Expand Down Expand Up @@ -127,7 +130,9 @@ func _process(delta: float) -> void:
_age = INF
_box.visible = false
return
var blocked := ctx.is_modal() or _in_conversation or (ctx.player != null and ctx.player.photo_mode)
var blocked := (
ctx.is_modal() or _in_conversation or (ctx.player != null and ctx.player.photo_mode)
)
var k_in := clampf(_age / FADE_IN, 0.0, 1.0)
var k_out := clampf((life - _age) / FADE_OUT, 0.0, 1.0)
var ease_in := 1.0 - (1.0 - k_in) * (1.0 - k_in) * (1.0 - k_in)
Expand Down
36 changes: 30 additions & 6 deletions scripts/fp/ui/hud_chips.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const IDS := ["pop", "mood", "money", "power", "water", "time", "alerts", "sessi
const STATE_COLORS := {"ok": S.TEXT, "good": S.GOOD, "warn": S.AMBER, "fail": S.RED}

var ctx: FpContext
## id -> {"panel": PanelContainer, "box": StyleBoxFlat, "icon": HudIcon, "value": Label, "state": String, "pulse": float}
## id -> {"panel": PanelContainer, "box": StyleBoxFlat, "icon": HudIcon, "value": Label,
## "state": String, "pulse": float, "line": Color}
var _chips: Dictionary = {}
var _day: Label
var _speed: Label
Expand Down Expand Up @@ -85,13 +86,25 @@ func refresh() -> void:
var st := sim.stats
_put("pop", S.fmt(int(st.get("population", 0))), "ok")
var mood := mood_value()
var mood_state := "good" if mood >= 6.5 else ("ok" if mood >= 4.5 else ("warn" if mood >= 3.0 else "fail"))
var mood_state := (
"good" if mood >= 6.5 else ("ok" if mood >= 4.5 else ("warn" if mood >= 3.0 else "fail"))
)
_put("mood", "%.1f" % mood, mood_state)
(_chips["mood"]["icon"] as HudIcon).mood = clampf(mood / 10.0, 0.0, 1.0)
var funds := sim.total_funds()
_put("money", S.money(funds), "warn" if funds < 0 else "ok")
_util("power", float(st.get("power_need", 0.0)), float(st.get("power_cap", 0.0)), int(st.get("unpowered", 0)))
_util("water", float(st.get("water_need", 0.0)), float(st.get("water_cap", 0.0)), int(st.get("unwatered", 0)))
_util(
"power",
float(st.get("power_need", 0.0)),
float(st.get("power_cap", 0.0)),
int(st.get("unpowered", 0))
)
_util(
"water",
float(st.get("water_need", 0.0)),
float(st.get("water_cap", 0.0)),
int(st.get("unwatered", 0))
)
_refresh_clock()
var n := sim.events.size()
var alerts: Dictionary = _chips["alerts"]
Expand Down Expand Up @@ -150,7 +163,7 @@ func _process(delta: float) -> void:
var k := sin(p / PULSE * PI)
var sb: StyleBoxFlat = c["box"]
sb.bg_color = S.CHIP_BG.lerp(Color(0.12, 0.14, 0.2, 0.55), k)
sb.border_color = Color(1, 1, 1, 0.22 * k)
sb.border_color = (c["line"] as Color).lerp(Color(1, 1, 1, 0.5), k)
if _blink > 0.0:
_blink = maxf(0.0, _blink - delta)
var a := 1.0 - 0.75 * absf(sin((BLINK - _blink) / BLINK * TAU))
Expand Down Expand Up @@ -202,6 +215,9 @@ func _put(id: String, value: String, state: String, pulse: bool = true) -> void:
# "good" tints only the icon: values stay white unless something needs attention.
l.add_theme_color_override("font_color", S.TEXT if state == "good" else col)
(c["icon"] as HudIcon).color = col if state != "ok" else S.TEXT
# A chip that needs attention carries its colour on the hairline too.
c["line"] = Color(col, 0.9) if state in ["warn", "fail"] else S.CHIP_LINE
(c["box"] as StyleBoxFlat).border_color = c["line"]


func _group(row: HBoxContainer, align: BoxContainer.AlignmentMode, expand: bool) -> HBoxContainer:
Expand Down Expand Up @@ -236,7 +252,15 @@ func _chip(parent: Control, id: String, icon: String) -> Dictionary:
v.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
h.add_child(v)
parent.add_child(p)
var c := {"panel": p, "box": sb, "icon": ic, "value": v, "state": "", "pulse": 0.0}
var c := {
"panel": p,
"box": sb,
"icon": ic,
"value": v,
"state": "",
"pulse": 0.0,
"line": S.CHIP_LINE
}
_chips[id] = c
return c

Expand Down
6 changes: 4 additions & 2 deletions scripts/fp/ui/hud_prompt.gd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func setup(p_ctx: FpContext) -> void:
_chip = PanelContainer.new()
_chip.name = "Chip"
_chip.mouse_filter = Control.MOUSE_FILTER_IGNORE
_chip.add_theme_stylebox_override("panel", S.box(Color(0.04, 0.05, 0.08, 0.55), 8, 8, 5))
_chip.add_theme_stylebox_override("panel", S.box(Color(0.04, 0.05, 0.08, 0.6), S.RADIUS, 8, 5))
var h := HBoxContainer.new()
h.mouse_filter = Control.MOUSE_FILTER_IGNORE
h.add_theme_constant_override("separation", 9)
Expand Down Expand Up @@ -121,7 +121,9 @@ func _process(delta: float) -> void:
_mode = mode
_snap = true
var first := mode == "first"
var blocked := ctx.is_modal() or _in_conversation or (ctx.player != null and ctx.player.photo_mode)
var blocked := (
ctx.is_modal() or _in_conversation or (ctx.player != null and ctx.player.photo_mode)
)
var view := size if size.x > 0.0 and size.y > 0.0 else get_viewport_rect().size
var centre := (view * 0.5).round()
# Crosshair: first person only.
Expand Down
Loading