cube-tube/app/text.rb

63 lines
1.7 KiB
Ruby
Raw Normal View History

2023-03-08 03:06:29 +00:00
# Why put our text in a Hash? It makes it easier to proofread when near each
# other, makes the game easier to localize, and it's easier to manage than
# scouring the codebase.
#
# Don't access via this constant! Use the `#text` method instead.
TEXT = {
back: "Back",
controls_title: "Controls",
controls_keyboard: "WASD/Arrows to move | J/Z/Space to confirm | Esc/P to pause",
controls_gamepad: "Stick/D-Pad to move | A to confirm | Start to pause",
fullscreen: "Fullscreen",
made_by: "A game by",
music: "Music",
off: "OFF",
on: "ON",
paused: "Paused",
quit: "Quit",
resume: "Resume",
2023-04-11 06:26:39 +00:00
return_to_main_menu: "Main Menu",
2023-03-08 03:06:29 +00:00
settings: "Settings",
sfx: "Sound Effects",
start: "Start",
2023-04-11 06:26:39 +00:00
cube_tube: "Cube tube",
2023-03-08 03:06:29 +00:00
}
# Gets the text for the passed in `key`. Raises if it does not exist. We don't
# want missing text!
def text(key)
TEXT.fetch(key)
end
SIZE_XS = 0
SIZE_SM = 4
SIZE_MD = 6
2023-04-11 06:26:39 +00:00
SIZE_LG = 14
2023-03-08 03:06:29 +00:00
FONT_REGULAR = "fonts/Atkinson-Hyperlegible-Regular-102.ttf"
FONT_ITALIC = "fonts/Atkinson-Hyperlegible-Italic-102.ttf"
FONT_BOLD = "fonts/Atkinson-Hyperlegible-Bold-102.ttf"
FONT_BOLD_ITALIC = "fonts/Atkinson-Hyperlegible-BoldItalic-102.ttf"
2023-04-11 06:26:39 +00:00
FONT_DOTMATRIX = "fonts/DotMatrix.ttf"
FONT_DOTMATRIX_BOLD = "fonts/DotMatrix-Bold.ttf"
FONT_RUBIK_BLACK = "fonts/Rubik-Black.ttf"
2023-03-08 03:06:29 +00:00
# Friendly method with sensible defaults for creating DRGTK label data
# structures.
def label(value_or_key, x:, y:, align: ALIGN_LEFT, size: SIZE_MD, color: WHITE, font: FONT_REGULAR)
text = if value_or_key.is_a?(Symbol)
text(value_or_key)
else
value_or_key
end
{
text: text,
x: x,
y: y,
alignment_enum: align,
size_enum: size,
font: font,
}.merge(color)
end