mirror of
https://github.com/dborth/fceugx.git
synced 2024-10-31 22:45:05 +01:00
corrections/improvements to game saving
This commit is contained in:
parent
f860642125
commit
2d1db4c364
@ -303,6 +303,31 @@ bool SaveState (char * filepath, int method, bool silent)
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
// save screenshot - I would prefer to do this from gameScreenTex
|
||||
if(gameScreenTex2 != NULL && method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
||||
{
|
||||
AllocSaveBuffer ();
|
||||
|
||||
IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer);
|
||||
|
||||
if (pngContext != NULL)
|
||||
{
|
||||
imgSize = PNGU_EncodeFromGXTexture(pngContext, screenwidth, screenheight, gameScreenTex2, 0);
|
||||
PNGU_ReleaseImageContext(pngContext);
|
||||
}
|
||||
|
||||
if(imgSize > 0)
|
||||
{
|
||||
char screenpath[1024];
|
||||
strncpy(screenpath, filepath, 1024);
|
||||
screenpath[strlen(screenpath)-4] = 0;
|
||||
sprintf(screenpath, "%s.png", screenpath);
|
||||
SaveFile(screenpath, imgSize, method, silent);
|
||||
}
|
||||
|
||||
FreeSaveBuffer ();
|
||||
}
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
datasize = GCFCEUSS_Save(method);
|
||||
@ -323,30 +348,6 @@ bool SaveState (char * filepath, int method, bool silent)
|
||||
}
|
||||
FreeSaveBuffer ();
|
||||
|
||||
// save screenshot - I would prefer to do this from gameScreenTex
|
||||
if(gameScreenTex2 != NULL && method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
||||
{
|
||||
AllocSaveBuffer ();
|
||||
|
||||
IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer);
|
||||
|
||||
if (pngContext != NULL)
|
||||
{
|
||||
imgSize = PNGU_EncodeFromGXTexture(pngContext, 640, 480, gameScreenTex2, 0);
|
||||
PNGU_ReleaseImageContext(pngContext);
|
||||
}
|
||||
|
||||
if(imgSize > 0)
|
||||
{
|
||||
char screenpath[1024];
|
||||
filepath[strlen(filepath)-4] = 0;
|
||||
sprintf(screenpath, "%s.png", filepath);
|
||||
SaveFile(screenpath, imgSize, method, silent);
|
||||
}
|
||||
|
||||
FreeSaveBuffer ();
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
if (!silent)
|
||||
|
@ -22,10 +22,10 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
|
||||
action = a;
|
||||
selectable = true;
|
||||
|
||||
if(action == 0) // save
|
||||
if(action == 0) // load
|
||||
listOffset = 0;
|
||||
else
|
||||
listOffset = -2;
|
||||
listOffset = -2; // save - reserve -2 & -1 for new slots
|
||||
|
||||
selectedItem = 0;
|
||||
focus = 0; // allow focus
|
||||
@ -199,13 +199,13 @@ void GuiSaveBrowser::ResetState()
|
||||
|
||||
int GuiSaveBrowser::GetClickedSave()
|
||||
{
|
||||
int found = -1;
|
||||
int found = -3;
|
||||
for(int i=0; i<SAVELISTSIZE; i++)
|
||||
{
|
||||
if(saveBtn[i]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
saveBtn[i]->SetState(STATE_SELECTED);
|
||||
found = i;
|
||||
found = listOffset+i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1600,7 +1600,7 @@ static int MenuGameSaves(int action)
|
||||
ret = saveBrowser.GetClickedSave();
|
||||
|
||||
// load or save game
|
||||
if(ret >= 0)
|
||||
if(ret > -3)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
@ -1621,7 +1621,7 @@ static int MenuGameSaves(int action)
|
||||
}
|
||||
else // save
|
||||
{
|
||||
if(ret == 0) // new RAM
|
||||
if(ret == -2) // new RAM
|
||||
{
|
||||
for(i=1; i < 100; i++)
|
||||
if(saves.files[FILE_RAM][i] == 0)
|
||||
@ -1634,7 +1634,7 @@ static int MenuGameSaves(int action)
|
||||
menu = MENU_GAME_SAVE;
|
||||
}
|
||||
}
|
||||
else if(ret == 1) // new Snapshot
|
||||
else if(ret == -1) // new State
|
||||
{
|
||||
for(i=1; i < 100; i++)
|
||||
if(saves.files[FILE_STATE][i] == 0)
|
||||
@ -1649,8 +1649,8 @@ static int MenuGameSaves(int action)
|
||||
}
|
||||
else // overwrite RAM/State
|
||||
{
|
||||
MakeFilePath(filepath, saves.type[ret-2], method, saves.filename[ret-2]);
|
||||
switch(saves.type[ret-2])
|
||||
MakeFilePath(filepath, saves.type[ret], method, saves.filename[ret]);
|
||||
switch(saves.type[ret])
|
||||
{
|
||||
case FILE_RAM:
|
||||
SaveRAM(filepath, GCSettings.SaveMethod, NOTSILENT);
|
||||
|
Loading…
Reference in New Issue
Block a user