From 718b658a1acd5fea3b2c896f91bb452c9a1c4847 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 14 Feb 2018 07:14:11 +0000 Subject: [PATCH] Init lookups earlier, to allow for config to be loaded. --- src/main.c | 2 ++ src/main.h | 1 + src/system/init.c | 8 +++++++- src/system/lookup.c | 10 ++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 5205071..07061a8 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,8 @@ int main(int argc, char *argv[]) srand(time(NULL)); + initLookups(); + init18N(argc, argv); initSDL(); diff --git a/src/main.h b/src/main.h index 48c2b54..7a4ba3d 100644 --- a/src/main.h +++ b/src/main.h @@ -29,6 +29,7 @@ extern void prepareScene(void); extern void presentScene(void); extern void initAtlasTest(void); extern void init18N(int argc, char *argv[]); +extern void initLookups(void); App app; Camera camera; diff --git a/src/system/init.c b/src/system/init.c index 7ce437e..1392122 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -123,7 +123,6 @@ void initGameSystem(void) { int i, numInitFuns; void (*initFuncs[]) (void) = { - initLookups, initGraphics, initFonts, initAtlas, @@ -224,6 +223,9 @@ static void loadConfig(void) app.config.fullscreen = cJSON_GetObjectItem(root, "fullscreen")->valueint; 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.blood = cJSON_GetObjectItem(root, "blood")->valueint; controlsJSON = cJSON_GetObjectItem(root, "controls"); if (controlsJSON) @@ -265,9 +267,13 @@ void saveConfig(void) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving config ..."); root = cJSON_CreateObject(); + cJSON_AddNumberToObject(root, "fullscreen", app.config.fullscreen); cJSON_AddNumberToObject(root, "musicVolume", app.config.musicVolume); cJSON_AddNumberToObject(root, "soundVolume", app.config.soundVolume); + + cJSON_AddNumberToObject(root, "blood", app.config.blood); + cJSON_AddNumberToObject(root, "hudInventory", app.config.hudInventory); keysJSON = cJSON_CreateObject(); for (i = 0 ; i < CONTROL_MAX ; i++) diff --git a/src/system/lookup.c b/src/system/lookup.c index 30f0ea9..3701846 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -38,6 +38,16 @@ void initLookups(void) addLookup("DOOR_OPEN", DOOR_OPEN); addLookup("DOOR_CLOSED", DOOR_CLOSED); + + addLookup("CONTROL_LEFT", CONTROL_LEFT); + addLookup("CONTROL_RIGHT", CONTROL_RIGHT); + addLookup("CONTROL_UP", CONTROL_UP); + addLookup("CONTROL_DOWN", CONTROL_DOWN); + addLookup("CONTROL_FIRE", CONTROL_FIRE); + addLookup("CONTROL_JUMP", CONTROL_JUMP); + addLookup("CONTROL_JETPACK", CONTROL_JETPACK); + addLookup("CONTROL_PAUSE", CONTROL_PAUSE); + addLookup("CONTROL_MAP", CONTROL_MAP); } static void addLookup(const char *name, long value)