diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-25 16:29:19 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-25 16:29:19 +0100 |
commit | e8bc1eab9a45b8893701e3acbd008fe259c53a4c (patch) | |
tree | eac29a2ee78245122b48dd8ec4fdfd6581d97f98 /hud | |
parent | 83c2ceb9cbe890ec50399b6e4908218477a3088f (diff) |
before was messy, now is MACRO(MACRO(MACRO(MACRO(clean))))
Diffstat (limited to 'hud')
-rw-r--r-- | hud/hud.c | 83 | ||||
-rw-r--r-- | hud/hud_views.c | 282 |
2 files changed, 120 insertions, 245 deletions
@@ -144,45 +144,41 @@ int hud_fnu_check (info_unit *u, infos *info) { if (u->chassis == -1) return 1; if (u->battery == -1) return 2; if (u->brain == -1) return 3; - float curweight = info_unit_get_weight(info, u); int chassis_lvl = u->levels[LEVEL_CHASSIS]; - float maxweight = info->chassis[u->chassis].weight_max[chassis_lvl]; - if (curweight > maxweight) { return 4; } + + stats_unit base; + stats_unit_compute(info, u, &base); + if (base.frame.weight > base.frame.weight_max) { return 4; } return 0; } void hud_map_sel (info_unit *u, infos *info, int sel, int ind, int8_t **n, int *bound, int size[]) { + *bound = info->statslen[sel]; if (sel == 0) { *n = &u->chassis; - *bound = info->chassislen; size[0] = 300; size[1] = 300; } if (sel == 1) { - *n = &u->battery; - *bound = info->batterieslen; + *n = &u->brain; size[0] = 145; size[1] = 145; } if (sel == 2) { - *n = &u->armor[ind]; - *bound = info->armorslen; - size[0] = 150; size[1] = 200; + *n = &u->battery; + size[0] = 145; size[1] = 145; } if (sel == 3) { *n = &u->weapons[ind]; - *bound = info->weaponslen; size[0] = 200; size[1] = 170; } if (sel == 4) { - *n = &u->augs[ind]; - *bound = info->augslen; + *n = &u->armor[ind]; size[0] = 150; size[1] = 200; } if (sel == 5) { - *n = &u->brain; - *bound = info->brainslen; - size[0] = 145; size[1] = 145; + *n = &u->augs[ind]; + size[0] = 150; size[1] = 200; } } @@ -324,7 +320,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possb, sizesb); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_BATTERY] = lvl; else { - h->fnu.sel = 1; h->state = 2; + h->fnu.sel = 2; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_battery); } } @@ -334,15 +330,16 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possbr, sizesbr); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_BRAIN] = lvl; else { - h->fnu.sel = 5; h->state = 2; + h->fnu.sel = 1; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_brain); } } if (h->fnu.uinfo.chassis != -1) { int lc = h->fnu.uinfo.levels[LEVEL_CHASSIS]; - for (int i=0; - i<info->chassis[h->fnu.uinfo.chassis].slot_armor[lc]; i++) - { + stats_comp *comp = + info->stats[STATS_CHASSIS] +h->fnu.uinfo.chassis; + + for (int i=0; i<comp->base[lc].slot_armor; i++) { float possa[2] = { h->fnu.rect_armor[i].x, h->fnu.rect_armor[i].y }; float sizesa[2] = { @@ -351,14 +348,12 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possa, sizesa); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_ARMOR+i] = lvl; else { - h->fnu.sel = 2; h->fnu.ind = i; h->state = 2; + h->fnu.sel = 4; h->fnu.ind = i; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_armor[i]); } } } - for (int i=0; - i<info->chassis[h->fnu.uinfo.chassis].slot_weapon[lc]; i++) - { + for (int i=0; i<comp->base[lc].slot_weapon; i++) { float possa[2] = { h->fnu.rect_weapons[i].x, h->fnu.rect_weapons[i].y }; float sizesa[2] = { @@ -372,9 +367,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, } } } - for (int i=0; - i<info->chassis[h->fnu.uinfo.chassis].slot_aug[lc]; i++) - { + for (int i=0; i<comp->base[lc].slot_armor; i++) { float possa[2] = { h->fnu.rect_augs[i].x, h->fnu.rect_augs[i].y }; float sizesa[2] = { @@ -383,7 +376,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possa, sizesa); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_AUGS+i] = lvl; else { - h->fnu.sel = 4; h->fnu.ind = i; h->state = 2; + h->fnu.sel = 5; h->fnu.ind = i; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_augs[i]); } } @@ -437,7 +430,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, memcpy(h->ob.oppo, buffer+arlen, 32); memcpy(gst->army_bp[1].name, buffer+arlen+32, 32); gst->playernum = 2; - gst_tobattle(gst); + gst_tobattle(gst, info); 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 = 3; @@ -458,7 +451,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, memcpy(h->ob.oppo, buffer+arlen, 32); memcpy(gst->army_bp[1].name, buffer+arlen+32, 32); gst->playernum = 2; - gst_tobattle(gst); + gst_tobattle(gst, info); 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 = 3; @@ -560,6 +553,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, unit u; unit_init(info, ar, m, x, y, info->templates+h->og.temp_place, 0, &u); + army_spawn(ar, m, u); } } else { @@ -605,12 +599,11 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, if (pt_rect(mousepos, posp, sizep)) { if (h->og.start_battle_flag == 1) { // start battle - printf("ahia\n"); h->og.start_battle_flag = 0; hud_edit_close(h, info); info_load_army(gst->army_bp+1, h->og.army_list[i]); gst->playernum = 2; - gst_tobattle(gst); + gst_tobattle(gst, info); gst->cam[0] = -gs->resx/2 +gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2 @@ -619,7 +612,6 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, h->state = 3; Mix_PlayChannel( -1, sounds[SOUND_SUCCESS], 0 ); } else { - printf("lol\n"); int cur = h->og.army_listcur; info_save_army(gst->army_bp+0, h->og.army_list[cur]); h->og.army_listcur = i; @@ -783,24 +775,24 @@ void hud_render_sel (hud_sel *sc, MKb *mkb, info_unit *u, render_view_chassis(rend, t, x, y, info, i, lvl, sprites); } if (sel==1) { - int lvl = u->levels[LEVEL_BATTERY]; - render_view_battery(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_BRAIN]; + render_view_brain(rend, t, x, y, info, i, lvl); } if (sel==2) { - int lvl = u->levels[LEVEL_ARMOR+ind]; - render_view_armor_detail(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_BATTERY]; + render_view_battery(rend, t, x, y, info, i, lvl); } if (sel==3) { int lvl = u->levels[LEVEL_WEAPONS+ind]; render_view_weapon_detail(rend, t, x, y, info, i, lvl); } if (sel==4) { - int lvl = u->levels[LEVEL_AUGS+ind]; - render_view_aug_detail(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_ARMOR+ind]; + render_view_armor_detail(rend, t, x, y, info, i, lvl); } if (sel==5) { - int lvl = u->levels[LEVEL_BRAIN]; - render_view_brain(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_AUGS+ind]; + render_view_aug_detail(rend, t, x, y, info, i, lvl); } } SDL_RenderSetClipRect(rend, NULL); @@ -832,7 +824,10 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, int lc = fnu->uinfo.levels[LEVEL_CHASSIS]; if (fnu->uinfo.chassis != -1) { - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_weapon[lc]; i++) { + stats_comp *comp = + info->stats[STATS_CHASSIS] +fnu->uinfo.chassis; + + for (int i=0; i<comp->base[lc].slot_weapon; i++) { SDL_SetRenderDrawColor(rend, 200, 100, 255, 255); SDL_RenderFillRect(rend, fnu->rect_weapons+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); @@ -842,7 +837,7 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, fnu->rect_weapons[i].y, info, fnu->uinfo.weapons[i], fnu->uinfo.levels[LEVEL_WEAPONS+i]); } - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_armor[lc]; i++) { + for (int i=0; i<comp->base[lc].slot_armor; i++) { SDL_SetRenderDrawColor(rend, 200, 200, 255, 255); SDL_RenderFillRect(rend, fnu->rect_armor+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); @@ -852,7 +847,7 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, fnu->rect_armor[i].y, info, fnu->uinfo.armor[i], fnu->uinfo.levels[LEVEL_ARMOR+i]); } - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_aug[lc]; i++) { + for (int i=0; i<comp->base[lc].slot_aug; i++) { SDL_SetRenderDrawColor(rend, 200, 200, 255, 255); SDL_RenderFillRect(rend, fnu->rect_augs+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); diff --git a/hud/hud_views.c b/hud/hud_views.c index c767e68..a669034 100644 --- a/hud/hud_views.c +++ b/hud/hud_views.c @@ -29,56 +29,62 @@ render_text_scaled(rend, ss, p, t, 1);\ } + +void render_view_comp (SDL_Renderer* rend, txtd *t, int px, int py, + infos *info, stats_comp *comp, int lvl) +{ + float pad = 0; + float h = 0; + + char arr[32][64]; + { + int n = stats_frame_sprintf(info, comp->base +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + { + int n = stats_frame_sprintf(info, comp->perc +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + { + int n = stats_weapon_sprintf(info, comp->base_weapon +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + { + int n = stats_weapon_sprintf(info, comp->perc_weapon +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } +} + +void render_view_stats_unit (SDL_Renderer* rend, txtd *t, int px, int py, + infos *info, stats_unit *u) +{ + float pad = 0; + float h = 0; + + char arr[32][64]; + { + int n = stats_frame_sprintf(info, &u->frame, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + h += 10; + for (int i=0; i<u->weaponlen; i++) { + LABEL(px+pad, py+h, " WEAPON", 1); h += 15; + 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; } + } +} + + void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py, infos *info, info_unit *tm) { float h = 10; LABEL(px+10, py+h, "STATS", 2); h += 35; + LABEL(px+10, py+h, tm->name, 1); h += 15; - { float val = info_unit_get_cost(info, tm); - char s[64]; sprintf(s, "COST: %.2f", val); - LABEL(px+10, py+h, s, 1); - } h += 20; - - float calcweight = info_unit_get_weight(info, tm); - float maxweight = info->chassis[tm->chassis].weight_max[ - tm->levels[LEVEL_CHASSIS]]; - float pw[2] = { px+10, py+h }; - char sw[64]; sprintf(sw, "WEIGHT: %.0f/%.0f", - calcweight, maxweight); - render_text_scaled(rend, sw, pw, t, 1); - h += 15; - - float hp = info_unit_get_health(info, tm); - float php[2] = { px+10, py+h }; - char shp[64]; sprintf(shp, "HP: %.2f", hp); - render_text_scaled(rend, shp, php, t, 1); - h += 15; - - float speed = info_unit_get_speed(info, tm); - float pspeed[2] = { px+10, py+h }; - char sspeed[64]; sprintf(sspeed, "SPEED: %.2f", speed); - render_text_scaled(rend, sspeed, pspeed, t, 1); - h += 15; - - float dps = info_unit_get_dps(info, tm); - float pdps[2] = { px+10, py+h }; - char sdps[64]; sprintf(sdps, "DAMAGE PER TURN: %.2f", dps); - render_text_scaled(rend, sdps, pdps, t, 1); - h += 20; - - float part[2] = { px+10, py+h }; - render_text_scaled(rend, "ARMOR:", part, t, 1); - h += 15; - - for (int i=0; i<7; i++) { - float ar = info_unit_get_armor(info, tm, i); - float par[2] = { px+10, py+h }; - char sar[64]; sprintf(sar, "%s: %.1f%", info->damage_types[i], ar); - render_text_scaled(rend, sar, par, t, 1); - h += 15; - } - h += 5; + stats_unit base; + stats_unit_compute(info, tm, &base); + render_view_stats_unit(rend, t, px+10, py+h, info, &base); } @@ -112,21 +118,10 @@ void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py, info_chassis *ch = info->chassis+chassis; int h = 10; - LABEL(px+10, py+h, info->chassis[chassis].name, 1); h += 30; - - LABEL_F3(px+10, py+h, "MAX WEIGHT", 0, ch->weight_max, 1); h += 15; - LABEL_F3(px+10, py+h, "HP", 0, ch->hp, 1); h += 15; - LABEL_F3(px+10, py+h, "SPEED", 2, ch->speed, 1); h += 15; - LABEL_F3(px+10, py+h, "UPKEEP", 2, ch->upkeep, 1); h += 20; - - LABEL_I3(px+10, py+h, "WEAPON SLOTS", ch->slot_weapon, 1); h += 15; - LABEL_I3(px+10, py+h, "ARMOR SLOTS", ch->slot_armor, 1); h += 15; - LABEL_I3(px+10, py+h, "AUGMENT SLOTS", ch->slot_aug, 1); h += 15; - - SDL_Rect srcRect = { chassis*32, 32, 32, 32 }; - SDL_Rect dstRect = { px+300-32-10, py+10, 32, 32 }; - SDL_RenderCopy(rend, sprites, &srcRect, &dstRect); - + stats_comp *comp = info->stats[STATS_CHASSIS]+chassis; + LABEL(px+10, py+h, comp->name, 2); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); + info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 0, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -143,16 +138,10 @@ void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py, if (batt != -1) { info_battery *battery = info->batteries+batt; int h = 10; - LABEL(px+10, py+h, info->batteries[batt].name, 1); h += 30; - LABEL_F3(px+10, py+h, "MAX WEIGHT", 0, battery->weight, 1); h += 15; - LABEL_F3(px+10, py+h, "CAPACITY", 0, battery->capacity, 1); h += 15; - - float prech[2] = { px+10, py+h }; char srech[64]; - if (info->batteries[batt].recharge[lvl] == 0) { - strcpy(srech, "NOT RECHARGEABLE"); - } else { strcpy(srech, "RECHARGEABLE"); } - render_text_scaled(rend, srech, prech, t, 1); + stats_comp *comp = info->stats[STATS_BATTERY]+batt; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); float size[2] = {145, 145}; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); @@ -170,26 +159,9 @@ void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py, info_armor *arm = info->armors+armor; int h = 10; - LABEL(px+10, py+h, arm->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, arm->weight, 1); h += 20; + stats_comp *comp = info->stats[STATS_ARMOR]+armor; + LABEL(px+10, py+h, comp->name, 1); h += 20; - /*char sa[64]; int j=0; - char temp[16] = "red: "; - strcpy(sa+j, temp); - j += strlen(temp); - for (int i=0; i<7; i++) { - if (i<7-1) { - sprintf(temp, "%.0f, ", info->armors[armor].armor[i][lvl]); - } else { - sprintf(temp, "%.0f", info->armors[armor].armor[i][lvl]); - } - strcpy(sa+j, temp); - j += strlen(temp); - } - sa[j] = '\0'; - float pa[2] = { px+10, py+25 }; - render_text_scaled(rend, sa, pa, t, 1); - */ float size[2] = { 150, 50 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); } else { @@ -204,20 +176,11 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py, if (armor != -1) { info_armor *arm = info->armors+armor; int h = 10; + + stats_comp *comp = info->stats[STATS_ARMOR]+armor; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); - LABEL(px+10, py+h, arm->name, 1); h += 30; - LABEL_F3(px+10, py+h, "WEIGHT", 0, arm->weight, 1); h += 20; - LABEL(px+10, py+h, "DAMAGE REDUCTION", 1); h += 15; - - for (int i=0; i<7; i++) { - float sum = 0; for(int j=0;j<MAXLEVEL;j++) - sum+=fabs(arm->armor[i][j]); - if (sum > 0) { - LABEL_F3(px+10, py+h, info->damage_types[i], - 1, arm->armor[i], 1); - } - h += 15; - } info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 2, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -234,17 +197,10 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, if (weapon != -1) { info_weapon *weap = info->weapons+weapon; int h = 10; - - char dt[32]; - sprintf(dt, "DAMAGE TYPE: %s", - info->damage_types[info->weapons[weapon].damage_type]); - - LABEL(px+10, py+h, weap->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, weap->weight, 1); h += 15; - LABEL(px+10, py+h, dt, 1); h += 15; - LABEL_F3(px+10, py+h, "DAMAGE", 0, weap->damage, 1); h += 15; - LABEL_F3(px+10, py+h, "RANGE", 0, weap->range, 1); h += 15; - LABEL_F3(px+10, py+h, "COOLDOWN", 0, weap->cooldown, 1); h += 15; + + stats_comp *comp = info->stats[STATS_WEAPONS]+weapon; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); float size[2] = { 200, 110 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); @@ -261,32 +217,11 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, if (weapon != -1) { info_weapon *weap = info->weapons+weapon; int h = 10; + + stats_comp *comp = info->stats[STATS_WEAPONS]+weapon; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); - char dt[32]; - sprintf(dt, "DAMAGE TYPE: %s", - info->damage_types[info->weapons[weapon].damage_type]); - - LABEL(px+10, py+h, weap->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, weap->weight, 1); h += 15; - LABEL(px+10, py+h, dt, 1); h += 15; - LABEL_F3(px+10, py+h, "DAMAGE", 0, weap->damage, 1); h += 15; - LABEL_F3(px+10, py+h, "RANGE", 0, weap->range, 1); h += 15; - LABEL_F3(px+10, py+h, "COOLDOWN", 0, weap->cooldown, 1); h += 15; - LABEL_F3(px+10, py+h, "UPKEEP", 0, weap->upkeep, 1); h += 15; - - float kb = 0; for(int i=0;i<MAXLEVEL;i++) - kb += fabs(weap->knockback[i]); - if (kb > 0) { - LABEL_I3(px+10, py+h, "KNOCKBACK", weap->knockback, 1); - h += 15; - } - - float cps = 0; for(int i=0;i<MAXLEVEL;i++) - cps += fabs(weap->charge_per_shot[i]); - if (cps > 0) { - LABEL_F3(px+10, py+h, "CHARGE PER SHOT",0,weap->charge_per_shot, 1); - h += 15; - } info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 3, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -304,8 +239,8 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py, info_aug *augm = info->augs+aug; int h = 10; - LABEL(px+10, py+h, augm->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, augm->weight, 1); h += 15; + stats_comp *comp = info->stats[STATS_AUGS]+aug; + LABEL(px+10, py+h, comp->name, 1); h += 20; float size[2] = { 150, 50 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); @@ -322,67 +257,10 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, info_aug *augm = info->augs+aug; int h = 10; - LABEL(px+10, py+h, augm->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, augm->weight, 1); h += 15; + stats_comp *comp = info->stats[STATS_AUGS]+aug; + LABEL(px+10, py+h, comp->name, 1); h += 20; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); - float range = 0; for(int i=0;i<MAXLEVEL;i++) - range += fabs(augm->add_range[i]); - if (range > 0) { - LABEL_F3(px+10, py+h, "RANGE", 0, augm->add_range, 1); h += 15; - } - - float cooldown = 0; for(int i=0;i<MAXLEVEL;i++) - cooldown += fabs(augm->add_cooldown[i]); - if (cooldown != 0) { - LABEL_F3(px+10, py+h, "COOLDOWN", 2, augm->add_cooldown, 1); - h += 15; - } - - float speed = 0; for(int i=0;i<MAXLEVEL;i++) - speed += fabs(augm->add_speed[i]); - if (speed != 0) { - LABEL_F3(px+10, py+h, "SPEED", 2, augm->add_speed, 1); h += 15; - } - - float hp = 0; for(int i=0;i<MAXLEVEL;i++) - hp += fabs(augm->add_hp[i]); - if (hp != 0) { - LABEL_F3(px+10, py+h, "HP", 1, augm->add_hp, 1); h += 15; - } - - h += 5; - - float sum = 0; - for (int i=0; i<7; i++) - for(int j=0;j<MAXLEVEL;j++) - sum += fabs(augm->add_armor[i][j]); - if (sum != 0) { - for (int i=0; i<7; i++) { - float suml = 0; for(int j=0;j<MAXLEVEL;j++) - suml+=fabs(augm->add_armor[i][j]); - if (suml > 0) { - LABEL_F3(px+10, py+h, info->damage_types[i], - 1, augm->add_armor[i], 1); - h += 15; - } - } - } - - sum = 0; - for (int i=0; i<7; i++) - for(int j=0;j<MAXLEVEL;j++) - sum += fabs(augm->add_damage[i][j]); - if (sum != 0) { - for (int i=0; i<7; i++) { - float suml = 0; for(int j=0;j<MAXLEVEL;j++) - suml+=fabs(augm->add_damage[i][j]); - if (suml > 0) { - LABEL_F3(px+10, py+h, info->damage_types[i], - 1, augm->add_damage[i], 1); - h += 15; - } - } - } info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 4, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -398,9 +276,11 @@ void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py, { if (brain != -1) { float pname[2] = { px+10, py+10 }; - char sname[64]; sprintf(sname, "%s", - info->brains[brain].name); - render_text_scaled(rend, sname, pname, t, 1); + int h = 10; + + stats_comp *comp = info->stats[STATS_BRAIN]+brain; + LABEL(px+10, py+h, comp->name, 1); h += 20; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); float size[2] = { 145, 145 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); |