win32: straighten out the save slot 0 / F10 business

This commit is contained in:
zeromus 2010-03-10 18:03:11 +00:00
parent 8ebe438af2
commit 7b768b83d8
4 changed files with 20 additions and 37 deletions

View File

@ -578,25 +578,24 @@ void clear_savestates()
savestates[i].exists = FALSE;
}
/* Scan for existing savestates and update struct */
// Scan for existing savestates and update struct
void scan_savestates()
{
struct stat sbuf;
char filename[MAX_PATH+1];
u8 i;
clear_savestates();
for( i = 1; i <= NB_STATES; i++ )
for(int i = 0; i < NB_STATES; i++ )
{
path.getpathnoext(path.STATES, filename);
path.getpathnoext(path.STATES, filename);
if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ;
sprintf(filename+strlen(filename), ".ds%d", i);
if( stat(filename,&sbuf) == -1 ) continue;
savestates[i-1].exists = TRUE;
strncpy(savestates[i-1].date, format_time(sbuf.st_mtime),40);
savestates[i-1].date[40-1] = '\0';
savestates[i].exists = TRUE;
strncpy(savestates[i].date, format_time(sbuf.st_mtime),40);
savestates[i].date[40-1] = '\0';
}
return ;

View File

@ -1873,8 +1873,8 @@ void NDS_UnPause(bool showMsg)
**/
void UpdateSaveStateMenu(int pos, char* txt)
{
ModifyMenu(mainMenu,IDM_STATE_SAVE_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_SAVE_F1 + pos, txt);
ModifyMenu(mainMenu,IDM_STATE_LOAD_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_LOAD_F1 + pos, txt);
ModifyMenu(mainMenu,IDM_STATE_SAVE_F10 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_SAVE_F10 + pos, txt);
ModifyMenu(mainMenu,IDM_STATE_LOAD_F10 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_LOAD_F10 + pos, txt);
}
/***
@ -1890,7 +1890,7 @@ void ResetSaveStateTimes()
char ntxt[64];
for(int i = 0; i < NB_STATES;i++)
{
sprintf(ntxt,"%d %s", i+1, "");
sprintf(ntxt,"%d %s", i, "");
UpdateSaveStateMenu(i, ntxt);
}
}
@ -1911,7 +1911,7 @@ void LoadSaveStateInfo()
{
if(savestates[i].exists)
{
sprintf(ntxt, "&%d %s", i+1, savestates[i].date);
sprintf(ntxt, "&%d %s", i, savestates[i].date);
UpdateSaveStateMenu(i, ntxt);
}
}
@ -3610,8 +3610,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
//Update savestate slot items based on ROM loaded
for (int x = 0; x < 10; x++)
{
DesEnableMenuItem(mainMenu, IDM_STATE_SAVE_F1+x, romloaded);
DesEnableMenuItem(mainMenu, IDM_STATE_LOAD_F1+x, romloaded);
DesEnableMenuItem(mainMenu, IDM_STATE_SAVE_F10+x, romloaded);
DesEnableMenuItem(mainMenu, IDM_STATE_LOAD_F10+x, romloaded);
}
//Gray the recent ROM menu item if there are no recent ROMs
@ -4567,39 +4567,22 @@ DOKEYDOWN:
case IDM_STATE_SAVE_F8:
case IDM_STATE_SAVE_F9:
case IDM_STATE_SAVE_F10:
HK_StateSaveSlot( abs(IDM_STATE_SAVE_F1 - LOWORD(wParam)) +1, true);
HK_StateSaveSlot(LOWORD(wParam)-IDM_STATE_SAVE_F10, true);
return 0;
case IDM_STATE_LOAD_F1:
HK_StateLoadSlot(1, true);
return 0;
case IDM_STATE_LOAD_F2:
HK_StateLoadSlot(2, true);
return 0;
case IDM_STATE_LOAD_F3:
HK_StateLoadSlot(3, true);
return 0;
case IDM_STATE_LOAD_F4:
HK_StateLoadSlot(4, true);
return 0;
case IDM_STATE_LOAD_F5:
HK_StateLoadSlot(5, true);
return 0;
case IDM_STATE_LOAD_F6:
HK_StateLoadSlot(6, true);
return 0;
case IDM_STATE_LOAD_F7:
HK_StateLoadSlot(7, true);
return 0;
case IDM_STATE_LOAD_F8:
HK_StateLoadSlot(8, true);
return 0;
case IDM_STATE_LOAD_F9:
HK_StateLoadSlot(9, true);
return 0;
case IDM_STATE_LOAD_F10:
HK_StateLoadSlot(10, true);
HK_StateLoadSlot(LOWORD(wParam)-IDM_STATE_LOAD_F10, true);
return 0;
case IDM_IMPORTBACKUPMEMORY:
{
OPENFILENAME ofn;
@ -6059,10 +6042,11 @@ void UpdateHotkeyAssignments()
UpdateHotkeyAssignment(CustomKeys.NewLuaScript, IDC_NEW_LUA_SCRIPT);
UpdateHotkeyAssignment(CustomKeys.MostRecentLuaScript, IDD_LUARECENT_RESERVE_START);
UpdateHotkeyAssignment(CustomKeys.CloseLuaScripts, IDC_CLOSE_LUA_SCRIPTS);
for(int i = 0; i < 10; i++)
UpdateHotkeyAssignment(CustomKeys.Save[(i+1)%10], IDM_STATE_SAVE_F1 + i);
UpdateHotkeyAssignment(CustomKeys.Save[i], IDM_STATE_SAVE_F10 + i);
for(int i = 0; i < 10; i++)
UpdateHotkeyAssignment(CustomKeys.Load[(i+1)%10], IDM_STATE_LOAD_F1 + i);
UpdateHotkeyAssignment(CustomKeys.Load[i], IDM_STATE_LOAD_F10 + i);
}

View File

@ -55,6 +55,7 @@
#define IDM_SUBMITBUGREPORT 134
#define IDM_STATE_LOAD 135
#define IDM_STATE_SAVE 136
#define IDM_STATE_SAVE_F10 139
#define IDM_STATE_SAVE_F1 140
#define IDM_STATE_SAVE_F2 141
#define IDM_STATE_SAVE_F3 142
@ -64,7 +65,7 @@
#define IDM_STATE_SAVE_F7 146
#define IDM_STATE_SAVE_F8 147
#define IDM_STATE_SAVE_F9 148
#define IDM_STATE_SAVE_F10 149
#define IDM_STATE_LOAD_F10 149
#define IDM_STATE_LOAD_F1 150
#define IDM_STATE_LOAD_F2 151
#define IDM_STATE_LOAD_F3 152
@ -74,7 +75,6 @@
#define IDM_STATE_LOAD_F7 156
#define IDM_STATE_LOAD_F8 157
#define IDM_STATE_LOAD_F9 158
#define IDM_STATE_LOAD_F10 159
#define IDC_COMBO1 160
#define IDC_COMBO2 161
#define IDC_COMBO3 162

Binary file not shown.