Improve Save Manager (#2951)

* Add the save icons to the save data entry and manager.

* Simplify code slightly since I have an else now so no need for == false

* Move the icon to the top of the list because it looks better.  Remove redundant settitle.

* Fix size.  It's a bit forced but there wasn't any better way as far as I could see on stack overflow.

Also, add an error dialog if you have no entries.

Simplify the logic slightly for the selected since with the no data case handled, I can make more assumptions about the return value.

* save_data_utility: fix dialog sizes

* CELL_OK

* Retcon dialog to instead be error in log.

* Dangle92 and I had some fun. Everything should be good now.

* In dangle's code he disabled the icon, in mine I hide it if there is nothing. Having both isn't needed.  Yay merges resulting in doing stupid things.

* Fix leek

* Default size to zero for sanity. Shared pointer is fine handling null (tested with disgaea and renaming icon file)

* Simplifying. Thanks for review and advice all
This commit is contained in:
Robbie 2017-07-13 10:38:13 -05:00 committed by Ivan
parent e8ba5876ce
commit ab595d2b95
3 changed files with 74 additions and 45 deletions

View file

@ -141,11 +141,16 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version,
save_entry2.atime = entry.atime;
save_entry2.mtime = entry.mtime;
save_entry2.ctime = entry.ctime;
//save_entry2.iconBuf = NULL; // TODO: Here should be the PNG buffer
//save_entry2.iconBufSize = 0; // TODO: Size of the PNG file
if (fs::is_file(base_dir + entry.name + "/ICON0.PNG"))
{
fs::file icon = fs::file(base_dir + entry.name + "/ICON0.PNG");
u32 iconSize = icon.size();
std::vector<uchar> iconData;
icon.read(iconData, iconSize);
save_entry2.iconBuf = iconData;
}
save_entry2.isNew = false;
save_entries.push_back(save_entry2);
save_entries.emplace_back(save_entry2);
}
break;
@ -210,6 +215,13 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version,
return CELL_SAVEDATA_ERROR_CBRESULT;
}
// if the callback has returned ok, lets return OK.
// typically used at game launch when no list is actually required.
if ((result->result == CELL_SAVEDATA_CBRESULT_OK_LAST) || (result->result == CELL_SAVEDATA_CBRESULT_OK_LAST_NOCONFIRM))
{
return CELL_OK;
}
// Clean save data list
save_entries.erase(std::remove_if(save_entries.begin(), save_entries.end(), [&listSet](const SaveDataEntry& entry) -> bool
{
@ -293,10 +305,9 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version,
}
}
// Display Save Data List but do so asynchronously in the GUI thread. For, qTimers only work using main UI thread.
// Display Save Data List but do so asynchronously in the GUI thread.
bool hasNewData = (bool)listSet->newData; // newData
atomic_t<bool> dlg_result(false);
bool hasNewData = (bool) listSet->newData; // Are we saving?
Emu.CallAfter([&]()
{
@ -309,28 +320,18 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version,
thread_ctrl::wait_for(1000);
}
// UI returns -1 for new save games
if (selected == -1)
{
if (hasNewData)
{
save_entry.dirName = listSet->newData->dirName.get_ptr();
}
else
{
// This happens if someone tries to load but there is no data selected. Some games will throw errors (Akiba) if cell_ok is returned
return CELL_CANCEL;
}
save_entry.dirName = listSet->newData->dirName.get_ptr();
}
// Cancel selected in UI
else if (selected == -2)
if (selected == -2)
{
return CELL_CANCEL;
}
if ((result->result == CELL_SAVEDATA_CBRESULT_OK_LAST) || (result->result == CELL_SAVEDATA_CBRESULT_OK_LAST_NOCONFIRM))
{
return CELL_OK;
}
}
if (funcFixed)