mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-06 12:43:46 +01:00
Merge pull request #21227 from hrydgard/even-more-fixes
Some code cleanup and refactoring
This commit is contained in:
19 files changed
+110
-204
No files matched your search
+36
-76
@@ -1,5 +1,4 @@
|
||||
#include <cstring>
|
||||
|
||||
#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<class RetType, class Func>
|
||||
inline RetType RouteVFSOperation(const std::vector<VFSEntry> &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<uint8_t *>(entries_, filename, [size](VFSBackend *reader, std::string_view path) {
|
||||
return reader->ReadFile(path, size);
|
||||
});
|
||||
}
|
||||
|
||||
bool VFS::GetFileListing(std::string_view path, std::vector<File::FileInfo> *listing, const char *filter) {
|
||||
@@ -74,24 +79,9 @@ bool VFS::GetFileListing(std::string_view path, std::vector<File::FileInfo> *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<bool>(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<bool>(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<bool>(entries_, path, [](VFSBackend *reader, std::string_view path) {
|
||||
return reader->Exists(path);
|
||||
});
|
||||
}
|
||||
@@ -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<VFSEntry> entries_;
|
||||
};
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
+6
-23
@@ -12,29 +12,12 @@ OnScreenDisplay g_OSD;
|
||||
// Effectively forever.
|
||||
constexpr double forever_s = 10000000000.0;
|
||||
|
||||
OnScreenDisplay::~OnScreenDisplay() {
|
||||
std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<void()> 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) {
|
||||
|
||||
+4
-7
@@ -4,6 +4,7 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
|
||||
#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<void()> 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<void()> clickCallback;
|
||||
|
||||
int instanceID;
|
||||
double startTime;
|
||||
|
||||
@@ -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<ManagedTexture>(dc.GetDrawContext(), filename_.c_str(), ImageFileType::DETECT, true);
|
||||
texture_ = std::make_unique<ManagedTexture>(dc.GetDrawContext(), filename_.c_str(), ImageFileType::DETECT);
|
||||
if (!texture_.get())
|
||||
textureFailed_ = true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
+7
-8
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
+13
-39
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
+4
-3
@@ -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
|
||||
|
||||
@@ -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<Path> 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>();
|
||||
}
|
||||
|
||||
Path memc = GetSysDirectory(DIRECTORY_SAVEDATA);
|
||||
|
||||
std::vector<Path> directories;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
-3
@@ -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) {
|
||||
|
||||
+1
-2
@@ -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:
|
||||
|
||||
+7
-14
@@ -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<Path *>(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);
|
||||
|
||||
+6
-6
@@ -90,7 +90,7 @@
|
||||
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/bigobj /await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
@@ -115,7 +115,7 @@
|
||||
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/bigobj /await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
@@ -140,7 +140,7 @@
|
||||
<PreprocessorDefinitions>GOLD;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/bigobj /await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
@@ -166,7 +166,7 @@
|
||||
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/bigobj /await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
@@ -191,7 +191,7 @@
|
||||
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/bigobj /await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
@@ -216,7 +216,7 @@
|
||||
<PreprocessorDefinitions>GOLD;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/bigobj /await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
|
||||
+1
-1
Submodule ext/aemu_postoffice updated: eec2e71424...b0625ecb65.
Reference in new issue
Block a user