From 2eef87c8970db643c4ef09e0fd9e8110c8193043 Mon Sep 17 00:00:00 2001 From: jacopo grandi Date: Sat, 20 Feb 2021 00:11:23 +0100 Subject: finish condition and bad cost function --- hud/hud.c | 29 +++++++++++++++++++++++------ hud/hud_views.c | 6 ++++++ 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'hud') diff --git a/hud/hud.c b/hud/hud.c index 2c73288..7906c84 100644 --- a/hud/hud.c +++ b/hud/hud.c @@ -314,6 +314,19 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, } } +void hud_process_overlay_battle (graphic_settings *gs, hud *h, MKb *mkb, + infos *info, army *ar, map *m, txtd *t, gamestate *gst, + Mix_Chunk *sounds[]) +{ + if (gst->over == 1) { + h->state = 0; + gst->state = 0; + gst->cam[0] = -gs->resx/2+gst->map_editor.sx*gst->map_editor.ts/2; + gst->cam[1] = -gs->resy/2+gst->map_editor.sy*gst->map_editor.ts/2; + gst_toeditor(gst); + } +} + void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, infos *info, army *ar, map *m, txtd *t, gamestate *gst, net_client *netc, net_server *nets, Mix_Chunk *sounds[]) @@ -339,7 +352,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, gst_tobattle(gst); gst->cam[0] = -gs->resx/2+gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2+gst->map_battle.sy*gst->map_battle.ts/2; - h->state = 4; + h->state = 3; } } } @@ -355,7 +368,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, gst_tobattle(gst); gst->cam[0] = -gs->resx/2+gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2+gst->map_battle.sy*gst->map_battle.ts/2; - h->state = 4; + h->state = 3; } } @@ -380,7 +393,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, gst->cam[0] = -gs->resx/2+gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2+gst->map_battle.sy*gst->map_battle.ts/2; h->og.battle_state = 3; - h->state = 4; + h->state = 3; Mix_PlayChannel( -1, sounds[SOUND_SUCCESS], 0 ); } @@ -522,9 +535,13 @@ void hud_process (graphic_settings *gs, hud *h, MKb *mkb, hud_process_overlay_game(gs, h, mkb, info, ar, m, t, gst, netc, nets, sounds); break; - case 1: hud_process_form_new_unit(gs, h, mkb, info, ar, m, t, - sounds); break; - case 2: hud_process_sel(gs, h, mkb, info, ar, m, t, sounds); break; + case 1: hud_process_form_new_unit(gs, h, mkb, info, ar, m, t, sounds); + break; + case 2: hud_process_sel(gs, h, mkb, info, ar, m, t, sounds); + break; + case 3: hud_process_overlay_battle(gs, h, mkb, info, ar, m, t, gst, + sounds); + break; } } diff --git a/hud/hud_views.c b/hud/hud_views.c index 4828275..046ba53 100644 --- a/hud/hud_views.c +++ b/hud/hud_views.c @@ -14,6 +14,12 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py, render_text_scaled(rend, sname, pname, t, 2); h += 35; + float cost = info_unit_get_cost(info, tm); + float pcost[2] = { px+10, py+h }; + char scost[64]; sprintf(scost, "COST: %.2f", cost); + render_text_scaled(rend, scost, pcost, t, 1); + h += 20; + float calcweight = info_unit_get_weight(info, tm); float maxweight = info->chassis[tm->chassis].weight_max[ tm->levels[LEVEL_CHASSIS]]; -- cgit v1.2.3-54-g00ecf