renombrades extensions .h a .hpp
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "utils.h"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_RenderPoint, SDL_FRect, SDL_FPoint, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_Renderer
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits
|
||||
|
||||
#include "lang.h" // Para getText
|
||||
#include "resource_helper.h" // Para ResourceHelper
|
||||
#include "lang.hpp" // Para getText
|
||||
#include "resource_helper.hpp" // Para ResourceHelper
|
||||
|
||||
// Variables
|
||||
Overrides overrides = Overrides();
|
||||
@@ -26,7 +26,7 @@ auto distanceSquared(int x1, int y1, int x2, int y2) -> double {
|
||||
}
|
||||
|
||||
// Obtiene el punto de colisión entre dos circulos
|
||||
auto getCollisionPoint(const Circle &a, const Circle &b) -> SDL_FPoint {
|
||||
auto getCollisionPoint(const Circle& a, const Circle& b) -> SDL_FPoint {
|
||||
float dx = b.x - a.x;
|
||||
float dy = b.y - a.y;
|
||||
float dist = std::sqrt((dx * dx) + (dy * dy));
|
||||
@@ -44,7 +44,7 @@ auto getCollisionPoint(const Circle &a, const Circle &b) -> SDL_FPoint {
|
||||
}
|
||||
|
||||
// Detector de colisiones entre dos circulos
|
||||
auto checkCollision(const Circle &a, const Circle &b) -> bool {
|
||||
auto checkCollision(const Circle& a, const Circle& b) -> bool {
|
||||
// Calcula el radio total al cuadrado
|
||||
int total_radius_squared = (a.r + b.r) * (a.r + b.r);
|
||||
|
||||
@@ -53,7 +53,7 @@ auto checkCollision(const Circle &a, const Circle &b) -> bool {
|
||||
}
|
||||
|
||||
// Detector de colisiones entre un circulo y un rectangulo
|
||||
auto checkCollision(const Circle &a, const SDL_FRect &b) -> bool {
|
||||
auto checkCollision(const Circle& a, const SDL_FRect& b) -> bool {
|
||||
// Encuentra el punto más cercano en el rectángulo
|
||||
float c_x = std::clamp(static_cast<float>(a.x), b.x, b.x + b.w);
|
||||
float c_y = std::clamp(static_cast<float>(a.y), b.y, b.y + b.h);
|
||||
@@ -63,7 +63,7 @@ auto checkCollision(const Circle &a, const SDL_FRect &b) -> bool {
|
||||
}
|
||||
|
||||
// Detector de colisiones entre dos rectangulos
|
||||
auto checkCollision(const SDL_FRect &a, const SDL_FRect &b) -> bool {
|
||||
auto checkCollision(const SDL_FRect& a, const SDL_FRect& b) -> bool {
|
||||
const int LEFT_A = a.x;
|
||||
const int RIGHT_A = a.x + a.w;
|
||||
const int TOP_A = a.y;
|
||||
@@ -90,7 +90,7 @@ auto checkCollision(const SDL_FRect &a, const SDL_FRect &b) -> bool {
|
||||
}
|
||||
|
||||
// Detector de colisiones entre un punto y un rectangulo
|
||||
auto checkCollision(const SDL_FPoint &p, const SDL_FRect &r) -> bool {
|
||||
auto checkCollision(const SDL_FPoint& p, const SDL_FRect& r) -> bool {
|
||||
if (p.x < r.x || p.x > r.x + r.w) {
|
||||
return false;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ auto checkCollision(const SDL_FPoint &p, const SDL_FRect &r) -> bool {
|
||||
}
|
||||
|
||||
// Convierte una cadena en un valor booleano
|
||||
auto stringToBool(const std::string &str) -> bool {
|
||||
auto stringToBool(const std::string& str) -> bool {
|
||||
std::string s = trim(toLower(str));
|
||||
return (s == "true" || s == "1" || s == "yes" || s == "on");
|
||||
}
|
||||
@@ -117,14 +117,14 @@ auto boolToOnOff(bool value) -> std::string {
|
||||
}
|
||||
|
||||
// Convierte una cadena a minusculas
|
||||
auto toLower(const std::string &str) -> std::string {
|
||||
auto toLower(const std::string& str) -> std::string {
|
||||
std::string result = str;
|
||||
std::ranges::transform(result, result.begin(), [](unsigned char c) { return std::tolower(c); });
|
||||
return result;
|
||||
}
|
||||
|
||||
// Dibuja un circulo
|
||||
void drawCircle(SDL_Renderer *renderer, int32_t center_x, int32_t center_y, int32_t radius) {
|
||||
void drawCircle(SDL_Renderer* renderer, int32_t center_x, int32_t center_y, int32_t radius) {
|
||||
const int32_t DIAMETER = (radius * 2);
|
||||
|
||||
int32_t x = (radius - 1);
|
||||
@@ -159,7 +159,7 @@ void drawCircle(SDL_Renderer *renderer, int32_t center_x, int32_t center_y, int3
|
||||
}
|
||||
|
||||
// Quita los espacioes en un string
|
||||
auto trim(const std::string &str) -> std::string {
|
||||
auto trim(const std::string& str) -> std::string {
|
||||
auto start = std::ranges::find_if_not(str, ::isspace);
|
||||
auto end = std::ranges::find_if_not(std::ranges::reverse_view(str), ::isspace).base();
|
||||
return (start < end ? std::string(start, end) : std::string());
|
||||
@@ -290,12 +290,12 @@ auto easeInCubic(double time) -> double {
|
||||
}
|
||||
|
||||
// Comprueba si una vector contiene una cadena
|
||||
auto stringInVector(const std::vector<std::string> &vec, const std::string &str) -> bool {
|
||||
auto stringInVector(const std::vector<std::string>& vec, const std::string& str) -> bool {
|
||||
return std::ranges::find(vec, str) != vec.end();
|
||||
}
|
||||
|
||||
// Imprime por pantalla una línea de texto de tamaño fijo rellena con puntos
|
||||
void printWithDots(const std::string &text1, const std::string &text2, const std::string &text3) {
|
||||
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3) {
|
||||
constexpr size_t TOTAL_WIDTH = 52;
|
||||
|
||||
// Calcula el ancho del campo para text2 restando la longitud de text1 y text3
|
||||
@@ -320,20 +320,19 @@ void printWithDots(const std::string &text1, const std::string &text2, const std
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s", formatted_text.c_str());
|
||||
}
|
||||
|
||||
|
||||
// Obtiene el nombre de un fichero a partir de una ruta completa
|
||||
auto getFileName(const std::string &path) -> std::string {
|
||||
auto getFileName(const std::string& path) -> std::string {
|
||||
return std::filesystem::path(path).filename().string();
|
||||
}
|
||||
|
||||
// Obtiene la ruta eliminando el nombre del fichero
|
||||
auto getPath(const std::string &full_path) -> std::string {
|
||||
auto getPath(const std::string& full_path) -> std::string {
|
||||
std::filesystem::path path(full_path);
|
||||
return path.parent_path().string();
|
||||
}
|
||||
|
||||
// Trunca un string y le añade puntos suspensivos
|
||||
auto truncateWithEllipsis(const std::string &input, size_t length) -> std::string {
|
||||
auto truncateWithEllipsis(const std::string& input, size_t length) -> std::string {
|
||||
if (input.size() <= length) {
|
||||
return input;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user