migrant a SDL3

This commit is contained in:
2025-03-25 20:26:45 +01:00
parent f1b0303474
commit a9c869baf6
49 changed files with 374 additions and 416 deletions

View File

@@ -1,7 +1,8 @@
#include "hiscore_table.h"
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_render.h> // Para SDL_QueryTexture
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand, size_t
#include <algorithm> // Para max
@@ -33,7 +34,7 @@ HiScoreTable::HiScoreTable()
background_(std::make_unique<Background>()),
counter_(0),
ticks_(0),
view_area_({0, 0, param.game.width, param.game.height}),
view_area_(SDL_FRect{0, 0, static_cast<float>(param.game.width), static_cast<float>(param.game.height)}),
fade_mode_(FadeMode::IN),
background_fade_color_(Color(0, 0, 0))
{
@@ -214,15 +215,15 @@ void HiScoreTable::createSprites()
auto entry_text = Resource::get()->getText("smb2");
// Obtiene el tamaño de la textura
int backbuffer_width;
int backbuffer_height;
SDL_QueryTexture(backbuffer_, nullptr, nullptr, &backbuffer_width, &backbuffer_height);
float backbuffer_width;
float backbuffer_height;
SDL_GetTextureSize(backbuffer_, &backbuffer_width, &backbuffer_height);
constexpr int entry_lenght = 22;
constexpr int max_names = 10;
constexpr int ENTRY_LENGHT = 22;
constexpr int MAX_NAMES = 10;
const int space_between_header = entry_text->getCharacterSize() * 4;
const int space_between_lines = entry_text->getCharacterSize() * 2;
const int size = space_between_header + space_between_lines * (max_names - 1) + entry_text->getCharacterSize();
const int size = space_between_header + space_between_lines * (MAX_NAMES - 1) + entry_text->getCharacterSize();
const int first_line = (param.game.height - size) / 2;
// Crea el sprite para el texto de cabecera
@@ -231,14 +232,14 @@ void HiScoreTable::createSprites()
// Crea los sprites para las entradas en la tabla de puntuaciones
const int animation = rand() % 4;
const std::string sample_line(entry_lenght + 3, ' ');
const std::string sample_line(ENTRY_LENGHT + 3, ' ');
auto sample_entry = std::make_unique<Sprite>(entry_text->writeDXToTexture(TEXT_SHADOW, sample_line, 1, orange_color, 1, shdw_txt_color));
const auto entry_width = sample_entry->getWidth();
for (int i = 0; i < max_names; ++i)
for (int i = 0; i < MAX_NAMES; ++i)
{
const auto table_position = format(i + 1) + ". ";
const auto score = format(options.game.hi_score_table.at(i).score);
const auto num_dots = entry_lenght - options.game.hi_score_table.at(i).name.size() - score.size();
const auto num_dots = ENTRY_LENGHT - options.game.hi_score_table.at(i).name.size() - score.size();
const auto one_cc = options.game.hi_score_table.at(i).one_credit_complete ? " }" : "";
std::string dots;
for (int j = 0; j < (int)num_dots; ++j)