SmallString: Add missing methods

Backport of
79c226efff
2cd747983a
6b7cf6a432
f75a5605eb
This commit is contained in:
Stenzek 2024-04-12 23:24:20 +10:00 committed by Connor McLaughlin
parent ece20b1307
commit 9fa409a1a9
19 changed files with 404 additions and 221 deletions

View File

@ -103,7 +103,7 @@ __ri void Log::WriteToConsole(LOGLEVEL level, ConsoleColors color, std::string_v
buffer.append(s_ansi_color_codes[color]);
if (s_log_timestamps)
buffer.append_fmt(TIMESTAMP_FORMAT_STRING, Log::GetCurrentMessageTime());
buffer.append_format(TIMESTAMP_FORMAT_STRING, Log::GetCurrentMessageTime());
buffer.append(message);
buffer.append('\n');
@ -352,7 +352,7 @@ bool Log::SetFileOutputLevel(LOGLEVEL level, std::string path)
s_file_path = {};
if (IsConsoleOutputEnabled())
WriteToConsole(LOGLEVEL_ERROR, Color_StrongRed, TinyString::from_fmt("Failed to open log file '{}'", path));
WriteToConsole(LOGLEVEL_ERROR, Color_StrongRed, TinyString::from_format("Failed to open log file '{}'", path));
}
}
}

View File

