Init lookups earlier, to allow for config to be loaded.

This commit is contained in:
Steve 2018-02-14 07:14:11 +00:00
parent dacb561e62
commit 718b658a1a
4 changed files with 20 additions and 1 deletions

View File

@ -33,6 +33,8 @@ int main(int argc, char *argv[])
srand(time(NULL));
initLookups();
init18N(argc, argv);
initSDL();

View File

@ -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;

View File

@ -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++)

View File

@ -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)