WIP: 360dp lobby redesign
Port the project to a 360x640 canvas with the redesigned lobby, settings sheet, and refreshed UI.
This commit is contained in:
1 parent
f6fd807e9a
commit
46b5764144
34 files changed
+1299
-261
No files matched your search
+116
-22
@@ -1,10 +1,46 @@
|
||||
class_name UI
|
||||
extends RefCounted
|
||||
|
||||
## Small helpers so the screens stay readable.
|
||||
## Every control is built in code for now; we can move to .tscn layouts later.
|
||||
## 360dp design tokens. All sizes here are dp-like canvas units.
|
||||
|
||||
static func label(text: String, font_size: int, color: Color = Palette.INK) -> Label:
|
||||
const MARGIN := 16
|
||||
const GAP := 12
|
||||
const BTN_H := 54
|
||||
const BTN_FONT := 19
|
||||
const BODY := 16
|
||||
const SMALL := 14
|
||||
const CAPTION := 12
|
||||
const H1 := 44
|
||||
const H2 := 26
|
||||
const H3 := 21
|
||||
const RADIUS := 22
|
||||
|
||||
const FONT_HEADING_BASE := preload("res://assets/fonts/Fredoka-Variable.ttf")
|
||||
const FONT_BODY_BASE := preload("res://assets/fonts/Nunito-Variable.ttf")
|
||||
|
||||
static var _heading_font: FontVariation
|
||||
static var _body_font: FontVariation
|
||||
|
||||
|
||||
static func heading_font() -> Font:
|
||||
if _heading_font == null:
|
||||
_heading_font = FontVariation.new()
|
||||
_heading_font.base_font = FONT_HEADING_BASE
|
||||
var ts := TextServerManager.get_primary_interface()
|
||||
_heading_font.variation_opentype = { ts.name_to_tag("wght"): 600 }
|
||||
return _heading_font
|
||||
|
||||
|
||||
static func body_font() -> Font:
|
||||
if _body_font == null:
|
||||
_body_font = FontVariation.new()
|
||||
_body_font.base_font = FONT_BODY_BASE
|
||||
var ts := TextServerManager.get_primary_interface()
|
||||
_body_font.variation_opentype = { ts.name_to_tag("wght"): 400 }
|
||||
return _body_font
|
||||
|
||||
|
||||
static func label(text: String, font_size: int = BODY, color: Color = Palette.INK, heading: bool = false) -> Label:
|
||||
var l := Label.new()
|
||||
l.text = text
|
||||
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
@@ -12,27 +48,65 @@ static func label(text: String, font_size: int, color: Color = Palette.INK) -> L
|
||||
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
l.add_theme_font_size_override("font_size", font_size)
|
||||
l.add_theme_color_override("font_color", color)
|
||||
l.add_theme_font_override("font", heading_font() if (heading or font_size >= 28) else body_font())
|
||||
return l
|
||||
|
||||
|
||||
static func button(text: String, primary: bool = false, min_height: int = 58) -> Button:
|
||||
static func heading(text: String, font_size: int = H2, color: Color = Palette.INK) -> Label:
|
||||
return label(text, font_size, color, true)
|
||||
|
||||
|
||||
static func body(text: String, color: Color = Palette.INK, font_size: int = BODY) -> Label:
|
||||
return label(text, font_size, color, false)
|
||||
|
||||
|
||||
static func caption(text: String, color: Color = Palette.MUTED) -> Label:
|
||||
return label(text, CAPTION, color, false)
|
||||
|
||||
|
||||
static func button(text: String, primary: bool = false, min_height: int = BTN_H) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.custom_minimum_size = Vector2(0, min_height)
|
||||
b.add_theme_font_size_override("font_size", 22)
|
||||
b.add_theme_color_override("font_color", Palette.INK)
|
||||
b.add_theme_color_override("font_hover_color", Palette.INK)
|
||||
b.add_theme_color_override("font_pressed_color", Palette.INK)
|
||||
b.add_theme_color_override("font_focus_color", Palette.INK)
|
||||
b.add_theme_stylebox_override("normal", _button_style(Palette.GOLD if primary else Palette.PAPER))
|
||||
b.add_theme_stylebox_override("hover", _button_style((Palette.GOLD if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.add_theme_stylebox_override("pressed", _button_style((Palette.GOLD if primary else Palette.PAPER).darkened(0.07)))
|
||||
b.add_theme_stylebox_override("focus", _button_style((Palette.GOLD if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.add_theme_font_override("font", heading_font())
|
||||
b.add_theme_font_size_override("font_size", BTN_FONT)
|
||||
b.add_theme_color_override("font_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_color_override("font_hover_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_color_override("font_pressed_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_color_override("font_focus_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_stylebox_override("normal", _button_style(Palette.ORANGE if primary else Palette.PAPER))
|
||||
b.add_theme_stylebox_override("hover", _button_style((Palette.ORANGE if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.add_theme_stylebox_override("pressed", _button_style((Palette.ORANGE if primary else Palette.PAPER).darkened(0.07)))
|
||||
b.add_theme_stylebox_override("focus", _button_style((Palette.ORANGE if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
return b
|
||||
|
||||
|
||||
static func panel(color: Color = Palette.PAPER, radius: int = 28, margin: int = 24) -> PanelContainer:
|
||||
static func round_button(icon_path: String, size: int = 48) -> Button:
|
||||
var b := Button.new()
|
||||
b.custom_minimum_size = Vector2(size, size)
|
||||
b.icon = load(icon_path)
|
||||
b.expand_icon = false
|
||||
b.add_theme_stylebox_override("normal", _round_style(Palette.PAPER))
|
||||
b.add_theme_stylebox_override("hover", _round_style(Palette.PAPER.lightened(0.04)))
|
||||
b.add_theme_stylebox_override("pressed", _round_style(Palette.PAPER.darkened(0.06)))
|
||||
b.add_theme_stylebox_override("focus", _round_style(Palette.PAPER.lightened(0.04)))
|
||||
b.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
return b
|
||||
|
||||
|
||||
static func icon(icon_path: String, size: int = 20, color: Color = Palette.MUTED) -> TextureRect:
|
||||
var t := TextureRect.new()
|
||||
t.texture = load(icon_path)
|
||||
t.custom_minimum_size = Vector2(size, size)
|
||||
t.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
t.modulate = color
|
||||
t.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
return t
|
||||
|
||||
|
||||
static func panel(color: Color = Palette.PAPER, radius: int = RADIUS, margin: int = 16) -> PanelContainer:
|
||||
var p := PanelContainer.new()
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = color
|
||||
@@ -45,24 +119,44 @@ static func panel(color: Color = Palette.PAPER, radius: int = 28, margin: int =
|
||||
s.content_margin_top = margin
|
||||
s.content_margin_bottom = margin
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.12)
|
||||
s.shadow_size = 6
|
||||
s.shadow_offset = Vector2(0, 4)
|
||||
s.shadow_size = 5
|
||||
s.shadow_offset = Vector2(0, 3)
|
||||
p.add_theme_stylebox_override("panel", s)
|
||||
return p
|
||||
|
||||
|
||||
static func spacer(height: int = GAP) -> Control:
|
||||
var c := Control.new()
|
||||
c.custom_minimum_size = Vector2(0, height)
|
||||
c.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
return c
|
||||
|
||||
|
||||
static func _button_style(color: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = color
|
||||
s.corner_radius_top_left = 18
|
||||
s.corner_radius_top_right = 18
|
||||
s.corner_radius_bottom_left = 18
|
||||
s.corner_radius_bottom_right = 18
|
||||
s.corner_radius_top_left = 26
|
||||
s.corner_radius_top_right = 26
|
||||
s.corner_radius_bottom_left = 26
|
||||
s.corner_radius_bottom_right = 26
|
||||
s.content_margin_left = 18
|
||||
s.content_margin_right = 18
|
||||
s.content_margin_top = 10
|
||||
s.content_margin_bottom = 10
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.14)
|
||||
s.shadow_size = 4
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.16)
|
||||
s.shadow_size = 5
|
||||
s.shadow_offset = Vector2(0, 3)
|
||||
return s
|
||||
|
||||
|
||||
static func _round_style(color: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = color
|
||||
s.corner_radius_top_left = 26
|
||||
s.corner_radius_top_right = 26
|
||||
s.corner_radius_bottom_left = 26
|
||||
s.corner_radius_bottom_right = 26
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.12)
|
||||
s.shadow_size = 4
|
||||
s.shadow_offset = Vector2(0, 2)
|
||||
return s
|
||||
Reference in new issue
Block a user