@ -82,7 +82,7 @@ bool DynamicLibrary::Open(const char* filename, Error* error)
m_handle = reinterpret_cast<void*>(LoadLibraryW(StringUtil::UTF8StringToWideString(filename).c_str()));
if (!m_handle)
{
Error::SetWin32(error, TinyString::from_fmt("Loading {} failed: ", filename), GetLastError());
Error::SetWin32(error, TinyString::from_format("Loading {} failed: ", filename), GetLastError());
return false;
}

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#include "SmallString.h"
@ -39,14 +39,14 @@ SmallStringBase::SmallStringBase(SmallStringBase&& move)
assign(std::move(move));
}
SmallStringBase::SmallStringBase(const std::string_view& sv)
SmallStringBase::SmallStringBase(const std::string_view sv)
{
assign(sv);
}
SmallStringBase::SmallStringBase(const std::string& str)
SmallStringBase::SmallStringBase(const std::string& str)
{
assign(str);
assign(str);
}
SmallStringBase::~SmallStringBase()
@ -89,7 +89,7 @@ void SmallStringBase::reserve(u32 new_reserve)
m_on_heap = true;
}
m_buffer_size = real_reserve;
m_buffer_size = new_reserve;
}
void SmallStringBase::shrink_to_fit()
@ -125,7 +125,7 @@ SmallStringBase& SmallStringBase::operator=(SmallStringBase&& move)
return *this;
}
SmallStringBase& SmallStringBase::operator=(const std::string_view& str)
SmallStringBase& SmallStringBase::operator=(const std::string_view str)
{
assign(str);
return *this;
@ -172,6 +172,18 @@ void SmallStringBase::append(const char* str, u32 length)
m_buffer[m_length] = 0;
}
void SmallStringBase::append_hex(const void* data, size_t len)
{
if (len == 0)
return;
make_room_for(static_cast<u32>(len) * 4);
const u8* bytes = static_cast<const u8*>(data);
append_format("{:02X}", bytes[0]);
for (size_t i = 1; i < len; i++)
append_format(", {:02X}", bytes[i]);
}
void SmallStringBase::prepend(const char* str, u32 length)
{
if (length == 0)
@ -207,27 +219,27 @@ void SmallStringBase::append(const std::string& str)
append(str.c_str(), static_cast<u32>(str.length()));
}
void SmallStringBase::append(const std::string_view& str)
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.
char stack_buffer[1024];
char* heap_buffer = nullptr;
char* buffer = stack_buffer;
u32 buffer_size = std::size(stack_buffer);
u32 buffer_size = static_cast<u32>(std::size(stack_buffer));
u32 written;
for (;;)
@ -273,27 +285,27 @@ void SmallStringBase::prepend(const std::string& str)
prepend(str.c_str(), static_cast<u32>(str.length()));
}
void SmallStringBase::prepend(const std::string_view& str)
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.
char stack_buffer[1024];
char* heap_buffer = NULL;
char* buffer = stack_buffer;
u32 buffer_size = std::size(stack_buffer);
u32 buffer_size = static_cast<u32>(std::size(stack_buffer));
u32 written;
for (;;)
@ -359,23 +371,23 @@ void SmallStringBase::insert(s32 offset, const std::string& str)
insert(offset, str.c_str(), static_cast<u32>(str.size()));
}
void SmallStringBase::insert(s32 offset, const std::string_view& str)
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)
@ -421,12 +433,18 @@ void SmallStringBase::assign(const std::string& str)
append(str.data(), static_cast<u32>(str.size()));
}
void SmallStringBase::assign(const std::string_view& str)
void SmallStringBase::assign(const std::string_view str)
{
clear();
append(str.data(), static_cast<u32>(str.size()));
}
void SmallStringBase::vformat(fmt::string_view fmt, fmt::format_args args)
{
clear();
fmt::vformat_to(std::back_inserter(*this), fmt, args);
}
bool SmallStringBase::equals(const char* str) const
{
if (m_length == 0)
@ -440,10 +458,16 @@ bool SmallStringBase::equals(const SmallStringBase& str) const
return (m_length == str.m_length && (m_length == 0 || std::strcmp(m_buffer, str.m_buffer) == 0));
}
bool SmallStringBase::equals(const std::string_view& str) const
bool SmallStringBase::equals(const std::string_view str) const
{
return (m_length == static_cast<u32>(str.length()) &&
(m_length == 0 || CASE_N_COMPARE(m_buffer, str.data(), m_length) == 0));
(m_length == 0 || std::memcmp(m_buffer, str.data(), m_length) == 0));
}
bool SmallStringBase::equals(const std::string& str) const
{
return (m_length == static_cast<u32>(str.length()) &&
(m_length == 0 || std::memcmp(m_buffer, str.data(), m_length) == 0));
}
bool SmallStringBase::iequals(const char* otherText) const
@ -459,30 +483,114 @@ bool SmallStringBase::iequals(const SmallStringBase& str) const
return (m_length == str.m_length && (m_length == 0 || std::strcmp(m_buffer, str.m_buffer) == 0));
}
bool SmallStringBase::iequals(const std::string_view& str) const
bool SmallStringBase::iequals(const std::string_view str) const
{
return (m_length == static_cast<u32>(str.length()) &&
(m_length == 0 || CASE_N_COMPARE(m_buffer, str.data(), m_length) == 0));
}
int SmallStringBase::compare(const SmallStringBase& str) const
bool SmallStringBase::iequals(const std::string& str) const
{
return std::strcmp(m_buffer, str.m_buffer);
return (m_length == static_cast<u32>(str.length()) &&
(m_length == 0 || CASE_N_COMPARE(m_buffer, str.data(), m_length) == 0));
}
int SmallStringBase::compare(const char* otherText) const
{
return std::strcmp(m_buffer, otherText);
return compare(std::string_view(otherText));
}
int SmallStringBase::icompare(const SmallStringBase& otherString) const
int SmallStringBase::compare(const SmallStringBase& str) const
{
return CASE_COMPARE(m_buffer, otherString.m_buffer);
if (m_length == 0)
return (str.m_length == 0) ? 0 : -1;
else if (str.m_length == 0)
return 1;
const int res = std::strncmp(m_buffer, str.m_buffer, std::min(m_length, str.m_length));
if (m_length == str.m_length || res != 0)
return res;
else
return (m_length > str.m_length) ? 1 : -1;
}
int SmallStringBase::compare(const std::string_view str) const
{
const u32 slength = static_cast<u32>(str.length());
if (m_length == 0)
return (slength == 0) ? 0 : -1;
else if (slength == 0)
return 1;
const int res = std::strncmp(m_buffer, str.data(), std::min(m_length, slength));
if (m_length == slength || res != 0)
return res;
else
return (m_length > slength) ? 1 : -1;
}
int SmallStringBase::compare(const std::string& str) const
{
const u32 slength = static_cast<u32>(str.length());
if (m_length == 0)
return (slength == 0) ? 0 : -1;
else if (slength == 0)
return 1;
const int res = std::strncmp(m_buffer, str.data(), std::min(m_length, slength));
if (m_length == slength || res != 0)
return res;
else
return (m_length > slength) ? 1 : -1;
}
int SmallStringBase::icompare(const char* otherText) const
{
return CASE_COMPARE(m_buffer, otherText);
return icompare(std::string_view(otherText));
}
int SmallStringBase::icompare(const SmallStringBase& str) const
{
if (m_length == 0)
return (str.m_length == 0) ? 0 : -1;
else if (str.m_length == 0)
return 1;
const int res = CASE_N_COMPARE(m_buffer, str.m_buffer, std::min(m_length, str.m_length));
if (m_length == str.m_length || res != 0)
return res;
else
return (m_length > str.m_length) ? 1 : -1;
}
int SmallStringBase::icompare(const std::string_view str) const
{
const u32 slength = static_cast<u32>(str.length());
if (m_length == 0)
return (slength == 0) ? 0 : -1;
else if (slength == 0)
return 1;
const int res = CASE_N_COMPARE(m_buffer, str.data(), std::min(m_length, slength));
if (m_length == slength || res != 0)
return res;
else
return (m_length > slength) ? 1 : -1;
}
int SmallStringBase::icompare(const std::string& str) const
{
const u32 slength = static_cast<u32>(str.length());
if (m_length == 0)
return (slength == 0) ? 0 : -1;
else if (slength == 0)
return 1;
const int res = CASE_N_COMPARE(m_buffer, str.data(), std::min(m_length, slength));
if (m_length == slength || res != 0)
return res;
else
return (m_length > slength) ? 1 : -1;
}
bool SmallStringBase::starts_with(const char* str, bool case_sensitive) const
@ -505,7 +613,17 @@ bool SmallStringBase::starts_with(const SmallStringBase& str, bool case_sensitiv
(CASE_N_COMPARE(str.m_buffer, m_buffer, other_length) == 0);
}
bool SmallStringBase::starts_with(const std::string_view& str, bool case_sensitive) const
bool SmallStringBase::starts_with(const std::string_view str, bool case_sensitive) const
{
const u32 other_length = static_cast<u32>(str.length());
if (other_length > m_length)
return false;
return (case_sensitive) ? (std::strncmp(str.data(), m_buffer, other_length) == 0) :
(CASE_N_COMPARE(str.data(), m_buffer, other_length) == 0);
}
bool SmallStringBase::starts_with(const std::string& str, bool case_sensitive) const
{
const u32 other_length = static_cast<u32>(str.length());
if (other_length > m_length)
@ -537,7 +655,18 @@ bool SmallStringBase::ends_with(const SmallStringBase& str, bool case_sensitive)
(CASE_N_COMPARE(str.m_buffer, m_buffer + start_offset, other_length) == 0);
}
bool SmallStringBase::ends_with(const std::string_view& str, bool case_sensitive) const
bool SmallStringBase::ends_with(const std::string_view str, bool case_sensitive) const
{
const u32 other_length = static_cast<u32>(str.length());
if (other_length > m_length)
return false;
const u32 start_offset = m_length - other_length;
return (case_sensitive) ? (std::strncmp(str.data(), m_buffer + start_offset, other_length) == 0) :
(CASE_N_COMPARE(str.data(), m_buffer + start_offset, other_length) == 0);
}
bool SmallStringBase::ends_with(const std::string& str, bool case_sensitive) const
{
const u32 other_length = static_cast<u32>(str.length());
if (other_length > m_length)
@ -589,6 +718,16 @@ s32 SmallStringBase::find(const char* str, u32 offset) const
return at ? static_cast<s32>(at - m_buffer) : -1;
}
u32 SmallStringBase::count(char ch) const
{
const char* ptr = m_buffer;
const char* end = ptr + m_length;
u32 count = 0;
while (ptr != end)
count += static_cast<u32>(*(ptr++) == ch);
return count;
}
void SmallStringBase::resize(u32 new_size, char fill, bool shrink_if_smaller)
{
// if going larger, or we don't own the buffer, realloc

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#pragma once
@ -29,7 +29,7 @@ public:
SmallStringBase(const SmallStringBase& copy);
SmallStringBase(SmallStringBase&& move);
SmallStringBase(const std::string& str);
SmallStringBase(const std::string_view& sv);
SmallStringBase(const std::string_view sv);
// Destructor. Child classes may not have any destructors, as this is not virtual.
~SmallStringBase();
@ -38,7 +38,7 @@ public:
void assign(const char* str);
void assign(const char* str, u32 length);
void assign(const std::string& copy);
void assign(const std::string_view& copy);
void assign(const std::string_view copy);
void assign(const SmallStringBase& copy);
void assign(SmallStringBase&& move);
@ -55,15 +55,18 @@ public:
void append(const char* appendText);
void append(const char* str, u32 length);
void append(const std::string& str);
void append(const std::string_view& str);
void append(const std::string_view str);
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);
// append a single character to this string
void prepend(char c);
@ -72,53 +75,61 @@ public:
void prepend(const char* str);
void prepend(const char* str, u32 length);
void prepend(const std::string& str);
void prepend(const std::string_view& str);
void prepend(const std::string_view str);
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);
void insert(s32 offset, const char* str, u32 length);
void insert(s32 offset, const std::string& str);
void insert(s32 offset, const std::string_view& str);
void insert(s32 offset, const std::string_view str);
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);
void vformat(fmt::string_view fmt, fmt::format_args args);
// compare one string to another
bool equals(const char* str) const;
bool equals(const SmallStringBase& str) const;
bool equals(const std::string_view& str) const;
bool equals(const std::string_view str) const;
bool equals(const std::string& str) const;
bool iequals(const char* str) const;
bool iequals(const SmallStringBase& str) const;
bool iequals(const std::string_view& str) const;
bool iequals(const std::string_view str) const;
bool iequals(const std::string& str) const;
// numerical compares
int compare(const char* str) const;
int compare(const SmallStringBase& str) const;
int compare(const std::string_view& str) const;
int compare(const std::string_view str) const;
int compare(const std::string& str) const;
int icompare(const char* str) const;
int icompare(const SmallStringBase& str) const;
int icompare(const std::string_view& str) const;
int icompare(const std::string_view str) const;
int icompare(const std::string& str) const;
// starts with / ends with
bool starts_with(const char* str, bool case_sensitive = true) const;
bool starts_with(const std::string_view& str, bool case_sensitive = true) const;
bool starts_with(const SmallStringBase& str, bool case_sensitive = true) const;
bool starts_with(const std::string_view str, bool case_sensitive = true) const;
bool starts_with(const std::string& str, bool case_sensitive = true) const;
bool ends_with(const char* str, bool case_sensitive = true) const;
bool ends_with(const std::string_view& str, bool case_sensitive = true) const;
bool ends_with(const SmallStringBase& str, bool case_sensitive = true) const;
bool ends_with(const std::string_view str, bool case_sensitive = true) const;
bool ends_with(const std::string& str, bool case_sensitive = true) const;
// searches for a character inside a string
// rfind is the same except it starts at the end instead of the start
@ -131,6 +142,9 @@ public:
// returns -1 if it is not found, otherwise the offset in the string
s32 find(const char* str, u32 offset = 0) const;
// returns the number of instances of the specified character
u32 count(char ch) const;
// removes characters from string
void erase(s32 offset, s32 count = std::numeric_limits<s32>::max());
@ -179,21 +193,25 @@ public:
// comparative operators
__fi bool operator==(const char* str) const { return equals(str); }
__fi bool operator==(const SmallStringBase& str) const { return equals(str); }
__fi bool operator==(const std::string_view& str) const { return equals(str); }
__fi bool operator==(const std::string_view str) const { return equals(str); }
__fi bool operator==(const std::string& str) const { return equals(str); }
__fi bool operator!=(const char* str) const { return !equals(str); }
__fi bool operator!=(const SmallStringBase& str) const { return !equals(str); }
__fi bool operator!=(const std::string_view& str) const { return !equals(str); }
__fi bool operator!=(const std::string_view str) const { return !equals(str); }
__fi bool operator!=(const std::string& str) const { return !equals(str); }
__fi bool operator<(const char* str) const { return (compare(str) < 0); }
__fi bool operator<(const SmallStringBase& str) const { return (compare(str) < 0); }
__fi bool operator<(const std::string_view& str) const { return (compare(str) < 0); }
__fi bool operator<(const std::string_view str) const { return (compare(str) < 0); }
__fi bool operator<(const std::string& str) const { return (compare(str) < 0); }
__fi bool operator>(const char* str) const { return (compare(str) > 0); }
__fi bool operator>(const SmallStringBase& str) const { return (compare(str) > 0); }
__fi bool operator>(const std::string_view& str) const { return (compare(str) > 0); }
__fi bool operator>(const std::string_view str) const { return (compare(str) > 0); }
__fi bool operator>(const std::string& str) const { return (compare(str) > 0); }
SmallStringBase& operator=(const SmallStringBase& copy);
SmallStringBase& operator=(const char* str);
SmallStringBase& operator=(const std::string& str);
SmallStringBase& operator=(const std::string_view& str);
SmallStringBase& operator=(const std::string_view str);
SmallStringBase& operator=(SmallStringBase&& move);
protected:
@ -253,7 +271,7 @@ public:
assign(move);
}
__fi SmallStackString(const std::string_view& sv)
__fi SmallStackString(const std::string_view sv)
{
init();
assign(sv);
@ -283,7 +301,7 @@ public:
return *this;
}
__fi SmallStackString& operator=(const std::string_view& sv)
__fi SmallStackString& operator=(const std::string_view sv)
{
assign(sv);
return *this;
@ -296,26 +314,12 @@ public:
}
// Override the fromstring method
__fi static SmallStackString from_format(const char* format, ...) /*printflike(1, 2)*/
{
std::va_list ap;
va_start(ap, format);
SmallStackString ret;
ret.format_va(format, ap);
va_end(ap);
return ret;
}
static SmallStackString from_sprintf(const char* format, ...) /*printflike(1, 2)*/;
template <typename... T>
__fi static SmallStackString from_fmt(fmt::format_string<T...> fmt, T&&... args)
{
SmallStackString ret;
fmt::vformat_to(std::back_inserter(ret), fmt, fmt::make_format_args(args...));
return ret;
}
static SmallStackString from_format(fmt::format_string<T...> fmt, T&&... args);
static SmallStackString from_vformat(fmt::string_view fmt, fmt::format_args args);
private:
char m_stack_buffer[L + 1];
@ -333,18 +337,54 @@ private:
}
};
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4459) // warning C4459: declaration of 'uint' hides global declaration
#endif
template <u32 L>
__fi SmallStackString<L> SmallStackString<L>::from_sprintf(const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
SmallStackString ret;
ret.vsprintf(format, ap);
va_end(ap);
return ret;
}
template <u32 L>
template <typename... T>
__fi 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...));
return ret;
}
template <u32 L>
__fi SmallStackString<L> SmallStackString<L>::from_vformat(fmt::string_view fmt, fmt::format_args args)
{
SmallStackString<L> ret;
fmt::vformat_to(std::back_inserter(ret), fmt, args);
return ret;
}
// stack string types
typedef SmallStackString<64> TinyString;
typedef SmallStackString<256> SmallString;
using TinyString = SmallStackString<64>;
using SmallString = SmallStackString<256>;
template <typename... T>
__fi void SmallStringBase::append_fmt(fmt::format_string<T...> fmt, T&&... args)
__fi 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>
__fi void SmallStringBase::prepend_fmt(fmt::format_string<T...> fmt, T&&... args)
__fi 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...));
@ -352,12 +392,16 @@ __fi void SmallStringBase::prepend_fmt(fmt::format_string<T...> fmt, T&&... args
}
template <typename... T>
__fi void SmallStringBase::fmt(fmt::format_string<T...> fmt, T&&... args)
__fi void SmallStringBase::format(fmt::format_string<T...> fmt, T&&... args)
{
clear();
fmt::vformat_to(std::back_inserter(*this), fmt, fmt::make_format_args(args...));
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#define MAKE_FORMATTER(type) \
template <> \
struct fmt::formatter<type> \

View File

@ -24,11 +24,11 @@ static QString GetDocFileUrl(std::string_view name)
#ifdef _WIN32
// Windows uses the docs directory in bin.
const std::string path = Path::Combine(EmuFolders::AppRoot,
TinyString::from_fmt("docs" FS_OSPATH_SEPARATOR_STR "{}", name));
TinyString::from_format("docs" FS_OSPATH_SEPARATOR_STR "{}", name));
#else
// Linux/Mac has this in the Resources directory.
const std::string path = Path::Combine(EmuFolders::Resources,
TinyString::from_fmt("docs" FS_OSPATH_SEPARATOR_STR "{}", name));
TinyString::from_format("docs" FS_OSPATH_SEPARATOR_STR "{}", name));
#endif
return QUrl::fromLocalFile(QString::fromStdString(path)).toString();
}

