yog-cli 0.49.0

Yog build tool — `yog build` compiles a mod and packages it as .yog.
Documentation
// <auto-generated>
//     Generated by yog from src/$NAME$.yui (view model $VM$, codegen $CODEGEN$) —
//     do not edit: changes are lost on the next `yog build` / `yog check` /
//     `yog ui gen`. Edit the .yui file instead.
// </auto-generated>
//
// Pulled into the code-behind module (which defines `$VM$`) with:
//
//     yog_api::ui_include!("$NAME$");

const _: () = ::yog_kit::__codegen::require($CODEGEN$);

/// The UI id this screen registers under.
#[allow(dead_code)]
pub const ID: &str = $ID_LIT$;
/// Design-time size in GUI pixels.
#[allow(dead_code)]
pub const WIDTH: f32 = $WIDTH$;
#[allow(dead_code)]
pub const HEIGHT: f32 = $HEIGHT$;

/// Ids of this screen's named widgets.
#[allow(dead_code)]
pub mod ids {
$IDS$}

$TEMPLATES$/// The compiled view of this screen — hosted by `yog_kit::Screen`.
/// Private like the view model it names; tests in the code-behind
/// module drive it with `yog_kit::testing::TestHost<View>`.
struct View {
$VIEW_FIELDS$}

impl ::yog_kit::View for View {
    type Vm = $VM$;
    const META: ::yog_kit::ScreenMeta = ::yog_kit::ScreenMeta {
        id: ID,
        w: WIDTH,
        h: HEIGHT,
        anchor: ::yog_kit::Anchor::$ANCHOR$,
        modal: $MODAL$,
        pause: $PAUSE$,
        live: $LIVE$,
    };

    fn build() -> (Self, ::yog_api::ui::Widget, ::yog_kit::Parts) {
        #[allow(unused_imports)]
        $UI_USE$
        let root = $EXPR$;
        #[allow(unused_mut)]
        let mut parts = ::yog_kit::Parts::new();
$PARTS$        let view = View {
$VIEW_INITS$        };
        (view, root, parts)
    }

    #[allow(unused_variables)]
    fn update(&mut self, root: &mut ::yog_api::ui::Widget, vm: &$VM$, u: &mut ::yog_kit::Update) {
$UPDATE$    }

    #[allow(unused_variables, clippy::let_unit_value, clippy::single_match, clippy::match_single_binding)]
    fn dispatch(&mut self, vm: &mut $VM$, cx: &mut ::yog_kit::Cx<'_, $VM$>, ev: ::yog_kit::ViewEvent) {
        match ev {
$DISPATCH$            _ => {}
        }
    }
}

static __HANDLE: ::std::sync::OnceLock<::yog_kit::ScreenHandle<$VM$>> = ::std::sync::OnceLock::new();

/// Registers the screen (rendering + input) with a new view model
/// (`$CREATE$`); returns its handle. Call once, from `Mod::register`.
#[allow(dead_code, private_interfaces)]
pub fn register(registry: &mut ::yog_api::Registry) -> ::yog_kit::ScreenHandle<$VM$> {
    register_with(registry, $CREATE$)
}

/// [`register`] with a given view model.
#[allow(dead_code, private_interfaces)]
pub fn register_with(registry: &mut ::yog_api::Registry, vm: $VM$) -> ::yog_kit::ScreenHandle<$VM$> {
    ::std::clone::Clone::clone(__HANDLE.get_or_init(|| ::yog_kit::Screen::<View>::register(registry, vm)))
}

/// The handle [`register`] returned (`None` before it).
#[allow(dead_code, private_interfaces)]
pub fn handle() -> ::std::option::Option<::yog_kit::ScreenHandle<$VM$>> {
    __HANDLE.get().cloned()
}

/// Opens the screen (modal: $MODAL$, pauses the game: $PAUSE$).
#[allow(dead_code)]
pub fn open() {
    ::yog_api::open_ui(ID, $MODAL$, $PAUSE$);
}

/// Closes the screen if it's open.
#[allow(dead_code)]
pub fn close() {
    ::yog_api::close_ui(ID);
}