2024-02-02 16:45:23 -08:00
|
|
|
fn init(state) {
|
2024-02-05 10:12:15 -08:00
|
|
|
conf::show_starfield(true);
|
|
|
|
conf::show_phys(false);
|
2024-02-04 11:45:49 -08:00
|
|
|
|
2024-02-05 10:12:15 -08:00
|
|
|
sprite::add(
|
2024-02-04 11:45:49 -08:00
|
|
|
"button",
|
|
|
|
"ui::planet::button",
|
2024-02-02 16:45:23 -08:00
|
|
|
Rect(
|
2024-02-04 11:45:49 -08:00
|
|
|
99.0, 128.0, 73.898, 18.708,
|
2024-02-16 13:29:19 -08:00
|
|
|
Anchor::Center,
|
|
|
|
Anchor::NorthWest
|
2024-02-02 16:45:23 -08:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-05 10:12:15 -08:00
|
|
|
sprite::add(
|
2024-02-02 16:45:23 -08:00
|
|
|
"landscape",
|
2024-02-03 16:06:11 -08:00
|
|
|
{
|
2024-02-08 20:41:04 -08:00
|
|
|
if state.player_ship().is_landed() {
|
|
|
|
state.player_ship().landed_on().image();
|
2024-02-03 16:06:11 -08:00
|
|
|
} else {
|
|
|
|
"";
|
|
|
|
}
|
|
|
|
},
|
2024-02-02 16:45:23 -08:00
|
|
|
Rect(
|
|
|
|
-180.0, 142.0, 274.0, 135.0,
|
2024-02-16 13:29:19 -08:00
|
|
|
Anchor::Center,
|
|
|
|
Anchor::NorthWest
|
2024-02-02 16:45:23 -08:00
|
|
|
)
|
|
|
|
);
|
2024-02-05 10:12:15 -08:00
|
|
|
sprite::set_mask("landscape", "ui::landscapemask");
|
2024-02-02 16:45:23 -08:00
|
|
|
|
2024-02-05 10:12:15 -08:00
|
|
|
sprite::add(
|
2024-02-04 11:45:49 -08:00
|
|
|
"frame",
|
|
|
|
"ui::planet",
|
2024-02-02 16:45:23 -08:00
|
|
|
Rect(
|
2024-02-04 11:45:49 -08:00
|
|
|
0.0, 0.0, 400.0, 297.866,
|
|
|
|
Anchor::Center,
|
|
|
|
Anchor::Center
|
2024-02-02 16:45:23 -08:00
|
|
|
)
|
|
|
|
);
|
2024-02-08 20:41:04 -08:00
|
|
|
// If this is not set, the button will
|
|
|
|
// not receive events
|
2024-02-16 13:29:19 -08:00
|
|
|
sprite::disable_events("frame", true);
|
2024-02-04 11:45:49 -08:00
|
|
|
|
|
|
|
|
2024-02-05 10:12:15 -08:00
|
|
|
textbox::add(
|
2024-02-03 16:45:47 -08:00
|
|
|
"title", 10.0, 10.0,
|
2024-02-16 13:29:19 -08:00
|
|
|
Color(1.0, 1.0, 1.0, 1.0),
|
2024-02-02 16:45:23 -08:00
|
|
|
Rect(
|
|
|
|
-70.79, 138.0, 59.867, 10.0,
|
2024-02-16 13:29:19 -08:00
|
|
|
Anchor::Center,
|
|
|
|
Anchor::NorthWest
|
|
|
|
)
|
2024-02-02 16:45:23 -08:00
|
|
|
);
|
2024-02-05 10:12:15 -08:00
|
|
|
textbox::align_center("title");
|
|
|
|
textbox::font_serif("title");
|
|
|
|
textbox::weight_bold("title");
|
2024-02-08 20:41:04 -08:00
|
|
|
if state.player_ship().is_landed() {
|
|
|
|
textbox::set_text("title", state.player_ship().landed_on().display_name());
|
2024-02-03 16:06:11 -08:00
|
|
|
}
|
|
|
|
|
2024-02-05 10:12:15 -08:00
|
|
|
textbox::add(
|
2024-02-03 16:45:47 -08:00
|
|
|
"desc", 7.5, 8.0,
|
2024-02-16 13:29:19 -08:00
|
|
|
Color(1.0, 1.0, 1.0, 1.0),
|
2024-02-03 16:06:11 -08:00
|
|
|
Rect(
|
|
|
|
-178.92, -20.3, 343.0, 81.467,
|
2024-02-16 13:29:19 -08:00
|
|
|
Anchor::Center,
|
|
|
|
Anchor::NorthWest
|
|
|
|
)
|
2024-02-03 16:06:11 -08:00
|
|
|
);
|
2024-02-05 10:12:15 -08:00
|
|
|
textbox::font_sans("desc");
|
2024-02-08 20:41:04 -08:00
|
|
|
if state.player_ship().is_landed() {
|
|
|
|
textbox::set_text("desc", state.player_ship().landed_on().desc());
|
2024-02-03 16:06:11 -08:00
|
|
|
}
|
2024-02-02 16:45:23 -08:00
|
|
|
}
|
|
|
|
|
2024-02-03 11:24:17 -08:00
|
|
|
fn event(state, event) {
|
|
|
|
if type_of(event) == "MouseHoverEvent" {
|
|
|
|
let element = event.element();
|
2024-02-04 11:45:49 -08:00
|
|
|
if element == "button" {
|
2024-02-03 11:24:17 -08:00
|
|
|
if event.is_enter() {
|
2024-02-07 15:58:48 -08:00
|
|
|
sprite::jump_to("button", "on:top", 0.1);
|
2024-02-03 11:24:17 -08:00
|
|
|
} else {
|
2024-02-07 15:58:48 -08:00
|
|
|
sprite::jump_to("button", "off:top", 0.1);
|
2024-02-03 11:24:17 -08:00
|
|
|
}
|
2024-02-02 16:45:23 -08:00
|
|
|
}
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-02 16:45:23 -08:00
|
|
|
}
|
2024-02-03 11:24:17 -08:00
|
|
|
|
|
|
|
|
|
|
|
if type_of(event) == "MouseClickEvent" {
|
|
|
|
if !event.is_down() {
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-03 11:24:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
let element = event.element();
|
2024-02-04 11:45:49 -08:00
|
|
|
if element == "button" {
|
2024-02-05 10:12:15 -08:00
|
|
|
ui::go_to_scene("outfitter");
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-03 11:24:17 -08:00
|
|
|
}
|
|
|
|
return;
|
2024-02-02 22:19:06 -08:00
|
|
|
}
|
|
|
|
|
2024-02-07 15:58:48 -08:00
|
|
|
|
|
|
|
if type_of(event) == "KeyboardEvent" {
|
|
|
|
if !event.is_down() {
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-07 15:58:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if event.key() == "L" {
|
|
|
|
return PlayerDirective::UnLand;
|
|
|
|
}
|
|
|
|
|
|
|
|
if event.key() == "O" {
|
|
|
|
ui::go_to_scene("outfitter");
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-07 15:58:48 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-03 11:24:17 -08:00
|
|
|
if type_of(event) == "PlayerShipStateEvent" {
|
|
|
|
if !state.player_ship().is_landed() {
|
2024-02-05 10:12:15 -08:00
|
|
|
ui::go_to_scene("flying");
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-03 11:24:17 -08:00
|
|
|
}
|
2024-02-08 20:41:04 -08:00
|
|
|
return PlayerDirective::None;
|
2024-02-02 22:19:06 -08:00
|
|
|
}
|
|
|
|
}
|