Load and use correct save slot.
This commit is contained in:
parent
c91aac41fe
commit
09afbfc0d9
|
@ -272,7 +272,7 @@ static void loadMetaInfo(void)
|
||||||
free(text);
|
free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadGame(void)
|
void loadGame(int slot)
|
||||||
{
|
{
|
||||||
cJSON *root, *node, *statsJSON;
|
cJSON *root, *node, *statsJSON;
|
||||||
char *text, filename[MAX_PATH_LENGTH], *statName;
|
char *text, filename[MAX_PATH_LENGTH], *statName;
|
||||||
|
@ -284,6 +284,8 @@ void loadGame(void)
|
||||||
|
|
||||||
initGame();
|
initGame();
|
||||||
|
|
||||||
|
game.saveSlot = slot;
|
||||||
|
|
||||||
sprintf(filename, "%s/%d/game.json", app.saveDir, game.saveSlot);
|
sprintf(filename, "%s/%d/game.json", app.saveDir, game.saveSlot);
|
||||||
|
|
||||||
if (fileExists(filename))
|
if (fileExists(filename))
|
||||||
|
|
|
@ -38,7 +38,6 @@ void returnToTitle(void);
|
||||||
|
|
||||||
static Texture *atlasTexture;
|
static Texture *atlasTexture;
|
||||||
static Atlas *title;
|
static Atlas *title;
|
||||||
static int recentSaveSlot;
|
|
||||||
static int saveAction;
|
static int saveAction;
|
||||||
static Widget *startNewGame;
|
static Widget *startNewGame;
|
||||||
static Widget *load;
|
static Widget *load;
|
||||||
|
@ -91,13 +90,16 @@ void initTitle(void)
|
||||||
|
|
||||||
titleAlpha = 0;
|
titleAlpha = 0;
|
||||||
|
|
||||||
recentSaveSlot = getRecentSave();
|
continueGame->value[1] = getRecentSave();
|
||||||
|
|
||||||
showWidgetGroup("title");
|
showWidgetGroup("title");
|
||||||
|
|
||||||
if (recentSaveSlot != -1)
|
if (continueGame->value[1] != -1)
|
||||||
{
|
{
|
||||||
setSelectedWidget("continue", "title");
|
setSelectedWidget("continue", "title");
|
||||||
|
|
||||||
|
load->disabled = 0;
|
||||||
|
continueGame->disabled = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -255,11 +257,9 @@ static void doContinueGame(void)
|
||||||
{
|
{
|
||||||
stopMusic();
|
stopMusic();
|
||||||
|
|
||||||
loadGame();
|
loadGame(continueGame->value[1]);
|
||||||
|
|
||||||
initHub();
|
initHub();
|
||||||
|
|
||||||
game.saveSlot = continueGame->value[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doOptions(void)
|
static void doOptions(void)
|
||||||
|
@ -291,7 +291,7 @@ static void doSaveSlot(void)
|
||||||
{
|
{
|
||||||
stopMusic();
|
stopMusic();
|
||||||
|
|
||||||
loadGame();
|
loadGame(game.saveSlot);
|
||||||
|
|
||||||
initHub();
|
initHub();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ extern Widget *getWidget(char *name, char *group);
|
||||||
extern void initCredits(int playMusic);
|
extern void initCredits(int playMusic);
|
||||||
extern void initHub(void);
|
extern void initHub(void);
|
||||||
extern void initOptions(void (*callback)(void));
|
extern void initOptions(void (*callback)(void));
|
||||||
extern void loadGame(void);
|
extern void loadGame(int slot);
|
||||||
extern void loadMusic(char *filename);
|
extern void loadMusic(char *filename);
|
||||||
extern void newGame(void);
|
extern void newGame(void);
|
||||||
extern void playMusic(int loop);
|
extern void playMusic(int loop);
|
||||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
void initWorldTest(char *worldId)
|
void initWorldTest(char *worldId)
|
||||||
{
|
{
|
||||||
loadGame();
|
loadGame(0);
|
||||||
|
|
||||||
saveGame();
|
saveGame();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
extern void initHub(void);
|
extern void initHub(void);
|
||||||
extern void initWorld(void);
|
extern void initWorld(void);
|
||||||
extern void loadGame(void);
|
extern void loadGame(int slot);
|
||||||
extern void saveGame(void);
|
extern void saveGame(void);
|
||||||
|
|
||||||
extern Game game;
|
extern Game game;
|
||||||
|
|
Loading…
Reference in New Issue