Common: Drop String, add SmallString
This commit is contained in:
+45
-47
@@ -25,7 +25,7 @@
|
||||
#include "common/path.h"
|
||||
#include "common/platform.h"
|
||||
#include "common/scoped_guard.h"
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
#include "common/string_util.h"
|
||||
|
||||
#include "util/cd_image.h"
|
||||
@@ -253,7 +253,7 @@ void Achievements::ReportRCError(int err, fmt::format_string<T...> fmt, T&&... a
|
||||
{
|
||||
TinyString str;
|
||||
fmt::vformat_to(std::back_inserter(str), fmt, fmt::make_format_args(args...));
|
||||
str.AppendFmtString("{} ({})", rc_error_str(err), err);
|
||||
str.append_fmt("{} ({})", rc_error_str(err), err);
|
||||
ReportError(str);
|
||||
}
|
||||
|
||||
@@ -1137,16 +1137,15 @@ void Achievements::HandleLeaderboardTrackerShowEvent(const rc_client_event_t* ev
|
||||
event->leaderboard_tracker->display);
|
||||
|
||||
TinyString width_string;
|
||||
width_string.AppendString(ICON_FA_STOPWATCH);
|
||||
width_string.append(ICON_FA_STOPWATCH);
|
||||
const u32 display_len = static_cast<u32>(std::strlen(event->leaderboard_tracker->display));
|
||||
for (u32 i = 0; i < display_len; i++)
|
||||
width_string.AppendCharacter('0');
|
||||
width_string.append('0');
|
||||
|
||||
LeaderboardTrackerIndicator indicator;
|
||||
indicator.tracker_id = event->leaderboard_tracker->id;
|
||||
indicator.size = ImGuiFullscreen::g_medium_font->CalcTextSizeA(
|
||||
ImGuiFullscreen::g_medium_font->FontSize, FLT_MAX, 0.0f, width_string.GetCharArray(),
|
||||
width_string.GetCharArray() + width_string.GetLength());
|
||||
indicator.size = ImGuiFullscreen::g_medium_font->CalcTextSizeA(ImGuiFullscreen::g_medium_font->FontSize, FLT_MAX,
|
||||
0.0f, width_string.c_str(), width_string.end_ptr());
|
||||
indicator.text = fmt::format(ICON_FA_STOPWATCH " {}", event->leaderboard_tracker->display);
|
||||
indicator.active = true;
|
||||
s_active_leaderboard_trackers.push_back(std::move(indicator));
|
||||
@@ -1495,8 +1494,8 @@ std::string Achievements::GetAchievementBadgePath(const rc_client_achievement_t*
|
||||
if (achievement->badge_name[0] == 0)
|
||||
return path;
|
||||
|
||||
path = Path::Combine(s_image_directory, TinyString::FromFmt("achievement_{}_{}_{}.png", s_game_id, achievement->id,
|
||||
s_achievement_state_strings[state]));
|
||||
path = Path::Combine(s_image_directory, TinyString::from_fmt("achievement_{}_{}_{}.png", s_game_id, achievement->id,
|
||||
s_achievement_state_strings[state]));
|
||||
|
||||
if (!FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
@@ -1517,7 +1516,7 @@ std::string Achievements::GetUserBadgePath(const std::string_view& username)
|
||||
std::string path;
|
||||
const std::string clean_username = Path::SanitizeFileName(username);
|
||||
if (!clean_username.empty())
|
||||
path = Path::Combine(s_image_directory, TinyString::FromFmt("user_{}.png", clean_username));
|
||||
path = Path::Combine(s_image_directory, TinyString::from_fmt("user_{}.png", clean_username));
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -2062,27 +2061,27 @@ void Achievements::DrawAchievementsWindow()
|
||||
}
|
||||
|
||||
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + g_large_font->FontSize));
|
||||
text = s_game_title;
|
||||
text.assign(s_game_title);
|
||||
|
||||
if (s_hardcore_mode)
|
||||
text.AppendString(TRANSLATE_SV("Achievements", " (Hardcore Mode)"));
|
||||
text.append(TRANSLATE_SV("Achievements", " (Hardcore Mode)"));
|
||||
|
||||
top += g_large_font->FontSize + spacing;
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, text.GetCharArray(), text.GetCharArray() + text.GetLength(),
|
||||
nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f),
|
||||
&title_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
|
||||
if (s_game_summary.num_unlocked_achievements == s_game_summary.num_core_achievements)
|
||||
{
|
||||
text.Fmt(TRANSLATE_FS("Achievements", "You have unlocked all achievements and earned {} points!"),
|
||||
text.fmt(TRANSLATE_FS("Achievements", "You have unlocked all achievements and earned {} points!"),
|
||||
s_game_summary.points_unlocked);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.Fmt(
|
||||
text.fmt(
|
||||
TRANSLATE_FS("Achievements", "You have unlocked {} of {} achievements, earning {} of {} possible points."),
|
||||
s_game_summary.num_unlocked_achievements, s_game_summary.num_core_achievements,
|
||||
s_game_summary.points_unlocked, s_game_summary.points_core);
|
||||
@@ -2091,8 +2090,8 @@ void Achievements::DrawAchievementsWindow()
|
||||
top += g_medium_font->FontSize + spacing;
|
||||
|
||||
ImGui::PushFont(g_medium_font);
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength(), nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, text.c_str(), text.end_ptr(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &summary_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
const float progress_height = ImGuiFullscreen::LayoutScale(20.0f);
|
||||
@@ -2104,14 +2103,13 @@ void Achievements::DrawAchievementsWindow()
|
||||
ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UISecondaryColor));
|
||||
|
||||
text.Fmt("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
text_size = ImGui::CalcTextSize(text.GetCharArray(), text.GetCharArray() + text.GetLength());
|
||||
text.fmt("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
text_size = ImGui::CalcTextSize(text.c_str(), text.end_ptr());
|
||||
const ImVec2 text_pos(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) -
|
||||
(text_size.y / 2.0f));
|
||||
dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos,
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryTextColor), text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength());
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryTextColor), text.c_str(), text.end_ptr());
|
||||
top += progress_height + spacing;
|
||||
}
|
||||
}
|
||||
@@ -2183,7 +2181,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
ImGuiFullscreen::MenuButtonFrame(TinyString::FromFmt("chv_{}", cheevo->id), true,
|
||||
ImGuiFullscreen::MenuButtonFrame(TinyString::from_fmt("chv_{}", cheevo->id), true,
|
||||
!is_measured ? ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT + unlock_size :
|
||||
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT +
|
||||
progress_height_unscaled + progress_spacing_unscaled,
|
||||
@@ -2219,12 +2217,12 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
SmallString text;
|
||||
|
||||
const float midpoint = bb.Min.y + g_large_font->FontSize + spacing;
|
||||
text.Fmt((cheevo->points != 1) ? TRANSLATE_FS("Achievements", "{} points") : TRANSLATE_FS("Achievements", "{} point"),
|
||||
text.fmt((cheevo->points != 1) ? TRANSLATE_FS("Achievements", "{} points") : TRANSLATE_FS("Achievements", "{} point"),
|
||||
cheevo->points);
|
||||
const ImVec2 points_template_size(
|
||||
g_medium_font->CalcTextSizeA(g_medium_font->FontSize, FLT_MAX, 0.0f, TRANSLATE("Achievements", "XXX points")));
|
||||
const ImVec2 points_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, FLT_MAX, 0.0f, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength()));
|
||||
const ImVec2 points_size(
|
||||
g_medium_font->CalcTextSizeA(g_medium_font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.end_ptr()));
|
||||
const float points_template_start = bb.Max.x - points_template_size.x;
|
||||
const float points_start = points_template_start + ((points_template_size.x - points_size.x) * 0.5f);
|
||||
const char* lock_text = is_unlocked ? ICON_FA_LOCK_OPEN : ICON_FA_LOCK;
|
||||
@@ -2248,18 +2246,18 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, cheevo->description, nullptr, nullptr, ImVec2(0.0f, 0.0f),
|
||||
&summary_bb);
|
||||
}
|
||||
ImGui::RenderTextClipped(points_bb.Min, points_bb.Max, text.GetCharArray(), text.GetCharArray() + text.GetLength(),
|
||||
&points_size, ImVec2(0.0f, 0.0f), &points_bb);
|
||||
ImGui::RenderTextClipped(points_bb.Min, points_bb.Max, text.c_str(), text.end_ptr(), &points_size, ImVec2(0.0f, 0.0f),
|
||||
&points_bb);
|
||||
|
||||
if (is_unlocked)
|
||||
{
|
||||
TinyString date;
|
||||
FullscreenUI::TimeToPrintableString(&date, cheevo->unlock_time);
|
||||
text.Fmt(TRANSLATE_FS("Achievements", "Unlocked: {}"), date);
|
||||
text.fmt(TRANSLATE_FS("Achievements", "Unlocked: {}"), date);
|
||||
|
||||
const ImRect unlock_bb(summary_bb.Min.x, summary_bb.Max.y + spacing, summary_bb.Max.x, bb.Max.y);
|
||||
ImGui::RenderTextClipped(unlock_bb.Min, unlock_bb.Max, text, text.GetCharArray() + text.GetLength(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &unlock_bb);
|
||||
ImGui::RenderTextClipped(unlock_bb.Min, unlock_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f),
|
||||
&unlock_bb);
|
||||
}
|
||||
else if (is_measured)
|
||||
{
|
||||
@@ -2399,43 +2397,43 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
}
|
||||
|
||||
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + g_large_font->FontSize));
|
||||
text.Assign(Achievements::GetGameTitle());
|
||||
text.assign(Achievements::GetGameTitle());
|
||||
|
||||
top += g_large_font->FontSize + spacing;
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, text.GetCharArray(), text.GetCharArray() + text.GetLength(),
|
||||
nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f),
|
||||
&title_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
if (is_leaderboard_open)
|
||||
{
|
||||
const ImRect subtitle_bb(ImVec2(left, top), ImVec2(right, top + g_large_font->FontSize));
|
||||
text.Assign(s_open_leaderboard->title);
|
||||
text.assign(s_open_leaderboard->title);
|
||||
|
||||
top += g_large_font->FontSize + spacing_small;
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::RenderTextClipped(subtitle_bb.Min, subtitle_bb.Max, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength(), nullptr, ImVec2(0.0f, 0.0f), &subtitle_bb);
|
||||
ImGui::RenderTextClipped(subtitle_bb.Min, subtitle_bb.Max, text.c_str(), text.end_ptr(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &subtitle_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
text.Assign(s_open_leaderboard->description);
|
||||
text.assign(s_open_leaderboard->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 count = 0;
|
||||
for (u32 i = 0; i < s_leaderboard_list->num_buckets; i++)
|
||||
count += s_leaderboard_list->buckets[i].num_leaderboards;
|
||||
text.Fmt(TRANSLATE_FS("Achievements", "This game has {} leaderboards."), count);
|
||||
text.fmt(TRANSLATE_FS("Achievements", "This game has {} leaderboards."), count);
|
||||
}
|
||||
|
||||
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
|
||||
top += g_medium_font->FontSize + spacing_small;
|
||||
|
||||
ImGui::PushFont(g_medium_font);
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength(), nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, text.c_str(), text.end_ptr(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &summary_bb);
|
||||
|
||||
if (!is_leaderboard_open && !Achievements::IsHardcoreModeActive())
|
||||
{
|
||||
@@ -2646,7 +2644,7 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
|
||||
float text_start_x = bb.Min.x + LayoutScale(15.0f);
|
||||
SmallString text;
|
||||
|
||||
text.Format("%u", entry.rank);
|
||||
text.fmt("{}", entry.rank);
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
|
||||
@@ -2654,8 +2652,8 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 242, 0, 255));
|
||||
|
||||
const ImRect rank_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
ImGui::RenderTextClipped(rank_bb.Min, rank_bb.Max, text.GetCharArray(), text.GetCharArray() + text.GetLength(),
|
||||
nullptr, ImVec2(0.0f, 0.0f), &rank_bb);
|
||||
ImGui::RenderTextClipped(rank_bb.Min, rank_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f),
|
||||
&rank_bb);
|
||||
text_start_x += rank_column_width + column_spacing;
|
||||
|
||||
const float icon_size = bb.Max.y - bb.Min.y;
|
||||
@@ -2694,8 +2692,8 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
|
||||
const ImRect time_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
SmallString submit_time;
|
||||
FullscreenUI::TimeToPrintableString(&submit_time, entry.submitted);
|
||||
ImGui::RenderTextClipped(time_bb.Min, time_bb.Max, submit_time.GetCharArray(),
|
||||
submit_time.GetCharArray() + submit_time.GetLength(), nullptr, ImVec2(0.0f, 0.0f), &time_bb);
|
||||
ImGui::RenderTextClipped(time_bb.Min, time_bb.Max, submit_time.c_str(), submit_time.end_ptr(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &time_bb);
|
||||
|
||||
if (is_self)
|
||||
ImGui::PopStyleColor();
|
||||
@@ -2716,7 +2714,7 @@ void Achievements::DrawLeaderboardListEntry(const rc_client_leaderboard_t* lboar
|
||||
static constexpr float alpha = 0.8f;
|
||||
|
||||
TinyString id_str;
|
||||
id_str.Format("%u", lboard->id);
|
||||
id_str.fmt("{}", lboard->id);
|
||||
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
#include "common/types.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ void BIOS::PatchBIOS(u8* image, u32 image_size, u32 address, u32 value, u32 mask
|
||||
CPU::DisassembleInstruction(&old_disasm, address, existing_value);
|
||||
CPU::DisassembleInstruction(&new_disasm, address, new_value);
|
||||
Log_DevPrintf("BIOS-Patch 0x%08X (+0x%X): 0x%08X %s -> %08X %s", address, offset, existing_value,
|
||||
old_disasm.GetCharArray(), new_value, new_disasm.GetCharArray());
|
||||
old_disasm.c_str(), new_value, new_disasm.c_str());
|
||||
}
|
||||
|
||||
bool BIOS::PatchBIOSFastBoot(u8* image, u32 image_size)
|
||||
|
||||
+9
-9
@@ -770,22 +770,22 @@ static TickCount DoInvalidAccess(MemoryAccessType type, MemoryAccessSize size, P
|
||||
u32& value)
|
||||
{
|
||||
SmallString str;
|
||||
str.AppendString("Invalid bus ");
|
||||
str.append("Invalid bus ");
|
||||
if (size == MemoryAccessSize::Byte)
|
||||
str.AppendString("byte");
|
||||
str.append("byte");
|
||||
if (size == MemoryAccessSize::HalfWord)
|
||||
str.AppendString("word");
|
||||
str.append("word");
|
||||
if (size == MemoryAccessSize::Word)
|
||||
str.AppendString("dword");
|
||||
str.AppendCharacter(' ');
|
||||
str.append("dword");
|
||||
str.append(' ');
|
||||
if (type == MemoryAccessType::Read)
|
||||
str.AppendString("read");
|
||||
str.append("read");
|
||||
else
|
||||
str.AppendString("write");
|
||||
str.append("write");
|
||||
|
||||
str.AppendFormattedString(" at address 0x%08X", address);
|
||||
str.append_fmt(" at address 0x{:08X}", address);
|
||||
if (type == MemoryAccessType::Write)
|
||||
str.AppendFormattedString(" (value 0x%08X)", value);
|
||||
str.append_fmt(" (value 0x{:08X})", value);
|
||||
|
||||
Log_ErrorPrint(str);
|
||||
if (type == MemoryAccessType::Read)
|
||||
|
||||
+5
-6
@@ -803,7 +803,7 @@ bool CDROM::PrecacheMedia()
|
||||
TinyString CDROM::LBAToMSFString(CDImage::LBA lba)
|
||||
{
|
||||
const auto pos = CDImage::Position::FromLBA(lba);
|
||||
return TinyString::FromFmt("{:02d}:{:02d}:{:02d}", pos.minute, pos.second, pos.frame);
|
||||
return TinyString::from_fmt("{:02d}:{:02d}:{:02d}", pos.minute, pos.second, pos.frame);
|
||||
}
|
||||
|
||||
void CDROM::SetReadaheadSectors(u32 readahead_sectors)
|
||||
@@ -2436,7 +2436,7 @@ void CDROM::UpdatePhysicalPosition(bool update_logical)
|
||||
const CDImage::LBA new_physical_lba = base + new_offset;
|
||||
#ifdef _DEBUG
|
||||
Log_DevPrintf("Tick diff %u, sector diff %u, old pos %s, new pos %s", diff, sector_diff,
|
||||
LBAToMSFString(s_physical_lba).GetCharArray(), LBAToMSFString(new_physical_lba).GetCharArray());
|
||||
LBAToMSFString(s_physical_lba).c_str(), LBAToMSFString(new_physical_lba).c_str());
|
||||
#endif
|
||||
if (s_physical_lba != new_physical_lba)
|
||||
{
|
||||
@@ -2575,7 +2575,7 @@ void CDROM::DoSeekComplete(TickCount ticks_late)
|
||||
else
|
||||
{
|
||||
Log_WarningPrintf("%s seek to [%s] failed", logical ? "Logical" : "Physical",
|
||||
LBAToMSFString(m_reader.GetLastReadSector()).GetCharArray());
|
||||
LBAToMSFString(m_reader.GetLastReadSector()).c_str());
|
||||
s_secondary_status.ClearActiveBits();
|
||||
SendAsyncErrorResponse(STAT_SEEK_ERROR, 0x04);
|
||||
s_last_sector_header_valid = false;
|
||||
@@ -2733,8 +2733,7 @@ void CDROM::DoSectorRead()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_DevPrintf("Sector %u [%s] has invalid subchannel Q", s_current_lba,
|
||||
LBAToMSFString(s_current_lba).GetCharArray());
|
||||
Log_DevPrintf("Sector %u [%s] has invalid subchannel Q", s_current_lba, LBAToMSFString(s_current_lba).c_str());
|
||||
}
|
||||
|
||||
if (subq.track_number_bcd == CDImage::LEAD_OUT_TRACK_NUMBER)
|
||||
@@ -2806,7 +2805,7 @@ void CDROM::ProcessDataSector(const u8* raw_sector, const CDImage::SubChannelQ&
|
||||
{
|
||||
const u32 sb_num = (s_current_write_sector_buffer + 1) % NUM_SECTOR_BUFFERS;
|
||||
Log_DevPrintf("Read sector %u [%s]: mode %u submode 0x%02X into buffer %u", s_current_lba,
|
||||
LBAToMSFString(s_current_lba).GetCharArray(), ZeroExtend32(s_last_sector_header.sector_mode),
|
||||
LBAToMSFString(s_current_lba).c_str(), ZeroExtend32(s_last_sector_header.sector_mode),
|
||||
ZeroExtend32(s_last_sector_subheader.submode.bits), sb_num);
|
||||
|
||||
if (s_mode.xa_enable && s_last_sector_header.sector_mode == 2)
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
#include "common/byte_stream.h"
|
||||
#include "common/file_system.h"
|
||||
#include "common/log.h"
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
#include "common/string_util.h"
|
||||
#include "controller.h"
|
||||
#include "cpu_code_cache.h"
|
||||
@@ -397,9 +397,9 @@ bool CheatList::LoadFromLibretroString(const std::string& str)
|
||||
|
||||
for (u32 i = 0; i < num_cheats; i++)
|
||||
{
|
||||
const std::string* desc = FindKey(kvp, TinyString::FromFormat("cheat%u_desc", i));
|
||||
const std::string* code = FindKey(kvp, TinyString::FromFormat("cheat%u_code", i));
|
||||
const std::string* enable = FindKey(kvp, TinyString::FromFormat("cheat%u_enable", i));
|
||||
const std::string* desc = FindKey(kvp, TinyString::from_fmt("cheat{}_desc", i));
|
||||
const std::string* code = FindKey(kvp, TinyString::from_fmt("cheat{}_code", i));
|
||||
const std::string* enable = FindKey(kvp, TinyString::from_fmt("cheat{}_enable", i));
|
||||
if (!desc || !code || !enable)
|
||||
{
|
||||
Log_WarningPrintf("Missing desc/code/enable for cheat %u", i);
|
||||
|
||||
@@ -799,7 +799,7 @@ bool CompileBlock(CodeBlock* block, bool allow_flush)
|
||||
{
|
||||
CPU::DisassembleInstruction(&disasm, cbi.pc, cbi.instruction.bits);
|
||||
Log_DebugPrintf("[%s %s 0x%08X] %08X %s", cbi.is_branch_delay_slot ? "BD" : " ",
|
||||
cbi.is_load_delay_slot ? "LD" : " ", cbi.pc, cbi.instruction.bits, disasm.GetCharArray());
|
||||
cbi.is_load_delay_slot ? "LD" : " ", cbi.pc, cbi.instruction.bits, disasm.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+18
-18
@@ -571,15 +571,15 @@ static void TracePrintInstruction()
|
||||
TinyString comment;
|
||||
DisassembleInstruction(&instr, pc, bits);
|
||||
DisassembleInstructionComment(&comment, pc, bits, &g_state.regs);
|
||||
if (!comment.IsEmpty())
|
||||
if (!comment.empty())
|
||||
{
|
||||
for (u32 i = instr.GetLength(); i < 30; i++)
|
||||
instr.AppendCharacter(' ');
|
||||
instr.AppendString("; ");
|
||||
instr.AppendString(comment);
|
||||
for (u32 i = instr.length(); i < 30; i++)
|
||||
instr.append(' ');
|
||||
instr.append("; ");
|
||||
instr.append(comment);
|
||||
}
|
||||
|
||||
std::printf("%08x: %08x %s\n", pc, bits, instr.GetCharArray());
|
||||
std::printf("%08x: %08x %s\n", pc, bits, instr.c_str());
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -590,15 +590,15 @@ static void PrintInstruction(u32 bits, u32 pc, Registers* regs, const char* pref
|
||||
TinyString comment;
|
||||
DisassembleInstruction(&instr, pc, bits);
|
||||
DisassembleInstructionComment(&comment, pc, bits, regs);
|
||||
if (!comment.IsEmpty())
|
||||
if (!comment.empty())
|
||||
{
|
||||
for (u32 i = instr.GetLength(); i < 30; i++)
|
||||
instr.AppendCharacter(' ');
|
||||
instr.AppendString("; ");
|
||||
instr.AppendString(comment);
|
||||
for (u32 i = instr.length(); i < 30; i++)
|
||||
instr.append(' ');
|
||||
instr.append("; ");
|
||||
instr.append(comment);
|
||||
}
|
||||
|
||||
Log_DevPrintf("%s%08x: %08x %s", prefix, pc, bits, instr.GetCharArray());
|
||||
Log_DevPrintf("%s%08x: %08x %s", prefix, pc, bits, instr.c_str());
|
||||
}
|
||||
|
||||
static void LogInstruction(u32 bits, u32 pc, Registers* regs)
|
||||
@@ -607,15 +607,15 @@ static void LogInstruction(u32 bits, u32 pc, Registers* regs)
|
||||
TinyString comment;
|
||||
DisassembleInstruction(&instr, pc, bits);
|
||||
DisassembleInstructionComment(&comment, pc, bits, regs);
|
||||
if (!comment.IsEmpty())
|
||||
if (!comment.empty())
|
||||
{
|
||||
for (u32 i = instr.GetLength(); i < 30; i++)
|
||||
instr.AppendCharacter(' ');
|
||||
instr.AppendString("; ");
|
||||
instr.AppendString(comment);
|
||||
for (u32 i = instr.length(); i < 30; i++)
|
||||
instr.append(' ');
|
||||
instr.append("; ");
|
||||
instr.append(comment);
|
||||
}
|
||||
|
||||
WriteToExecutionLog("%08x: %08x %s\n", pc, bits, instr.GetCharArray());
|
||||
WriteToExecutionLog("%08x: %08x %s\n", pc, bits, instr.c_str());
|
||||
}
|
||||
|
||||
static void HandleWriteSyscall()
|
||||
|
||||
+39
-36
@@ -1,9 +1,12 @@
|
||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "cpu_disasm.h"
|
||||
#include "common/assert.h"
|
||||
#include "cpu_core.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/small_string.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace CPU {
|
||||
@@ -169,9 +172,9 @@ static const std::array<std::pair<CopCommonInstruction, const char*>, 4> s_cop_c
|
||||
|
||||
static const std::array<std::pair<Cop0Instruction, const char*>, 1> s_cop0_table = {{{Cop0Instruction::rfe, "rfe"}}};
|
||||
|
||||
static void FormatInstruction(String* dest, const Instruction inst, u32 pc, const char* format)
|
||||
static void FormatInstruction(SmallStringBase* dest, const Instruction inst, u32 pc, const char* format)
|
||||
{
|
||||
dest->Clear();
|
||||
dest->clear();
|
||||
|
||||
const char* str = format;
|
||||
while (*str != '\0')
|
||||
@@ -179,77 +182,77 @@ static void FormatInstruction(String* dest, const Instruction inst, u32 pc, cons
|
||||
const char ch = *(str++);
|
||||
if (ch != '$')
|
||||
{
|
||||
dest->AppendCharacter(ch);
|
||||
dest->append(ch);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::strncmp(str, "rs", 2) == 0)
|
||||
{
|
||||
dest->AppendString(GetRegName(inst.r.rs));
|
||||
dest->append(GetRegName(inst.r.rs));
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "rt", 2) == 0)
|
||||
{
|
||||
dest->AppendString(GetRegName(inst.r.rt));
|
||||
dest->append(GetRegName(inst.r.rt));
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "rd", 2) == 0)
|
||||
{
|
||||
dest->AppendString(GetRegName(inst.r.rd));
|
||||
dest->append(GetRegName(inst.r.rd));
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "shamt", 5) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%d", ZeroExtend32(inst.r.shamt.GetValue()));
|
||||
dest->append_fmt("{}", ZeroExtend32(inst.r.shamt.GetValue()));
|
||||
str += 5;
|
||||
}
|
||||
else if (std::strncmp(str, "immu", 4) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%u", inst.i.imm_zext32());
|
||||
dest->append_fmt("{}", inst.i.imm_zext32());
|
||||
str += 4;
|
||||
}
|
||||
else if (std::strncmp(str, "imm", 3) == 0)
|
||||
{
|
||||
// dest->AppendFormattedString("%d", static_cast<int>(inst.i.imm_sext32()));
|
||||
dest->AppendFormattedString("%04x", inst.i.imm_zext32());
|
||||
dest->append_fmt("{:04x}", inst.i.imm_zext32());
|
||||
str += 3;
|
||||
}
|
||||
else if (std::strncmp(str, "rel", 3) == 0)
|
||||
{
|
||||
const u32 target = (pc + UINT32_C(4)) + (inst.i.imm_sext32() << 2);
|
||||
dest->AppendFormattedString("%08x", target);
|
||||
dest->append_fmt("{:08x}", target);
|
||||
str += 3;
|
||||
}
|
||||
else if (std::strncmp(str, "offsetrs", 8) == 0)
|
||||
{
|
||||
const s32 offset = static_cast<s32>(inst.i.imm_sext32());
|
||||
dest->AppendFormattedString("%d(%s)", offset, GetRegName(inst.i.rs));
|
||||
dest->append_fmt("{}({})", offset, GetRegName(inst.i.rs));
|
||||
str += 8;
|
||||
}
|
||||
else if (std::strncmp(str, "jt", 2) == 0)
|
||||
{
|
||||
const u32 target = ((pc + UINT32_C(4)) & UINT32_C(0xF0000000)) | (inst.j.target << 2);
|
||||
dest->AppendFormattedString("%08x", target);
|
||||
dest->append_fmt("{:08x}", target);
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "copcc", 5) == 0)
|
||||
{
|
||||
dest->AppendCharacter(((inst.bits & (UINT32_C(1) << 24)) != 0) ? 't' : 'f');
|
||||
dest->append(((inst.bits & (UINT32_C(1) << 24)) != 0) ? 't' : 'f');
|
||||
str += 5;
|
||||
}
|
||||
else if (std::strncmp(str, "coprd", 5) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%u", ZeroExtend32(static_cast<u8>(inst.r.rd.GetValue())));
|
||||
dest->append_fmt("{}", ZeroExtend32(static_cast<u8>(inst.r.rd.GetValue())));
|
||||
str += 5;
|
||||
}
|
||||
else if (std::strncmp(str, "coprt", 5) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%u", ZeroExtend32(static_cast<u8>(inst.r.rt.GetValue())));
|
||||
dest->append_fmt("{}", ZeroExtend32(static_cast<u8>(inst.r.rt.GetValue())));
|
||||
str += 5;
|
||||
}
|
||||
else if (std::strncmp(str, "cop", 3) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%u", static_cast<u8>(inst.op.GetValue()) & INSTRUCTION_COP_N_MASK);
|
||||
dest->append_fmt("{}", static_cast<u8>(inst.op.GetValue()) & INSTRUCTION_COP_N_MASK);
|
||||
str += 3;
|
||||
}
|
||||
else
|
||||
@@ -259,7 +262,7 @@ static void FormatInstruction(String* dest, const Instruction inst, u32 pc, cons
|
||||
}
|
||||
}
|
||||
|
||||
static void FormatComment(String* dest, const Instruction inst, u32 pc, Registers* regs, const char* format)
|
||||
static void FormatComment(SmallStringBase* dest, const Instruction inst, u32 pc, Registers* regs, const char* format)
|
||||
{
|
||||
const char* str = format;
|
||||
while (*str != '\0')
|
||||
@@ -270,21 +273,21 @@ static void FormatComment(String* dest, const Instruction inst, u32 pc, Register
|
||||
|
||||
if (std::strncmp(str, "rs", 2) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%s%s=0x%08X", dest->IsEmpty() ? "" : ", ", GetRegName(inst.r.rs),
|
||||
regs->r[static_cast<u8>(inst.r.rs.GetValue())]);
|
||||
dest->append_fmt("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rs),
|
||||
regs->r[static_cast<u8>(inst.r.rs.GetValue())]);
|
||||
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "rt", 2) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%s%s=0x%08X", dest->IsEmpty() ? "" : ", ", GetRegName(inst.r.rt),
|
||||
regs->r[static_cast<u8>(inst.r.rt.GetValue())]);
|
||||
dest->append_fmt("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rt),
|
||||
regs->r[static_cast<u8>(inst.r.rt.GetValue())]);
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "rd", 2) == 0)
|
||||
{
|
||||
dest->AppendFormattedString("%s%s=0x%08X", dest->IsEmpty() ? "" : ", ", GetRegName(inst.r.rd),
|
||||
regs->r[static_cast<u8>(inst.r.rd.GetValue())]);
|
||||
dest->append_fmt("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rd),
|
||||
regs->r[static_cast<u8>(inst.r.rd.GetValue())]);
|
||||
str += 2;
|
||||
}
|
||||
else if (std::strncmp(str, "shamt", 5) == 0)
|
||||
@@ -306,8 +309,8 @@ static void FormatComment(String* dest, const Instruction inst, u32 pc, Register
|
||||
else if (std::strncmp(str, "offsetrs", 8) == 0)
|
||||
{
|
||||
const s32 offset = static_cast<s32>(inst.i.imm_sext32());
|
||||
dest->AppendFormattedString("%saddr=0x%08X", dest->IsEmpty() ? "" : ", ",
|
||||
regs->r[static_cast<u8>(inst.i.rs.GetValue())] + offset);
|
||||
dest->append_fmt("{}addr={:08X}", dest->empty() ? "" : ", ",
|
||||
regs->r[static_cast<u8>(inst.i.rs.GetValue())] + offset);
|
||||
str += 8;
|
||||
}
|
||||
else if (std::strncmp(str, "jt", 2) == 0)
|
||||
@@ -338,8 +341,8 @@ static void FormatComment(String* dest, const Instruction inst, u32 pc, Register
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void FormatCopInstruction(String* dest, u32 pc, const Instruction inst, const std::pair<T, const char*>* table,
|
||||
size_t table_size, T table_key)
|
||||
static void FormatCopInstruction(SmallStringBase* dest, u32 pc, const Instruction inst,
|
||||
const std::pair<T, const char*>* table, size_t table_size, T table_key)
|
||||
{
|
||||
for (size_t i = 0; i < table_size; i++)
|
||||
{
|
||||
@@ -350,12 +353,12 @@ void FormatCopInstruction(String* dest, u32 pc, const Instruction inst, const st
|
||||
}
|
||||
}
|
||||
|
||||
dest->Format("<cop%u 0x%08X>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
|
||||
dest->fmt("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void FormatCopComment(String* dest, u32 pc, Registers* regs, const Instruction inst,
|
||||
const std::pair<T, const char*>* table, size_t table_size, T table_key)
|
||||
static void FormatCopComment(SmallStringBase* dest, u32 pc, Registers* regs, const Instruction inst,
|
||||
const std::pair<T, const char*>* table, size_t table_size, T table_key)
|
||||
{
|
||||
for (size_t i = 0; i < table_size; i++)
|
||||
{
|
||||
@@ -367,7 +370,7 @@ void FormatCopComment(String* dest, u32 pc, Registers* regs, const Instruction i
|
||||
}
|
||||
}
|
||||
|
||||
void DisassembleInstruction(String* dest, u32 pc, u32 bits)
|
||||
void DisassembleInstruction(SmallStringBase* dest, u32 pc, u32 bits)
|
||||
{
|
||||
const Instruction inst{bits};
|
||||
switch (inst.op)
|
||||
@@ -400,7 +403,7 @@ void DisassembleInstruction(String* dest, u32 pc, u32 bits)
|
||||
case InstructionOp::cop3:
|
||||
default:
|
||||
{
|
||||
dest->Format("<cop%u 0x%08X>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
|
||||
dest->fmt("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -427,7 +430,7 @@ void DisassembleInstruction(String* dest, u32 pc, u32 bits)
|
||||
}
|
||||
}
|
||||
|
||||
void DisassembleInstructionComment(String* dest, u32 pc, u32 bits, Registers* regs)
|
||||
void DisassembleInstructionComment(SmallStringBase* dest, u32 pc, u32 bits, Registers* regs)
|
||||
{
|
||||
const Instruction inst{bits};
|
||||
switch (inst.op)
|
||||
@@ -461,7 +464,7 @@ void DisassembleInstructionComment(String* dest, u32 pc, u32 bits, Registers* re
|
||||
case InstructionOp::cop3:
|
||||
default:
|
||||
{
|
||||
dest->Format("<cop%u 0x%08X>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
|
||||
dest->fmt("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#pragma once
|
||||
#include "common/string.h"
|
||||
#include "cpu_types.h"
|
||||
|
||||
class SmallStringBase;
|
||||
|
||||
namespace CPU {
|
||||
void DisassembleInstruction(String* dest, u32 pc, u32 bits);
|
||||
void DisassembleInstructionComment(String* dest, u32 pc, u32 bits, Registers* regs);
|
||||
void DisassembleInstruction(SmallStringBase* dest, u32 pc, u32 bits);
|
||||
void DisassembleInstructionComment(SmallStringBase* dest, u32 pc, u32 bits, Registers* regs);
|
||||
} // namespace CPU
|
||||
|
||||
+95
-107
@@ -32,7 +32,7 @@
|
||||
#include "common/log.h"
|
||||
#include "common/make_array.h"
|
||||
#include "common/path.h"
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/threading.h"
|
||||
|
||||
@@ -54,19 +54,23 @@ Log_SetChannel(FullscreenUI);
|
||||
|
||||
#define TR_CONTEXT "FullscreenUI"
|
||||
|
||||
namespace FullscreenUI {
|
||||
namespace {
|
||||
template<size_t L>
|
||||
class IconStackString : public StackString<L>
|
||||
class IconStackString : public SmallStackString<L>
|
||||
{
|
||||
public:
|
||||
ALWAYS_INLINE IconStackString(const char* icon, const char* str)
|
||||
{
|
||||
StackString<L>::Fmt("{} {}", icon, Host::TranslateToStringView(TR_CONTEXT, str));
|
||||
SmallStackString<L>::fmt("{} {}", icon, Host::TranslateToStringView(TR_CONTEXT, str));
|
||||
}
|
||||
ALWAYS_INLINE IconStackString(const char* icon, const char* str, const char* suffix)
|
||||
{
|
||||
SmallStackString<L>::fmt("{} {}##{}", icon, Host::TranslateToStringView(TR_CONTEXT, str), suffix);
|
||||
}
|
||||
};
|
||||
} // namespace FullscreenUI
|
||||
} // namespace
|
||||
|
||||
#define FSUI_ICONSTR(icon, str) FullscreenUI::IconStackString<128>(icon, str).GetCharArray()
|
||||
#define FSUI_ICONSTR(icon, str) IconStackString<128>(icon, str).c_str()
|
||||
#define FSUI_STR(str) Host::TranslateToString(TR_CONTEXT, str)
|
||||
#define FSUI_CSTR(str) Host::TranslateToCString(TR_CONTEXT, str)
|
||||
#define FSUI_VSTR(str) Host::TranslateToStringView(TR_CONTEXT, str)
|
||||
@@ -472,7 +476,7 @@ static GameListPage s_game_list_page = GameListPage::Grid;
|
||||
// Utility
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FullscreenUI::TimeToPrintableString(String* str, time_t t)
|
||||
void FullscreenUI::TimeToPrintableString(SmallStringBase* str, time_t t)
|
||||
{
|
||||
struct tm lt = {};
|
||||
#ifdef _MSC_VER
|
||||
@@ -483,7 +487,7 @@ void FullscreenUI::TimeToPrintableString(String* str, time_t t)
|
||||
|
||||
char buf[256];
|
||||
std::strftime(buf, sizeof(buf), "%c", <);
|
||||
str->Assign(buf);
|
||||
str->assign(buf);
|
||||
}
|
||||
|
||||
void FullscreenUI::StartAsyncOp(std::function<void(::ProgressCallback*)> callback, std::string name)
|
||||
@@ -1342,7 +1346,7 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
|
||||
const char* name, const char* display_name, bool show_type)
|
||||
{
|
||||
TinyString title;
|
||||
title.Fmt("{}/{}", section, name);
|
||||
title.fmt("{}/{}", section, name);
|
||||
|
||||
ImRect bb;
|
||||
bool visible, hovered, clicked;
|
||||
@@ -1360,17 +1364,17 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
|
||||
switch (type)
|
||||
{
|
||||
case InputBindingInfo::Type::Button:
|
||||
title = fmt::format(ICON_FA_DOT_CIRCLE "{}", display_name);
|
||||
title.fmt(ICON_FA_DOT_CIRCLE "{}", display_name);
|
||||
break;
|
||||
case InputBindingInfo::Type::Axis:
|
||||
case InputBindingInfo::Type::HalfAxis:
|
||||
title = fmt::format(ICON_FA_BULLSEYE "{}", display_name);
|
||||
title.fmt(ICON_FA_BULLSEYE "{}", display_name);
|
||||
break;
|
||||
case InputBindingInfo::Type::Motor:
|
||||
title = fmt::format(ICON_FA_BELL "{}", display_name);
|
||||
title.fmt(ICON_FA_BELL "{}", display_name);
|
||||
break;
|
||||
case InputBindingInfo::Type::Macro:
|
||||
title = fmt::format(ICON_FA_PIZZA_SLICE "{}", display_name);
|
||||
title.fmt(ICON_FA_PIZZA_SLICE "{}", display_name);
|
||||
break;
|
||||
default:
|
||||
title = display_name;
|
||||
@@ -1379,8 +1383,8 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
|
||||
}
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, show_type ? title.GetCharArray() : display_name, nullptr,
|
||||
nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, show_type ? title.c_str() : display_name, nullptr, nullptr,
|
||||
ImVec2(0.0f, 0.0f), &title_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
const std::string value(bsi->GetStringValue(section, name));
|
||||
@@ -1521,12 +1525,12 @@ void FullscreenUI::DrawInputBindingWindow()
|
||||
if (ImGui::BeginPopupModal(title, nullptr,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoInputs))
|
||||
{
|
||||
ImGui::TextWrapped("%s", SmallString::FromFmt(FSUI_FSTR("Setting {} binding {}."), s_input_binding_section,
|
||||
s_input_binding_display_name)
|
||||
.GetCharArray());
|
||||
ImGui::TextWrapped("%s", SmallString::from_fmt(FSUI_FSTR("Setting {} binding {}."), s_input_binding_section,
|
||||
s_input_binding_display_name)
|
||||
.c_str());
|
||||
ImGui::TextUnformatted(FSUI_CSTR("Push a controller button or axis now."));
|
||||
ImGui::NewLine();
|
||||
ImGui::TextUnformatted(SmallString::FromFmt(FSUI_FSTR("Timing out in {:.0f} seconds..."), time_remaining));
|
||||
ImGui::TextUnformatted(SmallString::from_fmt(FSUI_FSTR("Timing out in {:.0f} seconds..."), time_remaining));
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
@@ -2004,7 +2008,7 @@ void FullscreenUI::DrawIntSpinBoxSetting(SettingsInterface* bsi, const char* tit
|
||||
bsi->GetOptionalIntValue(section, key, game_settings ? std::nullopt : std::optional<int>(default_value));
|
||||
TinyString value_text;
|
||||
if (value.has_value())
|
||||
value_text.Format(format, value.value());
|
||||
value_text.format(format, value.value());
|
||||
else
|
||||
value_text = FSUI_VSTR("Use Global Setting");
|
||||
|
||||
@@ -2821,14 +2825,14 @@ void FullscreenUI::DrawBIOSSettingsPage()
|
||||
continue;
|
||||
|
||||
TinyString title;
|
||||
title.Fmt(FSUI_FSTR("BIOS for {}"), Settings::GetConsoleRegionDisplayName(region));
|
||||
title.fmt(FSUI_FSTR("BIOS for {}"), Settings::GetConsoleRegionDisplayName(region));
|
||||
|
||||
const std::optional<std::string> filename(bsi->GetOptionalStringValue(
|
||||
"BIOS", config_keys[i], game_settings ? std::nullopt : std::optional<const char*>("")));
|
||||
|
||||
if (MenuButtonWithValue(title,
|
||||
SmallString::FromFmt(FSUI_FSTR("BIOS to use when emulating {} consoles."),
|
||||
Settings::GetConsoleRegionDisplayName(region)),
|
||||
SmallString::from_fmt(FSUI_FSTR("BIOS to use when emulating {} consoles."),
|
||||
Settings::GetConsoleRegionDisplayName(region)),
|
||||
filename.has_value() ? (filename->empty() ? FSUI_CSTR("Auto-Detect") : filename->c_str()) :
|
||||
FSUI_CSTR("Use Global Setting")))
|
||||
{
|
||||
@@ -3052,7 +3056,7 @@ void FullscreenUI::DrawEmulationSettingsPage()
|
||||
|
||||
u64 ram_usage, vram_usage;
|
||||
System::CalculateRewindMemoryUsage(rewind_save_slots, &ram_usage, &vram_usage);
|
||||
rewind_summary.Fmt(
|
||||
rewind_summary.fmt(
|
||||
FSUI_FSTR("Rewind for {0} frames, lasting {1:.2f} seconds will require up to {3} MB of RAM and {4} MB of VRAM."),
|
||||
rewind_save_slots, duration, ram_usage / 1048576, vram_usage / 1048576);
|
||||
}
|
||||
@@ -3277,18 +3281,18 @@ void FullscreenUI::DrawControllerSettingsPage()
|
||||
|
||||
if (mtap_enabled[mtap_port])
|
||||
{
|
||||
MenuHeading(TinyString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}{}")), mtap_port + 1,
|
||||
mtap_slot_names[mtap_slot]));
|
||||
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}{}")), mtap_port + 1,
|
||||
mtap_slot_names[mtap_slot]));
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuHeading(TinyString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}")), mtap_port + 1));
|
||||
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}")), mtap_port + 1));
|
||||
}
|
||||
|
||||
const std::string section(fmt::format("Pad{}", global_slot + 1));
|
||||
const std::string type(bsi->GetStringValue(section.c_str(), "Type", Controller::GetDefaultPadType(global_slot)));
|
||||
const Controller::ControllerInfo* ci = Controller::GetControllerInfo(type);
|
||||
if (MenuButton(TinyString::FromFmt("{}##type{}", FSUI_ICONSTR(ICON_FA_GAMEPAD, "Controller Type"), global_slot),
|
||||
if (MenuButton(TinyString::from_fmt("{}##type{}", FSUI_ICONSTR(ICON_FA_GAMEPAD, "Controller Type"), global_slot),
|
||||
ci ? ci->display_name : FSUI_CSTR("Unknown")))
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> raw_options(Controller::GetControllerTypeNames());
|
||||
@@ -3298,7 +3302,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
||||
{
|
||||
options.emplace_back(std::move(it.second), type == it.first);
|
||||
}
|
||||
OpenChoiceDialog(TinyString::FromFmt(FSUI_FSTR("Port {} Controller Type"), global_slot + 1), false,
|
||||
OpenChoiceDialog(TinyString::from_fmt(FSUI_FSTR("Port {} Controller Type"), global_slot + 1), false,
|
||||
std::move(options),
|
||||
[game_settings, section,
|
||||
raw_options = std::move(raw_options)](s32 index, const std::string& title, bool checked) {
|
||||
@@ -3327,25 +3331,25 @@ void FullscreenUI::DrawControllerSettingsPage()
|
||||
|
||||
if (mtap_enabled[mtap_port])
|
||||
{
|
||||
MenuHeading(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {}{} Macros")),
|
||||
mtap_port + 1, mtap_slot_names[mtap_slot]));
|
||||
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {}{} Macros")),
|
||||
mtap_port + 1, mtap_slot_names[mtap_slot]));
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuHeading(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {} Macros")),
|
||||
mtap_port + 1));
|
||||
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {} Macros")),
|
||||
mtap_port + 1));
|
||||
}
|
||||
|
||||
for (u32 macro_index = 0; macro_index < InputManager::NUM_MACRO_BUTTONS_PER_CONTROLLER; macro_index++)
|
||||
{
|
||||
DrawInputBindingButton(bsi, InputBindingInfo::Type::Macro, section.c_str(),
|
||||
TinyString::FromFmt("Macro{}", macro_index + 1),
|
||||
TinyString::FromFmt(FSUI_FSTR("Macro {} Trigger"), macro_index + 1));
|
||||
TinyString::from_fmt("Macro{}", macro_index + 1),
|
||||
TinyString::from_fmt(FSUI_FSTR("Macro {} Trigger"), macro_index + 1));
|
||||
|
||||
std::string binds_string(
|
||||
bsi->GetStringValue(section.c_str(), fmt::format("Macro{}Binds", macro_index + 1).c_str()));
|
||||
if (MenuButton(
|
||||
TinyString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_KEYBOARD, "Macro {} Buttons")), macro_index + 1),
|
||||
TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_KEYBOARD, "Macro {} Buttons")), macro_index + 1),
|
||||
binds_string.empty() ? FSUI_CSTR("No Buttons Selected") : binds_string.c_str()))
|
||||
{
|
||||
std::vector<std::string_view> buttons_split(StringUtil::SplitString(binds_string, '&', true));
|
||||
@@ -3363,7 +3367,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
||||
}
|
||||
|
||||
OpenChoiceDialog(
|
||||
TinyString::FromFmt(FSUI_FSTR("Select Macro {} Binds"), macro_index + 1), true, std::move(options),
|
||||
TinyString::from_fmt(FSUI_FSTR("Select Macro {} Binds"), macro_index + 1), true, std::move(options),
|
||||
[game_settings, section, macro_index, ci](s32 index, const std::string& title, bool checked) {
|
||||
// convert display name back to bind name
|
||||
std::string_view to_modify;
|
||||
@@ -3409,13 +3413,13 @@ void FullscreenUI::DrawControllerSettingsPage()
|
||||
|
||||
const std::string freq_key(fmt::format("Macro{}Frequency", macro_index + 1));
|
||||
const SmallString freq_title =
|
||||
SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_LIGHTBULB, "Macro {} Frequency")), macro_index + 1);
|
||||
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_LIGHTBULB, "Macro {} Frequency")), macro_index + 1);
|
||||
s32 frequency = bsi->GetIntValue(section.c_str(), freq_key.c_str(), 0);
|
||||
SmallString freq_summary;
|
||||
if (frequency == 0)
|
||||
freq_summary = FSUI_VSTR("Macro will not auto-toggle.");
|
||||
else
|
||||
freq_summary.Fmt(FSUI_FSTR("Macro will toggle every {} frames."), frequency);
|
||||
freq_summary.fmt(FSUI_FSTR("Macro will toggle every {} frames."), frequency);
|
||||
if (MenuButton(freq_title, freq_summary))
|
||||
ImGui::OpenPopup(freq_title);
|
||||
|
||||
@@ -3456,19 +3460,20 @@ void FullscreenUI::DrawControllerSettingsPage()
|
||||
{
|
||||
if (mtap_enabled[mtap_port])
|
||||
{
|
||||
MenuHeading(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {}{} Settings")),
|
||||
mtap_port + 1, mtap_slot_names[mtap_slot]));
|
||||
MenuHeading(
|
||||
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {}{} Settings")),
|
||||
mtap_port + 1, mtap_slot_names[mtap_slot]));
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuHeading(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {} Settings")),
|
||||
mtap_port + 1));
|
||||
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {} Settings")),
|
||||
mtap_port + 1));
|
||||
}
|
||||
|
||||
for (const SettingInfo& si : ci->settings)
|
||||
{
|
||||
TinyString title;
|
||||
title.Fmt(ICON_FA_COG "{}", si.display_name);
|
||||
title.fmt(ICON_FA_COG "{}", si.display_name);
|
||||
switch (si.type)
|
||||
{
|
||||
case SettingInfo::Type::Boolean:
|
||||
@@ -3583,13 +3588,13 @@ void FullscreenUI::DrawMemoryCardSettingsPage()
|
||||
|
||||
for (u32 i = 0; i < 2; i++)
|
||||
{
|
||||
MenuHeading(TinyString::FromFmt(FSUI_FSTR("Memory Card Port {}"), i + 1));
|
||||
MenuHeading(TinyString::from_fmt(FSUI_FSTR("Memory Card Port {}"), i + 1));
|
||||
|
||||
const MemoryCardType default_type =
|
||||
(i == 0) ? Settings::DEFAULT_MEMORY_CARD_1_TYPE : Settings::DEFAULT_MEMORY_CARD_2_TYPE;
|
||||
DrawEnumSetting(
|
||||
bsi, TinyString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SD_CARD, "Memory Card {} Type")), i + 1),
|
||||
SmallString::FromFmt(FSUI_FSTR("Sets which sort of memory card image will be used for slot {}."), i + 1),
|
||||
bsi, TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SD_CARD, "Memory Card {} Type")), i + 1),
|
||||
SmallString::from_fmt(FSUI_FSTR("Sets which sort of memory card image will be used for slot {}."), i + 1),
|
||||
"MemoryCards", type_keys[i], default_type, &Settings::ParseMemoryCardTypeName, &Settings::GetMemoryCardTypeName,
|
||||
&Settings::GetMemoryCardTypeDisplayName, MemoryCardType::Count);
|
||||
|
||||
@@ -3605,7 +3610,7 @@ void FullscreenUI::DrawMemoryCardSettingsPage()
|
||||
std::optional<const char*>((i == 0) ? "shared_card_1.mcd" : "shared_card_2.mcd")));
|
||||
|
||||
TinyString title;
|
||||
title.Fmt("{}##card_name_{}", FSUI_ICONSTR(ICON_FA_FILE, "Shared Card Name"), i);
|
||||
title.fmt("{}##card_name_{}", FSUI_ICONSTR(ICON_FA_FILE, "Shared Card Name"), i);
|
||||
if (MenuButtonWithValue(title,
|
||||
FSUI_CSTR("The selected memory card image will be used in shared mode for this slot."),
|
||||
path_value.has_value() ? path_value->c_str() : "Use Global Setting", is_shared))
|
||||
@@ -4075,7 +4080,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
|
||||
PostProcessingStageInfo& si = s_postprocessing_stages[stage_index];
|
||||
|
||||
ImGui::PushID(stage_index);
|
||||
str.Fmt(FSUI_FSTR("Stage {}: {}"), stage_index + 1, si.name);
|
||||
str.fmt(FSUI_FSTR("Stage {}: {}"), stage_index + 1, si.name);
|
||||
MenuHeading(str);
|
||||
|
||||
if (MenuButton(FSUI_ICONSTR(ICON_FA_TIMES, "Remove From Chain"), FSUI_CSTR("Removes this shader from the chain.")))
|
||||
@@ -4109,7 +4114,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
|
||||
case PostProcessing::ShaderOption::Type::Bool:
|
||||
{
|
||||
bool value = (opt.value[0].int_value != 0);
|
||||
tstr.Fmt(ICON_FA_COGS "{}", opt.ui_name);
|
||||
tstr.fmt(ICON_FA_COGS "{}", opt.ui_name);
|
||||
if (ToggleButton(tstr,
|
||||
(opt.default_value[0].int_value != 0) ? FSUI_CSTR("Default: Enabled") :
|
||||
FSUI_CSTR("Default: Disabled"),
|
||||
@@ -4124,8 +4129,8 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
|
||||
|
||||
case PostProcessing::ShaderOption::Type::Float:
|
||||
{
|
||||
tstr.Fmt(ICON_FA_RULER_VERTICAL "{}##{}", opt.ui_name, opt.name);
|
||||
str.Fmt(FSUI_FSTR("Value: {} | Default: {} | Minimum: {} | Maximum: {}"), opt.value[0].float_value,
|
||||
tstr.fmt(ICON_FA_RULER_VERTICAL "{}##{}", opt.ui_name, opt.name);
|
||||
str.fmt(FSUI_FSTR("Value: {} | Default: {} | Minimum: {} | Maximum: {}"), opt.value[0].float_value,
|
||||
opt.default_value[0].float_value, opt.min_value[0].float_value, opt.max_value[0].float_value);
|
||||
if (MenuButton(tstr, str))
|
||||
ImGui::OpenPopup(tstr);
|
||||
@@ -4223,8 +4228,8 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
|
||||
|
||||
case PostProcessing::ShaderOption::Type::Int:
|
||||
{
|
||||
tstr.Fmt(ICON_FA_RULER_VERTICAL "{}##{}", opt.ui_name, opt.name);
|
||||
str.Fmt(FSUI_FSTR("Value: {} | Default: {} | Minimum: {} | Maximum: {}"), opt.value[0].int_value,
|
||||
tstr.fmt(ICON_FA_RULER_VERTICAL "{}##{}", opt.ui_name, opt.name);
|
||||
str.fmt(FSUI_FSTR("Value: {} | Default: {} | Minimum: {} | Maximum: {}"), opt.value[0].int_value,
|
||||
opt.default_value[0].int_value, opt.min_value[0].int_value, opt.max_value[0].int_value);
|
||||
if (MenuButton(tstr, str))
|
||||
ImGui::OpenPopup(tstr);
|
||||
@@ -4489,17 +4494,17 @@ void FullscreenUI::DrawAchievementsSettingsPage()
|
||||
if (bsi->ContainsValue("Cheevos", "Token"))
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImGui::GetStyle().Colors[ImGuiCol_Text]);
|
||||
ActiveButton(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_USER, "Username: {}")),
|
||||
bsi->GetStringValue("Cheevos", "Username")),
|
||||
ActiveButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_USER, "Username: {}")),
|
||||
bsi->GetStringValue("Cheevos", "Username")),
|
||||
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
|
||||
TinyString ts_string;
|
||||
ts_string.AppendFmtString(
|
||||
ts_string.fmt(
|
||||
"{:%Y-%m-%d %H:%M:%S}",
|
||||
fmt::localtime(StringUtil::FromChars<u64>(bsi->GetStringValue("Cheevos", "LoginTimestamp", "0")).value_or(0)));
|
||||
ActiveButton(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_CLOCK, "Login token generated on {}")),
|
||||
ts_string.GetCharArray()),
|
||||
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
ActiveButton(
|
||||
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_CLOCK, "Login token generated on {}")), ts_string),
|
||||
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (MenuButton(FSUI_ICONSTR(ICON_FA_KEY, "Logout"), FSUI_CSTR("Logs out of RetroAchievements.")))
|
||||
@@ -4522,14 +4527,14 @@ void FullscreenUI::DrawAchievementsSettingsPage()
|
||||
const auto lock = Achievements::GetLock();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImGui::GetStyle().Colors[ImGuiCol_Text]);
|
||||
ActiveButton(SmallString::FromFmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_BOOKMARK, "Game: {} ({})")),
|
||||
Achievements::GetGameID(), Achievements::GetGameTitle()),
|
||||
ActiveButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_BOOKMARK, "Game: {} ({})")),
|
||||
Achievements::GetGameID(), Achievements::GetGameTitle()),
|
||||
false, false, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
|
||||
const std::string& rich_presence_string = Achievements::GetRichPresenceString();
|
||||
if (!rich_presence_string.empty())
|
||||
{
|
||||
ActiveButton(SmallString::FromFmt(ICON_FA_MAP "{}", rich_presence_string), false, false,
|
||||
ActiveButton(SmallString::from_fmt(ICON_FA_MAP "{}", rich_presence_string), false, false,
|
||||
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
}
|
||||
else
|
||||
@@ -4675,8 +4680,8 @@ void FullscreenUI::DrawPauseMenu()
|
||||
const std::string& serial = System::GetGameSerial();
|
||||
|
||||
if (!serial.empty())
|
||||
buffer.Format("%s - ", serial.c_str());
|
||||
buffer.AppendString(Path::GetFileName(System::GetDiscPath()));
|
||||
buffer.fmt("{} - ", serial);
|
||||
buffer.append(Path::GetFileName(System::GetDiscPath()));
|
||||
|
||||
const ImVec2 title_size(
|
||||
g_large_font->CalcTextSizeA(g_large_font->FontSize, std::numeric_limits<float>::max(), -1.0f, title.c_str()));
|
||||
@@ -4712,8 +4717,8 @@ void FullscreenUI::DrawPauseMenu()
|
||||
}
|
||||
}
|
||||
|
||||
DrawShadowedText(dl, g_large_font, title_pos, text_color, title.c_str());
|
||||
DrawShadowedText(dl, g_medium_font, subtitle_pos, text_color, buffer);
|
||||
DrawShadowedText(dl, g_large_font, title_pos, text_color, title.c_str(), title.c_str() + title.length());
|
||||
DrawShadowedText(dl, g_medium_font, subtitle_pos, text_color, buffer.c_str(), buffer.end_ptr());
|
||||
|
||||
const ImVec2 image_min(display_size.x - LayoutScale(20.0f + 50.0f) - rp_height,
|
||||
display_size.y - LayoutScale(20.0f + 50.0f) - rp_height);
|
||||
@@ -4723,14 +4728,12 @@ void FullscreenUI::DrawPauseMenu()
|
||||
|
||||
// current time / play time
|
||||
{
|
||||
buffer.Fmt("{:%X}", fmt::localtime(std::time(nullptr)));
|
||||
buffer.fmt("{:%X}", fmt::localtime(std::time(nullptr)));
|
||||
|
||||
const ImVec2 time_size(g_large_font->CalcTextSizeA(g_large_font->FontSize, std::numeric_limits<float>::max(), -1.0f,
|
||||
buffer.GetCharArray(),
|
||||
buffer.GetCharArray() + buffer.GetLength()));
|
||||
buffer.c_str(), buffer.end_ptr()));
|
||||
const ImVec2 time_pos(display_size.x - LayoutScale(10.0f) - time_size.x, LayoutScale(10.0f));
|
||||
DrawShadowedText(dl, g_large_font, time_pos, text_color, buffer.GetCharArray(),
|
||||
buffer.GetCharArray() + buffer.GetLength());
|
||||
DrawShadowedText(dl, g_large_font, time_pos, text_color, buffer.c_str(), buffer.end_ptr());
|
||||
|
||||
const std::string& serial = System::GetGameSerial();
|
||||
if (!serial.empty())
|
||||
@@ -4738,24 +4741,19 @@ void FullscreenUI::DrawPauseMenu()
|
||||
const std::time_t cached_played_time = GameList::GetCachedPlayedTimeForSerial(serial);
|
||||
const std::time_t session_time = static_cast<std::time_t>(System::GetSessionPlayedTime());
|
||||
|
||||
buffer.Fmt(FSUI_FSTR("Session: {}"), GameList::FormatTimespan(session_time, true).GetStringView());
|
||||
buffer.fmt(FSUI_FSTR("Session: {}"), GameList::FormatTimespan(session_time, true));
|
||||
const ImVec2 session_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, std::numeric_limits<float>::max(),
|
||||
-1.0f, buffer.GetCharArray(),
|
||||
buffer.GetCharArray() + buffer.GetLength()));
|
||||
-1.0f, buffer.c_str(), buffer.end_ptr()));
|
||||
const ImVec2 session_pos(display_size.x - LayoutScale(10.0f) - session_size.x,
|
||||
time_pos.y + g_large_font->FontSize + LayoutScale(4.0f));
|
||||
DrawShadowedText(dl, g_medium_font, session_pos, text_color, buffer.GetCharArray(),
|
||||
buffer.GetCharArray() + buffer.GetLength());
|
||||
DrawShadowedText(dl, g_medium_font, session_pos, text_color, buffer.c_str(), buffer.end_ptr());
|
||||
|
||||
buffer.Fmt(FSUI_FSTR("All Time: {}"),
|
||||
GameList::FormatTimespan(cached_played_time + session_time, true).GetStringView());
|
||||
buffer.fmt(FSUI_FSTR("All Time: {}"), GameList::FormatTimespan(cached_played_time + session_time, true));
|
||||
const ImVec2 total_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, std::numeric_limits<float>::max(),
|
||||
-1.0f, buffer.GetCharArray(),
|
||||
buffer.GetCharArray() + buffer.GetLength()));
|
||||
-1.0f, buffer.c_str(), buffer.end_ptr()));
|
||||
const ImVec2 total_pos(display_size.x - LayoutScale(10.0f) - total_size.x,
|
||||
session_pos.y + g_medium_font->FontSize + LayoutScale(4.0f));
|
||||
DrawShadowedText(dl, g_medium_font, total_pos, text_color, buffer.GetCharArray(),
|
||||
buffer.GetCharArray() + buffer.GetLength());
|
||||
DrawShadowedText(dl, g_medium_font, total_pos, text_color, buffer.c_str(), buffer.end_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5413,7 +5411,7 @@ void FullscreenUI::DrawResumeStateSelector()
|
||||
TimeToPrintableString(&time, entry.timestamp);
|
||||
ImGui::TextWrapped(
|
||||
FSUI_CSTR("A resume save state created at %s was found.\n\nDo you want to load this save and continue?"),
|
||||
time.GetCharArray());
|
||||
time.c_str());
|
||||
|
||||
const GPUTexture* image = entry.preview_texture ? entry.preview_texture.get() : GetPlaceholderTexture().get();
|
||||
const float image_height = LayoutScale(250.0f);
|
||||
@@ -5692,16 +5690,11 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
|
||||
GPUTexture* cover_texture = GetGameListCover(entry);
|
||||
|
||||
if (entry->serial.empty())
|
||||
{
|
||||
summary.Fmt("{} - ", Settings::GetDiscRegionDisplayName(entry->region));
|
||||
}
|
||||
summary.fmt("{} - ", Settings::GetDiscRegionDisplayName(entry->region));
|
||||
else
|
||||
{
|
||||
summary.Fmt("{} - {} - ", entry->serial, Settings::GetDiscRegionDisplayName(entry->region));
|
||||
}
|
||||
summary.fmt("{} - {} - ", entry->serial, Settings::GetDiscRegionDisplayName(entry->region));
|
||||
|
||||
const std::string_view filename(Path::GetFileName(entry->path));
|
||||
summary.AppendString(filename);
|
||||
summary.append(Path::GetFileName(entry->path));
|
||||
|
||||
const ImRect image_rect(
|
||||
CenterImage(ImRect(bb.Min, bb.Min + image_size), ImVec2(static_cast<float>(cover_texture->GetWidth()),
|
||||
@@ -5720,12 +5713,11 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
|
||||
entry->title.c_str() + entry->title.size(), nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
if (!summary.IsEmpty())
|
||||
if (!summary.empty())
|
||||
{
|
||||
ImGui::PushFont(g_medium_font);
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, summary.GetCharArray(),
|
||||
summary.GetCharArray() + summary.GetLength(), nullptr, ImVec2(0.0f, 0.0f),
|
||||
&summary_bb);
|
||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, summary.c_str(), summary.end_ptr(), nullptr,
|
||||
ImVec2(0.0f, 0.0f), &summary_bb);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
@@ -5832,10 +5824,8 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
|
||||
ImGui::Text(" (%s)", GameDatabase::GetCompatibilityRatingDisplayName(selected_entry->compatibility));
|
||||
|
||||
// play time
|
||||
ImGui::Text(FSUI_CSTR("Time Played: %s"),
|
||||
GameList::FormatTimespan(selected_entry->total_played_time).GetCharArray());
|
||||
ImGui::Text(FSUI_CSTR("Last Played: %s"),
|
||||
GameList::FormatTimestamp(selected_entry->last_played_time).GetCharArray());
|
||||
ImGui::Text(FSUI_CSTR("Time Played: %s"), GameList::FormatTimespan(selected_entry->total_played_time).c_str());
|
||||
ImGui::Text(FSUI_CSTR("Last Played: %s"), GameList::FormatTimestamp(selected_entry->last_played_time).c_str());
|
||||
|
||||
// size
|
||||
ImGui::Text(FSUI_CSTR("Size: %.2f MB"), static_cast<float>(selected_entry->total_size) / 1048576.0f);
|
||||
@@ -5941,11 +5931,10 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
|
||||
const ImRect title_bb(ImVec2(bb.Min.x, bb.Min.y + image_height + title_spacing), bb.Max);
|
||||
const std::string_view title(
|
||||
std::string_view(entry->title).substr(0, (entry->title.length() > 31) ? 31 : std::string_view::npos));
|
||||
draw_title.Fmt("{}{}", title, (title.length() == entry->title.length()) ? "" : "...");
|
||||
draw_title.fmt("{}{}", title, (title.length() == entry->title.length()) ? "" : "...");
|
||||
ImGui::PushFont(g_medium_font);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, draw_title.GetCharArray(),
|
||||
draw_title.GetCharArray() + draw_title.GetLength(), nullptr, ImVec2(0.5f, 0.0f),
|
||||
&title_bb);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, draw_title.c_str(), draw_title.end_ptr(), nullptr,
|
||||
ImVec2(0.5f, 0.0f), &title_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
if (pressed)
|
||||
@@ -6073,7 +6062,7 @@ void FullscreenUI::DrawGameListSettingsPage(const ImVec2& heading_size)
|
||||
|
||||
for (const auto& it : s_game_list_directories_cache)
|
||||
{
|
||||
if (MenuButton(SmallString::FromFmt(ICON_FA_FOLDER "{}", it.first),
|
||||
if (MenuButton(SmallString::from_fmt(ICON_FA_FOLDER "{}", it.first),
|
||||
it.second ? FSUI_CSTR("Scanning Subdirectories") : FSUI_CSTR("Not Scanning Subdirectories")))
|
||||
{
|
||||
ImGuiFullscreen::ChoiceDialogOptions options = {
|
||||
@@ -6609,8 +6598,7 @@ void FullscreenUI::ProgressCallback::Redraw(bool force)
|
||||
return;
|
||||
|
||||
m_last_progress_percent = percent;
|
||||
ImGuiFullscreen::UpdateBackgroundProgressDialog(
|
||||
m_name.c_str(), std::string(m_status_text.GetCharArray(), m_status_text.GetLength()), 0, 100, percent);
|
||||
ImGuiFullscreen::UpdateBackgroundProgressDialog(m_name.c_str(), m_status_text, 0, 100, percent);
|
||||
}
|
||||
|
||||
void FullscreenUI::ProgressCallback::DisplayError(const char* message)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class String;
|
||||
class SmallStringBase;
|
||||
|
||||
struct Settings;
|
||||
|
||||
@@ -32,7 +32,7 @@ void ReturnToPreviousWindow();
|
||||
void Shutdown();
|
||||
void Render();
|
||||
void InvalidateCoverCache();
|
||||
void TimeToPrintableString(String* str, time_t t);
|
||||
void TimeToPrintableString(SmallStringBase* str, time_t t);
|
||||
|
||||
// Returns true if the message has been dismissed.
|
||||
bool DrawErrorWindow(const char* message);
|
||||
|
||||
@@ -463,18 +463,19 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||
if ((supported_controllers & BIT_FOR(supported_ctype)) == 0)
|
||||
continue;
|
||||
|
||||
if (!supported_controller_string.IsEmpty())
|
||||
supported_controller_string.AppendString(", ");
|
||||
if (!supported_controller_string.empty())
|
||||
supported_controller_string.append(", ");
|
||||
|
||||
supported_controller_string.AppendString(Settings::GetControllerTypeDisplayName(supported_ctype));
|
||||
supported_controller_string.append(Settings::GetControllerTypeDisplayName(supported_ctype));
|
||||
}
|
||||
|
||||
Host::AddKeyedFormattedOSDMessage(
|
||||
"gamedb_controller_unsupported", 30.0f,
|
||||
TRANSLATE("OSDMessage", "Controller in port %u (%s) is not supported for %s.\nSupported controllers: "
|
||||
"%s\nPlease configure a supported controller from the list above."),
|
||||
i + 1u, Settings::GetControllerTypeDisplayName(ctype), System::GetGameTitle().c_str(),
|
||||
supported_controller_string.GetCharArray());
|
||||
Host::AddKeyedOSDMessage(
|
||||
"gamedb_controller_unsupported",
|
||||
fmt::format(
|
||||
TRANSLATE_FS("OSDMessage", "Controller in port {0} ({1}) is not supported for {2}.\nSupported controllers: "
|
||||
"{3}\nPlease configure a supported controller from the list above."),
|
||||
i + 1u, Settings::GetControllerTypeDisplayName(ctype), System::GetGameTitle(), supported_controller_string),
|
||||
Host::OSD_CRITICAL_ERROR_DURATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,7 +994,7 @@ TinyString GameList::FormatTimestamp(std::time_t timestamp)
|
||||
{
|
||||
char buf[128];
|
||||
std::strftime(buf, std::size(buf), "%x", &ttime);
|
||||
ret.Assign(buf);
|
||||
ret.assign(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1011,22 +1011,22 @@ TinyString GameList::FormatTimespan(std::time_t timespan, bool long_format)
|
||||
if (!long_format)
|
||||
{
|
||||
if (hours >= 100)
|
||||
ret.Fmt(TRANSLATE_FS("GameList", "{}h {}m"), hours, minutes);
|
||||
ret.fmt(TRANSLATE_FS("GameList", "{}h {}m"), hours, minutes);
|
||||
else if (hours > 0)
|
||||
ret.Fmt(TRANSLATE_FS("GameList", "{}h {}m {}s"), hours, minutes, seconds);
|
||||
ret.fmt(TRANSLATE_FS("GameList", "{}h {}m {}s"), hours, minutes, seconds);
|
||||
else if (minutes > 0)
|
||||
ret.Fmt(TRANSLATE_FS("GameList", "{}m {}s"), minutes, seconds);
|
||||
ret.fmt(TRANSLATE_FS("GameList", "{}m {}s"), minutes, seconds);
|
||||
else if (seconds > 0)
|
||||
ret.Fmt(TRANSLATE_FS("GameList", "{}s"), seconds);
|
||||
ret.fmt(TRANSLATE_FS("GameList", "{}s"), seconds);
|
||||
else
|
||||
ret = TRANSLATE_SV("GameList", "None");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hours > 0)
|
||||
ret = fmt::format(TRANSLATE_FS("GameList", "{} hours"), hours);
|
||||
ret.fmt(TRANSLATE_FS("GameList", "{} hours"), hours);
|
||||
else
|
||||
ret = fmt::format(TRANSLATE_FS("GameList", "{} minutes"), minutes);
|
||||
ret.fmt(TRANSLATE_FS("GameList", "{} minutes"), minutes);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "util/cd_image.h"
|
||||
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <functional>
|
||||
|
||||
@@ -180,8 +180,8 @@ bool GPU::HandleUnknownGP0Command()
|
||||
|
||||
SmallString dump;
|
||||
for (u32 i = 0; i < m_fifo.GetSize(); i++)
|
||||
dump.AppendFormattedString("%s0x%08X", (i > 0) ? " " : "", FifoPeek(i));
|
||||
Log_ErrorPrintf("FIFO: %s", dump.GetCharArray());
|
||||
dump.append_fmt("{}{:08X}", (i > 0) ? " " : "", FifoPeek(i));
|
||||
Log_ErrorPrintf("FIFO: %s", dump.c_str());
|
||||
|
||||
m_fifo.RemoveOne();
|
||||
EndCommand();
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "util/host.h"
|
||||
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
#include "common/types.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "host.h"
|
||||
Log_SetChannel(HostInterfaceProgressCallback);
|
||||
|
||||
HostInterfaceProgressCallback::HostInterfaceProgressCallback() : BaseProgressCallback() {}
|
||||
HostInterfaceProgressCallback::HostInterfaceProgressCallback() : BaseProgressCallback()
|
||||
{
|
||||
}
|
||||
|
||||
void HostInterfaceProgressCallback::PushState()
|
||||
{
|
||||
@@ -64,7 +66,8 @@ void HostInterfaceProgressCallback::Redraw(bool force)
|
||||
return;
|
||||
|
||||
m_last_progress_percent = percent;
|
||||
Host::DisplayLoadingScreen(m_status_text, 0, static_cast<int>(m_progress_range), static_cast<int>(m_progress_value));
|
||||
Host::DisplayLoadingScreen(m_status_text.c_str(), 0, static_cast<int>(m_progress_range),
|
||||
static_cast<int>(m_progress_value));
|
||||
}
|
||||
|
||||
void HostInterfaceProgressCallback::DisplayError(const char* message)
|
||||
|
||||
+72
-80
@@ -54,7 +54,7 @@
|
||||
Log_SetChannel(ImGuiManager);
|
||||
|
||||
namespace ImGuiManager {
|
||||
static void FormatProcessorStat(String& text, double usage, double time);
|
||||
static void FormatProcessorStat(SmallStringBase& text, double usage, double time);
|
||||
static void DrawPerformanceOverlay();
|
||||
static void DrawEnhancementsOverlay();
|
||||
static void DrawInputsOverlay();
|
||||
@@ -179,12 +179,12 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/,
|
||||
ImGui::TextUnformatted(message);
|
||||
|
||||
TinyString buf;
|
||||
buf.Fmt("{}/{}", progress_value, progress_max);
|
||||
buf.fmt("{}/{}", progress_value, progress_max);
|
||||
|
||||
const ImVec2 prog_size = ImGui::CalcTextSize(buf.GetCharArray(), buf.GetCharArray() + buf.GetLength());
|
||||
const ImVec2 prog_size = ImGui::CalcTextSize(buf.c_str(), buf.end_ptr());
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(width - padding_and_rounding - prog_size.x);
|
||||
ImGui::TextUnformatted(buf.GetCharArray(), buf.GetCharArray() + buf.GetLength());
|
||||
ImGui::TextUnformatted(buf.c_str(), buf.end_ptr());
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5.0f);
|
||||
|
||||
ImGui::ProgressBar(static_cast<float>(progress_value) / static_cast<float>(progress_max - progress_min),
|
||||
@@ -259,15 +259,15 @@ void ImGuiManager::RenderOverlayWindows()
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiManager::FormatProcessorStat(String& text, double usage, double time)
|
||||
void ImGuiManager::FormatProcessorStat(SmallStringBase& text, double usage, double time)
|
||||
{
|
||||
// Some values, such as GPU (and even CPU to some extent) can be out of phase with the wall clock,
|
||||
// which the processor time is divided by to get a utilization percentage. Let's clamp it at 100%,
|
||||
// so that people don't get confused, and remove the decimal places when it's there while we're at it.
|
||||
if (usage >= 99.95)
|
||||
text.AppendFmtString("100% ({:.2f}ms)", time);
|
||||
text.append_fmt("100% ({:.2f}ms)", time);
|
||||
else
|
||||
text.AppendFmtString("{:.1f}% ({:.2f}ms)", usage, time);
|
||||
text.append_fmt("{:.1f}% ({:.2f}ms)", usage, time);
|
||||
}
|
||||
|
||||
void ImGuiManager::DrawPerformanceOverlay()
|
||||
@@ -301,7 +301,7 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
dl->AddText( \
|
||||
font, font->FontSize, \
|
||||
ImVec2(ImGui::GetIO().DisplaySize.x - margin - text_size.x + shadow_offset, position_y + shadow_offset), \
|
||||
IM_COL32(0, 0, 0, 100), text, text.GetCharArray() + text.GetLength()); \
|
||||
IM_COL32(0, 0, 0, 100), text.c_str(), text.end_ptr()); \
|
||||
dl->AddText(font, font->FontSize, ImVec2(ImGui::GetIO().DisplaySize.x - margin - text_size.x, position_y), color, \
|
||||
(text)); \
|
||||
position_y += text_size.y + spacing; \
|
||||
@@ -313,22 +313,22 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
const float speed = System::GetEmulationSpeed();
|
||||
if (g_settings.display_show_fps)
|
||||
{
|
||||
text.AppendFmtString("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS());
|
||||
text.append_fmt("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS());
|
||||
first = false;
|
||||
}
|
||||
if (g_settings.display_show_speed)
|
||||
{
|
||||
text.AppendFmtString("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed)));
|
||||
text.append_fmt("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed)));
|
||||
|
||||
const float target_speed = System::GetTargetSpeed();
|
||||
if (target_speed <= 0.0f)
|
||||
text.AppendString(" (Max)");
|
||||
text.append(" (Max)");
|
||||
else
|
||||
text.AppendFmtString(" ({:.0f}%)", target_speed * 100.0f);
|
||||
text.append_fmt(" ({:.0f}%)", target_speed * 100.0f);
|
||||
|
||||
first = false;
|
||||
}
|
||||
if (!text.IsEmpty())
|
||||
if (!text.empty())
|
||||
{
|
||||
ImU32 color;
|
||||
if (speed < 95.0f)
|
||||
@@ -347,65 +347,63 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
const auto [effective_width, effective_height] = g_gpu->GetEffectiveDisplayResolution();
|
||||
const bool interlaced = g_gpu->IsInterlacedDisplayEnabled();
|
||||
const bool pal = g_gpu->IsInPALMode();
|
||||
text.Fmt("{}x{} {} {}", effective_width, effective_height, pal ? "PAL" : "NTSC",
|
||||
text.fmt("{}x{} {} {}", effective_width, effective_height, pal ? "PAL" : "NTSC",
|
||||
interlaced ? "Interlaced" : "Progressive");
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
if (g_settings.display_show_cpu)
|
||||
{
|
||||
text.Clear();
|
||||
text.AppendFmtString("{:.2f}ms | {:.2f}ms | {:.2f}ms", System::GetMinimumFrameTime(),
|
||||
System::GetAverageFrameTime(), System::GetMaximumFrameTime());
|
||||
text.fmt("{:.2f}ms | {:.2f}ms | {:.2f}ms", System::GetMinimumFrameTime(), System::GetAverageFrameTime(),
|
||||
System::GetMaximumFrameTime());
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
|
||||
text.Clear();
|
||||
if (g_settings.cpu_overclock_active || (!g_settings.IsUsingRecompiler() || g_settings.cpu_recompiler_icache ||
|
||||
g_settings.cpu_recompiler_memory_exceptions))
|
||||
{
|
||||
first = true;
|
||||
text.AppendString("CPU[");
|
||||
text.assign("CPU[");
|
||||
if (g_settings.cpu_overclock_active)
|
||||
{
|
||||
text.AppendFmtString("{}", g_settings.GetCPUOverclockPercent());
|
||||
text.append_fmt("{}", g_settings.GetCPUOverclockPercent());
|
||||
first = false;
|
||||
}
|
||||
if (g_settings.cpu_execution_mode == CPUExecutionMode::Interpreter)
|
||||
{
|
||||
text.AppendFmtString("{}{}", first ? "" : "/", "I");
|
||||
text.append_fmt("{}{}", first ? "" : "/", "I");
|
||||
first = false;
|
||||
}
|
||||
else if (g_settings.cpu_execution_mode == CPUExecutionMode::CachedInterpreter)
|
||||
{
|
||||
text.AppendFmtString("{}{}", first ? "" : "/", "CI");
|
||||
text.append_fmt("{}{}", first ? "" : "/", "CI");
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_settings.cpu_recompiler_icache)
|
||||
{
|
||||
text.AppendFmtString("{}{}", first ? "" : "/", "IC");
|
||||
text.append_fmt("{}{}", first ? "" : "/", "IC");
|
||||
first = false;
|
||||
}
|
||||
if (g_settings.cpu_recompiler_memory_exceptions)
|
||||
{
|
||||
text.AppendFmtString("{}{}", first ? "" : "/", "ME");
|
||||
text.append_fmt("{}{}", first ? "" : "/", "ME");
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
text.AppendString("]: ");
|
||||
text.append("]: ");
|
||||
}
|
||||
else
|
||||
{
|
||||
text.Assign("CPU: ");
|
||||
text.assign("CPU: ");
|
||||
}
|
||||
FormatProcessorStat(text, System::GetCPUThreadUsage(), System::GetCPUThreadAverageTime());
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
|
||||
if (g_gpu->GetSWThread())
|
||||
{
|
||||
text.Assign("SW: ");
|
||||
text.assign("SW: ");
|
||||
FormatProcessorStat(text, System::GetSWThreadUsage(), System::GetSWThreadAverageTime());
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
@@ -414,8 +412,7 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
{
|
||||
AudioStream* stream = g_spu.GetOutputStream();
|
||||
const u32 frames = stream->GetBufferedFramesRelaxed();
|
||||
text.Clear();
|
||||
text.Fmt("Audio: {:<4u}f/{:<3u}ms", frames, AudioStream::GetMSForBufferSize(stream->GetSampleRate(), frames));
|
||||
text.fmt("Audio: {:<4u}f/{:<3u}ms", frames, AudioStream::GetMSForBufferSize(stream->GetSampleRate(), frames));
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
#endif
|
||||
@@ -423,7 +420,7 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
|
||||
if (g_settings.display_show_gpu && g_gpu_device->IsGPUTimingEnabled())
|
||||
{
|
||||
text.Assign("GPU: ");
|
||||
text.assign("GPU: ");
|
||||
FormatProcessorStat(text, System::GetGPUUsage(), System::GetGPUAverageTime());
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
@@ -433,7 +430,7 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
const bool rewinding = System::IsRewinding();
|
||||
if (rewinding || System::IsFastForwardEnabled() || System::IsTurboEnabled())
|
||||
{
|
||||
text.Assign(rewinding ? ICON_FA_FAST_BACKWARD : ICON_FA_FAST_FORWARD);
|
||||
text.assign(rewinding ? ICON_FA_FAST_BACKWARD : ICON_FA_FAST_FORWARD);
|
||||
DRAW_LINE(standard_font, text, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
}
|
||||
@@ -477,25 +474,21 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
ImDrawList* win_dl = ImGui::GetCurrentWindow()->DrawList;
|
||||
const ImVec2 wpos(ImGui::GetCurrentWindow()->Pos);
|
||||
|
||||
text.Clear();
|
||||
text.AppendFmtString("{:.1f} ms", max);
|
||||
text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength());
|
||||
text.fmt("{:.1f} ms", max);
|
||||
text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.end_ptr());
|
||||
win_dl->AddText(ImVec2(wpos.x + history_size.x - text_size.x - spacing + shadow_offset, wpos.y + shadow_offset),
|
||||
IM_COL32(0, 0, 0, 100), text.GetCharArray(), text.GetCharArray() + text.GetLength());
|
||||
IM_COL32(0, 0, 0, 100), text.c_str(), text.end_ptr());
|
||||
win_dl->AddText(ImVec2(wpos.x + history_size.x - text_size.x - spacing, wpos.y), IM_COL32(255, 255, 255, 255),
|
||||
text.GetCharArray(), text.GetCharArray() + text.GetLength());
|
||||
text.c_str(), text.end_ptr());
|
||||
|
||||
text.Clear();
|
||||
text.AppendFmtString("{:.1f} ms", min);
|
||||
text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength());
|
||||
text.fmt("{:.1f} ms", min);
|
||||
text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.end_ptr());
|
||||
win_dl->AddText(ImVec2(wpos.x + history_size.x - text_size.x - spacing + shadow_offset,
|
||||
wpos.y + history_size.y - fixed_font->FontSize + shadow_offset),
|
||||
IM_COL32(0, 0, 0, 100), text.GetCharArray(), text.GetCharArray() + text.GetLength());
|
||||
IM_COL32(0, 0, 0, 100), text.c_str(), text.end_ptr());
|
||||
win_dl->AddText(
|
||||
ImVec2(wpos.x + history_size.x - text_size.x - spacing, wpos.y + history_size.y - fixed_font->FontSize),
|
||||
IM_COL32(255, 255, 255, 255), text.GetCharArray(), text.GetCharArray() + text.GetLength());
|
||||
IM_COL32(255, 255, 255, 255), text.c_str(), text.end_ptr());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::End();
|
||||
@@ -506,7 +499,7 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
else if (g_settings.display_show_status_indicators && state == System::State::Paused &&
|
||||
!FullscreenUI::HasActiveWindow())
|
||||
{
|
||||
text.Assign(ICON_FA_PAUSE);
|
||||
text.assign(ICON_FA_PAUSE);
|
||||
DRAW_LINE(standard_font, text, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
@@ -516,58 +509,57 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
void ImGuiManager::DrawEnhancementsOverlay()
|
||||
{
|
||||
LargeString text;
|
||||
text.AppendFmtString("{} {}-{}", Settings::GetConsoleRegionName(System::GetRegion()),
|
||||
GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()),
|
||||
g_gpu->IsHardwareRenderer() ? "HW" : "SW");
|
||||
text.append_fmt("{} {}-{}", Settings::GetConsoleRegionName(System::GetRegion()),
|
||||
GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()),
|
||||
g_gpu->IsHardwareRenderer() ? "HW" : "SW");
|
||||
|
||||
if (g_settings.rewind_enable)
|
||||
text.AppendFormattedString(" RW=%g/%u", g_settings.rewind_save_frequency, g_settings.rewind_save_slots);
|
||||
text.append_fmt(" RW={}/{}", g_settings.rewind_save_frequency, g_settings.rewind_save_slots);
|
||||
if (g_settings.IsRunaheadEnabled())
|
||||
text.AppendFormattedString(" RA=%u", g_settings.runahead_frames);
|
||||
text.append_fmt(" RA={}", g_settings.runahead_frames);
|
||||
|
||||
if (g_settings.cpu_overclock_active)
|
||||
text.AppendFormattedString(" CPU=%u%%", g_settings.GetCPUOverclockPercent());
|
||||
text.append_fmt(" CPU={}%", g_settings.GetCPUOverclockPercent());
|
||||
if (g_settings.enable_8mb_ram)
|
||||
text.AppendString(" 8MB");
|
||||
text.append(" 8MB");
|
||||
if (g_settings.cdrom_read_speedup != 1)
|
||||
text.AppendFormattedString(" CDR=%ux", g_settings.cdrom_read_speedup);
|
||||
text.append_fmt(" CDR={}x", g_settings.cdrom_read_speedup);
|
||||
if (g_settings.cdrom_seek_speedup != 1)
|
||||
text.AppendFormattedString(" CDS=%ux", g_settings.cdrom_seek_speedup);
|
||||
text.append_fmt(" CDS={}x", g_settings.cdrom_seek_speedup);
|
||||
if (g_settings.gpu_resolution_scale != 1)
|
||||
text.AppendFormattedString(" IR=%ux", g_settings.gpu_resolution_scale);
|
||||
text.append_fmt(" IR={}x", g_settings.gpu_resolution_scale);
|
||||
if (g_settings.gpu_multisamples != 1)
|
||||
{
|
||||
text.AppendFormattedString(" %ux%s", g_settings.gpu_multisamples,
|
||||
g_settings.gpu_per_sample_shading ? "SSAA" : "MSAA");
|
||||
text.append_fmt(" {}x{}", g_settings.gpu_multisamples, g_settings.gpu_per_sample_shading ? "SSAA" : "MSAA");
|
||||
}
|
||||
if (g_settings.gpu_true_color)
|
||||
text.AppendString(" TrueCol");
|
||||
text.append(" TrueCol");
|
||||
if (g_settings.gpu_disable_interlacing)
|
||||
text.AppendString(" ForceProg");
|
||||
text.append(" ForceProg");
|
||||
if (g_settings.gpu_force_ntsc_timings && System::GetRegion() == ConsoleRegion::PAL)
|
||||
text.AppendString(" PAL60");
|
||||
text.append(" PAL60");
|
||||
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest)
|
||||
text.AppendFormattedString(" %s", Settings::GetTextureFilterName(g_settings.gpu_texture_filter));
|
||||
text.append_fmt(" {}", Settings::GetTextureFilterName(g_settings.gpu_texture_filter));
|
||||
if (g_settings.gpu_widescreen_hack && g_settings.display_aspect_ratio != DisplayAspectRatio::Auto &&
|
||||
g_settings.display_aspect_ratio != DisplayAspectRatio::R4_3)
|
||||
{
|
||||
text.AppendString(" WSHack");
|
||||
text.append(" WSHack");
|
||||
}
|
||||
if (g_settings.gpu_pgxp_enable)
|
||||
{
|
||||
text.AppendString(" PGXP");
|
||||
text.append(" PGXP");
|
||||
if (g_settings.gpu_pgxp_culling)
|
||||
text.AppendString("/Cull");
|
||||
text.append("/Cull");
|
||||
if (g_settings.gpu_pgxp_texture_correction)
|
||||
text.AppendString("/Tex");
|
||||
text.append("/Tex");
|
||||
if (g_settings.gpu_pgxp_color_correction)
|
||||
text.AppendString("/Col");
|
||||
text.append("/Col");
|
||||
if (g_settings.gpu_pgxp_vertex_cache)
|
||||
text.AppendString("/VC");
|
||||
text.append("/VC");
|
||||
if (g_settings.gpu_pgxp_cpu)
|
||||
text.AppendString("/CPU");
|
||||
text.append("/CPU");
|
||||
if (g_settings.gpu_pgxp_depth_buffer)
|
||||
text.AppendString("/Depth");
|
||||
text.append("/Depth");
|
||||
}
|
||||
|
||||
const float scale = ImGuiManager::GetGlobalScale();
|
||||
@@ -577,13 +569,13 @@ void ImGuiManager::DrawEnhancementsOverlay()
|
||||
const float position_y = ImGui::GetIO().DisplaySize.y - margin - font->FontSize;
|
||||
|
||||
ImDrawList* dl = ImGui::GetBackgroundDrawList();
|
||||
ImVec2 text_size = font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), -1.0f, text,
|
||||
text.GetCharArray() + text.GetLength(), nullptr);
|
||||
ImVec2 text_size = font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), -1.0f, text.c_str(),
|
||||
text.end_ptr(), nullptr);
|
||||
dl->AddText(font, font->FontSize,
|
||||
ImVec2(ImGui::GetIO().DisplaySize.x - margin - text_size.x + shadow_offset, position_y + shadow_offset),
|
||||
IM_COL32(0, 0, 0, 100), text, text.GetCharArray() + text.GetLength());
|
||||
IM_COL32(0, 0, 0, 100), text.c_str(), text.end_ptr());
|
||||
dl->AddText(font, font->FontSize, ImVec2(ImGui::GetIO().DisplaySize.x - margin - text_size.x, position_y),
|
||||
IM_COL32(255, 255, 255, 255), text, text.GetCharArray() + text.GetLength());
|
||||
IM_COL32(255, 255, 255, 255), text.c_str(), text.end_ptr());
|
||||
}
|
||||
|
||||
void ImGuiManager::DrawInputsOverlay()
|
||||
@@ -612,7 +604,7 @@ void ImGuiManager::DrawInputsOverlay()
|
||||
|
||||
const ImVec4 clip_rect(current_x, current_y, display_size.x - margin, display_size.y - margin);
|
||||
|
||||
LargeString text;
|
||||
SmallString text;
|
||||
|
||||
for (u32 port = 0; port < NUM_CONTROLLER_AND_CARD_PORTS; port++)
|
||||
{
|
||||
@@ -625,7 +617,7 @@ void ImGuiManager::DrawInputsOverlay()
|
||||
if (!cinfo)
|
||||
continue;
|
||||
|
||||
text.Fmt("P{} |", port + 1u);
|
||||
text.fmt("P{} |", port + 1u);
|
||||
|
||||
for (const Controller::ControllerBindingInfo& bi : cinfo->bindings)
|
||||
{
|
||||
@@ -637,9 +629,9 @@ void ImGuiManager::DrawInputsOverlay()
|
||||
// axes are always shown
|
||||
const float value = controller->GetBindState(bi.bind_index);
|
||||
if (value >= (254.0f / 255.0f))
|
||||
text.AppendFmtString(" {}", bi.name);
|
||||
text.append_fmt(" {}", bi.name);
|
||||
else if (value > (1.0f / 255.0f))
|
||||
text.AppendFmtString(" {}: {:.2f}", bi.name, value);
|
||||
text.append_fmt(" {}: {:.2f}", bi.name, value);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -648,7 +640,7 @@ void ImGuiManager::DrawInputsOverlay()
|
||||
// buttons only shown when active
|
||||
const float value = controller->GetBindState(bi.bind_index);
|
||||
if (value >= 0.5f)
|
||||
text.AppendFmtString(" {}", bi.name);
|
||||
text.append_fmt(" {}", bi.name);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -662,9 +654,9 @@ void ImGuiManager::DrawInputsOverlay()
|
||||
}
|
||||
|
||||
dl->AddText(font, font->FontSize, ImVec2(current_x + shadow_offset, current_y + shadow_offset), shadow_color,
|
||||
text.GetCharArray(), text.GetCharArray() + text.GetLength(), 0.0f, &clip_rect);
|
||||
dl->AddText(font, font->FontSize, ImVec2(current_x, current_y), text_color, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength(), 0.0f, &clip_rect);
|
||||
text.c_str(), text.end_ptr(), 0.0f, &clip_rect);
|
||||
dl->AddText(font, font->FontSize, ImVec2(current_x, current_y), text_color, text.c_str(), text.end_ptr(), 0.0f,
|
||||
&clip_rect);
|
||||
|
||||
current_y += font->FontSize + spacing;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ static bool LoadLibraryPSF(const char* path, bool use_pc_sp, u32 depth = 0)
|
||||
u32 lib_counter = 2;
|
||||
for (;;)
|
||||
{
|
||||
lib_name = file.GetTagString(TinyString::FromFormat("_lib%u", lib_counter++));
|
||||
lib_name = file.GetTagString(TinyString::from_fmt("_lib{}", lib_counter++));
|
||||
if (!lib_name.has_value())
|
||||
break;
|
||||
|
||||
|
||||
@@ -101,34 +101,6 @@ bool Settings::HasAnyPerGameMemoryCards() const
|
||||
});
|
||||
}
|
||||
|
||||
std::array<TinyString, NUM_CONTROLLER_AND_CARD_PORTS> Settings::GeneratePortLabels() const
|
||||
{
|
||||
static constexpr std::array<std::array<bool, NUM_MULTITAPS>, static_cast<size_t>(MultitapMode::Count)>
|
||||
multitap_enabled_on_port = {{{false, false}, {true, false}, {false, true}, {true, true}}};
|
||||
|
||||
std::array<TinyString, NUM_CONTROLLER_AND_CARD_PORTS> labels;
|
||||
|
||||
u32 logical_port = 0;
|
||||
for (u32 physical_port = 0; physical_port < NUM_MULTITAPS; physical_port++)
|
||||
{
|
||||
if (multitap_enabled_on_port[static_cast<size_t>(multitap_mode)][physical_port])
|
||||
{
|
||||
for (u32 i = 0; i < 4; i++)
|
||||
{
|
||||
labels[logical_port] = TinyString::FromFormat("Port %u%c", physical_port + 1u, 'A' + i);
|
||||
logical_port++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
labels[logical_port] = TinyString::FromFormat("Port %u", physical_port + 1u);
|
||||
logical_port++;
|
||||
}
|
||||
}
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
void Settings::CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator)
|
||||
{
|
||||
const u32 percent_gcd = std::gcd(percent, 100);
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@
|
||||
#pragma once
|
||||
#include "common/log.h"
|
||||
#include "common/settings_interface.h"
|
||||
#include "common/string.h"
|
||||
#include "common/small_string.h"
|
||||
#include "types.h"
|
||||
#include "util/audio_stream.h"
|
||||
#include <array>
|
||||
@@ -246,8 +246,6 @@ struct Settings
|
||||
std::string pcdrv_root;
|
||||
bool pcdrv_enable_writes = false;
|
||||
|
||||
std::array<TinyString, NUM_CONTROLLER_AND_CARD_PORTS> GeneratePortLabels() const;
|
||||
|
||||
LOGLEVEL log_level = DEFAULT_LOG_LEVEL;
|
||||
std::string log_filter;
|
||||
bool log_to_console = DEFAULT_LOG_TO_CONSOLE;
|
||||
|
||||
+11
-15
@@ -237,7 +237,7 @@ static bool s_discord_presence_active = false;
|
||||
|
||||
static TinyString GetTimestampStringForFileName()
|
||||
{
|
||||
return TinyString::FromFmt("{:%Y-%m-%d_%H-%M-%S}", fmt::localtime(std::time(nullptr)));
|
||||
return TinyString::from_fmt("{:%Y-%m-%d_%H-%M-%S}", fmt::localtime(std::time(nullptr)));
|
||||
}
|
||||
|
||||
void System::Internal::ProcessStartup()
|
||||
@@ -3341,25 +3341,21 @@ bool System::CheckForSBIFile(CDImage* image)
|
||||
{
|
||||
return Host::ConfirmMessage(
|
||||
"Confirm Unsupported Configuration",
|
||||
StringUtil::StdStringFromFormat(
|
||||
TRANSLATE(
|
||||
"System",
|
||||
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nThe game will "
|
||||
"likely not run properly.\n\nPlease check the README for instructions on how to add an SBI file.\n\nDo "
|
||||
"you wish to continue?"),
|
||||
s_running_game_serial.c_str(), s_running_game_title.c_str())
|
||||
.c_str());
|
||||
LargeString::from_fmt(
|
||||
TRANSLATE_FS("System", "You are attempting to run a libcrypt protected game without an SBI file:\n\n{0}: "
|
||||
"{1}\n\nThe game will likely not run properly.\n\nPlease check the README for "
|
||||
"instructions on how to add an SBI file.\n\nDo you wish to continue?"),
|
||||
s_running_game_serial, s_running_game_title));
|
||||
}
|
||||
else
|
||||
{
|
||||
Host::ReportErrorAsync(
|
||||
TRANSLATE("System", "Error"),
|
||||
SmallString::FromFormat(
|
||||
TRANSLATE("System",
|
||||
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nYour dump is "
|
||||
"incomplete, you must add the SBI file to run this game. \n\n"
|
||||
"The name of the SBI file must match the name of the disc image."),
|
||||
s_running_game_serial.c_str(), s_running_game_title.c_str()));
|
||||
LargeString::from_fmt(
|
||||
TRANSLATE_FS("System", "You are attempting to run a libcrypt protected game without an SBI file:\n\n{0}: "
|
||||
"{1}\n\nYour dump is incomplete, you must add the SBI file to run this game. \n\nThe "
|
||||
"name of the SBI file must match the name of the disc image."),
|
||||
s_running_game_serial, s_running_game_title));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user