millorada una mica la classe Debug en quant a mostrar info
This commit is contained in:
@@ -36,24 +36,51 @@ void Debug::render() { // NOLINT(readability-make-member-function-const)
|
||||
auto text = Resource::Cache::get()->getText("aseprite");
|
||||
int y = y_;
|
||||
int w = 0;
|
||||
constexpr int DESP_Y = 7;
|
||||
const int CHAR_SIZE = text->getCharacterSize();
|
||||
|
||||
// Watch window: valores persistentes (key: value)
|
||||
for (const auto& [key, value] : watches_) {
|
||||
const std::string LINE = key + ": " + value;
|
||||
text->write(x_, y, LINE);
|
||||
w = std::max(w, text->length(LINE));
|
||||
y += DESP_Y;
|
||||
if (y > 192 - CHAR_SIZE) {
|
||||
y = y_;
|
||||
x_ += w + 2;
|
||||
w = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Slot one-shot: mensajes de un solo frame
|
||||
for (const auto& s : slot_) {
|
||||
text->write(x_, y, s);
|
||||
w = (std::max(w, (int)s.length()));
|
||||
y += text->getCharacterSize() + 1;
|
||||
if (y > 192 - text->getCharacterSize()) {
|
||||
w = std::max(w, text->length(s));
|
||||
y += DESP_Y;
|
||||
if (y > 192 - CHAR_SIZE) {
|
||||
y = y_;
|
||||
x_ += (w * text->getCharacterSize()) + 2;
|
||||
x_ += w + 2;
|
||||
w = 0;
|
||||
}
|
||||
}
|
||||
|
||||
y = 0;
|
||||
for (const auto& l : log_) {
|
||||
text->writeColored(x_ + 10, y, l, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
y += text->getCharacterSize() + 1;
|
||||
y += CHAR_SIZE + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece/actualiza un valor persistente en el watch window
|
||||
void Debug::set(const std::string& key, const std::string& value) {
|
||||
watches_[key] = value;
|
||||
}
|
||||
|
||||
// Elimina un valor del watch window
|
||||
void Debug::unset(const std::string& key) {
|
||||
watches_.erase(key);
|
||||
}
|
||||
|
||||
// Establece la posición donde se colocará la información de debug
|
||||
void Debug::setPos(SDL_FPoint p) {
|
||||
x_ = p.x;
|
||||
|
||||
Reference in New Issue
Block a user