SmallString: fmt -> format, format -> sprintf

This commit is contained in:
Stenzek 2023-12-13 21:06:15 +10:00
parent ad6e49998f
commit 79c226efff
No known key found for this signature in database
30 changed files with 224 additions and 224 deletions

View file

@ -18,7 +18,7 @@ void ProgressCallback::SetFormattedStatusText(const char* Format, ...)
va_list ap;
va_start(ap, Format);
str.format_va(Format, ap);
str.vsprintf(Format, ap);
va_end(ap);
SetStatusText(str);
@ -30,7 +30,7 @@ void ProgressCallback::DisplayFormattedError(const char* format, ...)
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
DisplayError(str);
@ -42,7 +42,7 @@ void ProgressCallback::DisplayFormattedWarning(const char* format, ...)
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
DisplayWarning(str);
@ -54,7 +54,7 @@ void ProgressCallback::DisplayFormattedInformation(const char* format, ...)
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
DisplayInformation(str);
@ -66,7 +66,7 @@ void ProgressCallback::DisplayFormattedDebugMessage(const char* format, ...)
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
DisplayDebugMessage(str);
@ -78,7 +78,7 @@ void ProgressCallback::DisplayFormattedModalError(const char* format, ...)
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
ModalError(str);
@ -90,7 +90,7 @@ bool ProgressCallback::DisplayFormattedModalConfirmation(const char* format, ...
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
return ModalConfirmation(str);
@ -102,7 +102,7 @@ void ProgressCallback::DisplayFormattedModalInformation(const char* format, ...)
va_list ap;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
ModalInformation(str);
@ -341,7 +341,7 @@ void ConsoleProgressCallback::Redraw(bool update_value_only)
SmallString message;
message.append(m_status_text);
message.append_fmt(" [{:.2f}%]", percent_complete);
message.append_format(" [{:.2f}%]", percent_complete);
if (max_bar_length > 0)
{

View file

@ -179,9 +179,9 @@ void SmallStringBase::append_hex(const void* data, size_t len)
make_room_for(static_cast<u32>(len) * 4);
const u8* bytes = static_cast<const u8*>(data);
append_fmt("{:02X}", bytes[0]);
append_format("{:02X}", bytes[0]);
for (size_t i = 1; i < len; i++)
append_fmt(", {:02X}", bytes[i]);
append_format(", {:02X}", bytes[i]);
}
void SmallStringBase::prepend(const char* str, u32 length)
@ -224,15 +224,15 @@ void SmallStringBase::append(const std::string_view& str)
append(str.data(), static_cast<u32>(str.length()));
}
void SmallStringBase::append_format(const char* format, ...)
void SmallStringBase::append_sprintf(const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
append_format_va(format, ap);
append_vsprintf(format, ap);
va_end(ap);
}
void SmallStringBase::append_format_va(const char* format, va_list ap)
void SmallStringBase::append_vsprintf(const char* format, va_list ap)
{
// We have a 1KB byte buffer on the stack here. If this is too little, we'll grow it via the heap,
// but 1KB should be enough for most strings.
@ -290,15 +290,15 @@ void SmallStringBase::prepend(const std::string_view& str)
prepend(str.data(), static_cast<u32>(str.length()));
}
void SmallStringBase::prepend_format(const char* format, ...)
void SmallStringBase::prepend_sprintf(const char* format, ...)
{
va_list ap;
va_start(ap, format);
prepend_format_va(format, ap);
prepend_vsprintf(format, ap);
va_end(ap);
}
void SmallStringBase::prepend_format_va(const char* format, va_list ArgPtr)
void SmallStringBase::prepend_vsprintf(const char* format, va_list ArgPtr)
{
// We have a 1KB byte buffer on the stack here. If this is too little, we'll grow it via the heap,
// but 1KB should be enough for most strings.
@ -376,18 +376,18 @@ void SmallStringBase::insert(s32 offset, const std::string_view& str)
insert(offset, str.data(), static_cast<u32>(str.size()));
}
void SmallStringBase::format(const char* format, ...)
void SmallStringBase::sprintf(const char* format, ...)
{
va_list ap;
va_start(ap, format);
format_va(format, ap);
vsprintf(format, ap);
va_end(ap);
}
void SmallStringBase::format_va(const char* format, va_list ap)
void SmallStringBase::vsprintf(const char* format, va_list ap)
{
clear();
append_format_va(format, ap);
append_vsprintf(format, ap);
}
void SmallStringBase::assign(const SmallStringBase& copy)

View file

