aboutsummaryrefslogtreecommitdiff
path: root/hud
diff options
context:
space:
mode:
Diffstat (limited to 'hud')
-rw-r--r--hud/hud.c27
-rw-r--r--hud/hud_views.c8
2 files changed, 28 insertions, 7 deletions
diff --git a/hud/hud.c b/hud/hud.c
index f2eb361..dfb4f24 100644
--- a/hud/hud.c
+++ b/hud/hud.c
@@ -44,7 +44,7 @@ void init_form_new_unit (graphic_settings *gs, form_new_unit *fnu, txtd *t) {
SDL_Rect_init(&fnu->rect_chassis, x+20, y+20+145+10+30, 300, 300);
SDL_Rect_init(&fnu->rect_brain, x+20, y+20+30, 145, 145);
- SDL_Rect_init(&fnu->rect_battery, 0+25, y+20+30, 145, 145);
+ SDL_Rect_init(&fnu->rect_battery, x+150+25, y+20+30, 145, 145);
for (int i=0; i<8; i++) {
SDL_Rect_init(&fnu->rect_weapons[i],
x+20+300+10+30, y+20+120*i +30, 200, 110);
@@ -376,7 +376,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb,
}
}
}
- for (int i=0; i<comp->base[lc].slot_armor; i++) {
+ for (int i=0; i<comp->base[lc].slot_aug; i++) {
float possa[2] = {
h->fnu.rect_augs[i].x, h->fnu.rect_augs[i].y };
float sizesa[2] = {
@@ -655,7 +655,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb,
float wjoin = get_text_width("join game", t);
float pn[2] = { h->og.join_game.pos[0]+wjoin + 4*2+10,
h->og.join_game.pos[1]+4 };
- char sn[64]; sprintf(sn, "IP: %s", h->og.playername);
+ char sn[64]; sprintf(sn, "IP: %s", h->og.ip);
float sizen[2] = { get_text_width(sn, t), 10 };
if (pt_rect(mousepos, pn, sizen)) {
h->nameedit = h->og.ip;
@@ -996,7 +996,12 @@ void hud_render_overlay_game (overlay_game *og, MKb *mkb,
float cost = 0;
for (int i=0; i<gst->army_bp[0].uslen; i++) {
- cost += 10;
+ if (gst->army_bp[0].us[i].info.chassis != -1
+ && gst->army_bp[0].us[i].owner == 0) {
+ stats_unit base;
+ stats_unit_compute(info, &gst->army_bp[0].us[i].info, &base);
+ cost += stats_compute_cost(&info->cost_weights, &base);
+ }
}
float cx = og->rect_army.x+5;
float cy = og->rect_army.y+5 + 30;
@@ -1111,7 +1116,12 @@ void hud_render_overlay_battle (overlay_battle *ob, MKb *mkb,
{
float cost = 0;
for (int i=0; i<gst->army_bp[0].uslen; i++) {
- cost += 10;
+ if (gst->army_bp[0].us[i].info.chassis != -1
+ && gst->army_bp[0].us[i].owner == 0) {
+ stats_unit base;
+ stats_unit_compute(info, &gst->army_bp[0].us[i].info, &base);
+ cost += stats_compute_cost(&info->cost_weights, &base);
+ }
}
float p[2] = { x+10, y+h };
char s[64]; sprintf(s, "COST: %.0f", cost);
@@ -1119,7 +1129,12 @@ void hud_render_overlay_battle (overlay_battle *ob, MKb *mkb,
float cost2 = 0;
for (int i=0; i<gst->army_bp[1].uslen; i++) {
- cost2 += 10;
+ if (gst->army_bp[0].us[i].info.chassis != -1
+ && gst->army_bp[0].us[i].owner == 1) {
+ stats_unit base;
+ stats_unit_compute(info, &gst->army_bp[0].us[i].info, &base);
+ cost += stats_compute_cost(&info->cost_weights, &base);
+ }
}
char p2[64]; sprintf(p2, "COST: %.0f", cost2);
float p2w = get_text_width(p2, t);
diff --git a/hud/hud_views.c b/hud/hud_views.c
index b2192b3..385501e 100644
--- a/hud/hud_views.c
+++ b/hud/hud_views.c
@@ -72,6 +72,10 @@ void render_view_stats_unit (SDL_Renderer* rend, txtd *t, int px, int py,
int n = stats_weapon_sprintf(info, u->weapon +i, arr);
for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; }
}
+ h += 5;
+ float cost = stats_compute_cost(&info->cost_weights, u);
+ char s[64]; sprintf(s, "COST: %.2f", cost);
+ LABEL(px+pad, py+h, s, 1); h += 15;
}
@@ -84,7 +88,9 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py,
stats_unit base;
stats_unit_compute(info, tm, &base);
- render_view_stats_unit(rend, t, px+10, py+h, info, &base);
+ if (tm->chassis != -1) {
+ render_view_stats_unit(rend, t, px+10, py+h, info, &base);
+ }
}