System: Don't print whole path in save OSD messages

This commit is contained in:
Connor McLaughlin 2022-08-05 17:07:40 +10:00
parent 6bf0ad789e
commit 589785f8a0
2 changed files with 30 additions and 6 deletions

View File

@ -1,7 +1,9 @@
#include "memory_card.h"
#include "IconsFontAwesome5.h"
#include "common/byte_stream.h"
#include "common/file_system.h"
#include "common/log.h"
#include "common/path.h"
#include "common/string_util.h"
#include "host.h"
#include "system.h"
@ -305,13 +307,23 @@ bool MemoryCard::SaveIfChanged(bool display_osd_message)
if (m_filename.empty())
return false;
std::string osd_key;
std::string display_name;
if (display_osd_message)
{
osd_key = fmt::format("memory_card_save_{}", m_filename);
display_name = FileSystem::GetDisplayNameFromPath(m_filename);
}
if (!MemoryCardImage::SaveToFile(m_data, m_filename.c_str()))
{
if (display_osd_message)
{
Host::AddFormattedOSDMessage(
20.0f, Host::TranslateString("OSDMessage", "Failed to save memory card to '%s'"),
m_filename.c_str());
Host::AddIconOSDMessage(
std::move(osd_key), ICON_FA_SD_CARD,
fmt::format(Host::TranslateString("OSDMessage", "Failed to save memory card to '{}'.").GetCharArray(),
Path::GetFileName(display_name)),
20.0f);
}
return false;
@ -319,8 +331,11 @@ bool MemoryCard::SaveIfChanged(bool display_osd_message)
if (display_osd_message)
{
Host::AddFormattedOSDMessage(
2.0f, Host::TranslateString("OSDMessage", "Saved memory card to '%s'"), m_filename.c_str());
Host::AddIconOSDMessage(
std::move(osd_key), ICON_FA_SD_CARD,
fmt::format(Host::TranslateString("OSDMessage", "Saved memory card to '{}'.").GetCharArray(),
Path::GetFileName(display_name)),
5.0f);
}
return true;

View File

@ -1,4 +1,5 @@
#include "system.h"
#include "IconsFontAwesome5.h"
#include "achievements.h"
#include "bios.h"
#include "bus.h"
@ -953,7 +954,15 @@ bool System::LoadState(const char* filename)
return false;
Log_InfoPrintf("Loading state from '%s'...", filename);
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Loading state from '%s'..."), filename);
{
const std::string display_name(FileSystem::GetDisplayNameFromPath(filename));
Host::AddIconOSDMessage(
"load_state", ICON_FA_FOLDER_OPEN,
fmt::format(Host::TranslateString("OSDMessage", "Loading state from '{}'...").GetCharArray(),
Path::GetFileName(display_name)),
5.0f);
}
SaveUndoLoadState();