@ -58,11 +58,11 @@ public:
void append(const SmallStringBase& str);
// append formatted string to this string
void append_format(const char* format, ...) printflike(2, 3);
void append_format_va(const char* format, va_list ap);
void append_sprintf(const char* format, ...) printflike(2, 3);
void append_vsprintf(const char* format, va_list ap);
template<typename... T>
void append_fmt(fmt::format_string<T...> fmt, T&&... args);
void append_format(fmt::format_string<T...> fmt, T&&... args);
// append hex string
void append_hex(const void* data, size_t len);
@ -78,11 +78,11 @@ public:
void prepend(const SmallStringBase& str);
// append formatted string to this string
void prepend_format(const char* format, ...) printflike(2, 3);
void prepend_format_va(const char* format, va_list ap);
void prepend_sprintf(const char* format, ...) printflike(2, 3);
void prepend_vsprintf(const char* format, va_list ap);
template<typename... T>
void prepend_fmt(fmt::format_string<T...> fmt, T&&... args);
void prepend_format(fmt::format_string<T...> fmt, T&&... args);
// insert a string at the specified offset
void insert(s32 offset, const char* str);
@ -92,11 +92,11 @@ public:
void insert(s32 offset, const SmallStringBase& str);
// set to formatted string
void format(const char* format, ...) printflike(2, 3);
void format_va(const char* format, va_list ap);
void sprintf(const char* format, ...) printflike(2, 3);
void vsprintf(const char* format, va_list ap);
template<typename... T>
void fmt(fmt::format_string<T...> fmt, T&&... args);
void format(fmt::format_string<T...> fmt, T&&... args);
// compare one string to another
bool equals(const char* str) const;
@ -298,10 +298,10 @@ public:
}
// Override the fromstring method
static SmallStackString from_format(const char* format, ...) printflike(1, 2);
static SmallStackString from_sprintf(const char* format, ...) printflike(1, 2);
template<typename... T>
static SmallStackString from_fmt(fmt::format_string<T...> fmt, T&&... args);
static SmallStackString from_format(fmt::format_string<T...> fmt, T&&... args);
private:
char m_stack_buffer[L + 1];
@ -325,13 +325,13 @@ private:
#endif
template<u32 L>
ALWAYS_INLINE SmallStackString<L> SmallStackString<L>::from_format(const char* format, ...)
ALWAYS_INLINE SmallStackString<L> SmallStackString<L>::from_sprintf(const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
SmallStackString ret;
ret.format_va(format, ap);
ret.vsprintf(format, ap);
va_end(ap);
@ -340,7 +340,7 @@ ALWAYS_INLINE SmallStackString<L> SmallStackString<L>::from_format(const char* f
template<u32 L>
template<typename... T>
ALWAYS_INLINE SmallStackString<L> SmallStackString<L>::from_fmt(fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE SmallStackString<L> SmallStackString<L>::from_format(fmt::format_string<T...> fmt, T&&... args)
{
SmallStackString<L> ret;
fmt::vformat_to(std::back_inserter(ret), fmt, fmt::make_format_args(args...));
@ -353,13 +353,13 @@ using SmallString = SmallStackString<256>;
using LargeString = SmallStackString<512>;
template<typename... T>
ALWAYS_INLINE void SmallStringBase::append_fmt(fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE void SmallStringBase::append_format(fmt::format_string<T...> fmt, T&&... args)
{
fmt::vformat_to(std::back_inserter(*this), fmt, fmt::make_format_args(args...));
}
template<typename... T>
ALWAYS_INLINE void SmallStringBase::prepend_fmt(fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE void SmallStringBase::prepend_format(fmt::format_string<T...> fmt, T&&... args)
{
TinyString str;
fmt::vformat_to(std::back_inserter(str), fmt, fmt::make_format_args(args...));
@ -367,7 +367,7 @@ ALWAYS_INLINE void SmallStringBase::prepend_fmt(fmt::format_string<T...> fmt, T&
}
template<typename... T>
ALWAYS_INLINE void SmallStringBase::fmt(fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE void SmallStringBase::format(fmt::format_string<T...> fmt, T&&... args)
{
clear();
fmt::vformat_to(std::back_inserter(*this), fmt, fmt::make_format_args(args...));

View file

@ -259,7 +259,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.append_fmt("{} ({})", rc_error_str(err), err);
str.append_format("{} ({})", rc_error_str(err), err);
ReportError(str);
}
@ -1542,7 +1542,7 @@ std::string Achievements::GetAchievementBadgePath(const rc_client_achievement_t*
if (achievement->badge_name[0] == 0)
return path;
path = Path::Combine(s_image_directory, TinyString::from_fmt("achievement_{}_{}_{}.png", s_game_id, achievement->id,
path = Path::Combine(s_image_directory, TinyString::from_format("achievement_{}_{}_{}.png", s_game_id, achievement->id,
s_achievement_state_strings[state]));
if (download_if_missing && !FileSystem::FileExists(path.c_str()))
@ -1564,7 +1564,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::from_fmt("user_{}.png", clean_username));
path = Path::Combine(s_image_directory, TinyString::from_format("user_{}.png", clean_username));
return path;
}
@ -2186,12 +2186,12 @@ void Achievements::DrawAchievementsWindow()
{
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.format(TRANSLATE_FS("Achievements", "You have unlocked all achievements and earned {} points!"),
s_game_summary.points_unlocked);
}
else
{
text.fmt(TRANSLATE_FS("Achievements",
text.format(TRANSLATE_FS("Achievements",
"You have unlocked {0} of {1} achievements, earning {2} of {3} possible points."),
s_game_summary.num_unlocked_achievements, s_game_summary.num_core_achievements,
s_game_summary.points_unlocked, s_game_summary.points_core);
@ -2220,7 +2220,7 @@ 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.format("{}%", 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),
@ -2299,7 +2299,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
ImRect bb;
bool visible, hovered;
ImGuiFullscreen::MenuButtonFrame(TinyString::from_fmt("chv_{}", cheevo->id), true,
ImGuiFullscreen::MenuButtonFrame(TinyString::from_format("chv_{}", cheevo->id), true,
!is_measured ? ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT + unlock_size :
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT +
progress_height_unscaled + progress_spacing_unscaled,
@ -2335,7 +2335,7 @@ 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.format((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")));
@ -2371,7 +2371,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
{
TinyString date;
FullscreenUI::TimeToPrintableString(&date, cheevo->unlock_time);
text.fmt(TRANSLATE_FS("Achievements", "Unlocked: {}"), date);
text.format(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.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f),
@ -2543,7 +2543,7 @@ void Achievements::DrawLeaderboardsWindow()
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.format(TRANSLATE_FS("Achievements", "This game has {} leaderboards."), count);
}
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
@ -2762,7 +2762,7 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
float text_start_x = bb.Min.x + LayoutScale(15.0f);
SmallString text;
text.fmt("{}", entry.rank);
text.format("{}", entry.rank);
ImGui::PushFont(g_large_font);
@ -2832,7 +2832,7 @@ void Achievements::DrawLeaderboardListEntry(const rc_client_leaderboard_t* lboar
static constexpr float alpha = 0.8f;
TinyString id_str;
id_str.fmt("{}", lboard->id);
id_str.format("{}", lboard->id);
ImRect bb;
bool visible, hovered;

View file

@ -824,7 +824,7 @@ bool CDROM::PrecacheMedia()
TinyString CDROM::LBAToMSFString(CDImage::LBA lba)
{
const auto pos = CDImage::Position::FromLBA(lba);
return TinyString::from_fmt("{:02d}:{:02d}:{:02d}", pos.minute, pos.second, pos.frame);
return TinyString::from_format("{:02d}:{:02d}:{:02d}", pos.minute, pos.second, pos.frame);
}
void CDROM::SetReadaheadSectors(u32 readahead_sectors)
@ -1425,7 +1425,7 @@ void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late)
{
SmallString params;
for (u32 i = 0; i < s_param_fifo.GetSize(); i++)
params.append_fmt("{}0x{:02X}", (i == 0) ? "" : ", ", s_param_fifo.Peek(i));
params.append_format("{}0x{:02X}", (i == 0) ? "" : ", ", s_param_fifo.Peek(i));
Log_DevFmt("CDROM executing command 0x{:02X} ({}), stat = 0x{:02X}, params = [{}]", static_cast<u8>(s_command),
ci.name, s_secondary_status.bits, params);
}
@ -3410,7 +3410,7 @@ void CDROM::DrawDebugWindow()
// don't want to use locale...
TinyString ret;
TinyString temp;
temp.append_fmt("{}", val);
temp.append_format("{}", val);
u32 commas = 2u - (temp.length() % 3u);
for (const char* p = temp.c_str(); *p != 0u; p++)

View file

@ -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::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));
const std::string* desc = FindKey(kvp, TinyString::from_format("cheat{}_desc", i));
const std::string* code = FindKey(kvp, TinyString::from_format("cheat{}_code", i));
const std::string* enable = FindKey(kvp, TinyString::from_format("cheat{}_enable", i));
if (!desc || !code || !enable)
{
Log_WarningPrintf("Missing desc/code/enable for cheat %u", i);

View file

@ -203,36 +203,36 @@ static void FormatInstruction(SmallStringBase* dest, const Instruction inst, u32
}
else if (std::strncmp(str, "shamt", 5) == 0)
{
dest->append_fmt("{}", ZeroExtend32(inst.r.shamt.GetValue()));
dest->append_format("{}", ZeroExtend32(inst.r.shamt.GetValue()));
str += 5;
}
else if (std::strncmp(str, "immu", 4) == 0)
{
dest->append_fmt("{}", inst.i.imm_zext32());
dest->append_format("{}", 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->append_fmt("{:04x}", inst.i.imm_zext32());
dest->append_format("{: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->append_fmt("{:08x}", target);
dest->append_format("{:08x}", target);
str += 3;
}
else if (std::strncmp(str, "offsetrs", 8) == 0)
{
const s32 offset = static_cast<s32>(inst.i.imm_sext32());
dest->append_fmt("{}({})", offset, GetRegName(inst.i.rs));
dest->append_format("{}({})", 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->append_fmt("{:08x}", target);
dest->append_format("{:08x}", target);
str += 2;
}
else if (std::strncmp(str, "copcc", 5) == 0)
@ -242,17 +242,17 @@ static void FormatInstruction(SmallStringBase* dest, const Instruction inst, u32
}
else if (std::strncmp(str, "coprd", 5) == 0)
{
dest->append_fmt("{}", ZeroExtend32(static_cast<u8>(inst.r.rd.GetValue())));
dest->append_format("{}", ZeroExtend32(static_cast<u8>(inst.r.rd.GetValue())));
str += 5;
}
else if (std::strncmp(str, "coprt", 5) == 0)
{
dest->append_fmt("{}", ZeroExtend32(static_cast<u8>(inst.r.rt.GetValue())));
dest->append_format("{}", ZeroExtend32(static_cast<u8>(inst.r.rt.GetValue())));
str += 5;
}
else if (std::strncmp(str, "cop", 3) == 0)
{
dest->append_fmt("{}", static_cast<u8>(inst.op.GetValue()) & INSTRUCTION_COP_N_MASK);
dest->append_format("{}", static_cast<u8>(inst.op.GetValue()) & INSTRUCTION_COP_N_MASK);
str += 3;
}
else
@ -273,20 +273,20 @@ static void FormatComment(SmallStringBase* dest, const Instruction inst, u32 pc,
if (std::strncmp(str, "rs", 2) == 0)
{
dest->append_fmt("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rs),
dest->append_format("{}{}=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->append_fmt("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rt),
dest->append_format("{}{}=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->append_fmt("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rd),
dest->append_format("{}{}=0x{:08X}", dest->empty() ? "" : ", ", GetRegName(inst.r.rd),
regs->r[static_cast<u8>(inst.r.rd.GetValue())]);
str += 2;
}
@ -309,7 +309,7 @@ static void FormatComment(SmallStringBase* dest, const Instruction inst, u32 pc,
else if (std::strncmp(str, "offsetrs", 8) == 0)
{
const s32 offset = static_cast<s32>(inst.i.imm_sext32());
dest->append_fmt("{}addr={:08X}", dest->empty() ? "" : ", ",
dest->append_format("{}addr={:08X}", dest->empty() ? "" : ", ",
regs->r[static_cast<u8>(inst.i.rs.GetValue())] + offset);
str += 8;
}
@ -353,7 +353,7 @@ static void FormatCopInstruction(SmallStringBase* dest, u32 pc, const Instructio
}
}
dest->fmt("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
dest->format("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
}
template<typename T>
@ -403,7 +403,7 @@ void DisassembleInstruction(SmallStringBase* dest, u32 pc, u32 bits)
case InstructionOp::cop3:
default:
{
dest->fmt("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
dest->format("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
}
break;
}
@ -464,7 +464,7 @@ void DisassembleInstructionComment(SmallStringBase* dest, u32 pc, u32 bits, Regi
case InstructionOp::cop3:
default:
{
dest->fmt("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
dest->format("<cop{} 0x{:08X}>", ZeroExtend32(inst.cop.cop_n.GetValue()), inst.cop.imm25.GetValue());
}
break;
}

View file

@ -255,7 +255,7 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
for (u32 i = 0; i < 10; i++)
{
if (i < disas_instruction.length)
hex.append_fmt(" {:02X}", ptr[i]);
hex.append_format(" {:02X}", ptr[i]);
else
hex.append(" ");
}

View file

@ -60,11 +60,11 @@ class IconStackString : public SmallStackString<L>
public:
ALWAYS_INLINE IconStackString(const char* icon, const char* str)
{
SmallStackString<L>::fmt("{} {}", icon, Host::TranslateToStringView(TR_CONTEXT, str));
SmallStackString<L>::format("{} {}", 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);
SmallStackString<L>::format("{} {}##{}", icon, Host::TranslateToStringView(TR_CONTEXT, str), suffix);
}
};
} // namespace
@ -543,7 +543,7 @@ void FullscreenUI::CancelAsyncOps()
void FullscreenUI::AsyncOpThreadEntryPoint(std::function<void(::ProgressCallback*)> callback,
FullscreenUI::ProgressCallback* progress)
{
Threading::SetNameOfCurrentThread(TinyString::from_fmt("{} Async Op", progress->GetName()).c_str());
Threading::SetNameOfCurrentThread(TinyString::from_format("{} Async Op", progress->GetName()).c_str());
callback(progress);
@ -849,7 +849,7 @@ bool FullscreenUI::LoadResources()
s_fallback_playlist_texture = LoadTexture("fullscreenui/address-book-new.png");
for (u32 i = 0; i < static_cast<u32>(GameDatabase::CompatibilityRating::Count); i++)
s_game_compatibility_textures[i] = LoadTexture(TinyString::from_fmt("fullscreenui/star-{}.png", i).c_str());
s_game_compatibility_textures[i] = LoadTexture(TinyString::from_format("fullscreenui/star-{}.png", i).c_str());
return true;
}
@ -1344,7 +1344,7 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
return;
TinyString title;
title.fmt("{}/{}", section, name);
title.format("{}/{}", section, name);
std::string value = bsi->GetStringValue(section, name);
const bool oneline = (std::count_if(value.begin(), value.end(), [](char ch) { return (ch == '&'); }) <= 1);
@ -1365,24 +1365,24 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
{
if (icon_name)
{
title.fmt("{} {}", icon_name, display_name);
title.format("{} {}", icon_name, display_name);
}
else
{
switch (type)
{
case InputBindingInfo::Type::Button:
title.fmt(ICON_FA_DOT_CIRCLE " {}", display_name);
title.format(ICON_FA_DOT_CIRCLE " {}", display_name);
break;
case InputBindingInfo::Type::Axis:
case InputBindingInfo::Type::HalfAxis:
title.fmt(ICON_FA_BULLSEYE " {}", display_name);
title.format(ICON_FA_BULLSEYE " {}", display_name);
break;
case InputBindingInfo::Type::Motor:
title.fmt(ICON_FA_BELL " {}", display_name);
title.format(ICON_FA_BELL " {}", display_name);
break;
case InputBindingInfo::Type::Macro:
title.fmt(ICON_FA_PIZZA_SLICE " {}", display_name);
title.format(ICON_FA_PIZZA_SLICE " {}", display_name);
break;
default:
title = display_name;
@ -1555,12 +1555,12 @@ void FullscreenUI::DrawInputBindingWindow()
if (ImGui::BeginPopupModal(title, nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoInputs))
{
ImGui::TextWrapped("%s", SmallString::from_fmt(FSUI_FSTR("Setting {} binding {}."), s_input_binding_section,
ImGui::TextWrapped("%s", SmallString::from_format(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::from_fmt(FSUI_FSTR("Timing out in {:.0f} seconds..."), time_remaining));
ImGui::TextUnformatted(SmallString::from_format(FSUI_FSTR("Timing out in {:.0f} seconds..."), time_remaining));
ImGui::EndPopup();
}
@ -2038,7 +2038,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.sprintf(format, value.value());
else
value_text = FSUI_VSTR("Use Global Setting");
@ -2880,13 +2880,13 @@ void FullscreenUI::DrawBIOSSettingsPage()
continue;
TinyString title;
title.fmt(FSUI_FSTR("BIOS for {}"), Settings::GetConsoleRegionDisplayName(region));
title.format(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::from_fmt(FSUI_FSTR("BIOS to use when emulating {} consoles."),
SmallString::from_format(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")))
@ -3137,7 +3137,7 @@ void FullscreenUI::DrawEmulationSettingsPage()
u64 ram_usage, vram_usage;
System::CalculateRewindMemoryUsage(rewind_save_slots, &ram_usage, &vram_usage);
rewind_summary.fmt(
rewind_summary.format(
FSUI_FSTR("Rewind for {0} frames, lasting {1:.2f} seconds will require up to {2} MB of RAM and {3} MB of VRAM."),
rewind_save_slots, duration, ram_usage / 1048576, vram_usage / 1048576);
}
@ -3362,18 +3362,18 @@ void FullscreenUI::DrawControllerSettingsPage()
if (mtap_enabled[mtap_port])
{
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}{}")), mtap_port + 1,
MenuHeading(TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}{}")), mtap_port + 1,
mtap_slot_names[mtap_slot]));
}
else
{
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}")), mtap_port + 1));
MenuHeading(TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}")), mtap_port + 1));
}
const TinyString section = TinyString::from_fmt("Pad{}", global_slot + 1);
const TinyString section = TinyString::from_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::from_fmt("{}##type{}", FSUI_ICONSTR(ICON_FA_GAMEPAD, "Controller Type"), global_slot),
if (MenuButton(TinyString::from_format("{}##type{}", FSUI_ICONSTR(ICON_FA_GAMEPAD, "Controller Type"), global_slot),
ci ? Host::TranslateToCString("ControllerType", ci->display_name) : FSUI_CSTR("Unknown")))
{
std::vector<std::pair<std::string, std::string>> raw_options(Controller::GetControllerTypeNames());
@ -3383,7 +3383,7 @@ void FullscreenUI::DrawControllerSettingsPage()
{
options.emplace_back(std::move(it.second), type == it.first);
}
OpenChoiceDialog(TinyString::from_fmt(FSUI_FSTR("Port {} Controller Type"), global_slot + 1), false,
OpenChoiceDialog(TinyString::from_format(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) {
@ -3415,20 +3415,20 @@ void FullscreenUI::DrawControllerSettingsPage()
if (mtap_enabled[mtap_port])
{
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {}{} Macros")),
MenuHeading(SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {}{} Macros")),
mtap_port + 1, mtap_slot_names[mtap_slot]));
}
else
{
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_MICROCHIP, "Controller Port {} Macros")),
MenuHeading(SmallString::from_format(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::from_fmt("Macro{}", macro_index + 1),
TinyString::from_fmt(FSUI_FSTR("Macro {} Trigger"), macro_index + 1), nullptr);
TinyString::from_format("Macro{}", macro_index + 1),
TinyString::from_format(FSUI_FSTR("Macro {} Trigger"), macro_index + 1), nullptr);
std::string binds_string(
bsi->GetStringValue(section.c_str(), fmt::format("Macro{}Binds", macro_index + 1).c_str()));
@ -3446,11 +3446,11 @@ void FullscreenUI::DrawControllerSettingsPage()
break;
}
}
pretty_binds_string.append_fmt("{}{}", pretty_binds_string.empty() ? "" : " ", dispname);
pretty_binds_string.append_format("{}{}", pretty_binds_string.empty() ? "" : " ", dispname);
}
}
if (MenuButtonWithValue(
TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_KEYBOARD, "Macro {} Buttons")), macro_index + 1),
TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_KEYBOARD, "Macro {} Buttons")), macro_index + 1),
nullptr, pretty_binds_string.empty() ? FSUI_CSTR("-") : pretty_binds_string.c_str(), true,
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
{
@ -3469,7 +3469,7 @@ void FullscreenUI::DrawControllerSettingsPage()
}
OpenChoiceDialog(
TinyString::from_fmt(FSUI_FSTR("Select Macro {} Binds"), macro_index + 1), true, std::move(options),
TinyString::from_format(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;
@ -3489,7 +3489,7 @@ void FullscreenUI::DrawControllerSettingsPage()
auto lock = Host::GetSettingsLock();
SettingsInterface* bsi = GetEditingSettingsInterface(game_settings);
const TinyString key = TinyString::from_fmt("Macro{}Binds", macro_index + 1);
const TinyString key = TinyString::from_format("Macro{}Binds", macro_index + 1);
std::string binds_string = bsi->GetStringValue(section.c_str(), key.c_str());
std::vector<std::string_view> buttons_split(StringUtil::SplitString(binds_string, '&', true));
@ -3513,15 +3513,15 @@ void FullscreenUI::DrawControllerSettingsPage()
});
}
const TinyString freq_key = TinyString::from_fmt("Macro{}Frequency", macro_index + 1);
const TinyString freq_key = TinyString::from_format("Macro{}Frequency", macro_index + 1);
const SmallString freq_title =
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_LIGHTBULB, "Macro {} Frequency")), macro_index + 1);
SmallString::from_format(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("Disabled");
else
freq_summary.fmt(FSUI_FSTR("{} Frames"), frequency);
freq_summary.format(FSUI_FSTR("{} Frames"), frequency);
if (MenuButtonWithValue(freq_title, nullptr, freq_summary, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
ImGui::OpenPopup(freq_title);
@ -3563,19 +3563,19 @@ void FullscreenUI::DrawControllerSettingsPage()
if (mtap_enabled[mtap_port])
{
MenuHeading(
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {}{} Settings")),
SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {}{} Settings")),
mtap_port + 1, mtap_slot_names[mtap_slot]));
}
else
{
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {} Settings")),
MenuHeading(SmallString::from_format(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 "{}", Host::TranslateToStringView(ci->name, si.display_name));
title.format(ICON_FA_COG "{}", Host::TranslateToStringView(ci->name, si.display_name));
const char* description = Host::TranslateToCString(ci->name, si.description);
switch (si.type)
{
@ -3689,13 +3689,13 @@ void FullscreenUI::DrawMemoryCardSettingsPage()
for (u32 i = 0; i < 2; i++)
{
MenuHeading(TinyString::from_fmt(FSUI_FSTR("Memory Card Port {}"), i + 1));
MenuHeading(TinyString::from_format(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::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),
bsi, TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_SD_CARD, "Memory Card {} Type")), i + 1),
SmallString::from_format(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);
@ -3711,7 +3711,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.format("{}##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() : FSUI_CSTR("Use Global Setting"), is_shared))
@ -4194,7 +4194,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.format(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.")))
@ -4228,7 +4228,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.format(ICON_FA_COGS "{}", opt.ui_name);
if (ToggleButton(tstr,
(opt.default_value[0].int_value != 0) ? FSUI_CSTR("Default: Enabled") :
FSUI_CSTR("Default: Disabled"),
@ -4243,8 +4243,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.format(ICON_FA_RULER_VERTICAL "{}##{}", opt.ui_name, opt.name);
str.format(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);
@ -4342,8 +4342,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.format(ICON_FA_RULER_VERTICAL "{}##{}", opt.ui_name, opt.name);
str.format(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);
@ -4608,16 +4608,16 @@ void FullscreenUI::DrawAchievementsSettingsPage()
if (bsi->ContainsValue("Cheevos", "Token"))
{
ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImGui::GetStyle().Colors[ImGuiCol_Text]);
ActiveButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_USER, "Username: {}")),
ActiveButton(SmallString::from_format(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.fmt(
ts_string.format(
"{:%Y-%m-%d %H:%M:%S}",
fmt::localtime(StringUtil::FromChars<u64>(bsi->GetStringValue("Cheevos", "LoginTimestamp", "0")).value_or(0)));
ActiveButton(
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_CLOCK, "Login token generated on {}")), ts_string),
SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_CLOCK, "Login token generated on {}")), ts_string),
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
ImGui::PopStyleColor();
@ -4641,14 +4641,14 @@ void FullscreenUI::DrawAchievementsSettingsPage()
const auto lock = Achievements::GetLock();
ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImGui::GetStyle().Colors[ImGuiCol_Text]);
ActiveButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_BOOKMARK, "Game: {} ({})")),
ActiveButton(SmallString::from_format(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::from_fmt(ICON_FA_MAP "{}", rich_presence_string), false, false,
ActiveButton(SmallString::from_format(ICON_FA_MAP "{}", rich_presence_string), false, false,
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
}
else
@ -4794,7 +4794,7 @@ void FullscreenUI::DrawPauseMenu()
const std::string& serial = System::GetGameSerial();
if (!serial.empty())
buffer.fmt("{} - ", serial);
buffer.format("{} - ", serial);
buffer.append(Path::GetFileName(System::GetDiscPath()));
const float image_width = 60.0f;
@ -4848,7 +4848,7 @@ void FullscreenUI::DrawPauseMenu()
// current time / play time
{
buffer.fmt("{:%X}", fmt::localtime(std::time(nullptr)));
buffer.format("{:%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.c_str(), buffer.end_ptr()));
@ -4861,14 +4861,14 @@ 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));
buffer.format(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.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.c_str(), buffer.end_ptr());
buffer.fmt(FSUI_FSTR("All Time: {}"), GameList::FormatTimespan(cached_played_time + session_time, true));
buffer.format(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.c_str(), buffer.end_ptr()));
const ImVec2 total_pos(display_size.x - LayoutScale(10.0f) - total_size.x,
@ -5809,9 +5809,9 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
GPUTexture* cover_texture = GetGameListCover(entry);
if (entry->serial.empty())
summary.fmt("{} - ", Settings::GetDiscRegionDisplayName(entry->region));
summary.format("{} - ", Settings::GetDiscRegionDisplayName(entry->region));
else
summary.fmt("{} - {} - ", entry->serial, Settings::GetDiscRegionDisplayName(entry->region));
summary.format("{} - {} - ", entry->serial, Settings::GetDiscRegionDisplayName(entry->region));
summary.append(Path::GetFileName(entry->path));
@ -5915,7 +5915,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
// region
{
const TinyString flag_texture =
TinyString::from_fmt("fullscreenui/{}.png", Settings::GetDiscRegionName(selected_entry->region));
TinyString::from_format("fullscreenui/{}.png", Settings::GetDiscRegionName(selected_entry->region));
ImGui::TextUnformatted(FSUI_CSTR("Region: "));
ImGui::SameLine();
ImGui::Image(GetCachedTextureAsync(flag_texture.c_str()), LayoutScale(23.0f, 16.0f));
@ -6050,7 +6050,7 @@ 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.format("{}{}", title, (title.length() == entry->title.length()) ? "" : "...");
ImGui::PushFont(g_medium_font);
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, draw_title.c_str(), draw_title.end_ptr(), nullptr,
ImVec2(0.5f, 0.0f), &title_bb);
@ -6181,7 +6181,7 @@ void FullscreenUI::DrawGameListSettingsPage(const ImVec2& heading_size)
for (const auto& it : s_game_list_directories_cache)
{
if (MenuButton(SmallString::from_fmt(ICON_FA_FOLDER " {}", it.first),
if (MenuButton(SmallString::from_format(ICON_FA_FOLDER " {}", it.first),
it.second ? FSUI_CSTR("Scanning Subdirectories") : FSUI_CSTR("Not Scanning Subdirectories")))
{
ImGuiFullscreen::ChoiceDialogOptions options = {

View file

@ -1047,22 +1047,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.format(TRANSLATE_FS("GameList", "{}h {}m"), hours, minutes);
else if (hours > 0)
ret.fmt(TRANSLATE_FS("GameList", "{}h {}m {}s"), hours, minutes, seconds);
ret.format(TRANSLATE_FS("GameList", "{}h {}m {}s"), hours, minutes, seconds);
else if (minutes > 0)
ret.fmt(TRANSLATE_FS("GameList", "{}m {}s"), minutes, seconds);
ret.format(TRANSLATE_FS("GameList", "{}m {}s"), minutes, seconds);
else if (seconds > 0)
ret.fmt(TRANSLATE_FS("GameList", "{}s"), seconds);
ret.format(TRANSLATE_FS("GameList", "{}s"), seconds);
else
ret = TRANSLATE_SV("GameList", "None");
}
else
{
if (hours > 0)
ret.fmt(TRANSLATE_FS("GameList", "{} hours"), hours);
ret.format(TRANSLATE_FS("GameList", "{} hours"), hours);
else
ret.fmt(TRANSLATE_FS("GameList", "{} minutes"), minutes);
ret.format(TRANSLATE_FS("GameList", "{} minutes"), minutes);
}
return ret;

View file

@ -66,7 +66,7 @@ static std::optional<std::string_view> DeserializePacket(const std::string_view&
static std::string SerializePacket(const std::string_view& in)
{
std::stringstream ss;
ss << '$' << in << '#' << TinyString::from_fmt("{:02x}", ComputeChecksum(in));
ss << '$' << in << '#' << TinyString::from_format("{:02x}", ComputeChecksum(in));
return ss.str();
}

View file

@ -180,7 +180,7 @@ bool GPU::HandleUnknownGP0Command()
SmallString dump;
for (u32 i = 0; i < m_fifo.GetSize(); i++)
dump.append_fmt("{}{:08X}", (i > 0) ? " " : "", FifoPeek(i));
dump.append_format("{}{:08X}", (i > 0) ? " " : "", FifoPeek(i));
Log_ErrorPrintf("FIFO: %s", dump.c_str());
m_fifo.RemoveOne();
@ -512,7 +512,7 @@ void GPU::FinishVRAMWrite()
{
if (g_settings.debugging.dump_cpu_to_vram_copies)
{
DumpVRAMToFile(TinyString::from_fmt("cpu_to_vram_copy_{}.png", s_cpu_to_vram_dump_id++), m_vram_transfer.width,
DumpVRAMToFile(TinyString::from_format("cpu_to_vram_copy_{}.png", s_cpu_to_vram_dump_id++), m_vram_transfer.width,
m_vram_transfer.height, sizeof(u16) * m_vram_transfer.width, m_blit_buffer.data(), true);
}
@ -580,7 +580,7 @@ bool GPU::HandleCopyRectangleVRAMToCPUCommand()
if (g_settings.debugging.dump_vram_to_cpu_copies)
{
DumpVRAMToFile(TinyString::from_fmt("vram_to_cpu_copy_{}.png", s_vram_to_cpu_dump_id++), m_vram_transfer.width,
DumpVRAMToFile(TinyString::from_format("vram_to_cpu_copy_{}.png", s_vram_to_cpu_dump_id++), m_vram_transfer.width,
m_vram_transfer.height, sizeof(u16) * VRAM_WIDTH,
&m_vram_ptr[m_vram_transfer.y * VRAM_WIDTH + m_vram_transfer.x], true);
}

View file

@ -169,7 +169,7 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/,
ImGui::TextUnformatted(message);
TinyString buf;
buf.fmt("{}/{}", progress_value, progress_max);
buf.format("{}/{}", progress_value, progress_max);
const ImVec2 prog_size = ImGui::CalcTextSize(buf.c_str(), buf.end_ptr());
ImGui::SameLine();
@ -245,9 +245,9 @@ void ImGuiManager::FormatProcessorStat(SmallStringBase& text, double usage, doub
// 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.append_fmt("100% ({:.2f}ms)", time);
text.append_format("100% ({:.2f}ms)", time);
else
text.append_fmt("{:.1f}% ({:.2f}ms)", usage, time);
text.append_format("{:.1f}% ({:.2f}ms)", usage, time);
}
void ImGuiManager::DrawPerformanceOverlay()
@ -293,18 +293,18 @@ void ImGuiManager::DrawPerformanceOverlay()
const float speed = System::GetEmulationSpeed();
if (g_settings.display_show_fps)
{
text.append_fmt("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS());
text.append_format("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS());
first = false;
}
if (g_settings.display_show_speed)
{
text.append_fmt("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed)));
text.append_format("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed)));
const float target_speed = System::GetTargetSpeed();
if (target_speed <= 0.0f)
text.append(" (Max)");
else
text.append_fmt(" ({:.0f}%)", target_speed * 100.0f);
text.append_format(" ({:.0f}%)", target_speed * 100.0f);
first = false;
}
@ -327,14 +327,14 @@ 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.format("{}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.fmt("{:.2f}ms | {:.2f}ms | {:.2f}ms", System::GetMinimumFrameTime(), System::GetAverageFrameTime(),
text.format("{:.2f}ms | {:.2f}ms | {:.2f}ms", System::GetMinimumFrameTime(), System::GetAverageFrameTime(),
System::GetMaximumFrameTime());
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
@ -346,34 +346,34 @@ void ImGuiManager::DrawPerformanceOverlay()
text.assign("CPU[");
if (g_settings.cpu_overclock_active)
{
text.append_fmt("{}", g_settings.GetCPUOverclockPercent());
text.append_format("{}", g_settings.GetCPUOverclockPercent());
first = false;
}
if (g_settings.cpu_execution_mode == CPUExecutionMode::Interpreter)
{
text.append_fmt("{}{}", first ? "" : "/", "I");
text.append_format("{}{}", first ? "" : "/", "I");
first = false;
}
else if (g_settings.cpu_execution_mode == CPUExecutionMode::CachedInterpreter)
{
text.append_fmt("{}{}", first ? "" : "/", "CI");
text.append_format("{}{}", first ? "" : "/", "CI");
first = false;
}
else if (g_settings.cpu_execution_mode == CPUExecutionMode::NewRec)
{
text.append_fmt("{}{}", first ? "" : "/", "NR");
text.append_format("{}{}", first ? "" : "/", "NR");
first = false;
}
else
{
if (g_settings.cpu_recompiler_icache)
{
text.append_fmt("{}{}", first ? "" : "/", "IC");
text.append_format("{}{}", first ? "" : "/", "IC");
first = false;
}
if (g_settings.cpu_recompiler_memory_exceptions)
{
text.append_fmt("{}{}", first ? "" : "/", "ME");
text.append_format("{}{}", first ? "" : "/", "ME");
first = false;
}
}
@ -460,14 +460,14 @@ void ImGuiManager::DrawPerformanceOverlay()
ImDrawList* win_dl = ImGui::GetCurrentWindow()->DrawList;
const ImVec2 wpos(ImGui::GetCurrentWindow()->Pos);
text.fmt("{:.1f} ms", max);
text.format("{:.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.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.c_str(), text.end_ptr());
text.fmt("{:.1f} ms", min);
text.format("{:.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),
@ -495,28 +495,28 @@ void ImGuiManager::DrawPerformanceOverlay()
void ImGuiManager::DrawEnhancementsOverlay()
{
LargeString text;
text.append_fmt("{} {}-{}", Settings::GetConsoleRegionName(System::GetRegion()),
text.append_format("{} {}-{}", Settings::GetConsoleRegionName(System::GetRegion()),
GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()),
g_gpu->IsHardwareRenderer() ? "HW" : "SW");
if (g_settings.rewind_enable)
text.append_fmt(" RW={}/{}", g_settings.rewind_save_frequency, g_settings.rewind_save_slots);
text.append_format(" RW={}/{}", g_settings.rewind_save_frequency, g_settings.rewind_save_slots);
if (g_settings.IsRunaheadEnabled())
text.append_fmt(" RA={}", g_settings.runahead_frames);
text.append_format(" RA={}", g_settings.runahead_frames);
if (g_settings.cpu_overclock_active)
text.append_fmt(" CPU={}%", g_settings.GetCPUOverclockPercent());
text.append_format(" CPU={}%", g_settings.GetCPUOverclockPercent());
if (g_settings.enable_8mb_ram)
text.append(" 8MB");
if (g_settings.cdrom_read_speedup != 1)
text.append_fmt(" CDR={}x", g_settings.cdrom_read_speedup);
text.append_format(" CDR={}x", g_settings.cdrom_read_speedup);
if (g_settings.cdrom_seek_speedup != 1)
text.append_fmt(" CDS={}x", g_settings.cdrom_seek_speedup);
text.append_format(" CDS={}x", g_settings.cdrom_seek_speedup);
if (g_settings.gpu_resolution_scale != 1)
text.append_fmt(" IR={}x", g_settings.gpu_resolution_scale);
text.append_format(" IR={}x", g_settings.gpu_resolution_scale);
if (g_settings.gpu_multisamples != 1)
{
text.append_fmt(" {}x{}", g_settings.gpu_multisamples, g_settings.gpu_per_sample_shading ? "SSAA" : "MSAA");
text.append_format(" {}x{}", g_settings.gpu_multisamples, g_settings.gpu_per_sample_shading ? "SSAA" : "MSAA");
}
if (g_settings.gpu_true_color)
text.append(" TrueCol");
@ -525,7 +525,7 @@ void ImGuiManager::DrawEnhancementsOverlay()
if (g_settings.gpu_force_ntsc_timings && System::GetRegion() == ConsoleRegion::PAL)
text.append(" PAL60");
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest)
text.append_fmt(" {}", Settings::GetTextureFilterName(g_settings.gpu_texture_filter));
text.append_format(" {}", 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)
{
@ -604,9 +604,9 @@ void ImGuiManager::DrawInputsOverlay()
continue;
if (cinfo->icon_name)
text.append_fmt("{} {}", cinfo->icon_name, port + 1u);
text.append_format("{} {}", cinfo->icon_name, port + 1u);
else
text.append_fmt("{} |", port + 1u);
text.append_format("{} |", port + 1u);
for (const Controller::ControllerBindingInfo& bi : cinfo->bindings)
{
@ -618,9 +618,9 @@ void ImGuiManager::DrawInputsOverlay()
// axes are always shown
const float value = controller->GetBindState(bi.bind_index);
if (value >= (254.0f / 255.0f))
text.append_fmt(" {}", bi.icon_name ? bi.icon_name : bi.name);
text.append_format(" {}", bi.icon_name ? bi.icon_name : bi.name);
else if (value > (1.0f / 255.0f))
text.append_fmt(" {}: {:.2f}", bi.icon_name ? bi.icon_name : bi.name, value);
text.append_format(" {}: {:.2f}", bi.icon_name ? bi.icon_name : bi.name, value);
}
break;
@ -629,7 +629,7 @@ void ImGuiManager::DrawInputsOverlay()
// buttons only shown when active
const float value = controller->GetBindState(bi.bind_index);
if (value >= 0.5f)
text.append_fmt(" {}", bi.icon_name ? bi.icon_name : bi.name);
text.append_format(" {}", bi.icon_name ? bi.icon_name : bi.name);
}
break;
@ -953,7 +953,7 @@ void SaveStateSelectorUI::Draw()
ImGui::Indent(text_indent);
ImGui::TextUnformatted(TinyString::from_fmt(entry.global ?
ImGui::TextUnformatted(TinyString::from_format(entry.global ?
TRANSLATE_FS("SaveStateSelectorUI", "Global Slot {}") :
TRANSLATE_FS("SaveStateSelectorUI", "Game Slot {}"),
entry.slot)

View file

@ -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::from_fmt("_lib{}", lib_counter++));
lib_name = file.GetTagString(TinyString::from_format("_lib{}", lib_counter++));
if (!lib_name.has_value())
break;

View file

@ -1500,7 +1500,7 @@ bool SPU::StartDumpingAudio(const char* filename)
if (i == NUM_VOICES)
new_suffix.assign("reverb.wav");
else
new_suffix.fmt("voice{}.wav", i);
new_suffix.format("voice{}.wav", i);
const std::string voice_filename = Path::ReplaceExtension(filename, new_suffix);
if (!s_voice_dump_writers[i]->Open(voice_filename.c_str(), SAMPLE_RATE, 2))

View file

@ -236,7 +236,7 @@ static bool s_discord_presence_active = false;
static TinyString GetTimestampStringForFileName()
{
return TinyString::from_fmt("{:%Y-%m-%d_%H-%M-%S}", fmt::localtime(std::time(nullptr)));
return TinyString::from_format("{:%Y-%m-%d_%H-%M-%S}", fmt::localtime(std::time(nullptr)));
}
void System::Internal::ProcessStartup()
@ -3408,7 +3408,7 @@ bool System::CheckForSBIFile(CDImage* image)
{
return Host::ConfirmMessage(
"Confirm Unsupported Configuration",
LargeString::from_fmt(
LargeString::from_format(
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?"),
@ -3418,7 +3418,7 @@ bool System::CheckForSBIFile(CDImage* image)
{
Host::ReportErrorAsync(
TRANSLATE("System", "Error"),
LargeString::from_fmt(
LargeString::from_format(
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."),

View file

@ -481,7 +481,7 @@ void GameListWidget::resizeTableViewColumnsToFit()
static TinyString getColumnVisibilitySettingsKeyName(int column)
{
return TinyString::from_fmt("Show{}", GameListModel::getColumnName(static_cast<GameListModel::Column>(column)));
return TinyString::from_format("Show{}", GameListModel::getColumnName(static_cast<GameListModel::Column>(column)));
}
void GameListWidget::loadTableViewColumnVisibilitySettings()

View file

@ -172,7 +172,7 @@ void MemoryCardSettingsWidget::onBrowseMemoryCardPathClicked(int index)
void MemoryCardSettingsWidget::onMemoryCardPathChanged(int index)
{
const auto key = TinyString::from_fmt("Card{}Path", index + 1);
const auto key = TinyString::from_format("Card{}Path", index + 1);
std::string relative_path(
Path::MakeRelative(m_port_ui[index].memory_card_path->text().toStdString(), EmuFolders::MemoryCards));
m_dialog->setStringSettingValue("MemoryCards", key, relative_path.c_str());
@ -180,7 +180,7 @@ void MemoryCardSettingsWidget::onMemoryCardPathChanged(int index)
void MemoryCardSettingsWidget::onResetMemoryCardPathClicked(int index)
{
const auto key = TinyString::from_fmt("Card{}Path", index + 1);
const auto key = TinyString::from_format("Card{}Path", index + 1);
if (m_dialog->isPerGameSettings())
m_dialog->removeSettingValue("MemoryCards", key);
else
@ -191,7 +191,7 @@ void MemoryCardSettingsWidget::onResetMemoryCardPathClicked(int index)
void MemoryCardSettingsWidget::updateMemoryCardPath(int index)
{
const auto key = TinyString::from_fmt("Card{}Path", index + 1);
const auto key = TinyString::from_format("Card{}Path", index + 1);
std::string path(
m_dialog->getEffectiveStringValue("MemoryCards", key, Settings::GetDefaultSharedMemoryCardName(index).c_str()));
if (!Path::IsAbsolute(path))

View file

@ -66,7 +66,7 @@ void CubebAudioStream::LogCallback(const char* fmt, ...)
LargeString str;
std::va_list ap;
va_start(ap, fmt);
str.format_va(fmt, ap);
str.vsprintf(fmt, ap);
va_end(ap);
Log_DevPrint(str);
}

View file

@ -76,7 +76,7 @@ void CueParser::File::SetError(u32 line_number, Error* error, const char* format
std::va_list ap;
SmallString str;
va_start(ap, format);
str.format_va(format, ap);
str.vsprintf(format, ap);
va_end(ap);
Log_ErrorPrintf("Cue parse error at line %u: %s", line_number, str.c_str());

View file

@ -408,17 +408,17 @@ TinyString DInputSource::ConvertKeyToString(InputBindingKey key)
{
const char* modifier =
(key.modifier == InputModifier::FullAxis ? "Full" : (key.modifier == InputModifier::Negate ? "-" : "+"));
ret.fmt("DInput-{}/{}Axis{}{}", u32(key.source_index), modifier, u32(key.data), key.invert ? "~" : "");
ret.format("DInput-{}/{}Axis{}{}", u32(key.source_index), modifier, u32(key.data), key.invert ? "~" : "");
}
else if (key.source_subtype == InputSubclass::ControllerButton && key.data >= MAX_NUM_BUTTONS)
{
const u32 hat_num = (key.data - MAX_NUM_BUTTONS) / NUM_HAT_DIRECTIONS;
const u32 hat_dir = (key.data - MAX_NUM_BUTTONS) % NUM_HAT_DIRECTIONS;
ret.fmt("DInput-{}/Hat{}{}", u32(key.source_index), hat_num, s_hat_directions[hat_dir]);
ret.format("DInput-{}/Hat{}{}", u32(key.source_index), hat_num, s_hat_directions[hat_dir]);
}
else if (key.source_subtype == InputSubclass::ControllerButton)
{
ret.fmt("DInput-{}/Button{}", u32(key.source_index), u32(key.data));
ret.format("DInput-{}/Button{}", u32(key.source_index), u32(key.data));
}
}

View file

@ -318,7 +318,7 @@ void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version)
if (m_features.pipeline_cache)
{
const std::string pc_filename =
Path::Combine(base_path, TinyString::from_fmt("{}.bin", GetShaderCacheBaseName("pipelines")));
Path::Combine(base_path, TinyString::from_format("{}.bin", GetShaderCacheBaseName("pipelines")));
if (FileSystem::FileExists(pc_filename.c_str()))
{
Log_InfoPrintf("Removing old pipeline cache '%s'", pc_filename.c_str());
@ -337,7 +337,7 @@ void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version)
if (m_features.pipeline_cache && !base_path.empty())
{
const std::string basename = GetShaderCacheBaseName("pipelines");
const std::string filename = Path::Combine(base_path, TinyString::from_fmt("{}.bin", basename));
const std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename));
if (ReadPipelineCache(filename))
s_pipeline_cache_path = std::move(filename);
else

View file

@ -761,10 +761,10 @@ struct GLAutoPop
#define GL_INS(msg) g_gpu_device->InsertDebugMessage(msg)
#define GL_OBJECT_NAME(obj, name) (obj)->SetDebugName(name)
#define GL_SCOPE_FMT(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(SmallString::from_fmt(__VA_ARGS__)), 0))
#define GL_PUSH_FMT(...) g_gpu_device->PushDebugGroup(SmallString::from_fmt(__VA_ARGS__))
#define GL_INS_FMT(...) g_gpu_device->InsertDebugMessage(SmallString::from_fmt(__VA_ARGS__))
#define GL_OBJECT_NAME_FMT(obj, ...) (obj)->SetDebugName(SmallString::from_fmt(__VA_ARGS__))
#define GL_SCOPE_FMT(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(SmallString::from_format(__VA_ARGS__)), 0))
#define GL_PUSH_FMT(...) g_gpu_device->PushDebugGroup(SmallString::from_format(__VA_ARGS__))
#define GL_INS_FMT(...) g_gpu_device->InsertDebugMessage(SmallString::from_format(__VA_ARGS__))
#define GL_OBJECT_NAME_FMT(obj, ...) (obj)->SetDebugName(SmallString::from_format(__VA_ARGS__))
#else
#define GL_SCOPE(name) (void)0
#define GL_PUSH(name) (void)0

View file

@ -2435,7 +2435,7 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac
dl->AddRectFilled(pos, ImVec2(pos.x + fraction * (box_end.x - pos.x), box_end.y),
ImGui::GetColorU32(UISecondaryColor));
const auto text = TinyString::from_fmt("{}%", static_cast<int>(std::round(fraction * 100.0f)));
const auto text = TinyString::from_format("{}%", static_cast<int>(std::round(fraction * 100.0f)));
const ImVec2 text_size(ImGui::CalcTextSize(text));
const ImVec2 text_pos(pos.x + ((box_end.x - pos.x) / 2.0f) - (text_size.x / 2.0f),
pos.y + ((box_end.y - pos.y) / 2.0f) - (text_size.y / 2.0f));

View file

@ -1840,7 +1840,7 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
if (bnum >= std::size(button_mapping))
continue;
new_bind.fmt("SDL-{}/{}", cnum, button_mapping[bnum]);
new_bind.format("SDL-{}/{}", cnum, button_mapping[bnum]);
si.SetStringValue(new_section.c_str(), new_key, new_bind);
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
num_changes++;
@ -1850,14 +1850,14 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
if (bnum >= std::size(axis_mapping))
continue;
new_bind.fmt("SDL-{}/{}{}", cnum, dir, axis_mapping[bnum]);
new_bind.format("SDL-{}/{}{}", cnum, dir, axis_mapping[bnum]);
si.SetStringValue(new_section.c_str(), new_key, new_bind);
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
num_changes++;
}
else if (StringUtil::StartsWith(old_bind.c_str(), "Keyboard/Keypad+"))
{
new_bind.fmt("Keyboard/Numpad{}", old_bind.substr(16));
new_bind.format("Keyboard/Numpad{}", old_bind.substr(16));
si.SetStringValue(new_section.c_str(), new_key, new_bind);
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
num_changes++;
@ -1890,9 +1890,9 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
if (bnum >= std::size(axis_mapping))
continue;
new_bind.fmt("SDL-{}/-{}", cnum, axis_mapping[bnum]);
new_bind.format("SDL-{}/-{}", cnum, axis_mapping[bnum]);
si.SetStringValue(new_section.c_str(), new_neg_key, new_bind);
new_bind.fmt("SDL-{}/+{}", cnum, axis_mapping[bnum]);
new_bind.format("SDL-{}/+{}", cnum, axis_mapping[bnum]);
si.SetStringValue(new_section.c_str(), new_pos_key, new_bind);
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
@ -1906,9 +1906,9 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
unsigned cnum;
if (std::sscanf(rumble_source.c_str(), "Controller%u", &cnum) == 1)
{
new_bind.fmt("SDL-{}/LargeMotor", cnum);
new_bind.format("SDL-{}/LargeMotor", cnum);
si.SetStringValue(new_section.c_str(), "LargeMotor", new_bind);
new_bind.fmt("SDL-{}/SmallMotor", cnum);
new_bind.format("SDL-{}/SmallMotor", cnum);
si.SetStringValue(new_section.c_str(), "SmallMotor", new_bind);
num_changes++;
}

View file

@ -359,7 +359,7 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
else
{
glBindAttribLocation(program_id, i,
TinyString::from_fmt("{}{}", semantic_vars[static_cast<u8>(va.semantic.GetValue())],
TinyString::from_format("{}{}", semantic_vars[static_cast<u8>(va.semantic.GetValue())],
static_cast<u8>(va.semantic_index)));
}
}
@ -420,7 +420,7 @@ void OpenGLDevice::PostLinkProgram(const GPUPipeline::GraphicsConfig& plconfig,
const u32 num_textures = std::max<u32>(GetActiveTexturesForLayout(plconfig.layout), 1);
for (u32 i = 0; i < num_textures; i++)
{
location = glGetUniformLocation(program_id, TinyString::from_fmt("samp{}", i));
location = glGetUniformLocation(program_id, TinyString::from_format("samp{}", i));
if (location >= 0)
glUniform1i(location, i);
}

View file

@ -127,11 +127,11 @@ TinyString PostProcessing::ValueToString(ShaderOption::Type type, u32 vector_siz
break;
case ShaderOption::Type::Int:
ret.append_fmt("{}", value[i].int_value);
ret.append_format("{}", value[i].int_value);
break;
case ShaderOption::Type::Float:
ret.append_fmt("{}", value[i].float_value);
ret.append_format("{}", value[i].float_value);
break;
default:
@ -210,7 +210,7 @@ std::vector<std::pair<std::string, std::string>> PostProcessing::GetAvailableSha
TinyString PostProcessing::GetStageConfigSection(u32 index)
{
return TinyString::from_fmt("PostProcessing/Stage{}", index + 1);
return TinyString::from_format("PostProcessing/Stage{}", index + 1);
}
void PostProcessing::CopyStageConfig(SettingsInterface& si, u32 old_index, u32 new_index)

View file

@ -455,11 +455,11 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
(key.modifier == InputModifier::FullAxis ? "Full" : (key.modifier == InputModifier::Negate ? "-" : "+"));
if (key.data < std::size(s_sdl_axis_names))
{
ret.fmt("SDL-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_sdl_axis_names[key.data]);
ret.format("SDL-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_sdl_axis_names[key.data]);
}
else
{
ret.fmt("SDL-{}/{}Axis{}{}", static_cast<u32>(key.source_index), modifier,
ret.format("SDL-{}/{}Axis{}{}", static_cast<u32>(key.source_index), modifier,
key.data - static_cast<u32>(std::size(s_sdl_axis_names)), key.invert ? "~" : "");
}
}
@ -467,11 +467,11 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
{
if (key.data < std::size(s_sdl_button_names))
{
ret.fmt("SDL-{}/{}", static_cast<u32>(key.source_index), s_sdl_button_names[key.data]);
ret.format("SDL-{}/{}", static_cast<u32>(key.source_index), s_sdl_button_names[key.data]);
}
else
{
ret.fmt("SDL-{}/Button{}", static_cast<u32>(key.source_index),
ret.format("SDL-{}/Button{}", static_cast<u32>(key.source_index),
key.data - static_cast<u32>(std::size(s_sdl_button_names)));
}
}
@ -479,16 +479,16 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
{
const u32 hat_index = key.data / static_cast<u32>(std::size(s_sdl_hat_direction_names));
const u32 hat_direction = key.data % static_cast<u32>(std::size(s_sdl_hat_direction_names));
ret.fmt("SDL-{}/Hat{}{}", static_cast<u32>(key.source_index), hat_index,
ret.format("SDL-{}/Hat{}{}", static_cast<u32>(key.source_index), hat_index,
s_sdl_hat_direction_names[hat_direction]);
}
else if (key.source_subtype == InputSubclass::ControllerMotor)
{
ret.fmt("SDL-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
ret.format("SDL-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
}
else if (key.source_subtype == InputSubclass::ControllerHaptic)
{
ret.fmt("SDL-{}/Haptic", static_cast<u32>(key.source_index));
ret.format("SDL-{}/Haptic", static_cast<u32>(key.source_index));
}
}
@ -505,14 +505,14 @@ TinyString SDLInputSource::ConvertKeyToIcon(InputBindingKey key)
{
if (key.data < std::size(s_sdl_axis_icons) && key.modifier != InputModifier::FullAxis)
{
ret.fmt("SDL-{} {}", static_cast<u32>(key.source_index),
ret.format("SDL-{} {}", static_cast<u32>(key.source_index),
s_sdl_axis_icons[key.data][key.modifier == InputModifier::None]);
}
}
else if (key.source_subtype == InputSubclass::ControllerButton)
{
if (key.data < std::size(s_sdl_button_icons))
ret.fmt("SDL-{} {}", static_cast<u32>(key.source_index), s_sdl_button_icons[key.data]);
ret.format("SDL-{} {}", static_cast<u32>(key.source_index), s_sdl_button_icons[key.data]);
}
}

View file

@ -700,7 +700,7 @@ bool VulkanDevice::CreateCommandBuffers()
LOG_VULKAN_ERROR(res, "vkCreateCommandPool failed: ");
return false;
}
Vulkan::SetObjectName(m_device, resources.command_pool, TinyString::from_fmt("Frame Command Pool {}", frame_index));
Vulkan::SetObjectName(m_device, resources.command_pool, TinyString::from_format("Frame Command Pool {}", frame_index));
VkCommandBufferAllocateInfo buffer_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr,
resources.command_pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY,
@ -715,7 +715,7 @@ bool VulkanDevice::CreateCommandBuffers()
for (u32 i = 0; i < resources.command_buffers.size(); i++)
{
Vulkan::SetObjectName(m_device, resources.command_buffers[i],
TinyString::from_fmt("Frame {} {}Command Buffer", frame_index, (i == 0) ? "Init" : ""));
TinyString::from_format("Frame {} {}Command Buffer", frame_index, (i == 0) ? "Init" : ""));
}
VkFenceCreateInfo fence_info = {VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT};
@ -726,7 +726,7 @@ bool VulkanDevice::CreateCommandBuffers()
LOG_VULKAN_ERROR(res, "vkCreateFence failed: ");
return false;
}
Vulkan::SetObjectName(m_device, resources.fence, TinyString::from_fmt("Frame Fence {}", frame_index));
Vulkan::SetObjectName(m_device, resources.fence, TinyString::from_format("Frame Fence {}", frame_index));
if (!m_optional_extensions.vk_khr_push_descriptor)
{
@ -745,7 +745,7 @@ bool VulkanDevice::CreateCommandBuffers()
return false;
}
Vulkan::SetObjectName(m_device, resources.descriptor_pool,
TinyString::from_fmt("Frame Descriptor Pool {}", frame_index));
TinyString::from_format("Frame Descriptor Pool {}", frame_index));
}
++frame_index;

View file

@ -325,15 +325,15 @@ TinyString XInputSource::ConvertKeyToString(InputBindingKey key)
if (key.source_subtype == InputSubclass::ControllerAxis && key.data < std::size(s_axis_names))
{
const char modifier = key.modifier == InputModifier::Negate ? '-' : '+';
ret.fmt("XInput-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_axis_names[key.data]);
ret.format("XInput-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_axis_names[key.data]);
}
else if (key.source_subtype == InputSubclass::ControllerButton && key.data < std::size(s_button_names))
{
ret.fmt("XInput-{}/{}", static_cast<u32>(key.source_index), s_button_names[key.data]);
ret.format("XInput-{}/{}", static_cast<u32>(key.source_index), s_button_names[key.data]);
}
else if (key.source_subtype == InputSubclass::ControllerMotor)
{
ret.fmt("XInput-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
ret.format("XInput-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
}
}
@ -350,14 +350,14 @@ TinyString XInputSource::ConvertKeyToIcon(InputBindingKey key)
{
if (key.data < std::size(s_axis_icons) && key.modifier != InputModifier::FullAxis)
{
ret.fmt("XInput-{} {}", static_cast<u32>(key.source_index),
ret.format("XInput-{} {}", static_cast<u32>(key.source_index),
s_axis_icons[key.data][key.modifier == InputModifier::None]);
}
}
else if (key.source_subtype == InputSubclass::ControllerButton)
{
if (key.data < std::size(s_button_icons))
ret.fmt("XInput-{} {}", static_cast<u32>(key.source_index), s_button_icons[key.data]);
ret.format("XInput-{} {}", static_cast<u32>(key.source_index), s_button_icons[key.data]);
}
}