forked from jaildesigner-jailgames/jaildoctors_dilemma
canvi de pc
This commit is contained in:
@@ -4,31 +4,26 @@
|
||||
#include "text.h" // Para Text
|
||||
#include "texture.h" // Para Texture
|
||||
#include "utils.h"
|
||||
class Screen;
|
||||
#include "screen.h"
|
||||
#include "asset.h"
|
||||
|
||||
// Constructor
|
||||
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
{
|
||||
Debug::Debug()
|
||||
// Copia la dirección de los objetos
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->asset = asset;
|
||||
|
||||
: screen_(Screen::get()),
|
||||
renderer_(Screen::get()->getRenderer()),
|
||||
asset_(Asset::get())
|
||||
{
|
||||
// Reserva memoria para los punteros
|
||||
texture = new Texture(renderer, asset->get("debug.png"));
|
||||
text = new Text(asset->get("debug.txt"), texture, renderer);
|
||||
|
||||
// Inicializa variables
|
||||
x = 0;
|
||||
y = 0;
|
||||
enabled = false;
|
||||
texture_ = new Texture(renderer_, asset_->get("debug.png"));
|
||||
text_ = new Text(asset_->get("debug.txt"), texture_, renderer_);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Debug::~Debug()
|
||||
{
|
||||
delete texture;
|
||||
delete text;
|
||||
delete texture_;
|
||||
delete text_;
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
@@ -39,74 +34,74 @@ void Debug::update()
|
||||
// Dibuja en pantalla
|
||||
void Debug::render()
|
||||
{
|
||||
int y = this->y;
|
||||
int y = y_;
|
||||
int w = 0;
|
||||
|
||||
for (auto s : slot)
|
||||
for (auto s : slot_)
|
||||
{
|
||||
text->write(x, y, s);
|
||||
text_->write(x_, y, s);
|
||||
w = (std::max(w, (int)s.length()));
|
||||
y += text->getCharacterSize() + 1;
|
||||
if (y > 192 - text->getCharacterSize())
|
||||
y += text_->getCharacterSize() + 1;
|
||||
if (y > 192 - text_->getCharacterSize())
|
||||
{
|
||||
y = this->y;
|
||||
x += w * text->getCharacterSize() + 2;
|
||||
y = y_;
|
||||
x_ += w * text_->getCharacterSize() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
y = 0;
|
||||
for (auto l : log)
|
||||
for (auto l : log_)
|
||||
{
|
||||
text->writeColored(x + 10, y, l, color_t(255, 255, 255));
|
||||
y += text->getCharacterSize() + 1;
|
||||
text_->writeColored(x_ + 10, y, l, color_t(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;
|
||||
x_ = p.x;
|
||||
y_ = p.y;
|
||||
}
|
||||
|
||||
// Añade un texto para mostrar
|
||||
void Debug::add(std::string text)
|
||||
{
|
||||
slot.push_back(text);
|
||||
slot_.push_back(text);
|
||||
}
|
||||
|
||||
// Borra la información de debug
|
||||
void Debug::clear()
|
||||
{
|
||||
slot.clear();
|
||||
slot_.clear();
|
||||
}
|
||||
|
||||
// Añade un texto para mostrar en el apartado log
|
||||
void Debug::addToLog(std::string text)
|
||||
{
|
||||
log.push_back(text);
|
||||
log_.push_back(text);
|
||||
}
|
||||
|
||||
// Borra la información de debug del apartado log
|
||||
void Debug::clearLog()
|
||||
{
|
||||
log.clear();
|
||||
log_.clear();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Debug::setEnabled(bool value)
|
||||
{
|
||||
enabled = value;
|
||||
enabled_ = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Debug::getEnabled()
|
||||
{
|
||||
return enabled;
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable
|
||||
void Debug::switchEnabled()
|
||||
{
|
||||
enabled = !enabled;
|
||||
enabled_ = !enabled_;
|
||||
}
|
||||
Reference in New Issue
Block a user