linter
This commit is contained in:
@@ -32,7 +32,7 @@ class Debug {
|
||||
static void destroy();
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||
static Debug* get();
|
||||
static auto get() -> Debug*;
|
||||
|
||||
// Dibuja en pantalla
|
||||
void render();
|
||||
@@ -41,12 +41,12 @@ class Debug {
|
||||
void setPos(SDL_FPoint p);
|
||||
|
||||
// Getters
|
||||
bool getEnabled() const { return enabled_; }
|
||||
[[nodiscard]] auto getEnabled() const -> bool { return enabled_; }
|
||||
|
||||
// Setters
|
||||
void add(std::string text) { slot_.push_back(text); }
|
||||
void add(const std::string& text) { slot_.push_back(text); }
|
||||
void clear() { slot_.clear(); }
|
||||
void addToLog(std::string text) { log_.push_back(text); }
|
||||
void addToLog(const std::string& text) { log_.push_back(text); }
|
||||
void clearLog() { log_.clear(); }
|
||||
void setEnabled(bool value) { enabled_ = value; }
|
||||
void toggleEnabled() { enabled_ = !enabled_; }
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "core/system/director.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
|
||||
#include <stdio.h> // Para printf, perror
|
||||
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
||||
#include <unistd.h> // Para getuid
|
||||
|
||||
#include <cerrno> // Para errno, EEXIST, EACCES, ENAMETOO...
|
||||
#include <cstdio> // Para printf, perror
|
||||
#include <cstdlib> // Para exit, EXIT_FAILURE, srand
|
||||
#include <iostream> // Para basic_ostream, operator<<, cout
|
||||
#include <memory> // Para make_unique, unique_ptr
|
||||
@@ -20,7 +18,8 @@
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
#include "game/gameplay/cheevos.hpp" // Para Cheevos
|
||||
#include "game/options.hpp" // Para Options, options, OptionsVideo
|
||||
#include "game/options.hpp" // Para Options, options, OptionsVideo
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "game/scenes/credits.hpp" // Para Credits
|
||||
#include "game/scenes/ending.hpp" // Para Ending
|
||||
#include "game/scenes/ending2.hpp" // Para Ending2
|
||||
@@ -37,14 +36,14 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Director::Director(int argc, const char* argv[]) {
|
||||
std::cout << "Game start" << std::endl;
|
||||
Director::Director(std::vector<std::string> const& args) {
|
||||
std::cout << "Game start" << '\n';
|
||||
|
||||
// Crea e inicializa las opciones del programa
|
||||
Options::init();
|
||||
|
||||
// Comprueba los parametros del programa
|
||||
executable_path_ = checkProgramArguments(argc, argv);
|
||||
executable_path_ = checkProgramArguments(args);
|
||||
|
||||
// Crea el objeto que controla los ficheros de recursos
|
||||
Asset::init(executable_path_);
|
||||
@@ -92,14 +91,14 @@ Director::~Director() {
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
std::cout << "\nBye!" << std::endl;
|
||||
std::cout << "\nBye!" << '\n';
|
||||
}
|
||||
|
||||
// Comprueba los parametros del programa
|
||||
std::string Director::checkProgramArguments(int argc, const char* argv[]) {
|
||||
// Iterar sobre los argumentos del programa
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string argument(argv[i]);
|
||||
auto Director::checkProgramArguments(std::vector<std::string> const& args) -> std::string {
|
||||
// Iterar sobre los argumentos del programa (saltando args[0] que es el ejecutable)
|
||||
for (std::size_t i = 1; i < args.size(); ++i) {
|
||||
const std::string& argument = args[i];
|
||||
|
||||
if (argument == "--console") {
|
||||
Options::console = true;
|
||||
@@ -114,7 +113,7 @@ std::string Director::checkProgramArguments(int argc, const char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
return argv[0];
|
||||
return args[0];
|
||||
}
|
||||
|
||||
// Crea la carpeta del sistema donde guardar datos
|
||||
@@ -141,7 +140,7 @@ void Director::createSystemFolder(const std::string& folder) {
|
||||
}
|
||||
#endif
|
||||
|
||||
struct stat st = {0};
|
||||
struct stat st = {.st_dev = 0};
|
||||
if (stat(system_folder_.c_str(), &st) == -1) {
|
||||
errno = 0;
|
||||
#ifdef _WIN32
|
||||
@@ -239,7 +238,7 @@ void Director::initInput() {
|
||||
}
|
||||
|
||||
// Crea el indice de ficheros
|
||||
bool Director::setFileList() {
|
||||
auto Director::setFileList() -> bool {
|
||||
#ifdef MACOS_BUNDLE
|
||||
const std::string prefix = "/../Resources";
|
||||
#else
|
||||
@@ -527,7 +526,7 @@ void Director::runGame() {
|
||||
game->run();
|
||||
}
|
||||
|
||||
int Director::run() {
|
||||
auto Director::run() -> int {
|
||||
// Bucle principal
|
||||
while (SceneManager::current != SceneManager::Scene::QUIT) {
|
||||
switch (SceneManager::current) {
|
||||
|
||||
@@ -3,23 +3,24 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
class Director {
|
||||
public:
|
||||
Director(int argc, const char* argv[]); // Constructor
|
||||
Director(std::vector<std::string> const& args); // Constructor
|
||||
~Director(); // Destructor
|
||||
static int run(); // Bucle principal
|
||||
static auto run() -> int; // Bucle principal
|
||||
|
||||
private:
|
||||
// --- Variables ---
|
||||
std::string executable_path_; // Path del ejecutable
|
||||
std::string system_folder_; // Carpeta del sistema donde guardar datos
|
||||
static std::string checkProgramArguments(int argc, const char* argv[]); // Comprueba los parametros del programa
|
||||
static auto checkProgramArguments(std::vector<std::string> const& args) -> std::string; // Comprueba los parametros del programa
|
||||
|
||||
// --- Funciones ---
|
||||
void createSystemFolder(const std::string& folder); // Crea la carpeta del sistema donde guardar datos
|
||||
static void initInput(); // Inicializa el objeto Input
|
||||
bool setFileList(); // Crea el indice de ficheros
|
||||
auto setFileList() -> bool; // Crea el indice de ficheros
|
||||
static void runLogo(); // Ejecuta la seccion de juego con el logo
|
||||
static void runLoadingScreen(); // Ejecuta la seccion de juego de la pantalla de carga
|
||||
static void runTitle(); // Ejecuta la seccion de juego con el titulo y los menus
|
||||
|
||||
Reference in New Issue
Block a user