Skip to content

Tutorials · Interfaces · Chapter 4

One palette

20 minutes Uses: Theme, ThemeRole, Button, Panel, Text

By the end

  • The HUD canvas’s Theme set to the pack’s palette, and applied
  • Gold titles by the Accent role; a red Drop button by the Danger role
On this page

One palette

So far every colour was typed onto the node that wears it. A Theme holds a screen’s colours in one place, as a palette, and Apply theme writes them into the controls under the canvas, each by the role it takes. Change a colour in one place and apply it again, and the whole screen follows.

  1. Select hud. Its Inspector holds two components: the Canvas from chapter 1, and a ThemeComponent, which a new Canvas comes with.
  2. In its Theme, set Panel to 255, 255, 255, alpha 255, Panel Accent to 254, 231, 97, alpha 255 and Panel Danger to 232, 69, 55, alpha 255. If the picker reads F at its top left, press it back to U8, as in chapter 1.
  3. Set Text to 236, 227, 206, alpha 255, Text Accent to 254, 174, 52, alpha 255 and Text Danger to 255, 228, 220, alpha 255.
  4. Set Button to 255, 255, 255, alpha 255 and Button Text to 236, 227, 206, alpha 255.
  5. Set Hover Lift to 0.15 and Press Sink to 0.35.
  6. Select bag and set its Rect’s Offset Max to -16, 448. The window grows from 252 to 288 high, to leave room at its foot for a button.
hud selected, its Inspector narrowed with the search box, theme, to its Theme: Panel white, Panel Accent yellow, Panel Danger red, Text cream, Text Accent orange, Text Danger pale pink, Button white, Button Text cream, Hover Lift 0.15 and Press Sink 0.35, with an Apply theme button under them; the Viewport shows the HUD’s plate and the bag, its title BAG in gold and a small red DROP button at its foot
The Theme as this chapter leaves it.
Panel, Panel Accent, Panel Danger
The fills of panels, by role: the plain one, an accent for emphasis, and a danger one for what deletes or discards. The Delve’s panels draw pictures, and a white fill draws a picture as it is, so the plain one is white. The accent is a warm yellow, 254, 231, 97, and the danger a red, 232, 69, 55.
Text, Text Accent, Text Danger
The colours of words, by the same three roles. The plain words are the cream of chapter 1’s title, 236, 227, 206. The accent is gold, 254, 174, 52, and the danger words a pale pink, 255, 228, 220, picked to read on the red.
Button, Button Text
A plain button’s face when it is idle, and the words on it. White again, for the same reason, and the cream words. An accent or a danger button takes its role’s fill and its role’s words instead, so these two matter first to the plain buttons that start in chapter 5.
Hover Lift, Press Sink
How far a button’s face changes under the pointer and while it is held, each a fraction from 0 to 1 of the way to white or to black. Hover Lift lightens the face toward white: 0.15. Press Sink darkens it toward black: 0.35. A new Theme’s are both 0.2.

Roles

A node’s Theme Role says which of the Theme’s looks its controls take. A node with no Theme Role takes the plain one, so most of the HUD needs none.

  1. Select hud_title, click Add component and choose ThemeRoleComponent. Set Role to Accent.
  2. Do the same for bag_title.
  3. Select gem_plate, click Add component and choose ThemeRoleComponent, and set Role to Custom.
bag_title selected, its Inspector narrowed with the search box, role, to its Theme Role: Role Accent; the Viewport shows the bag with its title BAG in gold
Role
Which of the Theme’s looks the node’s controls take. Normal is the plain look, and a node with no Theme Role has it. Accent is for emphasis: the two titles. Danger is for a button that deletes or discards: Drop. Custom keeps the node’s own colours through every Apply theme: the gem plate.

A danger button

The bag gets a Drop button at its foot. Chapter 9 makes it ask whether to empty the bag. It takes the Danger role, so it comes out red.

  1. Select bag, click + Add node and choose Button. Rename the node drop_button.
  2. In its Rect, set Anchor Min to 1, 1, Offset Min to -108, -40, Offset Max to -12, -12 and Pivot to 1, 1. Anchor Max stays 1, 1. The button is 96 wide and 28 high, 12 in from the bag’s right and bottom edges.
  3. In its Panel, set Texture to panelInset_beige.png and Border to 6.
  4. In its Text, set Text to Drop, Scale to 0.5 and Align to Center.
  5. Click Add component and choose ThemeRoleComponent. Set Role to Danger.
  6. In its Button, set Action to drop.

