diff --git a/Common/System/Request.h b/Common/System/Request.h index c860ad132b..8bfeba4efa 100644 --- a/Common/System/Request.h +++ b/Common/System/Request.h @@ -11,7 +11,7 @@ class Path; -typedef std::function RequestCallback; +typedef std::function RequestCallback; typedef std::function RequestFailedCallback; typedef int RequesterToken; diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 39173541b8..4e059df9fe 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -793,7 +793,7 @@ void SliderFloatPopupScreen::OnCompleted(DialogResult result) { void AskForInput(ScreenManager *screenManager, RequesterToken token, UI::View *sourceView, std::string_view title, std::function callback) { // Choose method depending on platform capabilities. if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { - System_InputBoxGetString(token, title, "", false, [callback](const std::string &enteredValue, int) { + System_InputBoxGetString(token, title, "", false, [callback](std::string_view enteredValue, int) { callback(SanitizeString(StripSpaces(enteredValue), StringRestriction::None, 0, 0), true); }); return; @@ -825,7 +825,7 @@ void PopupTextInputChoice::HandleClick(EventParams &e) { // Choose method depending on platform capabilities. if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { - System_InputBoxGetString(token_, text_, *value_, passwordMasking_, [this](const std::string &enteredValue, int) { + System_InputBoxGetString(token_, text_, *value_, passwordMasking_, [this](std::string_view enteredValue, int) { *value_ = SanitizeString(StripSpaces(enteredValue), restriction_, minLen_, maxLen_); EventParams params{}; params.v = this; @@ -1120,7 +1120,7 @@ std::string ChoiceWithValueDisplay::ValueText(bool *shadow) const { FileChooserChoice::FileChooserChoice(RequesterToken token, std::string *value, std::string_view text, BrowseFileType fileType, LayoutParams *layoutParams) : AbstractChoiceWithValueDisplay(text, layoutParams), value_(value) { OnClick.Add([=](UI::EventParams &) { - System_BrowseForFile(token, text_, fileType, [=](const std::string &returnValue, int) { + System_BrowseForFile(token, text_, fileType, [=](std::string_view returnValue, int) { if (*value_ != returnValue) { *value = returnValue; UI::EventParams e{}; @@ -1144,7 +1144,7 @@ std::string FileChooserChoice::ValueText(bool *shadow) const { 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) { + System_BrowseForFolder(token_, text_, Path(*value), [=](std::string_view returnValue, int) { if (*value_ != returnValue) { *value = returnValue; UI::EventParams e{}; diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index bdd0e86645..f179eb7e52 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -810,7 +810,7 @@ int PSPOskDialog::NativeKeyboard() { // There's already ConvertUCS2ToUTF8 in this file. Should we use that instead of the global ones? System_InputBoxGetString(NON_EPHEMERAL_TOKEN, ::ConvertUCS2ToUTF8(titleText), ::ConvertUCS2ToUTF8(defaultText), false, - [this](const std::string &value, int) { + [this](std::string_view value, int) { // Success callback std::lock_guard guard(nativeMutex_); if (nativeStatus_ != PSPOskNativeStatus::WAITING) { diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 17101c5996..8189abec88 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1305,7 +1305,7 @@ void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count) { if (count != NULL) (*count)++; } -void sendChat(const std::string &chatString) { +void sendChat(std::string_view chatString) { SceNetAdhocctlChatPacketC2S chat{}; chat.base.opcode = OPCODE_CHAT; //TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected @@ -1313,7 +1313,7 @@ void sendChat(const std::string &chatString) { // Send Chat to Server if (!chatString.empty()) { //maximum char allowed is 64 character for compability with original server (pro.coldbird.net) - std::string message = chatString.substr(0, 60); // 64 return chat variable corrupted is it out of memory? + std::string message(chatString.substr(0, 60)); // 64 return chat variable corrupted is it out of memory? strcpy(chat.message, message.c_str()); //Send Chat Messages if (IsSocketReady((int)metasocket, false, true) > 0) { @@ -1330,7 +1330,7 @@ void sendChat(const std::string &chatString) { std::lock_guard guard(chatLogLock); auto n = GetI18NCategory(I18NCat::NETWORKING); chatLog.push_back(std::string(n->T("You're in Offline Mode, go to lobby or online hall"))); - INFO_LOG(Log::sceNet, "Offline. Would have sent: %s", chatString.c_str()); + INFO_LOG(Log::sceNet, "Offline. Would have sent: %.*s", STR_VIEW(chatString)); chatMessageGeneration++; } } diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index 657feff4d9..4ca28ea360 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -883,7 +883,7 @@ void addFriend(SceNetAdhocctlConnectPacketS2C * packet); * Send chat or get that * @param std::string ChatString */ -void sendChat(const std::string &chatString); +void sendChat(std::string_view chatString); std::vector getChatLog(); int GetChatChangeID(); int GetChatMessageCount(); diff --git a/UI/AdhocServerScreen.cpp b/UI/AdhocServerScreen.cpp index 6132d4d8a9..9324423131 100644 --- a/UI/AdhocServerScreen.cpp +++ b/UI/AdhocServerScreen.cpp @@ -861,7 +861,7 @@ void AskToEditCurrentServer(int requestToken, ScreenManager *screenManager) { // Choose method depending on platform capabilities. if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { - System_InputBoxGetString(requestToken, n->T("Ad hoc server address"), g_Config.sProAdhocServer, false, [](const std::string &enteredValue, int) { + System_InputBoxGetString(requestToken, n->T("Ad hoc server address"), g_Config.sProAdhocServer, false, [](std::string_view enteredValue, int) { EditServerName(enteredValue); }); return; diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 6b086ed561..ba7ccc0be2 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -114,7 +114,7 @@ void ChatMenu::OnAskForChatMessage(UI::EventParams &e) { using namespace UI; if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { - System_InputBoxGetString(token_, n->T("Chat"), "", false, [](const std::string &value, int) { + System_InputBoxGetString(token_, n->T("Chat"), "", false, [](std::string_view value, int) { sendChat(value); }); } else { @@ -183,7 +183,7 @@ void ChatMenu::Update() { // Could remove the fullscreen check here, it works now. auto n = GetI18NCategory(I18NCat::NETWORKING); if (promptInput_ && g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen) { - System_InputBoxGetString(token_, n->T("Chat"), n->T("Chat Here"), false, [](const std::string &value, int) { + System_InputBoxGetString(token_, n->T("Chat"), n->T("Chat Here"), false, [](std::string_view value, int) { sendChat(value); }); promptInput_ = false; diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 73d83e1841..3bf8234b41 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -437,7 +437,7 @@ void CwCheatScreen::ImportAndReport(const Path &cheatFile) { } void CwCheatScreen::OnImportBrowse(UI::EventParams ¶ms) { - System_BrowseForFile(GetRequesterToken(), "Open cheat DB file", BrowseFileType::DB, [&](const std::string &value, int) { + System_BrowseForFile(GetRequesterToken(), "Open cheat DB file", BrowseFileType::DB, [this](std::string_view value, int) { if (value.empty()) { return; } diff --git a/UI/DeveloperToolsScreen.cpp b/UI/DeveloperToolsScreen.cpp index ebcc716741..15118232e8 100644 --- a/UI/DeveloperToolsScreen.cpp +++ b/UI/DeveloperToolsScreen.cpp @@ -758,8 +758,8 @@ void DeveloperToolsScreen::OnMIPSTracerPathChanged(UI::EventParams &e) { dev->T("Select the log file"), "trace.txt", BrowseFileType::ANY, - [this](const std::string &value, int) { - mipsTracer.set_logging_path(value); + [this](std::string_view value, int) { + mipsTracer.set_logging_path(std::string(value)); MIPSTracerPath_ = value; MIPSTracerPath->SetRightText(MIPSTracerPath_); } diff --git a/UI/DriverManagerScreen.cpp b/UI/DriverManagerScreen.cpp index 7cb3c49bbc..11355b4676 100644 --- a/UI/DriverManagerScreen.cpp +++ b/UI/DriverManagerScreen.cpp @@ -215,14 +215,14 @@ void DriverManagerScreen::OnCustomDriverUninstall(UI::EventParams &e) { void DriverManagerScreen::OnCustomDriverInstall(UI::EventParams &e) { auto gr = GetI18NCategory(I18NCat::GRAPHICS); - System_BrowseForFile(GetRequesterToken(), gr->T("Install custom driver..."), BrowseFileType::ZIP, [this](const std::string &value, int) { + System_BrowseForFile(GetRequesterToken(), gr->T("Install custom driver..."), BrowseFileType::ZIP, [this](std::string_view value, int) { if (value.empty()) { return; } auto gr = GetI18NCategory(I18NCat::GRAPHICS); - Path zipPath = Path(value); + Path zipPath(value); // Don't bother checking the file extension. Can't always do that with files from Download (they have paths like content://com.android.providers.downloads.documents/document/msf%3A1000001095). // Though, it may be possible to get it in other ways. diff --git a/UI/GameBrowser.cpp b/UI/GameBrowser.cpp index 430fd8afe1..a74bfc5033 100644 --- a/UI/GameBrowser.cpp +++ b/UI/GameBrowser.cpp @@ -578,7 +578,7 @@ void GameBrowser::LastClick(UI::EventParams &e) { void GameBrowser::BrowseClick(UI::EventParams &e) { auto mm = GetI18NCategory(I18NCat::MAINMENU); - System_BrowseForFolder(token_, mm->T("Choose folder"), path_.GetPath(), [this](const std::string &filename, int) { + System_BrowseForFolder(token_, mm->T("Choose folder"), path_.GetPath(), [this](std::string_view filename, int) { SetPath(Path(filename)); }); } @@ -783,7 +783,7 @@ void GameBrowser::Refresh() { if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) { topBar->Add(new Choice(mm->T("Enter Path"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Add([=](UI::EventParams &) { auto mm = GetI18NCategory(I18NCat::MAINMENU); - System_InputBoxGetString(token_, mm->T("Enter Path"), path_.GetPath().ToString(), false, [=](const char *responseString, int responseValue) { + System_InputBoxGetString(token_, mm->T("Enter Path"), path_.GetPath().ToString(), false, [=](std::string_view responseString, int responseValue) { this->SetPath(Path(responseString)); }); }); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1d1891a169..60687ad9dd 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -105,8 +105,8 @@ extern AndroidAudioState *g_audioState; void SetMemStickDirDarwin(int requesterToken) { auto initialPath = g_Config.memStickDirectory; INFO_LOG(Log::System, "Current path: %s", initialPath.c_str()); - System_BrowseForFolder(requesterToken, "", initialPath, [](const std::string &value, int) { - INFO_LOG(Log::System, "Selected path: %s", value.c_str()); + System_BrowseForFolder(requesterToken, "", initialPath, [](std::string_view value, int) { + INFO_LOG(Log::System, "Selected path: %.*s", STR_VIEW(value)); DarwinFileSystemServices::setUserPreferredMemoryStickDirectory(Path(value)); }); } @@ -1628,7 +1628,7 @@ void GameSettingsScreen::OnChangeBackground(UI::EventParams &e) { } auto sy = GetI18NCategory(I18NCat::SYSTEM); - System_BrowseForImage(GetRequesterToken(), sy->T("Set UI background..."), bgJpg, [=](const std::string &value, int converted) { + System_BrowseForImage(GetRequesterToken(), sy->T("Set UI background..."), bgJpg, [this](std::string_view value, int converted) { if (converted == 1) { // The platform code converted and saved the file to the desired path already. INFO_LOG(Log::UI, "Converted file."); @@ -1656,14 +1656,14 @@ void GameSettingsScreen::OnChangeBackground(UI::EventParams &e) { } if (!filename.empty()) { - Path src(value); Path dest = GetSysDirectory(DIRECTORY_SYSTEM) / filename; - File::Copy(src, dest); - if (src.FilePathContainsNoCase("temp_import.jpg")) { - INFO_LOG(Log::UI, "Deleting temp file: %s", GetFriendlyPath(src).c_str()); - File::Delete(src); + File::Copy(path, dest); + if (path.FilePathContainsNoCase("temp_import.jpg")) { + INFO_LOG(Log::UI, "Deleting temp file: %s", GetFriendlyPath(path).c_str()); + File::Delete(path); } } else { + auto sy = GetI18NCategory(I18NCat::SYSTEM); g_OSD.Show(OSDType::MESSAGE_ERROR, sy->T("Only JPG and PNG images are supported"), path.GetFilename(), 5.0); } } diff --git a/UI/IAPScreen.cpp b/UI/IAPScreen.cpp index b0ce6faf48..ba2096f068 100644 --- a/UI/IAPScreen.cpp +++ b/UI/IAPScreen.cpp @@ -62,7 +62,7 @@ void IAPScreen::CreateSettingsViews(UI::ViewGroup *rightColumnItems) { buyButton->OnClick.Add([this, requesterToken](UI::EventParams &) { INFO_LOG(Log::System, "Showing purchase UI..."); if (useIAP_) { - System_IAPMakePurchase(requesterToken, "org.ppsspp.gold", [this](const char *responseString, int intValue) { + System_IAPMakePurchase(requesterToken, "org.ppsspp.gold", [this](std::string_view responseString, int intValue) { INFO_LOG(Log::System, "PPSSPP Gold purchase successful!"); auto di = GetI18NCategory(I18NCat::DIALOG); g_OSD.Show(OSDType::MESSAGE_SUCCESS, di->T("GoldThankYou", "Thank you for supporting the PPSSPP project!"), 3.0f); @@ -90,7 +90,7 @@ void IAPScreen::CreateSettingsViews(UI::ViewGroup *rightColumnItems) { restorePurchases->OnClick.Add([this, requesterToken, restorePurchases](UI::EventParams &) { restorePurchases->SetEnabled(false); INFO_LOG(Log::System, "Requesting purchase restore"); - System_IAPRestorePurchases(requesterToken, [this](const char *responseString, int) { + System_IAPRestorePurchases(requesterToken, [this](std::string_view responseString, int) { INFO_LOG(Log::System, "Successfully restored purchases!"); RecreateViews(); }, [](int responseValue) { diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 68698d7388..8e8ffc073b 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -618,7 +618,7 @@ static void RecurseFileSystem(IFileSystem *fs, std::string path, RequesterToken std::string fullPath = path + "/" + file.name; int size = file.size; // save dialog - System_BrowseForFileSave(token, "Save file", file.name, BrowseFileType::ANY, [fullPath, fs, size](const char *responseString, int) { + System_BrowseForFileSave(token, "Save file", file.name, BrowseFileType::ANY, [fullPath, fs, size](std::string_view responseString, int) { int fd = fs->OpenFile(fullPath, FILEACCESS_READ); if (fd >= 0) { std::string data; @@ -1343,7 +1343,7 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) { if (ctx->BufferState() == ATRAC_STATUS_ALL_DATA_LOADED) { if (ImGui::Button("Save to disk...")) { - System_BrowseForFileSave(cfg.requesterToken, "Save AT3 file", "song.at3", BrowseFileType::ATRAC3, [=](const std::string &filename, int) { + System_BrowseForFileSave(cfg.requesterToken, "Save AT3 file", "song.at3", BrowseFileType::ATRAC3, [&info](std::string_view filename, int) { if (!Memory::IsValidRange(info.buffer, info.bufferByte)) { return; } @@ -2182,7 +2182,7 @@ void ImAtracToolWindow::Draw(ImConfig &cfg) { ImGui::InputText("File", atracPath_, sizeof(atracPath_)); ImGui::SameLine(); if (ImGui::Button("Choose...")) { - System_BrowseForFile(cfg.requesterToken, "Choose AT3 file", BrowseFileType::ATRAC3, [this](const std::string &filename, int) { + System_BrowseForFile(cfg.requesterToken, "Choose AT3 file", BrowseFileType::ATRAC3, [this](std::string_view filename, int) { truncate_cpy(atracPath_, filename); Load(); }, nullptr); @@ -2205,7 +2205,7 @@ void ImAtracToolWindow::Draw(ImConfig &cfg) { if (data_.size()) { if (ImGui::Button("Dump 64 raw frames")) { std::string firstFrames = data_.substr(track_->dataByteOffset, track_->bytesPerFrame * 64); - System_BrowseForFileSave(cfg.requesterToken, "Save .at3raw", "at3.raw", BrowseFileType::ANY, [firstFrames](const std::string &filename, int) { + System_BrowseForFileSave(cfg.requesterToken, "Save .at3raw", "at3.raw", BrowseFileType::ANY, [firstFrames](std::string_view filename, int) { FILE *f = File::OpenCFile(Path(filename), "wb"); if (f) { fwrite(firstFrames.data(), 1, firstFrames.size(), f); @@ -2412,7 +2412,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu ImGui::Separator(); if (ImGui::MenuItem("Load .ppmap...")) { - System_BrowseForFile(reqToken_, "Load PPSSPP symbol map", BrowseFileType::SYMBOL_MAP, [&](const char *responseString, int) { + System_BrowseForFile(reqToken_, "Load PPSSPP symbol map", BrowseFileType::SYMBOL_MAP, [this](std::string_view responseString, int) { Path path(responseString); if (!g_symbolMap->LoadSymbolMap(path)) { ERROR_LOG(Log::Common, "Failed to load symbol map"); @@ -2421,7 +2421,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu }); } if (ImGui::MenuItem("Save .ppmap...")) { - System_BrowseForFileSave(reqToken_, "Save PPSSPP symbol map", "symbols.ppmap", BrowseFileType::SYMBOL_MAP, [](const char *responseString, int) { + System_BrowseForFileSave(reqToken_, "Save PPSSPP symbol map", "symbols.ppmap", BrowseFileType::SYMBOL_MAP, [](std::string_view responseString, int) { Path path(responseString); if (!g_symbolMap->SaveSymbolMap(path)) { ERROR_LOG(Log::Common, "Failed to save symbol map"); @@ -2429,7 +2429,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu }); } if (ImGui::MenuItem("Load No$ .sym...")) { - System_BrowseForFile(reqToken_, "Load No$ symbol map", BrowseFileType::SYMBOL_MAP, [&](const char *responseString, int) { + System_BrowseForFile(reqToken_, "Load No$ symbol map", BrowseFileType::SYMBOL_MAP, [this](std::string_view responseString, int) { Path path(responseString); if (!g_symbolMap->LoadNocashSym(path)) { ERROR_LOG(Log::Common, "Failed to load No$ symbol map"); @@ -2438,7 +2438,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu }); } if (ImGui::MenuItem("Save No$ .sym...")) { - System_BrowseForFileSave(reqToken_, "Save No$ symbol map", "symbols.sym", BrowseFileType::SYMBOL_MAP, [](const char *responseString, int) { + System_BrowseForFileSave(reqToken_, "Save No$ symbol map", "symbols.sym", BrowseFileType::SYMBOL_MAP, [](std::string_view responseString, int) { Path path(responseString); if (!g_symbolMap->SaveNocashSym(path)) { ERROR_LOG(Log::Common, "Failed to save No$ symbol map"); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 1af913cbc8..7eb9540a43 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -518,7 +518,7 @@ bool MainScreen::key(const KeyInput &key) { if (key.flags & KeyInputFlags::DOWN) { if (key.keyCode == NKCODE_F && (key.flags & KeyInputFlags::MOD_CTRL) && System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { auto se = GetI18NCategory(I18NCat::SEARCH); - System_InputBoxGetString(GetRequesterToken(), se->T("Search term"), searchFilter_, false, [&](const std::string &value, int) { + System_InputBoxGetString(GetRequesterToken(), se->T("Search term"), searchFilter_, false, [this](std::string_view value, int) { searchFilter_ = StripSpaces(value); searchChanged_ = true; }); @@ -597,7 +597,7 @@ void MainScreen::update() { void MainScreen::OnLoadFile(UI::EventParams &e) { if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) { auto mm = GetI18NCategory(I18NCat::MAINMENU); - System_BrowseForFile(GetRequesterToken(), mm->T("Load"), BrowseFileType::BOOTABLE, [](const std::string &value, int) { + System_BrowseForFile(GetRequesterToken(), mm->T("Load"), BrowseFileType::BOOTABLE, [](std::string_view value, int) { System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, value); }); } @@ -836,7 +836,7 @@ void UmdReplaceScreen::CreateViews() { if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) { rightColumnItems->Add(new Choice(mm->T("Load", "Load...")))->OnClick.Add([&](UI::EventParams &e) { auto mm = GetI18NCategory(I18NCat::MAINMENU); - System_BrowseForFile(GetRequesterToken(), mm->T("Load"), BrowseFileType::BOOTABLE, [this](const std::string &value, int) { + System_BrowseForFile(GetRequesterToken(), mm->T("Load"), BrowseFileType::BOOTABLE, [this](std::string_view value, int) { __UmdReplace(Path(value)); TriggerFinish(DR_OK); }); diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index 7d77604e49..f794fe4cc6 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -307,11 +307,11 @@ void MemStickScreen::SetFolderManually(UI::EventParams ¶ms) { // The old way, from before scoped storage. Write in the full path. #if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) auto sy = GetI18NCategory(I18NCat::SYSTEM); - System_InputBoxGetString(GetRequesterToken(), sy->T("Memory Stick Folder"), g_Config.memStickDirectory.ToString(), false, [&](const std::string &value, int) { + System_InputBoxGetString(GetRequesterToken(), sy->T("Memory Stick Folder"), g_Config.memStickDirectory.ToString(), false, [this](std::string_view value, int) { auto sy = GetI18NCategory(I18NCat::SYSTEM); auto di = GetI18NCategory(I18NCat::DIALOG); - std::string newPath = value; + std::string newPath(value); size_t pos = newPath.find_last_not_of('/'); // Gotta have at least something but a /, and also needs to start with a /. if (newPath.empty() || pos == std::string::npos || newPath[0] != '/') { @@ -417,8 +417,8 @@ void MemStickScreen::UseStorageRoot(UI::EventParams ¶ms) { void MemStickScreen::Browse(UI::EventParams ¶ms) { auto mm = GetI18NCategory(I18NCat::MAINMENU); - System_BrowseForFolder(GetRequesterToken(), mm->T("Choose folder"), g_Config.memStickDirectory, [this](const std::string &value, int) { - Path pendingMemStickFolder = Path(value); + System_BrowseForFolder(GetRequesterToken(), mm->T("Choose folder"), g_Config.memStickDirectory, [this](std::string_view value, int) { + Path pendingMemStickFolder(value); INFO_LOG(Log::System, "Got folder: '%s' (old: %s)", pendingMemStickFolder.c_str(), g_Config.memStickDirectory.c_str()); // Browse finished. Let's pop up the confirmation dialog. if (!pendingMemStickFolder.empty() && pendingMemStickFolder == g_Config.memStickDirectory && File::IsDirectory(pendingMemStickFolder)) { diff --git a/UI/RetroAchievementScreens.cpp b/UI/RetroAchievementScreens.cpp index 3e6d519c03..81e408f5b4 100644 --- a/UI/RetroAchievementScreens.cpp +++ b/UI/RetroAchievementScreens.cpp @@ -384,7 +384,7 @@ void RetroAchievementsSettingsScreen::CreateAccountTab(UI::ViewGroup *viewGroup) viewGroup->Add(new Choice(di->T("Log in")))->OnClick.Add([this](UI::EventParams &) -> void { auto di = GetI18NCategory(I18NCat::DIALOG); std::string title = StringFromFormat("RetroAchievements: %s", di->T_cstr("Log in")); - System_AskUsernamePassword(GetRequesterToken(), title, g_Config.sAchievementsUserName, [](const std::string &value, int) { + System_AskUsernamePassword(GetRequesterToken(), title, g_Config.sAchievementsUserName, [](std::string_view value, int) { std::vector parts; SplitString(value, '\n', parts); if (parts.size() == 2 && !parts[0].empty() && !parts[1].empty()) { diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 1790271207..a59cfddfbf 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -672,7 +672,7 @@ void SavedataScreen::CreateExtraButtons(UI::ViewGroup *verticalLayout, int margi void SavedataScreen::OnSearch(UI::EventParams &e) { if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { auto di = GetI18NCategory(I18NCat::DIALOG); - System_InputBoxGetString(GetRequesterToken(), di->T("Filter"), searchFilter_, false, [](const std::string &value, int ivalue) { + System_InputBoxGetString(GetRequesterToken(), di->T("Filter"), searchFilter_, false, [](std::string_view value, int ivalue) { System_PostUIMessage(UIMessage::SAVEDATA_SEARCH, value); }); } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 67cca5487f..0c684163d0 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -352,7 +352,7 @@ namespace MainWindow { DrawMenuBar(hWnd); } - void BrowseAndBootDone(std::string filename); + void BrowseAndBootDone(std::string_view filename); void BrowseAndBoot(RequesterToken token, std::string defaultPath, bool browseDirectory) { bool browsePauseAfter = false; @@ -366,28 +366,29 @@ namespace MainWindow { W32Util::MakeTopMost(GetHWND(), false); if (browseDirectory) { - System_BrowseForFolder(token, mm->T("Load"), Path(), [](const std::string &value, int) { + System_BrowseForFolder(token, mm->T("Load"), Path(), [](std::string_view value, int) { BrowseAndBootDone(value); }); } else { - System_BrowseForFile(token, mm->T("Load"), BrowseFileType::BOOTABLE, [](const std::string &value, int) { + System_BrowseForFile(token, mm->T("Load"), BrowseFileType::BOOTABLE, [](std::string_view value, int) { BrowseAndBootDone(value); }); } } - void BrowseAndBootDone(std::string filename) { + void BrowseAndBootDone(std::string_view filename) { if (GetUIState() == UISTATE_INGAME || GetUIState() == UISTATE_EXCEPTION || GetUIState() == UISTATE_PAUSEMENU) { Core_Resume(); } - filename = ReplaceAll(filename, "\\", "/"); - System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, filename); + std::string fileStr(filename); + fileStr = ReplaceAll(fileStr, "\\", "/"); + System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, fileStr); W32Util::MakeTopMost(GetHWND(), g_Config.bTopMost); } static void UmdSwitchAction(RequesterToken token) { auto mm = GetI18NCategory(I18NCat::MAINMENU); - System_BrowseForFile(token, mm->T("Switch UMD"), BrowseFileType::BOOTABLE, [](const std::string &value, int) { + System_BrowseForFile(token, mm->T("Switch UMD"), BrowseFileType::BOOTABLE, [](std::string_view value, int) { // This is safe because the callback runs on the emu thread. __UmdReplace(Path(value)); });