Skip to main content

Module yui

Module yui 

Source
Expand description

.yui screen files — the declarative form of a yog-ui widget tree that Yog-IDLE’s screen designer edits — and their code generation.

A .yui file is a small XAML-like XML document: one element per widget, attributes named after the yog-ui builder methods they become:

<Screen id="mymod:main_menu" width="176" height="166" anchor="center" bg="#C0101010" padding="8">
  <Label id="title" x="8" y="6" text="Main Menu" color="#FFFFFF" no_wrap="true"/>
  <Button x="38" y="40" w="100" h="20" text="Play" bg="#FF555555" on_click="play"/>
  <Column x="8" y="70" w="160" gap="2">
    <Label text="Flowing child"/>
  </Column>
</Screen>

yog build (and yog check, yog ui gen) turns src/**/foo.yui into .yog-build/generated/**/foo.g.rs — WPF’s MainWindow.g.cs: generated into the build directory on every build, never committed, pulled into the screen’s hand-written code-behind module with yog_api::ui_include!("foo"). See docs/yui.md in Yog-IDLE for the full format.

Structs§

Element
One XML element: name, attributes in source order, child elements.

Constants§

GENERATED_DIR
Where generated screen code goes, under the project root.
HEX_MARK
What a color written in hex starts with: #RRGGBB.

Functions§

color
#RRGGBB, #AARRGGBB or 0xAARRGGBB → 0xAARRGGBB (Color::parse; a file’s color is written with its # or 0x, not as a decimal).
const_name
A Rust constant name for an event/widget id: mymod:btn-play → MYMOD_BTN_PLAY.
find_yui_files
generate
Generates the .g.rs source for a .yui document. name is the screen’s path under src/ without the extension (mod_list, screens/options): what the code-behind passes to ui_include!.
generate_all
yog build’s step: regenerates every src/**/*.yui’s .g.rs and drops generated files whose .yui is gone.
generate_file
Generates .yog-build/generated/<name>.g.rs for one .yui file of the project at root — only rewritten when the output changed, so cargo doesn’t rebuild for nothing.
generate_for
generate for the mod mod_id (resolves mod: image sources), also returning line N: ... warnings.
generate_with
generate_for with the mod’s recipe layouts, for <RecipeArea>s.
generated_path
Where src/<name>.yui’s generated code goes: .yog-build/generated/<name>.g.rs.
include_name
foo.yui’s name for ui_include!: its path under src/ without the extension, /-separated (mod_list, screens/options).
is_book_page_file
Every .yui file under dir, recursively. Whether path’s root is a <Component book_page="…">.
parse_xml
Parses an XML document (the subset .yui uses) into its root element.
pascal
stat_bar / my-mod → StatBar / MyMod.
project_root
The project root (the folder with yog.toml) a .yui file belongs to.
set_resource_refs
Makes the mod’s compiled .yres resources visible to the generator: text="@Strings.title" and source="@Icons.logo" resolve through them.
text_expr
The Rust expression for a text attribute, its @ forms as everywhere in Yog Data (yog_data::typed): "@Strings.title" is a text of resources/Strings.yres (see set_resource_refs), "@lang:gui.done" any translation key, "@item:minecraft:stick" (@block:, @entity:) that content’s name — each looked up when the tree is built (::yog_api::tr, so it follows the game’s language); "@@..." is a literal text starting with @; anything else is the literal text.