forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "core/rendering/screen.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <ctype.h> // Para toupper
|
||||
|
||||
#include <algorithm> // Para max, min, transform
|
||||
#include <cctype> // Para toupper
|
||||
#include <fstream> // Para basic_ostream, operator<<, endl, basic_...
|
||||
#include <iostream> // Para cerr
|
||||
#include <iterator> // Para istreambuf_iterator, operator==
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/asset.hpp" // Para Asset, AssetType
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
|
||||
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
|
||||
// [SINGLETON]
|
||||
@@ -32,7 +32,7 @@ void Screen::destroy() {
|
||||
}
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||
Screen* Screen::get() {
|
||||
auto Screen::get() -> Screen* {
|
||||
return Screen::screen;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ Screen::Screen()
|
||||
initSDLVideo();
|
||||
|
||||
// Ajusta los tamaños
|
||||
game_surface_dstrect_ = {Options::video.border.width, Options::video.border.height, Options::game.width, Options::game.height};
|
||||
game_surface_dstrect_ = {.x = Options::video.border.width, .y = Options::video.border.height, .w = Options::game.width, .h = Options::game.height};
|
||||
// adjustWindowSize();
|
||||
current_palette_ = findPalette(Options::video.palette);
|
||||
|
||||
@@ -55,7 +55,7 @@ Screen::Screen()
|
||||
if (game_texture_ == nullptr) {
|
||||
// Registrar el error si está habilitado
|
||||
if (Options::console) {
|
||||
std::cerr << "Error: game_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error: game_texture_ could not be created!\nSDL Error: " << SDL_GetError() << '\n';
|
||||
}
|
||||
}
|
||||
SDL_SetTextureScaleMode(game_texture_, SDL_SCALEMODE_NEAREST);
|
||||
@@ -65,7 +65,7 @@ Screen::Screen()
|
||||
if (border_texture_ == nullptr) {
|
||||
// Registrar el error si está habilitado
|
||||
if (Options::console) {
|
||||
std::cerr << "Error: border_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
std::cerr << "Error: border_texture_ could not be created!\nSDL Error: " << SDL_GetError() << '\n';
|
||||
}
|
||||
}
|
||||
SDL_SetTextureScaleMode(border_texture_, SDL_SCALEMODE_NEAREST);
|
||||
@@ -142,7 +142,7 @@ void Screen::toggleVideoMode() {
|
||||
}
|
||||
|
||||
// Reduce el tamaño de la ventana
|
||||
bool Screen::decWindowZoom() {
|
||||
auto Screen::decWindowZoom() -> bool {
|
||||
if (static_cast<int>(Options::video.fullscreen) == 0) {
|
||||
const int PREVIOUS_ZOOM = Options::window.zoom;
|
||||
--Options::window.zoom;
|
||||
@@ -158,7 +158,7 @@ bool Screen::decWindowZoom() {
|
||||
}
|
||||
|
||||
// Aumenta el tamaño de la ventana
|
||||
bool Screen::incWindowZoom() {
|
||||
auto Screen::incWindowZoom() -> bool {
|
||||
if (static_cast<int>(Options::video.fullscreen) == 0) {
|
||||
const int PREVIOUS_ZOOM = Options::window.zoom;
|
||||
++Options::window.zoom;
|
||||
@@ -235,7 +235,7 @@ void Screen::adjustRenderLogicalSize() {
|
||||
}
|
||||
|
||||
// Establece el renderizador para las surfaces
|
||||
void Screen::setRendererSurface(std::shared_ptr<Surface> surface) {
|
||||
void Screen::setRendererSurface(const std::shared_ptr<Surface> &surface) {
|
||||
(surface) ? renderer_surface_ = std::make_shared<std::shared_ptr<Surface>>(surface) : renderer_surface_ = std::make_shared<std::shared_ptr<Surface>>(game_surface_);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ void Screen::setPalete() {
|
||||
}
|
||||
|
||||
// Convertir a mayúsculas
|
||||
std::transform(Options::video.palette.begin(), Options::video.palette.end(), Options::video.palette.begin(), ::toupper);
|
||||
std::ranges::transform(Options::video.palette, Options::video.palette.begin(), ::toupper);
|
||||
}
|
||||
|
||||
// Extrae los nombres de las paletas
|
||||
@@ -316,7 +316,7 @@ void Screen::renderOverlays() {
|
||||
}
|
||||
|
||||
// Localiza la paleta dentro del vector de paletas
|
||||
size_t Screen::findPalette(const std::string& name) {
|
||||
auto Screen::findPalette(const std::string& name) -> size_t {
|
||||
std::string upper_name = toUpper(name + ".pal");
|
||||
|
||||
for (size_t i = 0; i < palettes_.size(); ++i) {
|
||||
@@ -373,11 +373,11 @@ void Screen::toggleIntegerScale() {
|
||||
}
|
||||
|
||||
// Getters
|
||||
SDL_Renderer* Screen::getRenderer() { return renderer_; }
|
||||
std::shared_ptr<Surface> Screen::getRendererSurface() { return (*renderer_surface_); }
|
||||
std::shared_ptr<Surface> Screen::getBorderSurface() { return border_surface_; }
|
||||
auto Screen::getRenderer() -> SDL_Renderer* { return renderer_; }
|
||||
auto Screen::getRendererSurface() -> std::shared_ptr<Surface> { return (*renderer_surface_); }
|
||||
auto Screen::getBorderSurface() -> std::shared_ptr<Surface> { return border_surface_; }
|
||||
|
||||
std::vector<uint8_t> loadData(const std::string& filepath) {
|
||||
auto loadData(const std::string& filepath) -> std::vector<uint8_t> {
|
||||
// Fallback a filesystem
|
||||
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
||||
if (!file) {
|
||||
|
||||
@@ -39,7 +39,7 @@ class Screen {
|
||||
// Constructor para inicializar la estructura.
|
||||
FPS()
|
||||
|
||||
{}
|
||||
= default;
|
||||
|
||||
// Incrementador que se llama en cada frame.
|
||||
void increment() {
|
||||
@@ -192,7 +192,7 @@ class Screen {
|
||||
void hide();
|
||||
|
||||
// Establece el renderizador para las surfaces
|
||||
void setRendererSurface(std::shared_ptr<Surface> surface = nullptr);
|
||||
void setRendererSurface(const std::shared_ptr<Surface> &surface = nullptr);
|
||||
|
||||
// Cambia la paleta
|
||||
void nextPalette();
|
||||
|
||||
@@ -21,7 +21,7 @@ struct AnimationData {
|
||||
|
||||
AnimationData()
|
||||
|
||||
{}
|
||||
= default;
|
||||
};
|
||||
|
||||
using Animations = std::vector<std::string>;
|
||||
|
||||
Reference in New Issue
Block a user