comment out bunch of qt things

This commit is contained in:
SimoZ64
2025-04-16 15:20:12 +02:00
parent a27ccf87d8
commit 0cb479dda8
13 changed files with 125 additions and 226 deletions

View File

@@ -1,24 +1,17 @@
#pragma once
#include <JSONUtils.hpp>
#include <QCheckBox>
#include <QSlider>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
class AudioSettings final : public QWidget {
std::unique_ptr<QCheckBox> lockChannels = std::make_unique<QCheckBox>();
std::unique_ptr<QLabel> labelLock = std::make_unique<QLabel>("Lock channels:");
std::unique_ptr<QLabel> labelL = std::make_unique<QLabel>("Volume L");
std::unique_ptr<QLabel> labelR = std::make_unique<QLabel>("Volume R");
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
std::unique_ptr<QHBoxLayout> volLayout = std::make_unique<QHBoxLayout>();
Q_OBJECT
class AudioSettings final {
//std::unique_ptr<QCheckBox> lockChannels = std::make_unique<QCheckBox>();
//std::unique_ptr<QLabel> labelLock = std::make_unique<QLabel>("Lock channels:");
//std::unique_ptr<QLabel> labelL = std::make_unique<QLabel>("Volume L");
//std::unique_ptr<QLabel> labelR = std::make_unique<QLabel>("Volume R");
//std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
//std::unique_ptr<QHBoxLayout> volLayout = std::make_unique<QHBoxLayout>();
//Q_OBJECT
public:
std::unique_ptr<QSlider> volumeL = std::make_unique<QSlider>(Qt::Horizontal),
volumeR = std::make_unique<QSlider>(Qt::Horizontal);
//std::unique_ptr<QSlider> volumeL = std::make_unique<QSlider>(Qt::Horizontal),
// volumeR = std::make_unique<QSlider>(Qt::Horizontal);
explicit AudioSettings(nlohmann::json &);
nlohmann::json &settings;
Q_SIGNALS:
void modified();
};

View File

@@ -121,8 +121,7 @@ add_executable(kaizen
InputSettings.hpp
InputSettings.cpp
Debugger.hpp
Debugger.cpp
CodeModel.hpp)
Debugger.cpp)
target_link_libraries(kaizen PUBLIC SDL3::SDL3 SDL3::SDL3-static cflags::cflags discord-rpc fmt mio nlohmann_json parallel-rdp capstone backend)
target_compile_definitions(kaizen PUBLIC SDL_MAIN_HANDLED)

View File

