Manual Make

On this page
  1. Make a UI kit
  2. Choose a style
  3. Pick the pieces
  4. Change the materials
  5. What gets written
  6. Use it in Godot 4
  7. Re-export a piece you edited
  8. Fonts
  9. Style it
  10. Load it in Godot 4
  11. Next

UI and Fonts

Make a palette-locked 9-slice UI kit with a Godot 4 theme, and export the built-in pixel font as a BMFont any engine can load.

One command writes a UI kit: a dialog box, a panel, a button in all its states, an inventory slot and a health bar, as 9-slice pieces in your palette, plus a Godot 4 theme that styles the built-in controls with them. Another writes Mode 8's pixel font as a BMFont. Both run on the CPU, need no GPU, and give the same pixels every time.

A mock dialog in each of the four UI styles: bevel, flat, rounded and scifi, each with a title, body text and two buttons
The four UI styles on the same palette

Make a UI kit#

Inside a project, the kit uses the project's palette. Make an empty project to try it:

terminal
$ mode8 init my-game
✓ Created project my-game/
  palette nes_crimson_hero · new assets 64x72 · ComfyUI http://127.0.0.1:8188

Next:
  cd my-game
  mode8 draft knight_right --out drafts/hero.png
  mode8 studio .
  mode8 doctor   # check the local AI setup for mode8 gen
$ cd my-game
$ mode8 ui --out-dir exports/ui --sheet shots/ui.png
✓ UI kit (bevel): 31 pieces → exports/ui/
  dialog_box, panel, button_normal, button_hover, button_pressed, button_disabled, +25 more
  Godot theme exports/ui/ui_theme.tres (font size 9, a white tint mask; health bar, preview scene)
  palette nes_crimson_hero from mode8.toml

Next:
  mode8 verify --assets-dir exports/ui

That is the whole kit in the default bevel style: 9 pieces, their Godot styleboxes, a theme, a health bar scene and the theme's font. --sheet also writes a labeled, zoomed contact sheet of every piece for review.

The contact sheet of the bevel kit: dialog box, panel, the four button states, slot frame, health bar frame and fill, each labeled
Every piece of the bevel kit, labeled

Choose a style#

--style picks the look. Each style draws its pieces from named material ramps of the palette, so a kit always matches the rest of your art:

StyleBodyAccentLooks like
bevelmetalgoldraised steel plates with a gold rim (the default)
flatneutralwaterflat panels with a thin border, no bevel
roundedwoodgoldwarm wood with rounded corners
scifitechenergyhull panels with cut corners and a glowing edge

The health bar fill is the palette's blood ramp in every style.

terminal
$ mode8 ui --out-dir exports/ui-scifi --style scifi --palette cyberpunk_neon
✓ UI kit (scifi): 31 pieces → exports/ui-scifi/
  dialog_box, panel, button_normal, button_hover, button_pressed, button_disabled, +25 more
  Godot theme exports/ui-scifi/ui_theme.tres (font size 9, a white tint mask; health bar, preview scene)

Next:
  mode8 verify --assets-dir exports/ui-scifi

--palette overrides the project's palette for one kit. Outside a project, always pass one.

Pick the pieces#

--kinds takes a comma-separated list of dialog_box, panel, button, slot_frame and health_bar (the default is all of them). button writes four states, normal, hover, pressed and disabled, plus a focus ring; health_bar writes its frame and its fill. --size sets one size for every piece you ask for:

terminal
$ mode8 ui --out-dir exports/hud --kinds button,health_bar --size 64x16
✓ UI kit (bevel): 6 pieces → exports/hud/
  button_normal, button_hover, button_pressed, button_disabled, health_bar_frame, health_bar_fill
  Godot theme exports/hud/ui_theme.tres (font size 9, a white tint mask; health bar scene)
  palette nes_crimson_hero from mode8.toml

Next:
  mode8 verify --assets-dir exports/hud

Without --size, each kind has its own: dialog box 48x32, panel 32x32, button 32x16, slot frame 24x24, health bar 48x10. A 9-slice piece stretches to any size in the engine, so the default sizes are usually what you want.

Change the materials#

Each style fills three slots: body, accent and bar. --materials swaps the material a slot uses, for a stone and gold kit for a castle, say. mode8 list materials names every material a palette can declare:

