10 kB 127 lines
b2461cb6
nanachi.org
⋯
docs/game-assets.md
download raw history
at master Markdown

Game and portal assets #

The UI copies Factorio's Mods window and the mod portal's style. This page lists where the visuals and UI sounds come from, which files the build embeds, and how to refresh them.

Credits: sprites, fonts, styles and screenshots are from Factorio 2.0.77 by Wube Software. Portal colours, border images and typography come from the shared stylesheet at factorio.com / mods.factorio.com. Mods and their thumbnails belong to their authors.

Sources #

  • The game is authoritative for every widget it draws. data/core/prototypes/style.lua defines styles and graphical sets over data/core/graphics/gui-new.png (597x1220, drawn at sprite scale 0.5, so the atlas is 2x at 100% UI scale). Cut pieces from the atlas at the target scale and use their nine-slice metadata; don't approximate edges with softer shadows.
  • The portal supplies portal-only widgets (filter sidebar, exclude toggles, description rendering) and cross-checks. Every portal page loads the same factorio.com/static/css/main.css. tools/fetch-portal-css.ts extracts the rules our widgets use, plus every class used by the /search page and the base typography, into docs/reference/portal-css.txt, and the embedded images into assets/portal/. If a portal widget seems missing, check the extractor's filter first.
  • Screenshots of the game at 100% and 125% UI scale, and crops of individual states, are catalogued in docs/reference/README.md.

Install layout (read-only) #

  • data/base/info.json gives the game version; data/{base,elevated-rails,quality,space-age}/ hold builtin mod metadata and thumbnails. core is not a mod.
  • The write-data folder is %APPDATA%\Factorio by default: mods/, mods/mod-list.json, mods/mod-settings.dat, config/config.ini, saves, logs. config-path.cfg and a literal write-data= in config.ini can relocate it. player-data.json may hold credentials and is never read.
  • Design inputs under data/core: prototypes/style.lua, prototypes/fonts.lua, locale/en/info.json, fonts/TitilliumWeb-{Regular,SemiBold,Bold}.ttf, graphics/icons/mod-manager/ (ban states, download, history), graphics/icons/mip/ (authored small icons; use the 16 px mip at 100% instead of filtering a larger image), graphics/missing-thumbnail.png (144x144), and the executable icons.

What is tracked #

Path Contents
assets/game/sounds/ Ten used Ogg Vorbis GUI cues and index.json (source paths, gains, SHA-256, game version); embedded in Rust
assets/game/fonts/ Titillium Web Regular, SemiBold, Bold
assets/game/pieces/1/ 100% nine-slice surfaces, states, corners, ribs and index.json (checked by build.rs)
assets/game/icons1x/ 100% GUI icons used by views
assets/game/factorio.ico, factorio-icon.png Windows resource icon and Slint window icon
assets/game/factorio.icns macOS .app icon, copied from factorio.app/Contents/Resources of a macOS install (16–128 px, as the game ships it)
assets/portal/ Portal border-image PNGs, backgrounds and SVGs
assets/ui/ Hand-drawn view-mode SVGs (table, rows, grid)
docs/reference/game-assets.txt Inventory of the tracked game files

Everything else the tools produce (assets/game/sprites/, icons/, styles.json, slices/, 1.25x pieces) is ignored. Update game-assets.txt when embedded assets change. Mod thumbnails at runtime come from the user's mods and the app cache, not from these folders.

Refreshing #

Set FACTORIO_DIR if the install isn't in a standard location. The tools only read the install.

bun tools/setup-assets.ts         :: extract-assets, dump-styles, pieces --scale 1, make-icons, in order
bun tools/fetch-portal-css.ts     :: portal-css.txt and assets/portal/
bun bench/slint/gen-pieces.ts     :: regenerate src/view/widgets/pieces.slint from the piece index
Tool Does
tools/extract-assets.ts Copies used GUI Vorbis clips, fonts, icons and atlas regions into assets/game/; sprites/index.json records each source rect, corner size, draw type and scale.
tools/dump-styles.ts Evaluates the stock style.lua and font definitions in a sandboxed Lua 5.4 VM (wasmoon) into assets/game/styles.json (raw and resolved styles, constants, fonts, game version; keys sorted, no absolute paths). It doesn't run the game's data stage or load modded styles.
tools/pieces.ts [--scale 1|1.25] [--out dir] Cuts and composes the atlas into whole nine-slice PNGs at the target scale plus index.json (source, tint, extents, fixed/stretch/tile axes). ensurePieces(scale) refreshes stale output; fingerprints include source, version and scale.
tools/style-slices.ts Diagnostic per-piece exporter (button:hovered, checkbox:checked, ...) into assets/game/slices/; owns the shared boxResize filter. Not a runtime input.
bench/slint/make-icons.ts Builds the 100% icons in assets/game/icons1x/.

