Galactica/content/ui/landed.rhai

110 lines
1.8 KiB
Plaintext

fn init(state) {
let player = state.player_ship();
conf::show_starfield(true);
conf::show_phys(false);
sprite::add(
"button",
"ui::planet::button",
Rect(
99.0, 128.0, 73.898, 18.708,
Anchor::NorthWest,
Anchor::Center
)
);
sprite::add(
"landscape",
{
if player.is_landed() {
player.landed_on().image();
} else {
"";
}
},
Rect(
-180.0, 142.0, 274.0, 135.0,
Anchor::NorthWest,
Anchor::Center
)
);
sprite::set_mask("landscape", "ui::landscapemask");
sprite::add(
"frame",
"ui::planet",
Rect(
0.0, 0.0, 400.0, 297.866,
Anchor::Center,
Anchor::Center
)
);
textbox::add(
"title", 10.0, 10.0,
Rect(
-70.79, 138.0, 59.867, 10.0,
Anchor::NorthWest,
Anchor::Center
),
Color(1.0, 1.0, 1.0, 1.0)
);
textbox::align_center("title");
textbox::font_serif("title");
textbox::weight_bold("title");
if player.is_landed() {
textbox::set_text("title", player.landed_on().name());
}
textbox::add(
"desc", 7.5, 8.0,
Rect(
-178.92, -20.3, 343.0, 81.467,
Anchor::NorthWest,
Anchor::Center
),
Color(1.0, 1.0, 1.0, 1.0)
);
textbox::font_sans("desc");
if player.is_landed() {
textbox::set_text("desc", player.landed_on().desc());
}
}
fn event(state, event) {
if type_of(event) == "MouseHoverEvent" {
let element = event.element();
if element == "button" {
if event.is_enter() {
sprite::take_edge("button", "on:top", 0.1);
} else {
sprite::take_edge("button", "off:top", 0.1);
}
}
return;
}
if type_of(event) == "MouseClickEvent" {
if !event.is_down() {
return;
}
let element = event.element();
if element == "button" {
ui::go_to_scene("outfitter");
return;
}
return;
}
if type_of(event) == "PlayerShipStateEvent" {
if !state.player_ship().is_landed() {
ui::go_to_scene("flying");
return;
}
return;
}
}