Galactica/content/ui/landed.rhai

110 lines
1.8 KiB
Plaintext

fn init(state) {
let player = state.player_ship();
conf_set_starfield(true);
conf_set_phys(false);
add_sprite(
"button",
"ui::planet::button",
Rect(
99.0, 128.0, 73.898, 18.708,
Anchor::NorthWest,
Anchor::Center
)
);
add_sprite(
"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");
add_sprite(
"frame",
"ui::planet",
Rect(
0.0, 0.0, 400.0, 297.866,
Anchor::Center,
Anchor::Center
)
);
add_textbox(
"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());
}
add_textbox(
"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" {
go_to_scene("outfitter");
return;
}
return;
}
if type_of(event) == "PlayerShipStateEvent" {
if !state.player_ship().is_landed() {
go_to_scene("flying");
return;
}
return;
}
}