terminal
$ mode8 ui --out-dir exports/ui-stone --materials body=stone,accent=gold
✓ UI kit (bevel): 31 pieces → exports/ui-stone/
  dialog_box, panel, button_normal, button_hover, button_pressed, button_disabled, +25 more
  Godot theme exports/ui-stone/ui_theme.tres (font size 9, a white tint mask; health bar, preview scene)
  palette nes_crimson_hero from mode8.toml

Next:
  mode8 verify --assets-dir exports/ui-stone

What gets written#

terminal
$ ls exports/ui
ui_button_disabled.png
ui_button_disabled_stylebox.tres
ui_button_focus_stylebox.tres
ui_button_hover.png
ui_button_hover_stylebox.tres
ui_button_normal.png
ui_button_normal_stylebox.tres
ui_button_pressed.png
ui_button_pressed_stylebox.tres
ui_checkbox_checked.png
ui_checkbox_checked_disabled.png
ui_checkbox_checked_disabled_texture.tres
Show 58 more lines
ui_checkbox_checked_hover.png
ui_checkbox_checked_hover_texture.tres
ui_checkbox_checked_texture.tres
ui_checkbox_empty.tres
ui_checkbox_radio_checked.png
ui_checkbox_radio_checked_disabled.png
ui_checkbox_radio_checked_disabled_texture.tres
ui_checkbox_radio_checked_texture.tres
ui_checkbox_radio_unchecked.png
ui_checkbox_radio_unchecked_disabled.png
ui_checkbox_radio_unchecked_disabled_texture.tres
ui_checkbox_radio_unchecked_texture.tres
ui_checkbox_unchecked.png
ui_checkbox_unchecked_disabled.png
ui_checkbox_unchecked_disabled_texture.tres
ui_checkbox_unchecked_hover.png
ui_checkbox_unchecked_hover_texture.tres
ui_checkbox_unchecked_texture.tres
ui_cursor.png
ui_cursor_texture.tres
ui_dialog_box.png
ui_dialog_box_stylebox.tres
ui_font.fnt
ui_font.png
ui_health_bar.tscn
ui_health_bar_fill.png
ui_health_bar_fill_stylebox.tres
ui_health_bar_frame.png
ui_health_bar_frame_stylebox.tres
ui_panel.png
ui_panel_stylebox.tres
ui_preview.tscn
ui_slider_fill.png
ui_slider_fill_hover.png
ui_slider_fill_hover_stylebox.tres
ui_slider_fill_stylebox.tres
ui_slider_grabber.png
ui_slider_grabber_disabled.png
ui_slider_grabber_disabled_texture.tres
ui_slider_grabber_hover.png
ui_slider_grabber_hover_texture.tres
ui_slider_grabber_texture.tres
ui_slider_track.png
ui_slider_track_stylebox.tres
ui_slot_frame.png
ui_slot_frame_stylebox.tres
ui_tab_disabled.png
ui_tab_disabled_stylebox.tres
ui_tab_hover.png
ui_tab_hover_stylebox.tres
ui_tab_selected.png
ui_tab_selected_stylebox.tres
ui_tab_unselected.png
ui_tab_unselected_stylebox.tres
ui_theme.tres
ui_tooltip.png
ui_tooltip_stylebox.tres
ui_ui.json

With the default --name ui:

FileWhat it is
ui_<piece>.pngone PNG per piece, in the palette
ui_<piece>_stylebox.tresa Godot 4 StyleBoxTexture per piece: its 9-slice margins, content margins and a nearest-filtered texture
ui_button_focus_stylebox.tresthe keyboard focus ring for buttons
ui_theme.tresa Godot 4 Theme that wires the styleboxes and the font into the built-in controls
ui_health_bar.tscna ready ProgressBar scene that uses the theme
ui_font.fnt, ui_font.pngthe theme's font (see Fonts)
ui_ui.jsonevery piece's size, 9-slice margins, content insets and min_size, for other engines

margins are the pixels on each side that never stretch. content is where text and child controls sit inside the frame. --formats png,json,godot limits the outputs, for example to png,json when you are not using Godot.

Every piece is checked against the palette as it is written. A piece that fails makes the command exit 1; mode8 verify --assets-dir exports/ui checks the whole folder again later.

Use it in Godot 4#

Copy the folder anywhere under your Godot project: the resources point at their PNGs by paths relative to themselves. Then give a Control the theme, and every Panel, PanelContainer, PopupPanel, AcceptDialog, Button and ProgressBar under it picks the kit up:

