From c87c95fbde449b1aea0198bd8887282dec566ad9 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 1 May 2016 16:35:11 +0100 Subject: [PATCH] Added healthBars option to gameplay features. --- data/app/config.json | 3 ++- src/battle/entities.c | 2 +- src/structs.h | 1 + src/system/init.c | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/app/config.json b/data/app/config.json index 7c0e30a..8fb2956 100644 --- a/data/app/config.json +++ b/data/app/config.json @@ -37,6 +37,7 @@ "gameplay" : { "friendlyFire" : 0, "autoSwitchPlayerTarget" : 0, - "missileReTarget" : 0 + "missileReTarget" : 0, + "healthBars" : 0 } } diff --git a/src/battle/entities.c b/src/battle/entities.c index 6d686b2..fe1c37c 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -425,7 +425,7 @@ static void drawHealthBar(Entity *e) { SDL_Rect r; - if (!(e->flags & EF_NO_HEALTH_BAR) && e->health > 0) + if (app.gameplay.healthBars && !(e->flags & EF_NO_HEALTH_BAR) && e->health > 0) { r.x = e->x - (e->w / 2) - battle.camera.x; r.y = e->y - e->h - battle.camera.y; diff --git a/src/structs.h b/src/structs.h index 9cd1319..a44adef 100644 --- a/src/structs.h +++ b/src/structs.h @@ -387,6 +387,7 @@ typedef struct { int friendlyFire; int autoSwitchPlayerTarget; int missileReTarget; + int healthBars; } Gameplay; typedef struct { diff --git a/src/system/init.c b/src/system/init.c index 652695d..a338665 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -267,6 +267,7 @@ static void loadConfigFile(char *filename) app.gameplay.friendlyFire = cJSON_GetObjectItem(gameplayJSON, "friendlyFire")->valueint; app.gameplay.autoSwitchPlayerTarget = cJSON_GetObjectItem(gameplayJSON, "autoSwitchPlayerTarget")->valueint; app.gameplay.missileReTarget = cJSON_GetObjectItem(gameplayJSON, "missileReTarget")->valueint; + app.gameplay.healthBars = cJSON_GetObjectItem(gameplayJSON, "healthBars")->valueint; } cJSON_Delete(root); @@ -311,6 +312,7 @@ void saveConfig(void) cJSON_AddNumberToObject(gameplayJSON, "friendlyFire", app.gameplay.friendlyFire); cJSON_AddNumberToObject(gameplayJSON, "autoSwitchPlayerTarget", app.gameplay.autoSwitchPlayerTarget); cJSON_AddNumberToObject(gameplayJSON, "missileReTarget", app.gameplay.missileReTarget); + cJSON_AddNumberToObject(gameplayJSON, "healthBars", app.gameplay.healthBars); cJSON_AddItemToObject(root, "gameplay", gameplayJSON); out = cJSON_Print(root);