mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Make the i18n T function use std::string_view
Buildfixes, crashfixes One more Android buildfix Buildfix Qt
This commit is contained in:
parent
9322b4c6dc
commit
c5791764d8
@ -72,20 +72,32 @@ void I18NCategory::Clear() {
|
||||
missedKeyLog_.clear();
|
||||
}
|
||||
|
||||
const char *I18NCategory::T(const char *key, const char *def) {
|
||||
if (!key) {
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
std::string_view I18NCategory::T(std::string_view key, std::string_view def) {
|
||||
auto iter = map_.find(key);
|
||||
if (iter != map_.end()) {
|
||||
return iter->second.text.c_str();
|
||||
} else {
|
||||
std::lock_guard<std::mutex> guard(missedKeyLock_);
|
||||
if (def)
|
||||
missedKeyLog_[key] = def;
|
||||
std::string missedKey(key);
|
||||
if (!def.empty())
|
||||
missedKeyLog_[missedKey] = def;
|
||||
else
|
||||
missedKeyLog_[key] = key;
|
||||
missedKeyLog_[missedKey] = std::string(key);
|
||||
return !def.empty() ? def : key;
|
||||
}
|
||||
}
|
||||
|
||||
const char *I18NCategory::T_cstr(const char *key, const char *def) {
|
||||
auto iter = map_.find(key);
|
||||
if (iter != map_.end()) {
|
||||
return iter->second.text.c_str();
|
||||
} else {
|
||||
std::lock_guard<std::mutex> guard(missedKeyLock_);
|
||||
std::string missedKey(key);
|
||||
if (def)
|
||||
missedKeyLog_[missedKey] = def;
|
||||
else
|
||||
missedKeyLog_[missedKey] = std::string(key);
|
||||
return def ? def : key;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
@ -81,10 +82,11 @@ public:
|
||||
I18NCategory() {}
|
||||
explicit I18NCategory(const Section §ion);
|
||||
|
||||
const char *T(const char *key, const char *def = nullptr);
|
||||
const char *T(const std::string &key) {
|
||||
return T(key.c_str(), nullptr);
|
||||
}
|
||||
// Faster since the string lengths don't need to be recomputed.
|
||||
std::string_view T(std::string_view key, std::string_view def = "");
|
||||
|
||||
// Try to avoid this. Still useful in snprintf.
|
||||
const char *T_cstr(const char *key, const char *def = nullptr);
|
||||
|
||||
const std::map<std::string, std::string> Missed() const {
|
||||
std::lock_guard<std::mutex> guard(missedKeyLock_);
|
||||
@ -99,6 +101,7 @@ private:
|
||||
I18NCategory(I18NRepo *repo, const char *name) {}
|
||||
void SetMap(const std::map<std::string, std::string> &m);
|
||||
|
||||
// std::less<> is needed to be able to look up string_views in a string-keyed map.
|
||||
std::map<std::string, I18NEntry, std::less<>> map_;
|
||||
mutable std::mutex missedKeyLock_;
|
||||
std::map<std::string, std::string> missedKeyLog_;
|
||||
@ -119,12 +122,16 @@ public:
|
||||
|
||||
// Translate the string, by looking up "key" in the file, and falling back to either def or key, in that order, if the lookup fails.
|
||||
// def can (and usually is) set to nullptr.
|
||||
const char *T(I18NCat category, const char *key, const char *def = nullptr) {
|
||||
std::string_view T(I18NCat category, std::string_view key, std::string_view def = "") {
|
||||
if (category == I18NCat::NONE)
|
||||
return def ? def : key;
|
||||
return !def.empty() ? def : key;
|
||||
return cats_[(size_t)category]->T(key, def);
|
||||
}
|
||||
|
||||
const char *T_cstr(I18NCat category, const char *key, const char *def = nullptr) {
|
||||
if (category == I18NCat::NONE)
|
||||
return def ? def : key;
|
||||
return cats_[(size_t)category]->T_cstr(key, def);
|
||||
}
|
||||
void LogMissingKeys() const;
|
||||
|
||||
private:
|
||||
@ -142,6 +149,10 @@ extern I18NRepo g_i18nrepo;
|
||||
|
||||
std::shared_ptr<I18NCategory> GetI18NCategory(I18NCat cat);
|
||||
|
||||
inline const char *T(I18NCat category, const char *key, const char *def = nullptr) {
|
||||
inline std::string_view T(I18NCat category, std::string_view key, std::string_view def = "") {
|
||||
return g_i18nrepo.T(category, key, def);
|
||||
}
|
||||
|
||||
inline const char *T_cstr(I18NCat category, const char *key, const char *def = "") {
|
||||
return g_i18nrepo.T_cstr(category, key, def);
|
||||
}
|
@ -395,12 +395,12 @@ public:
|
||||
}
|
||||
return list;
|
||||
}
|
||||
std::vector<std::string> GetPresentModeList(const char *currentMarkerString) const override {
|
||||
std::vector<std::string> GetPresentModeList(std::string_view currentMarkerString) const override {
|
||||
std::vector<std::string> list;
|
||||
for (auto mode : vulkan_->GetAvailablePresentModes()) {
|
||||
std::string str = VulkanPresentModeToString(mode);
|
||||
if (mode == vulkan_->GetPresentMode()) {
|
||||
str += std::string(" (") + currentMarkerString + ")";
|
||||
str += std::string(" (") + std::string(currentMarkerString) + ")";
|
||||
}
|
||||
list.push_back(str);
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ public:
|
||||
virtual std::vector<std::string> GetFeatureList() const { return std::vector<std::string>(); }
|
||||
virtual std::vector<std::string> GetExtensionList(bool device, bool enabledOnly) const { return std::vector<std::string>(); }
|
||||
virtual std::vector<std::string> GetDeviceList() const { return std::vector<std::string>(); }
|
||||
virtual std::vector<std::string> GetPresentModeList(const char *currentMarkerString) const { return std::vector<std::string>(); }
|
||||
virtual std::vector<std::string> GetPresentModeList(std::string_view currentMarkerString) const { return std::vector<std::string>(); }
|
||||
virtual std::vector<std::string> GetSurfaceFormatList() const { return std::vector<std::string>(); }
|
||||
|
||||
// Describes the primary shader language that this implementation prefers.
|
||||
|
@ -498,7 +498,7 @@ int Client::ReadResponseEntity(net::Buffer *readbuf, const std::vector<std::stri
|
||||
return 0;
|
||||
}
|
||||
|
||||
HTTPRequest::HTTPRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode, const std::string &name)
|
||||
HTTPRequest::HTTPRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode, std::string_view name)
|
||||
: Request(method, url, name, &cancelled_, progressBarMode), postData_(postData), postMime_(postMime), outfile_(outfile) {
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ protected:
|
||||
// Really an asynchronous request.
|
||||
class HTTPRequest : public Request {
|
||||
public:
|
||||
HTTPRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode = ProgressBarMode::DELAYED, const std::string &name = "");
|
||||
HTTPRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode = ProgressBarMode::DELAYED, std::string_view name = "");
|
||||
~HTTPRequest();
|
||||
|
||||
void Start() override;
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace http {
|
||||
|
||||
HTTPSRequest::HTTPSRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode, const std::string &name)
|
||||
HTTPSRequest::HTTPSRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode, std::string_view name)
|
||||
: Request(method, url, name, &cancelled_, progressBarMode), method_(method), postData_(postData), postMime_(postMime), outfile_(outfile) {
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <string_view>
|
||||
|
||||
#include "Common/Net/HTTPRequest.h"
|
||||
|
||||
@ -13,7 +14,7 @@ namespace http {
|
||||
// Really an asynchronous request.
|
||||
class HTTPSRequest : public Request {
|
||||
public:
|
||||
HTTPSRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode = ProgressBarMode::DELAYED, const std::string &name = "");
|
||||
HTTPSRequest(RequestMethod method, const std::string &url, const std::string &postData, const std::string &postMime, const Path &outfile, ProgressBarMode progressBarMode = ProgressBarMode::DELAYED, std::string_view name = "");
|
||||
~HTTPSRequest();
|
||||
|
||||
void Start() override;
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
namespace http {
|
||||
|
||||
Request::Request(RequestMethod method, const std::string &url, const std::string &name, bool *cancelled, ProgressBarMode mode) : method_(method), url_(url), name_(name), progress_(cancelled), progressBarMode_(mode) {
|
||||
INFO_LOG(HTTP, "HTTP %s request: %s (%s)", RequestMethodToString(method), url.c_str(), name.c_str());
|
||||
Request::Request(RequestMethod method, const std::string &url, std::string_view name, bool *cancelled, ProgressBarMode mode) : method_(method), url_(url), name_(name), progress_(cancelled), progressBarMode_(mode) {
|
||||
INFO_LOG(HTTP, "HTTP %s request: %s (%.*s)", RequestMethodToString(method), url.c_str(), (int)name.size(), name.data());
|
||||
|
||||
progress_.callback = [=](int64_t bytes, int64_t contentLength, bool done) {
|
||||
std::string message;
|
||||
@ -64,7 +64,7 @@ std::shared_ptr<Request> RequestManager::StartDownloadWithCallback(
|
||||
const Path &outfile,
|
||||
ProgressBarMode mode,
|
||||
std::function<void(Request &)> callback,
|
||||
const std::string &name,
|
||||
std::string_view name,
|
||||
const char *acceptMime) {
|
||||
std::shared_ptr<Request> dl;
|
||||
if (IsHttpsUrl(url) && System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS)) {
|
||||
@ -92,7 +92,7 @@ std::shared_ptr<Request> RequestManager::AsyncPostWithCallback(
|
||||
const std::string &postMime,
|
||||
ProgressBarMode mode,
|
||||
std::function<void(Request &)> callback,
|
||||
const std::string &name) {
|
||||
std::string_view name) {
|
||||
std::shared_ptr<Request> dl;
|
||||
if (IsHttpsUrl(url) && System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS)) {
|
||||
#ifndef HTTPS_NOT_AVAILABLE
|
||||
|
@ -23,7 +23,7 @@ enum class ProgressBarMode {
|
||||
// Abstract request.
|
||||
class Request {
|
||||
public:
|
||||
Request(RequestMethod method, const std::string &url, const std::string &name, bool *cancelled, ProgressBarMode mode);
|
||||
Request(RequestMethod method, const std::string &url, std::string_view name, bool *cancelled, ProgressBarMode mode);
|
||||
virtual ~Request() {}
|
||||
|
||||
void SetAccept(const char *mime) {
|
||||
@ -93,7 +93,7 @@ public:
|
||||
const Path &outfile,
|
||||
ProgressBarMode mode,
|
||||
std::function<void(Request &)> callback,
|
||||
const std::string &name = "",
|
||||
std::string_view name = "",
|
||||
const char *acceptMime = nullptr);
|
||||
|
||||
std::shared_ptr<Request> AsyncPostWithCallback(
|
||||
@ -102,7 +102,7 @@ public:
|
||||
const std::string &postMime, // Use postMime = "application/x-www-form-urlencoded" for standard form-style posts, such as used by retroachievements. For encoding form data manually we have MultipartFormDataEncoder.
|
||||
ProgressBarMode mode,
|
||||
std::function<void(Request &)> callback,
|
||||
const std::string &name = "");
|
||||
std::string_view name = "");
|
||||
|
||||
// Drops finished downloads from the list.
|
||||
void Update();
|
||||
|
@ -56,6 +56,18 @@ size_t truncate_cpy(char *dest, size_t destSize, const char *src) {
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t truncate_cpy(char *dest, size_t destSize, std::string_view src) {
|
||||
if (src.size() > destSize - 1) {
|
||||
memcpy(dest, src.data(), destSize - 1);
|
||||
dest[destSize - 1] = 0;
|
||||
return destSize - 1;
|
||||
} else {
|
||||
memcpy(dest, src.data(), src.size());
|
||||
dest[src.size()] = 0;
|
||||
return src.size();
|
||||
}
|
||||
}
|
||||
|
||||
const char* safe_string(const char* s) {
|
||||
return s ? s : "(null)";
|
||||
}
|
||||
@ -376,8 +388,8 @@ std::string ReplaceAll(std::string_view input, std::string_view src, std::string
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string UnescapeMenuString(const char *input, char *shortcutChar) {
|
||||
size_t len = strlen(input);
|
||||
std::string UnescapeMenuString(std::string_view input, char *shortcutChar) {
|
||||
size_t len = input.length();
|
||||
std::string output;
|
||||
output.reserve(len);
|
||||
bool escaping = false;
|
||||
@ -402,8 +414,8 @@ std::string UnescapeMenuString(const char *input, char *shortcutChar) {
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string ApplySafeSubstitutions(const char *format, std::string_view string1, std::string_view string2, std::string_view string3, std::string_view string4) {
|
||||
size_t formatLen = strlen(format);
|
||||
std::string ApplySafeSubstitutions(std::string_view format, std::string_view string1, std::string_view string2, std::string_view string3, std::string_view string4) {
|
||||
size_t formatLen = format.length();
|
||||
std::string output;
|
||||
output.reserve(formatLen + 20);
|
||||
for (size_t i = 0; i < formatLen; i++) {
|
||||
@ -433,8 +445,8 @@ std::string ApplySafeSubstitutions(const char *format, std::string_view string1,
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string ApplySafeSubstitutions(const char *format, int i1, int i2, int i3, int i4) {
|
||||
size_t formatLen = strlen(format);
|
||||
std::string ApplySafeSubstitutions(std::string_view format, int i1, int i2, int i3, int i4) {
|
||||
size_t formatLen = format.length();
|
||||
std::string output;
|
||||
output.reserve(formatLen + 20);
|
||||
for (size_t i = 0; i < formatLen; i++) {
|
||||
|
@ -92,7 +92,7 @@ std::string ReplaceAll(std::string_view input, std::string_view src, std::string
|
||||
|
||||
// Takes something like R&eplace and returns Replace, plus writes 'e' to *shortcutChar
|
||||
// if not nullptr. Useful for Windows menu strings.
|
||||
std::string UnescapeMenuString(const char *input, char *shortcutChar);
|
||||
std::string UnescapeMenuString(std::string_view input, char *shortcutChar);
|
||||
|
||||
void SkipSpace(const char **ptr);
|
||||
|
||||
@ -101,6 +101,7 @@ template<size_t Count>
|
||||
inline size_t truncate_cpy(char(&out)[Count], const char *src) {
|
||||
return truncate_cpy(out, Count, src);
|
||||
}
|
||||
size_t truncate_cpy(char *dest, size_t destSize, std::string_view src);
|
||||
|
||||
const char* safe_string(const char* s);
|
||||
|
||||
@ -125,5 +126,5 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
|
||||
// Replaces %1, %2, %3 in format with arg1, arg2, arg3.
|
||||
// Much safer than snprintf and friends.
|
||||
// For mixes of strings and ints, manually convert the ints to strings.
|
||||
std::string ApplySafeSubstitutions(const char *format, std::string_view string1, std::string_view string2 = "", std::string_view string3 = "", std::string_view string4 = "");
|
||||
std::string ApplySafeSubstitutions(const char *format, int i1, int i2 = 0, int i3 = 0, int i4 = 0);
|
||||
std::string ApplySafeSubstitutions(std::string_view format, std::string_view string1, std::string_view string2 = "", std::string_view string3 = "", std::string_view string4 = "");
|
||||
std::string ApplySafeSubstitutions(std::string_view format, int i1, int i2 = 0, int i3 = 0, int i4 = 0);
|
||||
|
@ -227,7 +227,7 @@ void OnScreenDisplay::ShowLeaderboardSubmitted(const std::string &title, const s
|
||||
g_OSD.Show(OSDType::LEADERBOARD_SUBMITTED, title, value, 3.0f);
|
||||
}
|
||||
|
||||
void OnScreenDisplay::SetProgressBar(const std::string &id, std::string &&message, float minValue, float maxValue, float progress, float delay) {
|
||||
void OnScreenDisplay::SetProgressBar(std::string_view id, std::string_view message, float minValue, float maxValue, float progress, float delay) {
|
||||
_dbg_assert_(!my_isnanorinf(progress));
|
||||
_dbg_assert_(!my_isnanorinf(minValue));
|
||||
_dbg_assert_(!my_isnanorinf(maxValue));
|
||||
@ -250,7 +250,7 @@ void OnScreenDisplay::SetProgressBar(const std::string &id, std::string &&messag
|
||||
Entry bar;
|
||||
bar.id = id;
|
||||
bar.type = OSDType::PROGRESS_BAR;
|
||||
bar.text = std::move(message);
|
||||
bar.text = message;
|
||||
bar.minValue = minValue;
|
||||
bar.maxValue = maxValue;
|
||||
bar.progress = progress;
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
// Progress bar controls
|
||||
// Set is both create and update. If you set maxValue <= minValue, you'll create an "indeterminate" progress
|
||||
// bar that doesn't show a specific amount of progress.
|
||||
void SetProgressBar(const std::string &id, std::string &&message, float minValue, float maxValue, float progress, float delay_s);
|
||||
void SetProgressBar(std::string_view id, std::string_view message, float minValue, float maxValue, float progress, float delay_s);
|
||||
void RemoveProgressBar(const std::string &id, bool success, float delay_s);
|
||||
|
||||
// Call every frame to keep the sidebar visible. Otherwise it'll fade out.
|
||||
|
@ -31,7 +31,7 @@ const char *RequestTypeAsString(SystemRequestType type) {
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestManager::MakeSystemRequest(SystemRequestType type, RequesterToken token, RequestCallback callback, RequestFailedCallback failedCallback, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||
bool RequestManager::MakeSystemRequest(SystemRequestType type, RequesterToken token, RequestCallback callback, RequestFailedCallback failedCallback, std::string_view param1, std::string_view param2, int param3) {
|
||||
if (token == NO_REQUESTER_TOKEN) {
|
||||
_dbg_assert_(!callback);
|
||||
_dbg_assert_(!failedCallback);
|
||||
@ -49,7 +49,10 @@ bool RequestManager::MakeSystemRequest(SystemRequestType type, RequesterToken to
|
||||
}
|
||||
|
||||
VERBOSE_LOG(SYSTEM, "Making system request %s: id %d", RequestTypeAsString(type), requestId);
|
||||
if (!System_MakeRequest(type, requestId, param1, param2, param3)) {
|
||||
std::string p1(param1);
|
||||
std::string p2(param2);
|
||||
// TODO: Convert to string_view
|
||||
if (!System_MakeRequest(type, requestId, p1, p2, param3)) {
|
||||
if (callback || failedCallback) {
|
||||
std::lock_guard<std::mutex> guard(callbackMutex_);
|
||||
callbackMap_.erase(requestId);
|
||||
@ -130,7 +133,7 @@ void RequestManager::Clear() {
|
||||
callbackMap_.clear();
|
||||
}
|
||||
|
||||
void System_CreateGameShortcut(const Path &path, const std::string &title) {
|
||||
void System_CreateGameShortcut(const Path &path, std::string_view title) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::CREATE_GAME_SHORTCUT, NO_REQUESTER_TOKEN, nullptr, nullptr, path.ToString(), title, 0);
|
||||
}
|
||||
|
||||
@ -139,6 +142,6 @@ void System_ShowFileInFolder(const Path &path) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SHOW_FILE_IN_FOLDER, NO_REQUESTER_TOKEN, nullptr, nullptr, path.ToString(), "", 0);
|
||||
}
|
||||
|
||||
void System_BrowseForFolder(RequesterToken token, const std::string &title, const Path &initialPath, RequestCallback callback, RequestFailedCallback failedCallback) {
|
||||
void System_BrowseForFolder(RequesterToken token, std::string_view title, const Path &initialPath, RequestCallback callback, RequestFailedCallback failedCallback) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::BROWSE_FOR_FOLDER, token, callback, failedCallback, title, initialPath.ToCString(), 0);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
// The callback you pass in will be called on the main thread later.
|
||||
// Params are at the end since it's the part most likely to recieve additions in the future,
|
||||
// now that we have both callbacks.
|
||||
bool MakeSystemRequest(SystemRequestType type, RequesterToken token, RequestCallback callback, RequestFailedCallback failedCallback, const std::string ¶m1, const std::string ¶m2, int param3);
|
||||
bool MakeSystemRequest(SystemRequestType type, RequesterToken token, RequestCallback callback, RequestFailedCallback failedCallback, std::string_view param1, std::string_view param2, int param3);
|
||||
|
||||
// Called by the platform implementation, when it's finished with a request.
|
||||
void PostSystemSuccess(int requestId, const char *responseString, int responseValue = 0);
|
||||
@ -83,13 +83,13 @@ extern RequestManager g_requestManager;
|
||||
// Wrappers for easy requests.
|
||||
// NOTE: Semantics have changed - this no longer calls the callback on cancellation, instead you
|
||||
// can specify a different callback for that.
|
||||
inline void System_InputBoxGetString(RequesterToken token, const std::string &title, const std::string &defaultValue, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
inline void System_InputBoxGetString(RequesterToken token, std::string_view title, std::string_view defaultValue, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::INPUT_TEXT_MODAL, token, callback, failedCallback, title, defaultValue, 0);
|
||||
}
|
||||
|
||||
// This one will pop up a special image browser if available. You can also pick
|
||||
// images with the file browser below.
|
||||
inline void System_BrowseForImage(RequesterToken token, const std::string &title, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
inline void System_BrowseForImage(RequesterToken token, std::string_view title, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::BROWSE_FOR_IMAGE, token, callback, failedCallback, title, "", 0);
|
||||
}
|
||||
|
||||
@ -103,18 +103,18 @@ enum class BrowseFileType {
|
||||
ANY,
|
||||
};
|
||||
|
||||
inline void System_BrowseForFile(RequesterToken token, const std::string &title, BrowseFileType type, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
inline void System_BrowseForFile(RequesterToken token, std::string_view title, BrowseFileType type, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::BROWSE_FOR_FILE, token, callback, failedCallback, title, "", (int)type);
|
||||
}
|
||||
|
||||
void System_BrowseForFolder(RequesterToken token, const std::string &title, const Path &initialPath, RequestCallback callback, RequestFailedCallback failedCallback = nullptr);
|
||||
void System_BrowseForFolder(RequesterToken token, std::string_view title, const Path &initialPath, RequestCallback callback, RequestFailedCallback failedCallback = nullptr);
|
||||
|
||||
// The returned string is username + '\n' + password.
|
||||
inline void System_AskUsernamePassword(RequesterToken token, const std::string &title, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
inline void System_AskUsernamePassword(RequesterToken token, std::string_view title, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::ASK_USERNAME_PASSWORD, token, callback, failedCallback, title, "", 0);
|
||||
}
|
||||
|
||||
inline void System_CopyStringToClipboard(const std::string &string) {
|
||||
inline void System_CopyStringToClipboard(std::string_view string) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::COPY_TO_CLIPBOARD, NO_REQUESTER_TOKEN, nullptr, nullptr, string, "", 0);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ inline void System_ExitApp() {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::EXIT_APP, NO_REQUESTER_TOKEN, nullptr, nullptr, "", "", 0);
|
||||
}
|
||||
|
||||
inline void System_RestartApp(const std::string ¶ms) {
|
||||
inline void System_RestartApp(std::string_view params) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::RESTART_APP, NO_REQUESTER_TOKEN, nullptr, nullptr, params, "", 0);
|
||||
}
|
||||
|
||||
@ -131,50 +131,50 @@ inline void System_RecreateActivity() {
|
||||
}
|
||||
|
||||
// The design is a little weird, just a holdover from the old message. Can either toggle or set to on or off.
|
||||
inline void System_ToggleFullscreenState(const std::string ¶m) {
|
||||
inline void System_ToggleFullscreenState(std::string_view param) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::TOGGLE_FULLSCREEN_STATE, NO_REQUESTER_TOKEN, nullptr, nullptr, param, "", 0);
|
||||
}
|
||||
|
||||
inline void System_GraphicsBackendFailedAlert(const std::string ¶m) {
|
||||
inline void System_GraphicsBackendFailedAlert(std::string_view param) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::GRAPHICS_BACKEND_FAILED_ALERT, NO_REQUESTER_TOKEN, nullptr, nullptr, param, "", 0);
|
||||
}
|
||||
|
||||
inline void System_CameraCommand(const std::string &command) {
|
||||
inline void System_CameraCommand(std::string_view command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::CAMERA_COMMAND, NO_REQUESTER_TOKEN, nullptr, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_GPSCommand(const std::string &command) {
|
||||
inline void System_GPSCommand(std::string_view command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::GPS_COMMAND, NO_REQUESTER_TOKEN, nullptr, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_InfraredCommand(const std::string &command) {
|
||||
inline void System_InfraredCommand(std::string_view command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::INFRARED_COMMAND, NO_REQUESTER_TOKEN, nullptr, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_MicrophoneCommand(const std::string &command) {
|
||||
inline void System_MicrophoneCommand(std::string_view command) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::MICROPHONE_COMMAND, NO_REQUESTER_TOKEN, nullptr, nullptr, command, "", 0);
|
||||
}
|
||||
|
||||
inline void System_ShareText(const std::string &text) {
|
||||
inline void System_ShareText(std::string_view text) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SHARE_TEXT, NO_REQUESTER_TOKEN, nullptr, nullptr, text, "", 0);
|
||||
}
|
||||
|
||||
inline void System_NotifyUIState(const std::string &state) {
|
||||
inline void System_NotifyUIState(std::string_view state) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::NOTIFY_UI_STATE, NO_REQUESTER_TOKEN, nullptr, nullptr, state, "", 0);
|
||||
}
|
||||
|
||||
inline void System_SetWindowTitle(const std::string ¶m) {
|
||||
inline void System_SetWindowTitle(std::string_view param) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SET_WINDOW_TITLE, NO_REQUESTER_TOKEN, nullptr, nullptr, param, "", 0);
|
||||
}
|
||||
|
||||
inline bool System_SendDebugOutput(const std::string &string) {
|
||||
inline bool System_SendDebugOutput(std::string_view string) {
|
||||
return g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_OUTPUT, NO_REQUESTER_TOKEN, nullptr, nullptr, string, "", 0);
|
||||
}
|
||||
|
||||
inline void System_SendDebugScreenshot(const std::string &data, int height) {
|
||||
inline void System_SendDebugScreenshot(std::string_view data, int height) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_SCREENSHOT, NO_REQUESTER_TOKEN, nullptr, nullptr, data, "", height);
|
||||
}
|
||||
|
||||
// Non-inline to avoid including Path.h
|
||||
void System_CreateGameShortcut(const Path &path, const std::string &title);
|
||||
void System_CreateGameShortcut(const Path &path, std::string_view title);
|
||||
void System_ShowFileInFolder(const Path &path);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
@ -28,7 +29,7 @@ enum PermissionStatus {
|
||||
|
||||
// These APIs must be implemented by every port (for example app-android.cpp, SDLMain.cpp).
|
||||
// Ideally these should be safe to call from any thread.
|
||||
void System_Toast(const char *text);
|
||||
void System_Toast(std::string_view text);
|
||||
void System_ShowKeyboard();
|
||||
|
||||
// Vibrate either takes a number of milliseconds to vibrate unconditionally,
|
||||
|
@ -93,6 +93,7 @@ void UIContext::BeginPipeline(Draw::Pipeline *pipeline, Draw::SamplerState *samp
|
||||
}
|
||||
|
||||
void UIContext::RebindTexture() const {
|
||||
_dbg_assert_(uitexture_);
|
||||
if (uitexture_)
|
||||
draw_->BindTexture(0, uitexture_);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
|
||||
|
||||
std::vector<std::string> choices;
|
||||
for (int i = 0; i < numChoices_; i++) {
|
||||
choices.push_back(category ? category->T(choices_[i]) : choices_[i]);
|
||||
choices.push_back(category ? std::string(category->T(choices_[i])) : std::string(choices_[i]));
|
||||
}
|
||||
|
||||
ListPopupScreen *popupScreen = new ListPopupScreen(ChopTitle(text_), choices, *value_ - minVal_,
|
||||
@ -154,13 +154,13 @@ std::string PopupMultiChoice::ValueText() const {
|
||||
return valueText_;
|
||||
}
|
||||
|
||||
PopupSliderChoice::PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, const std::string &text, ScreenManager *screenManager, const std::string &units, LayoutParams *layoutParams)
|
||||
PopupSliderChoice::PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, std::string_view text, ScreenManager *screenManager, std::string_view units, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(1), units_(units), screenManager_(screenManager) {
|
||||
fmt_ = "%d";
|
||||
OnClick.Handle(this, &PopupSliderChoice::HandleClick);
|
||||
}
|
||||
|
||||
PopupSliderChoice::PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, const std::string &text, int step, ScreenManager *screenManager, const std::string &units, LayoutParams *layoutParams)
|
||||
PopupSliderChoice::PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, std::string_view text, int step, ScreenManager *screenManager, std::string_view units, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(step), units_(units), screenManager_(screenManager) {
|
||||
fmt_ = "%d";
|
||||
OnClick.Handle(this, &PopupSliderChoice::HandleClick);
|
||||
@ -175,14 +175,14 @@ void PopupSliderChoice::SetFormat(std::string_view fmt) {
|
||||
}
|
||||
}
|
||||
|
||||
PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, const std::string &text, ScreenManager *screenManager, const std::string &units, LayoutParams *layoutParams)
|
||||
PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, std::string_view text, ScreenManager *screenManager, std::string_view units, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(1.0f), units_(units), screenManager_(screenManager) {
|
||||
_dbg_assert_(maxValue > minValue);
|
||||
fmt_ = "%2.2f";
|
||||
OnClick.Handle(this, &PopupSliderChoiceFloat::HandleClick);
|
||||
}
|
||||
|
||||
PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, const std::string &text, float step, ScreenManager *screenManager, const std::string &units, LayoutParams *layoutParams)
|
||||
PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, std::string_view text, float step, ScreenManager *screenManager, std::string_view units, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(step), units_(units), screenManager_(screenManager) {
|
||||
_dbg_assert_(step > 0.0f);
|
||||
_dbg_assert_(maxValue > minValue);
|
||||
@ -222,7 +222,7 @@ EventReturn PopupSliderChoice::HandleChange(EventParams &e) {
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
static bool IsValidNumberFormatString(const std::string &s) {
|
||||
static bool IsValidNumberFormatString(std::string_view s) {
|
||||
if (s.empty())
|
||||
return false;
|
||||
size_t percentCount = 0;
|
||||
@ -518,7 +518,7 @@ void SliderFloatPopupScreen::OnCompleted(DialogResult result) {
|
||||
}
|
||||
}
|
||||
|
||||
PopupTextInputChoice::PopupTextInputChoice(RequesterToken token, std::string *value, const std::string &title, const std::string &placeholder, int maxLen, ScreenManager *screenManager, LayoutParams *layoutParams)
|
||||
PopupTextInputChoice::PopupTextInputChoice(RequesterToken token, std::string *value, std::string_view title, std::string_view placeholder, int maxLen, ScreenManager *screenManager, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(title, layoutParams), screenManager_(screenManager), value_(value), placeHolder_(placeholder), maxLen_(maxLen), token_(token) {
|
||||
OnClick.Handle(this, &PopupTextInputChoice::HandleClick);
|
||||
}
|
||||
@ -682,11 +682,10 @@ std::string ChoiceWithValueDisplay::ValueText() const {
|
||||
} else if (iValue_ != nullptr) {
|
||||
valueText << *iValue_;
|
||||
}
|
||||
|
||||
return valueText.str();
|
||||
}
|
||||
|
||||
FileChooserChoice::FileChooserChoice(RequesterToken token, std::string *value, const std::string &text, BrowseFileType fileType, LayoutParams *layoutParams)
|
||||
FileChooserChoice::FileChooserChoice(RequesterToken token, std::string *value, std::string_view text, BrowseFileType fileType, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), fileType_(fileType), token_(token) {
|
||||
OnClick.Add([=](UI::EventParams &) {
|
||||
System_BrowseForFile(token, text_, fileType, [=](const std::string &returnValue, int) {
|
||||
@ -704,13 +703,13 @@ FileChooserChoice::FileChooserChoice(RequesterToken token, std::string *value, c
|
||||
std::string FileChooserChoice::ValueText() const {
|
||||
if (value_->empty()) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
return di->T("Default");
|
||||
return std::string(di->T("Default"));
|
||||
}
|
||||
Path path(*value_);
|
||||
return path.GetFilename();
|
||||
}
|
||||
|
||||
FolderChooserChoice::FolderChooserChoice(RequesterToken token, std::string *value, const std::string &text, LayoutParams *layoutParams)
|
||||
FolderChooserChoice::FolderChooserChoice(RequesterToken token, std::string *value, std::string_view text, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), token_(token) {
|
||||
OnClick.Add([=](UI::EventParams &) {
|
||||
System_BrowseForFolder(token_, text_, Path(*value), [=](const std::string &returnValue, int) {
|
||||
@ -728,7 +727,7 @@ FolderChooserChoice::FolderChooserChoice(RequesterToken token, std::string *valu
|
||||
std::string FolderChooserChoice::ValueText() const {
|
||||
if (value_->empty()) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
return di->T("Default");
|
||||
return std::string(di->T("Default"));
|
||||
}
|
||||
Path path(*value_);
|
||||
return path.ToVisualString();
|
||||
|
@ -15,11 +15,11 @@ static const int NO_DEFAULT_INT = -1000000;
|
||||
|
||||
class ListPopupScreen : public PopupScreen {
|
||||
public:
|
||||
ListPopupScreen(std::string title) : PopupScreen(title) {}
|
||||
ListPopupScreen(std::string title, const std::vector<std::string> &items, int selected, std::function<void(int)> callback, bool showButtons = false)
|
||||
ListPopupScreen(std::string_view title) : PopupScreen(title) {}
|
||||
ListPopupScreen(std::string_view title, const std::vector<std::string> &items, int selected, std::function<void(int)> callback, bool showButtons = false)
|
||||
: PopupScreen(title, "OK", "Cancel"), adaptor_(items, selected), callback_(callback), showButtons_(showButtons) {
|
||||
}
|
||||
ListPopupScreen(std::string title, const std::vector<std::string> &items, int selected, bool showButtons = false)
|
||||
ListPopupScreen(std::string_view title, const std::vector<std::string> &items, int selected, bool showButtons = false)
|
||||
: PopupScreen(title, "OK", "Cancel"), adaptor_(items, selected), showButtons_(showButtons) {
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ private:
|
||||
|
||||
class MessagePopupScreen : public PopupScreen {
|
||||
public:
|
||||
MessagePopupScreen(std::string title, std::string message, std::string button1, std::string button2, std::function<void(bool)> callback)
|
||||
MessagePopupScreen(std::string_view title, std::string message, std::string button1, std::string button2, std::function<void(bool)> callback)
|
||||
: PopupScreen(title, button1, button2), message_(message), callback_(callback) {}
|
||||
|
||||
const char *tag() const override { return "MessagePopupScreen"; }
|
||||
@ -77,7 +77,7 @@ private:
|
||||
|
||||
class SliderPopupScreen : public PopupScreen {
|
||||
public:
|
||||
SliderPopupScreen(int *value, int minValue, int maxValue, int defaultValue, const std::string &title, int step = 1, const std::string &units = "")
|
||||
SliderPopupScreen(int *value, int minValue, int maxValue, int defaultValue, std::string_view title, int step = 1, std::string_view units = "")
|
||||
: PopupScreen(title, "OK", "Cancel"), units_(units), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(step) {}
|
||||
void CreatePopupContents(ViewGroup *parent) override;
|
||||
|
||||
@ -113,7 +113,7 @@ private:
|
||||
|
||||
class SliderFloatPopupScreen : public PopupScreen {
|
||||
public:
|
||||
SliderFloatPopupScreen(float *value, float minValue, float maxValue, float defaultValue, const std::string &title, float step = 1.0f, const std::string &units = "", bool liveUpdate = false)
|
||||
SliderFloatPopupScreen(float *value, float minValue, float maxValue, float defaultValue, std::string_view title, float step = 1.0f, std::string_view units = "", bool liveUpdate = false)
|
||||
: PopupScreen(title, "OK", "Cancel"), units_(units), value_(value), originalValue_(*value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(step), liveUpdate_(liveUpdate) {}
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override;
|
||||
|
||||
@ -144,7 +144,7 @@ private:
|
||||
|
||||
class TextEditPopupScreen : public PopupScreen {
|
||||
public:
|
||||
TextEditPopupScreen(std::string *value, const std::string &placeholder, const std::string &title, int maxLen)
|
||||
TextEditPopupScreen(std::string *value, std::string_view placeholder, std::string_view title, int maxLen)
|
||||
: PopupScreen(title, "OK", "Cancel"), value_(value), placeholder_(placeholder), maxLen_(maxLen) {}
|
||||
void CreatePopupContents(ViewGroup *parent) override;
|
||||
|
||||
@ -194,7 +194,7 @@ private:
|
||||
// Reads and writes value to determine the current selection.
|
||||
class PopupMultiChoice : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
PopupMultiChoice(int *value, const std::string &text, const char **choices, int minVal, int numChoices,
|
||||
PopupMultiChoice(int *value, std::string_view text, const char **choices, int minVal, int numChoices,
|
||||
I18NCat category, ScreenManager *screenManager, UI::LayoutParams *layoutParams = nullptr)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), choices_(choices), minVal_(minVal), numChoices_(numChoices),
|
||||
category_(category), screenManager_(screenManager) {
|
||||
@ -246,7 +246,7 @@ private:
|
||||
// Allows passing in a dynamic vector of strings. Saves the string.
|
||||
class PopupMultiChoiceDynamic : public PopupMultiChoice {
|
||||
public:
|
||||
PopupMultiChoiceDynamic(std::string *value, const std::string &text, std::vector<std::string> choices,
|
||||
PopupMultiChoiceDynamic(std::string *value, std::string_view text, std::vector<std::string> choices,
|
||||
I18NCat category, ScreenManager *screenManager, UI::LayoutParams *layoutParams = nullptr)
|
||||
: UI::PopupMultiChoice(&valueInt_, text, nullptr, 0, (int)choices.size(), category, screenManager, layoutParams),
|
||||
valueStr_(value) {
|
||||
@ -282,14 +282,14 @@ private:
|
||||
|
||||
class PopupSliderChoice : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, const std::string &text, ScreenManager *screenManager, const std::string &units = "", LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, const std::string &text, int step, ScreenManager *screenManager, const std::string &units = "", LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, std::string_view text, ScreenManager *screenManager, std::string_view units = "", LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoice(int *value, int minValue, int maxValue, int defaultValue, std::string_view text, int step, ScreenManager *screenManager, std::string_view units = "", LayoutParams *layoutParams = 0);
|
||||
|
||||
void SetFormat(std::string_view fmt);
|
||||
void SetZeroLabel(const std::string &str) {
|
||||
void SetZeroLabel(std::string_view str) {
|
||||
zeroLabel_ = str;
|
||||
}
|
||||
void SetNegativeDisable(const std::string &str) {
|
||||
void SetNegativeDisable(std::string_view str) {
|
||||
negativeLabel_ = str;
|
||||
}
|
||||
|
||||
@ -317,8 +317,8 @@ private:
|
||||
|
||||
class PopupSliderChoiceFloat : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, const std::string &text, ScreenManager *screenManager, const std::string &units = "", LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, const std::string &text, float step, ScreenManager *screenManager, const std::string &units = "", LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, std::string_view text, ScreenManager *screenManager, std::string_view units = "", LayoutParams *layoutParams = 0);
|
||||
PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, std::string_view text, float step, ScreenManager *screenManager, std::string_view units = "", LayoutParams *layoutParams = 0);
|
||||
|
||||
void SetFormat(std::string_view fmt);
|
||||
void SetZeroLabel(const std::string &str) {
|
||||
@ -356,7 +356,7 @@ private:
|
||||
// NOTE: This one will defer to a system-native dialog if possible.
|
||||
class PopupTextInputChoice : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
PopupTextInputChoice(RequesterToken token, std::string *value, const std::string &title, const std::string &placeholder, int maxLen, ScreenManager *screenManager, LayoutParams *layoutParams = 0);
|
||||
PopupTextInputChoice(RequesterToken token, std::string *value, std::string_view title, std::string_view placeholder, int maxLen, ScreenManager *screenManager, LayoutParams *layoutParams = 0);
|
||||
|
||||
Event OnChange;
|
||||
|
||||
@ -377,13 +377,13 @@ private:
|
||||
|
||||
class ChoiceWithValueDisplay : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
ChoiceWithValueDisplay(int *value, const std::string &text, LayoutParams *layoutParams = 0)
|
||||
ChoiceWithValueDisplay(int *value, std::string_view text, LayoutParams *layoutParams = 0)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), iValue_(value) {}
|
||||
|
||||
ChoiceWithValueDisplay(std::string *value, const std::string &text, I18NCat category, LayoutParams *layoutParams = 0)
|
||||
ChoiceWithValueDisplay(std::string *value, std::string_view text, I18NCat category, LayoutParams *layoutParams = 0)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), sValue_(value), category_(category) {}
|
||||
|
||||
ChoiceWithValueDisplay(std::string *value, const std::string &text, std::string(*translateCallback)(const char *value), LayoutParams *layoutParams = 0)
|
||||
ChoiceWithValueDisplay(std::string *value, std::string_view text, std::string(*translateCallback)(std::string_view value), LayoutParams *layoutParams = 0)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), sValue_(value), translateCallback_(translateCallback) {
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ private:
|
||||
std::string *sValue_ = nullptr;
|
||||
int *iValue_ = nullptr;
|
||||
I18NCat category_ = I18NCat::CATEGORY_COUNT;
|
||||
std::string(*translateCallback_)(const char *value) = nullptr;
|
||||
std::string(*translateCallback_)(std::string_view value) = nullptr;
|
||||
};
|
||||
|
||||
enum class FileChooserFileType {
|
||||
@ -402,7 +402,7 @@ enum class FileChooserFileType {
|
||||
|
||||
class FileChooserChoice : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
FileChooserChoice(RequesterToken token, std::string *value, const std::string &title, BrowseFileType fileType, LayoutParams *layoutParams = nullptr);
|
||||
FileChooserChoice(RequesterToken token, std::string *value, std::string_view title, BrowseFileType fileType, LayoutParams *layoutParams = nullptr);
|
||||
std::string ValueText() const override;
|
||||
|
||||
Event OnChange;
|
||||
@ -415,7 +415,7 @@ private:
|
||||
|
||||
class FolderChooserChoice : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
FolderChooserChoice(RequesterToken token, std::string *value, const std::string &title, LayoutParams *layoutParams = nullptr);
|
||||
FolderChooserChoice(RequesterToken token, std::string *value, std::string_view title, LayoutParams *layoutParams = nullptr);
|
||||
std::string ValueText() const override;
|
||||
|
||||
Event OnChange;
|
||||
|
@ -295,13 +295,13 @@ UI::EventReturn UIScreen::OnCancel(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
PopupScreen::PopupScreen(std::string title, std::string button1, std::string button2)
|
||||
PopupScreen::PopupScreen(std::string_view title, std::string_view button1, std::string_view button2)
|
||||
: title_(title) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
if (!button1.empty())
|
||||
button1_ = di->T(button1.c_str());
|
||||
button1_ = di->T(button1);
|
||||
if (!button2.empty())
|
||||
button2_ = di->T(button2.c_str());
|
||||
button2_ = di->T(button2);
|
||||
alpha_ = 0.0f; // inherited
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ private:
|
||||
|
||||
class PopupScreen : public UIDialogScreen {
|
||||
public:
|
||||
PopupScreen(std::string title, std::string button1 = "", std::string button2 = "");
|
||||
PopupScreen(std::string_view title, std::string_view button1 = "", std::string_view button2 = "");
|
||||
|
||||
virtual void CreatePopupContents(UI::ViewGroup *parent) = 0;
|
||||
void CreateViews() override;
|
||||
|
@ -546,7 +546,7 @@ std::string Choice::DescribeText() const {
|
||||
return ApplySafeSubstitutions(u->T("%1 choice"), text_);
|
||||
}
|
||||
|
||||
InfoItem::InfoItem(const std::string &text, const std::string &rightText, LayoutParams *layoutParams)
|
||||
InfoItem::InfoItem(std::string_view text, std::string_view rightText, LayoutParams *layoutParams)
|
||||
: Item(layoutParams), text_(text), rightText_(rightText) {
|
||||
// We set the colors later once we have a UIContext.
|
||||
bgColor_ = AddTween(new CallbackColorTween(0.1f));
|
||||
@ -594,7 +594,7 @@ std::string InfoItem::DescribeText() const {
|
||||
return ApplySafeSubstitutions(u->T("%1: %2"), text_, rightText_);
|
||||
}
|
||||
|
||||
ItemHeader::ItemHeader(const std::string &text, LayoutParams *layoutParams)
|
||||
ItemHeader::ItemHeader(std::string_view text, LayoutParams *layoutParams)
|
||||
: Item(layoutParams), text_(text) {
|
||||
layoutParams_->width = FILL_PARENT;
|
||||
layoutParams_->height = 40;
|
||||
@ -624,7 +624,7 @@ std::string ItemHeader::DescribeText() const {
|
||||
return ApplySafeSubstitutions(u->T("%1 heading"), text_);
|
||||
}
|
||||
|
||||
CollapsibleHeader::CollapsibleHeader(bool *toggle, const std::string &text, LayoutParams *layoutParams)
|
||||
CollapsibleHeader::CollapsibleHeader(bool *toggle, std::string_view text, LayoutParams *layoutParams)
|
||||
: CheckBox(toggle, text, "", layoutParams) {
|
||||
layoutParams_->width = FILL_PARENT;
|
||||
layoutParams_->height = 40;
|
||||
@ -1098,7 +1098,7 @@ void TextView::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
TextEdit::TextEdit(const std::string &text, const std::string &title, const std::string &placeholderText, LayoutParams *layoutParams)
|
||||
TextEdit::TextEdit(std::string_view text, std::string_view title, std::string_view placeholderText, LayoutParams *layoutParams)
|
||||
: View(layoutParams), text_(text), title_(title), undo_(text), placeholderText_(placeholderText),
|
||||
textColor_(0xFFFFFFFF), maxLen_(255) {
|
||||
caret_ = (int)text_.size();
|
||||
|
@ -543,15 +543,15 @@ protected:
|
||||
// Right now more flexible image support though.
|
||||
class Button : public Clickable {
|
||||
public:
|
||||
Button(const std::string &text, LayoutParams *layoutParams = 0)
|
||||
Button(std::string_view text, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), text_(text), imageID_(ImageID::invalid()) {}
|
||||
Button(const std::string &text, ImageID imageID, LayoutParams *layoutParams = 0)
|
||||
Button(std::string_view text, ImageID imageID, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), text_(text), imageID_(imageID) {}
|
||||
|
||||
void Click() override;
|
||||
void Draw(UIContext &dc) override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
const std::string &GetText() const { return text_; }
|
||||
std::string_view GetText() const { return text_; }
|
||||
std::string DescribeText() const override;
|
||||
void SetPadding(int w, int h) {
|
||||
paddingW_ = w;
|
||||
@ -579,7 +579,7 @@ private:
|
||||
|
||||
class RadioButton : public Clickable {
|
||||
public:
|
||||
RadioButton(int *value, int thisButtonValue, const std::string &text, LayoutParams *layoutParams = 0)
|
||||
RadioButton(int *value, int thisButtonValue, std::string_view text, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), value_(value), thisButtonValue_(thisButtonValue), text_(text) {}
|
||||
void Click() override;
|
||||
void Draw(UIContext &dc) override;
|
||||
@ -704,11 +704,11 @@ public:
|
||||
// Use to trigger something or open a submenu screen.
|
||||
class Choice : public ClickableItem {
|
||||
public:
|
||||
Choice(const std::string &text, LayoutParams *layoutParams = nullptr)
|
||||
Choice(std::string_view text, LayoutParams *layoutParams = nullptr)
|
||||
: Choice(text, std::string(), false, layoutParams) {}
|
||||
Choice(const std::string &text, ImageID image, LayoutParams *layoutParams = nullptr)
|
||||
Choice(std::string_view text, ImageID image, LayoutParams *layoutParams = nullptr)
|
||||
: ClickableItem(layoutParams), text_(text), image_(image) {}
|
||||
Choice(const std::string &text, const std::string &smallText, bool selected = false, LayoutParams *layoutParams = nullptr)
|
||||
Choice(std::string_view text, std::string_view smallText, bool selected = false, LayoutParams *layoutParams = nullptr)
|
||||
: ClickableItem(layoutParams), text_(text), smallText_(smallText), image_(ImageID::invalid()) {}
|
||||
Choice(ImageID image, LayoutParams *layoutParams = nullptr)
|
||||
: ClickableItem(layoutParams), image_(image), rightIconImage_(ImageID::invalid()) {}
|
||||
@ -759,7 +759,7 @@ private:
|
||||
// Different key handling.
|
||||
class StickyChoice : public Choice {
|
||||
public:
|
||||
StickyChoice(const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = 0)
|
||||
StickyChoice(std::string_view text, std::string_view smallText = "", LayoutParams *layoutParams = 0)
|
||||
: Choice(text, smallText, false, layoutParams) {}
|
||||
StickyChoice(ImageID buttonImage, LayoutParams *layoutParams = 0)
|
||||
: Choice(buttonImage, layoutParams) {}
|
||||
@ -779,7 +779,7 @@ protected:
|
||||
|
||||
class InfoItem : public Item {
|
||||
public:
|
||||
InfoItem(const std::string &text, const std::string &rightText, LayoutParams *layoutParams = nullptr);
|
||||
InfoItem(std::string_view text, std::string_view rightText, LayoutParams *layoutParams = nullptr);
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
@ -787,13 +787,13 @@ public:
|
||||
// These are focusable so that long lists of them can be keyboard scrolled.
|
||||
bool CanBeFocused() const override { return true; }
|
||||
|
||||
void SetText(const std::string &text) {
|
||||
void SetText(std::string_view text) {
|
||||
text_ = text;
|
||||
}
|
||||
const std::string &GetText() const {
|
||||
return text_;
|
||||
}
|
||||
void SetRightText(const std::string &text) {
|
||||
void SetRightText(std::string_view text) {
|
||||
rightText_ = text;
|
||||
}
|
||||
void SetChoiceStyle(bool choiceStyle) {
|
||||
@ -812,7 +812,7 @@ private:
|
||||
|
||||
class AbstractChoiceWithValueDisplay : public Choice {
|
||||
public:
|
||||
AbstractChoiceWithValueDisplay(const std::string &text, LayoutParams *layoutParams = nullptr)
|
||||
AbstractChoiceWithValueDisplay(std::string_view text, LayoutParams *layoutParams = nullptr)
|
||||
: Choice(text, layoutParams) {
|
||||
}
|
||||
|
||||
@ -833,7 +833,7 @@ protected:
|
||||
|
||||
class ChoiceWithCallbackValueDisplay : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
ChoiceWithCallbackValueDisplay(const std::string &text, std::function<std::string()> valueFunc, LayoutParams *layoutParams = nullptr)
|
||||
ChoiceWithCallbackValueDisplay(std::string_view text, std::function<std::string()> valueFunc, LayoutParams *layoutParams = nullptr)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), valueFunc_(valueFunc) {}
|
||||
protected:
|
||||
std::string ValueText() const override {
|
||||
@ -844,7 +844,7 @@ protected:
|
||||
|
||||
class ItemHeader : public Item {
|
||||
public:
|
||||
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
|
||||
ItemHeader(std::string_view text, LayoutParams *layoutParams = 0);
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
@ -856,7 +856,7 @@ private:
|
||||
|
||||
class PopupHeader : public Item {
|
||||
public:
|
||||
PopupHeader(const std::string &text, LayoutParams *layoutParams = 0)
|
||||
PopupHeader(std::string_view text, LayoutParams *layoutParams = 0)
|
||||
: Item(layoutParams), text_(text) {
|
||||
layoutParams_->width = FILL_PARENT;
|
||||
layoutParams_->height = 64;
|
||||
@ -870,7 +870,7 @@ private:
|
||||
|
||||
class CheckBox : public ClickableItem {
|
||||
public:
|
||||
CheckBox(bool *toggle, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = nullptr)
|
||||
CheckBox(bool *toggle, std::string_view text, std::string_view smallText = "", LayoutParams *layoutParams = nullptr)
|
||||
: ClickableItem(layoutParams), toggle_(toggle), text_(text), smallText_(smallText) {
|
||||
OnClick.Handle(this, &CheckBox::OnClicked);
|
||||
}
|
||||
@ -899,7 +899,7 @@ protected:
|
||||
|
||||
class CollapsibleHeader : public CheckBox {
|
||||
public:
|
||||
CollapsibleHeader(bool *open, const std::string &text, LayoutParams *layoutParams = nullptr);
|
||||
CollapsibleHeader(bool *open, std::string_view text, LayoutParams *layoutParams = nullptr);
|
||||
void Draw(UIContext &dc) override;
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
@ -916,11 +916,11 @@ private:
|
||||
|
||||
class BitCheckBox : public CheckBox {
|
||||
public:
|
||||
BitCheckBox(uint32_t *bitfield, uint32_t bit, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = nullptr)
|
||||
BitCheckBox(uint32_t *bitfield, uint32_t bit, std::string_view text, std::string_view smallText = "", LayoutParams *layoutParams = nullptr)
|
||||
: CheckBox(nullptr, text, smallText, layoutParams), bitfield_(bitfield), bit_(bit) {
|
||||
}
|
||||
|
||||
BitCheckBox(int *bitfield, int bit, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = nullptr) : BitCheckBox((uint32_t *)bitfield, (uint32_t)bit, text, smallText, layoutParams) {}
|
||||
BitCheckBox(int *bitfield, int bit, std::string_view text, std::string_view smallText = "", LayoutParams *layoutParams = nullptr) : BitCheckBox((uint32_t *)bitfield, (uint32_t)bit, text, smallText, layoutParams) {}
|
||||
|
||||
void Toggle() override;
|
||||
bool Toggled() const override;
|
||||
@ -988,7 +988,7 @@ public:
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
void SetText(const std::string &text) { text_ = text; }
|
||||
void SetText(std::string_view text) { text_ = text; }
|
||||
const std::string &GetText() const { return text_; }
|
||||
std::string DescribeText() const override { return GetText(); }
|
||||
void SetSmall(bool small) { small_ = small; }
|
||||
@ -1016,8 +1016,8 @@ private:
|
||||
|
||||
class TextEdit : public View {
|
||||
public:
|
||||
TextEdit(const std::string &text, const std::string &title, const std::string &placeholderText, LayoutParams *layoutParams = nullptr);
|
||||
void SetText(const std::string &text) { text_ = text; scrollPos_ = 0; caret_ = (int)text_.size(); }
|
||||
TextEdit(std::string_view text, std::string_view title, std::string_view placeholderText, LayoutParams *layoutParams = nullptr);
|
||||
void SetText(std::string_view text) { text_ = text; scrollPos_ = 0; caret_ = (int)text_.size(); }
|
||||
void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; }
|
||||
const std::string &GetText() const { return text_; }
|
||||
void SetMaxLen(size_t maxLen) { maxLen_ = maxLen; }
|
||||
|
@ -189,7 +189,7 @@ std::string ViewGroup::DescribeText() const {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string ViewGroup::DescribeListUnordered(const char *heading) const {
|
||||
std::string ViewGroup::DescribeListUnordered(std::string_view heading) const {
|
||||
std::stringstream ss;
|
||||
ss << heading << "\n";
|
||||
|
||||
@ -206,7 +206,7 @@ std::string ViewGroup::DescribeListUnordered(const char *heading) const {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string ViewGroup::DescribeListOrdered(const char *heading) const {
|
||||
std::string ViewGroup::DescribeListOrdered(std::string_view heading) const {
|
||||
std::stringstream ss;
|
||||
ss << heading << "\n";
|
||||
|
||||
@ -973,7 +973,7 @@ void TabHolder::AddBack(UIScreen *parent) {
|
||||
}
|
||||
}
|
||||
|
||||
void TabHolder::AddTabContents(const std::string &title, View *tabContents) {
|
||||
void TabHolder::AddTabContents(std::string_view title, View *tabContents) {
|
||||
tabContents->ReplaceLayoutParams(new AnchorLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
tabs_.push_back(tabContents);
|
||||
tabStrip_->AddChoice(title);
|
||||
@ -1075,7 +1075,7 @@ ChoiceStrip::ChoiceStrip(Orientation orientation, LayoutParams *layoutParams)
|
||||
SetSpacing(0.0f);
|
||||
}
|
||||
|
||||
void ChoiceStrip::AddChoice(const std::string &title) {
|
||||
void ChoiceStrip::AddChoice(std::string_view title) {
|
||||
StickyChoice *c = new StickyChoice(title, "",
|
||||
orientation_ == ORIENT_HORIZONTAL ?
|
||||
nullptr :
|
||||
@ -1174,7 +1174,7 @@ StickyChoice *ChoiceStrip::Choice(int index) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CollapsibleSection::CollapsibleSection(const std::string &title, LayoutParams *layoutParams) : LinearLayout(ORIENT_VERTICAL, layoutParams) {
|
||||
CollapsibleSection::CollapsibleSection(std::string_view title, LayoutParams *layoutParams) : LinearLayout(ORIENT_VERTICAL, layoutParams) {
|
||||
open_ = &localOpen_;
|
||||
SetSpacing(0.0f);
|
||||
|
||||
|
@ -82,8 +82,8 @@ public:
|
||||
std::string DescribeText() const override;
|
||||
|
||||
protected:
|
||||
std::string DescribeListUnordered(const char *heading) const;
|
||||
std::string DescribeListOrdered(const char *heading) const;
|
||||
std::string DescribeListUnordered(std::string_view heading) const;
|
||||
std::string DescribeListOrdered(std::string_view heading) const;
|
||||
|
||||
std::vector<View *> views_;
|
||||
View *defaultFocusView_ = nullptr;
|
||||
@ -261,7 +261,7 @@ class ChoiceStrip : public LinearLayout {
|
||||
public:
|
||||
ChoiceStrip(Orientation orientation, LayoutParams *layoutParams = 0);
|
||||
|
||||
void AddChoice(const std::string &title);
|
||||
void AddChoice(std::string_view title);
|
||||
void AddChoice(ImageID buttonImage);
|
||||
|
||||
int GetSelection() const { return selected_; }
|
||||
@ -291,7 +291,7 @@ public:
|
||||
TabHolder(Orientation orientation, float stripSize, LayoutParams *layoutParams = 0);
|
||||
|
||||
template <class T>
|
||||
T *AddTab(const std::string &title, T *tabContents) {
|
||||
T *AddTab(std::string_view title, T *tabContents) {
|
||||
AddTabContents(title, (View *)tabContents);
|
||||
return tabContents;
|
||||
}
|
||||
@ -309,7 +309,7 @@ public:
|
||||
void PersistData(PersistStatus status, std::string anonId, PersistMap &storage) override;
|
||||
|
||||
private:
|
||||
void AddTabContents(const std::string &title, View *tabContents);
|
||||
void AddTabContents(std::string_view title, View *tabContents);
|
||||
EventReturn OnTabClick(EventParams &e);
|
||||
|
||||
LinearLayout *tabContainer_ = nullptr;
|
||||
@ -327,7 +327,7 @@ class CollapsibleHeader;
|
||||
|
||||
class CollapsibleSection : public LinearLayout {
|
||||
public:
|
||||
CollapsibleSection(const std::string &title, LayoutParams *layoutParams = nullptr);
|
||||
CollapsibleSection(std::string_view title, LayoutParams *layoutParams = nullptr);
|
||||
|
||||
void Update() override;
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ void Config::LoadLangValuesMapping() {
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<std::string, std::pair<std::string, int>> &Config::GetLangValuesMapping() {
|
||||
const std::map<std::string, std::pair<std::string, int>, std::less<>> &Config::GetLangValuesMapping() {
|
||||
if (langValuesMapping_.empty()) {
|
||||
LoadLangValuesMapping();
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ public:
|
||||
bool HasRecentIsos() const;
|
||||
void ClearRecentIsos();
|
||||
|
||||
const std::map<std::string, std::pair<std::string, int>> &GetLangValuesMapping();
|
||||
const std::map<std::string, std::pair<std::string, int>, std::less<>> &GetLangValuesMapping();
|
||||
bool LoadAppendedConfig();
|
||||
void SetAppendedConfigIni(const Path &path);
|
||||
void UpdateAfterSettingAutoFrameSkip();
|
||||
@ -630,7 +630,7 @@ private:
|
||||
std::string gameId_;
|
||||
std::string gameIdTitle_;
|
||||
std::vector<std::string> recentIsos;
|
||||
std::map<std::string, std::pair<std::string, int>> langValuesMapping_;
|
||||
std::map<std::string, std::pair<std::string, int>, std::less<>> langValuesMapping_;
|
||||
PlayTimeTracker playTimeTracker_;
|
||||
Path iniFilename_;
|
||||
Path controllerIniFilename_;
|
||||
|
@ -300,13 +300,12 @@ PPGeImageStyle PSPDialog::FadedImageStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
void PSPDialog::DisplayButtons(int flags, const char *caption)
|
||||
{
|
||||
void PSPDialog::DisplayButtons(int flags, std::string_view caption) {
|
||||
bool useCaption = false;
|
||||
char safeCaption[65] = {0};
|
||||
if (caption != NULL && *caption != '\0') {
|
||||
if (!caption.empty()) {
|
||||
useCaption = true;
|
||||
truncate_cpy(safeCaption, caption);
|
||||
truncate_cpy(safeCaption, sizeof(safeCaption), caption);
|
||||
}
|
||||
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
|
||||
@ -318,12 +317,12 @@ void PSPDialog::DisplayButtons(int flags, const char *caption)
|
||||
x2 = 183.5f;
|
||||
}
|
||||
if (flags & DS_BUTTON_OK) {
|
||||
const char *text = useCaption ? safeCaption : di->T("Enter");
|
||||
std::string_view text = useCaption ? safeCaption : di->T("Enter");
|
||||
PPGeDrawImage(okButtonImg, x2, 256, 11.5f, 11.5f, textStyle);
|
||||
PPGeDrawText(text, x2 + 14.5f, 252, textStyle);
|
||||
}
|
||||
if (flags & DS_BUTTON_CANCEL) {
|
||||
const char *text = useCaption ? safeCaption : di->T("Back");
|
||||
std::string_view text = useCaption ? safeCaption : di->T("Back");
|
||||
PPGeDrawImage(cancelButtonImg, x1, 256, 11.5f, 11.5f, textStyle);
|
||||
PPGeDrawText(text, x1 + 14.5f, 252, textStyle);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ protected:
|
||||
bool IsButtonPressed(int checkButton);
|
||||
bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);
|
||||
// The caption override is assumed to have a size of 64 bytes.
|
||||
void DisplayButtons(int flags, const char *caption = NULL);
|
||||
void DisplayButtons(int flags, std::string_view caption = "");
|
||||
void ChangeStatus(DialogStatus newStatus, int delayUs);
|
||||
void ChangeStatusInit(int delayUs);
|
||||
void ChangeStatusShutdown(int delayUs);
|
||||
|
@ -151,7 +151,7 @@ void PSPMsgDialog::FormatErrorCode(uint32_t code) {
|
||||
|
||||
switch (code) {
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_LOAD_DATA_BROKEN:
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T("MsgErrorSavedataDataBroken", "Save data was corrupt."), code);
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T_cstr("MsgErrorSavedataDataBroken", "Save data was corrupt."), code);
|
||||
break;
|
||||
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_MS:
|
||||
@ -159,23 +159,23 @@ void PSPMsgDialog::FormatErrorCode(uint32_t code) {
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_SAVE_NO_MS:
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_MS:
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_MS:
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T("MsgErrorSavedataNoMS", "Memory stick not inserted."), code);
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T_cstr("MsgErrorSavedataNoMS", "Memory stick not inserted."), code);
|
||||
break;
|
||||
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA:
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA:
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA:
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA:
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T("MsgErrorSavedataNoData", "Warning: no save data was found."), code);
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T_cstr("MsgErrorSavedataNoData", "Warning: no save data was found."), code);
|
||||
break;
|
||||
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_RW_MEMSTICK_FULL:
|
||||
case SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE:
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T("MsgErrorSavedataMSFull", "Memory stick full. Check your storage space."), code);
|
||||
snprintf(msgText, 512, "%s (%08x)", err->T_cstr("MsgErrorSavedataMSFull", "Memory stick full. Check your storage space."), code);
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf(msgText, 512, "%s %08x", err->T("MsgErrorCode", "Error code:"), code);
|
||||
snprintf(msgText, 512, "%s %08x", err->T_cstr("MsgErrorCode", "Error code:"), code);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ void PSPMsgDialog::DisplayMessage(const std::string &text, bool hasYesNo, bool h
|
||||
|
||||
// Without the scrollbar, we have 390 total pixels.
|
||||
float WRAP_WIDTH = 340.0f;
|
||||
if ((size_t)UTF8StringNonASCIICount(text.c_str()) >= text.size() / 4) {
|
||||
if ((size_t)UTF8StringNonASCIICount(text) >= text.size() / 4) {
|
||||
WRAP_WIDTH = 376.0f;
|
||||
if (text.size() > 12) {
|
||||
messageStyle.scale = 0.6f;
|
||||
@ -195,7 +195,7 @@ void PSPMsgDialog::DisplayMessage(const std::string &text, bool hasYesNo, bool h
|
||||
}
|
||||
|
||||
float totalHeight = 0.0f;
|
||||
PPGeMeasureText(nullptr, &totalHeight, text.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight, text, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
// The PSP normally only shows about 8 lines at a time.
|
||||
// For improved UX, we intentionally show part of the next line.
|
||||
float visibleHeight = std::min(totalHeight, 175.0f);
|
||||
|
@ -103,7 +103,7 @@ void PSPNetconfDialog::DrawIndicator() {
|
||||
PPGeDrawImage(456, 248, 20.0f, 20.0f, 1, 10, 1, 10, 10, 10, FadedImageStyle());
|
||||
}
|
||||
|
||||
void PSPNetconfDialog::DisplayMessage(const std::string &text1, const std::string &text2a, const std::string &text2b, const std::string &text3a, const std::string &text3b, bool hasYesNo, bool hasOK) {
|
||||
void PSPNetconfDialog::DisplayMessage(std::string_view text1, std::string_view text2a, std::string_view text2b, std::string_view text3a, std::string_view text3b, bool hasYesNo, bool hasOK) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
|
||||
@ -111,12 +111,12 @@ void PSPNetconfDialog::DisplayMessage(const std::string &text1, const std::strin
|
||||
PPGeStyle messageStyleRight = FadedStyle(PPGeAlign::BOX_RIGHT, FONT_SCALE);
|
||||
PPGeStyle messageStyleLeft = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
|
||||
|
||||
std::string text2 = text2a + " " + text2b;
|
||||
std::string text3 = text3a + " " + text3b;
|
||||
std::string text2 = std::string(text2a) + " " + std::string(text2b);
|
||||
std::string text3 = std::string(text3a) + " " + std::string(text3b);
|
||||
|
||||
// Without the scrollbar, we have 350 total pixels.
|
||||
float WRAP_WIDTH = 300.0f;
|
||||
if (UTF8StringNonASCIICount(text1.c_str()) >= (int)text1.size() / 4) {
|
||||
if (UTF8StringNonASCIICount(text1) >= (int)text1.size() / 4) {
|
||||
WRAP_WIDTH = 336.0f;
|
||||
if (text1.size() > 12) {
|
||||
messageStyle.scale = 0.6f;
|
||||
@ -124,13 +124,13 @@ void PSPNetconfDialog::DisplayMessage(const std::string &text1, const std::strin
|
||||
}
|
||||
|
||||
float totalHeight1 = 0.0f;
|
||||
PPGeMeasureText(nullptr, &totalHeight1, text1.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight1, text1, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
float totalHeight2 = 0.0f;
|
||||
if (text2 != " ")
|
||||
PPGeMeasureText(nullptr, &totalHeight2, text2.c_str(), FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight2, text2, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
float totalHeight3 = 0.0f;
|
||||
if (text3 != " ")
|
||||
PPGeMeasureText(nullptr, &totalHeight3, text3.c_str(), FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight3, text3, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
float marginTop = 0.0f;
|
||||
if (text2 != " " || text3 != " ")
|
||||
marginTop = 11.0f;
|
||||
@ -183,23 +183,23 @@ void PSPNetconfDialog::DisplayMessage(const std::string &text1, const std::strin
|
||||
}
|
||||
|
||||
PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2));
|
||||
PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
|
||||
PPGeDrawTextWrapped(text1, 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
|
||||
if (!text2a.empty()) {
|
||||
if (!text2b.empty())
|
||||
PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
PPGeDrawTextWrapped(text2a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
else
|
||||
PPGeDrawTextWrapped(text2a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
PPGeDrawTextWrapped(text2a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
}
|
||||
if (!text2b.empty())
|
||||
PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeDrawTextWrapped(text2b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
if (!text3a.empty()) {
|
||||
if (!text3b.empty())
|
||||
PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
PPGeDrawTextWrapped(text3a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
else
|
||||
PPGeDrawTextWrapped(text3a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
PPGeDrawTextWrapped(text3a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
}
|
||||
if (!text3b.empty())
|
||||
PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeDrawTextWrapped(text3b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeScissorReset();
|
||||
|
||||
// Do we need a scrollbar?
|
||||
@ -329,7 +329,8 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
|
||||
if (timedout) {
|
||||
// FIXME: Do we need to show error message?
|
||||
DisplayMessage(di->T("InternalError", "An internal error has occurred.") + StringFromFormat("\n(%08X)", connResult));
|
||||
std::string message(di->T("InternalError", "An internal error has occurred."));
|
||||
DisplayMessage(message + StringFromFormat("\n(%08X)", connResult));
|
||||
DisplayButtons(DS_BUTTON_CANCEL, di->T("Back"));
|
||||
}
|
||||
else {
|
||||
@ -337,7 +338,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
if (g_Config.iWlanAdhocChannel == PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC)
|
||||
channel = "Automatic";
|
||||
|
||||
DisplayMessage(di->T("ConnectingPleaseWait", "Connecting.\nPlease wait..."), di->T("Channel:") + std::string(" ") + di->T(channel));
|
||||
DisplayMessage(di->T("ConnectingPleaseWait", "Connecting.\nPlease wait..."), std::string(di->T("Channel:")) + std::string(" ") + std::string(di->T(channel)));
|
||||
|
||||
// Only Join mode is showing Cancel button on KHBBS and the button will fade out before the dialog is fading out, probably because it's already connected thus can't be canceled anymore
|
||||
if (request.netAction == NETCONF_JOIN_ADHOC)
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
void DisplayMessage(const std::string &text1, const std::string &text2a = "", const std::string &text2b = "", const std::string &text3a = "", const std::string &text3b = "", bool hasYesNo = false, bool hasOK = false);
|
||||
void DisplayMessage(std::string_view text1, std::string_view text2a = "", std::string_view text2b = "", std::string_view text3a = "", std::string_view text3b = "", bool hasYesNo = false, bool hasOK = false);
|
||||
void DrawBanner();
|
||||
void DrawIndicator();
|
||||
|
||||
|
@ -100,7 +100,7 @@ void PSPNpSigninDialog::DrawLogo() {
|
||||
PPGeDrawImage(416, 22, 64.0f, 64.0f, 1, 10, 1, 10, 64, 64, FadedImageStyle());
|
||||
}
|
||||
|
||||
void PSPNpSigninDialog::DisplayMessage(const std::string &text1, const std::string &text2a, const std::string &text2b, const std::string &text3a, const std::string &text3b, bool hasYesNo, bool hasOK) {
|
||||
void PSPNpSigninDialog::DisplayMessage(std::string_view text1, std::string_view text2a, std::string_view text2b, std::string_view text3a, std::string_view text3b, bool hasYesNo, bool hasOK) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
|
||||
@ -108,12 +108,12 @@ void PSPNpSigninDialog::DisplayMessage(const std::string &text1, const std::stri
|
||||
PPGeStyle messageStyleRight = FadedStyle(PPGeAlign::BOX_RIGHT, FONT_SCALE);
|
||||
PPGeStyle messageStyleLeft = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
|
||||
|
||||
std::string text2 = text2a + " " + text2b;
|
||||
std::string text3 = text3a + " " + text3b;
|
||||
std::string text2 = std::string(text2a) + " " + std::string(text2b);
|
||||
std::string text3 = std::string(text3a) + " " + std::string(text3b);
|
||||
|
||||
// Without the scrollbar, we have 350 total pixels.
|
||||
float WRAP_WIDTH = 300.0f;
|
||||
if (UTF8StringNonASCIICount(text1.c_str()) >= (int)text1.size() / 4) {
|
||||
if (UTF8StringNonASCIICount(text1) >= (int)text1.size() / 4) {
|
||||
WRAP_WIDTH = 336.0f;
|
||||
if (text1.size() > 12) {
|
||||
messageStyle.scale = 0.6f;
|
||||
@ -121,13 +121,13 @@ void PSPNpSigninDialog::DisplayMessage(const std::string &text1, const std::stri
|
||||
}
|
||||
|
||||
float totalHeight1 = 0.0f;
|
||||
PPGeMeasureText(nullptr, &totalHeight1, text1.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight1, text1, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
float totalHeight2 = 0.0f;
|
||||
if (text2 != " ")
|
||||
PPGeMeasureText(nullptr, &totalHeight2, text2.c_str(), FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight2, text2, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
float totalHeight3 = 0.0f;
|
||||
if (text3 != " ")
|
||||
PPGeMeasureText(nullptr, &totalHeight3, text3.c_str(), FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &totalHeight3, text3, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
|
||||
float marginTop = 0.0f;
|
||||
if (text2 != " " || text3 != " ")
|
||||
marginTop = 11.0f;
|
||||
@ -180,23 +180,23 @@ void PSPNpSigninDialog::DisplayMessage(const std::string &text1, const std::stri
|
||||
}
|
||||
|
||||
PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2));
|
||||
PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
|
||||
PPGeDrawTextWrapped(text1, 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
|
||||
if (!text2a.empty()) {
|
||||
if (!text2b.empty())
|
||||
PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
PPGeDrawTextWrapped(text2a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
else
|
||||
PPGeDrawTextWrapped(text2a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
PPGeDrawTextWrapped(text2a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
}
|
||||
if (!text2b.empty())
|
||||
PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeDrawTextWrapped(text2b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
if (!text3a.empty()) {
|
||||
if (!text3b.empty())
|
||||
PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
PPGeDrawTextWrapped(text3a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
|
||||
else
|
||||
PPGeDrawTextWrapped(text3a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
PPGeDrawTextWrapped(text3a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
|
||||
}
|
||||
if (!text3b.empty())
|
||||
PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeDrawTextWrapped(text3b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
|
||||
PPGeScissorReset();
|
||||
|
||||
// Do we need a scrollbar?
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
void DisplayMessage(const std::string &text1, const std::string &text2a = "", const std::string &text2b = "", const std::string &text3a = "", const std::string &text3b = "", bool hasYesNo = false, bool hasOK = false);
|
||||
void DisplayMessage(std::string_view text1, std::string_view text2a = "", std::string_view text2b = "", std::string_view text3a = "", std::string_view text3b = "", bool hasYesNo = false, bool hasOK = false);
|
||||
void DrawBanner();
|
||||
void DrawIndicator();
|
||||
void DrawLogo();
|
||||
|
@ -44,7 +44,7 @@
|
||||
const static int OSK_INIT_DELAY_US = 300000;
|
||||
const static int OSK_SHUTDOWN_DELAY_US = 40000;
|
||||
|
||||
static std::map<std::string, std::pair<std::string, int>> languageMapping;
|
||||
static std::map<std::string, std::pair<std::string, int>, std::less<>> languageMapping;
|
||||
|
||||
const uint8_t numKeyCols[OSK_KEYBOARD_COUNT] = {12, 12, 13, 13, 12, 12, 12, 12, 12};
|
||||
const uint8_t numKeyRows[OSK_KEYBOARD_COUNT] = {4, 4, 6, 6, 5, 4, 4, 4, 4};
|
||||
|
@ -347,9 +347,8 @@ void PSPSaveDialog::DisplayBanner(int which)
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_VCENTER, 0.6f);
|
||||
textStyle.hasShadow = false;
|
||||
|
||||
const char *title;
|
||||
switch (which)
|
||||
{
|
||||
std::string_view title;
|
||||
switch (which) {
|
||||
case DB_SAVE:
|
||||
title = di->T("Save");
|
||||
break;
|
||||
@ -580,18 +579,18 @@ void PSPSaveDialog::DisplaySaveDataInfo2(bool showNewData) {
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 8, 200, textStyle);
|
||||
}
|
||||
|
||||
void PSPSaveDialog::DisplayMessage(const std::string &text, bool hasYesNo)
|
||||
void PSPSaveDialog::DisplayMessage(std::string_view text, bool hasYesNo)
|
||||
{
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
|
||||
|
||||
const float WRAP_WIDTH = 254.0f;
|
||||
float y = 136.0f, h;
|
||||
PPGeMeasureText(nullptr, &h, text.c_str(), FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
PPGeMeasureText(nullptr, &h, text, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
|
||||
float h2 = h / 2.0f;
|
||||
if (hasYesNo)
|
||||
{
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
const char *choiceText;
|
||||
std::string_view choiceText;
|
||||
float x, w;
|
||||
if (yesnoChoice == 1) {
|
||||
choiceText = di->T("Yes");
|
||||
@ -617,7 +616,7 @@ void PSPSaveDialog::DisplayMessage(const std::string &text, bool hasYesNo)
|
||||
yesnoChoice = 0;
|
||||
}
|
||||
}
|
||||
PPGeDrawTextWrapped(text.c_str(), 334.0f, y, WRAP_WIDTH, 0, textStyle);
|
||||
PPGeDrawTextWrapped(text, 334.0f, y, WRAP_WIDTH, 0, textStyle);
|
||||
float sy = 122.0f - h2, ey = 150.0f + h2;
|
||||
PPGeDrawRect(202.0f, sy, 466.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawRect(202.0f, ey, 466.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
@ -94,7 +94,7 @@ private:
|
||||
void DisplaySaveIcon(bool checkExists);
|
||||
void DisplaySaveDataInfo1();
|
||||
void DisplaySaveDataInfo2(bool showNewData = false);
|
||||
void DisplayMessage(const std::string &text, bool hasYesNo = false);
|
||||
void DisplayMessage(std::string_view text, bool hasYesNo = false);
|
||||
const std::string GetSelectedSaveDirName() const;
|
||||
|
||||
void JoinIOThread();
|
||||
|
@ -1334,7 +1334,7 @@ void sendChat(const std::string &chatString) {
|
||||
} else {
|
||||
std::lock_guard<std::mutex> guard(chatLogLock);
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
chatLog.push_back(n->T("You're in Offline Mode, go to lobby or online hall"));
|
||||
chatLog.push_back(std::string(n->T("You're in Offline Mode, go to lobby or online hall")));
|
||||
chatMessageGeneration++;
|
||||
}
|
||||
}
|
||||
@ -1385,7 +1385,7 @@ int friendFinder(){
|
||||
g_adhocServerIP.in.sin_addr.s_addr = INADDR_NONE;
|
||||
if (g_Config.bEnableWlan && !net::DNSResolve(g_Config.proAdhocServer, "", &resolved, err)) {
|
||||
ERROR_LOG(SCENET, "DNS Error Resolving %s\n", g_Config.proAdhocServer.c_str());
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, n->T("DNS Error Resolving ") + g_Config.proAdhocServer);
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, std::string(n->T("DNS Error Resolving ")) + g_Config.proAdhocServer);
|
||||
}
|
||||
if (resolved) {
|
||||
for (auto ptr = resolved; ptr != NULL; ptr = ptr->ai_next) {
|
||||
|
@ -147,13 +147,13 @@ size_t GetRichPresenceMessage(char *buffer, size_t bufSize) {
|
||||
return rc_client_get_rich_presence_message(g_rcClient, buffer, bufSize);
|
||||
}
|
||||
|
||||
bool WarnUserIfHardcoreModeActive(bool isSaveStateAction, const char *message) {
|
||||
bool WarnUserIfHardcoreModeActive(bool isSaveStateAction, std::string_view message) {
|
||||
if (!HardcoreModeActive() || (isSaveStateAction && g_Config.bAchievementsSaveStateInHardcoreMode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *showMessage = message;
|
||||
if (!message) {
|
||||
std::string_view showMessage = message;
|
||||
if (message.empty()) {
|
||||
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
|
||||
showMessage = ac->T("This feature is not available in Hardcore Mode");
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ bool HardcoreModeActive();
|
||||
// If no message is specified, a standard "This feature is not available in Hardcore Mode" message will be shown.
|
||||
// Also returns true if hardcore mode is active.
|
||||
// Specify isSaveAction so we can still permit saves (but not loads) in hardcore mode if that option is enabled.
|
||||
bool WarnUserIfHardcoreModeActive(bool isSaveStateAction, const char *message = nullptr);
|
||||
bool WarnUserIfHardcoreModeActive(bool isSaveStateAction, std::string_view message = "");
|
||||
|
||||
// Returns the length of the string. If (size_t)-1, there's no message.
|
||||
size_t GetRichPresenceMessage(char *buffer, size_t bufSize);
|
||||
|
@ -497,7 +497,7 @@ namespace SaveState
|
||||
if (detectSlot(UNDO_STATE_EXTENSION)) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
// Allow the number to be positioned where it makes sense.
|
||||
std::string undo = sy->T("undo %c");
|
||||
std::string undo(sy->T("undo %c"));
|
||||
return title + " (" + StringFromFormat(undo.c_str(), slotChar) + ")";
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ namespace SaveState
|
||||
|
||||
// The file can't be loaded - let's note that.
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
return filename.GetFilename() + " " + sy->T("(broken)");
|
||||
return filename.GetFilename() + " " + std::string(sy->T("(broken)"));
|
||||
}
|
||||
|
||||
std::string GenerateFullDiscId(const Path &gameFilename) {
|
||||
@ -581,14 +581,14 @@ namespace SaveState
|
||||
if (g_Config.bEnableStateUndo) {
|
||||
Path backup = GetSysDirectory(DIRECTORY_SAVESTATE) / LOAD_UNDO_NAME;
|
||||
|
||||
auto saveCallback = [=](Status status, const std::string &message, void *data) {
|
||||
auto saveCallback = [=](Status status, std::string_view message, void *data) {
|
||||
if (status != Status::FAILURE) {
|
||||
DeleteIfExists(backup);
|
||||
File::Rename(backup.WithExtraExtension(".tmp"), backup);
|
||||
g_Config.sStateLoadUndoGame = GenerateFullDiscId(gameFilename);
|
||||
g_Config.Save("Saving config for savestate last load undo");
|
||||
} else {
|
||||
ERROR_LOG(SAVESTATE, "Saving load undo state failed: %s", message.c_str());
|
||||
ERROR_LOG(SAVESTATE, "Saving load undo state failed: %.*s", (int)message.size(), message.data());
|
||||
}
|
||||
Load(fn, slot, callback, cbUserData);
|
||||
};
|
||||
@ -639,7 +639,7 @@ namespace SaveState
|
||||
Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION);
|
||||
if (!fn.empty()) {
|
||||
Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||
auto renameCallback = [=](Status status, const std::string &message, void *data) {
|
||||
auto renameCallback = [=](Status status, std::string_view message, void *data) {
|
||||
if (status != Status::FAILURE) {
|
||||
if (g_Config.bEnableStateUndo) {
|
||||
DeleteIfExists(fnUndo);
|
||||
@ -939,12 +939,8 @@ namespace SaveState
|
||||
std::string title;
|
||||
|
||||
auto sc = GetI18NCategory(I18NCat::SCREEN);
|
||||
const char *i18nLoadFailure = sc->T("Load savestate failed", "");
|
||||
const char *i18nSaveFailure = sc->T("Save State Failed", "");
|
||||
if (strlen(i18nLoadFailure) == 0)
|
||||
i18nLoadFailure = sc->T("Failed to load state");
|
||||
if (strlen(i18nSaveFailure) == 0)
|
||||
i18nSaveFailure = sc->T("Failed to save state");
|
||||
const char *i18nLoadFailure = sc->T_cstr("Failed to load state");
|
||||
const char *i18nSaveFailure = sc->T_cstr("Failed to save state");
|
||||
|
||||
std::string slot_prefix = op.slot >= 0 ? StringFromFormat("(%d) ", op.slot + 1) : "";
|
||||
std::string errorString;
|
||||
@ -997,7 +993,7 @@ namespace SaveState
|
||||
}
|
||||
result = CChunkFileReader::Save(op.filename, title, PPSSPP_GIT_VERSION, state);
|
||||
if (result == CChunkFileReader::ERROR_NONE) {
|
||||
callbackMessage = slot_prefix + sc->T("Saved State");
|
||||
callbackMessage = slot_prefix + std::string(sc->T("Saved State"));
|
||||
callbackResult = Status::SUCCESS;
|
||||
#ifndef MOBILE_DEVICE
|
||||
if (g_Config.bSaveLoadResetsAVdumping) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
@ -31,7 +32,7 @@ namespace SaveState
|
||||
WARNING,
|
||||
SUCCESS,
|
||||
};
|
||||
typedef std::function<void(Status status, const std::string &message, void *cbUserData)> Callback;
|
||||
typedef std::function<void(Status status, std::string_view message, void *cbUserData)> Callback;
|
||||
|
||||
static const int NUM_SLOTS = 5;
|
||||
static const char * const STATE_EXTENSION = "ppst";
|
||||
|
@ -413,7 +413,7 @@ bool GameManager::DetectTexturePackDest(struct zip *z, int iniIndex, Path &dest)
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameManager::SetInstallError(const std::string &err) {
|
||||
void GameManager::SetInstallError(std::string_view err) {
|
||||
installProgress_ = 0.0f;
|
||||
installError_ = err;
|
||||
InstallDone();
|
||||
|
@ -90,7 +90,7 @@ private:
|
||||
|
||||
bool ExtractFile(struct zip *z, int file_index, const Path &outFilename, size_t *bytesCopied, size_t allBytes);
|
||||
bool DetectTexturePackDest(struct zip *z, int iniIndex, Path &dest);
|
||||
void SetInstallError(const std::string &err);
|
||||
void SetInstallError(std::string_view err);
|
||||
|
||||
bool InstallInProgress() const { return installThread_.joinable(); }
|
||||
|
||||
|
@ -137,7 +137,7 @@ void PPGeSetDrawContext(Draw::DrawContext *draw) {
|
||||
}
|
||||
|
||||
// Overwrite the current text lines buffer so it can be drawn later.
|
||||
void PPGePrepareText(const char *text, float x, float y, PPGeAlign align, float scale, float lineHeightScale,
|
||||
void PPGePrepareText(std::string_view text, float x, float y, PPGeAlign align, float scale, float lineHeightScale,
|
||||
int WrapType = PPGE_LINE_NONE, int wrapWidth = 0);
|
||||
|
||||
// These functions must be called between PPGeBegin and PPGeEnd.
|
||||
@ -519,7 +519,7 @@ static const AtlasChar *PPGeGetChar(const AtlasFont &atlasfont, unsigned int cva
|
||||
}
|
||||
|
||||
// Break a single text string into mutiple lines.
|
||||
static AtlasTextMetrics BreakLines(const char *text, const AtlasFont &atlasfont, float x, float y,
|
||||
static AtlasTextMetrics BreakLines(std::string_view text, const AtlasFont &atlasfont, float x, float y,
|
||||
PPGeAlign align, float scale, float lineHeightScale, int wrapType, float wrapWidth, bool dryRun)
|
||||
{
|
||||
y += atlasfont.ascend * scale;
|
||||
@ -773,8 +773,7 @@ static std::string PPGeSanitizeText(std::string_view text) {
|
||||
return SanitizeUTF8(text);
|
||||
}
|
||||
|
||||
void PPGeMeasureText(float *w, float *h, const char *text, float scale, int WrapType, int wrapWidth) {
|
||||
_dbg_assert_(text);
|
||||
void PPGeMeasureText(float *w, float *h, std::string_view text, float scale, int WrapType, int wrapWidth) {
|
||||
std::string s = PPGeSanitizeText(text);
|
||||
|
||||
if (HasTextDrawer()) {
|
||||
@ -809,7 +808,7 @@ void PPGeMeasureText(float *w, float *h, const char *text, float scale, int Wrap
|
||||
if (h) *h = metrics.lineHeight * metrics.numLines;
|
||||
}
|
||||
|
||||
void PPGePrepareText(const char *text, float x, float y, PPGeAlign align, float scale, float lineHeightScale, int WrapType, int wrapWidth)
|
||||
void PPGePrepareText(std::string_view text, float x, float y, PPGeAlign align, float scale, float lineHeightScale, int WrapType, int wrapWidth)
|
||||
{
|
||||
const AtlasFont &atlasfont = g_ppge_atlas.fonts[0];
|
||||
if (!g_ppge_atlas.IsMetadataLoaded() || g_ppge_atlas.num_fonts < 1) {
|
||||
@ -1056,10 +1055,7 @@ static void PPGeDecimateTextImages(int age) {
|
||||
}
|
||||
}
|
||||
|
||||
void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
void PPGeDrawText(std::string_view text, float x, float y, const PPGeStyle &style) {
|
||||
std::string str = PPGeSanitizeText(text);
|
||||
if (str.empty()) {
|
||||
return;
|
||||
@ -1106,7 +1102,7 @@ static std::string_view CropLinesToCount(std::string_view s, int numLines) {
|
||||
return s.substr(0, len);
|
||||
}
|
||||
|
||||
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, const PPGeStyle &style) {
|
||||
void PPGeDrawTextWrapped(std::string_view text, float x, float y, float wrapWidth, float wrapHeight, const PPGeStyle &style) {
|
||||
std::string s = PPGeSanitizeText(text);
|
||||
if (wrapHeight != 0.0f) {
|
||||
s = StripTrailingWhite(s);
|
||||
@ -1155,7 +1151,7 @@ void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, fl
|
||||
|
||||
int sx = style.hasShadow ? 1 : 0;
|
||||
int sy = style.hasShadow ? 2 : 0;
|
||||
PPGePrepareText(s.c_str(), x + sx, y + sy, style.align, style.scale, style.scale, PPGE_LINE_USE_ELLIPSIS | PPGE_LINE_WRAP_WORD, wrapWidth);
|
||||
PPGePrepareText(s, x + sx, y + sy, style.align, style.scale, style.scale, PPGE_LINE_USE_ELLIPSIS | PPGE_LINE_WRAP_WORD, wrapWidth);
|
||||
|
||||
float scale = style.scale;
|
||||
float lineHeightScale = style.scale;
|
||||
@ -1176,12 +1172,12 @@ void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, fl
|
||||
// Try to keep the font as large as possible, so reduce the line height some.
|
||||
scale = reduced * 1.15f;
|
||||
lineHeightScale = reduced;
|
||||
PPGePrepareText(s.c_str(), x + sx, y + sy, style.align, scale, lineHeightScale, PPGE_LINE_USE_ELLIPSIS | PPGE_LINE_WRAP_WORD, wrapWidth);
|
||||
PPGePrepareText(s, x + sx, y + sy, style.align, scale, lineHeightScale, PPGE_LINE_USE_ELLIPSIS | PPGE_LINE_WRAP_WORD, wrapWidth);
|
||||
}
|
||||
if (style.hasShadow) {
|
||||
// This doesn't have the nicer shadow because it's so many verts.
|
||||
PPGeDrawCurrentText(style.shadowColor);
|
||||
PPGePrepareText(s.c_str(), x, y, style.align, scale, lineHeightScale, PPGE_LINE_USE_ELLIPSIS | PPGE_LINE_WRAP_WORD, wrapWidth);
|
||||
PPGePrepareText(s, x, y, style.align, scale, lineHeightScale, PPGE_LINE_USE_ELLIPSIS | PPGE_LINE_WRAP_WORD, wrapWidth);
|
||||
}
|
||||
PPGeDrawCurrentText(style.color);
|
||||
}
|
||||
@ -1347,7 +1343,7 @@ void PPGeDisableTexture()
|
||||
|
||||
std::vector<PPGeImage *> PPGeImage::loadedTextures_;
|
||||
|
||||
PPGeImage::PPGeImage(const std::string &pspFilename)
|
||||
PPGeImage::PPGeImage(std::string_view pspFilename)
|
||||
: filename_(pspFilename) {
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
|
||||
@ -87,12 +88,12 @@ struct PPGeImageStyle {
|
||||
};
|
||||
|
||||
// Get the metrics of the bounding box of the text without changing the buffer or state.
|
||||
void PPGeMeasureText(float *w, float *h, const char *text, float scale, int WrapType = PPGE_LINE_NONE, int wrapWidth = 0);
|
||||
void PPGeMeasureText(float *w, float *h, std::string_view text, float scale, int WrapType = PPGE_LINE_NONE, int wrapWidth = 0);
|
||||
|
||||
// Draws some text using the one font we have.
|
||||
// Clears the text buffer when done.
|
||||
void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style);
|
||||
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, const PPGeStyle &style);
|
||||
void PPGeDrawText(std::string_view text, float x, float y, const PPGeStyle &style);
|
||||
void PPGeDrawTextWrapped(std::string_view text, float x, float y, float wrapWidth, float wrapHeight, const PPGeStyle &style);
|
||||
|
||||
// Draws a "4-patch" for button-like things that can be resized.
|
||||
void PPGeDraw4Patch(ImageID atlasImage, float x, float y, float w, float h, u32 color = 0xFFFFFFFF);
|
||||
@ -113,7 +114,7 @@ bool PPGeIsFontTextureAddress(u32 addr);
|
||||
|
||||
class PPGeImage {
|
||||
public:
|
||||
PPGeImage(const std::string &pspFilename);
|
||||
PPGeImage(std::string_view pspFilename);
|
||||
PPGeImage(u32 pngPointer, size_t pngSize);
|
||||
~PPGeImage();
|
||||
|
||||
|
@ -257,7 +257,7 @@ void RemoveUnknownPostShaders(std::vector<std::string> *names) {
|
||||
}
|
||||
}
|
||||
|
||||
const ShaderInfo *GetPostShaderInfo(const std::string &name) {
|
||||
const ShaderInfo *GetPostShaderInfo(std::string_view name) {
|
||||
for (size_t i = 0; i < shaderInfo.size(); i++) {
|
||||
if (shaderInfo[i].section == name)
|
||||
return &shaderInfo[i];
|
||||
@ -310,7 +310,7 @@ const std::vector<ShaderInfo> &GetAllPostShaderInfo() {
|
||||
return shaderInfo;
|
||||
}
|
||||
|
||||
const TextureShaderInfo *GetTextureShaderInfo(const std::string &name) {
|
||||
const TextureShaderInfo *GetTextureShaderInfo(std::string_view name) {
|
||||
for (auto &info : textureShaderInfo) {
|
||||
if (info.section == name) {
|
||||
return &info;
|
||||
|
@ -106,13 +106,13 @@ struct TextureShaderInfo {
|
||||
|
||||
void ReloadAllPostShaderInfo(Draw::DrawContext *draw);
|
||||
|
||||
const ShaderInfo *GetPostShaderInfo(const std::string &name);
|
||||
const ShaderInfo *GetPostShaderInfo(std::string_view name);
|
||||
std::vector<const ShaderInfo *> GetPostShaderChain(const std::string &name);
|
||||
std::vector<const ShaderInfo *> GetFullPostShadersChain(const std::vector<std::string> &names);
|
||||
bool PostShaderChainRequires60FPS(const std::vector<const ShaderInfo *> &chain);
|
||||
const std::vector<ShaderInfo> &GetAllPostShaderInfo();
|
||||
|
||||
const TextureShaderInfo *GetTextureShaderInfo(const std::string &name);
|
||||
const TextureShaderInfo *GetTextureShaderInfo(std::string_view name);
|
||||
const std::vector<TextureShaderInfo> &GetAllTextureShaderInfo();
|
||||
void RemoveUnknownPostShaders(std::vector<std::string> *names);
|
||||
|
||||
|
@ -99,7 +99,7 @@ void TextureReplacer::NotifyConfigChanged() {
|
||||
// Somewhat crude message, re-using translation strings.
|
||||
auto d = GetI18NCategory(I18NCat::DEVELOPER);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, std::string(d->T("Save new textures")) + ": " + di->T("Enabled"), 2.0f);
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, std::string(d->T("Save new textures")) + ": " + std::string(di->T("Enabled")), 2.0f);
|
||||
}
|
||||
|
||||
if (!replaceEnabled_ && wasReplaceEnabled) {
|
||||
|
@ -419,7 +419,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
}
|
||||
}
|
||||
|
||||
void System_Toast(const char *text) {}
|
||||
void System_Toast(std::string_view text) {}
|
||||
|
||||
void System_AskForPermission(SystemPermission permission) {}
|
||||
PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; }
|
||||
|
@ -149,7 +149,7 @@ void MainWindow::openmsAct()
|
||||
QDesktopServices::openUrl(QUrl(memorystick));
|
||||
}
|
||||
|
||||
void SaveStateActionFinished(SaveState::Status status, const std::string &message, void *userdata)
|
||||
static void SaveStateActionFinished(SaveState::Status status, std::string_view message, void *userdata)
|
||||
{
|
||||
// TODO: Improve messaging?
|
||||
if (status == SaveState::Status::FAILURE)
|
||||
|
@ -70,11 +70,11 @@ void OSXOpenURL(const char *url) {
|
||||
}
|
||||
|
||||
-(NSString *)localizedString: (const char *)key category: (I18NCat)cat {
|
||||
return @(T(cat, key));
|
||||
return @(T_cstr(cat, key));
|
||||
}
|
||||
|
||||
-(NSString *)localizedMenuString: (const char *)key {
|
||||
std::string processed = UnescapeMenuString(T(I18NCat::DESKTOPUI, key), nullptr);
|
||||
std::string processed = UnescapeMenuString(T_cstr(I18NCat::DESKTOPUI, key), nullptr);
|
||||
return @(processed.c_str());
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ void OSXOpenURL(const char *url) {
|
||||
|
||||
-(NSMenu *)makeFileSubmenu {
|
||||
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T_cstr(key), nil).c_str())
|
||||
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle:DESKTOPUI_LOCALIZED("File")];
|
||||
NSMenuItem *openWithSystemFolderBrowserItem = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Load") action:@selector(openSystemFileBrowser) keyEquivalent:@"o"];
|
||||
@ -274,10 +274,10 @@ void OSXOpenURL(const char *url) {
|
||||
std::shared_ptr<I18NCategory> graphicsLocalization = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
|
||||
|
||||
NSMenu *parent = [[NSMenu alloc] initWithTitle:@(mainSettingsLocalization->T("Graphics"))];
|
||||
NSMenu *parent = [[NSMenu alloc] initWithTitle:@(mainSettingsLocalization->T_cstr("Graphics"))];
|
||||
NSMenu *backendsMenu = [[NSMenu alloc] init];
|
||||
#define GRAPHICS_LOCALIZED(key) @(graphicsLocalization->T(key))
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())
|
||||
#define GRAPHICS_LOCALIZED(key) @(graphicsLocalization->T_cstr(key))
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T_cstr(key), nil).c_str())
|
||||
|
||||
NSMenuItem *gpuBackendItem = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Backend") action:nil keyEquivalent:@""];
|
||||
|
||||
@ -333,7 +333,7 @@ void OSXOpenURL(const char *url) {
|
||||
|
||||
-(NSMenu *)makeEmulationMenu {
|
||||
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T_cstr(key), nil).c_str())
|
||||
|
||||
NSMenu *parent = [[NSMenu alloc] initWithTitle:DESKTOPUI_LOCALIZED("Emulation")];
|
||||
|
||||
@ -353,7 +353,7 @@ void OSXOpenURL(const char *url) {
|
||||
-(NSMenu *)makeDebugMenu {
|
||||
std::shared_ptr<I18NCategory> sysInfoLocalization = GetI18NCategory(I18NCat::SYSINFO);
|
||||
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T_cstr(key), nil).c_str())
|
||||
|
||||
NSMenu *parent = [[NSMenu alloc] initWithTitle:DESKTOPUI_LOCALIZED("Debugging")];
|
||||
|
||||
@ -434,9 +434,9 @@ void OSXOpenURL(const char *url) {
|
||||
|
||||
-(void)breakAction: (NSMenuItem *)item {
|
||||
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())
|
||||
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T_cstr(key), nil).c_str())
|
||||
std::shared_ptr<I18NCategory> developerUILocalization = GetI18NCategory(I18NCat::DEVELOPER);
|
||||
#define DEVELOPERUI_LOCALIZED(key) @(developerUILocalization->T(key))
|
||||
#define DEVELOPERUI_LOCALIZED(key) @(developerUILocalization->T_cstr(key))
|
||||
if (Core_IsStepping()) {
|
||||
Core_EnableStepping(false, "ui.break");
|
||||
item.title = DESKTOPUI_LOCALIZED("Break");
|
||||
@ -620,7 +620,7 @@ TOGGLE_METHOD(FullScreen, g_Config.bFullScreen, System_MakeRequest(SystemRequest
|
||||
|
||||
-(void)addOpenRecentlyItem {
|
||||
std::shared_ptr<I18NCategory> mainmenuLocalization = GetI18NCategory(I18NCat::MAINMENU);
|
||||
#define MAINMENU_LOCALIZED(key) @(mainmenuLocalization->T(key))
|
||||
#define MAINMENU_LOCALIZED(key) @(mainmenuLocalization->T_cstr(key))
|
||||
|
||||
std::vector<std::string> recentIsos = g_Config.RecentIsos();
|
||||
NSMenuItem *openRecent = [[NSMenuItem alloc] initWithTitle:MAINMENU_LOCALIZED("Recent") action:nil keyEquivalent:@""];
|
||||
|
@ -206,13 +206,12 @@ static void UpdateScreenDPI(SDL_Window *window) {
|
||||
|
||||
// Simple implementations of System functions
|
||||
|
||||
|
||||
void System_Toast(const char *text) {
|
||||
void System_Toast(std::string_view text) {
|
||||
#ifdef _WIN32
|
||||
std::wstring str = ConvertUTF8ToWString(text);
|
||||
MessageBox(0, str.c_str(), L"Toast!", MB_ICONINFORMATION);
|
||||
#else
|
||||
puts(text);
|
||||
printf("%*.s", (int)text.length(), text.data());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
std::string pspButtonName = KeyMap::GetPspButtonName(this->pspBtn_);
|
||||
|
||||
parent->Add(new TextView(std::string(km->T("Map a new key for")) + " " + mc->T(pspButtonName), new LinearLayoutParams(Margins(10, 0))));
|
||||
parent->Add(new TextView(std::string(km->T("Map a new key for")) + " " + std::string(mc->T(pspButtonName)), new LinearLayoutParams(Margins(10, 0))));
|
||||
parent->Add(new TextView(std::string(mapping_.ToVisualString()), new LinearLayoutParams(Margins(10, 0))));
|
||||
|
||||
comboMappingsNotEnabled_ = parent->Add(new NoticeView(NoticeLevel::WARN, km->T("Combo mappings are not enabled"), "", new LinearLayoutParams(Margins(10, 0))));
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
class ButtonShapeScreen : public PopupScreen {
|
||||
public:
|
||||
ButtonShapeScreen(std::string title, int *setting) : PopupScreen(title), setting_(setting) {}
|
||||
ButtonShapeScreen(std::string_view title, int *setting) : PopupScreen(title), setting_(setting) {}
|
||||
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override {
|
||||
using namespace UI;
|
||||
@ -63,7 +63,7 @@ private:
|
||||
|
||||
class ButtonIconScreen : public PopupScreen {
|
||||
public:
|
||||
ButtonIconScreen(std::string title, int *setting) : PopupScreen(title), setting_(setting) {}
|
||||
ButtonIconScreen(std::string_view title, int *setting) : PopupScreen(title), setting_(setting) {}
|
||||
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override {
|
||||
using namespace UI;
|
||||
|
@ -99,7 +99,7 @@ void CwCheatScreen::CreateViews() {
|
||||
|
||||
std::string root = GetSysDirectory(DIRECTORY_MEMSTICK_ROOT).ToString();
|
||||
|
||||
std::string title = StringFromFormat(cw->T("Import from %s"), "PSP/Cheats/cheat.db");
|
||||
std::string title = StringFromFormat(cw->T_cstr("Import from %s"), "PSP/Cheats/cheat.db");
|
||||
|
||||
leftColumn->Add(new Choice(title.c_str()))->OnClick.Handle(this, &CwCheatScreen::OnImportCheat);
|
||||
leftColumn->Add(new Choice(mm->T("Browse"), ImageID("I_FOLDER_OPEN")))->OnClick.Handle(this, &CwCheatScreen::OnImportBrowse);
|
||||
|
@ -277,7 +277,7 @@ void DrawCrashDump(UIContext *ctx, const Path &gamePath) {
|
||||
if (ctx->Draw()->GetFontAtlas()->getFont(ubuntu24))
|
||||
ctx->BindFontTexture();
|
||||
ctx->Draw()->SetFontScale(1.1f, 1.1f);
|
||||
ctx->Draw()->DrawTextShadow(ubuntu24, sy->T("Game crashed"), x, y, 0xFFFFFFFF);
|
||||
ctx->Draw()->DrawTextShadow(ubuntu24, sy->T_cstr("Game crashed"), x, y, 0xFFFFFFFF);
|
||||
|
||||
char statbuf[4096];
|
||||
char versionString[256];
|
||||
|
@ -360,7 +360,7 @@ UI::EventReturn LogConfigScreen::OnLogLevel(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
LogLevelScreen::LogLevelScreen(const std::string &title) : ListPopupScreen(title) {
|
||||
LogLevelScreen::LogLevelScreen(std::string_view title) : ListPopupScreen(title) {
|
||||
int NUMLOGLEVEL = 6;
|
||||
std::vector<std::string> list;
|
||||
for (int i = 0; i < NUMLOGLEVEL; ++i) {
|
||||
@ -521,7 +521,7 @@ void SystemInfoScreen::CreateTabs() {
|
||||
}
|
||||
|
||||
int totalThreads = cpu_info.num_cores * cpu_info.logical_cpu_count;
|
||||
std::string cores = StringFromFormat(si->T("%d (%d per core, %d cores)"), totalThreads, cpu_info.logical_cpu_count, cpu_info.num_cores);
|
||||
std::string cores = StringFromFormat(si->T_cstr("%d (%d per core, %d cores)"), totalThreads, cpu_info.logical_cpu_count, cpu_info.num_cores);
|
||||
cpuInfo->Add(new InfoItem(si->T("Threads"), cores));
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
cpuInfo->Add(new InfoItem(si->T("JIT available"), System_GetPropertyBool(SYSPROP_CAN_JIT) ? di->T("Yes") : di->T("No")));
|
||||
@ -532,7 +532,7 @@ void SystemInfoScreen::CreateTabs() {
|
||||
DrawContext *draw = screenManager()->getDrawContext();
|
||||
|
||||
const std::string apiNameKey = draw->GetInfoString(InfoField::APINAME);
|
||||
const char *apiName = gr->T(apiNameKey);
|
||||
std::string_view apiName = gr->T(apiNameKey);
|
||||
gpuInfo->Add(new InfoItem(si->T("3D API"), apiName));
|
||||
|
||||
// TODO: Not really vendor, on most APIs it's a device name (GL calls it vendor though).
|
||||
@ -585,26 +585,26 @@ void SystemInfoScreen::CreateTabs() {
|
||||
gpuInfo->Add(new InfoItem(si->T("Compressed texture formats"), texCompressionFormats));
|
||||
|
||||
CollapsibleSection *osInformation = deviceSpecs->Add(new CollapsibleSection(si->T("OS Information")));
|
||||
osInformation->Add(new InfoItem(si->T("Memory Page Size"), StringFromFormat(si->T("%d bytes"), GetMemoryProtectPageSize())));
|
||||
osInformation->Add(new InfoItem(si->T("Memory Page Size"), StringFromFormat(si->T_cstr("%d bytes"), GetMemoryProtectPageSize())));
|
||||
osInformation->Add(new InfoItem(si->T("RW/RX exclusive"), PlatformIsWXExclusive() ? di->T("Active") : di->T("Inactive")));
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
osInformation->Add(new InfoItem(si->T("Sustained perf mode"), System_GetPropertyBool(SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE) ? di->T("Supported") : di->T("Unsupported")));
|
||||
#endif
|
||||
|
||||
const char *build = si->T("Release");
|
||||
std::string_view build = si->T("Release");
|
||||
#ifdef _DEBUG
|
||||
build = si->T("Debug");
|
||||
#endif
|
||||
osInformation->Add(new InfoItem(si->T("PPSSPP build"), build));
|
||||
|
||||
CollapsibleSection *audioInformation = deviceSpecs->Add(new CollapsibleSection(si->T("Audio Information")));
|
||||
audioInformation->Add(new InfoItem(si->T("Sample rate"), StringFromFormat(si->T("%d Hz"), System_GetPropertyInt(SYSPROP_AUDIO_SAMPLE_RATE))));
|
||||
audioInformation->Add(new InfoItem(si->T("Sample rate"), StringFromFormat(si->T_cstr("%d Hz"), System_GetPropertyInt(SYSPROP_AUDIO_SAMPLE_RATE))));
|
||||
int framesPerBuffer = System_GetPropertyInt(SYSPROP_AUDIO_FRAMES_PER_BUFFER);
|
||||
if (framesPerBuffer > 0) {
|
||||
audioInformation->Add(new InfoItem(si->T("Frames per buffer"), StringFromFormat("%d", framesPerBuffer)));
|
||||
}
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
audioInformation->Add(new InfoItem(si->T("Optimal sample rate"), StringFromFormat(si->T("%d Hz"), System_GetPropertyInt(SYSPROP_AUDIO_OPTIMAL_SAMPLE_RATE))));
|
||||
audioInformation->Add(new InfoItem(si->T("Optimal sample rate"), StringFromFormat(si->T_cstr("%d Hz"), System_GetPropertyInt(SYSPROP_AUDIO_OPTIMAL_SAMPLE_RATE))));
|
||||
audioInformation->Add(new InfoItem(si->T("Optimal frames per buffer"), StringFromFormat("%d", System_GetPropertyInt(SYSPROP_AUDIO_OPTIMAL_FRAMES_PER_BUFFER))));
|
||||
#endif
|
||||
|
||||
@ -617,7 +617,7 @@ void SystemInfoScreen::CreateTabs() {
|
||||
displayInfo->Add(new InfoItem(si->T("UI resolution"), StringFromFormat("%dx%d (%s: %0.2f)",
|
||||
g_display.dp_xres,
|
||||
g_display.dp_yres,
|
||||
si->T("DPI"),
|
||||
si->T_cstr("DPI"),
|
||||
g_display.dpi)));
|
||||
displayInfo->Add(new InfoItem(si->T("Pixel resolution"), StringFromFormat("%dx%d",
|
||||
g_display.pixel_xres,
|
||||
@ -634,7 +634,7 @@ void SystemInfoScreen::CreateTabs() {
|
||||
}
|
||||
|
||||
// Don't show on Windows, since it's always treated as 60 there.
|
||||
displayInfo->Add(new InfoItem(si->T("Refresh rate"), StringFromFormat(si->T("%0.2f Hz"), (float)System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE))));
|
||||
displayInfo->Add(new InfoItem(si->T("Refresh rate"), StringFromFormat(si->T_cstr("%0.2f Hz"), (float)System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE))));
|
||||
std::string presentModes;
|
||||
if (draw->GetDeviceCaps().presentModesSupported & Draw::PresentMode::FIFO) presentModes += "FIFO, ";
|
||||
if (draw->GetDeviceCaps().presentModesSupported & Draw::PresentMode::IMMEDIATE) presentModes += "IMMEDIATE, ";
|
||||
@ -811,7 +811,7 @@ void SystemInfoScreen::CreateTabs() {
|
||||
colorFormats->Add(new TextView(format, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
|
||||
}
|
||||
|
||||
CollapsibleSection *enabledExtensions = gpuExtensions->Add(new CollapsibleSection(std::string(si->T("Vulkan Extensions")) + " (" + di->T("Enabled") + ")"));
|
||||
CollapsibleSection *enabledExtensions = gpuExtensions->Add(new CollapsibleSection(std::string(si->T("Vulkan Extensions")) + " (" + std::string(di->T("Enabled")) + ")"));
|
||||
std::vector<std::string> extensions = draw->GetExtensionList(true, true);
|
||||
std::sort(extensions.begin(), extensions.end());
|
||||
for (auto &extension : extensions) {
|
||||
@ -1644,7 +1644,7 @@ void RecreateActivity() {
|
||||
INFO_LOG(SYSTEM, "Got back from recreate");
|
||||
} else {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
System_Toast(gr->T("Must Restart", "You must restart PPSSPP for this change to take effect"));
|
||||
System_Toast(gr->T_cstr("Must Restart", "You must restart PPSSPP for this change to take effect"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ private:
|
||||
|
||||
class LogLevelScreen : public UI::ListPopupScreen {
|
||||
public:
|
||||
LogLevelScreen(const std::string &title);
|
||||
LogLevelScreen(std::string_view title);
|
||||
|
||||
const char *tag() const override { return "LogLevel"; }
|
||||
|
||||
@ -119,7 +119,7 @@ protected:
|
||||
|
||||
class AddressPromptScreen : public PopupScreen {
|
||||
public:
|
||||
AddressPromptScreen(const std::string &title) : PopupScreen(title, "OK", "Cancel"), addrView_(NULL), addr_(0) {
|
||||
AddressPromptScreen(std::string_view title) : PopupScreen(title, "OK", "Cancel"), addrView_(NULL), addr_(0) {
|
||||
memset(buttons_, 0, sizeof(buttons_));
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ void Discord::Update() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void Discord::SetPresenceGame(const char *gameTitle) {
|
||||
void Discord::SetPresenceGame(std::string_view gameTitle) {
|
||||
if (!IsEnabled())
|
||||
return;
|
||||
|
||||
@ -102,11 +102,10 @@ void Discord::SetPresenceGame(const char *gameTitle) {
|
||||
|
||||
#ifdef ENABLE_DISCORD
|
||||
auto sc = GetI18NCategory(I18NCat::SCREEN);
|
||||
|
||||
std::string title(gameTitle);
|
||||
DiscordRichPresence discordPresence{};
|
||||
discordPresence.state = gameTitle;
|
||||
std::string details = sc->T("Playing");
|
||||
discordPresence.details = details.c_str();
|
||||
discordPresence.state = title.c_str();
|
||||
discordPresence.details = sc->T_cstr("Playing");
|
||||
discordPresence.startTimestamp = time(0);
|
||||
discordPresence.largeImageText = "PPSSPP is the best PlayStation Portable emulator around!";
|
||||
#ifdef GOLD
|
||||
@ -130,7 +129,7 @@ void Discord::SetPresenceMenu() {
|
||||
auto sc = GetI18NCategory(I18NCat::SCREEN);
|
||||
|
||||
DiscordRichPresence discordPresence{};
|
||||
discordPresence.state = sc->T("In menu");
|
||||
discordPresence.state = sc->T_cstr("In menu");
|
||||
discordPresence.details = "";
|
||||
discordPresence.startTimestamp = time(0);
|
||||
discordPresence.largeImageText = "PPSSPP is the best PlayStation Portable emulator around!";
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
// Simple wrapper around the Discord api.
|
||||
|
||||
// All platforms should call it, but we only actually take action on
|
||||
@ -13,7 +15,7 @@ public:
|
||||
void Update(); // Call every frame or at least regularly. Will initialize if necessary.
|
||||
void Shutdown();
|
||||
|
||||
void SetPresenceGame(const char *gameTitle);
|
||||
void SetPresenceGame(std::string_view gameTitle);
|
||||
void SetPresenceMenu();
|
||||
void ClearPresence();
|
||||
|
||||
|
@ -162,19 +162,19 @@ UI::EventReturn DisplayLayoutScreen::OnPostProcShaderChange(UI::EventParams &e)
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
static std::string PostShaderTranslateName(const char *value) {
|
||||
if (!strcmp(value, "Off")) {
|
||||
static std::string PostShaderTranslateName(std::string_view value) {
|
||||
if (value == "Off") {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
// Off is a legacy fake item (gonna migrate off it later).
|
||||
return gr->T("Add postprocessing shader");
|
||||
return std::string(gr->T("Add postprocessing shader"));
|
||||
}
|
||||
|
||||
const ShaderInfo *info = GetPostShaderInfo(value);
|
||||
if (info) {
|
||||
auto ps = GetI18NCategory(I18NCat::POSTSHADERS);
|
||||
return ps->T(value, info ? info->name.c_str() : value);
|
||||
return std::string(ps->T(value, info ? info->name : value));
|
||||
} else {
|
||||
return value;
|
||||
return std::string(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -475,7 +475,7 @@ void PostProcScreen::CreateViews() {
|
||||
continue;
|
||||
if (shaders_[i].section == selectedName)
|
||||
selected = (int)indexTranslation_.size();
|
||||
items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str()));
|
||||
items.push_back(std::string(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str())));
|
||||
indexTranslation_.push_back(i);
|
||||
}
|
||||
adaptor_ = UI::StringVectorListAdaptor(items, selected);
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
|
||||
class PostProcScreen : public UI::ListPopupScreen {
|
||||
public:
|
||||
PostProcScreen(const std::string &title, int id, bool showStereoShaders)
|
||||
PostProcScreen(std::string_view title, int id, bool showStereoShaders)
|
||||
: ListPopupScreen(title), id_(id), showStereoShaders_(showStereoShaders) { }
|
||||
|
||||
void CreateViews() override;
|
||||
|
@ -300,7 +300,7 @@ void EmuScreen::bootGame(const Path &filename) {
|
||||
// Reset views in case controls are in a different place.
|
||||
RecreateViews();
|
||||
|
||||
g_Discord.SetPresenceGame(info->GetTitle().c_str());
|
||||
g_Discord.SetPresenceGame(info->GetTitle());
|
||||
} else {
|
||||
g_Discord.SetPresenceGame(sc->T("Untitled PSP game"));
|
||||
}
|
||||
@ -429,7 +429,7 @@ void EmuScreen::bootComplete() {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
// Stereo rendering is experimental, so let's notify the user it's being used.
|
||||
// Carefully reuse translations for this rare warning.
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, std::string(gr->T("Stereo rendering")) + ": " + di->T("Enabled"));
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, std::string(gr->T("Stereo rendering")) + ": " + std::string(di->T("Enabled")));
|
||||
}
|
||||
|
||||
saveStateSlot_ = SaveState::GetCurrentSlot();
|
||||
@ -486,13 +486,13 @@ void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
|
||||
SetExtraAssertInfo(extraAssertInfoStr_.c_str());
|
||||
}
|
||||
|
||||
static void AfterSaveStateAction(SaveState::Status status, const std::string &message, void *) {
|
||||
static void AfterSaveStateAction(SaveState::Status status, std::string_view message, void *) {
|
||||
if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) {
|
||||
g_OSD.Show(status == SaveState::Status::SUCCESS ? OSDType::MESSAGE_SUCCESS : OSDType::MESSAGE_ERROR, message, status == SaveState::Status::SUCCESS ? 2.0 : 5.0);
|
||||
}
|
||||
}
|
||||
|
||||
static void AfterStateBoot(SaveState::Status status, const std::string &message, void *ignored) {
|
||||
static void AfterStateBoot(SaveState::Status status, std::string_view message, void *ignored) {
|
||||
AfterSaveStateAction(status, message, ignored);
|
||||
Core_EnableStepping(false);
|
||||
System_Notify(SystemNotification::DISASSEMBLY);
|
||||
|
@ -301,23 +301,23 @@ ScreenRenderFlags GameScreen::render(ScreenRenderMode mode) {
|
||||
if (info->Ready(GameInfoFlags::SIZE | GameInfoFlags::UNCOMPRESSED_SIZE)) {
|
||||
char temp[256];
|
||||
if (tvGameSize_) {
|
||||
snprintf(temp, sizeof(temp), "%s: %s", ga->T("Game"), NiceSizeFormat(info->gameSizeOnDisk).c_str());
|
||||
snprintf(temp, sizeof(temp), "%s: %s", ga->T_cstr("Game"), NiceSizeFormat(info->gameSizeOnDisk).c_str());
|
||||
if (info->gameSizeUncompressed != info->gameSizeOnDisk) {
|
||||
size_t len = strlen(temp);
|
||||
snprintf(temp + len, sizeof(temp) - len, " (%s: %s)", ga->T("Uncompressed"), NiceSizeFormat(info->gameSizeUncompressed).c_str());
|
||||
snprintf(temp + len, sizeof(temp) - len, " (%s: %s)", ga->T_cstr("Uncompressed"), NiceSizeFormat(info->gameSizeUncompressed).c_str());
|
||||
}
|
||||
tvGameSize_->SetText(temp);
|
||||
}
|
||||
if (tvSaveDataSize_) {
|
||||
if (info->saveDataSize > 0) {
|
||||
snprintf(temp, sizeof(temp), "%s: %s", ga->T("SaveData"), NiceSizeFormat(info->saveDataSize).c_str());
|
||||
snprintf(temp, sizeof(temp), "%s: %s", ga->T_cstr("SaveData"), NiceSizeFormat(info->saveDataSize).c_str());
|
||||
tvSaveDataSize_->SetText(temp);
|
||||
} else {
|
||||
tvSaveDataSize_->SetVisibility(UI::V_GONE);
|
||||
}
|
||||
}
|
||||
if (info->installDataSize > 0 && tvInstallDataSize_) {
|
||||
snprintf(temp, sizeof(temp), "%s: %1.2f %s", ga->T("InstallData"), (float) (info->installDataSize) / 1024.f / 1024.f, ga->T("MB"));
|
||||
snprintf(temp, sizeof(temp), "%s: %1.2f %s", ga->T_cstr("InstallData"), (float) (info->installDataSize) / 1024.f / 1024.f, ga->T_cstr("MB"));
|
||||
tvInstallDataSize_->SetText(temp);
|
||||
tvInstallDataSize_->SetVisibility(UI::V_VISIBLE);
|
||||
}
|
||||
@ -543,7 +543,7 @@ UI::EventReturn GameScreen::OnRemoveFromRecent(UI::EventParams &e) {
|
||||
|
||||
class SetBackgroundPopupScreen : public PopupScreen {
|
||||
public:
|
||||
SetBackgroundPopupScreen(const std::string &title, const Path &gamePath)
|
||||
SetBackgroundPopupScreen(std::string_view title, const Path &gamePath)
|
||||
: PopupScreen(title), gamePath_(gamePath) {
|
||||
timeStart_ = time_now_d();
|
||||
}
|
||||
|
@ -159,13 +159,13 @@ static bool UsingHardwareTextureScaling() {
|
||||
return g_Config.bTexHardwareScaling && GetGPUBackend() == GPUBackend::VULKAN && !g_Config.bSoftwareRendering;
|
||||
}
|
||||
|
||||
static std::string TextureTranslateName(const char *value) {
|
||||
static std::string TextureTranslateName(std::string_view value) {
|
||||
const TextureShaderInfo *info = GetTextureShaderInfo(value);
|
||||
if (info) {
|
||||
auto ts = GetI18NCategory(I18NCat::TEXTURESHADERS);
|
||||
return ts->T(value, info ? info->name.c_str() : value);
|
||||
return std::string(ts->T(value, info ? info->name.c_str() : value));
|
||||
} else {
|
||||
return value;
|
||||
return std::string(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,13 +206,13 @@ bool PathToVisualUsbPath(Path path, std::string &outPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string PostShaderTranslateName(const char *value) {
|
||||
static std::string PostShaderTranslateName(std::string_view value) {
|
||||
const ShaderInfo *info = GetPostShaderInfo(value);
|
||||
if (info) {
|
||||
auto ps = GetI18NCategory(I18NCat::POSTSHADERS);
|
||||
return ps->T(value, info ? info->name.c_str() : value);
|
||||
return std::string(ps->T(value, info ? info->name : value));
|
||||
} else {
|
||||
return value;
|
||||
return std::string(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) {
|
||||
#if defined(SDL)
|
||||
std::vector<std::string> audioDeviceList;
|
||||
SplitString(System_GetProperty(SYSPROP_AUDIO_DEVICE_LIST), '\0', audioDeviceList);
|
||||
audioDeviceList.insert(audioDeviceList.begin(), a->T("Auto"));
|
||||
audioDeviceList.insert(audioDeviceList.begin(), a->T_cstr("Auto"));
|
||||
PopupMultiChoiceDynamic *audioDevice = audioSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sAudioDevice, a->T("Device"), audioDeviceList, I18NCat::NONE, screenManager()));
|
||||
audioDevice->OnChoice.Handle(this, &GameSettingsScreen::OnAudioDevice);
|
||||
sdlAudio = true;
|
||||
@ -700,7 +700,7 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings)
|
||||
Choice *customizeTilt = controlsSettings->Add(new ChoiceWithCallbackValueDisplay(co->T("Tilt control setup"), []() -> std::string {
|
||||
auto co = GetI18NCategory(I18NCat::CONTROLS);
|
||||
if ((u32)g_Config.iTiltInputType < (u32)g_numTiltTypes) {
|
||||
return co->T(g_tiltTypes[g_Config.iTiltInputType]);
|
||||
return std::string(co->T(g_tiltTypes[g_Config.iTiltInputType]));
|
||||
}
|
||||
return "";
|
||||
}));
|
||||
@ -819,12 +819,12 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings)
|
||||
// Compound view just like the audio file choosers
|
||||
class MacAddressChooser : public UI::LinearLayout {
|
||||
public:
|
||||
MacAddressChooser(RequesterToken token, Path gamePath, std::string *value, const std::string &title, ScreenManager *screenManager, UI::LayoutParams *layoutParams = nullptr);
|
||||
MacAddressChooser(RequesterToken token, Path gamePath, std::string *value, std::string_view title, ScreenManager *screenManager, UI::LayoutParams *layoutParams = nullptr);
|
||||
};
|
||||
|
||||
static constexpr UI::Size ITEM_HEIGHT = 64.f;
|
||||
|
||||
MacAddressChooser::MacAddressChooser(RequesterToken token, Path gamePath_, std::string *value, const std::string &title, ScreenManager *screenManager, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams) {
|
||||
MacAddressChooser::MacAddressChooser(RequesterToken token, Path gamePath_, std::string *value, std::string_view title, ScreenManager *screenManager, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams) {
|
||||
using namespace UI;
|
||||
SetSpacing(5.0f);
|
||||
if (!layoutParams) {
|
||||
@ -846,9 +846,9 @@ MacAddressChooser::MacAddressChooser(RequesterToken token, Path gamePath_, std::
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
const char *confirmMessage = n->T("ChangeMacSaveConfirm", "Generate a new MAC address?");
|
||||
const char *warningMessage = n->T("ChangeMacSaveWarning", "Some games verify the MAC address when loading savedata, so this may break old saves.");
|
||||
std::string combined = g_Config.sMACAddress + "\n\n" + std::string(confirmMessage) + "\n\n" + warningMessage;
|
||||
std::string_view confirmMessage = n->T("ChangeMacSaveConfirm", "Generate a new MAC address?");
|
||||
std::string_view warningMessage = n->T("ChangeMacSaveWarning", "Some games verify the MAC address when loading savedata, so this may break old saves.");
|
||||
std::string combined = g_Config.sMACAddress + "\n\n" + std::string(confirmMessage) + "\n\n" + std::string(warningMessage);
|
||||
|
||||
auto confirmScreen = new PromptScreen(
|
||||
gamePath_,
|
||||
@ -1003,13 +1003,13 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
|
||||
|
||||
systemSettings->Add(new ItemHeader(sy->T("UI")));
|
||||
|
||||
auto langCodeToName = [](const char *value) -> std::string {
|
||||
auto langCodeToName = [](std::string_view value) -> std::string {
|
||||
auto &mapping = g_Config.GetLangValuesMapping();
|
||||
auto iter = mapping.find(value);
|
||||
if (iter != mapping.end()) {
|
||||
return iter->second.first;
|
||||
}
|
||||
return value;
|
||||
return std::string(value);
|
||||
};
|
||||
|
||||
systemSettings->Add(new ChoiceWithValueDisplay(&g_Config.sLanguageIni, sy->T("Language"), langCodeToName))->OnClick.Add([&](UI::EventParams &e) {
|
||||
@ -1285,7 +1285,8 @@ UI::EventReturn GameSettingsScreen::OnScreenRotation(UI::EventParams &e) {
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnAdhocGuides(UI::EventParams &e) {
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_LaunchUrl(LaunchUrlType::BROWSER_URL, n->T("MultiplayerHowToURL", "https://github.com/hrydgard/ppsspp/wiki/How-to-play-multiplayer-games-with-PPSSPP"));
|
||||
std::string url(n->T("MultiplayerHowToURL", "https://github.com/hrydgard/ppsspp/wiki/How-to-play-multiplayer-games-with-PPSSPP"));
|
||||
System_LaunchUrl(LaunchUrlType::BROWSER_URL, url.c_str());
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
@ -1927,7 +1928,7 @@ UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e)
|
||||
new PromptScreen(gamePath_, dev->T("RestoreGameDefaultSettings", "Are you sure you want to restore the game-specific settings back to the ppsspp defaults?\n"), di->T("OK"), di->T("Cancel"),
|
||||
std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, std::placeholders::_1)));
|
||||
} else {
|
||||
const char *title = sy->T("Restore Default Settings");
|
||||
std::string_view title = sy->T("Restore Default Settings");
|
||||
screenManager()->push(new RestoreSettingsScreen(title));
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
@ -1955,7 +1956,7 @@ UI::EventReturn DeveloperToolsScreen::OnOpenTexturesIniFile(UI::EventParams &e)
|
||||
} else {
|
||||
// Can't do much here, let's send a "toast" so the user sees that something happened.
|
||||
auto dev = GetI18NCategory(I18NCat::DEVELOPER);
|
||||
System_Toast((generatedFilename.ToVisualString() + ": " + dev->T("Texture ini file created")).c_str());
|
||||
System_Toast((generatedFilename.ToVisualString() + ": " + dev->T_cstr("Texture ini file created")).c_str());
|
||||
}
|
||||
|
||||
hasTexturesIni_ = HasIni::YES;
|
||||
@ -2318,7 +2319,7 @@ void GestureMappingScreen::CreateViews() {
|
||||
vert->Add(new PopupSliderChoiceFloat(&g_Config.fAnalogGestureSensibility, 0.01f, 5.0f, 1.0f, co->T("Sensitivity"), 0.01f, screenManager(), "x"))->SetEnabledPtr(&g_Config.bAnalogGesture);
|
||||
}
|
||||
|
||||
RestoreSettingsScreen::RestoreSettingsScreen(const char *title)
|
||||
RestoreSettingsScreen::RestoreSettingsScreen(std::string_view title)
|
||||
: PopupScreen(title, "OK", "Cancel") {}
|
||||
|
||||
void RestoreSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
@ -2329,7 +2330,7 @@ void RestoreSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
auto mm = GetI18NCategory(I18NCat::MAINMENU);
|
||||
auto dev = GetI18NCategory(I18NCat::DEVELOPER);
|
||||
|
||||
const char *text = dev->T(
|
||||
std::string_view text = dev->T(
|
||||
"RestoreDefaultSettings",
|
||||
"Restore these settings back to their defaults?\nYou can't undo this.\nPlease restart PPSSPP after restoring settings.");
|
||||
|
||||
|
@ -168,7 +168,7 @@ private:
|
||||
|
||||
class HostnameSelectScreen : public PopupScreen {
|
||||
public:
|
||||
HostnameSelectScreen(std::string *value, const std::string &title)
|
||||
HostnameSelectScreen(std::string *value, std::string_view title)
|
||||
: PopupScreen(title, "OK", "Cancel"), value_(value) {
|
||||
resolver_ = std::thread([](HostnameSelectScreen *thiz) {
|
||||
thiz->ResolverThread();
|
||||
@ -237,7 +237,7 @@ public:
|
||||
|
||||
class RestoreSettingsScreen : public PopupScreen {
|
||||
public:
|
||||
RestoreSettingsScreen(const char *title);
|
||||
RestoreSettingsScreen(std::string_view title);
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override;
|
||||
|
||||
const char *tag() const override { return "RestoreSettingsScreen"; }
|
||||
|
@ -86,7 +86,7 @@ GamepadView::GamepadView(const char *key, UI::LayoutParams *layoutParams) : UI::
|
||||
|
||||
std::string GamepadView::DescribeText() const {
|
||||
auto co = GetI18NCategory(I18NCat::CONTROLS);
|
||||
return co->T(key_);
|
||||
return std::string(co->T(key_));
|
||||
}
|
||||
|
||||
void MultiTouchButton::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
|
@ -54,7 +54,7 @@ void InstallZipScreen::CreateViews() {
|
||||
ZipFileContents contents = DetectZipFileContents(zipPath_, &zipInfo);
|
||||
|
||||
if (contents == ZipFileContents::ISO_FILE || contents == ZipFileContents::PSP_GAME_DIR) {
|
||||
std::string question = iz->T("Install game from ZIP file?");
|
||||
std::string_view question = iz->T("Install game from ZIP file?");
|
||||
leftColumn->Add(new TextView(question, ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
|
||||
leftColumn->Add(new TextView(shortFilename, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
|
||||
|
||||
@ -68,7 +68,7 @@ void InstallZipScreen::CreateViews() {
|
||||
|
||||
returnToHomebrew_ = true;
|
||||
} else if (contents == ZipFileContents::TEXTURE_PACK) {
|
||||
std::string question = iz->T("Install textures from ZIP file?");
|
||||
std::string_view question = iz->T("Install textures from ZIP file?");
|
||||
leftColumn->Add(new TextView(question, ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
|
||||
leftColumn->Add(new TextView(shortFilename, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
|
||||
|
||||
|
@ -12,7 +12,7 @@ enum class StickHistoryViewType {
|
||||
|
||||
class JoystickHistoryView : public UI::InertView {
|
||||
public:
|
||||
JoystickHistoryView(StickHistoryViewType type, std::string title, UI::LayoutParams *layoutParams = nullptr)
|
||||
JoystickHistoryView(StickHistoryViewType type, std::string_view title, UI::LayoutParams *layoutParams = nullptr)
|
||||
: UI::InertView(layoutParams), title_(title), type_(type) {}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
|
@ -467,7 +467,7 @@ void DirButton::Draw(UIContext &dc) {
|
||||
|
||||
dc.FillRect(style.background, bounds_);
|
||||
|
||||
const std::string text = GetText();
|
||||
std::string text(GetText());
|
||||
|
||||
ImageID image = ImageID("I_FOLDER");
|
||||
if (text == "..") {
|
||||
@ -509,7 +509,7 @@ void DirButton::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
GameBrowser::GameBrowser(int token, const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams)
|
||||
GameBrowser::GameBrowser(int token, const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string_view lastText, std::string_view lastLink, UI::LayoutParams *layoutParams)
|
||||
: LinearLayout(UI::ORIENT_VERTICAL, layoutParams), path_(path), gridStyle_(gridStyle), browseFlags_(browseFlags), lastText_(lastText), lastLink_(lastLink), screenManager_(screenManager), token_(token) {
|
||||
using namespace UI;
|
||||
path_.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
|
||||
@ -1306,7 +1306,7 @@ void MainScreen::CreateViews() {
|
||||
UI::Margins buttonMargins(0, 0);
|
||||
UI::Drawable solid(0xFFbd9939);
|
||||
upgradeBar_->SetBG(solid);
|
||||
upgradeBar_->Add(new TextView(u->T("New version of PPSSPP available") + std::string(": ") + g_Config.upgradeVersion, new LinearLayoutParams(1.0f, textMargins)));
|
||||
upgradeBar_->Add(new TextView(std::string(u->T("New version of PPSSPP available")) + std::string(": ") + g_Config.upgradeVersion, new LinearLayoutParams(1.0f, textMargins)));
|
||||
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(WINDOWS)
|
||||
upgradeBar_->Add(new Button(u->T("Download"), new LinearLayoutParams(buttonMargins)))->OnClick.Handle(this, &MainScreen::OnDownloadUpgrade);
|
||||
#else
|
||||
|
@ -44,7 +44,7 @@ bool LaunchFile(ScreenManager *screenManager, const Path &path);
|
||||
|
||||
class GameBrowser : public UI::LinearLayout {
|
||||
public:
|
||||
GameBrowser(int token, const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr);
|
||||
GameBrowser(int token, const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string_view lastText, std::string_view lastLink, UI::LayoutParams *layoutParams = nullptr);
|
||||
|
||||
UI::Event OnChoice;
|
||||
UI::Event OnHoldChoice;
|
||||
@ -191,7 +191,7 @@ private:
|
||||
|
||||
class GridSettingsScreen : public PopupScreen {
|
||||
public:
|
||||
GridSettingsScreen(std::string label) : PopupScreen(label) {}
|
||||
GridSettingsScreen(std::string_view label) : PopupScreen(label) {}
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override;
|
||||
UI::Event OnRecentChanged;
|
||||
|
||||
|
@ -223,7 +223,7 @@ void MemStickScreen::CreateViews() {
|
||||
AddExplanation(leftColumn, (MemStickScreen::Choice)choice_, extraView);
|
||||
}
|
||||
|
||||
std::string privateString = iz->T("Use App Private Data");
|
||||
std::string privateString(iz->T("Use App Private Data"));
|
||||
|
||||
if (initialSetup_) {
|
||||
privateString = StringFromFormat("%s (%s)", iz->T("Skip for now"), privateString.c_str());
|
||||
@ -236,7 +236,7 @@ void MemStickScreen::CreateViews() {
|
||||
|
||||
leftColumn->Add(new Spacer(new LinearLayoutParams(FILL_PARENT, 12.0f, 0.0f)));
|
||||
|
||||
const char *confirmButtonText = nullptr;
|
||||
std::string_view confirmButtonText = nullptr;
|
||||
ImageID confirmButtonImage = ImageID::invalid();
|
||||
switch (choice_) {
|
||||
case CHOICE_BROWSE_FOLDER:
|
||||
|
@ -507,11 +507,11 @@ void UIDialogScreenWithBackground::sendMessage(UIMessage message, const char *va
|
||||
HandleCommonMessages(message, value, screenManager(), this);
|
||||
}
|
||||
|
||||
PromptScreen::PromptScreen(const Path &gamePath, std::string message, std::string yesButtonText, std::string noButtonText, std::function<void(bool)> callback)
|
||||
PromptScreen::PromptScreen(const Path &gamePath, std::string_view message, std::string_view yesButtonText, std::string_view noButtonText, std::function<void(bool)> callback)
|
||||
: UIDialogScreenWithGameBackground(gamePath), message_(message), callback_(callback) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
yesButtonText_ = di->T(yesButtonText.c_str());
|
||||
noButtonText_ = di->T(noButtonText.c_str());
|
||||
yesButtonText_ = di->T(yesButtonText);
|
||||
noButtonText_ = di->T(noButtonText);
|
||||
}
|
||||
|
||||
void PromptScreen::CreateViews() {
|
||||
@ -557,7 +557,7 @@ void PromptScreen::TriggerFinish(DialogResult result) {
|
||||
UIDialogScreenWithBackground::TriggerFinish(result);
|
||||
}
|
||||
|
||||
TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupScreen(title) {}
|
||||
TextureShaderScreen::TextureShaderScreen(std::string_view title) : ListPopupScreen(title) {}
|
||||
|
||||
void TextureShaderScreen::CreateViews() {
|
||||
auto ps = GetI18NCategory(I18NCat::TEXTURESHADERS);
|
||||
@ -568,7 +568,7 @@ void TextureShaderScreen::CreateViews() {
|
||||
for (int i = 0; i < (int)shaders_.size(); i++) {
|
||||
if (shaders_[i].section == g_Config.sTextureShaderName)
|
||||
selected = i;
|
||||
items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str()));
|
||||
items.push_back(std::string(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str())));
|
||||
}
|
||||
adaptor_ = UI::StringVectorListAdaptor(items, selected);
|
||||
|
||||
@ -581,7 +581,7 @@ void TextureShaderScreen::OnCompleted(DialogResult result) {
|
||||
g_Config.sTextureShaderName = shaders_[listView_->GetSelected()].section;
|
||||
}
|
||||
|
||||
NewLanguageScreen::NewLanguageScreen(const std::string &title) : ListPopupScreen(title) {
|
||||
NewLanguageScreen::NewLanguageScreen(std::string_view title) : ListPopupScreen(title) {
|
||||
// Disable annoying encoding warning
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4566)
|
||||
@ -761,7 +761,7 @@ void LogoScreen::DrawForeground(UIContext &dc) {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
char temp[256];
|
||||
// Manually formatting UTF-8 is fun. \xXX doesn't work everywhere.
|
||||
snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5);
|
||||
snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T_cstr("created", "Created by"), 0xC3, 0xA5);
|
||||
if (System_GetPropertyBool(SYSPROP_APP_GOLD)) {
|
||||
dc.Draw()->DrawImage(ImageID("I_ICONGOLD"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
} else {
|
||||
@ -772,7 +772,7 @@ void LogoScreen::DrawForeground(UIContext &dc) {
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.DrawText(temp, bounds.centerX(), bounds.centerY() + 40, textColor, ALIGN_CENTER);
|
||||
dc.DrawText(cr->T("license", "Free Software under GPL 2.0+"), bounds.centerX(), bounds.centerY() + 70, textColor, ALIGN_CENTER);
|
||||
dc.DrawText(cr->T_cstr("license", "Free Software under GPL 2.0+"), bounds.centerX(), bounds.centerY() + 70, textColor, ALIGN_CENTER);
|
||||
|
||||
int ppsspp_org_y = bounds.h / 2 + 130;
|
||||
dc.DrawText("www.ppsspp.org", bounds.centerX(), ppsspp_org_y, textColor, ALIGN_CENTER);
|
||||
@ -785,7 +785,7 @@ void LogoScreen::DrawForeground(UIContext &dc) {
|
||||
// Add some emoji for testing.
|
||||
apiName += CodepointToUTF8(0x1F41B) + CodepointToUTF8(0x1F41C) + CodepointToUTF8(0x1F914);
|
||||
#endif
|
||||
dc.DrawText(gr->T(apiName), bounds.centerX(), ppsspp_org_y + 50, textColor, ALIGN_CENTER);
|
||||
dc.DrawText(gr->T_cstr(apiName.c_str()), bounds.centerX(), ppsspp_org_y + 50, textColor, ALIGN_CENTER);
|
||||
#endif
|
||||
|
||||
dc.Flush();
|
||||
@ -897,7 +897,7 @@ void CreditsScreen::DrawForeground(UIContext &dc) {
|
||||
specialthankssolarmystic += cr->T("testing");
|
||||
specialthankssolarmystic += ')';
|
||||
|
||||
const char *credits[] = {
|
||||
std::string_view credits[] = {
|
||||
System_GetPropertyBool(SYSPROP_APP_GOLD) ? "PPSSPP Gold" : "PPSSPP",
|
||||
"",
|
||||
cr->T("title", "A fast and portable PSP emulator"),
|
||||
@ -1029,13 +1029,15 @@ void CreditsScreen::DrawForeground(UIContext &dc) {
|
||||
float t = (float)(time_now_d() - startTime_) * 60.0;
|
||||
|
||||
float y = bounds.y2() - fmodf(t, (float)totalHeight);
|
||||
std::string line;
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
float alpha = linearInOut(y+32, 64, bounds.y2() - 192, 64);
|
||||
uint32_t textColor = colorAlpha(dc.theme->infoStyle.fgColor, alpha);
|
||||
|
||||
if (alpha > 0.0f) {
|
||||
dc.SetFontScale(ease(alpha), ease(alpha));
|
||||
dc.DrawText(credits[i], bounds.centerX(), y, textColor, ALIGN_HCENTER);
|
||||
line = credits[i];
|
||||
dc.DrawText(line.c_str(), bounds.centerX(), y, textColor, ALIGN_HCENTER);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
y += itemHeight;
|
||||
@ -1053,7 +1055,7 @@ SettingInfoMessage::SettingInfoMessage(int align, float cutOffY, UI::AnchorLayou
|
||||
Add(new UI::Spacer(10.0f));
|
||||
}
|
||||
|
||||
void SettingInfoMessage::Show(const std::string &text, const UI::View *refView) {
|
||||
void SettingInfoMessage::Show(std::string_view text, const UI::View *refView) {
|
||||
if (refView) {
|
||||
Bounds b = refView->GetBounds();
|
||||
const UI::AnchorLayoutParams *lp = GetLayoutParams()->As<UI::AnchorLayoutParams>();
|
||||
|
@ -87,7 +87,7 @@ protected:
|
||||
|
||||
class PromptScreen : public UIDialogScreenWithGameBackground {
|
||||
public:
|
||||
PromptScreen(const Path& gamePath, std::string message, std::string yesButtonText, std::string noButtonText,
|
||||
PromptScreen(const Path& gamePath, std::string_view message, std::string_view yesButtonText, std::string_view noButtonText,
|
||||
std::function<void(bool)> callback = &NoOpVoidBool);
|
||||
|
||||
void CreateViews() override;
|
||||
@ -108,7 +108,7 @@ private:
|
||||
|
||||
class NewLanguageScreen : public UI::ListPopupScreen {
|
||||
public:
|
||||
NewLanguageScreen(const std::string &title);
|
||||
NewLanguageScreen(std::string_view title);
|
||||
|
||||
const char *tag() const override { return "NewLanguage"; }
|
||||
|
||||
@ -120,7 +120,7 @@ private:
|
||||
|
||||
class TextureShaderScreen : public UI::ListPopupScreen {
|
||||
public:
|
||||
TextureShaderScreen(const std::string &title);
|
||||
TextureShaderScreen(std::string_view title);
|
||||
|
||||
void CreateViews() override;
|
||||
|
||||
@ -185,7 +185,7 @@ class SettingInfoMessage : public UI::LinearLayout {
|
||||
public:
|
||||
SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp);
|
||||
|
||||
void Show(const std::string &text, const UI::View *refView = nullptr);
|
||||
void Show(std::string_view text, const UI::View *refView = nullptr);
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string GetText() const;
|
||||
|
@ -733,7 +733,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
g_BackgroundAudio.SFX().LoadSamples();
|
||||
|
||||
if (!boot_filename.empty() && stateToLoad.Valid()) {
|
||||
SaveState::Load(stateToLoad, -1, [](SaveState::Status status, const std::string &message, void *) {
|
||||
SaveState::Load(stateToLoad, -1, [](SaveState::Status status, std::string_view message, void *) {
|
||||
if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) {
|
||||
g_OSD.Show(status == SaveState::Status::SUCCESS ? OSDType::MESSAGE_SUCCESS : OSDType::MESSAGE_ERROR,
|
||||
message, status == SaveState::Status::SUCCESS ? 2.0 : 5.0);
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "UI/DisplayLayoutScreen.h"
|
||||
#include "UI/RetroAchievementScreens.h"
|
||||
|
||||
static void AfterSaveStateAction(SaveState::Status status, const std::string &message, void *) {
|
||||
static void AfterSaveStateAction(SaveState::Status status, std::string_view message, void *) {
|
||||
if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) {
|
||||
g_OSD.Show(status == SaveState::Status::SUCCESS ? OSDType::MESSAGE_SUCCESS : OSDType::MESSAGE_ERROR,
|
||||
message, status == SaveState::Status::SUCCESS ? 2.0 : 5.0);
|
||||
@ -374,7 +374,7 @@ void GamePauseScreen::CreateViews() {
|
||||
}
|
||||
|
||||
// And tack on an explanation for why savestate options are not available.
|
||||
const char *notAvailable = ac->T("Save states not available in Hardcore Mode");
|
||||
std::string_view notAvailable = ac->T("Save states not available in Hardcore Mode");
|
||||
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, notAvailable, ""));
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ using namespace UI;
|
||||
|
||||
class RatingChoice : public LinearLayout {
|
||||
public:
|
||||
RatingChoice(const char *captionKey, int *value, LayoutParams *layoutParams = 0);
|
||||
RatingChoice(std::string_view captionKey, int *value, LayoutParams *layoutParams = 0);
|
||||
|
||||
RatingChoice *SetEnabledPtrs(bool *enabled);
|
||||
|
||||
@ -54,7 +54,7 @@ protected:
|
||||
virtual int TotalChoices() {
|
||||
return 3;
|
||||
}
|
||||
void AddChoice(int i, const std::string &title);
|
||||
void AddChoice(int i, std::string_view title);
|
||||
StickyChoice *GetChoice(int i) {
|
||||
return static_cast<StickyChoice *>(group_->GetViewByIndex(i));
|
||||
}
|
||||
@ -67,7 +67,7 @@ private:
|
||||
int *value_;
|
||||
};
|
||||
|
||||
RatingChoice::RatingChoice(const char *captionKey, int *value, LayoutParams *layoutParams)
|
||||
RatingChoice::RatingChoice(std::string_view captionKey, int *value, LayoutParams *layoutParams)
|
||||
: LinearLayout(ORIENT_VERTICAL, layoutParams), value_(value) {
|
||||
SetSpacing(0.0f);
|
||||
|
||||
@ -109,7 +109,7 @@ void RatingChoice::SetupChoices() {
|
||||
AddChoice(2, rp->T("Great"));
|
||||
}
|
||||
|
||||
void RatingChoice::AddChoice(int i, const std::string &title) {
|
||||
void RatingChoice::AddChoice(int i, std::string_view title) {
|
||||
auto c = group_->Add(new StickyChoice(title, ""));
|
||||
c->OnClick.Handle(this, &RatingChoice::OnChoiceClick);
|
||||
}
|
||||
@ -356,7 +356,7 @@ void ReportScreen::UpdateCRCInfo() {
|
||||
|
||||
void ReportScreen::UpdateOverallDescription() {
|
||||
auto rp = GetI18NCategory(I18NCat::REPORTING);
|
||||
const char *desc;
|
||||
std::string_view desc;
|
||||
uint32_t c = 0xFFFFFFFF;
|
||||
switch (overall_) {
|
||||
case ReportingOverallScore::PERFECT: desc = rp->T("Perfect Description", "Flawless emulation for the entire game - great!"); break;
|
||||
@ -486,7 +486,7 @@ void ReportFinishScreen::ShowSuggestions() {
|
||||
bool shownConfig = false;
|
||||
bool valid = false;
|
||||
for (const auto &item : suggestions) {
|
||||
const char *suggestion = nullptr;
|
||||
std::string_view suggestion = "";
|
||||
if (item == "Upgrade") {
|
||||
suggestion = rp->T("SuggestionUpgrade", "Upgrade to a newer PPSSPP build");
|
||||
} else if (item == "Downgrade") {
|
||||
@ -504,15 +504,15 @@ void ReportFinishScreen::ShowSuggestions() {
|
||||
// Ignore unknown configs, hopefully we recognized "Upgrade" at least.
|
||||
}
|
||||
|
||||
if (suggestion) {
|
||||
if (!suggestion.empty()) {
|
||||
valid = true;
|
||||
resultItems_->Add(new TextView(std::string(" - ") + suggestion, FLAG_WRAP_TEXT, false))->SetShadow(true);
|
||||
resultItems_->Add(new TextView(std::string(" - ") + std::string(suggestion), FLAG_WRAP_TEXT, false))->SetShadow(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
// No actual valid versions. Let's just say upgrade and hope the server's not broken.
|
||||
resultItems_->Add(new TextView(std::string(" - ") + rp->T("SuggestionUpgrade", "Upgrade to a newer PPSSPP build"), FLAG_WRAP_TEXT, false))->SetShadow(true);
|
||||
resultItems_->Add(new TextView(std::string(" - ") + rp->T_cstr("SuggestionUpgrade", "Upgrade to a newer PPSSPP build"), FLAG_WRAP_TEXT, false))->SetShadow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,14 @@ static inline const char *DeNull(const char *ptr) {
|
||||
// Compound view, creating a FileChooserChoice inside.
|
||||
class AudioFileChooser : public UI::LinearLayout {
|
||||
public:
|
||||
AudioFileChooser(RequesterToken token, std::string *value, const std::string &title, UI::UISound sound, UI::LayoutParams *layoutParams = nullptr);
|
||||
AudioFileChooser(RequesterToken token, std::string *value, std::string_view title, UI::UISound sound, UI::LayoutParams *layoutParams = nullptr);
|
||||
|
||||
UI::UISound sound_;
|
||||
};
|
||||
|
||||
static constexpr UI::Size ITEM_HEIGHT = 64.f;
|
||||
|
||||
AudioFileChooser::AudioFileChooser(RequesterToken token, std::string *value, const std::string &title, UI::UISound sound, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams), sound_(sound) {
|
||||
AudioFileChooser::AudioFileChooser(RequesterToken token, std::string *value, std::string_view title, UI::UISound sound, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams), sound_(sound) {
|
||||
using namespace UI;
|
||||
SetSpacing(2.0f);
|
||||
if (!layoutParams) {
|
||||
|
@ -332,7 +332,7 @@ void ProductView::CreateViews() {
|
||||
}
|
||||
|
||||
float size = entry_.size / (1024.f * 1024.f);
|
||||
Add(new TextView(StringFromFormat("%s: %.2f %s", st->T("Size"), size, st->T("MB"))));
|
||||
Add(new TextView(StringFromFormat("%s: %.2f %s", st->T_cstr("Size"), size, st->T_cstr("MB"))));
|
||||
}
|
||||
|
||||
void ProductView::Update() {
|
||||
@ -494,7 +494,7 @@ void StoreScreen::CreateViews() {
|
||||
if (connectionError_ || loading_) {
|
||||
auto st = GetI18NCategory(I18NCat::STORE);
|
||||
content = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f));
|
||||
content->Add(new TextView(loading_ ? std::string(st->T("Loading...")) : StringFromFormat("%s: %d", st->T("Connection Error"), resultCode_)));
|
||||
content->Add(new TextView(loading_ ? std::string(st->T("Loading...")) : StringFromFormat("%s: %d", st->T_cstr("Connection Error"), resultCode_)));
|
||||
if (!loading_) {
|
||||
content->Add(new Button(di->T("Retry")))->OnClick.Handle(this, &StoreScreen::OnRetry);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "Common/System/Display.h"
|
||||
#include "UI/TabbedDialogScreen.h"
|
||||
|
||||
UI::LinearLayout *TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag, const std::string &title, bool isSearch) {
|
||||
UI::LinearLayout *TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag, std::string_view title, bool isSearch) {
|
||||
using namespace UI;
|
||||
ViewGroup *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
scroll->SetTag(tag);
|
||||
|
@ -11,7 +11,7 @@ class TabbedUIDialogScreenWithGameBackground : public UIDialogScreenWithGameBack
|
||||
public:
|
||||
TabbedUIDialogScreenWithGameBackground(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
||||
|
||||
UI::LinearLayout *AddTab(const char *tag, const std::string &title, bool isSearch = false);
|
||||
UI::LinearLayout *AddTab(const char *tag, std::string_view title, bool isSearch = false);
|
||||
void CreateViews() override;
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ static const int leftColumnWidth = 140;
|
||||
|
||||
class CheckBoxChoice : public UI::Choice {
|
||||
public:
|
||||
CheckBoxChoice(const std::string &text, UI::CheckBox *checkbox, UI::LayoutParams *lp)
|
||||
CheckBoxChoice(std::string_view text, UI::CheckBox *checkbox, UI::LayoutParams *lp)
|
||||
: Choice(text, lp), checkbox_(checkbox) {
|
||||
OnClick.Handle(this, &CheckBoxChoice::HandleClick);
|
||||
}
|
||||
@ -113,11 +113,11 @@ void TouchControlVisibilityScreen::CreateViews() {
|
||||
char translated[256];
|
||||
int i = 0;
|
||||
if (sscanf(toggle.key.c_str(), "Custom %d", &i) == 1) {
|
||||
snprintf(translated, sizeof(translated), mc->T("Custom %d"), i);
|
||||
snprintf(translated, sizeof(translated), mc->T_cstr("Custom %d"), i);
|
||||
} else {
|
||||
truncate_cpy(translated, mc->T(toggle.key));
|
||||
truncate_cpy(translated, sizeof(translated), mc->T(toggle.key));
|
||||
}
|
||||
choice = new Choice(std::string(translated) + " (" + mc->T("tap to customize") + ")", "", false, new LinearLayoutParams(1.0f));
|
||||
choice = new Choice(std::string(translated) + " (" + std::string(mc->T("tap to customize")) + ")", "", false, new LinearLayoutParams(1.0f));
|
||||
choice->OnClick.Add(toggle.handle);
|
||||
} else if (toggle.img.isValid()) {
|
||||
choice = new CheckBoxChoice(toggle.img, checkbox, new LinearLayoutParams(1.0f));
|
||||
|
@ -402,7 +402,7 @@ float System_GetPropertyFloat(SystemProperty prop) {
|
||||
}
|
||||
}
|
||||
|
||||
void System_Toast(const char *str) {}
|
||||
void System_Toast(std::string_view str) {}
|
||||
|
||||
bool System_GetPropertyBool(SystemProperty prop) {
|
||||
switch (prop) {
|
||||
|
@ -188,7 +188,7 @@ void MainThreadFunc() {
|
||||
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
const char *defaultErrorAll = "PPSSPP failed to startup with any graphics backend. Try upgrading your graphics and other drivers.";
|
||||
const char *genericError = err->T("GenericAllStartupError", defaultErrorAll);
|
||||
std::string_view genericError = err->T("GenericAllStartupError", defaultErrorAll);
|
||||
std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error"));
|
||||
MessageBox(0, ConvertUTF8ToWString(genericError).c_str(), title.c_str(), MB_OK);
|
||||
|
||||
@ -220,7 +220,7 @@ void MainThreadFunc() {
|
||||
const char *defaultErrorVulkan = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to OpenGL?\n\nError message:";
|
||||
const char *defaultErrorOpenGL = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to DirectX 9?\n\nError message:";
|
||||
const char *defaultErrorDirect3D9 = "Failed initializing graphics. Try upgrading your graphics drivers and directx 9 runtime.\n\nWould you like to try switching to OpenGL?\n\nError message:";
|
||||
const char *genericError;
|
||||
std::string_view genericError;
|
||||
GPUBackend nextBackend = GPUBackend::DIRECT3D9;
|
||||
switch (g_Config.iGPUBackend) {
|
||||
case (int)GPUBackend::DIRECT3D9:
|
||||
@ -237,7 +237,7 @@ void MainThreadFunc() {
|
||||
genericError = err->T("GenericOpenGLError", defaultErrorOpenGL);
|
||||
break;
|
||||
}
|
||||
std::string full_error = StringFromFormat("%s\n\n%s", genericError, error_string.c_str());
|
||||
std::string full_error = StringFromFormat("%.*s\n\n%s", (int)genericError.size(), genericError.data(), error_string.c_str());
|
||||
std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error"));
|
||||
bool yes = IDYES == MessageBox(0, ConvertUTF8ToWString(full_error).c_str(), title.c_str(), MB_ICONERROR | MB_YESNO);
|
||||
ERROR_LOG(BOOT, "%s", full_error.c_str());
|
||||
|
@ -359,7 +359,7 @@ namespace MainWindow {
|
||||
});
|
||||
}
|
||||
|
||||
static void SaveStateActionFinished(SaveState::Status status, const std::string &message, void *userdata) {
|
||||
static void SaveStateActionFinished(SaveState::Status status, std::string_view message, void *userdata) {
|
||||
if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) {
|
||||
g_OSD.Show(status == SaveState::Status::SUCCESS ? OSDType::MESSAGE_SUCCESS : OSDType::MESSAGE_ERROR, message, status == SaveState::Status::SUCCESS ? 2.0 : 5.0);
|
||||
}
|
||||
|
@ -12,8 +12,7 @@
|
||||
#include <commdlg.h>
|
||||
#include <cderr.h>
|
||||
|
||||
namespace W32Util
|
||||
{
|
||||
namespace W32Util {
|
||||
std::string BrowseForFolder(HWND parent, std::string_view title, std::string_view initialPath) {
|
||||
std::wstring titleString = ConvertUTF8ToWString(title);
|
||||
return BrowseForFolder(parent, titleString.c_str(), initialPath);
|
||||
@ -224,11 +223,12 @@ HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathL
|
||||
return hres;
|
||||
}
|
||||
|
||||
bool CreateDesktopShortcut(const std::string &argumentPath, std::string gameTitle) {
|
||||
bool CreateDesktopShortcut(std::string_view argumentPath, std::string_view gameTitleStr) {
|
||||
// Get the desktop folder
|
||||
wchar_t *pathbuf = new wchar_t[4096];
|
||||
SHGetFolderPath(0, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, pathbuf);
|
||||
|
||||
std::string gameTitle(gameTitleStr);
|
||||
// Sanitize the game title for banned characters.
|
||||
const char bannedChars[] = "<>:\"/\\|?*";
|
||||
for (size_t i = 0; i < gameTitle.size(); i++) {
|
||||
@ -255,7 +255,7 @@ bool CreateDesktopShortcut(const std::string &argumentPath, std::string gameTitl
|
||||
|
||||
// Need to flip the slashes in the filename.
|
||||
|
||||
std::string sanitizedArgument = argumentPath;
|
||||
std::string sanitizedArgument(argumentPath);
|
||||
for (size_t i = 0; i < sanitizedArgument.size(); i++) {
|
||||
if (sanitizedArgument[i] == '/') {
|
||||
sanitizedArgument[i] = '\\';
|
||||
|
@ -5,21 +5,18 @@
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
namespace W32Util {
|
||||
namespace W32Util
|
||||
{
|
||||
// Can't make initialPath a string_view, need the null so might as well require it.
|
||||
std::string BrowseForFolder(HWND parent, std::string_view title, std::string_view initialPath);
|
||||
std::string BrowseForFolder(HWND parent, const wchar_t *title, std::string_view initialPath);
|
||||
bool BrowseForFileName (bool _bLoad, HWND _hParent, const wchar_t*_pTitle,
|
||||
const wchar_t *_pInitialFolder,const wchar_t *_pFilter,const wchar_t*_pExtension,
|
||||
std::string& _strFileName);
|
||||
std::vector<std::string> BrowseForFileNameMultiSelect(bool _bLoad, HWND _hParent, const wchar_t*_pTitle,
|
||||
const wchar_t*_pInitialFolder,const wchar_t*_pFilter,const wchar_t*_pExtension);
|
||||
|
||||
// Can't make initialPath a string_view, need the null so might as well require it.
|
||||
std::string BrowseForFolder(HWND parent, std::string_view title, std::string_view initialPath);
|
||||
std::string BrowseForFolder(HWND parent, const wchar_t *title, std::string_view initialPath);
|
||||
|
||||
bool BrowseForFileName(bool _bLoad, HWND _hParent,
|
||||
const wchar_t *_pTitle, const wchar_t *_pInitialFolder, const wchar_t *_pFilter, const wchar_t *_pExtension,
|
||||
std::string& _strFileName);
|
||||
|
||||
std::vector<std::string> BrowseForFileNameMultiSelect(bool _bLoad, HWND _hParent, const wchar_t *_pTitle,
|
||||
const wchar_t *_pInitialFolder, const wchar_t *_pFilter, const wchar_t *_pExtension);
|
||||
|
||||
std::string UserDocumentsPath();
|
||||
|
||||
bool CreateDesktopShortcut(const std::string &argumentPath, std::string gameTitle);
|
||||
std::string UserDocumentsPath();
|
||||
|
||||
bool CreateDesktopShortcut(std::string_view argumentPath, std::string_view gameTitle);
|
||||
} // namespace
|
||||
|
@ -626,7 +626,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
case SystemRequestType::GRAPHICS_BACKEND_FAILED_ALERT:
|
||||
{
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
const char *backendSwitchError = err->T("GenericBackendSwitchCrash", "PPSSPP crashed while starting. This usually means a graphics driver problem. Try upgrading your graphics drivers.\n\nGraphics backend has been switched:");
|
||||
std::string_view backendSwitchError = err->T("GenericBackendSwitchCrash", "PPSSPP crashed while starting. This usually means a graphics driver problem. Try upgrading your graphics drivers.\n\nGraphics backend has been switched:");
|
||||
std::wstring full_error = ConvertUTF8ToWString(StringFromFormat("%s %s", backendSwitchError, param1.c_str()));
|
||||
std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error"));
|
||||
MessageBox(MainWindow::GetHWND(), full_error.c_str(), title.c_str(), MB_OK);
|
||||
@ -664,7 +664,7 @@ void EnableCrashingOnCrashes() {
|
||||
FreeLibrary(kernel32);
|
||||
}
|
||||
|
||||
void System_Toast(const char *text) {
|
||||
void System_Toast(std::string_view text) {
|
||||
// Not-very-good implementation. Will normally not be used on Windows anyway.
|
||||
std::wstring str = ConvertUTF8ToWString(text);
|
||||
MessageBox(0, str.c_str(), L"Toast!", MB_ICONINFORMATION);
|
||||
|
@ -391,8 +391,8 @@ static void PushCommand(std::string cmd, std::string param) {
|
||||
}
|
||||
|
||||
// Android implementation of callbacks to the Java part of the app
|
||||
void System_Toast(const char *text) {
|
||||
PushCommand("toast", text);
|
||||
void System_Toast(std::string_view text) {
|
||||
PushCommand("toast", std::string(text));
|
||||
}
|
||||
|
||||
void System_ShowKeyboard() {
|
||||
|
@ -1142,7 +1142,6 @@ Failed to save state = Failed to save state
|
||||
fixed = السرعة: الجانبي
|
||||
GLToolsWarning = WARNING: GLTools detected, may cause problems.
|
||||
In menu = In menu
|
||||
Load savestate failed = Load savestate failed
|
||||
Loaded State = الحالة تم تحميلها
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1154,7 +1153,6 @@ Playing = جاري اللعب
|
||||
PressESC = إضغط خروج للدخول علي قائمة التوقف المؤقت.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = فشل في حفظ الحالة!
|
||||
Saved State = حُفظت الحالة
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Failed to save state
|
||||
fixed = Speed: alternate
|
||||
GLToolsWarning = WARNING: GLTools detected, may cause problems.
|
||||
In menu = In menu
|
||||
Load savestate failed = Load savestate failed
|
||||
Loaded State = State loaded
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1146,7 +1145,6 @@ Playing = Playing
|
||||
PressESC = Press ESC to open the pause menu.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = Failed to save state!
|
||||
Saved State = State saved
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Failed to save state
|
||||
fixed = Speed: alternate
|
||||
GLToolsWarning = WARNING: GLTools detected, may cause problems.
|
||||
In menu = In menu
|
||||
Load savestate failed = Load savestate failed
|
||||
Loaded State = Състояние заредено
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1146,7 +1145,6 @@ Playing = Playing
|
||||
PressESC = Натиснете ESC за да отворите pause menu-то.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = Неуспех при запис на състоянието!
|
||||
Saved State = Състояние запазено
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Error en desar l'estat.
|
||||
fixed = Velocitat: alternativa
|
||||
GLToolsWarning = AVÍS: "GLTools" detectat, pot causar problemes.
|
||||
In menu = Al menú
|
||||
Load savestate failed = Error en carregar l'estat desat.
|
||||
Loaded State = Estat carregat.
|
||||
Loaded. Game may refuse to save over different savedata. = Carregat. El joc pot no guardar sobre dades diferents.
|
||||
Loaded. Game may refuse to save over newer savedata. = Carregat. El joc pot no guardar sobre dades més actuals.
|
||||
@ -1146,7 +1145,6 @@ Playing = Reproduint...
|
||||
PressESC = Prem Esc per obrir el menú de pausa.
|
||||
replaceTextures_false = Les textures no seran reemplaçades.
|
||||
replaceTextures_true = Reemplaçament de textures activat.
|
||||
Save State Failed = Error en desar l'estat.
|
||||
Saved State = Estat desat.
|
||||
saveNewTextures_false = Desat de textures desactivat.
|
||||
saveNewTextures_true = Les textures seran desades al disc.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Uložení stavu selhalo
|
||||
fixed = Rychlost: alternativní
|
||||
GLToolsWarning = VAROVÁNÍ: Zjištěny GLTools, můžou způsobovat problémy
|
||||
In menu = In menu
|
||||
Load savestate failed = Načtení uloženého stavu selhalo
|
||||
Loaded State = Stav načten
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1146,7 +1145,6 @@ Playing = Playing
|
||||
PressESC = Stiskněte ESC k otevření nabídky při pozastavení.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = Nepodařilo se uložit stav!
|
||||
Saved State = Stav uložen
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Kunne ikke gemme tilstand
|
||||
fixed = Hastighed: fast
|
||||
GLToolsWarning = ADVARSEL: GLTools detekteret, kan give problemer
|
||||
In menu = In menu
|
||||
Load savestate failed = Hentning af spil-status fejlede
|
||||
Loaded State = Indlæste status
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1146,7 +1145,6 @@ Playing = Playing
|
||||
PressESC = Tryk ESC for at åbne pause menu.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = Kunne ikke gemme status!
|
||||
Saved State = Gemte status
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Speichern des Standes fehlgeschlagen
|
||||
fixed = Geschwindigkeit: Fest
|
||||
GLToolsWarning = WARNUNG: GLTools erkannt, dies kann zu Problemen führen.
|
||||
In menu = Im Menü
|
||||
Load savestate failed = Laden des Speicherstandes fehlgeschlagen
|
||||
Loaded State = Spielstand geladen
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1146,7 +1145,6 @@ Playing = Spiele
|
||||
PressESC = Drücke ESC um das Pausemenü zu öffnen.
|
||||
replaceTextures_false = Texturen werden nicht länger ersetzt.
|
||||
replaceTextures_true = Texturersetzung ist aktiviert.
|
||||
Save State Failed = Erstellung des Spielstands fehlgeschlagen!
|
||||
Saved State = Spielstand gespeichert
|
||||
saveNewTextures_false = Speichern von Texturen wurde deaktiviert.
|
||||
saveNewTextures_true = Texturen werden nun im Speicher abgelegt.
|
||||
|
@ -1134,7 +1134,6 @@ Failed to save state = Failed to save state
|
||||
fixed = Lassinna: sembarang
|
||||
GLToolsWarning = WARNING: GLTools detected, may cause problems.
|
||||
In menu = In menu
|
||||
Load savestate failed = Load savestate failed
|
||||
Loaded State = Tibukka'mi loadna
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata.
|
||||
@ -1146,7 +1145,6 @@ Playing = Playing
|
||||
PressESC = Pissi'ki' ESC ta melako menu.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = Gagal i mangnganna mane!
|
||||
Saved State = Tiannami Savena
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
@ -1158,7 +1158,6 @@ Failed to save state = Failed to save state
|
||||
fixed = Speed: alternate
|
||||
GLToolsWarning = WARNING: GLTools detected, may cause problems.
|
||||
In menu = In menu
|
||||
Load savestate failed = Load savestate failed
|
||||
Loaded State = State loaded
|
||||
Loaded. Save in game, restart, and load for less bugs. = Loaded. Save in game, restart, and load for less bugs.
|
||||
Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata.
|
||||
@ -1170,7 +1169,6 @@ Playing = Playing
|
||||
PressESC = Press ESC to open the pause menu.
|
||||
replaceTextures_false = Textures no longer are being replaced.
|
||||
replaceTextures_true = Texture replacement is enabled.
|
||||
Save State Failed = Failed to save state!
|
||||
Saved State = State saved
|
||||
saveNewTextures_false = Texture saving was disabled.
|
||||
saveNewTextures_true = Textures will now be saved to your storage.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user