arreglos en service menu per a emscripten

This commit is contained in:
2026-04-14 19:08:45 +02:00
parent 8706b2c7fb
commit 25a36d5064
5 changed files with 58 additions and 17 deletions

View File

@@ -10,6 +10,11 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# --- GENERACIÓN DE VERSIÓN AUTOMÁTICA ---
# Si GIT_HASH se ha pasado desde fuera (p.ej. desde el Makefile via -DGIT_HASH=xxx),
# lo usamos tal cual. Esto evita problemas con Docker/emscripten, donde git aborta por
# "dubious ownership" en el volumen montado. En builds locales sin -DGIT_HASH, se
# resuelve aquí ejecutando git directamente.
if(NOT DEFINED GIT_HASH OR GIT_HASH STREQUAL "")
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
@@ -19,9 +24,11 @@ if(GIT_FOUND)
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
else()
endif()
if(NOT DEFINED GIT_HASH OR GIT_HASH STREQUAL "")
set(GIT_HASH "unknown")
endif()
endif()
# Configurar archivo de versión
configure_file(${CMAKE_SOURCE_DIR}/source/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)

View File

@@ -34,6 +34,17 @@ else
VERSION := $(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/')
endif
# Hash del commit actual, computado en el host. Se pasa a CMake via -DGIT_HASH
# para que el build en docker/emscripten no falle por "dubious ownership" de Git.
ifeq ($(OS),Windows_NT)
GIT_HASH := $(shell git rev-parse --short=7 HEAD 2>NUL)
else
GIT_HASH := $(shell git rev-parse --short=7 HEAD 2>/dev/null)
endif
ifeq ($(GIT_HASH),)
GIT_HASH := unknown
endif
# ==============================================================================
# SHELL (Windows usa cmd.exe)
# ==============================================================================
@@ -411,12 +422,12 @@ raspi_release:
# COMPILACIÓN PARA WEBASSEMBLY (requiere Docker)
# ==============================================================================
wasm:
@echo "Compilando para WebAssembly - Version: $(VERSION)"
@echo "Compilando para WebAssembly - Version: $(VERSION) ($(GIT_HASH))"
docker run --rm \
-v $(DIR_ROOT):/src \
-w /src \
emscripten/emsdk:latest \
bash -c "emcmake cmake -S . -B build/wasm -DCMAKE_BUILD_TYPE=Release && cmake --build build/wasm"
bash -c "emcmake cmake -S . -B build/wasm -DCMAKE_BUILD_TYPE=Release -DGIT_HASH=$(GIT_HASH) && cmake --build build/wasm"
$(MKDIR) "$(DIST_DIR)/wasm"
cp build/wasm/$(TARGET_NAME).html $(DIST_DIR)/wasm/
cp build/wasm/$(TARGET_NAME).js $(DIST_DIR)/wasm/

View File

@@ -21,6 +21,10 @@
namespace GlobalInputs {
// Termina
void quit() {
#ifdef __EMSCRIPTEN__
// En la versión web no se permite salir: el navegador gestiona el cierre.
return;
#else
const std::string CODE = "QUIT";
if (Notifier::get()->checkCode(CODE)) {
// Si la notificación de salir está activa, cambia de sección
@@ -30,6 +34,7 @@ namespace GlobalInputs {
// Si la notificación de salir no está activa, muestra la notificación
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
}
#endif
}
// Reinicia

View File

@@ -120,11 +120,14 @@ void Director::init() {
Options::loadCrtPiFromFile(); // Carga los presets CrtPi
#ifdef __EMSCRIPTEN__
// En la versión web el navegador gestiona la ventana: forzamos zoom=1,
// fullscreen para ocupar el canvas, e integer scale para píxeles nítidos.
Options::window.zoom = 1;
Options::video.fullscreen = true;
// En la versión web el navegador gestiona la ventana: ventana (no
// fullscreen — el canvas ya marca el área), integer scale para píxeles nítidos.
Options::window.zoom = 3;
Options::video.fullscreen = false;
Options::video.integer_scale = true;
// Precarga silenciosa: pantalla negra mientras el .data termina de descargarse.
Options::loading.show = false;
Options::loading.wait_for_input = false;
#endif
loadParams(); // Carga los parámetros del programa
loadScoreFile(); // Carga el archivo de puntuaciones

View File

@@ -642,6 +642,21 @@ void ServiceMenu::setHiddenOptions() {
}
}
#ifdef __EMSCRIPTEN__
// En la versión web no tiene sentido exponer: shaders (build sin shaders),
// permitir apagar el sistema (no aplica al navegador) ni salir del juego
// (lo gestiona el navegador).
for (const auto& caption : {
Lang::getText("[SERVICE_MENU] SHADER"),
Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"),
Lang::getText("[SERVICE_MENU] QUIT")}) {
auto* option = getOptionByCaption(caption);
if (option != nullptr) {
option->setHidden(true);
}
}
#endif
updateMenu(); // El menú debe refrescarse si algo se oculta
}