View File

@ -308,14 +308,14 @@ void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::s
{
// Non-standard fonts always go to the user resources directory, since they're downloaded on demand.
font_path = Path::Combine(EmuFolders::UserResources,
SmallString::from_fmt("fonts" FS_OSPATH_SEPARATOR_STR "{}", imgui_font_name));
SmallString::from_format("fonts" FS_OSPATH_SEPARATOR_STR "{}", imgui_font_name));
if (!DownloadMissingFont(dialog_parent, imgui_font_name, font_path))
font_path.clear();
}
if (font_path.empty())
{
// Use the default font.
font_path = EmuFolders::GetOverridableResourcePath(SmallString::from_fmt(
font_path = EmuFolders::GetOverridableResourcePath(SmallString::from_format(
"fonts" FS_OSPATH_SEPARATOR_STR "{}", DEFAULT_IMGUI_FONT_NAME));
}

View File

@ -262,7 +262,7 @@ void Achievements::ReportRCError(int err, fmt::format_string<T...> fmt, T&&... a
{
SmallString 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);
}
@ -1560,7 +1560,7 @@ std::string Achievements::GetAchievementBadgePath(const rc_client_achievement_t*
return path;
path = Path::Combine(s_image_directory,
TinyString::from_fmt("achievement_{}_{}_{}.png", s_game_id, achievement->id, s_achievement_state_strings[state]));
TinyString::from_format("achievement_{}_{}_{}.png", s_game_id, achievement->id, s_achievement_state_strings[state]));
if (!FileSystem::FileExists(path.c_str()))
{
@ -1581,7 +1581,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;
}
@ -2188,12 +2188,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", "You have unlocked {0} of {1} achievements, earning {2} of {3} possible points."),
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()
dl->AddRectFilled(progress_bb.Min, 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),
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f));
@ -2312,7 +2312,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 + extra_summary_height + unlock_size :
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT + extra_summary_height + progress_height_unscaled + progress_spacing_unscaled,
&visible, &hovered, &bb.Min, &bb.Max, 0, alpha);
@ -2347,7 +2347,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"), cheevo->points);
text.format((cheevo->points != 1) ? TRANSLATE_FS("Achievements", "{} points") : TRANSLATE_FS("Achievements", "{} point"), cheevo->points);
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;
@ -2398,7 +2398,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
if (is_unlocked)
{
text.fmt(TRANSLATE_FS("Achievements", "Unlocked: {}"), FullscreenUI::TimeToPrintableString(cheevo->unlock_time));
text.format(TRANSLATE_FS("Achievements", "Unlocked: {}"), FullscreenUI::TimeToPrintableString(cheevo->unlock_time));
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), &unlock_bb);
@ -2564,7 +2564,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));
@ -2764,7 +2764,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);
@ -2831,7 +2831,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

@ -607,7 +607,7 @@ void GSgetStats(SmallStringBase& info)
{
const double fps = GetVerticalFrequency();
const double fillrate = pm.Get(GSPerfMon::Fillrate);
info.fmt("{} SW | {} S | {} P | {} D | {:.2f} U | {:.2f} D | {:.2f} mpps",
info.format("{} SW | {} S | {} P | {} D | {:.2f} U | {:.2f} D | {:.2f} mpps",
api_name,
(int)pm.Get(GSPerfMon::SyncPoint),
(int)pm.Get(GSPerfMon::Prim),
@ -622,7 +622,7 @@ void GSgetStats(SmallStringBase& info)
}
else
{
info.fmt("{} HW | {} P | {} D | {} DC | {} B | {} RP | {} RB | {} TC | {} TU",
info.format("{} HW | {} P | {} D | {} DC | {} B | {} RP | {} RB | {} TC | {} TU",
api_name,
(int)pm.Get(GSPerfMon::Prim),
(int)pm.Get(GSPerfMon::Draw),

View File

@ -844,7 +844,7 @@ bool GSCapture::DeliverVideoFrame(GSTexture* stex)
}
#ifdef PCSX2_DEVBUILD
pf.tex->SetDebugName(TinyString::from_fmt("GSCapture {}x{} Download Texture", stex->GetWidth(), stex->GetHeight()));
pf.tex->SetDebugName(TinyString::from_format("GSCapture {}x{} Download Texture", stex->GetWidth(), stex->GetHeight()));
#endif
}
@ -1361,7 +1361,7 @@ TinyString GSCapture::GetElapsedTime()
TinyString ret;
if (seconds >= 0)
ret.fmt("{:02d}:{:02d}:{:02d}", seconds / 3600, (seconds % 3600) / 60, seconds % 60);
ret.format("{:02d}:{:02d}:{:02d}", seconds / 3600, (seconds % 3600) / 60, seconds % 60);
return ret;
}

View File

@ -455,7 +455,7 @@ GSTexture* GSDevice::FetchSurface(GSTexture::Type type, int width, int height, i
{
const TextureLabel label = GetTextureLabel(type, format);
const u32 id = ++s_texture_counts[static_cast<u32>(label)];
t->SetDebugName(TinyString::from_fmt("{} {}", TextureLabelString(label), id));
t->SetDebugName(TinyString::from_format("{} {}", TextureLabelString(label), id));
}
#endif
}

View File

@ -2452,7 +2452,7 @@ bool GSDevice12::CompileConvertPipelines()
if (!m_convert[index])
return false;
D3D12::SetObjectName(m_convert[index].get(), TinyString::from_fmt("Convert pipeline {}", static_cast<int>(i)));
D3D12::SetObjectName(m_convert[index].get(), TinyString::from_format("Convert pipeline {}", static_cast<int>(i)));
if (i == ShaderConvert::COPY)
{
@ -2468,7 +2468,7 @@ bool GSDevice12::CompileConvertPipelines()
if (!m_color_copy[j])
return false;
D3D12::SetObjectName(m_color_copy[j].get(), TinyString::from_fmt("Color copy pipeline (r={}, g={}, b={}, a={})",
D3D12::SetObjectName(m_color_copy[j].get(), TinyString::from_format("Color copy pipeline (r={}, g={}, b={}, a={})",
j & 1u, (j >> 1) & 1u, (j >> 2) & 1u, (j >> 3) & 1u));
}
}
@ -2493,7 +2493,7 @@ bool GSDevice12::CompileConvertPipelines()
if (!m_color_copy[j])
return false;
D3D12::SetObjectName(m_color_copy[j].get(), TinyString::from_fmt("Color copy pipeline (r={}, g={}, b={}, a={})",
D3D12::SetObjectName(m_color_copy[j].get(), TinyString::from_format("Color copy pipeline (r={}, g={}, b={}, a={})",
j & 1u, (j >> 1) & 1u, (j >> 2) & 1u, (j >> 3) & 1u));
}
}
@ -2511,7 +2511,7 @@ bool GSDevice12::CompileConvertPipelines()
if (!arr[ds])
return false;
D3D12::SetObjectName(arr[ds].get(), TinyString::from_fmt("HDR {}/copy pipeline (ds={})", is_setup ? "setup" : "finish", ds));
D3D12::SetObjectName(arr[ds].get(), TinyString::from_format("HDR {}/copy pipeline (ds={})", is_setup ? "setup" : "finish", ds));
}
}
}
@ -2539,7 +2539,7 @@ bool GSDevice12::CompileConvertPipelines()
return false;
D3D12::SetObjectName(m_date_image_setup_pipelines[ds][datm].get(),
TinyString::from_fmt("DATE image clear pipeline (ds={}, datm={})", ds, (datm == 1 || datm == 3)));
TinyString::from_format("DATE image clear pipeline (ds={}, datm={})", ds, (datm == 1 || datm == 3)));
}
}
@ -2584,7 +2584,7 @@ bool GSDevice12::CompilePresentPipelines()
if (!m_present[index])
return false;
D3D12::SetObjectName(m_present[index].get(), TinyString::from_fmt("Present pipeline {}", static_cast<int>(i)));
D3D12::SetObjectName(m_present[index].get(), TinyString::from_format("Present pipeline {}", static_cast<int>(i)));
}
return true;
@ -2620,7 +2620,7 @@ bool GSDevice12::CompileInterlacePipelines()
if (!m_interlace[i])
return false;
D3D12::SetObjectName(m_convert[i].get(), TinyString::from_fmt("Interlace pipeline {}", static_cast<int>(i)));
D3D12::SetObjectName(m_convert[i].get(), TinyString::from_format("Interlace pipeline {}", static_cast<int>(i)));
}
return true;
@ -2657,7 +2657,7 @@ bool GSDevice12::CompileMergePipelines()
if (!m_merge[i])
return false;
D3D12::SetObjectName(m_convert[i].get(), TinyString::from_fmt("Merge pipeline {}", i));
D3D12::SetObjectName(m_convert[i].get(), TinyString::from_format("Merge pipeline {}", i));
}
return true;
@ -2990,7 +2990,7 @@ GSDevice12::ComPtr<ID3D12PipelineState> GSDevice12::CreateTFXPipeline(const Pipe
if (pipeline)
{
D3D12::SetObjectName(
pipeline.get(), TinyString::from_fmt("TFX Pipeline {:08X}/{:08X}{:016X}", p.vs.key, p.ps.key_hi, p.ps.key_lo));
pipeline.get(), TinyString::from_format("TFX Pipeline {:08X}/{:08X}{:016X}", p.vs.key, p.ps.key_hi, p.ps.key_lo));
}
return pipeline;

View File

