mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-25 23:48:29 +00:00
supporting scale correctly
This commit is contained in:
@@ -21,14 +21,15 @@ namespace ComSquare::Debugger
|
||||
_ui(),
|
||||
_ppu(ppu),
|
||||
_ramTileRenderer(ppu.vram, ppu.cgram),
|
||||
_currentRendererSize(0, 0)
|
||||
_currentRendererSize(0, 0),
|
||||
_widgetScale(2, 2)
|
||||
{
|
||||
this->_ui.setupUi(this->_window);
|
||||
//this->_qtSfmlRenderer(this->_ui.widget_sfml, 30);
|
||||
//this->_renderer = std::make_unique<Renderer::QtSFMLTileRenderer>(this->_ui.widget_sfml, 30);;
|
||||
this->_renderer = std::make_unique<Renderer::QtSFMLTileRenderer>(this->_ui.widget_sfml, 30);
|
||||
//this->_renderer = nullptr;
|
||||
// this->_sfWidget = std::make_unique<Renderer::QtSFMLTileRenderer>(this->_ui.widget_sfml);
|
||||
// this->_sfWidget = std::make_unique<Renderer::QtSFMLTileRenderer>(this->_ui.widget_sfml);
|
||||
QMainWindow::connect(this->_ui.NbColumns, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
[this](int nb) -> void { this->setNbColumns(nb); });
|
||||
QMainWindow::connect(this->_ui.ByteSize, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
@@ -43,6 +44,7 @@ namespace ComSquare::Debugger
|
||||
// used to setup ui restrictions
|
||||
this->setBpp(this->getBpp());
|
||||
this->_window->show();
|
||||
this->_renderer->setScale(this->_widgetScale.y, this->_widgetScale.x);
|
||||
this->internalUpdate();
|
||||
}
|
||||
|
||||
@@ -66,18 +68,15 @@ namespace ComSquare::Debugger
|
||||
{
|
||||
this->_ui.PaletteIndex->setDisabled(bpp > 4);
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
this->_ui.PaletteIndex->setValue(0);
|
||||
case 8: this->_ui.PaletteIndex->setValue(0);
|
||||
break;
|
||||
case 4:
|
||||
this->_ui.PaletteIndex->setMaximum(15);
|
||||
case 4: this->_ui.PaletteIndex->setMaximum(15);
|
||||
if (this->_ui.PaletteIndex->value() > 15) {
|
||||
this->_ui.PaletteIndex->setValue(15);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
bpp = 2;
|
||||
default: bpp = 2;
|
||||
this->_ui.PaletteIndex->setMaximum(63);
|
||||
break;
|
||||
}
|
||||
@@ -122,8 +121,10 @@ namespace ComSquare::Debugger
|
||||
|
||||
this->_currentRendererSize = {static_cast<unsigned int>(this->_ramTileRenderer.buffer.at(0).size()),
|
||||
static_cast<unsigned int>(this->_ramTileRenderer.buffer.size())};
|
||||
this->_renderer->setSize(this->_currentRendererSize.x, this->_currentRendererSize.y);
|
||||
this->_ui.widget_sfml->setMinimumSize(this->_currentRendererSize.x, this->_currentRendererSize.y);
|
||||
this->_renderer->setSize(this->_currentRendererSize.y * this->_widgetScale.y,
|
||||
this->_currentRendererSize.x * this->_widgetScale.x);
|
||||
this->_ui.widget_sfml->setMinimumSize(this->_currentRendererSize.x * this->_widgetScale.x,
|
||||
this->_currentRendererSize.y * this->_widgetScale.y);
|
||||
}
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
@@ -149,14 +150,10 @@ namespace ComSquare::Debugger
|
||||
void TileViewer::_bppChangeUIHandler(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 0:
|
||||
return this->setBpp(2);
|
||||
case 1:
|
||||
return this->setBpp(4);
|
||||
case 2:
|
||||
return this->setBpp(8);
|
||||
default:
|
||||
throw std::runtime_error("Invalid Index");
|
||||
case 0: return this->setBpp(2);
|
||||
case 1: return this->setBpp(4);
|
||||
case 2: return this->setBpp(8);
|
||||
default: throw std::runtime_error("Invalid Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ namespace ComSquare::Debugger
|
||||
void _bppChangeUIHandler(int index);
|
||||
//! @brief The size of the renderer to known if resize is necessary
|
||||
Vector2<unsigned> _currentRendererSize;
|
||||
//! @brief Factor used to "see easier the tiles in the debugger"
|
||||
Vector2<float> _widgetScale;
|
||||
|
||||
public:
|
||||
//! @brief ctor
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ComSquare
|
||||
//! @brief Set a size or resize the Renderer drawing size
|
||||
//! @param height The new height of the renderer in pixels
|
||||
//! @param width The new width of the renderer in pixels
|
||||
virtual void setSize(unsigned width, unsigned height) = 0;
|
||||
virtual void setSize(unsigned height, unsigned width) = 0;
|
||||
|
||||
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
|
||||
//! @param horizontalPosition horizontal index.
|
||||
@@ -36,6 +36,11 @@ namespace ComSquare
|
||||
//! @param maxFPS The number of FPS you aim to run on.
|
||||
virtual void createWindow(SNES &snes, int maxFPS) = 0;
|
||||
|
||||
//! @brief Set the scale of the renderer (it will scale all pixels)
|
||||
//! @param width The scale factor for width
|
||||
//! @param height The scale factor for height
|
||||
virtual void setScale(float height, float width) = 0;
|
||||
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
virtual void playAudio(std::span<int16_t> samples) = 0;
|
||||
|
||||
@@ -48,9 +48,14 @@ namespace ComSquare::Renderer
|
||||
this->_window->setWindowTitle((newWindowName + " - ComSquare").c_str());
|
||||
}
|
||||
|
||||
void QtSFML::setSize(unsigned int width, unsigned int height)
|
||||
void QtSFML::setSize(unsigned int height, unsigned int width)
|
||||
{
|
||||
this->_sfWidget->setSize(width, height);
|
||||
this->_sfWidget->setSize(height, width);
|
||||
}
|
||||
|
||||
void QtSFML::setScale(float height, float width)
|
||||
{
|
||||
this->_sfWidget->setScale(height, width);
|
||||
}
|
||||
|
||||
QtFullSFML::QtFullSFML(SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate) :
|
||||
|
||||
@@ -68,13 +68,18 @@ namespace ComSquare::Renderer
|
||||
//! @brief Set a size or resize the Renderer drawing size
|
||||
//! @param height The new height of the renderer in pixels
|
||||
//! @param width The new width of the renderer in pixels
|
||||
void setSize(unsigned width, unsigned height) override;
|
||||
void setSize(unsigned height, unsigned width) override;
|
||||
//! @brief Set the scale of the renderer (it will scale all pixels)
|
||||
//! @param width The scale factor for width
|
||||
//! @param height The scale factor for height
|
||||
void setScale(float height, float width) override;
|
||||
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
|
||||
//! @param X horizontal index.
|
||||
//! @param Y vertical index.
|
||||
//! @param rgba The color of the pixel.
|
||||
void putPixel(unsigned verticalPosition, unsigned horizontalPosition, uint32_t rgba) override;
|
||||
//! @brief This function doesn't do anything because QT internally handle drawing to the screen.
|
||||
//! @brief Render the buffer to the window
|
||||
//! @warning This function doesn't do anything because QT internally handle drawing to the screen.
|
||||
void drawScreen() override;
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
|
||||
@@ -53,9 +53,9 @@ namespace ComSquare::Renderer
|
||||
void QtWidgetSFML::_onInit()
|
||||
{}
|
||||
|
||||
void QtWidgetSFML::setSize(unsigned int width, unsigned int height)
|
||||
void QtWidgetSFML::setSize(unsigned int height, unsigned int width)
|
||||
{
|
||||
SFRenderer::setSize(width, height);
|
||||
SFRenderer::setSize(height, width);
|
||||
QWidget::resize(static_cast<int>(width), static_cast<int>(height));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ComSquare::Renderer
|
||||
//! @brief Set a size or resize the Renderer drawing size
|
||||
//! @param height The new height of the renderer in pixels
|
||||
//! @param width The new width of the renderer in pixels
|
||||
void setSize(unsigned width, unsigned height) override;
|
||||
void setSize(unsigned height, unsigned width) override;
|
||||
private:
|
||||
//! @brief Function called when this widget is created.
|
||||
virtual void _onInit();
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace ComSquare::Renderer
|
||||
}
|
||||
}
|
||||
|
||||
void SFRenderer::setSize(unsigned int width, unsigned int height)
|
||||
void SFRenderer::setSize(unsigned int height, unsigned int width)
|
||||
{
|
||||
this->_renderWindow.setSize({width, height});
|
||||
sf::FloatRect visibleArea(0, 0, width, height);
|
||||
@@ -94,4 +94,9 @@ namespace ComSquare::Renderer
|
||||
delete[] this->_pixelBuffer;
|
||||
this->_pixelBuffer = new sf::Color[height * width];
|
||||
}
|
||||
|
||||
void SFRenderer::setScale(float height, float width)
|
||||
{
|
||||
this->_sprite.setScale(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,11 @@ namespace ComSquare::Renderer
|
||||
//! @brief Set a size or resize the Renderer drawing size
|
||||
//! @param height The new height of the renderer in pixels
|
||||
//! @param width The new width of the renderer in pixels
|
||||
void setSize(unsigned width, unsigned height) override;
|
||||
void setSize(unsigned height, unsigned width) override;
|
||||
//! @brief Set the scale of the renderer (it will scale all pixels)
|
||||
//! @param width The scale factor for width
|
||||
//! @param height The scale factor for height
|
||||
void setScale(float height, float width) override;
|
||||
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
|
||||
//! @param horizontalPosition horizontal index.
|
||||
//! @param verticalPosition vertical index.
|
||||
|
||||
Reference in New Issue
Block a user