From dc85abac779992432cfaeabc87b026caa3dca299 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 19 Feb 2018 19:15:07 +0000 Subject: [PATCH] Start of options screen. --- src/game/options.c | 144 ++++++++++++++++++++++++++++++++++++++++++ src/game/options.h | 24 +++++++ src/structs.h | 5 +- src/system/init.c | 12 +++- src/system/textures.c | 4 +- src/world/hud.c | 4 +- 6 files changed, 184 insertions(+), 9 deletions(-) create mode 100644 src/game/options.c create mode 100644 src/game/options.h diff --git a/src/game/options.c b/src/game/options.c new file mode 100644 index 0000000..12a3e8a --- /dev/null +++ b/src/game/options.c @@ -0,0 +1,144 @@ +/* +Copyright (C) 2018 Parallel Realities + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "options.h" + +static void (*returnFromOptions)(void); +static void logic(void); +static void draw(void); +static void soundVolume(void); +static void musicVolume(void); +static void bloodGore(void); +static void trophyScreenshot(void); +static void trophyAlert(void); +static void inventory(void); +static void keyboard(void); +static void joypad(void); +static void back(void); + +static Widget soundVolumeWidget; +static Widget musicVolumeWidget; +static Widget bloodGoreWidget; +static Widget trophyScreenshotWidget; +static Widget trophyAlertWidget; +static Widget inventoryWidget; +static Widget keyboardWidget; +static Widget joypadWidget; +static Widget backWidget; + +void initOptions((void)(*callback)) +{ + returnFromOptions = callback; + + atlasTexture = getTexture(""); + + soundVolumeWidget = getWidget("soundVolume", "options") + soundVolumeWidget->action = soundVolume; + soundVolumeWidget->value = game.config.soundVolume; + + musicVolumeWidget = getWidget("musicVolume", "options") + musicVolumeWidget->action = musicVolume; + musicVolumeWidget->value = game.config.musicVolume; + + bloodGoreWidget = getWidget("bloodGore", "options") + bloodGoreWidget->action = bloodGore; + bloodGoreWidget->value = game.config.blood; + + trophyScreenshotWidget = getWidget("trophyScreenshot", "options") + trophyScreenshotWidget->action = trophyScreenshot; + trophyScreenshotWidget->value = game.config.trophyScreenshot; + + trophyAlertWidget = getWidget("trophyAlert", "options") + trophyAlertWidget->action = trophyAlert; + trophyAlertWidget->value = game.config.trophyAlert; + + inventoryWidget = getWidget("inventory", "options") + inventoryWidget->action = inventory; + inventoryWidget->value = game.config.inventory; + + keyboardWidget = getWidget("keyboard", "options") + keyboardWidget->action = keyboard; + + joypadWidget = getWidget("joypad", "options") + joypadWidget->action = joypad; + + backWidget = getWidget("back", "options") + backWidget->action = back; + + showWidgetGroup("options"); + + app.delegate.logic = logic; + app.delegate.draw = draw; +} + +static void logic(void) +{ + +} + +static void draw(void) +{ + +} + +static void soundVolume(void) +{ + +} + +static void musicVolume(void) +{ + +} + +static void bloodGore(void) +{ + +} + +static void trophyScreenshot(void) +{ + +} + +static void trophyAlert(void) +{ + +} + +static void inventory(void) +{ + +} + +static void keyboard(void) +{ + +} + +static void joypad(void) +{ + +} + +static void back(void) +{ + +} diff --git a/src/game/options.h b/src/game/options.h new file mode 100644 index 0000000..75c0187 --- /dev/null +++ b/src/game/options.h @@ -0,0 +1,24 @@ +/* +Copyright (C) 2018 Parallel Realities + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../common.h" + +extern App app; +extern Game game; diff --git a/src/structs.h b/src/structs.h index 08a3c84..3cbb755 100644 --- a/src/structs.h +++ b/src/structs.h @@ -209,7 +209,6 @@ struct Item { struct Bob { struct Unit; - int checkpointTimer; int outTimer; int stunTimer; int immuneTimer; @@ -331,8 +330,10 @@ typedef struct { int musicVolume; int keyControls[CONTROL_MAX]; int joypadControls[CONTROL_MAX]; - int hudInventory; + int inventory; int blood; + int trophyScreenshot; + int trophyAlert; } Config; typedef struct { diff --git a/src/system/init.c b/src/system/init.c index 35beca5..08e5d3d 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -192,8 +192,10 @@ static void initDefaultConfig(void) { int i; - app.config.hudInventory = 1; + app.config.inventory = 1; app.config.blood = 1; + app.config.trophyAlert = 1; + app.config.trophyScreenshot = 1; app.config.musicVolume = 8; app.config.soundVolume = 10; @@ -239,8 +241,10 @@ static void loadConfig(void) app.config.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint; app.config.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->valueint; - app.config.hudInventory = cJSON_GetObjectItem(root, "hudInventory")->valueint; + app.config.inventory = cJSON_GetObjectItem(root, "inventory")->valueint; app.config.blood = cJSON_GetObjectItem(root, "blood")->valueint; + app.config.trophyAlert = cJSON_GetObjectItem(root, "trophyAlert")->valueint; + app.config.trophyScreenshot = cJSON_GetObjectItem(root, "trophyScreenshot")->valueint; controlsJSON = cJSON_GetObjectItem(root, "controls"); if (controlsJSON) @@ -288,7 +292,9 @@ void saveConfig(void) cJSON_AddNumberToObject(root, "soundVolume", app.config.soundVolume); cJSON_AddNumberToObject(root, "blood", app.config.blood); - cJSON_AddNumberToObject(root, "hudInventory", app.config.hudInventory); + cJSON_AddNumberToObject(root, "inventory", app.config.inventory); + cJSON_AddNumberToObject(root, "trophyAlert", app.config.trophyAlert); + cJSON_AddNumberToObject(root, "trophyScreenshot", app.config.trophyScreenshot); keysJSON = cJSON_CreateObject(); for (i = 0 ; i < CONTROL_MAX ; i++) diff --git a/src/system/textures.c b/src/system/textures.c index f85660a..ae091df 100644 --- a/src/system/textures.c +++ b/src/system/textures.c @@ -20,11 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "textures.h" -static Texture textures[NUM_TEXTURE_BUCKETS]; - static Texture *addTextureToCache(const char *name, SDL_Texture *texture); Texture *getTexture(const char *name); +static Texture textures[NUM_TEXTURE_BUCKETS]; + void initTextures(void) { memset(&textures, 0, sizeof(Texture) * NUM_TEXTURE_BUCKETS); diff --git a/src/world/hud.c b/src/world/hud.c index a26c216..cc158bd 100644 --- a/src/world/hud.c +++ b/src/world/hud.c @@ -69,7 +69,7 @@ void drawHud(void) drawText(5, 80, 16, TA_LEFT, colors.white, "Weapon: %s", getWeaponName(world.bob->weaponType)); - if (app.config.hudInventory) + if (app.config.inventory) { drawInventory(); } @@ -217,7 +217,7 @@ void drawMissionStatus(void) SDL_Rect *r; char *status; - drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 64); + drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128); w = 800; h = 550;