Skip to main content

Module yres

Module yres 

Source
Expand description

.yres resource files — a mod’s texts, images, sounds, files, colors, numbers and flags, like a C# project’s Resources/*.resx. See Yog-IDLE’s docs/yres.md for the format.

yog build reads resources/**/*.yres: <Set>.yres is the neutral (en_us) file of resource set <Set>, <Set>.<locale>.yres its culture variants (texts only). It

  • writes the texts into assets/<mod id>/lang/<locale>.json (merged with a hand-written one), {name}/{0} placeholders turned into %1$s;
  • bundles image/file/sound entries’ files under assets/<mod id>/... (sounds as Ogg Vorbis: .ysound events name them);
  • generates obj/generated/resources/<Set>.g.rs — a type per set with a typed accessor per entry — and resources.g.rs including them, pulled in as crate::res by yog_api::resources!();;
  • resolves @<Set>.<name> references for .yui screens and yog.toml.

Structs§

Compiled
Everything yog build makes of a mod’s resources.
Entry
One entry of a .yres file.
Refs
What .yui screens and yog.toml can refer to as @<Set>.<name>.

Enums§

Kind
An entry’s type.
Value
A scalar as written: a string, a number (its literal), a bool, or bytes (a picture, a sound, a file — @bytes:<base64>).

Constants§

GENERATED_DIR
Where the per-set <Set>.g.rs files go.
GENERATED_FILE
Where the generated accessors go, under the mod root. The file yog_api::resources!() includes; it includes one resources/<Set>.g.rs per set (shown under its .yres in Yog-IDLE).
GENERATED_SCRIPT
The generated Yog Script of every set (Res.<Set>.<Entry>).
NEUTRAL_LOCALE
The locale of the neutral <Set>.yres files.

Functions§

compile
Compiles the mod’s resources (see the module docs). Any error fails the whole thing, listing every problem.
parse
Parses .yres text: its entries, or every problem, each with its code and place; names aren’t validated here (see [valid_name]).
resolve_image
Resolves a yog.toml image value: @<Set>.<name> → its image source.
resolve_text
Resolves a yog.toml value: @<Set>.<name> of a text → (neutral text, Some(key)); anything else as is. Errors on an unknown reference.
write
.yres text for entries, as the IDE writes it.
write_sources
Writes obj/generated/resources/<Set>.g.rs per set and obj/generated/resources.g.rs including them all (what yog_api::resources!() pulls in as crate::res); deletes those of sets that are gone.