Make failure reasons translatable.

This commit is contained in:
The Dax 2013-06-24 04:24:34 -04:00
parent 1a7cce2fc5
commit a341d39720
2 changed files with 12 additions and 4 deletions

View File

@ -581,11 +581,12 @@ class CChunkFileReader
public:
// Load file template
template<class T>
static bool Load(const std::string& _rFilename, int _Revision, T& _class)
static bool Load(const std::string& _rFilename, int _Revision, T& _class, std::string* _failureReason)
{
INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
if (!File::Exists(_rFilename)) {
_failureReason->append("StateDoesntExist");
ERROR_LOG(COMMON, "ChunkReader: File doesn't exist");
return false;
}
@ -617,6 +618,7 @@ public:
// Check revision
if (header.Revision != _Revision)
{
_failureReason->append("StateWrongVersion");
ERROR_LOG(COMMON,"ChunkReader: Wrong file revision, got %d expected %d",
header.Revision, _Revision);
return false;

View File

@ -219,6 +219,9 @@ namespace SaveState
{
Operation &op = operations[i];
bool result;
std::string reason;
std::string fullMessage;
I18NCategory *s = GetI18NCategory("Screen");
switch (op.type)
@ -227,11 +230,14 @@ namespace SaveState
if (MIPSComp::jit)
MIPSComp::jit->ClearCache();
INFO_LOG(COMMON, "Loading state from %s", op.filename.c_str());
result = CChunkFileReader::Load(op.filename, REVISION, state);
result = CChunkFileReader::Load(op.filename, REVISION, state, &reason);
if(result)
osm.Show(s->T("LoadedState"), 2.0);
else
osm.Show(s->T("LoadStateFailed"), 2.0);
else {
fullMessage.append(s->T("LoadStateFailed"));
fullMessage.append(s->T(reason.c_str()));
osm.Show(fullMessage, 2.0);
}
break;
case SAVESTATE_SAVE: