mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-06 07:06:00 +00:00
save_data: Fix save data list back button. (#1003)
* save_data: Fix save data list back button. * common: Add more null checks in CString. Co-authored-by: Vinicius Rangel <me@viniciusrangel.dev> --------- Co-authored-by: Vinicius Rangel <me@viniciusrangel.dev>
This commit is contained in:
parent
32df2b8e43
commit
9123dc4228
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wtautological-undefined-compare"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A null-terminated string with a fixed maximum length
|
* @brief A null-terminated string with a fixed maximum length
|
||||||
* This class is not meant to be used as a general-purpose string class
|
* This class is not meant to be used as a general-purpose string class
|
||||||
|
@ -29,20 +32,27 @@ public:
|
||||||
explicit CString(const CString<M>& other)
|
explicit CString(const CString<M>& other)
|
||||||
requires(M <= N)
|
requires(M <= N)
|
||||||
{
|
{
|
||||||
|
if (this == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::ranges::copy(other.begin(), other.end(), data);
|
std::ranges::copy(other.begin(), other.end(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FromString(const std::basic_string_view<T>& str) {
|
void FromString(const std::basic_string_view<T>& str) {
|
||||||
|
if (this == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
size_t p = str.copy(data, N - 1);
|
size_t p = str.copy(data, N - 1);
|
||||||
data[p] = '\0';
|
data[p] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zero() {
|
void Zero() {
|
||||||
|
if (this == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::ranges::fill(data, 0);
|
std::ranges::fill(data, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wtautological-undefined-compare"
|
|
||||||
explicit(false) operator std::basic_string_view<T>() const {
|
explicit(false) operator std::basic_string_view<T>() const {
|
||||||
if (this == nullptr) {
|
if (this == nullptr) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -70,21 +80,32 @@ public:
|
||||||
}
|
}
|
||||||
return std::basic_string_view<T>{data};
|
return std::basic_string_view<T>{data};
|
||||||
}
|
}
|
||||||
#pragma clang diagnostic pop
|
|
||||||
|
|
||||||
char* begin() {
|
char* begin() {
|
||||||
|
if (this == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* begin() const {
|
const char* begin() const {
|
||||||
|
if (this == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* end() {
|
char* end() {
|
||||||
|
if (this == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return data + N;
|
return data + N;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* end() const {
|
const char* end() const {
|
||||||
|
if (this == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return data + N;
|
return data + N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +148,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(CString<13>) == sizeof(char[13])); // Ensure size still matches a simple array
|
static_assert(sizeof(CString<13>) == sizeof(char[13])); // Ensure size still matches a simple array
|
||||||
static_assert(std::weakly_incrementable<CString<13>::Iterator>);
|
static_assert(std::weakly_incrementable<CString<13>::Iterator>);
|
||||||
|
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
|
@ -620,7 +620,7 @@ void SaveDialogUi::DrawList() {
|
||||||
SetCursorPosX(GetContentRegionAvail().x - button_size.x);
|
SetCursorPosX(GetContentRegionAvail().x - button_size.x);
|
||||||
if (Button(back, button_size)) {
|
if (Button(back, button_size)) {
|
||||||
result->dir_name.clear();
|
result->dir_name.clear();
|
||||||
Finish(ButtonId::INVALID);
|
Finish(ButtonId::INVALID, Result::USER_CANCELED);
|
||||||
}
|
}
|
||||||
if (IsKeyPressed(ImGuiKey_GamepadFaceRight)) {
|
if (IsKeyPressed(ImGuiKey_GamepadFaceRight)) {
|
||||||
SetItemCurrentNavFocus();
|
SetItemCurrentNavFocus();
|
||||||
|
|
Loading…
Reference in a new issue