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>/..., plus a sounds.json for the sounds;
  • generates .yog-build/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>.
ResFile
One .yres file.
Set
A resource set: its neutral file and culture variants.

Enums§

Kind
An entry’s type.
Value
A JSON scalar as written: a string, a number (its literal) or a bool.

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).
NEUTRAL_LOCALE
The locale of the neutral <Set>.yres files.
RESOURCES_DIR
Where resource files live, under the mod root.

Functions§

accessor_name
The accessor for entry name: screen.title → screen_title, ModName → mod_name.
compile
Compiles the mod’s resources (see the module docs). Any error fails the whole thing, listing every problem.
default_key
The default translation key of text name in set set.
find
Every resources/**/*.yres of the mod at root, sorted.
parse
Parses .yres text. Errors are line N: message. Duplicate names are an error; 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.
split_file_name
resources/.../Strings.ru_ru.yres → ("Strings", Some("ru_ru")).
valid_locale
Minecraft’s locale codes: lower case, en_us, pt_br, lol_us, …
valid_name
An entry name: identifiers joined by . (title, screen.title).
valid_set_name
A resource set name: one identifier (Strings, Icons).
write_sources
Writes .yog-build/generated/resources/<Set>.g.rs per set and .yog-build/generated/resources.g.rs including them all (what yog_api::resources!() pulls in as crate::res); deletes those of sets that are gone.

Type Aliases§

Output
A generated file: path inside the .yog and its bytes.