Added stats & purchase buttons
parent
de07e763c3
commit
7272f2a00a
|
@ -347,6 +347,9 @@ fn init(state) {
|
|||
|
||||
|
||||
fn event(state, event) {
|
||||
// TODO: update on ship outfit change only
|
||||
update_ship_info(state);
|
||||
|
||||
if type_of(event) == "MouseHoverEvent" {
|
||||
let element = event.element();
|
||||
|
||||
|
@ -394,6 +397,24 @@ fn event(state, event) {
|
|||
return PlayerDirective::None;
|
||||
}
|
||||
|
||||
if element == "buy_button" {
|
||||
if selected_outfit != false {
|
||||
let outfit = ct::get_outfit(selected_outfit);
|
||||
if outfit.is_some() {
|
||||
return PlayerDirective::BuyOutfit(outfit, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if element == "sell_button" {
|
||||
if selected_outfit != false {
|
||||
let outfit = ct::get_outfit(selected_outfit);
|
||||
if outfit.is_some() {
|
||||
return PlayerDirective::SellOutfit(outfit, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
element.starts_with("outfit.backg.") &&
|
||||
event.element().split("outfit.backg.".len())[1] != selected_outfit
|
||||
|
@ -475,6 +496,41 @@ fn update_outfit_info(selected_outfit) {
|
|||
|
||||
let stats = "";
|
||||
let tlen = 20;
|
||||
|
||||
|
||||
{
|
||||
let s = "cost ";
|
||||
s.pad(tlen, " ");
|
||||
stats += s + outfit.cost();
|
||||
stats += "\n";
|
||||
}
|
||||
|
||||
{
|
||||
let s = "needs gun port ";
|
||||
s.pad(tlen, " ");
|
||||
if outfit.stat_is_gun() {
|
||||
stats += s + "yes";
|
||||
} else {
|
||||
stats += s + "no"
|
||||
}
|
||||
stats += "\n";
|
||||
}
|
||||
|
||||
{
|
||||
let s = outfit.required_space();
|
||||
for k in s.keys() {
|
||||
let v = s[k];
|
||||
let s = k + " space needed ";
|
||||
s.pad(tlen, " ");
|
||||
if v != 0 {
|
||||
stats += s + v;
|
||||
stats += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stats += "\n";
|
||||
|
||||
if outfit.stat_thrust() != 0 {
|
||||
let s = "thrust ";
|
||||
s.pad(tlen, " ");
|
||||
|
@ -527,8 +583,28 @@ fn update_ship_info(state) {
|
|||
let tlen = 20;
|
||||
|
||||
|
||||
{
|
||||
let u = ship.used_space();
|
||||
let t = ship.total_space();
|
||||
for k in u.keys() {
|
||||
let vu = u[k];
|
||||
let vt = t[k];
|
||||
let s = k + " space ";
|
||||
s.pad(tlen, " ");
|
||||
stats += s + (vt - vu) + "/" + vt;
|
||||
stats += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let s = "gun points ";
|
||||
s.pad(tlen, " ");
|
||||
stats += s + ship.free_gun_points() + "/" + ship.total_gun_points();
|
||||
stats += "\n\n";
|
||||
}
|
||||
|
||||
// TODO: outfits add mass
|
||||
// TODO: calculate radial acceleration
|
||||
// TODO: calculate acceleration
|
||||
{
|
||||
let s = "shield strength ";
|
||||
s.pad(tlen, " ");
|
||||
|
|
Loading…
Reference in New Issue