gdscript
$HUD.theme = load("res://ui/ui_theme.tres")
$HUD/Dialog.theme_type_variation = &"DialogBox"   # a PanelContainer drawn as the dialog box
$HUD/Slot.theme_type_variation = &"SlotFrame"     # a PanelContainer drawn as an inventory slot

Or instance ui_health_bar.tscn for a health bar that is already themed. The theme sets the font at size 9, which draws the pixel font 1:1. The font in a kit is white, and the theme colors it: label and button text in a light color of the palette, disabled text in a darker one.

If your project imports the kit under a fixed folder and you want absolute paths, pass --godot-res-prefix res://ui.

Tip

Every starter already ships a full kit in godot/art/ui/ and one project asset per piece (assets/ui_panel/ and so on), so you can start by painting over those in the Studio.

Re-export a piece you edited#

A generated piece is a starting point. Paint over it in the Studio or any editor, then hand it back with --source and its 9-slice margins (left, top, right, bottom). Name the piece in --kinds, such as panel, or one button state such as button_hover:

terminal
$ mode8 ui --out-dir exports/ui --source exports/ui/ui_panel.png --kinds panel --margins 4,4,4,4
✓ UI kit: 1 piece → exports/ui/
  panel

Next:
  mode8 verify --assets-dir exports/ui

The re-export checks the piece, rewrites its stylebox with the new margins (the theme points at that file, so Godot picks up the change), and writes the piece's metadata to ui_panel_ui.json. It keeps your PNG's size and look, so --style and --size do not apply. Forgetting --margins is an input error:

terminalexit 2
$ mode8 ui --out-dir exports/ui --source exports/ui/ui_panel.png --kinds panel
error: --source needs --margins L,T,R,B (the 9-slice borders of the hand-edited piece)
  e.g. mode8 ui --source edits/panel.png --kinds panel --margins 4,4,4,4 --out-dir exports/ui

Fonts#

Mode 8 has one built-in pixel font: 95 printable ASCII glyphs on a 5x9 grid, with 7 px capitals and 2 px descenders, proportional by default with digits of equal width. mode8 font writes it as an AngelCode BMFont: a .fnt description and a PNG atlas.

terminal
$ mode8 font --out-dir exports/font
✓ Bitmap font: 191 glyphs, line height 11 → exports/font/
  exports/font/font.fnt · exports/font/font.png
  proportional · Latin-1 · 1132 kerning pairs · Godot font size 9 draws it 1:1
The font specimen: the full character set, a pangram, kerning pairs and the outlined and shadowed variants at 1x and 2x
The built-in font

The .fnt names its PNG by file name, so keep the two files together. font_font.json describes the same glyphs as JSON. --formats png,fnt skips the JSON.

Style it#

The glyphs are white by default. --color sets another color, --outline adds a 1 px outline and --shadow a drop shadow. --scale draws the font at an integer multiple, 1 to 16, so the pixels stay square:

terminal
$ mode8 font --out-dir exports/font-title --name title --color '#f8e8b0' --outline '#000000' --shadow '#3a1c28' --scale 2
✓ Bitmap font title: 191 glyphs, line height 22 → exports/font-title/
  exports/font-title/title.fnt · exports/font-title/title.png
  proportional · Latin-1 · 1132 kerning pairs · Godot font size 18 draws it 1:1

Quote the colors: # starts a comment in most shells. --mono gives every glyph the same advance, for score counters and tables:

terminal
$ mode8 font --out-dir exports/font-mono --mono
✓ Bitmap font: 191 glyphs, line height 11 → exports/font-mono/
  exports/font-mono/font.fnt · exports/font-mono/font.png
  monospaced · Latin-1 · Godot font size 9 draws it 1:1

Load it in Godot 4#

Godot 4 imports a .fnt file as a FontFile. Use it at the size the summary names (9 at --scale 1, 18 at --scale 2) and it draws 1:1:

gdscript
var font := load("res://font/font.fnt")
$Score.add_theme_font_override("font", font)
$Score.add_theme_font_size_override("font_size", 9)

PixiJS and LÖVE read the same BMFont text format. Whatever the engine, give the atlas a nearest-neighbor filter so it is never smoothed.

Next#

  • Effects: hit flashes, explosions and sparkles in the same palette.
  • Palettes: the material ramps the kits are drawn from.
  • Godot: the rest of the Godot exports.