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-04 11:45:49 -08:00
conf_set_starfield(true);
conf_set_phys(false);
add_sprite(
"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-04 11:45:49 -08:00
add_sprite(
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-04 11:45:49 -08:00
sprite_set_mask("landscape", "ui::landscapemask");
2024-02-02 16:45:23 -08:00
2024-02-04 11:45:49 -08:00
add_sprite(
"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
add_textbox(
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-04 11:45:49 -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-04 11:45:49 -08:00
textbox_set_text("title", player.landed_on().name());
2024-02-03 16:06:11 -08:00
}
2024-02-04 11:45:49 -08:00
add_textbox(
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-04 11:45:49 -08:00
textbox_font_sans("desc");
2024-02-03 16:06:11 -08:00
if player.is_landed() {
2024-02-04 11:45:49 -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-04 11:45:49 -08:00
sprite_take_edge("button", "on:top", 0.1);
2024-02-03 11:24:17 -08:00
} else {
2024-02-04 11:45:49 -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" {
go_to_scene("outfitter");
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-04 11:45:49 -08:00
go_to_scene("flying");
return;
2024-02-03 11:24:17 -08:00
}
return;
2024-02-02 22:19:06 -08:00
}
}