- renderInfo
- fix: no guardava el preset actual
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "core/rendering/text.hpp"
|
||||
#include "game/options.hpp"
|
||||
|
||||
namespace Overlay {
|
||||
|
||||
@@ -46,6 +47,9 @@ namespace Overlay {
|
||||
static std::vector<Notification> notifications_;
|
||||
static Uint32 last_ticks_ = 0;
|
||||
|
||||
// --- Render info ---
|
||||
static std::string render_info_text_;
|
||||
|
||||
void init() {
|
||||
font_ = std::make_unique<Text>("fonts/8bithud.fnt", "fonts/8bithud.gif");
|
||||
last_ticks_ = SDL_GetTicks();
|
||||
@@ -120,6 +124,19 @@ namespace Overlay {
|
||||
font_->draw(pixel_data, box_x + NOTIF_PADDING_H, box_y + NOTIF_PADDING_V, notif.message.c_str(), NOTIF_TEXT_COLOR);
|
||||
}
|
||||
|
||||
// Render info (FPS, driver, shader) — centrat, posició configurable
|
||||
if (Options::render_info.position != Options::RenderInfoPosition::OFF && !render_info_text_.empty()) {
|
||||
int info_w = font_->width(render_info_text_.c_str());
|
||||
int info_x = (SCREEN_W - info_w) / 2;
|
||||
int info_y = (Options::render_info.position == Options::RenderInfoPosition::TOP)
|
||||
? 1
|
||||
: SCREEN_H - font_->charHeight() - 1;
|
||||
// Ombra (1px desplaçat)
|
||||
font_->draw(pixel_data, info_x + 1, info_y + 1, render_info_text_.c_str(), Options::render_info.shadow_color);
|
||||
// Text
|
||||
font_->draw(pixel_data, info_x, info_y, render_info_text_.c_str(), Options::render_info.text_color);
|
||||
}
|
||||
|
||||
// Elimina les acabades
|
||||
notifications_.erase(
|
||||
std::remove_if(notifications_.begin(), notifications_.end(), [](const Notification& n) { return n.status == Status::FINISHED; }),
|
||||
@@ -139,4 +156,23 @@ namespace Overlay {
|
||||
notifications_.push_back(notif);
|
||||
}
|
||||
|
||||
void toggleRenderInfo() {
|
||||
// Cicla: OFF → TOP → BOTTOM → OFF
|
||||
switch (Options::render_info.position) {
|
||||
case Options::RenderInfoPosition::OFF:
|
||||
Options::render_info.position = Options::RenderInfoPosition::TOP;
|
||||
break;
|
||||
case Options::RenderInfoPosition::TOP:
|
||||
Options::render_info.position = Options::RenderInfoPosition::BOTTOM;
|
||||
break;
|
||||
case Options::RenderInfoPosition::BOTTOM:
|
||||
Options::render_info.position = Options::RenderInfoPosition::OFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setRenderInfoText(const char* text) {
|
||||
render_info_text_ = text;
|
||||
}
|
||||
|
||||
} // namespace Overlay
|
||||
|
||||
Reference in New Issue
Block a user