afegits metodes per a poder ciclar presets i altres opcions
esc en el joc + menu ja no tanca la app
This commit is contained in:
@@ -19,17 +19,17 @@ namespace Menu {
|
||||
|
||||
static constexpr int BOX_W = 220;
|
||||
static constexpr int BOX_H = 150;
|
||||
static constexpr int BOX_X = (SCREEN_W - BOX_W) / 2; // 50
|
||||
static constexpr int BOX_Y = (SCREEN_H - BOX_H) / 2; // 25
|
||||
static constexpr int BOX_X = (SCREEN_W - BOX_W) / 2; // 50
|
||||
static constexpr int BOX_Y = (SCREEN_H - BOX_H) / 2; // 25
|
||||
|
||||
static constexpr Uint32 BG_COLOR = 0xFF1A0E0E; // fons marró fosc (ABGR)
|
||||
static constexpr Uint8 BG_ALPHA = 220; // semi-transparent
|
||||
static constexpr Uint32 BORDER_COLOR = 0xFFFFFF00; // cyan
|
||||
static constexpr Uint32 TITLE_COLOR = 0xFFFFFFFF; // blanc
|
||||
static constexpr Uint32 LABEL_COLOR = 0xFFCCCCCC; // gris clar
|
||||
static constexpr Uint32 VALUE_COLOR = 0xFFFFFF00; // cyan
|
||||
static constexpr Uint32 CURSOR_COLOR = 0xFF00FFFF; // groc
|
||||
static constexpr Uint32 FOOTER_COLOR = 0xFF888888; // gris
|
||||
static constexpr Uint32 BG_COLOR = 0xFF1A0E0E; // fons marró fosc (ABGR)
|
||||
static constexpr Uint8 BG_ALPHA = 220; // semi-transparent
|
||||
static constexpr Uint32 BORDER_COLOR = 0xFFFFFF00; // cyan
|
||||
static constexpr Uint32 TITLE_COLOR = 0xFFFFFFFF; // blanc
|
||||
static constexpr Uint32 LABEL_COLOR = 0xFFCCCCCC; // gris clar
|
||||
static constexpr Uint32 VALUE_COLOR = 0xFFFFFF00; // cyan
|
||||
static constexpr Uint32 CURSOR_COLOR = 0xFF00FFFF; // groc
|
||||
static constexpr Uint32 FOOTER_COLOR = 0xFF888888; // gris
|
||||
|
||||
static constexpr int TITLE_PAD_Y = 4;
|
||||
static constexpr int ITEM_PAD_X = 10;
|
||||
@@ -64,63 +64,46 @@ namespace Menu {
|
||||
items_.clear();
|
||||
|
||||
// ZOOM
|
||||
items_.push_back({"ZOOM", ItemKind::IntRange,
|
||||
[] {
|
||||
items_.push_back({"ZOOM", ItemKind::IntRange, [] {
|
||||
char buf[16];
|
||||
std::snprintf(buf, sizeof(buf), "%dX", Screen::get()->getZoom());
|
||||
return std::string(buf);
|
||||
},
|
||||
[](int dir) {
|
||||
return std::string(buf); }, [](int dir) {
|
||||
if (dir < 0) Screen::get()->decZoom();
|
||||
else if (dir > 0) Screen::get()->incZoom();
|
||||
}});
|
||||
else if (dir > 0) Screen::get()->incZoom(); }});
|
||||
|
||||
// PANTALLA (fullscreen)
|
||||
items_.push_back({"PANTALLA", ItemKind::Toggle,
|
||||
[] { return std::string(Screen::get()->isFullscreen() ? "COMPLETA" : "FINESTRA"); },
|
||||
[](int) { Screen::get()->toggleFullscreen(); }});
|
||||
items_.push_back({"PANTALLA", ItemKind::Toggle, [] { return std::string(Screen::get()->isFullscreen() ? "COMPLETA" : "FINESTRA"); }, [](int) { Screen::get()->toggleFullscreen(); }});
|
||||
|
||||
// SHADER
|
||||
items_.push_back({"SHADER", ItemKind::Toggle,
|
||||
[] { return onOff(Options::video.shader_enabled); },
|
||||
[](int) { Screen::get()->toggleShaders(); }});
|
||||
items_.push_back({"SHADER", ItemKind::Toggle, [] { return onOff(Options::video.shader_enabled); }, [](int) { Screen::get()->toggleShaders(); }});
|
||||
|
||||
// ASPECTE 4:3
|
||||
items_.push_back({"ASPECTE 4:3", ItemKind::Toggle,
|
||||
[] { return yesNo(Options::video.aspect_ratio_4_3); },
|
||||
[](int) { Screen::get()->toggleAspectRatio(); }});
|
||||
items_.push_back({"ASPECTE 4:3", ItemKind::Toggle, [] { return yesNo(Options::video.aspect_ratio_4_3); }, [](int) { Screen::get()->toggleAspectRatio(); }});
|
||||
|
||||
// SUPERSAMPLING
|
||||
items_.push_back({"SUPERSAMPLING", ItemKind::Toggle,
|
||||
[] { return onOff(Options::video.supersampling); },
|
||||
[](int) { Screen::get()->toggleSupersampling(); }});
|
||||
items_.push_back({"SUPERSAMPLING", ItemKind::Toggle, [] { return onOff(Options::video.supersampling); }, [](int) { Screen::get()->toggleSupersampling(); }});
|
||||
|
||||
// TIPUS SHADER
|
||||
items_.push_back({"TIPUS SHADER", ItemKind::Cycle,
|
||||
[] { return std::string(Screen::get()->getActiveShaderName()); },
|
||||
[](int) { Screen::get()->nextShaderType(); }});
|
||||
items_.push_back({"TIPUS SHADER", ItemKind::Cycle, [] { return std::string(Screen::get()->getActiveShaderName()); }, [](int dir) {
|
||||
if (dir < 0) Screen::get()->prevShaderType();
|
||||
else Screen::get()->nextShaderType(); }});
|
||||
|
||||
// PRESET
|
||||
items_.push_back({"PRESET", ItemKind::Cycle,
|
||||
[] { return std::string(Screen::get()->getCurrentPresetName()); },
|
||||
[](int) { Screen::get()->nextPreset(); }});
|
||||
items_.push_back({"PRESET", ItemKind::Cycle, [] { return std::string(Screen::get()->getCurrentPresetName()); }, [](int dir) {
|
||||
if (dir < 0) Screen::get()->prevPreset();
|
||||
else Screen::get()->nextPreset(); }});
|
||||
|
||||
// FILTRE 4:3
|
||||
items_.push_back({"FILTRE 4:3", ItemKind::Toggle,
|
||||
[] { return std::string(Options::video.stretch_filter_linear ? "LINEAR" : "NEAREST"); },
|
||||
[](int) { Screen::get()->toggleStretchFilter(); }});
|
||||
items_.push_back({"FILTRE 4:3", ItemKind::Toggle, [] { return std::string(Options::video.stretch_filter_linear ? "LINEAR" : "NEAREST"); }, [](int) { Screen::get()->toggleStretchFilter(); }});
|
||||
|
||||
// RENDER INFO
|
||||
items_.push_back({"RENDER INFO", ItemKind::Cycle,
|
||||
[] {
|
||||
items_.push_back({"RENDER INFO", ItemKind::Cycle, [] {
|
||||
switch (Options::render_info.position) {
|
||||
case Options::RenderInfoPosition::OFF: return std::string("OFF");
|
||||
case Options::RenderInfoPosition::TOP: return std::string("TOP");
|
||||
case Options::RenderInfoPosition::BOTTOM: return std::string("BOTTOM");
|
||||
}
|
||||
return std::string("OFF");
|
||||
},
|
||||
[](int) { Overlay::toggleRenderInfo(); }});
|
||||
return std::string("OFF"); }, [](int dir) { Overlay::cycleRenderInfo(dir); }});
|
||||
}
|
||||
|
||||
// --- Dibuix ---
|
||||
@@ -161,10 +144,10 @@ namespace Menu {
|
||||
}
|
||||
|
||||
static void drawBorder(Uint32* buf, int x, int y, int w, int h, Uint32 color) {
|
||||
fillRect(buf, x, y, w, 1, color); // top
|
||||
fillRect(buf, x, y + h - 1, w, 1, color); // bottom
|
||||
fillRect(buf, x, y, 1, h, color); // left
|
||||
fillRect(buf, x + w - 1, y, 1, h, color); // right
|
||||
fillRect(buf, x, y, w, 1, color); // top
|
||||
fillRect(buf, x, y + h - 1, w, 1, color); // bottom
|
||||
fillRect(buf, x, y, 1, h, color); // left
|
||||
fillRect(buf, x + w - 1, y, 1, h, color); // right
|
||||
}
|
||||
|
||||
// --- API pública ---
|
||||
|
||||
@@ -170,19 +170,13 @@ 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 toggleRenderInfo() { cycleRenderInfo(+1); }
|
||||
|
||||
void cycleRenderInfo(int dir) {
|
||||
// Seqüència: OFF → TOP → BOTTOM → OFF
|
||||
int pos = static_cast<int>(Options::render_info.position);
|
||||
pos = (pos + (dir >= 0 ? 1 : -1) + 3) % 3;
|
||||
Options::render_info.position = static_cast<Options::RenderInfoPosition>(pos);
|
||||
}
|
||||
|
||||
void setRenderInfoText(const char* text) {
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Overlay {
|
||||
|
||||
// Activa/desactiva la info de renderitzat (FPS, driver, shader, preset)
|
||||
void toggleRenderInfo();
|
||||
void cycleRenderInfo(int dir); // dir=+1 avant, -1 endarrere
|
||||
void setRenderInfoText(const char* text);
|
||||
|
||||
// Gestió d'eixida amb doble ESC
|
||||
|
||||
@@ -240,6 +240,29 @@ void Screen::nextPreset() {
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::prevShaderType() {
|
||||
// Només dues opcions — prev == next
|
||||
nextShaderType();
|
||||
}
|
||||
|
||||
void Screen::prevPreset() {
|
||||
if (!shader_backend_ || !shader_backend_->isHardwareAccelerated()) return;
|
||||
|
||||
if (shader_backend_->getActiveShader() == Rendering::ShaderType::POSTFX) {
|
||||
if (Options::postfx_presets.empty()) return;
|
||||
int n = static_cast<int>(Options::postfx_presets.size());
|
||||
Options::current_postfx_preset = (Options::current_postfx_preset - 1 + n) % n;
|
||||
Options::video.current_postfx_preset = Options::postfx_presets[Options::current_postfx_preset].name;
|
||||
applyCurrentPostFXPreset();
|
||||
} else {
|
||||
if (Options::crtpi_presets.empty()) return;
|
||||
int n = static_cast<int>(Options::crtpi_presets.size());
|
||||
Options::current_crtpi_preset = (Options::current_crtpi_preset - 1 + n) % n;
|
||||
Options::video.current_crtpi_preset = Options::crtpi_presets[Options::current_crtpi_preset].name;
|
||||
applyCurrentCrtPiPreset();
|
||||
}
|
||||
}
|
||||
|
||||
auto Screen::getCurrentPresetName() const -> const char* {
|
||||
if (!shader_backend_ || !shader_backend_->isHardwareAccelerated()) return "---";
|
||||
if (shader_backend_->getActiveShader() == Rendering::ShaderType::POSTFX) {
|
||||
|
||||
@@ -29,7 +29,9 @@ class Screen {
|
||||
void toggleIntegerScale();
|
||||
void toggleStretchFilter();
|
||||
void nextShaderType(); // Cicla PostFX ↔ CrtPi (F7)
|
||||
void prevShaderType(); // Cicla al revés
|
||||
void nextPreset(); // Cicla presets del shader actiu (F8)
|
||||
void prevPreset(); // Cicla presets al revés
|
||||
[[nodiscard]] auto getCurrentPresetName() const -> const char*;
|
||||
void setActiveShader(Rendering::ShaderType type);
|
||||
void applyCurrentPostFXPreset();
|
||||
|
||||
Reference in New Issue
Block a user