Quitados todos los printf menos uno

This commit is contained in:
2022-10-30 22:48:50 +01:00
parent 531ac94bc0
commit 2e0b0f32b5
7 changed files with 49 additions and 53 deletions

View File

@@ -73,7 +73,7 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
}
} while (line != "[/animation]");
@@ -108,7 +108,7 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
// Normaliza valores
@@ -133,11 +133,11 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Pone un valor por defecto
//setRect({0, 0, frameWidth, frameHeight});
// setRect({0, 0, frameWidth, frameHeight});
return as;
}
@@ -212,7 +212,7 @@ int AnimatedSprite::getIndex(std::string name)
}
}
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
std::cout << "** Warning: could not find \"" << name.c_str() << "\" animation" << std::endl;
return -1;
}
@@ -409,7 +409,7 @@ animatedSprite_t AnimatedSprite::loadFromFile(std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
}
} while (line != "[/animation]");
@@ -445,7 +445,7 @@ animatedSprite_t AnimatedSprite::loadFromFile(std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
// Normaliza valores
@@ -470,7 +470,7 @@ animatedSprite_t AnimatedSprite::loadFromFile(std::string filePath)
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Pone un valor por defecto

View File

@@ -1,4 +1,5 @@
#include "asset.h"
#include <iostream>
// Constructor
Asset::Asset(std::string path)
@@ -31,7 +32,7 @@ std::string Asset::get(std::string text)
}
}
printf("Warning: file %s not found\n", text.c_str());
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl;
return "";
}
@@ -40,7 +41,7 @@ bool Asset::check()
{
bool success = true;
printf("\n** Checking files.\n");
std::cout << "\n** Checking files." << std::endl;
// Comprueba la lista de ficheros clasificandolos por tipo
for (int type = 0; type < t_maxAssetType; ++type)
@@ -59,7 +60,7 @@ bool Asset::check()
// Si hay ficheros de ese tipo, comprueba si existen
if (any)
{
printf("\n>> %s FILES\n", getTypeName(type).c_str());
std::cout << "\n>> " << getTypeName(type).c_str() << " FILES" << std::endl;
for (auto f : fileList)
{
@@ -74,11 +75,13 @@ bool Asset::check()
// Resultado
if (success)
{
printf("\n** All files OK.\n\n");
std::cout << "\n** All files OK.\n"
<< std::endl;
}
else
{
printf("\n** A file is missing. Exiting.\n\n");
std::cout << "\n** A file is missing. Exiting.\n"
<< std::endl;
}
return success;

View File

@@ -107,7 +107,7 @@ bool Menu::load(std::string file_path)
if (file.good())
{
// Procesa el fichero linea a linea
printf("Reading file %s\n", filename.c_str());
std::cout << "Reading file " << filename.c_str() << std::endl;
while (std::getline(file, line))
{
if (line == "[item]")
@@ -130,7 +130,7 @@ bool Menu::load(std::string file_path)
// Procesa las dos subcadenas
if (!setItem(&item, line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
success = false;
}
@@ -147,7 +147,7 @@ bool Menu::load(std::string file_path)
// Procesa las dos subcadenas
if (!setVars(line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
success = false;
}
@@ -161,13 +161,13 @@ bool Menu::load(std::string file_path)
}
// Cierra el fichero
printf("Closing file %s\n", filename.c_str());
std::cout << "Closing file " << filename.c_str() << std::endl;
file.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
success = false;
}
@@ -208,7 +208,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
else if ((var == "") || (var == "[/item]"))
{
}
else
{
success = false;
@@ -405,7 +405,7 @@ void Menu::updateSelector()
selector.moving = false;
}
}
else if (selector.despY < 0) // Va hacia arriba
{
if (selector.y < selector.targetY) // Ha llegado al destino
@@ -434,7 +434,7 @@ void Menu::updateSelector()
selector.resizing = false;
}
}
else if (selector.incH < 0) // Decrece
{
if (selector.h < selector.targetH) // Ha llegado al destino
@@ -642,7 +642,7 @@ void Menu::render()
{
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
}
else
{ // No seleccionable
if ((item.at(i).linkedUp) && (i == selector.index + 1))

View File

@@ -50,14 +50,14 @@ textFile_t LoadTextFile(std::string file)
};
// Cierra el fichero
printf("Text loaded: %s\n", filename.c_str());
std::cout << "Text loaded: " << filename.c_str() << std::endl;
rfile.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho
@@ -243,14 +243,14 @@ void Text::initOffsetFromFile(std::string file)
};
// Cierra el fichero
printf("Text loaded: %s\n", filename.c_str());
std::cout << "Text loaded: " << filename.c_str() << std::endl;
rfile.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho

View File

@@ -2,6 +2,7 @@
#include "texture.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <iostream>
// Constructor
Texture::Texture(SDL_Renderer *renderer, std::string path)
@@ -32,7 +33,7 @@ Texture::~Texture()
// Carga una imagen desde un fichero
bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
{
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
int req_format = STBI_rgb_alpha;
int width, height, orig_format;
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
@@ -43,7 +44,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
}
else
{
printf("Image loaded: %s\n", filename.c_str());
std::cout << "Image loaded: " << filename.c_str() << std::endl;
}
int depth, pitch;
@@ -71,7 +72,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
if (loadedSurface == nullptr)
{
printf("Unable to load image %s!\n", path.c_str());
std::cout << "Unable to load image " << path.c_str() << std::endl;
}
else
{
@@ -79,7 +80,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
if (newTexture == nullptr)
{
printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
std::cout << "Unable to create texture from " << path.c_str() << "! SDL Error: " << SDL_GetError() << std::endl;
}
else
{
@@ -104,7 +105,7 @@ bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Tex
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
if (texture == nullptr)
{
printf("Unable to create blank texture! SDL Error: %s\n", SDL_GetError());
std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl;
}
else
{