127 lines
2.4 KiB
Plaintext
127 lines
2.4 KiB
Plaintext
fn init(state) {
|
|
conf::show_starfield(true);
|
|
conf::show_phys(false);
|
|
|
|
sprite::add(
|
|
"button",
|
|
"ui::planet::button",
|
|
Rect(
|
|
99.0, 128.0, 73.898, 18.708,
|
|
Anchor::Center,
|
|
Anchor::NorthWest
|
|
)
|
|
);
|
|
|
|
sprite::add(
|
|
"landscape",
|
|
{
|
|
if state.player_ship().is_landed() {
|
|
state.player_ship().landed_on().image();
|
|
} else {
|
|
"";
|
|
}
|
|
},
|
|
Rect(
|
|
-180.0, 142.0, 274.0, 135.0,
|
|
Anchor::Center,
|
|
Anchor::NorthWest
|
|
)
|
|
);
|
|
sprite::set_mask("landscape", "ui::landscapemask");
|
|
|
|
sprite::add(
|
|
"frame",
|
|
"ui::planet",
|
|
Rect(
|
|
0.0, 0.0, 400.0, 297.866,
|
|
Anchor::Center,
|
|
Anchor::Center
|
|
)
|
|
);
|
|
// If this is not set, the button will
|
|
// not receive events
|
|
sprite::disable_events("frame", true);
|
|
|
|
|
|
textbox::add(
|
|
"title", 10.0, 10.0,
|
|
Color(1.0, 1.0, 1.0, 1.0),
|
|
Rect(
|
|
-70.79, 138.0, 59.867, 10.0,
|
|
Anchor::Center,
|
|
Anchor::NorthWest
|
|
)
|
|
);
|
|
textbox::align_center("title");
|
|
textbox::font_serif("title");
|
|
textbox::weight_bold("title");
|
|
if state.player_ship().is_landed() {
|
|
textbox::set_text("title", state.player_ship().landed_on().display_name());
|
|
}
|
|
|
|
textbox::add(
|
|
"desc", 7.5, 8.0,
|
|
Color(1.0, 1.0, 1.0, 1.0),
|
|
Rect(
|
|
-178.92, -20.3, 343.0, 81.467,
|
|
Anchor::Center,
|
|
Anchor::NorthWest
|
|
)
|
|
);
|
|
textbox::font_sans("desc");
|
|
if state.player_ship().is_landed() {
|
|
textbox::set_text("desc", state.player_ship().landed_on().desc());
|
|
}
|
|
}
|
|
|
|
fn event(state, event) {
|
|
if type_of(event) == "MouseHoverEvent" {
|
|
let element = event.element();
|
|
if element == "button" {
|
|
if event.is_enter() {
|
|
sprite::jump_to("button", "on:top", 0.1);
|
|
} else {
|
|
sprite::jump_to("button", "off:top", 0.1);
|
|
}
|
|
}
|
|
return PlayerDirective::None;
|
|
}
|
|
|
|
|
|
if type_of(event) == "MouseClickEvent" {
|
|
if !event.is_down() {
|
|
return PlayerDirective::None;
|
|
}
|
|
|
|
let element = event.element();
|
|
if element == "button" {
|
|
ui::go_to_scene("outfitter");
|
|
return PlayerDirective::None;
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
if type_of(event) == "KeyboardEvent" {
|
|
if !event.is_down() {
|
|
return PlayerDirective::None;
|
|
}
|
|
|
|
if event.key() == "L" {
|
|
return PlayerDirective::UnLand;
|
|
}
|
|
|
|
if event.key() == "O" {
|
|
ui::go_to_scene("outfitter");
|
|
return PlayerDirective::None;
|
|
}
|
|
}
|
|
|
|
if type_of(event) == "PlayerShipStateEvent" {
|
|
if !state.player_ship().is_landed() {
|
|
ui::go_to_scene("flying");
|
|
return PlayerDirective::None;
|
|
}
|
|
return PlayerDirective::None;
|
|
}
|
|
} |