src/core/gameStyle.ts is the style resolver behind the piece tool. inheritStyles follows explicit parents (or the root implied by the style type) and fails on missing parents or cycles; metric and padding shorthands expand before inheritance; nested values replace the inherited value whole. resolve(dump, name, state) returns metrics, padding, offsets, font and state colour, and ordered graphical layers (shadow, base, glow; backgrounds first, marks last) for default, hover, clicked, disabled, selected and checkbox states. Colours accept normalised or byte tuples (any component above 1 means bytes); tint multiplies RGB and alpha, opacity only alpha.

Raster rules: the box filter integrates fractional source coverage in premultiplied alpha and returns straight RGBA, avoiding fringes; channel conversion truncates. Fixed axes scale, stretched axes keep their source raster, tiled axes scale. A corner-size-8 composition is 17x17 source pixels (8 px corners, 1 px edges and centre), which is 4 logical px borders at 100%. Outer shadows and glows usually extend 4 logical px beyond the box. Use logical sizes for layout, not raster sizes. Selected tabs draw above their pane, unselected tabs below it, and tab glow extends outside the tab.

Visual tokens #

Token Value
Panel / recessed surface #313031 / #242324
Portal grey button: rest, hover, pressed, disabled #8e8e8e, #e39827, #f1be64, #3d3d3d
Green button: rest, hover, pressed #5eb663, #92e897, #cfdf93
Red button: rest, hover #fe5a5a, #ff9b9b
Cream heading / active tab text #ffe6c0
Link: game / portal #80cef0 / #7dcaed
Warning label #ff8e8e
Optional dependency #f9a838

Game metrics: default font Regular 14 px (semibold and bold 14 px), dialog buttons Bold 18 px, heading-1 Bold 18 px, default-tiny-bold Bold 10 px. Checkbox 14x14 logical px; ordinary buttons 28 px high with minimum width 108; dialog buttons 32 px high; tabs minimum width 84; thumbnails 144 px; vertical scrollbar 12 px wide; table rows 28 px. Titillium metrics: 1000 units per em, ascender 1133, descender -388, cap height about 0.69 em. The game's glyph advances are whole-pixel snapped, so long lines wrap and drift slightly differently here.

Manage rows are all #242324 with per-cell graphical sets. Game InfoTable separators are grooves over #403f40.

Where the game and portal differ (the game wins) #

Item Portal CSS Game
Button size height 36, min width 128, padding 10 12 28 px high, min width 108
Button bevel and shadow 2 px inset line, black outer shadow Five-pixel bevel ramp, brownish dirt glow
Disabled button text #818181 #b3b3b3
Tabs Radius 4, padding 10 18, inactive text #1d1c1d, weight 600 Sprite corners, min width 84, text #000000 bold; active fill #403f40
Checkbox 16x15, CSS-rotated tick 14x14 sprite tick
Panels Thin inset highlight, 0 0 3px shadow Five-pixel bevel ramps and atlas glows
Details table Filled #414040 cells Groove lines on #403f40, no cell fill
Zebra rows #3b3a3b / #424142 None in Manage; stripes appear only as the empty-list background

Button fill colours and the cream heading colour are identical in both.

Component sources #

Style names in style.lua (game 2.0.77) behind each widget, for looking up pieces:

Widget Style
Window frame, title strip, footer frame, draggable_space_header, draggable_space
Raised panel, details header inside_shallow_frame, subheader_frame
Inset panel inside_deep_frame, deep_frame_in_shallow_frame, default_inner_shadow
Tabs tab, tabbed_pane, tabbed_pane_frame
Buttons button, green_button, red_button, mini_button
Back / Confirm back_button, confirm_button over dialog_button
Tool buttons tool_button, tool_button_red
Checkbox checkbox
Mod table table_with_selection, mods_scroll_pane
Details key/value table bordered_table (border_image_set())
Thumbnail mod_thumbnail_image
Sort dropdown dropdown, dropdown_button
Explore filters mods_filter_exclude_button, mods_filter_hit_count_label, caption_label
Scrollbar vertical_scrollbar
Updates error banner negative_message_frame
Search field textbox (closest match; the game has no dedicated search style)

UI sounds #

The app embeds the ten clips in assets/game/sounds/index.json, copied byte for byte from Factorio 2.0.77 data/core/sound/. The manifest credits Wube Software and records each source, gain and SHA-256. The red text button has gain 0.5; other currently used cues have gain 1. Mini buttons, true switches and red forward arrows are absent, so their unused sounds are not included. Red tool buttons use the tool cue; Back/Cancel/Exit use the ordinary click. List selection and cannot feedback are app mapping choices; game/desktop listening parity remains unverified.

FACTORIO_DIR=... bun tools/extract-assets.ts --sounds-only refreshes just this subset. Missing/unreadable source clips leave the prior subset intact. A missing install leaves tracked assets intact. No sound discovery, extraction or game access occurs during playback. Missing/corrupt embedded clips are individually silent. The Settings slider uses extracted slider full/empty bars and button states from style.lua, generated through tools/pieces.ts.