Galactica/content/ui/landed.rhai

110 lines
1.8 KiB
Plaintext
Raw Normal View History

2024-02-02 16:45:23 -08:00
fn init(state) {
2024-02-03 16:06:11 -08:00
let player = state.player_ship();
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,
Anchor::NorthWest,
Anchor::Center
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
{
if player.is_landed() {
player.landed_on().image();
} else {
"";
}
},
2024-02-02 16:45:23 -08:00
Rect(
-180.0, 142.0, 274.0, 135.0,
2024-02-04 11:45:49 -08:00
Anchor::NorthWest,
Anchor::Center
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-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-02 16:45:23 -08:00
Rect(
-70.79, 138.0, 59.867, 10.0,
2024-02-04 11:45:49 -08:00
Anchor::NorthWest,
Anchor::Center
2024-02-03 16:21:21 -08:00
),
Color(1.0, 1.0, 1.0, 1.0)
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-03 16:06:11 -08:00
if player.is_landed() {
2024-02-05 10:12:15 -08:00
textbox::set_text("title", player.landed_on().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-03 16:06:11 -08:00
Rect(
-178.92, -20.3, 343.0, 81.467,
2024-02-04 11:45:49 -08:00
Anchor::NorthWest,
Anchor::Center
2024-02-03 16:21:21 -08:00
),
Color(1.0, 1.0, 1.0, 1.0)
2024-02-03 16:06:11 -08:00
);
2024-02-05 10:12:15 -08:00
textbox::font_sans("desc");
2024-02-03 16:06:11 -08:00
if player.is_landed() {
2024-02-05 10:12:15 -08:00
textbox::set_text("desc", player.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-05 10:12:15 -08:00
sprite::take_edge("button", "on:top", 0.1);
2024-02-03 11:24:17 -08:00
} else {
2024-02-05 10:12:15 -08:00
sprite::take_edge("button", "off:top", 0.1);
2024-02-03 11:24:17 -08:00
}
2024-02-02 16:45:23 -08:00
}
2024-02-03 11:24:17 -08:00
return;
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-04 11:45:49 -08:00
return;
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-04 11:45:49 -08:00
return;
2024-02-03 11:24:17 -08:00
}
return;
2024-02-02 22:19:06 -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-04 11:45:49 -08:00
return;
2024-02-03 11:24:17 -08:00
}
return;
2024-02-02 22:19:06 -08:00
}
}