fillRect moved

This commit is contained in:
2025-12-19 18:22:26 +01:00
parent adf418dff9
commit 64fce596ce
2 changed files with 18 additions and 15 deletions

View File

@ -0,0 +1,16 @@
#pragma once
#include <SDL3/SDL.h>
namespace RenderPrimitives {
inline void fillRect(SDL_Renderer* renderer, float x, float y, float w, float h, SDL_Color color) {
if (!renderer) {
return;
}
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
SDL_FRect rect{x, y, w, h};
SDL_RenderFillRect(renderer, &rect);
}
} // namespace RenderPrimitives

View File

@ -42,6 +42,7 @@
#include "states/LoadingManager.h" #include "states/LoadingManager.h"
#include "utils/ImagePathResolver.h" #include "utils/ImagePathResolver.h"
#include "graphics/renderers/GameRenderer.h" #include "graphics/renderers/GameRenderer.h"
#include "graphics/renderers/RenderPrimitives.h"
#include "core/Config.h" #include "core/Config.h"
#include "core/Settings.h" #include "core/Settings.h"
#include "ui/MenuLayout.h" #include "ui/MenuLayout.h"
@ -64,12 +65,6 @@ static constexpr int WELL_H = Game::ROWS * Game::TILE;
// Bit 0 = (x=0,y=0), Bit 1 = (1,0) ... Bit 15 = (3,3) // Bit 0 = (x=0,y=0), Bit 1 = (1,0) ... Bit 15 = (3,3)
// Shapes & game logic now in Game.cpp // Shapes & game logic now in Game.cpp
// (removed inline shapes)
// Piece struct now in Game.h
// Game struct replaced by Game class
static const std::array<SDL_Color, PIECE_COUNT + 1> COLORS = {{ static const std::array<SDL_Color, PIECE_COUNT + 1> COLORS = {{
SDL_Color{20, 20, 26, 255}, // 0 empty SDL_Color{20, 20, 26, 255}, // 0 empty
SDL_Color{0, 255, 255, 255}, // I SDL_Color{0, 255, 255, 255}, // I
@ -90,13 +85,6 @@ static std::atomic<int> g_loadedTasks{0};
static std::string g_currentLoadingFile; static std::string g_currentLoadingFile;
static std::mutex g_currentLoadingMutex; static std::mutex g_currentLoadingMutex;
static void drawRect(SDL_Renderer *r, float x, float y, float w, float h, SDL_Color c)
{
SDL_SetRenderDrawColor(r, c.r, c.g, c.b, c.a);
SDL_FRect fr{x, y, w, h};
SDL_RenderFillRect(r, &fr);
}
// Hover state for level popup ( -1 = none, 0..19 = hovered level ) // Hover state for level popup ( -1 = none, 0..19 = hovered level )
// Now managed by LevelSelectorState // Now managed by LevelSelectorState
@ -129,7 +117,6 @@ static bool isNewHighScore = false;
static std::string playerName = ""; static std::string playerName = "";
static bool helpOverlayPausedGame = false; static bool helpOverlayPausedGame = false;
// Fireworks implementation moved to app/Fireworks.{h,cpp}
int main(int, char **) int main(int, char **)
{ {
@ -1327,7 +1314,7 @@ int main(int, char **)
float contentOffsetY = (winH - contentH) * 0.5f / contentScale; float contentOffsetY = (winH - contentH) * 0.5f / contentScale;
auto drawRect = [&](float x, float y, float w, float h, SDL_Color c) auto drawRect = [&](float x, float y, float w, float h, SDL_Color c)
{ SDL_SetRenderDrawColor(renderer,c.r,c.g,c.b,c.a); SDL_FRect fr{x + contentOffsetX, y + contentOffsetY, w, h}; SDL_RenderFillRect(renderer,&fr); }; { RenderPrimitives::fillRect(renderer, x + contentOffsetX, y + contentOffsetY, w, h, c); };
// Calculate dimensions for perfect centering (like JavaScript version) // Calculate dimensions for perfect centering (like JavaScript version)
const bool isLimitedHeight = LOGICAL_H < 450; const bool isLimitedHeight = LOGICAL_H < 450;