91 lines
1.6 KiB
Plaintext
91 lines
1.6 KiB
Plaintext
fn config() {
|
|
let config = SceneConfig();
|
|
config.show_starfield(true);
|
|
config.show_phys(false);
|
|
return config
|
|
}
|
|
|
|
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",
|
|
"ui::landscape::test",
|
|
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("Title");
|
|
|
|
return [
|
|
button,
|
|
landscape,
|
|
frame,
|
|
title,
|
|
];
|
|
}
|
|
|
|
fn event(state, event) {
|
|
if type_of(event) == "MouseHoverEvent" {
|
|
let element = event.element();
|
|
if element.has_name("button") {
|
|
if event.is_enter() {
|
|
element.take_edge("on:top", 0.1);
|
|
} else {
|
|
element.take_edge("off:top", 0.1);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
if type_of(event) == "MouseClickEvent" {
|
|
if !event.is_down() {
|
|
return SceneAction::None;
|
|
}
|
|
|
|
let element = event.element();
|
|
if element.has_name("button") {
|
|
return SceneAction::GoTo("outfitter");
|
|
}
|
|
return;
|
|
}
|
|
|
|
if type_of(event) == "PlayerShipStateEvent" {
|
|
if !state.player_ship().is_landed() {
|
|
return SceneAction::GoTo("flying");
|
|
}
|
|
return;
|
|
}
|
|
} |