nova clase renderInfo

afegit control de offset a les notificacions
This commit is contained in:
2026-03-28 12:49:38 +01:00
parent f15658a767
commit 065f66d40e
12 changed files with 189 additions and 82 deletions

View File

@@ -9,8 +9,6 @@
#include <fstream> // Para basic_ostream, operator<<, endl, basic_...
#include <iostream> // Para cerr
#include <iterator> // Para istreambuf_iterator, operator==
#include <iomanip> // Para setprecision
#include <sstream> // Para ostringstream
#include <string> // Para char_traits, string, operator+, operator==
#include "core/input/mouse.hpp" // Para updateCursorVisibility
@@ -21,6 +19,7 @@
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "core/resources/resource_list.hpp" // Para Asset, AssetType
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
#include "core/rendering/render_info.hpp" // Para RenderInfo
#include "game/ui/console.hpp" // Para Console
#include "game/ui/notifier.hpp" // Para Notifier
@@ -445,9 +444,7 @@ void Screen::textureToRenderer() {
// Renderiza todos los overlays
void Screen::renderOverlays() {
renderNotifications();
#ifdef _DEBUG
renderInfo();
#endif
if (RenderInfo::get() != nullptr) { RenderInfo::get()->render(); }
}
// Localiza la paleta dentro del vector de paletas
@@ -462,51 +459,6 @@ auto Screen::findPalette(const std::string& name) -> size_t { // NOLINT(readabi
return static_cast<size_t>(0);
}
// Muestra información por pantalla
void Screen::renderInfo() const {
if (!show_fps_ || text_ == nullptr) {
return;
}
const int LINE_HEIGHT = text_->getCharacterSize() - 3;
const int X = 0;
int y = (Console::get() != nullptr) ? Console::get()->getVisibleHeight() : 0;
// FPS
const std::string FPS_TEXT = std::to_string(fps_.last_value) + " fps";
text_->write(X, y, FPS_TEXT);
y += LINE_HEIGHT;
// Driver GPU
text_->write(X, y, gpu_driver_.empty() ? "sdl" : gpu_driver_);
y += LINE_HEIGHT;
// Zoom calculado (alto físico / alto lógico), con coma decimal y sin ceros innecesarios
const float ROUNDED = std::round(zoom_factor_ * 100.0F) / 100.0F;
std::string zoom_str;
if (ROUNDED == std::floor(ROUNDED)) {
zoom_str = std::to_string(static_cast<int>(ROUNDED));
} else {
std::ostringstream oss;
oss << std::fixed << std::setprecision(2) << ROUNDED;
zoom_str = oss.str();
if (zoom_str.back() == '0') { zoom_str.pop_back(); }
std::replace(zoom_str.begin(), zoom_str.end(), '.', ',');
}
text_->write(X, y, zoom_str + "x");
y += LINE_HEIGHT;
// PostFX: muestra preset y supersampling en una sola línea, o nada si está desactivado
if (Options::video.postfx) {
std::string preset_name = "-";
if (!Options::postfx_presets.empty()) {
preset_name = Options::postfx_presets[static_cast<size_t>(Options::current_postfx_preset)].name;
}
const std::string POSTFX_LINE = preset_name + (Options::video.supersampling ? " (SS)" : "");
text_->write(X, y, POSTFX_LINE);
}
}
// Limpia la game_surface_
void Screen::clearSurface(Uint8 index) { game_surface_->clear(index); }
@@ -528,12 +480,6 @@ void Screen::hide() { SDL_HideWindow(window_); }
// Establece la visibilidad de las notificaciones
void Screen::setNotificationsEnabled(bool value) { notifications_enabled_ = value; }
// Activa / desactiva el contador de FPS
void Screen::toggleFPS() {
show_fps_ = !show_fps_;
if (show_fps_) { updateZoomFactor(); }
}
// Alterna entre activar y desactivar el escalado entero
void Screen::toggleIntegerScale() {
Options::video.integer_scale = !Options::video.integer_scale;
@@ -556,6 +502,7 @@ void Screen::toggleVSync() {
// Getters
auto Screen::getRenderer() -> SDL_Renderer* { return renderer_; }
auto Screen::getRendererSurface() -> std::shared_ptr<Surface> { return (*renderer_surface_); }
auto Screen::getGameSurface() -> std::shared_ptr<Surface> { return game_surface_; }
auto Screen::getBorderSurface() -> std::shared_ptr<Surface> {
border_is_solid_ = false; // Modificación externa → modo borde dinámico
return border_surface_;