mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-26 05:24:21 +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);
|
||||
|
||||
protected:
|
||||
DiscMenu *menu;
|
||||
GameInfoBox *gameInfo;
|
||||
};
|
||||
@ -48,8 +47,15 @@ public:
|
||||
|
||||
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->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)
|
||||
|
28
gui.cpp
28
gui.cpp
@ -85,6 +85,7 @@ Gui::Gui()
|
||||
this->game_base_path = GAME_ROOT_PATH;
|
||||
|
||||
this->cur_gameInfo = new GameInfo();
|
||||
this->gameInfoChanged = false;
|
||||
|
||||
this->dlg = NULL;
|
||||
this->kbd = NULL;
|
||||
@ -318,6 +319,33 @@ void Gui::updateGameInfo(GameInfo *gi)
|
||||
panic_if(!gi, "gi must be set\n");
|
||||
delete this->cur_gameInfo;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user