@ -2943,7 +2943,7 @@ bool GSTextureCache::PrepareDownloadTexture(u32 width, u32 height, GSTexture::Fo
}
#ifdef PCSX2_DEVBUILD
(*tex)->SetDebugName(TinyString::from_fmt("Texture Cache {}x{} {} Readback",
(*tex)->SetDebugName(TinyString::from_format("Texture Cache {}x{} {} Readback",
new_width, new_height, GSTexture::GetFormatName(format)));
#endif
@ -4414,12 +4414,12 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
if (psm.pal > 0)
{
src->m_texture->SetDebugName(TinyString::from_fmt("Offset {},{} from 0x{:X} {} CBP 0x{:X}", x_offset, y_offset,
src->m_texture->SetDebugName(TinyString::from_format("Offset {},{} from 0x{:X} {} CBP 0x{:X}", x_offset, y_offset,
static_cast<u32>(TEX0.TBP0), psm_str(TEX0.PSM), static_cast<u32>(TEX0.CBP)));
}
else
{
src->m_texture->SetDebugName(TinyString::from_fmt("Offset {},{} from 0x{:X} {} ", x_offset, y_offset,
src->m_texture->SetDebugName(TinyString::from_format("Offset {},{} from 0x{:X} {} ", x_offset, y_offset,
static_cast<u32>(TEX0.TBP0), psm_str(TEX0.PSM), static_cast<u32>(TEX0.CBP)));
}
}
@ -4664,7 +4664,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
#ifdef PCSX2_DEVBUILD
if (GSConfig.UseDebugDevice)
{
src->m_texture->SetDebugName(TinyString::from_fmt("{}x{} copy of 0x{:X} {}", new_size.x, new_size.y,
src->m_texture->SetDebugName(TinyString::from_format("{}x{} copy of 0x{:X} {}", new_size.x, new_size.y,
static_cast<u32>(TEX0.TBP0), psm_str(TEX0.PSM)));
}
#endif
@ -4700,12 +4700,12 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
if (psm.pal > 0)
{
src->m_texture->SetDebugName(TinyString::from_fmt("Reinterpret 0x{:X} from {} to {} CBP 0x{:X}",
src->m_texture->SetDebugName(TinyString::from_format("Reinterpret 0x{:X} from {} to {} CBP 0x{:X}",
static_cast<u32>(TEX0.TBP0), psm_str(dst->m_TEX0.PSM), psm_str(TEX0.PSM), static_cast<u32>(TEX0.CBP)));
}
else
{
src->m_texture->SetDebugName(TinyString::from_fmt("Reinterpret 0x{:X} from {} to {}",
src->m_texture->SetDebugName(TinyString::from_format("Reinterpret 0x{:X} from {} to {}",
static_cast<u32>(TEX0.TBP0), psm_str(dst->m_TEX0.PSM), psm_str(TEX0.PSM)));
}
}
@ -4795,13 +4795,13 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
if (psm.pal > 0)
{
src->m_texture->SetDebugName(TinyString::from_fmt("{}x{} {} @ 0x{:X} TBW={} CBP=0x{:X}",
src->m_texture->SetDebugName(TinyString::from_format("{}x{} {} @ 0x{:X} TBW={} CBP=0x{:X}",
tw, th, psm_str(TEX0.PSM), static_cast<u32>(TEX0.TBP0), static_cast<u32>(TEX0.TBW),
static_cast<u32>(TEX0.CBP)));
}
else
{
src->m_texture->SetDebugName(TinyString::from_fmt("{}x{} {} @ 0x{:X} TBW={}",
src->m_texture->SetDebugName(TinyString::from_format("{}x{} {} @ 0x{:X} TBW={}",
tw, th, psm_str(TEX0.PSM), static_cast<u32>(TEX0.TBP0), static_cast<u32>(TEX0.TBW)));
}
}
@ -6373,7 +6373,7 @@ void GSTextureCache::Target::UpdateTextureDebugName()
#ifdef PCSX2_DEVBUILD
if (GSConfig.UseDebugDevice)
{
m_texture->SetDebugName(SmallString::from_fmt("{} 0x{:X} {} BW={} {}x{}",
m_texture->SetDebugName(SmallString::from_format("{} 0x{:X} {} BW={} {}x{}",
m_type ? "DS" : "RT", static_cast<u32>(m_TEX0.TBP0), psm_str(m_TEX0.PSM), static_cast<u32>(m_TEX0.TBW),
m_unscaled_size.x, m_unscaled_size.y));
}

View File

@ -61,11 +61,11 @@ namespace
public:
__fi 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));
}
__fi 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
@ -1186,7 +1186,7 @@ void FullscreenUI::DrawInputBindingButton(
SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, const char* name, const char* display_name, const char* icon_name, bool show_type)
{
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);
@ -1207,24 +1207,24 @@ void FullscreenUI::DrawInputBindingButton(
{
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_PF_CONTROLLER_VIBRATION " {}", display_name);
title.format(ICON_PF_CONTROLLER_VIBRATION " {}", display_name);
break;
case InputBindingInfo::Type::Macro:
title.fmt(ICON_PF_THUNDERBOLT " {}", display_name);
title.format(ICON_PF_THUNDERBOLT " {}", display_name);
break;
default:
title = display_name;
@ -2294,7 +2294,7 @@ void FullscreenUI::DrawSettingInfoSetting(SettingsInterface* bsi, const char* se
const char* translation_ctx)
{
SmallString title;
title.fmt(ICON_FA_COG " {}", Host::TranslateToStringView(translation_ctx, si.display_name));
title.format(ICON_FA_COG " {}", Host::TranslateToStringView(translation_ctx, si.display_name));
switch (si.type)
{
case SettingInfo::Type::Boolean:
@ -2516,7 +2516,7 @@ void FullscreenUI::DrawSettingsWindow()
if (s_game_settings_entry)
{
NavTitle(SmallString::from_fmt(
NavTitle(SmallString::from_format(
"{} ({})", Host::TranslateToCString(TR_CONTEXT, titles[static_cast<u32>(pages[index])]), s_game_settings_entry->GetTitle(true)));
}
else
@ -3649,14 +3649,14 @@ void FullscreenUI::DrawMemoryCardSettingsPage()
for (u32 port = 0; port < NUM_MEMORY_CARD_PORTS; port++)
{
SmallString str;
str.fmt(FSUI_FSTR("Slot {}"), port + 1);
str.format(FSUI_FSTR("Slot {}"), port + 1);
MenuHeading(str.c_str());
std::string enable_key(fmt::format("Slot{}_Enable", port + 1));
std::string file_key(fmt::format("Slot{}_Filename", port + 1));
DrawToggleSetting(bsi,
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR_S(ICON_PF_MEMORY_CARD, "Card Enabled", "##card_enabled_{}")), port),
SmallString::from_format(fmt::runtime(FSUI_ICONSTR_S(ICON_PF_MEMORY_CARD, "Card Enabled", "##card_enabled_{}")), port),
FSUI_CSTR("If not set, this card will be considered unplugged."), "MemoryCards", enable_key.c_str(), true);
const bool enabled = GetEffectiveBoolSetting(bsi, "MemoryCards", enable_key.c_str(), true);
@ -3664,7 +3664,7 @@ void FullscreenUI::DrawMemoryCardSettingsPage()
std::optional<std::string> value(bsi->GetOptionalStringValue("MemoryCards", file_key.c_str(),
IsEditingGameSettings(bsi) ? std::nullopt : std::optional<const char*>(FileMcd_GetDefaultName(port).c_str())));
if (MenuButtonWithValue(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR_S(ICON_FA_FILE, "Card Name", "##card_name_{}")), port),
if (MenuButtonWithValue(SmallString::from_format(fmt::runtime(FSUI_ICONSTR_S(ICON_FA_FILE, "Card Name", "##card_name_{}")), port),
FSUI_CSTR("The selected memory card image will be used for this slot."),
value.has_value() ? value->c_str() : FSUI_CSTR("Use Global Setting"), enabled))
{
@ -3722,7 +3722,7 @@ void FullscreenUI::DrawMemoryCardSettingsPage()
});
}
if (MenuButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR_S(ICON_FA_EJECT, "Eject Card", "##eject_card_{}")), port),
if (MenuButton(SmallString::from_format(fmt::runtime(FSUI_ICONSTR_S(ICON_FA_EJECT, "Eject Card", "##eject_card_{}")), port),
FSUI_CSTR("Removes the current card from the slot."), enabled))
{
bsi->SetStringValue("MemoryCards", file_key.c_str(), "");
@ -3952,12 +3952,12 @@ void FullscreenUI::DrawControllerSettingsPage()
ImGui::PushID(global_slot);
if (mtap_enabled[mtap_port])
{
MenuHeading(SmallString::from_fmt(
MenuHeading(SmallString::from_format(
fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}{}")), mtap_port + 1, mtap_slot_names[mtap_slot]));
}
else
{
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}")), mtap_port + 1));
MenuHeading(SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "Controller Port {}")), mtap_port + 1));
}
const char* section = sections[global_slot];
@ -3998,12 +3998,12 @@ void FullscreenUI::DrawControllerSettingsPage()
if (mtap_enabled[mtap_port])
{
MenuHeading(SmallString::from_fmt(
MenuHeading(SmallString::from_format(
fmt::runtime(FSUI_ICONSTR(ICON_PF_EMPTY_KEYCAP, "Controller Port {}{} Macros")), mtap_port + 1, mtap_slot_names[mtap_slot]));
}
else
{
MenuHeading(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_PF_EMPTY_KEYCAP, "Controller Port {} Macros")), mtap_port + 1));
MenuHeading(SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_PF_EMPTY_KEYCAP, "Controller Port {} Macros")), mtap_port + 1));
}
static bool macro_button_expanded[Pad::NUM_CONTROLLER_PORTS][Pad::NUM_MACRO_BUTTONS_PER_CONTROLLER] = {};
@ -4012,13 +4012,13 @@ void FullscreenUI::DrawControllerSettingsPage()
{
bool& expanded = macro_button_expanded[global_slot][macro_index];
expanded ^=
MenuHeadingButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_PF_EMPTY_KEYCAP, "Macro Button {}")), macro_index + 1),
MenuHeadingButton(SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_PF_EMPTY_KEYCAP, "Macro Button {}")), macro_index + 1),
macro_button_expanded[global_slot][macro_index] ? ICON_FA_CHEVRON_UP : ICON_FA_CHEVRON_DOWN);
if (!expanded)
continue;
DrawInputBindingButton(
bsi, InputBindingInfo::Type::Macro, section, TinyString::from_fmt("Macro{}", macro_index + 1), "Trigger", nullptr);
bsi, InputBindingInfo::Type::Macro, section, TinyString::from_format("Macro{}", macro_index + 1), "Trigger", nullptr);
std::string binds_string(bsi->GetStringValue(section, fmt::format("Macro{}Binds", macro_index + 1).c_str()));
TinyString pretty_binds_string;
@ -4035,7 +4035,7 @@ 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(FSUI_ICONSTR(ICON_FA_KEYBOARD, "Buttons"), nullptr, pretty_binds_string.empty() ? FSUI_CSTR("-") : pretty_binds_string.c_str(), true,
@ -4101,12 +4101,12 @@ void FullscreenUI::DrawControllerSettingsPage()
});
}
const TinyString freq_key = TinyString::from_fmt("Macro{}Frequency", macro_index + 1);
const TinyString freq_label = TinyString::from_fmt(ICON_FA_CLOCK " {}##macro_{}_frequency", FSUI_VSTR("Frequency"), macro_index + 1);
const TinyString freq_key = TinyString::from_format("Macro{}Frequency", macro_index + 1);
const TinyString freq_label = TinyString::from_format(ICON_FA_CLOCK " {}##macro_{}_frequency", FSUI_VSTR("Frequency"), macro_index + 1);
s32 frequency = bsi->GetIntValue(section, freq_key.c_str(), 0);
const SmallString freq_summary =
((frequency == 0) ? TinyString(FSUI_VSTR("Disabled")) :
TinyString::from_fmt(FSUI_FSTR("{} Frames"), frequency));
TinyString::from_format(FSUI_FSTR("{} Frames"), frequency));
if (MenuButtonWithValue(freq_label, FSUI_CSTR("Determines the frequency at which the macro will toggle the buttons on and off (aka auto fire)."), freq_summary, true))
ImGui::OpenPopup(freq_label.c_str());
@ -4160,13 +4160,13 @@ void FullscreenUI::DrawControllerSettingsPage()
{
if (mtap_enabled[mtap_port])
{
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, mtap_slot_names[mtap_slot]));
}
else
{
MenuHeading(
SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {} Settings")), mtap_port + 1));
SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Controller Port {} Settings")), mtap_port + 1));
}
for (const SettingInfo& si : ci->settings)
@ -4179,7 +4179,7 @@ void FullscreenUI::DrawControllerSettingsPage()
for (u32 port = 0; port < USB::NUM_PORTS; port++)
{
ImGui::PushID(port);
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "USB Port {}")), port + 1));
MenuHeading(TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_PLUG, "USB Port {}")), port + 1));
const std::string type(USB::GetConfigDevice(*bsi, port));
if (MenuButton(FSUI_ICONSTR(ICON_PF_USB, "Device Type"), USB::GetDeviceName(type)))
@ -4240,7 +4240,7 @@ void FullscreenUI::DrawControllerSettingsPage()
const std::span<const InputBindingInfo> bindings(USB::GetDeviceBindings(type, subtype));
if (!bindings.empty())
{
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_KEYBOARD, "{} Bindings")), USB::GetDeviceName(type)));
MenuHeading(TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_KEYBOARD, "{} Bindings")), USB::GetDeviceName(type)));
if (MenuButton(FSUI_ICONSTR(ICON_FA_TRASH, "Clear Bindings"), FSUI_CSTR("Clears all bindings for this USB controller.")))
{
@ -4259,7 +4259,7 @@ void FullscreenUI::DrawControllerSettingsPage()
const std::span<const SettingInfo> settings(USB::GetDeviceSettings(type, subtype));
if (!settings.empty())
{
MenuHeading(TinyString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "{} Settings")), USB::GetDeviceName(type)));
MenuHeading(TinyString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_SLIDERS_H, "{} Settings")), USB::GetDeviceName(type)));
const std::string section(USB::GetConfigSection(port));
for (const SettingInfo& si : settings)
@ -4481,7 +4481,7 @@ void FullscreenUI::DrawPatchesOrCheatsSettingsPage(bool cheats)
if (cheats && s_game_cheat_unlabelled_count > 0)
{
ActiveButton(SmallString::from_fmt(master_enable ? FSUI_FSTR("{} unlabelled patch codes will automatically activate.") :
ActiveButton(SmallString::from_format(master_enable ? FSUI_FSTR("{} unlabelled patch codes will automatically activate.") :
FSUI_FSTR("{} unlabelled patch codes found but not enabled."),
s_game_cheat_unlabelled_count),
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
@ -4659,13 +4659,13 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type)
const std::string session_time_str(GameList::FormatTimespan(session_time, true));
SmallString buf;
buf.fmt(FSUI_FSTR("This Session: {}"), session_time_str);
buf.format(FSUI_FSTR("This Session: {}"), session_time_str);
const ImVec2 session_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, std::numeric_limits<float>::max(), -1.0f, buf));
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, buf);
buf.fmt(FSUI_FSTR("All Time: {}"), played_time_str);
buf.format(FSUI_FSTR("All Time: {}"), played_time_str);
const ImVec2 total_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, std::numeric_limits<float>::max(), -1.0f, buf));
const ImVec2 total_pos(
display_size.x - LayoutScale(10.0f) - total_size.x, session_pos.y + g_medium_font->FontSize + LayoutScale(4.0f));
@ -4820,7 +4820,7 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type)
void FullscreenUI::InitializePlaceholderSaveStateListEntry(SaveStateListEntry* li, s32 slot)
{
li->title = fmt::format("{}##game_slot_{}", TinyString::from_fmt(FSUI_FSTR("Save Slot {0}"), slot), slot);
li->title = fmt::format("{}##game_slot_{}", TinyString::from_format(FSUI_FSTR("Save Slot {0}"), slot), slot);
li->summary = FSUI_STR("No save present in this slot.");
li->path = {};
li->timestamp = 0;
@ -4839,7 +4839,7 @@ bool FullscreenUI::InitializeSaveStateListEntry(
return false;
}
li->title = fmt::format("{}##game_slot_{}", TinyString::from_fmt(FSUI_FSTR("Save Slot {0}"), slot), slot);
li->title = fmt::format("{}##game_slot_{}", TinyString::from_format(FSUI_FSTR("Save Slot {0}"), slot), slot);
li->summary = fmt::format(FSUI_FSTR("Saved {}"), TimeToPrintableString(sd.ModificationTime));
li->slot = slot;
li->timestamp = sd.ModificationTime;
@ -5651,10 +5651,10 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 15.0f);
// file tile
ImGui::TextWrapped("%s", SmallString::from_fmt(FSUI_FSTR("File: {}"), Path::GetFileName(selected_entry->path)).c_str());
ImGui::TextWrapped("%s", SmallString::from_format(FSUI_FSTR("File: {}"), Path::GetFileName(selected_entry->path)).c_str());
// crc
ImGui::TextUnformatted(TinyString::from_fmt(FSUI_FSTR("CRC: {:08X}"), selected_entry->crc));
ImGui::TextUnformatted(TinyString::from_format(FSUI_FSTR("CRC: {:08X}"), selected_entry->crc));
// region
{
@ -5679,13 +5679,13 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
// play time
ImGui::TextUnformatted(
SmallString::from_fmt(FSUI_FSTR("Time Played: {}"), GameList::FormatTimespan(selected_entry->total_played_time)));
SmallString::from_format(FSUI_FSTR("Time Played: {}"), GameList::FormatTimespan(selected_entry->total_played_time)));
ImGui::TextUnformatted(
SmallString::from_fmt(FSUI_FSTR("Last Played: {}"), GameList::FormatTimestamp(selected_entry->last_played_time)));
SmallString::from_format(FSUI_FSTR("Last Played: {}"), GameList::FormatTimestamp(selected_entry->last_played_time)));
// size
ImGui::TextUnformatted(
SmallString::from_fmt(FSUI_FSTR("Size: {:.2f} MB"), static_cast<float>(selected_entry->total_size) / 1048576.0f));
SmallString::from_format(FSUI_FSTR("Size: {:.2f} MB"), static_cast<float>(selected_entry->total_size) / 1048576.0f));
ImGui::PopFont();
}
@ -5925,7 +5925,7 @@ void FullscreenUI::DrawGameListSettingsPage(const ImVec2& heading_size)
{FSUI_ICONSTR(ICON_FA_WINDOW_CLOSE, "Close Menu"), false},
};
OpenChoiceDialog(SmallString::from_fmt(ICON_FA_FOLDER " {}", it.first).c_str(), false, std::move(options),
OpenChoiceDialog(SmallString::from_format(ICON_FA_FOLDER " {}", it.first).c_str(), false, std::move(options),
[dir = it.first, recursive = it.second](s32 index, const std::string& title, bool checked) {
if (index < 0)
return;
@ -6317,10 +6317,10 @@ void FullscreenUI::DrawAchievementsSettingsPage(std::unique_lock<std::mutex>& se
if (bsi->ContainsValue("Achievements", "Token"))
{
ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImGui::GetStyle().Colors[ImGuiCol_Text]);
ActiveButton(SmallString::from_fmt(
ActiveButton(SmallString::from_format(
fmt::runtime(FSUI_ICONSTR(ICON_FA_USER, "Username: {}")), bsi->GetStringValue("Achievements", "Username")),
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
ActiveButton(SmallString::from_fmt(fmt::runtime(FSUI_ICONSTR(ICON_FA_CLOCK, "Login token generated on {}")),
ActiveButton(SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_CLOCK, "Login token generated on {}")),
TimeToPrintableString(static_cast<time_t>(
StringUtil::FromChars<u64>(bsi->GetStringValue("Achievements", "LoginTimestamp", "0")).value_or(0)))),
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
@ -6345,7 +6345,7 @@ void FullscreenUI::DrawAchievementsSettingsPage(std::unique_lock<std::mutex>& se
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: {0} ({1})")), Achievements::GetGameID(),
ActiveButton(SmallString::from_format(fmt::runtime(FSUI_ICONSTR(ICON_FA_BOOKMARK, "Game: {0} ({1})")), Achievements::GetGameID(),
Achievements::GetGameTitle()),
false, false, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
@ -6353,7 +6353,7 @@ void FullscreenUI::DrawAchievementsSettingsPage(std::unique_lock<std::mutex>& se
if (!rich_presence_string.empty())
{
ActiveButton(
SmallString::from_fmt(ICON_FA_MAP "{}", rich_presence_string), false, false, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
SmallString::from_format(ICON_FA_MAP "{}", rich_presence_string), false, false, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
}
else
{

View File

@ -87,9 +87,9 @@ __ri void ImGuiManager::FormatProcessorStat(SmallStringBase& text, double usage,
// 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);
}
__ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, float margin, float spacing)
@ -126,31 +126,31 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
switch (PerformanceMetrics::GetInternalFPSMethod())
{
case PerformanceMetrics::InternalFPSMethod::GSPrivilegedRegister:
text.append_fmt("G: {:.2f} [P] | V: {:.2f}", PerformanceMetrics::GetInternalFPS(),
text.append_format("G: {:.2f} [P] | V: {:.2f}", PerformanceMetrics::GetInternalFPS(),
PerformanceMetrics::GetFPS());
break;
case PerformanceMetrics::InternalFPSMethod::DISPFBBlit:
text.append_fmt("G: {:.2f} [B] | V: {:.2f}", PerformanceMetrics::GetInternalFPS(),
text.append_format("G: {:.2f} [B] | V: {:.2f}", PerformanceMetrics::GetInternalFPS(),
PerformanceMetrics::GetFPS());
break;
case PerformanceMetrics::InternalFPSMethod::None:
default:
text.append_fmt("V: {:.2f}", PerformanceMetrics::GetFPS());
text.append_format("V: {:.2f}", PerformanceMetrics::GetFPS());
break;
}
first = false;
}
if (GSConfig.OsdShowSpeed)
{
text.append_fmt("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed)));
text.append_format("{}{}%", first ? "" : " | ", static_cast<u32>(std::round(speed)));
const float target_speed = VMManager::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);
}
if (!text.empty())
{
@ -183,20 +183,20 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
GSgetInternalResolution(&width, &height);
text.clear();
text.append_fmt("{}x{} {} {}", width, height, ReportVideoMode(), ReportInterlaceMode());
text.append_format("{}x{} {} {}", width, height, ReportVideoMode(), ReportInterlaceMode());
DRAW_LINE(fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255));
}
if (GSConfig.OsdShowCPU)
{
text.clear();
text.append_fmt("{:.2f}ms | {:.2f}ms | {:.2f}ms", PerformanceMetrics::GetMinimumFrameTime(),
text.append_format("{:.2f}ms | {:.2f}ms | {:.2f}ms", PerformanceMetrics::GetMinimumFrameTime(),
PerformanceMetrics::GetAverageFrameTime(), PerformanceMetrics::GetMaximumFrameTime());
DRAW_LINE(fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255));
text.clear();
if (EmuConfig.Speedhacks.EECycleRate != 0 || EmuConfig.Speedhacks.EECycleSkip != 0)
text.append_fmt("EE[{}/{}]: ", EmuConfig.Speedhacks.EECycleRate, EmuConfig.Speedhacks.EECycleSkip);
text.append_format("EE[{}/{}]: ", EmuConfig.Speedhacks.EECycleRate, EmuConfig.Speedhacks.EECycleSkip);
else
text = "EE: ";
FormatProcessorStat(text, PerformanceMetrics::GetCPUThreadUsage(), PerformanceMetrics::GetCPUThreadAverageTime());
@ -210,7 +210,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
for (u32 i = 0; i < gs_sw_threads; i++)
{
text.clear();
text.append_fmt("SW-{}: ", i);
text.append_format("SW-{}: ", i);
FormatProcessorStat(text, PerformanceMetrics::GetGSSWThreadUsage(i), PerformanceMetrics::GetGSSWThreadAverageTime(i));
DRAW_LINE(fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255));
}
@ -291,7 +291,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
const ImVec2 wpos(ImGui::GetCurrentWindow()->Pos);
text.clear();
text.append_fmt("{:.1f} ms", max);
text.append_format("{:.1f} ms", max);
text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.c_str() + text.length());
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.c_str() + text.length());
@ -299,7 +299,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
text.c_str() + text.length());
text.clear();
text.append_fmt("{:.1f} ms", min);
text.append_format("{:.1f} ms", min);
text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.c_str() + text.length());
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),
@ -501,9 +501,9 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci
const Pad::ControllerInfo& cinfo = pad->GetInfo();
if (cinfo.icon_name)
text.fmt("{} {}", cinfo.icon_name, slot + 1u);
text.format("{} {}", cinfo.icon_name, slot + 1u);
else
text.fmt("{} |", slot + 1u);
text.format("{} |", slot + 1u);
for (u32 bind = 0; bind < static_cast<u32>(cinfo.bindings.size()); bind++)
{
@ -517,9 +517,9 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci
const float value = pad->GetEffectiveInput(bind);
const float abs_value = std::abs(value);
if (abs_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 (abs_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;
@ -528,9 +528,9 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci
// buttons display the value from 0 through 255.
const float value = pad->GetEffectiveInput(bind);
if (value >= 254.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 > 0.0f)
text.append_fmt(" {}: {:.0f}", bi.icon_name ? bi.icon_name : bi.name, value);
text.append_format(" {}: {:.0f}", bi.icon_name ? bi.icon_name : bi.name, value);
}
break;
@ -559,7 +559,7 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci
if (bindings.empty())
continue;
text.fmt("{} {} ", ICON_PF_USB, port + 1u);
text.format("{} {} ", ICON_PF_USB, port + 1u);
for (const InputBindingInfo& bi : bindings)
{
@ -571,9 +571,9 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci
// axes are only shown if not resting/past deadzone. values are normalized.
const float value = static_cast<float>(USB::GetDeviceBindValue(port, 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;
@ -582,9 +582,9 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci
// buttons display the value from 0 through 255. values are normalized, so denormalize them.
const float value = static_cast<float>(USB::GetDeviceBindValue(port, bi.bind_index)) * 255.0f;
if (value >= 254.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 > 0.0f)
text.append_fmt(" {}: {:.0f}", bi.icon_name ? bi.icon_name : bi.name, value);
text.append_format(" {}: {:.0f}", bi.icon_name ? bi.icon_name : bi.name, value);
}
break;
@ -634,17 +634,17 @@ __ri void ImGuiManager::DrawInputRecordingOverlay(float& position_y, float scale
// Status Indicators
if (g_InputRecording.getControls().isRecording())
{
DRAW_LINE(standard_font, TinyString::from_fmt(TRANSLATE_FS("ImGuiOverlays", "{} Recording Input"), ICON_PF_CIRCLE).c_str(), IM_COL32(255, 0, 0, 255));
DRAW_LINE(standard_font, TinyString::from_format(TRANSLATE_FS("ImGuiOverlays", "{} Recording Input"), ICON_PF_CIRCLE).c_str(), IM_COL32(255, 0, 0, 255));
}
else
{
DRAW_LINE(standard_font, TinyString::from_fmt(TRANSLATE_FS("ImGuiOverlays", "{} Replaying"), ICON_FA_PLAY).c_str(), IM_COL32(97, 240, 84, 255));
DRAW_LINE(standard_font, TinyString::from_format(TRANSLATE_FS("ImGuiOverlays", "{} Replaying"), ICON_FA_PLAY).c_str(), IM_COL32(97, 240, 84, 255));
}
// Input Recording Metadata
DRAW_LINE(fixed_font, TinyString::from_fmt(TRANSLATE_FS("ImGuiOverlays", "Input Recording Active: {}"), g_InputRecording.getData().getFilename()).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_fmt(TRANSLATE_FS("ImGuiOverlays", "Frame: {}/{} ({})"), g_InputRecording.getFrameCounter() + 1, g_InputRecording.getData().getTotalFrames(), g_FrameCount).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_fmt(TRANSLATE_FS("ImGuiOverlays", "Undo Count: {}"), g_InputRecording.getData().getUndoCount()).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_format(TRANSLATE_FS("ImGuiOverlays", "Input Recording Active: {}"), g_InputRecording.getData().getFilename()).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_format(TRANSLATE_FS("ImGuiOverlays", "Frame: {}/{} ({})"), g_InputRecording.getFrameCounter() + 1, g_InputRecording.getData().getTotalFrames(), g_FrameCount).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_format(TRANSLATE_FS("ImGuiOverlays", "Undo Count: {}"), g_InputRecording.getData().getUndoCount()).c_str(), IM_COL32(117, 255, 241, 255));
#undef DRAW_LINE
}
@ -659,7 +659,7 @@ __ri void ImGuiManager::DrawVideoCaptureOverlay(float& position_y, float scale,
ImDrawList* dl = ImGui::GetBackgroundDrawList();
static constexpr const char* ICON = ICON_PF_CIRCLE;
const TinyString text_msg = TinyString::from_fmt(" {}", GSCapture::GetElapsedTime());
const TinyString text_msg = TinyString::from_format(" {}", GSCapture::GetElapsedTime());
const ImVec2 icon_size = standard_font->CalcTextSizeA(standard_font->FontSize, std::numeric_limits<float>::max(),
-1.0f, ICON, nullptr, nullptr);
const ImVec2 text_size = standard_font->CalcTextSizeA(standard_font->FontSize, std::numeric_limits<float>::max(),

View File

@ -384,17 +384,17 @@ TinyString DInputSource::ConvertKeyToString(InputBindingKey key)
if (key.source_subtype == InputSubclass::ControllerAxis)
{
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 && !ShouldIgnoreInversion()) ? "~" : "");
ret.format("DInput-{}/{}Axis{}{}", u32(key.source_index), modifier, u32(key.data), (key.invert && !ShouldIgnoreInversion()) ? "~" : "");
}
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

@ -480,30 +480,30 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
{
const char* modifier = (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, key.data, (key.invert && !ShouldIgnoreInversion()) ? "~" : "");
ret.format("SDL-{}/{}Axis{}{}", static_cast<u32>(key.source_index), modifier, key.data, (key.invert && !ShouldIgnoreInversion()) ? "~" : "");
}
else if (key.source_subtype == InputSubclass::ControllerButton)
{
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), key.data);
ret.format("SDL-{}/Button{}", static_cast<u32>(key.source_index), key.data);
}
else if (key.source_subtype == InputSubclass::ControllerHat)
{
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, s_sdl_hat_direction_names[hat_direction]);
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));
}
}
@ -520,14 +520,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

@ -324,15 +324,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");
}
}
@ -349,14 +349,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]);
}
}

