aboutsummaryrefslogtreecommitdiff
path: root/hud
diff options
context:
space:
mode:
authorjacopo grandi <jak.sk8@hotmail.it>2021-02-19 18:30:53 +0100
committerjacopo grandi <jak.sk8@hotmail.it>2021-02-19 18:30:53 +0100
commit5126638d46398579c26d3c7bd908fe17b8508b13 (patch)
treefbb9e981187f32bf78dc521ff538ea31de9c0019 /hud
parent5f0fce4191309e9526b7109a0d87c092ce6a4193 (diff)
battery calc and unstable levels
Diffstat (limited to 'hud')
-rw-r--r--hud/hud.c49
-rw-r--r--hud/hud_views.c79
-rw-r--r--hud/hud_views.h20
3 files changed, 79 insertions, 69 deletions
diff --git a/hud/hud.c b/hud/hud.c
index 383cb01..2c73288 100644
--- a/hud/hud.c
+++ b/hud/hud.c
@@ -115,7 +115,8 @@ int hud_fnu_check (info_unit *u, infos *info) {
if (u->battery == -1) return 2;
if (u->brain == -1) return 3;
float curweight = info_unit_get_weight(info, u);
- float maxweight = info->chassis[u->chassis].weight_max;
+ int chassis_lvl = u->levels[LEVEL_CHASSIS];
+ float maxweight = info->chassis[u->chassis].weight_max[chassis_lvl];
if (curweight > maxweight) { return 4; }
return 0;
}
@@ -272,8 +273,9 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb,
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; i++)
+ i<info->chassis[h->fnu.uinfo.chassis].slot_armor[lc]; i++)
{
float possa[2] = {
h->fnu.rect_armor[i].x, h->fnu.rect_armor[i].y };
@@ -285,7 +287,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_weapon; i++)
+ i<info->chassis[h->fnu.uinfo.chassis].slot_weapon[lc]; i++)
{
float possa[2] = {
h->fnu.rect_weapons[i].x, h->fnu.rect_weapons[i].y };
@@ -297,7 +299,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; i++)
+ i<info->chassis[h->fnu.uinfo.chassis].slot_aug[lc]; i++)
{
float possa[2] = {
h->fnu.rect_augs[i].x, h->fnu.rect_augs[i].y };
@@ -552,12 +554,12 @@ void hud_render_sel (hud_sel *sc, MKb *mkb, info_unit *u,
SDL_RenderFillRect(rend, &r);
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderDrawRect(rend, &r);
- if (sel==0) render_view_chassis(rend, t, x, y, info, i, sprites);
- if (sel==1) render_view_battery(rend, t, x, y, info, i);
- if (sel==2) render_view_armor_detail(rend, t, x, y, info, i);
- if (sel==3) render_view_weapon_detail(rend, t, x, y, info, i);
- if (sel==4) render_view_aug_detail(rend, t, x, y, info, i);
- if (sel==5) render_view_brain(rend, t, x, y, info, i);
+ if (sel==0) render_view_chassis(rend, t, x, y, info, i, 0, sprites);
+ if (sel==1) render_view_battery(rend, t, x, y, info, i, 0);
+ if (sel==2) render_view_armor_detail(rend, t, x, y, info, i, 0);
+ if (sel==3) render_view_weapon_detail(rend, t, x, y, info, i, 0);
+ if (sel==4) render_view_aug_detail(rend, t, x, y, info, i, 0);
+ if (sel==5) render_view_brain(rend, t, x, y, info, i, 0);
}
SDL_RenderSetClipRect(rend, NULL);
}
@@ -586,33 +588,37 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb,
render_view_stats(rend, t, fnu->rect_stats.x, fnu->rect_stats.y,
info, &fnu->uinfo);
+ int lc = fnu->uinfo.levels[LEVEL_CHASSIS];
if (fnu->uinfo.chassis != -1) {
- for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_weapon; i++) {
+ for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_weapon[lc]; i++) {
SDL_SetRenderDrawColor(rend, 200, 100, 255, 255);
SDL_RenderFillRect(rend, fnu->rect_weapons+i);
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderDrawRect(rend, fnu->rect_weapons+i);
render_view_weapon(rend, t,
fnu->rect_weapons[i].x,
- fnu->rect_weapons[i].y, info, fnu->uinfo.weapons[i]);
+ 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; i++) {
+ for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_armor[lc]; i++) {
SDL_SetRenderDrawColor(rend, 200, 200, 255, 255);
SDL_RenderFillRect(rend, fnu->rect_armor+i);
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderDrawRect(rend, fnu->rect_armor+i);
render_view_armor(rend, t,
fnu->rect_armor[i].x,
- fnu->rect_armor[i].y, info, fnu->uinfo.armor[i]);
+ 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; i++) {
+ for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_aug[lc]; i++) {
SDL_SetRenderDrawColor(rend, 200, 200, 255, 255);
SDL_RenderFillRect(rend, fnu->rect_augs+i);
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderDrawRect(rend, fnu->rect_augs+i);
render_view_aug(rend, t,
fnu->rect_augs[i].x,
- fnu->rect_augs[i].y, info, fnu->uinfo.augs[i]);
+ fnu->rect_augs[i].y, info, fnu->uinfo.augs[i],
+ fnu->uinfo.levels[LEVEL_AUGS+i]);
}
}
@@ -681,11 +687,14 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb,
render_view_chassis(rend, t,
fnu->rect_chassis.x, fnu->rect_chassis.y,
- info, fnu->uinfo.chassis, sprites);
+ info, fnu->uinfo.chassis,
+ fnu->uinfo.levels[LEVEL_CHASSIS], sprites);
render_view_battery(rend, t,
- fnu->rect_battery.x, fnu->rect_battery.y, info, fnu->uinfo.battery);
+ fnu->rect_battery.x, fnu->rect_battery.y, info, fnu->uinfo.battery,
+ fnu->uinfo.levels[LEVEL_BATTERY]);
render_view_brain(rend, t,
- fnu->rect_brain.x, fnu->rect_brain.y, info, fnu->uinfo.brain);
+ fnu->rect_brain.x, fnu->rect_brain.y, info, fnu->uinfo.brain,
+ fnu->uinfo.levels[LEVEL_BRAIN]);
}
void hud_render_overlay_game (overlay_game *og, MKb *mkb,
@@ -708,7 +717,7 @@ void hud_render_overlay_game (overlay_game *og, MKb *mkb,
for (int i=0; i<info->templateslen; i++) {
float x = og->rect_templates.x+5;
float y = og->rect_templates.y+5 + i*20 + 30;
- render_view_template(rend, t, x, y, info, i);
+ render_view_template(rend, t, x, y, info, i, 0);
}
SDL_SetRenderDrawColor(rend, 0, 200, 120, 255);
diff --git a/hud/hud_views.c b/hud/hud_views.c
index 557ff1f..a7237e2 100644
--- a/hud/hud_views.c
+++ b/hud/hud_views.c
@@ -15,7 +15,8 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py,
h += 35;
float calcweight = info_unit_get_weight(info, tm);
- float maxweight = info->chassis[tm->chassis].weight_max;
+ 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);
@@ -55,7 +56,7 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py,
}
void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int chassis, SDL_Texture *sprites)
+ infos *info, int chassis, int lvl, SDL_Texture *sprites)
{
if (chassis != -1) {
float pname[2] = { px+10, py+10 };
@@ -85,7 +86,7 @@ void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py,
}
void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int batt)
+ infos *info, int batt, int lvl)
{
if (batt != -1) {
float pname[2] = { px+10, py+10 };
@@ -116,7 +117,7 @@ void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py,
void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int armor)
+ infos *info, int armor, int lvl)
{
if (armor != -1) {
float pname[2] = { px+10, py+10 };
@@ -128,9 +129,9 @@ void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py,
j += strlen(temp);
for (int i=0; i<7; i++) {
if (i<7-1) {
- sprintf(temp, "%.0f, ", info->armors[armor].armor[i]);
+ sprintf(temp, "%.0f, ", info->armors[armor].armor[i][lvl]);
} else {
- sprintf(temp, "%.0f", info->armors[armor].armor[i]);
+ sprintf(temp, "%.0f", info->armors[armor].armor[i][lvl]);
}
strcpy(sa+j, temp);
j += strlen(temp);
@@ -145,7 +146,7 @@ void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py,
}
void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int armor)
+ infos *info, int armor, int lvl)
{
if (armor != -1) {
float pname[2] = { px+10, py+10 };
@@ -153,7 +154,7 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py,
render_text_scaled(rend, sname, pname, t, 1);
float pweight[2] = { px+10, py+40 };
char sweight[64]; sprintf(sweight, "WEIGHT: %0.0f",
- info->armors[armor].weight);
+ info->armors[armor].weight[lvl]);
render_text_scaled(rend, sweight, pweight, t, 1);
float pred[2] = { px+10, py+60 };
@@ -161,21 +162,21 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py,
int h=0;
for (int i=0; i<7; i++) {
- if (info->armors[armor].armor[i] < 0.001) continue;
+ if (info->armors[armor].armor[i][lvl] < 0.001) continue;
float pa[2] = { px+10, py+75+h*15 };
char sa[64]; sprintf(sa, "%s: %.1f%",
- info->damage_types[i], info->armors[armor].armor[i]);
+ info->damage_types[i], info->armors[armor].armor[i][lvl]);
render_text_scaled(rend, sa, pa, t, 1);
h++;
}
} else {
- render_view_weapon(rend, t, px, py, info, armor);
+ render_view_weapon(rend, t, px, py, info, armor, lvl);
}
}
void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int weapon)
+ infos *info, int weapon, int lvl)
{
if (weapon != -1) {
float pname[2] = { px+10, py+10 };
@@ -184,7 +185,7 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py,
render_text_scaled(rend, sname, pname, t, 1);
float pweight[2] = { px+10, py+30 };
char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->weapons[weapon].weight);
+ info->weapons[weapon].weight[lvl]);
render_text_scaled(rend, sweight, pweight, t, 1);
float ptype[2] = { px+10, py+45 };
char stype[64]; sprintf(stype, "DAMAGE TYPE: %s",
@@ -192,15 +193,15 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py,
render_text_scaled(rend, stype, ptype, t, 1);
float pdamage[2] = { px+10, py+60 };
char sdamage[64]; sprintf(sdamage, "DAMAGE: %.0f",
- info->weapons[weapon].damage);
+ info->weapons[weapon].damage[lvl]);
render_text_scaled(rend, sdamage, pdamage, t, 1);
float prange[2] = { px+10, py+75 };
char srange[64]; sprintf(srange, "RANGE: %.0f",
- info->weapons[weapon].range);
+ info->weapons[weapon].range[lvl]);
render_text_scaled(rend, srange, prange, t, 1);
float pcool[2] = { px+10, py+90 };
char scool[64]; sprintf(scool, "COOLDOWN: %.0f",
- info->weapons[weapon].cooldown);
+ info->weapons[weapon].cooldown[lvl]);
render_text_scaled(rend, scool, pcool, t, 1);
} else {
float pname[2] = { px+10, py+10 };
@@ -209,7 +210,7 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py,
}
void render_view_weapon_detail (SDL_Renderer* rend, txtd *t,
- int px, int py, infos *info, int weapon)
+ int px, int py, infos *info, int weapon, int lvl)
{
if (weapon != -1) {
float pname[2] = { px+10, py+10 };
@@ -218,7 +219,7 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t,
render_text_scaled(rend, sname, pname, t, 1);
float pweight[2] = { px+10, py+30 };
char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->weapons[weapon].weight);
+ info->weapons[weapon].weight[lvl]);
render_text_scaled(rend, sweight, pweight, t, 1);
float ptype[2] = { px+10, py+45 };
char stype[64]; sprintf(stype, "DAMAGE TYPE: %s",
@@ -226,24 +227,24 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t,
render_text_scaled(rend, stype, ptype, t, 1);
float pdamage[2] = { px+10, py+60 };
char sdamage[64]; sprintf(sdamage, "DAMAGE: %.0f",
- info->weapons[weapon].damage);
+ info->weapons[weapon].damage[lvl]);
render_text_scaled(rend, sdamage, pdamage, t, 1);
float prange[2] = { px+10, py+75 };
char srange[64]; sprintf(srange, "RANGE: %.0f",
- info->weapons[weapon].range);
+ info->weapons[weapon].range[lvl]);
render_text_scaled(rend, srange, prange, t, 1);
float pcool[2] = { px+10, py+90 };
char scool[64]; sprintf(scool, "COOLDOWN: %.0f",
- info->weapons[weapon].cooldown);
+ info->weapons[weapon].cooldown[lvl]);
render_text_scaled(rend, scool, pcool, t, 1);
} else {
- render_view_weapon(rend, t, px, py, info, weapon);
+ render_view_weapon(rend, t, px, py, info, weapon, lvl);
}
}
void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int aug)
+ infos *info, int aug, int lvl)
{
if (aug != -1) {
float pname[2] = { px+10, py+10 };
@@ -252,7 +253,7 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py,
render_text_scaled(rend, sname, pname, t, 1);
float pweight[2] = { px+10, py+30 };
char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->augs[aug].weight);
+ info->augs[aug].weight[lvl]);
render_text_scaled(rend, sweight, pweight, t, 1);
} else {
float pname[2] = { px+10, py+10 };
@@ -261,7 +262,7 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py,
}
void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int aug)
+ infos *info, int aug, int lvl)
{
if (aug != -1) {
float h = 10;
@@ -273,11 +274,11 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
float pweight[2] = { px+10, py+h };
char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->augs[aug].weight);
+ info->augs[aug].weight[lvl]);
render_text_scaled(rend, sweight, pweight, t, 1);
h += 15;
- float range = info->augs[aug].add_range;
+ float range = info->augs[aug].add_range[lvl];
if (range != 0) {
float p[2] = { px+10, py+h };
char s[64]; sprintf(s, "RANGE: %.1f", range);
@@ -285,7 +286,7 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
h += 15;
}
- float cooldown = info->augs[aug].add_cooldown;
+ float cooldown = info->augs[aug].add_cooldown[lvl];
if (cooldown != 0) {
float p[2] = { px+10, py+h };
char s[64]; sprintf(s, "COOLDOWN: %.2f", cooldown);
@@ -293,7 +294,7 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
h += 15;
}
- float speed = info->augs[aug].add_speed;
+ float speed = info->augs[aug].add_speed[lvl];
if (speed != 0) {
float p[2] = { px+10, py+h };
char s[64]; sprintf(s, "SPEED: %.2f", speed);
@@ -301,7 +302,7 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
h += 15;
}
- float hp = info->augs[aug].add_hp;
+ float hp = info->augs[aug].add_hp[lvl];
if (hp != 0) {
float p[2] = { px+10, py+h };
char s[64]; sprintf(s, "HP: %.1f", hp);
@@ -312,44 +313,44 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
h += 5;
float sum = 0;
- for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_armor[i]);
+ for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_armor[i][lvl]);
if (sum != 0) {
float p[2] = { px+10, py+h };
render_text_scaled(rend, "ARMOR: ", p, t, 1);
h += 15;
for (int i=0; i<7; i++) {
- if (info->augs[aug].add_armor[i] == 0) continue;
+ if (info->augs[aug].add_armor[i][lvl] == 0) continue;
float pa[2] = { px+10, py+h };
char sa[64]; sprintf(sa, "%s: %.1f%",
- info->damage_types[i], info->augs[aug].add_armor[i]);
+ info->damage_types[i], info->augs[aug].add_armor[i][lvl]);
render_text_scaled(rend, sa, pa, t, 1);
h += 15;
}
}
sum = 0;
- for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_damage[i]);
+ for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_damage[i][lvl]);
if (sum != 0) {
float p[2] = { px+10, py+h };
render_text_scaled(rend, "DAMAGE: ", p, t, 1);
h += 15;
for (int i=0; i<7; i++) {
- if (info->augs[aug].add_damage[i] == 0) continue;
+ if (info->augs[aug].add_damage[i][lvl] == 0) continue;
float pa[2] = { px+10, py+h };
char sa[64]; sprintf(sa, "%s: %.1f%",
- info->damage_types[i], info->augs[aug].add_damage[i]);
+ info->damage_types[i], info->augs[aug].add_damage[i][lvl]);
render_text_scaled(rend, sa, pa, t, 1);
h += 15;
}
}
} else {
- render_view_aug(rend, t, px, py, info, aug);
+ render_view_aug(rend, t, px, py, info, aug, lvl);
}
}
void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int brain)
+ infos *info, int brain, int lvl)
{
if (brain != -1) {
float pname[2] = { px+10, py+10 };
@@ -364,7 +365,7 @@ void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py,
void render_view_template (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int temp)
+ infos *info, int temp, int lvl)
{
button b = { "edit", 4, { px, py } };
render_button(rend, t, &b);
diff --git a/hud/hud_views.h b/hud/hud_views.h
index ceced23..50311d2 100644
--- a/hud/hud_views.h
+++ b/hud/hud_views.h
@@ -16,32 +16,32 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py,
void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int chassis, SDL_Texture *sprites);
+ infos *info, int chassis, int lvl, SDL_Texture *sprites);
void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int batt);
+ infos *info, int batt, int lvl);
void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int armor);
+ infos *info, int armor, int lvl);
void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int armor);
+ infos *info, int armor, int lvl);
void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int weapon);
+ infos *info, int weapon, int lvl);
void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int weapon);
+ infos *info, int weapon, int lvl);
void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int aug);
+ infos *info, int aug, int lvl);
void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int aug);
+ infos *info, int aug, int lvl);
void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int brain);
+ infos *info, int brain, int lvl);
void render_view_template (SDL_Renderer* rend, txtd *t, int px, int py,
- infos *info, int temp);
+ infos *info, int temp, int lvl);
#endif \ No newline at end of file