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,17 +10,24 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# --- GENERACIÓN DE VERSIÓN AUTOMÁTICA --- # --- GENERACIÓN DE VERSIÓN AUTOMÁTICA ---
find_package(Git QUIET) # Si GIT_HASH se ha pasado desde fuera (p.ej. desde el Makefile via -DGIT_HASH=xxx),
if(GIT_FOUND) # lo usamos tal cual. Esto evita problemas con Docker/emscripten, donde git aborta por
execute_process( # "dubious ownership" en el volumen montado. En builds locales sin -DGIT_HASH, se
COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD # resuelve aquí ejecutando git directamente.
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} if(NOT DEFINED GIT_HASH OR GIT_HASH STREQUAL "")
OUTPUT_VARIABLE GIT_HASH find_package(Git QUIET)
OUTPUT_STRIP_TRAILING_WHITESPACE if(GIT_FOUND)
ERROR_QUIET execute_process(
) COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
else() WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
set(GIT_HASH "unknown") OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
if(NOT DEFINED GIT_HASH OR GIT_HASH STREQUAL "")
set(GIT_HASH "unknown")
endif()
endif() endif()
# Configurar archivo de versión # Configurar archivo de versión

View File

@@ -34,6 +34,17 @@ else
VERSION := $(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/') VERSION := $(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/')
endif 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) # SHELL (Windows usa cmd.exe)
# ============================================================================== # ==============================================================================
@@ -411,12 +422,12 @@ raspi_release:
# COMPILACIÓN PARA WEBASSEMBLY (requiere Docker) # COMPILACIÓN PARA WEBASSEMBLY (requiere Docker)
# ============================================================================== # ==============================================================================
wasm: wasm:
@echo "Compilando para WebAssembly - Version: $(VERSION)" @echo "Compilando para WebAssembly - Version: $(VERSION) ($(GIT_HASH))"
docker run --rm \ docker run --rm \
-v $(DIR_ROOT):/src \ -v $(DIR_ROOT):/src \
-w /src \ -w /src \
emscripten/emsdk:latest \ 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" $(MKDIR) "$(DIST_DIR)/wasm"
cp build/wasm/$(TARGET_NAME).html $(DIST_DIR)/wasm/ cp build/wasm/$(TARGET_NAME).html $(DIST_DIR)/wasm/
cp build/wasm/$(TARGET_NAME).js $(DIST_DIR)/wasm/ cp build/wasm/$(TARGET_NAME).js $(DIST_DIR)/wasm/

View File

@@ -21,6 +21,10 @@
namespace GlobalInputs { namespace GlobalInputs {
// Termina // Termina
void quit() { 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"; const std::string CODE = "QUIT";
if (Notifier::get()->checkCode(CODE)) { if (Notifier::get()->checkCode(CODE)) {
// Si la notificación de salir está activa, cambia de sección // 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 // Si la notificación de salir no está activa, muestra la notificación
Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE); Notifier::get()->show({Lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
} }
#endif
} }
// Reinicia // Reinicia

View File

@@ -120,11 +120,14 @@ void Director::init() {
Options::loadCrtPiFromFile(); // Carga los presets CrtPi Options::loadCrtPiFromFile(); // Carga los presets CrtPi
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
// En la versión web el navegador gestiona la ventana: forzamos zoom=1, // En la versión web el navegador gestiona la ventana: ventana (no
// fullscreen para ocupar el canvas, e integer scale para píxeles nítidos. // fullscreen — el canvas ya marca el área), integer scale para píxeles nítidos.
Options::window.zoom = 1; Options::window.zoom = 3;
Options::video.fullscreen = true; Options::video.fullscreen = false;
Options::video.integer_scale = true; 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 #endif
loadParams(); // Carga los parámetros del programa loadParams(); // Carga los parámetros del programa
loadScoreFile(); // Carga el archivo de puntuaciones 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 updateMenu(); // El menú debe refrescarse si algo se oculta
} }