diff --git a/Common/File/VFS/VFS.cpp b/Common/File/VFS/VFS.cpp index 26167efc86..a46a862f56 100644 --- a/Common/File/VFS/VFS.cpp +++ b/Common/File/VFS/VFS.cpp @@ -1,5 +1,4 @@ #include - #include "Common/Common.h" #include "Common/Log.h" #include "Common/File/VFS/VFS.h" @@ -37,6 +36,30 @@ static bool IsLocalAbsolutePath(std::string_view path) { return isUnixLocal || isWindowsLocal || isContentURI; } +template +inline RetType RouteVFSOperation(const std::vector &entries, std::string_view filename, Func func) { + const int fn_len = (int)filename.length(); + bool fileSystemFound = false; + for (const auto &entry : entries) { + int prefix_len = (int)entry.prefix.length(); + if (prefix_len >= fn_len) continue; + if (0 == memcmp(filename.data(), entry.prefix.data(), prefix_len)) { + fileSystemFound = true; + RetType result = func(entry.reader, filename.substr(prefix_len)); + if (result) + return result; + else + continue; + // INFO_LOG(Log::IO, "Prefix match: %s (%s) -> %s", entries[i].prefix, filename, filename + prefix_len); + // Else try the other registered file systems. + } + } + if (!fileSystemFound) { + ERROR_LOG(Log::IO, "Missing filesystem for '%.*s'", STR_VIEW(filename)); + } // Otherwise, the file was just missing. No need to log. + return RetType(); +} + // The returned data should be free'd with delete[]. uint8_t *VFS::ReadFile(std::string_view filename, size_t *size) { if (IsLocalAbsolutePath(filename)) { @@ -44,27 +67,9 @@ uint8_t *VFS::ReadFile(std::string_view filename, size_t *size) { // INFO_LOG(Log::IO, "Not a VFS path: %.*s . Reading local file.", STR_VIEW(filename)); return File::ReadLocalFile(Path(filename), size); } - - const int fn_len = (int)filename.length(); - bool fileSystemFound = false; - for (const auto &entry : entries_) { - int prefix_len = (int)entry.prefix.length(); - if (prefix_len >= fn_len) continue; - if (0 == memcmp(filename.data(), entry.prefix.data(), prefix_len)) { - fileSystemFound = true; - // INFO_LOG(Log::IO, "Prefix match: %s (%s) -> %s", entries[i].prefix, filename, filename + prefix_len); - uint8_t *data = entry.reader->ReadFile(filename.substr(prefix_len), size); - if (data) - return data; - else - continue; - // Else try the other registered file systems. - } - } - if (!fileSystemFound) { - ERROR_LOG(Log::IO, "Missing filesystem for '%.*s'", STR_VIEW(filename)); - } // Otherwise, the file was just missing. No need to log. - return nullptr; + return RouteVFSOperation(entries_, filename, [size](VFSBackend *reader, std::string_view path) { + return reader->ReadFile(path, size); + }); } bool VFS::GetFileListing(std::string_view path, std::vector *listing, const char *filter) { @@ -74,24 +79,9 @@ bool VFS::GetFileListing(std::string_view path, std::vector *lis File::GetFilesInDir(Path(path), listing, filter); return true; } - - int fn_len = (int)path.length(); - bool fileSystemFound = false; - for (const auto &entry : entries_) { - int prefix_len = (int)entry.prefix.length(); - if (prefix_len >= fn_len) continue; - if (0 == memcmp(path.data(), entry.prefix.data(), prefix_len)) { - fileSystemFound = true; - if (entry.reader->GetFileListing(path.substr(prefix_len), listing, filter)) { - return true; - } - } - } - - if (!fileSystemFound) { - ERROR_LOG(Log::IO, "Missing filesystem for %.*s", STR_VIEW(path)); - } // Otherwise, the file was just missing. No need to log. - return false; + return RouteVFSOperation(entries_, path, [listing, filter](VFSBackend *reader, std::string_view path) { + return reader->GetFileListing(path, listing, filter); + }); } bool VFS::GetFileInfo(std::string_view path, File::FileInfo *info) { @@ -100,24 +90,9 @@ bool VFS::GetFileInfo(std::string_view path, File::FileInfo *info) { // INFO_LOG(Log::IO, "Not a VFS path: %s . Getting local file info.", path); return File::GetFileInfo(Path(path), info); } - - bool fileSystemFound = false; - int fn_len = (int)path.length(); - for (const auto &entry : entries_) { - int prefix_len = (int)entry.prefix.length(); - if (prefix_len >= fn_len) continue; - if (0 == memcmp(path.data(), entry.prefix.data(), prefix_len)) { - fileSystemFound = true; - if (entry.reader->GetFileInfo(path.substr(prefix_len), info)) - return true; - else - continue; - } - } - if (!fileSystemFound) { - ERROR_LOG(Log::IO, "Missing filesystem for '%.*s'", STR_VIEW(path)); - } // Otherwise, the file was just missing. No need to log. - return false; + return RouteVFSOperation(entries_, path, [info](VFSBackend *reader, std::string_view path) { + return reader->GetFileInfo(path, info); + }); } bool VFS::Exists(std::string_view path) { @@ -126,22 +101,7 @@ bool VFS::Exists(std::string_view path) { // INFO_LOG(Log::IO, "Not a VFS path: %s . Getting local file info.", path); return File::Exists(Path(path)); } - - bool fileSystemFound = false; - int fn_len = (int)path.length(); - for (const auto &entry : entries_) { - int prefix_len = (int)entry.prefix.length(); - if (prefix_len >= fn_len) continue; - if (0 == memcmp(path.data(), entry.prefix.data(), prefix_len)) { - fileSystemFound = true; - if (entry.reader->Exists(path.substr(prefix_len))) - return true; - else - continue; - } - } - if (!fileSystemFound) { - ERROR_LOG(Log::IO, "Missing filesystem for '%.*s'", STR_VIEW(path)); - } // Otherwise, the file was just missing. No need to log. - return false; + return RouteVFSOperation(entries_, path, [](VFSBackend *reader, std::string_view path) { + return reader->Exists(path); + }); } diff --git a/Common/File/VFS/VFS.h b/Common/File/VFS/VFS.h index c339328356..bf317885f5 100644 --- a/Common/File/VFS/VFS.h +++ b/Common/File/VFS/VFS.h @@ -65,6 +65,11 @@ public: virtual std::string toString() const = 0; }; +struct VFSEntry { + std::string_view prefix; + VFSBackend *reader; +}; + class VFS : public VFSInterface { public: ~VFS() { Clear(); } @@ -81,10 +86,6 @@ public: bool Exists(std::string_view path); private: - struct VFSEntry { - std::string_view prefix; - VFSBackend *reader; - }; std::vector entries_; }; diff --git a/Common/Render/ManagedTexture.cpp b/Common/Render/ManagedTexture.cpp index d9997b33f3..90de360d79 100644 --- a/Common/Render/ManagedTexture.cpp +++ b/Common/Render/ManagedTexture.cpp @@ -23,8 +23,8 @@ // TODO: It really feels like we should be able to simplify this. class TextureLoadTask : public Task { public: - TextureLoadTask(std::string_view filename, ImageFileType type, bool generateMips, TempImage *tempImage, ManagedTexture::LoadState *state, LimitedWaitable *waitable) - : filename_(filename), type_(type), generateMips_(generateMips), tempImage_(tempImage), state_(state), waitable_(waitable) {} + TextureLoadTask(std::string_view filename, ImageFileType type, TempImage *tempImage, ManagedTexture::LoadState *state, LimitedWaitable *waitable) + : filename_(filename), type_(type), tempImage_(tempImage), state_(state), waitable_(waitable) {} TaskType Type() const override { return TaskType::IO_BLOCKING; } TaskPriority Priority() const override { return TaskPriority::NORMAL; } @@ -55,7 +55,6 @@ private: std::string filename_; TempImage *tempImage_; ImageFileType type_; - bool generateMips_; // not yet used ManagedTexture::LoadState *state_; }; @@ -211,8 +210,8 @@ Draw::Texture *ManagedTexture::GetTexture() { return texture_; } -ManagedTexture::ManagedTexture(Draw::DrawContext *draw, std::string_view filename, ImageFileType type, bool generateMips) - : draw_(draw), filename_(filename), type_(type), generateMips_(generateMips) +ManagedTexture::ManagedTexture(Draw::DrawContext *draw, std::string_view filename, ImageFileType type) + : draw_(draw), filename_(filename), type_(type) { StartLoadTask(); } @@ -230,7 +229,7 @@ ManagedTexture::~ManagedTexture() { void ManagedTexture::StartLoadTask() { _dbg_assert_(!taskWaitable_); taskWaitable_ = new LimitedWaitable(); - g_threadManager.EnqueueTask(new TextureLoadTask(filename_, type_, generateMips_, &pendingImage_, &state_, taskWaitable_)); + g_threadManager.EnqueueTask(new TextureLoadTask(filename_, type_, &pendingImage_, &state_, taskWaitable_)); } void ManagedTexture::DeviceLost() { diff --git a/Common/Render/ManagedTexture.h b/Common/Render/ManagedTexture.h index 49bc6ced60..0ac6211796 100644 --- a/Common/Render/ManagedTexture.h +++ b/Common/Render/ManagedTexture.h @@ -44,7 +44,7 @@ struct TempImage { // Managed (will auto-reload from file) and async. For use in UI. class ManagedTexture { public: - ManagedTexture(Draw::DrawContext *draw, std::string_view filename, ImageFileType type = ImageFileType::DETECT, bool generateMips = false); + ManagedTexture(Draw::DrawContext *draw, std::string_view filename, ImageFileType type = ImageFileType::DETECT); ~ManagedTexture(); Draw::Texture *GetTexture(); // For immediate use, don't store. int Width() const { return texture_->Width(); } diff --git a/Common/System/OSD.cpp b/Common/System/OSD.cpp index 6ce7500f9b..1e810e4986 100644 --- a/Common/System/OSD.cpp +++ b/Common/System/OSD.cpp @@ -12,29 +12,12 @@ OnScreenDisplay g_OSD; // Effectively forever. constexpr double forever_s = 10000000000.0; -OnScreenDisplay::~OnScreenDisplay() { - std::lock_guard guard(mutex_); - - double now = time_now_d(); - for (auto &iter : entries_) { - if (iter.clickCallback) { - // Wasn't clicked, but let it free any data. - iter.clickCallback(false, iter.clickUserData); - } - } -} - void OnScreenDisplay::Update() { std::lock_guard guard(mutex_); double now = time_now_d(); for (auto iter = entries_.begin(); iter != entries_.end(); ) { if (now >= iter->endTime) { - if (iter->clickCallback) { - // Wasn't clicked, but let it free any data. - iter->clickCallback(false, iter->clickUserData); - iter->clickCallback = nullptr; - } iter = entries_.erase(iter); } else { iter++; @@ -61,9 +44,10 @@ float OnScreenDisplay::IngameAlpha() const { void OnScreenDisplay::ClickEntry(size_t index, double now) { std::lock_guard guard(mutex_); if (index < entries_.size() && entries_[index].type != OSDType::ACHIEVEMENT_CHALLENGE_INDICATOR) { - entries_[index].endTime = std::min(now + FadeoutTime(), entries_[index].endTime); if (entries_[index].clickCallback) { - entries_[index].clickCallback(true, entries_[index].clickUserData); + entries_[index].clickCallback(); + } else { + entries_[index].endTime = std::min(now + FadeoutTime(), entries_[index].endTime); } } } @@ -333,18 +317,17 @@ void OnScreenDisplay::ClearAchievementStuff() { } } -void OnScreenDisplay::SetClickCallback(const char *id, void (*callback)(bool, void *), void *userdata) { +void OnScreenDisplay::SetClickCallback(std::string_view id, std::function callback) { _dbg_assert_(callback != nullptr); for (auto &ent : entries_) { // protect against dupes. - if (ent.id == id && !ent.clickCallback) { + if (ent.id == id) { ent.clickCallback = callback; - ent.clickUserData = userdata; } } } -void OnScreenDisplay::SetFlags(const char *id, OSDMessageFlags flags) { +void OnScreenDisplay::SetFlags(std::string_view id, OSDMessageFlags flags) { for (auto &ent : entries_) { // protect against dupes. if (ent.id == id) { diff --git a/Common/System/OSD.h b/Common/System/OSD.h index dd520a9949..a229623fc3 100644 --- a/Common/System/OSD.h +++ b/Common/System/OSD.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "Common/Common.h" @@ -49,8 +50,6 @@ ENUM_CLASS_BITOPS(OSDMessageFlags); // Data holder for on-screen messages. class OnScreenDisplay { public: - ~OnScreenDisplay(); - // If you specify 0.0f as duration, a duration will be chosen automatically depending on type. void Show(OSDType type, std::string_view text, float duration_s = 0.0f, const char *id = nullptr) { Show(type, text, "", duration_s, id); @@ -90,8 +89,8 @@ public: void ClearAchievementStuff(); // Can't add an infinite number of "Show" functions, so starting to offer post-modification. - void SetClickCallback(const char *id, void (*callback)(bool, void *), void *userdata); - void SetFlags(const char *id, OSDMessageFlags flag); + void SetFlags(std::string_view id, OSDMessageFlags flag); + void SetClickCallback(std::string_view id, std::function callback); struct Entry { OSDType type; @@ -102,9 +101,7 @@ public: std::string id; OSDMessageFlags flags; - // We could use std::function, but prefer to do it the oldschool way. - void (*clickCallback)(bool, void *); - void *clickUserData; + std::function clickCallback; int instanceID; double startTime; diff --git a/Common/UI/AsyncImageFileView.cpp b/Common/UI/AsyncImageFileView.cpp index 01c7f063c3..1b29a422bc 100644 --- a/Common/UI/AsyncImageFileView.cpp +++ b/Common/UI/AsyncImageFileView.cpp @@ -79,7 +79,7 @@ void AsyncImageFileView::DeviceRestored(Draw::DrawContext *draw) { void AsyncImageFileView::Draw(UIContext &dc) { using namespace Draw; if (!texture_ && !textureFailed_ && !filename_.empty()) { - texture_ = std::make_unique(dc.GetDrawContext(), filename_.c_str(), ImageFileType::DETECT, true); + texture_ = std::make_unique(dc.GetDrawContext(), filename_.c_str(), ImageFileType::DETECT); if (!texture_.get()) textureFailed_ = true; } diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index d2d7f30ae7..889e8fa6d2 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -1027,8 +1027,8 @@ void RadioButton::Draw(UIContext &dc) { } } -ImageView::ImageView(ImageID atlasImage, const std::string &text, ImageSizeMode sizeMode, LayoutParams *layoutParams) - : InertView(layoutParams), text_(text), atlasImage_(atlasImage), sizeMode_(sizeMode) {} +ImageView::ImageView(ImageID atlasImage, const std::string &text, LayoutParams *layoutParams) + : InertView(layoutParams), text_(text), atlasImage_(atlasImage) {} void ImageView::GetContentDimensions(const UIContext &dc, float &w, float &h) const { dc.Draw()->GetAtlas()->measureImage(atlasImage_, &w, &h); diff --git a/Common/UI/View.h b/Common/UI/View.h index 8c1576964b..80f37563f7 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -53,6 +53,12 @@ enum DrawableType { DRAW_STRETCH_IMAGE, }; +enum ImageSizeMode { + IS_DEFAULT, + IS_FIXED, + IS_KEEP_ASPECT, +}; + enum Visibility { V_VISIBLE, V_INVISIBLE, // Keeps position, not drawn or interacted with @@ -1116,15 +1122,9 @@ private: // TODO: Selections }; -enum ImageSizeMode { - IS_DEFAULT, - IS_FIXED, - IS_KEEP_ASPECT, -}; - class ImageView : public InertView { public: - ImageView(ImageID atlasImage, const std::string &text, ImageSizeMode sizeMode, LayoutParams *layoutParams = nullptr); + ImageView(ImageID atlasImage, const std::string &text, LayoutParams *layoutParams = nullptr); void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; void Draw(UIContext &dc) override; std::string DescribeText() const override { return text_; } @@ -1133,7 +1133,6 @@ public: private: std::string text_; ImageID atlasImage_; - ImageSizeMode sizeMode_; // TODO: Not actually used yet. float scale_ = 1.0f; }; diff --git a/Core/System.cpp b/Core/System.cpp index f120df9d9c..5c469c1351 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -403,22 +403,13 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin if ((g_logManager.GetOutputsEnabled() & LogOutput::File) && !g_logManager.GetLogFilePath().empty()) { auto dev = GetI18NCategory(I18NCat::DEVELOPER); - std::string logPath = g_logManager.GetLogFilePath().ToString(); - - // TODO: Really need a cleaner way to make clickable path notifications. - char *path = new char[logPath.size() + 1]; - strcpy(path, logPath.data()); + Path logPath = g_logManager.GetLogFilePath(); g_OSD.Show(OSDType::MESSAGE_INFO, ApplySafeSubstitutions("%1: %2", dev->T("Log to file"), g_logManager.GetLogFilePath().ToVisualString()), 0.0f, "log_to_file"); if (System_GetPropertyBool(SYSPROP_CAN_SHOW_FILE)) { - g_OSD.SetClickCallback("log_to_file", [](bool clicked, void *userdata) { - char *path = (char *)userdata; - if (clicked) { - System_ShowFileInFolder(Path(path)); - } else { - delete[] path; - } - }, path); + g_OSD.SetClickCallback("log_to_file", [logPath]() { + System_ShowFileInFolder(logPath); + }); } } @@ -837,21 +828,11 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, std::string_view nam if (File::Exists(fullPath)) { INFO_LOG(Log::sceModule, "%s already exists for this game, skipping dump.", filenameToDumpTo.c_str()); - char *path = new char[strlen(fullPath.c_str()) + 1]; - strcpy(path, fullPath.c_str()); - - g_OSD.Show(OSDType::MESSAGE_INFO, titleStr, fullPath.ToVisualString(), 5.0f); + g_OSD.Show(OSDType::MESSAGE_INFO, titleStr, fullPath.ToVisualString(), 5.0f, "file_dumped"); if (System_GetPropertyBool(SYSPROP_CAN_SHOW_FILE)) { - g_OSD.SetClickCallback("file_dumped", [](bool clicked, void *userdata) { - char *path = (char *)userdata; - if (clicked) { - System_ShowFileInFolder(Path(path)); - } else { - delete[] path; - } - }, path); - } else { - delete[] path; + g_OSD.SetClickCallback("file_dumped", [fullPath]() { + System_ShowFileInFolder(fullPath); + }); } return; } @@ -877,18 +858,11 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, std::string_view nam INFO_LOG(Log::sceModule, "Successfully wrote %s to %s", DumpFileTypeToString(type), fullPath.ToVisualString().c_str()); - char *path = new char[strlen(fullPath.c_str()) + 1]; - strcpy(path, fullPath.c_str()); - - // Re-suing the translation string here. - g_OSD.Show(OSDType::MESSAGE_SUCCESS, titleStr, fullPath.ToVisualString(), 5.0f); + // Re-using the translation string here. + g_OSD.Show(OSDType::MESSAGE_SUCCESS, titleStr, fullPath.ToVisualString(), 5.0f, "decr"); if (System_GetPropertyBool(SYSPROP_CAN_SHOW_FILE)) { - g_OSD.SetClickCallback("decr", [](bool clicked, void *userdata) { - char *path = (char *)userdata; - if (clicked) { - System_ShowFileInFolder(Path(path)); - } - delete[] path; - }, path); + g_OSD.SetClickCallback("decr", [fullPath]() { + System_ShowFileInFolder(fullPath); + }); } } diff --git a/UI/DeveloperToolsScreen.cpp b/UI/DeveloperToolsScreen.cpp index ba27e68690..821d6fb0a7 100644 --- a/UI/DeveloperToolsScreen.cpp +++ b/UI/DeveloperToolsScreen.cpp @@ -393,11 +393,9 @@ void DeveloperToolsScreen::CreateUITab(UI::LinearLayout *list) { // This one is clickable list->Add(new Choice(si->T("Success")))->OnClick.Add([&](UI::EventParams &) { g_OSD.Show(OSDType::MESSAGE_SUCCESS, "Success", 0.0f, "clickable"); - g_OSD.SetClickCallback("clickable", [](bool clicked, void *) { - if (clicked) { - System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.google.com/"); - } - }, nullptr); + g_OSD.SetClickCallback("clickable", []() { + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.google.com/"); + }); }); list->Add(new Choice(sy->T("RetroAchievements")))->OnClick.Add([&](UI::EventParams &) { g_OSD.Show(OSDType::MESSAGE_WARNING, "RetroAchievements warning", "", "I_RETROACHIEVEMENTS_LOGO"); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 25cb64cbcb..687ff998e8 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1574,9 +1574,10 @@ void EmuScreen::HandleFlip() { auto sy = GetI18NCategory(I18NCat::SYSTEM); avi.Stop(); g_OSD.Show(OSDType::MESSAGE_INFO, sy->T("AVI Dump stopped."), 3.0f, "avi_dump"); - g_OSD.SetClickCallback("avi_dump", [](bool, void *) { - System_ShowFileInFolder(avi.LastFilename()); - }, nullptr); + Path lastFilename = avi.LastFilename(); + g_OSD.SetClickCallback("avi_dump", [lastFilename]() { + System_ShowFileInFolder(lastFilename); + }); startDumping_ = false; } #endif diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 66790bfdd4..1f014101ef 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -251,7 +251,11 @@ std::string GameInfo::GetMTime() const { // Not too meaningful if the object itself is a savedata directory... // Call this under lock. std::vector GameInfo::GetSaveDataDirectories() { - _dbg_assert_(hasFlags & GameInfoFlags::PARAM_SFO); // so we know we have the ID. + if (!(hasFlags & GameInfoFlags::PARAM_SFO)) { + ERROR_LOG(Log::UI, "Can't get savedata directories if we don't have PARAM_SFO."); + return std::vector(); + } + Path memc = GetSysDirectory(DIRECTORY_SAVEDATA); std::vector directories; diff --git a/UI/JitCompareScreen.h b/UI/JitCompareScreen.h index a93d57184e..1b9a447065 100644 --- a/UI/JitCompareScreen.h +++ b/UI/JitCompareScreen.h @@ -18,11 +18,9 @@ private: // Uses the current ListType void FillBlockList(); - UI::LinearLayout *comparisonView_ = nullptr; UI::LinearLayout *leftDisasm_ = nullptr; UI::LinearLayout *rightDisasm_ = nullptr; - UI::LinearLayout *blockListView_ = nullptr; UI::LinearLayout *blockListContainer_ = nullptr; void OnSelectBlock(UI::EventParams &e); diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index b36068d173..5703a7c083 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -21,7 +21,7 @@ TextWithImage::TextWithImage(ImageID imageID, std::string_view text, UI::LinearL layoutParams_->height = ITEM_HEIGHT; } if (imageID.isValid()) { - Add(new ImageView(imageID, "", UI::IS_DEFAULT, new LinearLayoutParams(0.0f, UI::Gravity::G_VCENTER))); + Add(new ImageView(imageID, "", new LinearLayoutParams(0.0f, UI::Gravity::G_VCENTER))); } Add(new TextView(text, new LinearLayoutParams(1.0f, UI::Gravity::G_VCENTER))); } @@ -34,7 +34,7 @@ CopyableText::CopyableText(ImageID imageID, std::string_view text, UI::LinearLay layoutParams_->height = ITEM_HEIGHT; } if (imageID.isValid()) { - Add(new ImageView(imageID, "", UI::IS_DEFAULT, new LinearLayoutParams(0.0f, UI::Gravity::G_VCENTER))); + Add(new ImageView(imageID, "", new LinearLayoutParams(0.0f, UI::Gravity::G_VCENTER))); } Add(new TextView(text, new LinearLayoutParams(1.0f, UI::Gravity::G_VCENTER)))->SetBig(true); @@ -44,7 +44,7 @@ CopyableText::CopyableText(ImageID imageID, std::string_view text, UI::LinearLay }); } -TopBar::TopBar(const UIContext &ctx, TopBarFlags flags, std::string_view title, UI::LayoutParams *layoutParams) : UI::LinearLayout(ORIENT_HORIZONTAL, layoutParams), flags_(flags) { +TopBar::TopBar(const UIContext &ctx, TopBarFlags flags, std::string_view title, UI::LayoutParams *layoutParams) : UI::LinearLayout(ORIENT_HORIZONTAL, layoutParams) { using namespace UI; SetSpacing(10.0f); if (!layoutParams) { diff --git a/UI/MiscViews.h b/UI/MiscViews.h index 79b31df944..7f233fb45e 100644 --- a/UI/MiscViews.h +++ b/UI/MiscViews.h @@ -37,12 +37,11 @@ public: private: UI::Choice *backButton_ = nullptr; UI::Choice *contextMenuButton_ = nullptr; - TopBarFlags flags_ = TopBarFlags::Default; }; class ShinyIcon : public UI::ImageView { public: - ShinyIcon(ImageID atlasImage, UI::LayoutParams *layoutParams = 0) : UI::ImageView(atlasImage, "", UI::IS_DEFAULT, layoutParams) {} + ShinyIcon(ImageID atlasImage, UI::LayoutParams *layoutParams = 0) : UI::ImageView(atlasImage, "", layoutParams) {} void Draw(UIContext &dc) override; void SetAnimated(bool anim) { animated_ = anim; } private: diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 704a596d8a..9071dd91d7 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -846,12 +846,10 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { // This is a warning, not an error. auto g = GetI18NCategory(I18NCat::GRAPHICS); g_OSD.Show(OSDType::MESSAGE_WARNING, ApplySafeSubstitutions(g->T("Your display is set to a low refresh rate: %1 Hz. 60 Hz or higher is recommended."), (int)displayHz), 8.0f, "low_refresh"); - g_OSD.SetClickCallback("low_refresh", [](bool clicked, void *) { - if (clicked) { - // Open the display settings. - System_OpenDisplaySettings(); - } - }, nullptr); + g_OSD.SetClickCallback("low_refresh", []() { + // Open the display settings. + System_OpenDisplaySettings(); + }); } #endif @@ -1016,14 +1014,9 @@ static void TakeScreenshot(Draw::DrawContext *draw) { if (success) { g_OSD.Show(OSDType::MESSAGE_FILE_LINK, filename.ToVisualString(), 0.0f, "screenshot_link"); if (System_GetPropertyBool(SYSPROP_CAN_SHOW_FILE)) { - g_OSD.SetClickCallback("screenshot_link", [](bool clicked, void *data) -> void { - Path *path = reinterpret_cast(data); - if (clicked) { - System_ShowFileInFolder(*path); - } else { - delete path; - } - }, new Path(filename)); + g_OSD.SetClickCallback("screenshot_link", [filename]() -> void { + System_ShowFileInFolder(filename); + }); } } else { auto err = GetI18NCategory(I18NCat::ERRORS); diff --git a/UWP/UWP.vcxproj b/UWP/UWP.vcxproj index c7a2fb16e8..428844c1a4 100644 --- a/UWP/UWP.vcxproj +++ b/UWP/UWP.vcxproj @@ -90,7 +90,7 @@ _DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) pch.h stdcpp20 - /bigobj /await %(AdditionalOptions) + /bigobj %(AdditionalOptions) @@ -115,7 +115,7 @@ NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) pch.h stdcpp20 - /bigobj /await %(AdditionalOptions) + /bigobj %(AdditionalOptions) @@ -140,7 +140,7 @@ GOLD;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) pch.h stdcpp20 - /bigobj /await %(AdditionalOptions) + /bigobj %(AdditionalOptions) @@ -166,7 +166,7 @@ _DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) pch.h stdcpp20 - /bigobj /await %(AdditionalOptions) + /bigobj %(AdditionalOptions) @@ -191,7 +191,7 @@ NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) pch.h stdcpp20 - /bigobj /await %(AdditionalOptions) + /bigobj %(AdditionalOptions) @@ -216,7 +216,7 @@ GOLD;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) pch.h stdcpp20 - /bigobj /await %(AdditionalOptions) + /bigobj %(AdditionalOptions) diff --git a/ext/aemu_postoffice b/ext/aemu_postoffice index eec2e71424..b0625ecb65 160000 --- a/ext/aemu_postoffice +++ b/ext/aemu_postoffice @@ -1 +1 @@ -Subproject commit eec2e71424b455998e6add598411678bda25be5a +Subproject commit b0625ecb6502038b770eab638143f89699c96bfc