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.
EntryObject
An entry’s object form: { "type": ..., "value": ..., "comment": ..., ... }.
Picture
An image’s picture: its PNG and the file the build writes it to — which a texture packed into an atlas takes the place of.
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 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).
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.
color_of
A color entry’s value as ARGB, when it is one.
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.
name_problem
What’s wrong with entry name name, if anything.
parse
Parses .yres text. Every problem is reported, line:column: name: message one per line; 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.
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).
value_problem
What’s wrong with e’s value for its type, if anything — the build’s rule, which editors show too.
write
.yres text for entries, as the IDE writes it.
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.