The Panel’s Color, the Text’s Color and the Button’s three tints are not typed. Apply theme writes them, in the next section, from the Danger role.

drop_button selected, its Inspector narrowed with the search box, button, to its Button: Action drop, Disabled unticked, Normal a strong red, Hovered a lighter red, Pressed a darker red, and Hovered Texture, Pressed Texture and Disabled Texture all (none); the Viewport shows the bag with its red DROP button at the foot
The Button’s rows as this chapter leaves them.
Action
A Button’s Action: the name of the action its press fires, here drop. A Button fires it when a click on it is let go, or when Enter or Space is pressed while it has the focus. A script reads it with pressed("drop"), which is true for one step, the first after that. Nothing listens for drop yet: chapter 9’s question for the bag does.
Normal, Hovered, Pressed
The face’s tint at rest, under the pointer or with the focus, and while a click holds it down. Apply theme writes them from the role: Normal is the role’s fill, 232, 69, 55, Hovered is that lifted toward white by Hover Lift, 236, 124, 118, and Pressed that sunk toward black by Press Sink, 192, 55, 44.

The Button’s other four rows, Disabled and the three pictures, stay as they come. Chapter 5 sets them.

The two pictures below show the finished button. The first is taken before the game has taken a step, and the second a moment later, with the pointer on it.

Close up, the bag’s window as the game opens: the gold title BAG, the slots, and under them a button reading DROP in a strong, deep red
The first frame, before the game takes a step: Drop in its Normal red.
Close up, the same with the pointer on DROP: the button lighter, a salmon red
A moment later, with the pointer on Drop: its Hovered colour, lifted toward white.

Apply theme

  1. Select hud and press Apply theme, at the foot of its Theme. The two titles turn gold and Drop turns red.
  2. Press Ctrl+Z. The whole restyle was one step, so it goes back at once: the titles cream again, and Drop as it was before. Press Apply theme again.

Apply theme walks every node under the canvas and writes the Theme’s colours into its controls by its role: a Panel’s colour, a Text’s colour, a Button’s three tints, a Slider’s fill and track. A node already at its role’s colour stays as it was, which is why only the two titles and Drop changed here, and a Custom node is skipped. Pressing it twice is the same as pressing it once.

The colours are then the controls’ own. They are saved with the scene and drawn by an exported game, which never runs the Theme itself. So changing the Theme later changes nothing until you apply it again.

The room as chapter 3 left it: the HUD’s plate at the top left with its cream title, and the bag at the right with its cream title and sixteen slots, ending just below the slots with no button at its foot
For comparison, chapter 3’s HUD, before the theme.
The room with the theme applied: the titles THE DELVE and BAG in gold, and under the bag’s slots a red DROP button, drawn lighter than its resting red
The same with the theme applied: gold titles and a red Drop.

The theme, the roles and the Drop button

The theme

NodeComponentFieldValue
hudThemePanel255, 255, 255, alpha 255
Panel Accent254, 231, 97, alpha 255
Panel Danger232, 69, 55, alpha 255
Text236, 227, 206, alpha 255
Text Accent254, 174, 52, alpha 255
Text Danger255, 228, 220, alpha 255
Button255, 255, 255, alpha 255
Button Text236, 227, 206, alpha 255
Hover Lift0.15
Press Sink0.35
bagRectOffset Max-16, 448

The roles

NodeComponentFieldValue
hud_title, bag_titleTheme RoleRoleAccent
TextColor254, 174, 52, alpha 255, written by Apply theme
gem_plateTheme RoleRoleCustom

The Drop button

ComponentFieldValue
RectAnchor Min1, 1
Anchor Max1, 1
Offset Min-108, -40
Offset Max-12, -12
Pivot1, 1
PanelColor232, 69, 55, alpha 255, written by Apply theme
TexturepanelInset_beige.png
Border6
TextTextDrop
Scale0.5
Color255, 228, 220, alpha 255, written by Apply theme
AlignCenter
ButtonActiondrop
Normal232, 69, 55, alpha 255, written by Apply theme
Hovered236, 124, 118, alpha 255, written by Apply theme
Pressed192, 55, 44, alpha 255, written by Apply theme
Theme RoleRoleDanger

Every other field of every node is as it comes.

Check it works

Part 1 ends here: a HUD and a bag that look finished and do nothing yet. The title screen begins making them work.