forked from jaildesigner-jailgames/jaildoctors_dilemma
Reubicados los cpp de librerias comunes
This commit is contained in:
104
source/debug.cpp
104
source/debug.cpp
@@ -1,104 +0,0 @@
|
||||
#include "debug.h"
|
||||
|
||||
// Constructor
|
||||
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
{
|
||||
// Copia la dirección de los objetos
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->asset = asset;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
text = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
|
||||
|
||||
// Inicializa variables
|
||||
x = 0;
|
||||
y = 0;
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Debug::~Debug()
|
||||
{
|
||||
delete text;
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
void Debug::update()
|
||||
{
|
||||
}
|
||||
|
||||
// Dibuja en pantalla
|
||||
void Debug::render()
|
||||
{
|
||||
int y = this->y;
|
||||
int w = 0;
|
||||
|
||||
for (auto s : slot)
|
||||
{
|
||||
text->write(x, y, s);
|
||||
w = (std::max(w, (int)s.length()));
|
||||
y += text->getCharacterSize() + 1;
|
||||
if (y > 192 - text->getCharacterSize())
|
||||
{
|
||||
y = this->y;
|
||||
x += w * text->getCharacterSize() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
y = 0;
|
||||
for (auto l : log)
|
||||
{
|
||||
text->writeColored(x + 10, y, l, {255, 255, 255});
|
||||
y += text->getCharacterSize() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece la posición donde se colocará la información de debug
|
||||
void Debug::setPos(SDL_Point p)
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
}
|
||||
|
||||
// Añade un texto para mostrar
|
||||
void Debug::add(std::string text)
|
||||
{
|
||||
slot.push_back(text);
|
||||
}
|
||||
|
||||
// Borra la información de debug
|
||||
void Debug::clear()
|
||||
{
|
||||
slot.clear();
|
||||
}
|
||||
|
||||
// Añade un texto para mostrar en el apartado log
|
||||
void Debug::addToLog(std::string text)
|
||||
{
|
||||
log.push_back(text);
|
||||
}
|
||||
|
||||
// Borra la información de debug del apartado log
|
||||
void Debug::clearLog()
|
||||
{
|
||||
log.clear();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Debug::setEnabled(bool value)
|
||||
{
|
||||
enabled = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Debug::getEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable
|
||||
void Debug::switchEnabled()
|
||||
{
|
||||
enabled = !enabled;
|
||||
}
|
||||
Reference in New Issue
Block a user