Galactica/content/landed.rhai

71 lines
1.2 KiB
Plaintext

fn init(state) {
let frame = SpriteBuilder(
"frame",
"ui::planet",
Rect(
0.0, 0.0, 400.0, 297.866,
SpriteAnchor::Center,
SpriteAnchor::Center
)
);
let landscape = SpriteBuilder(
"landscape",
state.planet_landscape,
Rect(
-180.0, 142.0, 274.0, 135.0,
SpriteAnchor::NorthWest,
SpriteAnchor::Center
)
);
landscape.set_mask("ui::landscapemask");
let button = SpriteBuilder(
"button",
"ui::planet::button",
Rect(
99.0, 128.0, 73.898, 18.708,
SpriteAnchor::NorthWest,
SpriteAnchor::Center
)
);
let title = TextBoxBuilder(
"title",
10.0, 10.0, TextBoxFont::Serif, TextBoxJustify::Center,
Rect(
-70.79, 138.0, 59.867, 10.0,
SpriteAnchor::NorthWest,
SpriteAnchor::Center
)
);
title.set_text(state.planet_name);
return [
button,
landscape,
frame,
title,
];
}
fn hover(element, hover_state) {
if element.has_name("button") {
if hover_state {
element.take_edge("on:top", 0.1);
} else {
element.take_edge("off:top", 0.1);
}
}
}
fn click(element, click_state) {
if !click_state {
return SceneAction::None;
}
if element.has_name("button") {
return SceneAction::SceneOutfitter;
}
}