@@ -1,18 +1,12 @@
#pragma once
#include <JSONUtils.hpp>
#include <QComboBox>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
class CPUSettings final : public QWidget {
std::unique_ptr<QComboBox> cpuTypes = std::make_unique<QComboBox>();
std::unique_ptr<QLabel> label = std::make_unique<QLabel>("CPU type:");
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
Q_OBJECT
class CPUSettings final {
//std::unique_ptr<QComboBox> cpuTypes = std::make_unique<QComboBox>();
//std::unique_ptr<QLabel> label = std::make_unique<QLabel>("CPU type:");
//std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
//Q_OBJECT
public:
explicit CPUSettings(nlohmann::json &);
nlohmann::json &settings;
Q_SIGNALS:
void modified();
};

View File

@@ -1,12 +0,0 @@
#pragma once
#include <QAbstractTableModel>
class CodeModel final : public QAbstractTableModel {
Q_OBJECT
public:
~CodeModel() override = default;
explicit CodeModel(QObject *parent = nullptr) {}
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override { return 1; }
[[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 2; }
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { return {}; }
};

View File

@@ -1,19 +1,6 @@
#pragma once
#include <QDockWidget>
#include <QWidget>
#include <QTreeView>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <CodeModel.hpp>
class Debugger final : public QWidget {
std::unique_ptr<QDockWidget> disassembly = std::make_unique<QDockWidget>(),
cpuState = std::make_unique<QDockWidget>();
std::unique_ptr<QTreeView> codeView = std::make_unique<QTreeView>(disassembly.get()),
registers = std::make_unique<QTreeView>(cpuState.get());
std::unique_ptr<QHBoxLayout> horLayout = std::make_unique<QHBoxLayout>();
std::unique_ptr<QVBoxLayout> verLayout = std::make_unique<QVBoxLayout>();
std::unique_ptr<CodeModel> codeModel = std::make_unique<CodeModel>();
class Debugger final {
public:
Debugger();

View File

@@ -1,53 +1,56 @@
#include <Core.hpp>
#include <EmuThread.hpp>
EmuThread::EmuThread(const std::shared_ptr<n64::Core> &core, QLabel &fps, RenderWidget &renderWidget,
EmuThread::EmuThread(const std::shared_ptr<n64::Core> &core, std::string &fps, RenderWidget &renderWidget,
SettingsWindow &settings) noexcept :
renderWidget(renderWidget), core(core), settings(settings), fps(fps) {}
void EmuThread::run() noexcept {
core->parallel.Init(renderWidget.qtVkInstanceFactory, renderWidget.wsiPlatform, renderWidget.windowInfo,
core->cpu->GetMem().GetRDRAMPtr());
auto lastSample = std::chrono::high_resolution_clock::now();
auto avgFps = 16.667;
auto sampledFps = 0;
static bool oneSecondPassed = false;
fps.setText(fmt::format("{:.2f} FPS", 1000.0 / avgFps).c_str());
while (!isInterruptionRequested()) {
const auto startFrameTime = std::chrono::high_resolution_clock::now();
if (!core->pause) {
core->Run(settings.getVolumeL(), settings.getVolumeR());
}
if (core->render) {
core->parallel.UpdateScreen(core->cpu->GetMem().mmio.vi);
}
const auto endFrameTime = std::chrono::high_resolution_clock::now();
using namespace std::chrono_literals;
const auto frameTimeMs = std::chrono::duration<double>(endFrameTime - startFrameTime) / 1ms;
avgFps += frameTimeMs;
sampledFps++;
if (const auto elapsedSinceLastSample = std::chrono::duration<double>(endFrameTime - lastSample) / 1s;
elapsedSinceLastSample >= 1.0) {
if (!oneSecondPassed) {
oneSecondPassed = true;
continue;
void EmuThread::start() noexcept {
thread = std::thread([this]() {
isRunning = true;
core->parallel.Init(renderWidget.imGuiVkInstanceFactory, renderWidget.wsiPlatform, renderWidget.windowInfo,
core->cpu->GetMem().GetRDRAMPtr());
auto lastSample = std::chrono::high_resolution_clock::now();
auto avgFps = 16.667;
auto sampledFps = 0;
static bool oneSecondPassed = false;
fps = fmt::format("{:.2f} FPS", 1000.0 / avgFps);
while (!interruptionRequested) {
const auto startFrameTime = std::chrono::high_resolution_clock::now();
if (!core->pause) {
core->Run(settings.getVolumeL(), settings.getVolumeR());
}
if (core->render) {
core->parallel.UpdateScreen(core->cpu->GetMem().mmio.vi);
}
const auto endFrameTime = std::chrono::high_resolution_clock::now();
using namespace std::chrono_literals;
const auto frameTimeMs = std::chrono::duration<double>(endFrameTime - startFrameTime) / 1ms;
avgFps += frameTimeMs;
sampledFps++;
if (const auto elapsedSinceLastSample = std::chrono::duration<double>(endFrameTime - lastSample) / 1s;
elapsedSinceLastSample >= 1.0) {
if (!oneSecondPassed) {
oneSecondPassed = true;
continue;
}
lastSample = endFrameTime;
avgFps /= sampledFps;
sampledFps = 0;
fps = fmt::format("{:.2f} FPS", 1000.0 / avgFps);
}
lastSample = endFrameTime;
avgFps /= sampledFps;
sampledFps = 0;
fps.setText(fmt::format("{:.2f} FPS", 1000.0 / avgFps).c_str());
}
}
SetRender(false);
Stop();
SetRender(false);
Stop();
isRunning = false;
});
}
void EmuThread::TogglePause() const noexcept {

View File

@@ -12,14 +12,18 @@ class EmuThread final {
RenderWidget &renderWidget;
public:
explicit EmuThread(const std::shared_ptr<n64::Core> &, RenderWidget &, SettingsWindow &) noexcept;
explicit EmuThread(const std::shared_ptr<n64::Core> &, std::string &, RenderWidget &, SettingsWindow &) noexcept;
void run() noexcept;
void start() noexcept;
void TogglePause() const noexcept;
void SetRender(bool v) const noexcept;
void Reset() const noexcept;
void Stop() const noexcept;
void requestInterruption() { interruptionRequested = true; }
bool interruptionRequested = false, isRunning = false;
std::shared_ptr<n64::Core> core;
SettingsWindow &settings;
std::string fps;
std::thread thread;
};

View File

@@ -1,14 +1,8 @@
#pragma once
#include <JSONUtils.hpp>
#include <QLabel>
#include <QPushButton>
#include <QWidget>
#include <QKeyEvent>
#include <QVBoxLayout>
#include <QComboBox>
#include <QTimer>
#include <unordered_map>
class InputSettings final : public QWidget {
class InputSettings final {
bool grabbing = false;
int whichGrabbing = -1;
@@ -17,29 +11,26 @@ class InputSettings final : public QWidget {
std::unordered_map<u32, std::string> gamepadIndexes{};
std::unique_ptr<QHBoxLayout> AB = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> ZStart = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> LR = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> DupDdown = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> DleftDright = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> CupCdown = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> CleftCright = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> AupAdown = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> AleftAright = std::make_unique<QHBoxLayout>();
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
std::array<std::unique_ptr<QPushButton>, 18> kbButtons;
std::array<std::unique_ptr<QLabel>, 18> buttonLabels;
std::unique_ptr<QHBoxLayout> deviceComboBoxLayout = std::make_unique<QHBoxLayout>();
QTimer refresh, pollGamepad;
std::unique_ptr<QLabel> devicesLabel = std::make_unique<QLabel>("Device:");
std::unique_ptr<QComboBox> devices = std::make_unique<QComboBox>();
Q_OBJECT
//std::unique_ptr<QHBoxLayout> AB = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> ZStart = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> LR = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> DupDdown = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> DleftDright = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> CupCdown = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> CleftCright = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> AupAdown = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QHBoxLayout> AleftAright = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
//std::array<std::unique_ptr<QPushButton>, 18> kbButtons;
//std::array<std::unique_ptr<QLabel>, 18> buttonLabels;
//std::unique_ptr<QHBoxLayout> deviceComboBoxLayout = std::make_unique<QHBoxLayout>();
//QTimer refresh, pollGamepad;
//std::unique_ptr<QLabel> devicesLabel = std::make_unique<QLabel>("Device:");
//std::unique_ptr<QComboBox> devices = std::make_unique<QComboBox>();
//Q_OBJECT
public:
bool selectedDeviceIsNotKeyboard = false;
explicit InputSettings(nlohmann::json &);
nlohmann::json &settings;
void keyPressEvent(QKeyEvent *) override;
std::array<Qt::Key, 18> GetMappedKeys() const;
Q_SIGNALS:
void modified();
//std::array<Qt::Key, 18> GetMappedKeys() const;
};

View File

@@ -1,9 +1,5 @@
#include <Core.hpp>
#include <KaizenQt.hpp>
#include <QApplication>
#include <QDropEvent>
#include <QMessageBox>
#include <QMimeData>
namespace fs = std::filesystem;
@@ -44,17 +40,6 @@ void KaizenQt::ConnectMainWindowSignalsToSlots() noexcept {
connect(mainWindow.get(), &MainWindow::Pause, emuThread.get(), &EmuThread::TogglePause);
}
void KaizenQt::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void KaizenQt::dropEvent(QDropEvent *event) {
const auto path = event->mimeData()->urls()[0].toLocalFile();
LoadROM(path);
}
void KaizenQt::LoadROM(const QString &path) const noexcept {
mainWindow->actionPause->setEnabled(true);
mainWindow->actionReset->setEnabled(true);
@@ -69,8 +54,7 @@ void KaizenQt::LoadROM(const QString &path) const noexcept {
void KaizenQt::Quit() const noexcept {
if (emuThread) {
emuThread->requestInterruption();
while (emuThread->isRunning())
;
while (emuThread->isRunning) {}
}
QApplication::quit();
}

View File

@@ -4,23 +4,7 @@
#include <MainWindow.hpp>
#include <SettingsWindow.hpp>
#include <log.hpp>
enum class CompositorCategory { Windows, MacOS, XCB, Wayland };
static CompositorCategory GetOSCompositorCategory() {
const QString platform_name = QGuiApplication::platformName();
if (platform_name == QStringLiteral("windows"))
return CompositorCategory::Windows;
if (platform_name == QStringLiteral("xcb"))
return CompositorCategory::XCB;
if (platform_name == QStringLiteral("wayland") || platform_name == QStringLiteral("wayland-egl"))
return CompositorCategory::Wayland;
if (platform_name == QStringLiteral("cocoa") || platform_name == QStringLiteral("ios"))
return CompositorCategory::MacOS;
Util::error("Unknown Qt platform!");
return CompositorCategory::Windows;
}
#include <memory>
class KaizenQt {
public:

View File

@@ -1,41 +1,29 @@
#pragma once
#include <QApplication>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QKeyEvent>
#include <QMessageBox>
#include <QSlider>
#include <QMenu>
#include <QMenuBar>
#include <QStatusBar>
#include <RenderWidget.hpp>
#include <Debugger.hpp>
class MainWindow final : public QMainWindow {
Q_OBJECT
class MainWindow final {
public:
explicit MainWindow(const std::shared_ptr<n64::Core> &) noexcept;
std::unique_ptr<QAction> actionOpenDebuggerWindow{};
std::unique_ptr<QAction> actionAbout{};
std::unique_ptr<QAction> actionOpen{};
std::unique_ptr<QAction> actionExit{};
std::unique_ptr<QAction> actionPause{};
std::unique_ptr<QAction> actionReset{};
std::unique_ptr<QAction> actionStop{};
std::unique_ptr<QAction> actionSettings{};
std::unique_ptr<QWidget> centralwidget{};
std::unique_ptr<QVBoxLayout> verticalLayout{};
std::unique_ptr<RenderWidget> vulkanWidget{};
std::unique_ptr<QMenuBar> menubar{};
std::unique_ptr<QMenu> menuFile{};
std::unique_ptr<QMenu> menuEmulation{};
std::unique_ptr<QMenu> menuTools{};
std::unique_ptr<QMenu> menuAbout{};
std::unique_ptr<QStatusBar> statusbar{};
std::unique_ptr<QLabel> fpsCounter{};
//std::unique_ptr<QAction> actionOpenDebuggerWindow{};
//std::unique_ptr<QAction> actionAbout{};
//std::unique_ptr<QAction> actionOpen{};
//std::unique_ptr<QAction> actionExit{};
//std::unique_ptr<QAction> actionPause{};
//std::unique_ptr<QAction> actionReset{};
//std::unique_ptr<QAction> actionStop{};
//std::unique_ptr<QAction> actionSettings{};
//std::unique_ptr<QWidget> centralwidget{};
//std::unique_ptr<QVBoxLayout> verticalLayout{};
//std::unique_ptr<RenderWidget> vulkanWidget{};
//std::unique_ptr<QMenuBar> menubar{};
//std::unique_ptr<QMenu> menuFile{};
//std::unique_ptr<QMenu> menuEmulation{};
//std::unique_ptr<QMenu> menuTools{};
//std::unique_ptr<QMenu> menuAbout{};
//std::unique_ptr<QStatusBar> statusbar{};
//std::unique_ptr<QLabel> fpsCounter{};
private:
void Retranslate();
@@ -43,10 +31,9 @@ private:
bool textPauseToggle = false;
Q_SIGNALS:
void OpenDebugger();
void OpenSettings();
void OpenROM(const QString &rom_file);
void OpenROM(const std::string &rom_file);
void Exit();
void Reset();
void Stop();

View File

@@ -1,5 +1,4 @@
#pragma once
#undef signals
#include <ParallelRDPWrapper.hpp>
#include <SDL3/SDL.h>
#include <SDL3/SDL_vulkan.h>

View File

@@ -2,43 +2,29 @@
#include <AudioSettings.hpp>
#include <CPUSettings.hpp>
#include <InputSettings.hpp>
#include <QFileIconProvider>
#include <QPushButton>
#include <QTabWidget>
#include <QWidget>
#include <QButtonGroup>
#include <QFileDialog>
#include <QGroupBox>
#include <QVBoxLayout>
#include <memory>
class SettingsWindow final : public QWidget {
std::unique_ptr<QPushButton> cancel = std::make_unique<QPushButton>("Cancel");
std::unique_ptr<QPushButton> apply = std::make_unique<QPushButton>("Apply");
std::unique_ptr<QFileIconProvider> iconProv = std::make_unique<QFileIconProvider>();
std::unique_ptr<QPushButton> folderBtn = std::make_unique<QPushButton>(iconProv->icon(QFileIconProvider::Folder), "");
std::unique_ptr<QLabel> folderLabelPrefix = std::make_unique<QLabel>("Save files' path: ");
std::unique_ptr<QLabel> folderLabel;
std::unique_ptr<QHBoxLayout> generalLayout = std::make_unique<QHBoxLayout>();
std::unique_ptr<QVBoxLayout> generalLayoutV = std::make_unique<QVBoxLayout>();
std::unique_ptr<QTabWidget> tabs = std::make_unique<QTabWidget>();
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
std::unique_ptr<QHBoxLayout> buttonsLayout = std::make_unique<QHBoxLayout>();
Q_OBJECT
class SettingsWindow final {
//std::unique_ptr<QPushButton> cancel = std::make_unique<QPushButton>("Cancel");
//std::unique_ptr<QPushButton> apply = std::make_unique<QPushButton>("Apply");
//std::unique_ptr<QFileIconProvider> iconProv = std::make_unique<QFileIconProvider>();
//std::unique_ptr<QPushButton> folderBtn = std::make_unique<QPushButton>(iconProv->icon(QFileIconProvider::Folder), "");
//std::unique_ptr<QLabel> folderLabelPrefix = std::make_unique<QLabel>("Save files' path: ");
//std::unique_ptr<QLabel> folderLabel;
//std::unique_ptr<QHBoxLayout> generalLayout = std::make_unique<QHBoxLayout>();
//std::unique_ptr<QVBoxLayout> generalLayoutV = std::make_unique<QVBoxLayout>();
//std::unique_ptr<QTabWidget> tabs = std::make_unique<QTabWidget>();
//std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
//std::unique_ptr<QHBoxLayout> buttonsLayout = std::make_unique<QHBoxLayout>();
public:
SettingsWindow();
void hideEvent(QHideEvent *event) override { emit gotClosed(); }
void showEvent(QShowEvent *event) override { emit gotOpened(); }
[[nodiscard]] float getVolumeL() const { return static_cast<float>(audioSettings->volumeL->value()) / 100.f; }
[[nodiscard]] float getVolumeR() const { return static_cast<float>(audioSettings->volumeR->value()) / 100.f; }
std::array<Qt::Key, 18> keyMap{};
//std::array<ImGui::Key, 18> keyMap{};
nlohmann::json settings;
std::unique_ptr<CPUSettings> cpuSettings{};
std::unique_ptr<AudioSettings> audioSettings{};
std::unique_ptr<InputSettings> inputSettings{};
std::unique_ptr<QWidget> generalSettings{};
Q_SIGNALS:
void gotOpened();
void gotClosed();
void regrabKeyboard();
//std::unique_ptr<QWidget> generalSettings{};
};