Basis 1920x1080 mit Kachel 96 (Phase 0.5): Assets, Daten-ids, Engine, Theme und Pruefungen umgestellt; alte 32-px-Master im Archiv. Boden, Dach und Haus gezeichnet statt generiert (boden.py, dach.py) — FLUX-Kacheln hatten nach --flatten nur zwei Farben. Schrift neu in Zielaufloesung (font16.py, 12x16 entworfen, x2 exportiert, proportionaler Vorschub). Zwei Register: gemaltes Ortsbild mit Hotspots und Kachelgebiet mit gemalten Figuren, verbunden ueber einen ScreenManager. Die Schleife ist ohne Fenster geprueft (tools/probe_schleife.tscn). Dokumentation: darstellung.md (Regeln), stand.md (Uebergabe), Beweise unter art/prep/ (terrain-96, kacheltest, stadt-gemalt, schleife, stil-vergleich).
161 lines
6.9 KiB
GDScript
161 lines
6.9 KiB
GDScript
class_name UiTheme
|
|
extends RefCounted
|
|
## Das UI-Theme als Code-Fabrik — docs/darstellung.md §3.
|
|
##
|
|
## Warum nicht als `.tres`: die drei Flächen-Typen sind eine **Regel**, keine
|
|
## Sammlung von Handarbeit. Was hier steht, ist die einzige Stelle, an der
|
|
## Rahmen, Innenabstände und Zustandsfarben definiert sind — eine `.tres` würde
|
|
## dieselbe Regel noch einmal als Klickstrecke führen und beim nächsten Screen
|
|
## auseinanderlaufen.
|
|
##
|
|
## Benutzung (einmal, in `main.tscn` oder im ScreenManager):
|
|
##
|
|
## theme = UiTheme.baue()
|
|
##
|
|
## und dann an jedem Control `theme_type_variation = "WeltPanel"` bzw.
|
|
## `"ModalPanel"` setzen. Nichts anderes.
|
|
|
|
const PANEL_TEXTUR := "res://assets/ui/ui_panel_9slice_12px.png"
|
|
const PANEL_TEXTUR_3X := "res://assets/ui/ui_panel_9slice_12px_3x.png"
|
|
const FONT := "res://assets/font/font8_10.fnt"
|
|
const FONT_3X := "res://assets/font/font16_12_2x.fnt"
|
|
const DITHER_SHADER := "res://shaders/panel_dither.gdshader"
|
|
|
|
## Raster-Skala des Projekts: 3 = 1920er-Basis (seit 15.11.2026).
|
|
const SKALA := 3
|
|
|
|
## 9-Slice-Rand der 1x-Fassung (die 2x-Datei hat 4).
|
|
const RAND := 2
|
|
|
|
## Die Schrift ist ein BMFont und hat **eine** native Größe: `font16_12_2x.fnt`
|
|
## ist auf 12x16 entworfen und nur zweifach exportiert, also 32 px hoch mit
|
|
## Vorschub 24 und Zeile 36. Kleiner skalieren gibt es nicht — jede andere
|
|
## Größe ließe Godot interpolieren.
|
|
const SCHRIFTGROESSE := 32
|
|
|
|
## Innenabstand: Vielfache von 4 px, damit Buttons auf dem 8-px-Raster liegen.
|
|
const ABSTAND_H := 8
|
|
const ABSTAND_V := 4
|
|
|
|
# --- Farben (docs/ui.md §5, Anker aus der Weltpalette) ----------------------
|
|
const INK := Color(0.101961, 0.082353, 0.070588)
|
|
const PANEL := Color(0.227451, 0.184314, 0.152941)
|
|
const PANEL_HI := Color(0.329412, 0.270588, 0.211765)
|
|
const PANEL_LO := Color(0.152941, 0.125490, 0.105882)
|
|
const LINE := Color(0.486275, 0.403922, 0.305882)
|
|
const CREAM := Color(0.886275, 0.819608, 0.690196)
|
|
const CREAM_D := Color(0.690196, 0.627451, 0.509804)
|
|
const GOLD := Color(0.847059, 0.705882, 0.407843)
|
|
const OCHRE_D := Color(0.478431, 0.352941, 0.180392)
|
|
const AUS := Color(0.384314, 0.337255, 0.274510)
|
|
|
|
|
|
## `skala` ist die Raster-Skala: 3 = 1920er-Basis (seit 15.11.2026 der
|
|
## Projektstandard), 1 = die alte 640er-Basis. Die UI wird bei 3 nicht hochgezogen, sondern
|
|
## mit dreifachen Maßen gesetzt — 9-Slice-Rand 6, Innenabstand 24/12, Schrift
|
|
## 30 (Vorschub 24, Zeile 36).
|
|
static func baue(skala: int = SKALA) -> Theme:
|
|
var theme := Theme.new()
|
|
theme.default_font = load(FONT if skala == 1 else FONT_3X)
|
|
theme.default_font_size = SCHRIFTGROESSE
|
|
|
|
# --- Die drei Flächen (docs/darstellung.md §3) -------------------------
|
|
theme.set_type_variation("Rahmen", "Panel")
|
|
theme.set_type_variation("WeltPanel", "PanelContainer")
|
|
theme.set_type_variation("ModalPanel", "PanelContainer")
|
|
|
|
theme.set_stylebox("panel", "Rahmen", flaeche(Color(1, 1, 1), skala))
|
|
theme.set_stylebox("panel", "WeltPanel", flaeche(Color(1, 1, 1), skala))
|
|
# Das Modal ist dieselbe Fläche; den harten 2-px-Versatz zeichnet der
|
|
# Aufrufer als ColorRect dahinter (StyleBoxTexture kennt keinen Schatten).
|
|
theme.set_stylebox("panel", "ModalPanel", flaeche(Color(1, 1, 1), skala))
|
|
|
|
# --- Buttons ----------------------------------------------------------
|
|
theme.set_stylebox("normal", "Button", flaeche(Color(1, 1, 1), skala))
|
|
theme.set_stylebox("hover", "Button", flaeche(Color(1.55, 1.35, 1.05), skala))
|
|
theme.set_stylebox("pressed", "Button", flaeche(Color(0.82, 0.79, 0.74), skala))
|
|
theme.set_stylebox("disabled", "Button", flaeche(Color(0.62, 0.59, 0.55), skala))
|
|
theme.set_stylebox("focus", "Button", fokus(skala))
|
|
theme.set_color("font_color", "Button", CREAM)
|
|
theme.set_color("font_hover_color", "Button", GOLD)
|
|
theme.set_color("font_pressed_color", "Button", CREAM_D)
|
|
theme.set_color("font_disabled_color", "Button", AUS)
|
|
theme.set_font_size("font_size", "Button", SCHRIFTGROESSE)
|
|
|
|
# --- Text -------------------------------------------------------------
|
|
theme.set_color("font_color", "Label", CREAM)
|
|
theme.set_font_size("font_size", "Label", SCHRIFTGROESSE)
|
|
theme.set_color("default_color", "RichTextLabel", CREAM)
|
|
theme.set_font_size("normal_font_size", "RichTextLabel", SCHRIFTGROESSE)
|
|
theme.set_font_size("bold_font_size", "RichTextLabel", SCHRIFTGROESSE)
|
|
|
|
return theme
|
|
|
|
|
|
## Nicht-pixelige Fassung für die gemalten Register (Ortsbild, gemaltes
|
|
## Gebiet): Systemschrift, gerundete Flächen. Die Pixel-UI bleibt für Screens
|
|
## im Schema-Register.
|
|
static func baue_modern() -> Theme:
|
|
var theme := Theme.new()
|
|
var font := SystemFont.new()
|
|
font.font_names = PackedStringArray(["DejaVu Sans", "Noto Sans", "Sans"])
|
|
font.antialiasing = TextServer.FONT_ANTIALIASING_GRAY
|
|
theme.default_font = font
|
|
theme.default_font_size = 26
|
|
var flaeche := StyleBoxFlat.new()
|
|
flaeche.bg_color = Color(0.10, 0.09, 0.08, 0.88)
|
|
flaeche.border_color = Color(0.75, 0.68, 0.55, 0.9)
|
|
flaeche.set_border_width_all(2)
|
|
flaeche.set_corner_radius_all(10)
|
|
flaeche.set_content_margin_all(18)
|
|
for typ in ["WeltPanel", "ModalPanel", "Rahmen", "Button", "normal", "hover", "pressed"]:
|
|
theme.set_stylebox(typ, "PanelContainer" if typ in ["WeltPanel", "ModalPanel"] else "Button", flaeche)
|
|
theme.set_color("font_color", "Label", Color(0.95, 0.91, 0.84))
|
|
theme.set_color("font_color", "Button", Color(0.95, 0.91, 0.84))
|
|
return theme
|
|
|
|
|
|
## Eine Fläche aus dem 9-Slice-Panel. `tint` färbt die Textur über
|
|
## `modulate_color` um (1 = unverändert); damit kommen vier Knopfzustände aus
|
|
## einer Textur, ohne dass ein zweites Panel gezeichnet werden muss.
|
|
static func flaeche(tint: Color, skala: int = 1) -> StyleBoxTexture:
|
|
var sb := StyleBoxTexture.new()
|
|
sb.texture = load(PANEL_TEXTUR if skala == 1 else PANEL_TEXTUR_3X)
|
|
sb.texture_margin_left = RAND * skala
|
|
sb.texture_margin_top = RAND * skala
|
|
sb.texture_margin_right = RAND * skala
|
|
sb.texture_margin_bottom = RAND * skala
|
|
sb.content_margin_left = ABSTAND_H * skala
|
|
sb.content_margin_top = ABSTAND_V * skala
|
|
sb.content_margin_right = ABSTAND_H * skala
|
|
sb.content_margin_bottom = ABSTAND_V * skala
|
|
sb.modulate_color = tint
|
|
return sb
|
|
|
|
|
|
## Fokusrahmen: kein zweites Bild, sondern dieselbe Fläche in Gold.
|
|
static func fokus(skala: int = 1) -> StyleBoxTexture:
|
|
var sb := flaeche(Color(1.0, 0.94, 0.74), skala)
|
|
sb.expand_margin_left = 1.0 * skala
|
|
sb.expand_margin_top = 1.0 * skala
|
|
sb.expand_margin_right = 1.0 * skala
|
|
sb.expand_margin_bottom = 1.0 * skala
|
|
return sb
|
|
|
|
|
|
## Dimm-Ebene hinter einem Modal: docs/darstellung.md §3 „Ein Modal dimmt".
|
|
## `mouse_filter = STOP`, damit die Karte darunter keine Klicks mehr bekommt.
|
|
static func dimmung() -> ColorRect:
|
|
var rect := ColorRect.new()
|
|
rect.color = Color(0.0, 0.0, 0.0, 0.55)
|
|
rect.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
rect.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
return rect
|
|
|
|
|
|
## Material für geditherte Transparenz (50 %-Schachbrett) statt Alpha.
|
|
static func dither_material(deckung: float = 0.5) -> ShaderMaterial:
|
|
var mat := ShaderMaterial.new()
|
|
mat.shader = load(DITHER_SHADER)
|
|
mat.set_shader_parameter("deckung", deckung)
|
|
return mat
|