121 lines
2.1 KiB
Plaintext
121 lines
2.1 KiB
Plaintext
fn config() {
|
|
let config = SceneConfig();
|
|
config.show_starfield(true);
|
|
config.show_phys(false);
|
|
return config
|
|
}
|
|
|
|
fn init(state) {
|
|
let player = state.player_ship();
|
|
|
|
let frame = SpriteBuilder(
|
|
"frame",
|
|
"ui::planet",
|
|
Rect(
|
|
0.0, 0.0, 400.0, 297.866,
|
|
SpriteAnchor::Center,
|
|
SpriteAnchor::Center
|
|
)
|
|
);
|
|
|
|
let landscape = SpriteBuilder(
|
|
"landscape",
|
|
{
|
|
if player.is_landed() {
|
|
player.landed_on().image();
|
|
} else {
|
|
"";
|
|
}
|
|
},
|
|
Rect(
|
|
-180.0, 142.0, 274.0, 135.0,
|
|
SpriteAnchor::NorthWest,
|
|
SpriteAnchor::Center
|
|
)
|
|
);
|
|
landscape.set_mask("ui::landscapemask");
|
|
|
|
let button = SpriteBuilder(
|
|
"button",
|
|
"ui::planet::button",
|
|
Rect(
|
|
99.0, 128.0, 73.898, 18.708,
|
|
SpriteAnchor::NorthWest,
|
|
SpriteAnchor::Center
|
|
)
|
|
);
|
|
|
|
let title = TextBoxBuilder(
|
|
"title",
|
|
10.0, 10.0, TextBoxFont::Serif, TextBoxJustify::Center,
|
|
Rect(
|
|
-70.79, 138.0, 59.867, 10.0,
|
|
SpriteAnchor::NorthWest,
|
|
SpriteAnchor::Center
|
|
),
|
|
Color(1.0, 1.0, 1.0, 1.0)
|
|
);
|
|
if player.is_landed() {
|
|
title.set_text(player.landed_on().name());
|
|
} else {
|
|
title.set_text("");
|
|
}
|
|
|
|
let desc = TextBoxBuilder(
|
|
"desc",
|
|
7.5, 8.0, TextBoxFont::SansSerif, TextBoxJustify::Left,
|
|
Rect(
|
|
-178.92, -20.3, 343.0, 81.467,
|
|
SpriteAnchor::NorthWest,
|
|
SpriteAnchor::Center
|
|
),
|
|
Color(1.0, 1.0, 1.0, 1.0)
|
|
);
|
|
if player.is_landed() {
|
|
desc.set_text(player.landed_on().desc());
|
|
} else {
|
|
desc.set_text("");
|
|
}
|
|
|
|
return [
|
|
button,
|
|
landscape,
|
|
frame,
|
|
title,
|
|
desc,
|
|
];
|
|
}
|
|
|
|
fn event(state, event) {
|
|
if type_of(event) == "MouseHoverEvent" {
|
|
let element = event.element();
|
|
if element.has_name("button") {
|
|
if event.is_enter() {
|
|
element.take_edge("on:top", 0.1);
|
|
} else {
|
|
element.take_edge("off:top", 0.1);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
if type_of(event) == "MouseClickEvent" {
|
|
if !event.is_down() {
|
|
return SceneAction::None;
|
|
}
|
|
|
|
let element = event.element();
|
|
if element.has_name("button") {
|
|
return SceneAction::GoTo("outfitter");
|
|
}
|
|
return;
|
|
}
|
|
|
|
if type_of(event) == "PlayerShipStateEvent" {
|
|
if !state.player_ship().is_landed() {
|
|
return SceneAction::GoTo("flying");
|
|
}
|
|
return;
|
|
}
|
|
} |