Support more list focus settings.

This commit is contained in:
aquanull 2013-05-20 19:03:58 +08:00
parent dc25e6d223
commit c316bc9a33
3 changed files with 142 additions and 4 deletions

View File

@ -55,7 +55,41 @@ int PSPSaveDialog::Init(int paramAddr)
INFO_LOG(HLE,"Mode: %i", param.GetPspParam()->mode);
yesnoChoice = 1;
currentSelectedSave = param.GetLatestSave();
switch (param.GetPspParam()->focus)
{
case SCE_UTILITY_SAVEDATA_FOCUS_NAME:
currentSelectedSave = 0;
break;
case SCE_UTILITY_SAVEDATA_FOCUS_FIRSTLIST:
currentSelectedSave = param.GetFirstListSave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_LASTLIST:
currentSelectedSave = param.GetLastListSave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_LATEST:
currentSelectedSave = param.GetLatestSave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_OLDEST:
currentSelectedSave = param.GetOldestSave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_FIRSTDATA:
currentSelectedSave = param.GetFirstDataSave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_LASTDATA:
currentSelectedSave = param.GetLastDataSave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_FIRSTEMPTY:
currentSelectedSave = param.GetFirstEmptySave();
break;
case SCE_UTILITY_SAVEDATA_FOCUS_LASTEMPTY:
currentSelectedSave = param.GetLastEmptySave();
break;
default:
WARN_LOG(HLE, "Unknown save list focus option: %d", param.GetPspParam()->focus);
currentSelectedSave = 0;
break;
}
switch (param.GetPspParam()->mode)
{
case SCE_UTILITY_SAVEDATA_TYPE_LOAD:

View File

@ -1197,17 +1197,101 @@ void SavedataParam::SetSelectedSave(int idx)
selectedSave = idx;
}
int SavedataParam::GetFirstListSave()
{
return 0;
}
int SavedataParam::GetLastListSave()
{
return saveDataListCount - 1;
}
int SavedataParam::GetLatestSave()
{
int idx = 0;
time_t lastTime = 0;
time_t idxTime = 0;
for (int i = 0; i < saveDataListCount; ++i)
{
time_t thisTime = mktime(&saveDataList[i].modif_time);
if (lastTime < thisTime)
if (idxTime < thisTime)
{
idx = i;
lastTime = thisTime;
idxTime = thisTime;
}
}
return idx;
}
int SavedataParam::GetOldestSave()
{
int idx = 0;
time_t idxTime = 0;
for (int i = 0; i < saveDataListCount; ++i)
{
time_t thisTime = mktime(&saveDataList[i].modif_time);
if (idxTime > thisTime)
{
idx = i;
idxTime = thisTime;
}
}
return idx;
}
int SavedataParam::GetFirstDataSave()
{
int idx = 0;
for (int i = 0; i < saveDataListCount; ++i)
{
if (saveDataList[i].size != 0)
{
idx = i;;
break;
}
}
return idx;
}
int SavedataParam::GetLastDataSave()
{
int idx = 0;
for (int i = saveDataListCount; i > 0; )
{
--i;
if (saveDataList[i].size != 0)
{
idx = i;
break;
}
}
return idx;
}
int SavedataParam::GetFirstEmptySave()
{
int idx = 0;
for (int i = 0; i < saveDataListCount; ++i)
{
if (saveDataList[i].size == 0)
{
idx = i;
break;
}
}
return idx;
}
int SavedataParam::GetLastEmptySave()
{
int idx = 0;
for (int i = saveDataListCount; i > 0; )
{
--i;
if (saveDataList[i].size == 0)
{
idx = i;
break;
}
}
return idx;

View File

@ -47,6 +47,19 @@ enum SceUtilitySavedataType
SCE_UTILITY_SAVEDATA_TYPE_GETSIZE = 22,
};
enum SceUtilitySavedataFocus
{
SCE_UTILITY_SAVEDATA_FOCUS_NAME = 0, // specified by saveName[]
SCE_UTILITY_SAVEDATA_FOCUS_FIRSTLIST = 1, // first listed (on screen or of all)?
SCE_UTILITY_SAVEDATA_FOCUS_LASTLIST = 2, // last listed (on screen or of all)?
SCE_UTILITY_SAVEDATA_FOCUS_LATEST = 3, // latest by modification date (first if none)
SCE_UTILITY_SAVEDATA_FOCUS_OLDEST = 4, // doldest by modification date (first if none)
SCE_UTILITY_SAVEDATA_FOCUS_FIRSTDATA = 5, // first non-empty (first if none)
SCE_UTILITY_SAVEDATA_FOCUS_LASTDATA = 6, // last non-empty (first if none)
SCE_UTILITY_SAVEDATA_FOCUS_FIRSTEMPTY = 7, // first empty (what if no empty?)
SCE_UTILITY_SAVEDATA_FOCUS_LASTEMPTY = 8, // last empty (what if no empty?)
};
// title, savedataTitle, detail: parts of the unencrypted SFO
// data, it contains what the VSH and standard load screen shows
struct PspUtilitySavedataSFOParam
@ -223,7 +236,14 @@ public:
int GetSelectedSave();
void SetSelectedSave(int idx);
int GetFirstListSave();
int GetLastListSave();
int GetLatestSave();
int GetOldestSave();
int GetFirstDataSave();
int GetLastDataSave();
int GetFirstEmptySave();
int GetLastEmptySave();
void DoState(PointerWrap &p);