mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-29 15:04:23 +01:00
Add code to save the current game info (not tested)
This commit is contained in:
parent
baa43d1cab
commit
cd1768a140
@ -26,7 +26,6 @@ public:
|
|||||||
|
|
||||||
void draw(SDL_Surface *where);
|
void draw(SDL_Surface *where);
|
||||||
|
|
||||||
protected:
|
|
||||||
DiscMenu *menu;
|
DiscMenu *menu;
|
||||||
GameInfoBox *gameInfo;
|
GameInfoBox *gameInfo;
|
||||||
};
|
};
|
||||||
@ -48,8 +47,15 @@ public:
|
|||||||
|
|
||||||
virtual void selectCallback(int which)
|
virtual void selectCallback(int which)
|
||||||
{
|
{
|
||||||
printf("entry %d selected: %s\n", which, this->pp_msgs[which]);
|
const char *fileName = this->pp_msgs[this->cur_sel];
|
||||||
|
|
||||||
Gui::gui->timerController->disarm(this);
|
Gui::gui->timerController->disarm(this);
|
||||||
|
Gui::gui->dv->loadGameInfo(fileName);
|
||||||
|
|
||||||
|
if (Gui::gui->dv->gameInfo->gi)
|
||||||
|
Gui::gui->updateGameInfo(Gui::gui->dv->gameInfo->gi);
|
||||||
|
else
|
||||||
|
Gui::gui->updateGameInfo(new GameInfo(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void hoverCallback(int which)
|
virtual void hoverCallback(int which)
|
||||||
|
28
gui.cpp
28
gui.cpp
@ -85,6 +85,7 @@ Gui::Gui()
|
|||||||
this->game_base_path = GAME_ROOT_PATH;
|
this->game_base_path = GAME_ROOT_PATH;
|
||||||
|
|
||||||
this->cur_gameInfo = new GameInfo();
|
this->cur_gameInfo = new GameInfo();
|
||||||
|
this->gameInfoChanged = false;
|
||||||
|
|
||||||
this->dlg = NULL;
|
this->dlg = NULL;
|
||||||
this->kbd = NULL;
|
this->kbd = NULL;
|
||||||
@ -318,6 +319,33 @@ void Gui::updateGameInfo(GameInfo *gi)
|
|||||||
panic_if(!gi, "gi must be set\n");
|
panic_if(!gi, "gi must be set\n");
|
||||||
delete this->cur_gameInfo;
|
delete this->cur_gameInfo;
|
||||||
this->cur_gameInfo = gi;
|
this->cur_gameInfo = gi;
|
||||||
|
this->gameInfoChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gui::saveGameInfo()
|
||||||
|
{
|
||||||
|
struct game_info *p = this->cur_gameInfo->dump();
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
char buf[255];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%s/%s",
|
||||||
|
METADATA_ROOT_PATH, this->cur_gameInfo->filename);
|
||||||
|
fp = fopen(buf, "w");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
warning("Could not open %s for writing\n", buf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int n = fwrite((const void*)p, 1, p->sz, fp);
|
||||||
|
if (n != p->sz)
|
||||||
|
warning("Could only write %d bytes of %s\n", n, buf);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->gameInfoChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
3
gui.hh
3
gui.hh
@ -63,6 +63,8 @@ public:
|
|||||||
|
|
||||||
void updateGameInfo(GameInfo *gi);
|
void updateGameInfo(GameInfo *gi);
|
||||||
|
|
||||||
|
void saveGameInfo();
|
||||||
|
|
||||||
void exitMenu();
|
void exitMenu();
|
||||||
|
|
||||||
/* These are private, keep off! */
|
/* These are private, keep off! */
|
||||||
@ -113,6 +115,7 @@ public:
|
|||||||
const char *game_base_path;
|
const char *game_base_path;
|
||||||
|
|
||||||
GameInfo *cur_gameInfo;
|
GameInfo *cur_gameInfo;
|
||||||
|
bool gameInfoChanged;
|
||||||
|
|
||||||
/* New preferences */
|
/* New preferences */
|
||||||
Prefs *np;
|
Prefs *np;
|
||||||
|
Loading…
Reference in New Issue
Block a user