Merge branch 'master' into fastmem

This commit is contained in:
wheremyfoodat 2024-12-02 19:30:34 +02:00
commit 5811bc4c88
25 changed files with 534 additions and 35 deletions

View file

@ -3,6 +3,7 @@
#include "audio/dsp_core.hpp"
#include "renderer.hpp"
#include "frontend_settings.hpp"
struct AudioDeviceConfig {
float volumeRaw = 1.0f;
@ -86,8 +87,9 @@ struct EmulatorConfig {
WindowSettings windowSettings;
AudioDeviceConfig audioDeviceConfig;
FrontendSettings frontendSettings;
EmulatorConfig(const std::filesystem::path& path);
void load();
void save();
};
};

View file

@ -17,6 +17,8 @@ namespace Discord {
void init();
void update(RPCStatus status, const std::string& title);
void stop();
bool running() const { return enabled; }
};
} // namespace Discord

View file

@ -118,6 +118,9 @@ class Emulator {
void setOutputSize(u32 width, u32 height) { gpu.setOutputSize(width, height); }
void deinitGraphicsContext() { gpu.deinitGraphicsContext(); }
// Reloads some settings that require special handling, such as audio enable
void reloadSettings();
EmulatorConfig& getConfig() { return config; }
Cheats& getCheats() { return cheats; }
ServiceManager& getServiceManager() { return kernel.getServiceManager(); }

View file

@ -0,0 +1,32 @@
#pragma once
#include <string>
// Some UI settings that aren't fully frontend-dependent. Note: Not all frontends will support the same settings.
// Note: Any enums should ideally be ordered in the same order we want to show them in UI dropdown menus, so that we can cast indices to enums
// directly.
struct FrontendSettings {
enum class Theme : int {
System = 0,
Light = 1,
Dark = 2,
GreetingsCat = 3,
Cream = 4,
};
// Different panda-themed window icons
enum class WindowIcon : int {
Rpog = 0,
Rsyn = 1,
Rnap = 2,
Rcow = 3,
};
Theme theme = Theme::Dark;
WindowIcon icon = WindowIcon::Rpog;
static Theme themeFromString(std::string inString);
static const char* themeToString(Theme theme);
static WindowIcon iconFromString(std::string inString);
static const char* iconToString(WindowIcon icon);
};

View file

@ -1,30 +1,56 @@
#pragma once
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QDialog>
#include <QListWidget>
#include <QPalette>
#include <QStackedWidget>
#include <QTextEdit>
#include <QWidget>
#include <QtWidgets>
#include <array>
#include <functional>
#include <utility>
#include "emulator.hpp"
#include "frontend_settings.hpp"
class ConfigWindow : public QDialog {
Q_OBJECT
private:
enum class Theme : int {
System = 0,
Light = 1,
Dark = 2,
GreetingsCat = 3,
Cream = 4,
};
using ConfigCallback = std::function<void()>;
using MainWindowCallback = std::function<QWidget*()>;
Theme currentTheme;
QComboBox* themeSelect = nullptr;
using Theme = FrontendSettings::Theme;
using WindowIcon = FrontendSettings::WindowIcon;
void setTheme(Theme theme);
QTextEdit* helpText = nullptr;
QListWidget* widgetList = nullptr;
QStackedWidget* widgetContainer = nullptr;
static constexpr size_t settingWidgetCount = 6;
std::array<QString, settingWidgetCount> helpTexts;
// The config class holds a copy of the emulator config which it edits and sends
// over to the emulator in a thread-safe manner
EmulatorConfig config;
ConfigCallback updateConfig;
MainWindowCallback getMainWindow;
void addWidget(QWidget* widget, QString title, QString icon, QString helpText);
void setTheme(FrontendSettings::Theme theme);
void setIcon(FrontendSettings::WindowIcon icon);
public:
ConfigWindow(QWidget* parent = nullptr);
ConfigWindow(ConfigCallback configCallback, MainWindowCallback windowCallback, const EmulatorConfig& config, QWidget* parent = nullptr);
~ConfigWindow();
EmulatorConfig& getConfig() { return config; }
private:
Emulator* emu;
};

View file

@ -51,6 +51,7 @@ class MainWindow : public QMainWindow {
ReleaseTouchscreen,
ReloadUbershader,
SetScreenSize,
UpdateConfig,
};
// Tagged union representing our message queue messages

View file

@ -23,6 +23,9 @@ namespace Renderdoc {
// Sets output directory for captures
void setOutputDir(const std::string& path, const std::string& prefix);
// Returns whether Renderdoc has been loaded
bool isLoaded();
// Returns whether we've compiled with Renderdoc support
static constexpr bool isSupported() { return true; }
} // namespace Renderdoc
@ -34,6 +37,7 @@ namespace Renderdoc {
static void triggerCapture() { Helpers::panic("Tried to trigger a Renderdoc capture while support for renderdoc is disabled"); }
static void setOutputDir(const std::string& path, const std::string& prefix) {}
static constexpr bool isSupported() { return false; }
static constexpr bool isLoaded() { return false; }
} // namespace Renderdoc
#endif