View File

@ -102,7 +102,7 @@ namespace Patch
SmallString ToString() const
{
return SmallString::from_fmt("{},{},{},{:08x},{:x}", s_place_to_string[static_cast<u8>(placetopatch)],
return SmallString::from_format("{},{},{},{:08x},{:x}", s_place_to_string[static_cast<u8>(placetopatch)],
s_cpu_to_string[static_cast<u8>(cpu)], s_type_to_string[static_cast<u8>(type)], addr, data);
}
};

View File

@ -526,13 +526,13 @@ void Pcsx2Config::CpuOptions::LoadSave(SettingsWrapper& wrap)
SettingsWrapSection("EmuCore/CPU");
const auto read_fpcr = [&wrap, &CURRENT_SETTINGS_SECTION](FPControlRegister& fpcr, std::string_view prefix) {
fpcr.SetDenormalsAreZero(wrap.EntryBitBool(CURRENT_SETTINGS_SECTION, TinyString::from_fmt("{}.DenormalsAreZero", prefix),
fpcr.SetDenormalsAreZero(wrap.EntryBitBool(CURRENT_SETTINGS_SECTION, TinyString::from_format("{}.DenormalsAreZero", prefix),
fpcr.GetDenormalsAreZero(), fpcr.GetDenormalsAreZero()));
fpcr.SetFlushToZero(wrap.EntryBitBool(CURRENT_SETTINGS_SECTION, TinyString::from_fmt("{}.DenormalsAreZero", prefix),
fpcr.SetFlushToZero(wrap.EntryBitBool(CURRENT_SETTINGS_SECTION, TinyString::from_format("{}.DenormalsAreZero", prefix),
fpcr.GetFlushToZero(), fpcr.GetFlushToZero()));
uint round_mode = static_cast<uint>(fpcr.GetRoundMode());
wrap.Entry(CURRENT_SETTINGS_SECTION, TinyString::from_fmt("{}.Roundmode", prefix), round_mode, round_mode);
wrap.Entry(CURRENT_SETTINGS_SECTION, TinyString::from_format("{}.Roundmode", prefix), round_mode, round_mode);
round_mode = std::min(round_mode, static_cast<uint>(FPRoundMode::MaxCount) - 1u);
fpcr.SetRoundMode(static_cast<FPRoundMode>(round_mode));
};