From 74045c0d995a0a3f1c41d42d26b70cf0c8a6bbaf Mon Sep 17 00:00:00 2001 From: Anonymus Raccoon Date: Sun, 16 Feb 2020 22:54:43 +0100 Subject: [PATCH] Cleaning up and making the debugger resize well --- CMakeLists.txt | 2 - sources/Debugger/DebugCpu.hpp | 1 - sources/Renderer/QtRenderer/QtSFML.cpp | 13 +- sources/Renderer/QtRenderer/QtSFML.hpp | 6 +- sources/Renderer/QtRenderer/QtWindow.cpp | 21 -- sources/Renderer/QtRenderer/QtWindow.hpp | 35 --- ui/cpu.ui | 277 +++++++++++------------ 7 files changed, 141 insertions(+), 214 deletions(-) delete mode 100644 sources/Renderer/QtRenderer/QtWindow.cpp delete mode 100644 sources/Renderer/QtRenderer/QtWindow.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dfd570a..4e3bd76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,8 +131,6 @@ add_executable(ComSquare sources/Renderer/QtRenderer/QtWidgetSFML.hpp ui/cpu.ui resources/appResources.qrc - sources/Renderer/QtRenderer/QtWindow.cpp - sources/Renderer/QtRenderer/QtWindow.hpp sources/Utility/Utility.hpp) target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED) diff --git a/sources/Debugger/DebugCpu.hpp b/sources/Debugger/DebugCpu.hpp index 7b6959a..66184a9 100644 --- a/sources/Debugger/DebugCpu.hpp +++ b/sources/Debugger/DebugCpu.hpp @@ -8,7 +8,6 @@ #include "../CPU/CPU.hpp" #include "../Renderer/SFRenderer.hpp" #include "../SNES.hpp" -#include "../Renderer/QtRenderer/QtWindow.hpp" #include "../../ui/ui_cpu.h" namespace ComSquare::Debugger diff --git a/sources/Renderer/QtRenderer/QtSFML.cpp b/sources/Renderer/QtRenderer/QtSFML.cpp index 5229e0c..01707de 100644 --- a/sources/Renderer/QtRenderer/QtSFML.cpp +++ b/sources/Renderer/QtRenderer/QtSFML.cpp @@ -16,14 +16,17 @@ namespace ComSquare::Renderer { QtSFML::QtSFML(unsigned int h, unsigned int w) : - QtWindow(h, w), _sfWidget(nullptr) - { } + _window(), _sfWidget(nullptr) + { + this->_window.resize(w, h); + } void QtSFML::createWindow(SNES &snes, int maxFPS) { this->setWindowName(snes.cartridge->header.gameName); - this->_sfWidget = std::make_unique(snes, &_frame, QPoint(0, 0), QSize(this->_width, this->_height), maxFPS); - this->_sfWidget->show(); + this->_sfWidget = std::make_unique(snes, &_window, QPoint(0, 0), QSize(this->_window.width(), this->_window.height()), maxFPS); + this->_sfWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + this->_window.show(); } void QtSFML::putPixel(unsigned y, unsigned x, uint32_t rgba) @@ -35,7 +38,7 @@ namespace ComSquare::Renderer void QtSFML::setWindowName(std::string &newWindowName) { - QtWindow::setWindowName(newWindowName); + this->_window.setWindowTitle((newWindowName + " - ComSquare").c_str()); } QtFullSFML::QtFullSFML(SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate) : diff --git a/sources/Renderer/QtRenderer/QtSFML.hpp b/sources/Renderer/QtRenderer/QtSFML.hpp index d802a31..ff529d8 100644 --- a/sources/Renderer/QtRenderer/QtSFML.hpp +++ b/sources/Renderer/QtRenderer/QtSFML.hpp @@ -8,10 +8,10 @@ #include #include #include +#include #include "../IRenderer.hpp" #include "../SFRenderer.hpp" #include "QtWidgetSFML.hpp" -#include "QtWindow.hpp" namespace ComSquare::Renderer { @@ -29,8 +29,10 @@ namespace ComSquare::Renderer }; //! @brief A SFML renderer inside a QT window. - class QtSFML : public IRenderer, public QtWindow { + class QtSFML : public IRenderer { private: + //! @brief The main window that the app reside on. + QMainWindow _window; //! @brief The SFML widget. std::unique_ptr _sfWidget = nullptr; public: diff --git a/sources/Renderer/QtRenderer/QtWindow.cpp b/sources/Renderer/QtRenderer/QtWindow.cpp deleted file mode 100644 index dcf0809..0000000 --- a/sources/Renderer/QtRenderer/QtWindow.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -// Created by anonymus-raccoon on 2/16/20. -// - -#include "QtWindow.hpp" -#include - -namespace ComSquare::Renderer -{ - QtWindow::QtWindow(unsigned int height, unsigned int width) : - _frame(), _width(width), _height(height) - { - this->_frame.setWindowIcon(QIcon(":/resources/Logo.png")); - this->_frame.show(); - } - - void QtWindow::setWindowName(std::string &newWindowName) - { - this->_frame.setWindowTitle((newWindowName + " - ComSquare").c_str()); - } -} \ No newline at end of file diff --git a/sources/Renderer/QtRenderer/QtWindow.hpp b/sources/Renderer/QtRenderer/QtWindow.hpp deleted file mode 100644 index 2e726d7..0000000 --- a/sources/Renderer/QtRenderer/QtWindow.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Created by anonymus-raccoon on 2/16/20. -// - -#ifndef COMSQUARE_QTWINDOW_HPP -#define COMSQUARE_QTWINDOW_HPP - - -#include - -namespace ComSquare::Renderer -{ - class QtWindow { - protected: - //! @brief The SFML frame. - QFrame _frame; - //! @brief The _width of the window. - unsigned int _width; - //! @brief The _height of the window. - unsigned int _height; - public: - //! @brief Set a new name to the window, if there is already a name it will be overwrite. - //! @param newWindowName new title for the window. - void setWindowName(std::string &newWindowName); - //! @brief Constructor that return a SFML renderer inside a QT window. - //! @param height _height of the window. - //! @param width _width of the window. - QtWindow(unsigned int height, unsigned int width); - QtWindow(const QtWindow &) = delete; - QtWindow &operator=(const QtWindow &) = delete; - ~QtWindow() = default; - }; -} - -#endif //COMSQUARE_QTWINDOW_HPP diff --git a/ui/cpu.ui b/ui/cpu.ui index d810379..2e0e1bd 100644 --- a/ui/cpu.ui +++ b/ui/cpu.ui @@ -6,8 +6,8 @@ 0 0 - 422 - 399 + 420 + 405 @@ -21,152 +21,133 @@ false - - - - 220 - 30 - 200 - 305 - - - - - - - 220 - 0 - 200 - 25 - - - - Instructions History - - - Qt::AlignCenter - - - - - - 0 - 0 - 211 - 361 - - - - - - - Accumulator - - - - - - - - - - - - - - Program Bank - - - - - - - - - - Program Counter - - - - - - - - - - Direct Bank - - - - - - - - - - Direct Page - - - - - - - - - - Stack Pointer - - - - - - - - - - X Index - - - - - - - - - - Y Index - - - - - - - - - - Flags - - - - - - - - - - Emulation mode - - - - - - - Qt::RightToLeft - - - - - + + + + + + + Accumulator + + + + + + + + + + + + + + Program Bank + + + + + + + + + + Program Counter + + + + + + + + + + Direct Bank + + + + + + + + + + Direct Page + + + + + + + + + + Stack Pointer + + + + + + + + + + X Index + + + + + + + + + + Y Index + + + + + + + + + + Flags + + + + + + + + + + Emulation mode + + + + + + + Qt::RightToLeft + + + + + + + + + Instructions History + + + Qt::AlignCenter + + + + + + +