Init lookups earlier, to allow for config to be loaded.
This commit is contained in:
parent
dacb561e62
commit
718b658a1a
|
@ -33,6 +33,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
|
initLookups();
|
||||||
|
|
||||||
init18N(argc, argv);
|
init18N(argc, argv);
|
||||||
|
|
||||||
initSDL();
|
initSDL();
|
||||||
|
|
|
@ -29,6 +29,7 @@ extern void prepareScene(void);
|
||||||
extern void presentScene(void);
|
extern void presentScene(void);
|
||||||
extern void initAtlasTest(void);
|
extern void initAtlasTest(void);
|
||||||
extern void init18N(int argc, char *argv[]);
|
extern void init18N(int argc, char *argv[]);
|
||||||
|
extern void initLookups(void);
|
||||||
|
|
||||||
App app;
|
App app;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
|
|
@ -123,7 +123,6 @@ void initGameSystem(void)
|
||||||
{
|
{
|
||||||
int i, numInitFuns;
|
int i, numInitFuns;
|
||||||
void (*initFuncs[]) (void) = {
|
void (*initFuncs[]) (void) = {
|
||||||
initLookups,
|
|
||||||
initGraphics,
|
initGraphics,
|
||||||
initFonts,
|
initFonts,
|
||||||
initAtlas,
|
initAtlas,
|
||||||
|
@ -224,6 +223,9 @@ static void loadConfig(void)
|
||||||
app.config.fullscreen = cJSON_GetObjectItem(root, "fullscreen")->valueint;
|
app.config.fullscreen = cJSON_GetObjectItem(root, "fullscreen")->valueint;
|
||||||
app.config.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint;
|
app.config.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint;
|
||||||
app.config.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->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");
|
controlsJSON = cJSON_GetObjectItem(root, "controls");
|
||||||
if (controlsJSON)
|
if (controlsJSON)
|
||||||
|
@ -265,9 +267,13 @@ void saveConfig(void)
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving config ...");
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving config ...");
|
||||||
|
|
||||||
root = cJSON_CreateObject();
|
root = cJSON_CreateObject();
|
||||||
|
|
||||||
cJSON_AddNumberToObject(root, "fullscreen", app.config.fullscreen);
|
cJSON_AddNumberToObject(root, "fullscreen", app.config.fullscreen);
|
||||||
cJSON_AddNumberToObject(root, "musicVolume", app.config.musicVolume);
|
cJSON_AddNumberToObject(root, "musicVolume", app.config.musicVolume);
|
||||||
cJSON_AddNumberToObject(root, "soundVolume", app.config.soundVolume);
|
cJSON_AddNumberToObject(root, "soundVolume", app.config.soundVolume);
|
||||||
|
|
||||||
|
cJSON_AddNumberToObject(root, "blood", app.config.blood);
|
||||||
|
cJSON_AddNumberToObject(root, "hudInventory", app.config.hudInventory);
|
||||||
|
|
||||||
keysJSON = cJSON_CreateObject();
|
keysJSON = cJSON_CreateObject();
|
||||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||||
|
|
|
@ -38,6 +38,16 @@ void initLookups(void)
|
||||||
|
|
||||||
addLookup("DOOR_OPEN", DOOR_OPEN);
|
addLookup("DOOR_OPEN", DOOR_OPEN);
|
||||||
addLookup("DOOR_CLOSED", DOOR_CLOSED);
|
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)
|
static void addLookup(const char *name, long value)
|
||||||
|
|
Loading…
Reference in New Issue