Compare commits
3 Commits
4ac34b8583
...
4c1ed1cf9b
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c1ed1cf9b | |||
| f80d0a656e | |||
| 4429cd92c1 |
38
CLAUDE.md
38
CLAUDE.md
@@ -44,24 +44,38 @@ make tidy-fix # run clang-tidy with auto-fix
|
||||
|
||||
## Architecture
|
||||
|
||||
### Singletons (core systems)
|
||||
- **Director** (`source/director.hpp`) — Application state machine, orchestrates scene transitions (Logo → Intro → Title → Game → Credits/HiScore → Title)
|
||||
- **Screen** (`source/screen.hpp`) — Window management, SDL3 GPU rendering pipeline, post-processing effects
|
||||
- **Resource** (`source/resource.hpp`) — Asset loading/caching with PRELOAD and LAZY_LOAD modes, reads from `resources.pack`
|
||||
- **Audio** (`source/audio.hpp`) — Music and SFX management
|
||||
- **Input** (`source/input.hpp`) — Keyboard and gamepad input handling
|
||||
### Source layout
|
||||
The `source/` tree is organised in the same style as the sibling projects `projecte_2026` and `jaildoctors_dilemma`:
|
||||
|
||||
### Scenes (source/sections/)
|
||||
```
|
||||
source/
|
||||
├── core/ # engine: audio, input, locale, rendering (+ sdl3gpu, sprite), resources, system
|
||||
├── game/ # gameplay: entities, gameplay, scenes, ui, options
|
||||
├── utils/ # color, param, utils
|
||||
├── external/ # vendored third-party headers (json, fkyaml, stb_*)
|
||||
└── main.cpp
|
||||
```
|
||||
|
||||
`#include` paths are absolute relative to `source/` (e.g. `#include "core/audio/audio.hpp"`, `#include "game/scenes/logo.hpp"`). The CMake build adds a single `-I${CMAKE_SOURCE_DIR}/source`.
|
||||
|
||||
### Singletons (core systems)
|
||||
- **Director** (`source/core/system/director.hpp`) — Application state machine, orchestrates scene transitions (Logo → Intro → Title → Game → Credits/HiScore → Title)
|
||||
- **Screen** (`source/core/rendering/screen.hpp`) — Window management, SDL3 GPU rendering pipeline, post-processing effects
|
||||
- **Resource** (`source/core/resources/resource.hpp`) — Asset loading/caching with PRELOAD and LAZY_LOAD modes, reads from `resources.pack`
|
||||
- **Audio** (`source/core/audio/audio.hpp`) — Music and SFX management
|
||||
- **Input** (`source/core/input/input.hpp`) — Keyboard and gamepad input handling
|
||||
|
||||
### Scenes (source/game/scenes/)
|
||||
Each scene is a self-contained class with update/render lifecycle. Scene flow is managed by Director.
|
||||
|
||||
### Entity Managers
|
||||
- `BalloonManager` / `BulletManager` — Object pool-based entity management
|
||||
- `Player` — Two-player support (player 1: keyboard, player 2: gamepad)
|
||||
- `BalloonManager` / `BulletManager` — Object pool-based entity management (`source/game/gameplay/`)
|
||||
- `Player` — Two-player support (player 1: keyboard, player 2: gamepad) (`source/game/entities/`)
|
||||
|
||||
### Rendering Pipeline
|
||||
- SDL3 GPU API (Vulkan/Metal/D3D12 backends)
|
||||
- SPIR-V shaders compiled offline from GLSL (`data/shaders/`) via `glslc`
|
||||
- Compiled shader headers embedded in `source/rendering/sdl3gpu/postfx_*_spv.h`
|
||||
- Compiled shader headers embedded in `source/core/rendering/sdl3gpu/postfx_*_spv.h`
|
||||
- macOS uses Metal (no SPIR-V compilation needed)
|
||||
|
||||
### Configuration
|
||||
@@ -72,7 +86,9 @@ Each scene is a self-contained class with update/render lifecycle. Scene flow is
|
||||
- Gamepad mappings: `config/gamecontrollerdb.txt`
|
||||
|
||||
### External Libraries (header-only/vendored in source/external/)
|
||||
- nlohmann/json, fkyaml (YAML), stb_image, stb_vorbis, jail_audio
|
||||
- nlohmann/json, fkyaml (YAML), stb_image, stb_vorbis
|
||||
|
||||
`jail_audio` lives in `source/core/audio/` and `gif.{hpp,cpp}` in `source/core/rendering/` — these are first-party, not third-party.
|
||||
|
||||
## Code Style
|
||||
|
||||
|
||||
237
CMakeLists.txt
237
CMakeLists.txt
@@ -28,99 +28,120 @@ configure_file(${CMAKE_SOURCE_DIR}/source/version.h.in ${CMAKE_BINARY_DIR}/versi
|
||||
|
||||
# --- 1. LISTA EXPLÍCITA DE FUENTES ---
|
||||
set(APP_SOURCES
|
||||
# --- Archivos Principales del Sistema ---
|
||||
source/asset.cpp
|
||||
source/audio.cpp
|
||||
source/director.cpp
|
||||
source/global_events.cpp
|
||||
source/global_inputs.cpp
|
||||
source/input.cpp
|
||||
source/lang.cpp
|
||||
source/main.cpp
|
||||
source/param.cpp
|
||||
source/resource.cpp
|
||||
source/resource_helper.cpp
|
||||
source/resource_loader.cpp
|
||||
source/resource_pack.cpp
|
||||
source/screen.cpp
|
||||
source/text.cpp
|
||||
source/writer.cpp
|
||||
|
||||
# --- UI (User Interface) ---
|
||||
source/ui/menu_option.cpp
|
||||
source/ui/menu_renderer.cpp
|
||||
source/ui/notifier.cpp
|
||||
source/ui/service_menu.cpp
|
||||
source/ui/ui_message.cpp
|
||||
source/ui/window_message.cpp
|
||||
# --- core/audio ---
|
||||
source/core/audio/audio.cpp
|
||||
|
||||
# --- Lógica del Juego ---
|
||||
source/balloon_formations.cpp
|
||||
source/balloon_manager.cpp
|
||||
source/balloon.cpp
|
||||
source/bullet.cpp
|
||||
source/bullet_manager.cpp
|
||||
source/enter_name.cpp
|
||||
source/explosions.cpp
|
||||
source/game_logo.cpp
|
||||
source/item.cpp
|
||||
source/manage_hiscore_table.cpp
|
||||
source/player.cpp
|
||||
source/scoreboard.cpp
|
||||
source/tabe.cpp
|
||||
# --- core/input ---
|
||||
source/core/input/define_buttons.cpp
|
||||
source/core/input/global_inputs.cpp
|
||||
source/core/input/input.cpp
|
||||
source/core/input/input_types.cpp
|
||||
source/core/input/mouse.cpp
|
||||
|
||||
# --- Escenas ---
|
||||
source/sections/credits.cpp
|
||||
source/sections/game.cpp
|
||||
source/sections/hiscore_table.cpp
|
||||
source/sections/instructions.cpp
|
||||
source/sections/intro.cpp
|
||||
source/sections/logo.cpp
|
||||
source/sections/title.cpp
|
||||
# --- core/locale ---
|
||||
source/core/locale/lang.cpp
|
||||
|
||||
# --- Sprites y Gráficos ---
|
||||
source/animated_sprite.cpp
|
||||
source/background.cpp
|
||||
source/card_sprite.cpp
|
||||
source/fade.cpp
|
||||
source/moving_sprite.cpp
|
||||
source/path_sprite.cpp
|
||||
source/smart_sprite.cpp
|
||||
source/sprite.cpp
|
||||
source/texture.cpp
|
||||
source/tiled_bg.cpp
|
||||
# --- core/rendering ---
|
||||
source/core/rendering/background.cpp
|
||||
source/core/rendering/fade.cpp
|
||||
source/core/rendering/gif.cpp
|
||||
source/core/rendering/screen.cpp
|
||||
source/core/rendering/text.cpp
|
||||
source/core/rendering/texture.cpp
|
||||
source/core/rendering/tiled_bg.cpp
|
||||
source/core/rendering/writer.cpp
|
||||
source/core/rendering/sdl3gpu/sdl3gpu_shader.cpp
|
||||
source/core/rendering/sprite/animated_sprite.cpp
|
||||
source/core/rendering/sprite/card_sprite.cpp
|
||||
source/core/rendering/sprite/moving_sprite.cpp
|
||||
source/core/rendering/sprite/path_sprite.cpp
|
||||
source/core/rendering/sprite/smart_sprite.cpp
|
||||
source/core/rendering/sprite/sprite.cpp
|
||||
|
||||
# --- Otros ---
|
||||
source/color.cpp
|
||||
source/demo.cpp
|
||||
source/define_buttons.cpp
|
||||
source/difficulty.cpp
|
||||
source/input_types.cpp
|
||||
source/mouse.cpp
|
||||
source/options.cpp
|
||||
source/shutdown.cpp
|
||||
source/stage.cpp
|
||||
source/system_utils.cpp
|
||||
source/utils.cpp
|
||||
)
|
||||
# --- core/resources ---
|
||||
source/core/resources/asset.cpp
|
||||
source/core/resources/asset_integrated.cpp
|
||||
source/core/resources/resource.cpp
|
||||
source/core/resources/resource_helper.cpp
|
||||
source/core/resources/resource_loader.cpp
|
||||
source/core/resources/resource_pack.cpp
|
||||
|
||||
# Fuentes de librerías de terceros
|
||||
set(EXTERNAL_SOURCES
|
||||
source/external/json.hpp
|
||||
source/external/gif.cpp
|
||||
)
|
||||
# --- core/system ---
|
||||
source/core/system/demo.cpp
|
||||
source/core/system/director.cpp
|
||||
source/core/system/global_events.cpp
|
||||
source/core/system/shutdown.cpp
|
||||
source/core/system/system_utils.cpp
|
||||
|
||||
# Fuentes del sistema de renderizado
|
||||
set(RENDERING_SOURCES
|
||||
source/rendering/sdl3gpu/sdl3gpu_shader.cpp
|
||||
# --- game ---
|
||||
source/game/options.cpp
|
||||
|
||||
# --- game/entities ---
|
||||
source/game/entities/balloon.cpp
|
||||
source/game/entities/bullet.cpp
|
||||
source/game/entities/explosions.cpp
|
||||
source/game/entities/item.cpp
|
||||
source/game/entities/player.cpp
|
||||
source/game/entities/tabe.cpp
|
||||
|
||||
# --- game/gameplay ---
|
||||
source/game/gameplay/balloon_formations.cpp
|
||||
source/game/gameplay/balloon_manager.cpp
|
||||
source/game/gameplay/bullet_manager.cpp
|
||||
source/game/gameplay/difficulty.cpp
|
||||
source/game/gameplay/enter_name.cpp
|
||||
source/game/gameplay/game_logo.cpp
|
||||
source/game/gameplay/manage_hiscore_table.cpp
|
||||
source/game/gameplay/scoreboard.cpp
|
||||
source/game/gameplay/stage.cpp
|
||||
|
||||
# --- game/scenes ---
|
||||
source/game/scenes/credits.cpp
|
||||
source/game/scenes/game.cpp
|
||||
source/game/scenes/hiscore_table.cpp
|
||||
source/game/scenes/instructions.cpp
|
||||
source/game/scenes/intro.cpp
|
||||
source/game/scenes/logo.cpp
|
||||
source/game/scenes/title.cpp
|
||||
|
||||
# --- game/ui ---
|
||||
source/game/ui/menu_option.cpp
|
||||
source/game/ui/menu_renderer.cpp
|
||||
source/game/ui/notifier.cpp
|
||||
source/game/ui/service_menu.cpp
|
||||
source/game/ui/ui_message.cpp
|
||||
source/game/ui/window_message.cpp
|
||||
|
||||
# --- utils ---
|
||||
source/utils/color.cpp
|
||||
source/utils/param.cpp
|
||||
source/utils/utils.cpp
|
||||
)
|
||||
|
||||
# Configuración de SDL3
|
||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
||||
if(EMSCRIPTEN)
|
||||
# En Emscripten, SDL3 se compila desde source con FetchContent
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-3.2.12
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
message(STATUS "SDL3 compilado desde source para Emscripten")
|
||||
else()
|
||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
# --- SHADER COMPILATION (Linux/Windows only - macOS uses Metal) ---
|
||||
if(NOT APPLE)
|
||||
# --- SHADER COMPILATION (Linux/Windows only - macOS uses Metal, Emscripten no soporta SDL3 GPU) ---
|
||||
if(NOT APPLE AND NOT EMSCRIPTEN)
|
||||
find_program(GLSLC_EXE NAMES glslc)
|
||||
|
||||
set(SHADER_VERT_SRC "${CMAKE_SOURCE_DIR}/data/shaders/postfx.vert")
|
||||
@@ -129,11 +150,11 @@ if(NOT APPLE)
|
||||
set(SHADER_UPSCALE_SRC "${CMAKE_SOURCE_DIR}/data/shaders/upscale.frag")
|
||||
set(SHADER_DOWNSCALE_SRC "${CMAKE_SOURCE_DIR}/data/shaders/downscale.frag")
|
||||
|
||||
set(SHADER_VERT_H "${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu/postfx_vert_spv.h")
|
||||
set(SHADER_FRAG_H "${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu/postfx_frag_spv.h")
|
||||
set(SHADER_CRTPI_H "${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu/crtpi_frag_spv.h")
|
||||
set(SHADER_UPSCALE_H "${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu/upscale_frag_spv.h")
|
||||
set(SHADER_DOWNSCALE_H "${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu/downscale_frag_spv.h")
|
||||
set(SHADER_VERT_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/postfx_vert_spv.h")
|
||||
set(SHADER_FRAG_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/postfx_frag_spv.h")
|
||||
set(SHADER_CRTPI_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/crtpi_frag_spv.h")
|
||||
set(SHADER_UPSCALE_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/upscale_frag_spv.h")
|
||||
set(SHADER_DOWNSCALE_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/downscale_frag_spv.h")
|
||||
|
||||
set(ALL_SHADER_SOURCES "${SHADER_VERT_SRC}" "${SHADER_FRAG_SRC}" "${SHADER_CRTPI_SRC}" "${SHADER_UPSCALE_SRC}" "${SHADER_DOWNSCALE_SRC}")
|
||||
set(ALL_SHADER_HEADERS "${SHADER_VERT_H}" "${SHADER_FRAG_H}" "${SHADER_CRTPI_H}" "${SHADER_UPSCALE_H}" "${SHADER_DOWNSCALE_H}")
|
||||
@@ -179,22 +200,30 @@ if(NOT APPLE)
|
||||
message(STATUS "glslc no encontrado - usando headers SPIR-V precompilados")
|
||||
endif()
|
||||
else()
|
||||
if(EMSCRIPTEN)
|
||||
message(STATUS "Emscripten: shaders SPIR-V omitidos (SDL3 GPU no soportado en WebGL2)")
|
||||
else()
|
||||
message(STATUS "macOS: shaders SPIR-V omitidos (usa Metal)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# --- 2. AÑADIR EJECUTABLE ---
|
||||
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${EXTERNAL_SOURCES} ${RENDERING_SOURCES})
|
||||
if(EMSCRIPTEN)
|
||||
# En Emscripten no compilamos sdl3gpu_shader (SDL3 GPU no está soportado en WebGL2)
|
||||
set(APP_SOURCES_WASM ${APP_SOURCES})
|
||||
list(REMOVE_ITEM APP_SOURCES_WASM source/core/rendering/sdl3gpu/sdl3gpu_shader.cpp)
|
||||
add_executable(${PROJECT_NAME} ${APP_SOURCES_WASM})
|
||||
else()
|
||||
add_executable(${PROJECT_NAME} ${APP_SOURCES})
|
||||
endif()
|
||||
|
||||
if(NOT APPLE AND GLSLC_EXE)
|
||||
if(NOT APPLE AND NOT EMSCRIPTEN AND GLSLC_EXE)
|
||||
add_dependencies(${PROJECT_NAME} shaders)
|
||||
endif()
|
||||
|
||||
# --- 3. DIRECTORIOS DE INCLUSIÓN ---
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/source"
|
||||
"${CMAKE_SOURCE_DIR}/source/external"
|
||||
"${CMAKE_SOURCE_DIR}/source/rendering"
|
||||
"${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu"
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
)
|
||||
|
||||
@@ -231,12 +260,33 @@ elseif(APPLE)
|
||||
-rpath @executable_path/../Frameworks/
|
||||
)
|
||||
endif()
|
||||
elseif(EMSCRIPTEN)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE EMSCRIPTEN_BUILD NO_SHADERS)
|
||||
# -fexceptions: habilita excepciones C++ (fkyaml, std::runtime_error...) — sin esto cualquier throw llama a abort()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE
|
||||
"SHELL:--preload-file ${CMAKE_SOURCE_DIR}/data@/data"
|
||||
"SHELL:--preload-file ${CMAKE_SOURCE_DIR}/config@/config"
|
||||
-fexceptions
|
||||
-sALLOW_MEMORY_GROWTH=1
|
||||
-sMAX_WEBGL_VERSION=2
|
||||
-sINITIAL_MEMORY=67108864
|
||||
-sASSERTIONS=1
|
||||
# ASYNCIFY solo para permitir emscripten_sleep(0) durante la precarga de recursos
|
||||
# (el bucle principal del juego ya usa SDL3 Callback API, no depende de ASYNCIFY).
|
||||
-sASYNCIFY=1
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html")
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
|
||||
endif()
|
||||
|
||||
# Especificar la ubicación del ejecutable
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
# --- 5. STATIC ANALYSIS TARGETS ---
|
||||
|
||||
@@ -331,9 +381,6 @@ if(CPPCHECK_EXE)
|
||||
-DLINUX_BUILD
|
||||
--quiet
|
||||
-I ${CMAKE_SOURCE_DIR}/source
|
||||
-I ${CMAKE_SOURCE_DIR}/source/external
|
||||
-I ${CMAKE_SOURCE_DIR}/source/rendering
|
||||
-I ${CMAKE_SOURCE_DIR}/source/rendering/sdl3gpu
|
||||
${CPPCHECK_SOURCES}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Running cppcheck..."
|
||||
|
||||
20
Makefile
20
Makefile
@@ -407,6 +407,23 @@ raspi_release:
|
||||
# Elimina la carpeta temporal
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
# ==============================================================================
|
||||
# COMPILACIÓN PARA WEBASSEMBLY (requiere Docker)
|
||||
# ==============================================================================
|
||||
wasm:
|
||||
@echo "Compilando para WebAssembly - Version: $(VERSION)"
|
||||
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"
|
||||
$(MKDIR) "$(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).wasm $(DIST_DIR)/wasm/
|
||||
cp build/wasm/$(TARGET_NAME).data $(DIST_DIR)/wasm/
|
||||
@echo "Output: $(DIST_DIR)/wasm/"
|
||||
|
||||
# ==============================================================================
|
||||
# CODE QUALITY (delegados a cmake)
|
||||
# ==============================================================================
|
||||
@@ -447,6 +464,7 @@ help:
|
||||
@echo " make linux_release_desktop - Crear release con integracion desktop para Linux"
|
||||
@echo " make macos_release - Crear release para macOS"
|
||||
@echo " make raspi_release - Crear release para Raspberry Pi"
|
||||
@echo " make wasm - Crear build WebAssembly (requiere Docker) en dist/wasm"
|
||||
@echo ""
|
||||
@echo " Herramientas:"
|
||||
@echo " make spirv - Compilar shaders SPIR-V"
|
||||
@@ -463,4 +481,4 @@ help:
|
||||
@echo " make show_version - Mostrar version actual ($(VERSION))"
|
||||
@echo " make help - Mostrar esta ayuda"
|
||||
|
||||
.PHONY: all debug release windows_release macos_release linux_release linux_release_desktop raspi_release pack_tool resources.pack spirv format format-check tidy tidy-fix show_version help
|
||||
.PHONY: all debug release windows_release macos_release linux_release linux_release_desktop raspi_release wasm pack_tool resources.pack spirv format format-check tidy tidy-fix show_version help
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "audio.hpp"
|
||||
#include "core/audio/audio.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_G...
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#undef PLAYBACK_RIGHT
|
||||
// clang-format on
|
||||
|
||||
#include "external/jail_audio.hpp" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...
|
||||
#include "options.hpp" // Para AudioOptions, audio, MusicOptions
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "core/audio/jail_audio.hpp" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para AudioOptions, audio, MusicOptions
|
||||
|
||||
// Singleton
|
||||
Audio* Audio::instance = nullptr;
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "define_buttons.hpp"
|
||||
#include "core/input/define_buttons.hpp"
|
||||
|
||||
#include <algorithm> // Para __all_of_fn, all_of
|
||||
#include <memory> // Para unique_ptr, allocator, shared_ptr, operator==, make_unique
|
||||
|
||||
#include "input.hpp" // Para Input
|
||||
#include "input_types.hpp" // Para InputAction
|
||||
#include "lang.hpp" // Para getText
|
||||
#include "options.hpp" // Para Gamepad
|
||||
#include "param.hpp" // Para Param, param, ParamGame, ParamServiceMenu
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "ui/window_message.hpp" // Para WindowMessage
|
||||
#include "utils.hpp" // Para Zone
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/input_types.hpp" // Para InputAction
|
||||
#include "core/locale/lang.hpp" // Para getText
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para Gamepad
|
||||
#include "game/ui/window_message.hpp" // Para WindowMessage
|
||||
#include "utils/param.hpp" // Para Param, param, ParamGame, ParamServiceMenu
|
||||
#include "utils/utils.hpp" // Para Zone
|
||||
|
||||
DefineButtons::DefineButtons()
|
||||
: input_(Input::get()) {
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "input.hpp"
|
||||
#include "ui/window_message.hpp"
|
||||
#include "core/input/input.hpp"
|
||||
#include "game/ui/window_message.hpp"
|
||||
|
||||
namespace Options {
|
||||
struct Gamepad;
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "core/input/input_types.hpp" // Solo incluimos los tipos compartidos
|
||||
#include "external/json.hpp"
|
||||
#include "input_types.hpp" // Solo incluimos los tipos compartidos
|
||||
|
||||
// --- Estructuras ---
|
||||
struct GamepadConfig {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "global_inputs.hpp"
|
||||
#include "core/input/global_inputs.hpp"
|
||||
|
||||
#include <algorithm> // Para __any_of_fn, any_of
|
||||
#include <functional> // Para function
|
||||
@@ -7,16 +7,16 @@
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "input.hpp" // Para Input
|
||||
#include "input_types.hpp" // Para InputAction
|
||||
#include "lang.hpp" // Para getText, getLangFile, getLangName, getNextLangCode, loadFromFile
|
||||
#include "options.hpp" // Para Video, video, Settings, settings, Audio, audio, Window, window
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "section.hpp" // Para Name, name, Options, options, AttractMode, attract_mode
|
||||
#include "ui/notifier.hpp" // Para Notifier
|
||||
#include "ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils.hpp" // Para boolToOnOff
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/input_types.hpp" // Para InputAction
|
||||
#include "core/locale/lang.hpp" // Para getText, getLangFile, getLangName, getNextLangCode, loadFromFile
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/system/section.hpp" // Para Name, name, Options, options, AttractMode, attract_mode
|
||||
#include "game/options.hpp" // Para Video, video, Settings, settings, Audio, audio, Window, window
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils/utils.hpp" // Para boolToOnOff
|
||||
|
||||
namespace GlobalInputs {
|
||||
// Termina
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "input.hpp"
|
||||
#include "core/input/input.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_GetGamepadAxis, SDL_GamepadAxis, SDL_GamepadButton, SDL_GetError, SDL_JoystickID, SDL_AddGamepadMappingsFromFile, SDL_Event, SDL_EventType, SDL_GetGamepadButton, SDL_GetKeyboardState, SDL_INIT_GAMEPAD, SDL_InitSubSystem, SDL_LogError, SDL_OpenGamepad, SDL_PollEvent, SDL_WasInit, Sint16, SDL_Gamepad, SDL_LogCategory, SDL_Scancode
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "gamepad_config_manager.hpp" // for GamepadConfig (ptr only), GamepadConfigs
|
||||
#include "input_types.hpp" // for InputAction
|
||||
#include "core/input/gamepad_config_manager.hpp" // for GamepadConfig (ptr only), GamepadConfigs
|
||||
#include "core/input/input_types.hpp" // for InputAction
|
||||
|
||||
// --- Clase Input: gestiona la entrada de teclado y mandos (singleton) ---
|
||||
class Input {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "input_types.hpp"
|
||||
#include "core/input/input_types.hpp"
|
||||
|
||||
#include <utility> // Para pair
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "mouse.hpp"
|
||||
#include "core/input/mouse.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_HideCursor, SDL_Show...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "lang.hpp"
|
||||
#include "core/locale/lang.hpp"
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <exception> // Para exception
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "difficulty.hpp" // Para Difficulty
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "external/json.hpp" // Para basic_json, iteration_proxy_value, oper...
|
||||
#include "options.hpp" // Para SettingsOpt...
|
||||
#include "resource_helper.hpp" // Para ResourceHelper
|
||||
#include "game/gameplay/difficulty.hpp" // Para Difficulty
|
||||
#include "game/options.hpp" // Para SettingsOpt...
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "background.hpp"
|
||||
#include "core/rendering/background.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_GetRenderTarget, SDL_RenderTexture, SDL_SetTextureAlphaMod, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_TextureAccess, SDL_FPoint
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#include <string> // Para basic_string
|
||||
#include <utility> // Para move
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "moving_sprite.hpp" // Para MovingSprite
|
||||
#include "param.hpp" // Para Param, ParamBackground, param
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "sprite.hpp" // Para Sprite
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "utils.hpp" // Para easeOutCubic
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/sprite/moving_sprite.hpp" // Para MovingSprite
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "utils/param.hpp" // Para Param, ParamBackground, param
|
||||
#include "utils/utils.hpp" // Para easeOutCubic
|
||||
|
||||
// Constructor
|
||||
Background::Background(float total_progress_to_complete)
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <memory> // Para unique_ptr, shared_ptr
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "color.hpp" // Para Color
|
||||
#include "utils/color.hpp" // Para Color
|
||||
|
||||
class MovingSprite;
|
||||
class Sprite;
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "fade.hpp"
|
||||
#include "core/rendering/fade.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "param.hpp"
|
||||
#include "screen.hpp"
|
||||
#include "core/rendering/screen.hpp"
|
||||
#include "utils/color.hpp"
|
||||
#include "utils/param.hpp"
|
||||
|
||||
// Constructor
|
||||
Fade::Fade()
|
||||
253
source/core/rendering/gif.cpp
Normal file
253
source/core/rendering/gif.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
#include "core/rendering/gif.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, SDL_LogInfo
|
||||
|
||||
#include <cstring> // Para memcpy, size_t
|
||||
#include <iostream> // Para std::cout
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para char_traits, operator==, basic_string, string
|
||||
|
||||
namespace GIF {
|
||||
inline void readBytes(const uint8_t *&buffer, void *dst, size_t size) {
|
||||
std::memcpy(dst, buffer, size);
|
||||
buffer += size;
|
||||
}
|
||||
|
||||
void Gif::decompress(int code_length, const uint8_t *input, int input_length, uint8_t *out) {
|
||||
if (code_length < 2 || code_length > 12) {
|
||||
std::cout << "Invalid LZW code length: " << code_length << '\n';
|
||||
throw std::runtime_error("Invalid LZW code length");
|
||||
}
|
||||
|
||||
int i, bit;
|
||||
int prev = -1;
|
||||
std::vector<DictionaryEntry> dictionary;
|
||||
int dictionary_ind;
|
||||
unsigned int mask = 0x01;
|
||||
int reset_code_length = code_length;
|
||||
int clear_code = 1 << code_length;
|
||||
int stop_code = clear_code + 1;
|
||||
int match_len = 0;
|
||||
|
||||
dictionary.resize(1 << (code_length + 1));
|
||||
for (dictionary_ind = 0; dictionary_ind < (1 << code_length); dictionary_ind++) {
|
||||
dictionary[dictionary_ind].byte = static_cast<uint8_t>(dictionary_ind);
|
||||
dictionary[dictionary_ind].prev = -1;
|
||||
dictionary[dictionary_ind].len = 1;
|
||||
}
|
||||
dictionary_ind += 2;
|
||||
|
||||
while (input_length > 0) {
|
||||
int code = 0;
|
||||
for (i = 0; i < (code_length + 1); i++) {
|
||||
if (input_length <= 0) {
|
||||
std::cout << "Unexpected end of input in decompress" << '\n';
|
||||
throw std::runtime_error("Unexpected end of input in decompress");
|
||||
}
|
||||
bit = ((*input & mask) != 0) ? 1 : 0;
|
||||
mask <<= 1;
|
||||
if (mask == 0x100) {
|
||||
mask = 0x01;
|
||||
input++;
|
||||
input_length--;
|
||||
}
|
||||
code |= (bit << i);
|
||||
}
|
||||
|
||||
if (code == clear_code) {
|
||||
code_length = reset_code_length;
|
||||
dictionary.resize(1 << (code_length + 1));
|
||||
for (dictionary_ind = 0; dictionary_ind < (1 << code_length); dictionary_ind++) {
|
||||
dictionary[dictionary_ind].byte = static_cast<uint8_t>(dictionary_ind);
|
||||
dictionary[dictionary_ind].prev = -1;
|
||||
dictionary[dictionary_ind].len = 1;
|
||||
}
|
||||
dictionary_ind += 2;
|
||||
prev = -1;
|
||||
continue;
|
||||
} else if (code == stop_code) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (prev > -1 && code_length < 12) {
|
||||
if (code > dictionary_ind) {
|
||||
std::cout << "LZW error: code (" << code << ") exceeds dictionary_ind (" << dictionary_ind << ")" << '\n';
|
||||
throw std::runtime_error("LZW error: code exceeds dictionary_ind.");
|
||||
}
|
||||
|
||||
int ptr;
|
||||
if (code == dictionary_ind) {
|
||||
ptr = prev;
|
||||
while (dictionary[ptr].prev != -1)
|
||||
ptr = dictionary[ptr].prev;
|
||||
dictionary[dictionary_ind].byte = dictionary[ptr].byte;
|
||||
} else {
|
||||
ptr = code;
|
||||
while (dictionary[ptr].prev != -1)
|
||||
ptr = dictionary[ptr].prev;
|
||||
dictionary[dictionary_ind].byte = dictionary[ptr].byte;
|
||||
}
|
||||
dictionary[dictionary_ind].prev = prev;
|
||||
dictionary[dictionary_ind].len = dictionary[prev].len + 1;
|
||||
dictionary_ind++;
|
||||
|
||||
if ((dictionary_ind == (1 << (code_length + 1))) && (code_length < 11)) {
|
||||
code_length++;
|
||||
dictionary.resize(1 << (code_length + 1));
|
||||
}
|
||||
}
|
||||
|
||||
prev = code;
|
||||
|
||||
if (code < 0 || static_cast<size_t>(code) >= dictionary.size()) {
|
||||
std::cout << "Invalid LZW code " << code << ", dictionary size " << static_cast<unsigned long>(dictionary.size()) << '\n';
|
||||
throw std::runtime_error("LZW error: invalid code encountered");
|
||||
}
|
||||
|
||||
int curCode = code;
|
||||
match_len = dictionary[curCode].len;
|
||||
while (curCode != -1) {
|
||||
out[dictionary[curCode].len - 1] = dictionary[curCode].byte;
|
||||
if (dictionary[curCode].prev == curCode) {
|
||||
std::cout << "Internal error; self-reference detected." << '\n';
|
||||
throw std::runtime_error("Internal error in decompress: self-reference");
|
||||
}
|
||||
curCode = dictionary[curCode].prev;
|
||||
}
|
||||
out += match_len;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::readSubBlocks(const uint8_t *&buffer) {
|
||||
std::vector<uint8_t> data;
|
||||
uint8_t block_size = *buffer;
|
||||
buffer++;
|
||||
while (block_size != 0) {
|
||||
data.insert(data.end(), buffer, buffer + block_size);
|
||||
buffer += block_size;
|
||||
block_size = *buffer;
|
||||
buffer++;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::processImageDescriptor(const uint8_t *&buffer, const std::vector<RGB> &gct, int resolution_bits) {
|
||||
ImageDescriptor image_descriptor;
|
||||
readBytes(buffer, &image_descriptor, sizeof(ImageDescriptor));
|
||||
|
||||
uint8_t lzw_code_size;
|
||||
readBytes(buffer, &lzw_code_size, sizeof(uint8_t));
|
||||
|
||||
std::vector<uint8_t> compressed_data = readSubBlocks(buffer);
|
||||
int uncompressed_data_length = image_descriptor.image_width * image_descriptor.image_height;
|
||||
std::vector<uint8_t> uncompressed_data(uncompressed_data_length);
|
||||
|
||||
decompress(lzw_code_size, compressed_data.data(), static_cast<int>(compressed_data.size()), uncompressed_data.data());
|
||||
return uncompressed_data;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> Gif::loadPalette(const uint8_t *buffer) {
|
||||
uint8_t header[6];
|
||||
std::memcpy(header, buffer, 6);
|
||||
buffer += 6;
|
||||
|
||||
ScreenDescriptor screen_descriptor;
|
||||
std::memcpy(&screen_descriptor, buffer, sizeof(ScreenDescriptor));
|
||||
buffer += sizeof(ScreenDescriptor);
|
||||
|
||||
std::vector<uint32_t> global_color_table;
|
||||
if (screen_descriptor.fields & 0x80) {
|
||||
int global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
|
||||
global_color_table.resize(global_color_table_size);
|
||||
for (int i = 0; i < global_color_table_size; ++i) {
|
||||
uint8_t r = buffer[0];
|
||||
uint8_t g = buffer[1];
|
||||
uint8_t b = buffer[2];
|
||||
global_color_table[i] = (r << 16) | (g << 8) | b;
|
||||
buffer += 3;
|
||||
}
|
||||
}
|
||||
return global_color_table;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::processGifStream(const uint8_t *buffer, uint16_t &w, uint16_t &h) {
|
||||
uint8_t header[6];
|
||||
std::memcpy(header, buffer, 6);
|
||||
buffer += 6;
|
||||
|
||||
std::string headerStr(reinterpret_cast<char *>(header), 6);
|
||||
if (headerStr != "GIF87a" && headerStr != "GIF89a") {
|
||||
std::cout << "Formato de archivo GIF inválido: " << headerStr << '\n';
|
||||
throw std::runtime_error("Formato de archivo GIF inválido.");
|
||||
}
|
||||
|
||||
ScreenDescriptor screen_descriptor;
|
||||
readBytes(buffer, &screen_descriptor, sizeof(ScreenDescriptor));
|
||||
|
||||
w = screen_descriptor.width;
|
||||
h = screen_descriptor.height;
|
||||
|
||||
int color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
|
||||
std::vector<RGB> global_color_table;
|
||||
if (screen_descriptor.fields & 0x80) {
|
||||
int global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
|
||||
global_color_table.resize(global_color_table_size);
|
||||
std::memcpy(global_color_table.data(), buffer, 3 * global_color_table_size);
|
||||
buffer += 3 * global_color_table_size;
|
||||
}
|
||||
|
||||
uint8_t block_type = *buffer++;
|
||||
while (block_type != TRAILER) {
|
||||
if (block_type == EXTENSION_INTRODUCER) {
|
||||
uint8_t extension_label = *buffer++;
|
||||
switch (extension_label) {
|
||||
case GRAPHIC_CONTROL: {
|
||||
uint8_t blockSize = *buffer++;
|
||||
buffer += blockSize;
|
||||
uint8_t subBlockSize = *buffer++;
|
||||
while (subBlockSize != 0) {
|
||||
buffer += subBlockSize;
|
||||
subBlockSize = *buffer++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLICATION_EXTENSION:
|
||||
case COMMENT_EXTENSION:
|
||||
case PLAINTEXT_EXTENSION: {
|
||||
uint8_t blockSize = *buffer++;
|
||||
buffer += blockSize;
|
||||
uint8_t subBlockSize = *buffer++;
|
||||
while (subBlockSize != 0) {
|
||||
buffer += subBlockSize;
|
||||
subBlockSize = *buffer++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
uint8_t blockSize = *buffer++;
|
||||
buffer += blockSize;
|
||||
uint8_t subBlockSize = *buffer++;
|
||||
while (subBlockSize != 0) {
|
||||
buffer += subBlockSize;
|
||||
subBlockSize = *buffer++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (block_type == IMAGE_DESCRIPTOR) {
|
||||
return processImageDescriptor(buffer, global_color_table, color_resolution_bits);
|
||||
} else {
|
||||
std::cout << "Unrecognized block type: 0x" << std::hex << static_cast<int>(block_type) << std::dec << '\n';
|
||||
return std::vector<uint8_t>{};
|
||||
}
|
||||
block_type = *buffer++;
|
||||
}
|
||||
|
||||
return std::vector<uint8_t>{};
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::loadGif(const uint8_t *buffer, uint16_t &w, uint16_t &h) {
|
||||
return processGifStream(buffer, w, h);
|
||||
}
|
||||
|
||||
} // namespace GIF
|
||||
92
source/core/rendering/gif.hpp
Normal file
92
source/core/rendering/gif.hpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint> // Para uint8_t, uint16_t, uint32_t
|
||||
#include <vector> // Para vector
|
||||
|
||||
namespace GIF {
|
||||
|
||||
// Constantes definidas con constexpr, en lugar de macros
|
||||
constexpr uint8_t EXTENSION_INTRODUCER = 0x21;
|
||||
constexpr uint8_t IMAGE_DESCRIPTOR = 0x2C;
|
||||
constexpr uint8_t TRAILER = 0x3B;
|
||||
constexpr uint8_t GRAPHIC_CONTROL = 0xF9;
|
||||
constexpr uint8_t APPLICATION_EXTENSION = 0xFF;
|
||||
constexpr uint8_t COMMENT_EXTENSION = 0xFE;
|
||||
constexpr uint8_t PLAINTEXT_EXTENSION = 0x01;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct ScreenDescriptor {
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint8_t fields;
|
||||
uint8_t background_color_index;
|
||||
uint8_t pixel_aspect_ratio;
|
||||
};
|
||||
|
||||
struct RGB {
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
struct ImageDescriptor {
|
||||
uint16_t image_left_position;
|
||||
uint16_t image_top_position;
|
||||
uint16_t image_width;
|
||||
uint16_t image_height;
|
||||
uint8_t fields;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct DictionaryEntry {
|
||||
uint8_t byte;
|
||||
int prev;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct Extension {
|
||||
uint8_t extension_code;
|
||||
uint8_t block_size;
|
||||
};
|
||||
|
||||
struct GraphicControlExtension {
|
||||
uint8_t fields;
|
||||
uint16_t delay_time;
|
||||
uint8_t transparent_color_index;
|
||||
};
|
||||
|
||||
struct ApplicationExtension {
|
||||
uint8_t application_id[8];
|
||||
uint8_t version[3];
|
||||
};
|
||||
|
||||
struct PlaintextExtension {
|
||||
uint16_t left, top, width, height;
|
||||
uint8_t cell_width, cell_height;
|
||||
uint8_t foreground_color, background_color;
|
||||
};
|
||||
|
||||
class Gif {
|
||||
public:
|
||||
// Descompone (uncompress) el bloque comprimido usando LZW.
|
||||
// Este método puede lanzar std::runtime_error en caso de error.
|
||||
void decompress(int code_length, const uint8_t *input, int input_length, uint8_t *out);
|
||||
|
||||
// Carga la paleta (global color table) a partir de un buffer,
|
||||
// retornándola en un vector de uint32_t (cada color se compone de R, G, B).
|
||||
std::vector<uint32_t> loadPalette(const uint8_t *buffer);
|
||||
|
||||
// Carga el stream GIF; devuelve un vector con los datos de imagen sin comprimir y
|
||||
// asigna el ancho y alto mediante referencias.
|
||||
std::vector<uint8_t> loadGif(const uint8_t *buffer, uint16_t &w, uint16_t &h);
|
||||
|
||||
private:
|
||||
// Lee los sub-bloques de datos y los acumula en un std::vector<uint8_t>.
|
||||
std::vector<uint8_t> readSubBlocks(const uint8_t *&buffer);
|
||||
|
||||
// Procesa el Image Descriptor y retorna el vector de datos sin comprimir.
|
||||
std::vector<uint8_t> processImageDescriptor(const uint8_t *&buffer, const std::vector<RGB> &gct, int resolution_bits);
|
||||
|
||||
// Procesa el stream completo del GIF y devuelve los datos sin comprimir.
|
||||
std::vector<uint8_t> processGifStream(const uint8_t *buffer, uint16_t &w, uint16_t &h);
|
||||
};
|
||||
|
||||
} // namespace GIF
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "screen.hpp"
|
||||
#include "core/rendering/screen.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_RenderTexture, SDL_SetRenderDrawColor, SDL_SetRenderVSync, SDL_LogCategory, SDL_GetError, SDL_LogError, SDL_LogInfo, SDL_RendererLogicalPresentation, SDL_SetRenderLogicalPresentation, SDL_CreateTexture, SDL_DestroyTexture, SDL_DestroyWindow, SDL_GetDisplayName, SDL_GetTicks, SDL_Quit, SDL_RENDERER_VSYNC_DISABLED, SDL_RenderClear, SDL_CreateRenderer, SDL_CreateWindow, SDL_DestroyRenderer, SDL_DisplayID, SDL_FRect, SDL_GetCurrentDisplayMode, SDL_GetDisplays, SDL_GetRenderTarget, SDL_GetWindowPosition, SDL_GetWindowSize, SDL_Init, SDL_LogWarn, SDL_PixelFormat, SDL_RenderFillRect, SDL_RenderPresent, SDL_SetHint, SDL_SetRenderDrawBlendMode, SDL_SetTextureScaleMode, SDL_SetWindowFullscreen, SDL_SetWindowPosition, SDL_SetWindowSize, SDL_TextureAccess, SDL_free, SDL_BLENDMODE_BLEND, SDL_HINT_RENDER_DRIVER, SDL_INIT_VIDEO, SDL_ScaleMode, SDL_WINDOW_FULLSCREEN, SDL_WindowFlags
|
||||
|
||||
@@ -9,18 +9,20 @@
|
||||
#include <string> // Para basic_string, operator+, char_traits, to_string, string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "director.hpp" // Para Director::debug_config
|
||||
#include "mouse.hpp" // Para updateCursorVisibility
|
||||
#include "options.hpp" // Para Video, video, Window, window
|
||||
#include "param.hpp" // Para Param, param, ParamGame, ParamDebug
|
||||
#include "rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "text.hpp" // Para Text
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "ui/notifier.hpp" // Para Notifier
|
||||
#include "ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils.hpp" // Para toLower
|
||||
#include "core/input/mouse.hpp" // Para updateCursorVisibility
|
||||
#ifndef NO_SHADERS
|
||||
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader
|
||||
#endif
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/director.hpp" // Para Director::debug_config
|
||||
#include "game/options.hpp" // Para Video, video, Window, window
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils/param.hpp" // Para Param, param, ParamGame, ParamDebug
|
||||
#include "utils/utils.hpp" // Para toLower
|
||||
|
||||
// Singleton
|
||||
Screen* Screen::instance = nullptr;
|
||||
@@ -6,9 +6,9 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "color.hpp" // Para Color
|
||||
#include "options.hpp" // Para VideoOptions, video
|
||||
#include "rendering/shader_backend.hpp" // Para Rendering::ShaderType
|
||||
#include "core/rendering/shader_backend.hpp" // Para Rendering::ShaderType
|
||||
#include "game/options.hpp" // Para VideoOptions, video
|
||||
#include "utils/color.hpp" // Para Color
|
||||
|
||||
// Forward declarations
|
||||
class Notifier;
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "rendering/sdl3gpu/sdl3gpu_shader.hpp"
|
||||
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#include <iostream> // Para std::cout
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include "rendering/sdl3gpu/crtpi_frag_spv.h"
|
||||
#include "rendering/sdl3gpu/downscale_frag_spv.h"
|
||||
#include "rendering/sdl3gpu/postfx_frag_spv.h"
|
||||
#include "rendering/sdl3gpu/postfx_vert_spv.h"
|
||||
#include "rendering/sdl3gpu/upscale_frag_spv.h"
|
||||
#include "core/rendering/sdl3gpu/crtpi_frag_spv.h"
|
||||
#include "core/rendering/sdl3gpu/downscale_frag_spv.h"
|
||||
#include "core/rendering/sdl3gpu/postfx_frag_spv.h"
|
||||
#include "core/rendering/sdl3gpu/postfx_vert_spv.h"
|
||||
#include "core/rendering/sdl3gpu/upscale_frag_spv.h"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "rendering/shader_backend.hpp"
|
||||
#include "core/rendering/shader_backend.hpp"
|
||||
|
||||
// PostFX uniforms pushed to fragment stage each frame.
|
||||
// 12 floats = 48 bytes — meets Metal/Vulkan 16-byte alignment requirement.
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "animated_sprite.hpp"
|
||||
#include "core/rendering/sprite/animated_sprite.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError, SDL_FRect
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // Para move, pair
|
||||
|
||||
#include "resource_helper.hpp" // Para loadFile
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/resource_helper.hpp" // Para loadFile
|
||||
|
||||
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||
auto loadAnimationsFromFile(const std::string& file_path) -> AnimationsFileBuffer {
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <utility> // Para move
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "moving_sprite.hpp" // for MovingSprite
|
||||
#include "core/rendering/sprite/moving_sprite.hpp" // for MovingSprite
|
||||
|
||||
// Declaración adelantada
|
||||
class Texture;
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "card_sprite.hpp"
|
||||
#include "core/rendering/sprite/card_sprite.hpp"
|
||||
|
||||
#include <algorithm> // Para std::clamp
|
||||
#include <functional> // Para function
|
||||
#include <utility> // Para move
|
||||
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "utils.hpp" // Para easeOutBounce, easeOutCubic
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "utils/utils.hpp" // Para easeOutBounce, easeOutCubic
|
||||
|
||||
// Constructor
|
||||
CardSprite::CardSprite(std::shared_ptr<Texture> texture)
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <functional> // Para function
|
||||
#include <memory> // Para shared_ptr
|
||||
|
||||
#include "moving_sprite.hpp" // Para MovingSprite
|
||||
#include "core/rendering/sprite/moving_sprite.hpp" // Para MovingSprite
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "moving_sprite.hpp"
|
||||
#include "core/rendering/sprite/moving_sprite.hpp"
|
||||
|
||||
#include <cmath> // Para std::abs
|
||||
#include <utility>
|
||||
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
|
||||
// Constructor
|
||||
MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_FRect pos, Rotate rotate, float horizontal_zoom, float vertical_zoom, SDL_FlipMode flip)
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
|
||||
#include "sprite.hpp" // for Sprite
|
||||
#include "core/rendering/sprite/sprite.hpp" // for Sprite
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// IWYU pragma: no_include <bits/std_abs.h>
|
||||
#include "path_sprite.hpp"
|
||||
#include "core/rendering/sprite/path_sprite.hpp"
|
||||
|
||||
#include <cmath> // Para abs
|
||||
#include <functional> // Para function
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "sprite.hpp" // Para Sprite
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "smart_sprite.hpp"
|
||||
#include "core/rendering/sprite/smart_sprite.hpp"
|
||||
|
||||
#include "moving_sprite.hpp" // Para MovingSprite
|
||||
#include "core/rendering/sprite/moving_sprite.hpp" // Para MovingSprite
|
||||
|
||||
// Actualiza la posición y comprueba si ha llegado a su destino (time-based)
|
||||
void SmartSprite::update(float delta_time) {
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <utility>
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "sprite.hpp"
|
||||
#include "core/rendering/sprite/sprite.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
|
||||
// Constructor
|
||||
Sprite::Sprite(std::shared_ptr<Texture> texture, float pos_x, float pos_y, float width, float height)
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "text.hpp"
|
||||
#include "core/rendering/text.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, Uint8, SDL_GetRenderTarget, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_SetRenderTarget, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_TextureAccess, SDL_GetTextureAlphaMod
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include <utility> // Para std::cmp_less_equal
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "color.hpp" // Para Color
|
||||
#include "resource_helper.hpp" // Para loadFile
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "sprite.hpp" // Para Sprite
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "utils.hpp" // Para getFileName
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/resource_helper.hpp" // Para loadFile
|
||||
#include "utils/color.hpp" // Para Color
|
||||
#include "utils/utils.hpp" // Para getFileName
|
||||
|
||||
// Constructor
|
||||
Text::Text(const std::shared_ptr<Texture>& texture, const std::string& text_file) {
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
#include "color.hpp" // Para Color
|
||||
#include "sprite.hpp" // Para Sprite
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
|
||||
#include "utils/color.hpp" // Para Color
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "texture.hpp"
|
||||
#include "core/rendering/texture.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_...
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "color.hpp" // Para getFileName, Color
|
||||
#include "external/gif.hpp" // Para Gif
|
||||
#include "resource_helper.hpp" // Para ResourceHelper
|
||||
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_alpha
|
||||
#include "utils.hpp"
|
||||
#include "core/rendering/gif.hpp" // Para Gif
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "external/stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_alpha
|
||||
#include "utils/color.hpp" // Para getFileName, Color
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Constructor
|
||||
Texture::Texture(SDL_Renderer* renderer, std::string path)
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "tiled_bg.hpp"
|
||||
#include "core/rendering/tiled_bg.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_FRect, SDL_GetRenderTarget, SDL_RenderTexture, SDL_PixelFormat, SDL_TextureAccess
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <numbers> // Para pi
|
||||
#include <string> // Para basic_string
|
||||
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "sprite.hpp" // Para Sprite
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
|
||||
// Constructor
|
||||
TiledBG::TiledBG(SDL_FRect pos, TiledBGMode mode)
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetTextureColorMod, SDL_Renderer, SDL_Texture
|
||||
|
||||
#include "color.hpp" // Para Color
|
||||
#include "utils/color.hpp" // Para Color
|
||||
|
||||
// --- Enums ---
|
||||
enum class TiledBGMode : int { // Modos de funcionamiento para el tileado de fondo
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "writer.hpp"
|
||||
#include "core/rendering/writer.hpp"
|
||||
|
||||
#include "text.hpp" // Para Text
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
|
||||
// Actualiza el objeto (delta_time en ms)
|
||||
void Writer::update(float delta_time) {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "asset.hpp"
|
||||
#include "core/resources/asset.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <sstream> // Para basic_istringstream
|
||||
#include <stdexcept> // Para runtime_error
|
||||
|
||||
#include "resource_helper.hpp" // Para loadFile
|
||||
#include "utils.hpp" // Para getFileName
|
||||
#include "core/resources/resource_helper.hpp" // Para loadFile
|
||||
#include "utils/utils.hpp" // Para getFileName
|
||||
|
||||
// Singleton
|
||||
Asset* Asset::instance = nullptr;
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "asset_integrated.hpp"
|
||||
#include "core/resources/asset_integrated.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "asset.hpp"
|
||||
#include "resource_loader.hpp"
|
||||
#include "core/resources/asset.hpp"
|
||||
#include "core/resources/resource_loader.hpp"
|
||||
|
||||
// Extensión de Asset que integra ResourceLoader
|
||||
class AssetIntegrated : public Asset {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "resource.hpp"
|
||||
#include "core/resources/resource.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility> // Para move
|
||||
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "color.hpp" // Para Color, NO_COLOR_MOD
|
||||
#include "external/jail_audio.hpp" // Para JA_LoadMusic, JA_LoadSound, JA_DeleteMusic, JA_DeleteSound
|
||||
#include "lang.hpp" // Para getText
|
||||
#include "param.hpp" // Para Param, param, ParamPlayer, ParamResource, ParamGame
|
||||
#include "resource_helper.hpp" // Para loadFile
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "text.hpp" // Para Text
|
||||
#include "utils.hpp" // Para getFileName
|
||||
#include "core/audio/jail_audio.hpp" // Para JA_LoadMusic, JA_LoadSound, JA_DeleteMusic, JA_DeleteSound
|
||||
#include "core/locale/lang.hpp" // Para getText
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "core/resources/resource_helper.hpp" // Para loadFile
|
||||
#include "utils/color.hpp" // Para Color, NO_COLOR_MOD
|
||||
#include "utils/param.hpp" // Para Param, param, ParamPlayer, ParamResource, ParamGame
|
||||
#include "utils/utils.hpp" // Para getFileName
|
||||
#include "version.h" // Para APP_NAME, GIT_HASH
|
||||
|
||||
struct JA_Music_t; // lines 11-11
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <utility> // Para move
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimationsFileBuffer
|
||||
#include "demo.hpp" // Para DemoData
|
||||
#include "text.hpp" // Para Text, TextFile
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimationsFileBuffer
|
||||
#include "core/rendering/text.hpp" // Para Text, TextFile
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/system/demo.hpp" // Para DemoData
|
||||
|
||||
struct JA_Music_t;
|
||||
struct JA_Sound_t;
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "resource_helper.hpp"
|
||||
#include "core/resources/resource_helper.hpp"
|
||||
|
||||
#include <algorithm> // Para replace
|
||||
#include <cstddef> // Para size_t
|
||||
#include <fstream> // Para basic_ifstream, basic_ostream, basic_ios, operator<<, ios, basic_istream, endl, operator|, basic_istream::read, basic_istream::seekg, basic_istream::tellg, ifstream, streamsize
|
||||
#include <iostream> // Para cout
|
||||
|
||||
#include "resource_loader.hpp" // Para ResourceLoader
|
||||
#include "core/resources/resource_loader.hpp" // Para ResourceLoader
|
||||
|
||||
namespace ResourceHelper {
|
||||
static bool resource_system_initialized = false;
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "resource_loader.hpp"
|
||||
#include "core/resources/resource_loader.hpp"
|
||||
|
||||
#include <algorithm> // Para replace
|
||||
#include <filesystem> // Para exists, path, recursive_directory_iterator, directory_entry, relative
|
||||
#include <fstream> // Para basic_ostream, basic_ifstream, operator<<, basic_ios, endl, ios, basic_istream, operator|, basic_istream::read, basic_istream::seekg, basic_istream::tellg, ifstream, streamsize
|
||||
#include <iostream> // Para cerr, cout
|
||||
|
||||
#include "resource_pack.hpp" // Para ResourcePack
|
||||
#include "core/resources/resource_pack.hpp" // Para ResourcePack
|
||||
|
||||
std::unique_ptr<ResourceLoader> ResourceLoader::instance = nullptr;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "resource_pack.hpp"
|
||||
#include "core/resources/resource_pack.hpp"
|
||||
|
||||
#include <algorithm> // Para replace
|
||||
#include <array> // Para array
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "ui/notifier.hpp" // Para Notifier::Position
|
||||
#include "game/ui/notifier.hpp" // Para Notifier::Position
|
||||
|
||||
namespace Defaults::Game {
|
||||
constexpr float WIDTH = 320.0F;
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "demo.hpp"
|
||||
#include "core/system/demo.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_IOStream, SDL_IOFromConstMem, SDL_IOFromFile, SDL_ReadIO, SDL_WriteIO, SDL_CloseIO
|
||||
|
||||
#include <iostream> // Para std::cout
|
||||
#include <stdexcept> // Para runtime_error
|
||||
|
||||
#include "resource_helper.hpp" // Para ResourceHelper
|
||||
#include "utils.hpp" // Para getFileName
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "utils/utils.hpp" // Para getFileName
|
||||
|
||||
// Carga el fichero de datos para la demo
|
||||
auto loadDemoDataFromFile(const std::string& file_path) -> DemoData {
|
||||
@@ -1,5 +1,5 @@
|
||||
// IWYU pragma: no_include <bits/chrono.h>
|
||||
#include "director.hpp"
|
||||
#include "core/system/director.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_SetLogPriority, SDL_LogCategory, SDL_LogPriority, SDL_Quit
|
||||
|
||||
@@ -11,31 +11,31 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para allocator, basic_string, char_traits, operator+, string, operator==
|
||||
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/lang.hpp" // Para setLanguage
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/resources/resource_helper.hpp" // Para initializeResourceSystem
|
||||
#include "core/system/global_events.hpp" // Para GlobalEvents::handle
|
||||
#include "core/system/section.hpp" // Para Name, Options, name, options, AttractMode, attract_mode
|
||||
#include "core/system/shutdown.hpp" // Para resultToString, shutdownSystem, ShutdownResult
|
||||
#include "core/system/system_utils.hpp" // Para createApplicationFolder, resultToString, Result
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
#include "global_events.hpp" // Para GlobalEvents::handle
|
||||
#include "input.hpp" // Para Input
|
||||
#include "lang.hpp" // Para setLanguage
|
||||
#include "manage_hiscore_table.hpp" // Para ManageHiScoreTable
|
||||
#include "options.hpp" // Para Settings, loadFromFile, saveToFile, settings, setConfigFile, setControllersFile
|
||||
#include "param.hpp" // Para loadParamsFromFile
|
||||
#include "player.hpp" // Para Player
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "resource_helper.hpp" // Para initializeResourceSystem
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "section.hpp" // Para Name, Options, name, options, AttractMode, attract_mode
|
||||
#include "sections/credits.hpp" // Para Credits
|
||||
#include "sections/game.hpp" // Para Game
|
||||
#include "sections/hiscore_table.hpp" // Para HiScoreTable
|
||||
#include "sections/instructions.hpp" // Para Instructions
|
||||
#include "sections/intro.hpp" // Para Intro
|
||||
#include "sections/logo.hpp" // Para Logo
|
||||
#include "sections/title.hpp" // Para Title
|
||||
#include "shutdown.hpp" // Para resultToString, shutdownSystem, ShutdownResult
|
||||
#include "system_utils.hpp" // Para createApplicationFolder, resultToString, Result
|
||||
#include "ui/notifier.hpp" // Para Notifier
|
||||
#include "ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "game/entities/player.hpp" // Para Player
|
||||
#include "game/gameplay/manage_hiscore_table.hpp" // Para ManageHiScoreTable
|
||||
#include "game/options.hpp" // Para Settings, loadFromFile, saveToFile, settings, setConfigFile, setControllersFile
|
||||
#include "game/scenes/credits.hpp" // Para Credits
|
||||
#include "game/scenes/game.hpp" // Para Game
|
||||
#include "game/scenes/hiscore_table.hpp" // Para HiScoreTable
|
||||
#include "game/scenes/instructions.hpp" // Para Instructions
|
||||
#include "game/scenes/intro.hpp" // Para Intro
|
||||
#include "game/scenes/logo.hpp" // Para Logo
|
||||
#include "game/scenes/title.hpp" // Para Title
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "utils/param.hpp" // Para loadParamsFromFile
|
||||
|
||||
// Constructor
|
||||
Director::Director() {
|
||||
@@ -51,8 +51,14 @@ Director::Director() {
|
||||
std::cout << "Game start\n";
|
||||
|
||||
// Obtener la ruta del ejecutable desde SDL
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// En Emscripten los assets viven en la raíz del MEMFS virtual (/data, /config),
|
||||
// preloaded vía --preload-file en el linker. No hay ruta de ejecutable.
|
||||
executable_path_ = "";
|
||||
#else
|
||||
const char* base_path = SDL_GetBasePath();
|
||||
executable_path_ = (base_path != nullptr) ? base_path : "";
|
||||
#endif
|
||||
|
||||
// Crea la carpeta del sistema donde guardar los datos persistentes
|
||||
createSystemFolder("jailgames");
|
||||
@@ -92,11 +98,11 @@ void Director::init() {
|
||||
#endif
|
||||
|
||||
// Inicializar sistema de recursos con o sin fallback según el tipo de build
|
||||
#ifdef RELEASE_BUILD
|
||||
// Release: Sin fallback - Solo resources.pack (estricto)
|
||||
#if defined(RELEASE_BUILD) && !defined(__EMSCRIPTEN__)
|
||||
// Release nativo: Sin fallback - Solo resources.pack (estricto)
|
||||
ResourceHelper::initializeResourceSystem(pack_path, false);
|
||||
#else
|
||||
// Desarrollo: Con fallback - Puede usar data/ si falta el pack (flexible)
|
||||
// Desarrollo o Emscripten: Con fallback - carga desde filesystem/MEMFS
|
||||
ResourceHelper::initializeResourceSystem(pack_path, true);
|
||||
#endif
|
||||
|
||||
@@ -111,6 +117,14 @@ void Director::init() {
|
||||
Options::loadFromFile(); // Carga el archivo de configuración
|
||||
Options::loadPostFXFromFile(); // Carga los presets PostFX
|
||||
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;
|
||||
Options::video.integer_scale = true;
|
||||
#endif
|
||||
loadParams(); // Carga los parámetros del programa
|
||||
loadScoreFile(); // Carga el archivo de puntuaciones
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <memory> // Para unique_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
#include "section.hpp" // Para Section::Name
|
||||
#include "core/system/section.hpp" // Para Section::Name
|
||||
|
||||
namespace Lang {
|
||||
enum class Code : int;
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "global_events.hpp"
|
||||
#include "core/system/global_events.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_EventType, SDL_Event, SDL_LogInfo, SDL_LogCategory
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include <string> // Para allocator, operator+, string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "input.hpp" // Para Input
|
||||
#include "lang.hpp" // Para getText
|
||||
#include "mouse.hpp" // Para handleEvent
|
||||
#include "options.hpp" // Para GamepadManager, gamepad_manager
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "section.hpp" // Para Name, Options, name, options
|
||||
#include "ui/notifier.hpp" // Para Notifier
|
||||
#include "ui/service_menu.hpp" // Para ServiceMenu
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/mouse.hpp" // Para handleEvent
|
||||
#include "core/locale/lang.hpp" // Para getText
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/system/section.hpp" // Para Name, Options, name, options
|
||||
#include "game/options.hpp" // Para GamepadManager, gamepad_manager
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
|
||||
namespace GlobalEvents {
|
||||
// Comprueba los eventos de Input y muestra notificaciones
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "shutdown.hpp"
|
||||
#include "core/system/shutdown.hpp"
|
||||
|
||||
#include <sys/types.h> // Para pid_t
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "system_utils.hpp"
|
||||
#include "core/system/system_utils.hpp"
|
||||
|
||||
#include <sys/stat.h> // Para stat, mkdir, S_ISDIR
|
||||
|
||||
252
source/external/gif.cpp
vendored
252
source/external/gif.cpp
vendored
@@ -1,252 +0,0 @@
|
||||
#include "gif.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, SDL_LogInfo
|
||||
#include <cstring> // Para memcpy, size_t
|
||||
#include <iostream> // Para std::cout
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para char_traits, operator==, basic_string, string
|
||||
|
||||
namespace GIF {
|
||||
inline void readBytes(const uint8_t *&buffer, void *dst, size_t size) {
|
||||
std::memcpy(dst, buffer, size);
|
||||
buffer += size;
|
||||
}
|
||||
|
||||
void Gif::decompress(int code_length, const uint8_t *input, int input_length, uint8_t *out) {
|
||||
if (code_length < 2 || code_length > 12) {
|
||||
std::cout << "Invalid LZW code length: " << code_length << '\n';
|
||||
throw std::runtime_error("Invalid LZW code length");
|
||||
}
|
||||
|
||||
int i, bit;
|
||||
int prev = -1;
|
||||
std::vector<DictionaryEntry> dictionary;
|
||||
int dictionary_ind;
|
||||
unsigned int mask = 0x01;
|
||||
int reset_code_length = code_length;
|
||||
int clear_code = 1 << code_length;
|
||||
int stop_code = clear_code + 1;
|
||||
int match_len = 0;
|
||||
|
||||
dictionary.resize(1 << (code_length + 1));
|
||||
for (dictionary_ind = 0; dictionary_ind < (1 << code_length); dictionary_ind++) {
|
||||
dictionary[dictionary_ind].byte = static_cast<uint8_t>(dictionary_ind);
|
||||
dictionary[dictionary_ind].prev = -1;
|
||||
dictionary[dictionary_ind].len = 1;
|
||||
}
|
||||
dictionary_ind += 2;
|
||||
|
||||
while (input_length > 0) {
|
||||
int code = 0;
|
||||
for (i = 0; i < (code_length + 1); i++) {
|
||||
if (input_length <= 0) {
|
||||
std::cout << "Unexpected end of input in decompress" << '\n';
|
||||
throw std::runtime_error("Unexpected end of input in decompress");
|
||||
}
|
||||
bit = ((*input & mask) != 0) ? 1 : 0;
|
||||
mask <<= 1;
|
||||
if (mask == 0x100) {
|
||||
mask = 0x01;
|
||||
input++;
|
||||
input_length--;
|
||||
}
|
||||
code |= (bit << i);
|
||||
}
|
||||
|
||||
if (code == clear_code) {
|
||||
code_length = reset_code_length;
|
||||
dictionary.resize(1 << (code_length + 1));
|
||||
for (dictionary_ind = 0; dictionary_ind < (1 << code_length); dictionary_ind++) {
|
||||
dictionary[dictionary_ind].byte = static_cast<uint8_t>(dictionary_ind);
|
||||
dictionary[dictionary_ind].prev = -1;
|
||||
dictionary[dictionary_ind].len = 1;
|
||||
}
|
||||
dictionary_ind += 2;
|
||||
prev = -1;
|
||||
continue;
|
||||
} else if (code == stop_code) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (prev > -1 && code_length < 12) {
|
||||
if (code > dictionary_ind) {
|
||||
std::cout << "LZW error: code (" << code << ") exceeds dictionary_ind (" << dictionary_ind << ")" << '\n';
|
||||
throw std::runtime_error("LZW error: code exceeds dictionary_ind.");
|
||||
}
|
||||
|
||||
int ptr;
|
||||
if (code == dictionary_ind) {
|
||||
ptr = prev;
|
||||
while (dictionary[ptr].prev != -1)
|
||||
ptr = dictionary[ptr].prev;
|
||||
dictionary[dictionary_ind].byte = dictionary[ptr].byte;
|
||||
} else {
|
||||
ptr = code;
|
||||
while (dictionary[ptr].prev != -1)
|
||||
ptr = dictionary[ptr].prev;
|
||||
dictionary[dictionary_ind].byte = dictionary[ptr].byte;
|
||||
}
|
||||
dictionary[dictionary_ind].prev = prev;
|
||||
dictionary[dictionary_ind].len = dictionary[prev].len + 1;
|
||||
dictionary_ind++;
|
||||
|
||||
if ((dictionary_ind == (1 << (code_length + 1))) && (code_length < 11)) {
|
||||
code_length++;
|
||||
dictionary.resize(1 << (code_length + 1));
|
||||
}
|
||||
}
|
||||
|
||||
prev = code;
|
||||
|
||||
if (code < 0 || static_cast<size_t>(code) >= dictionary.size()) {
|
||||
std::cout << "Invalid LZW code " << code << ", dictionary size " << static_cast<unsigned long>(dictionary.size()) << '\n';
|
||||
throw std::runtime_error("LZW error: invalid code encountered");
|
||||
}
|
||||
|
||||
int curCode = code;
|
||||
match_len = dictionary[curCode].len;
|
||||
while (curCode != -1) {
|
||||
out[dictionary[curCode].len - 1] = dictionary[curCode].byte;
|
||||
if (dictionary[curCode].prev == curCode) {
|
||||
std::cout << "Internal error; self-reference detected." << '\n';
|
||||
throw std::runtime_error("Internal error in decompress: self-reference");
|
||||
}
|
||||
curCode = dictionary[curCode].prev;
|
||||
}
|
||||
out += match_len;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::readSubBlocks(const uint8_t *&buffer) {
|
||||
std::vector<uint8_t> data;
|
||||
uint8_t block_size = *buffer;
|
||||
buffer++;
|
||||
while (block_size != 0) {
|
||||
data.insert(data.end(), buffer, buffer + block_size);
|
||||
buffer += block_size;
|
||||
block_size = *buffer;
|
||||
buffer++;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::processImageDescriptor(const uint8_t *&buffer, const std::vector<RGB> &gct, int resolution_bits) {
|
||||
ImageDescriptor image_descriptor;
|
||||
readBytes(buffer, &image_descriptor, sizeof(ImageDescriptor));
|
||||
|
||||
uint8_t lzw_code_size;
|
||||
readBytes(buffer, &lzw_code_size, sizeof(uint8_t));
|
||||
|
||||
std::vector<uint8_t> compressed_data = readSubBlocks(buffer);
|
||||
int uncompressed_data_length = image_descriptor.image_width * image_descriptor.image_height;
|
||||
std::vector<uint8_t> uncompressed_data(uncompressed_data_length);
|
||||
|
||||
decompress(lzw_code_size, compressed_data.data(), static_cast<int>(compressed_data.size()), uncompressed_data.data());
|
||||
return uncompressed_data;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> Gif::loadPalette(const uint8_t *buffer) {
|
||||
uint8_t header[6];
|
||||
std::memcpy(header, buffer, 6);
|
||||
buffer += 6;
|
||||
|
||||
ScreenDescriptor screen_descriptor;
|
||||
std::memcpy(&screen_descriptor, buffer, sizeof(ScreenDescriptor));
|
||||
buffer += sizeof(ScreenDescriptor);
|
||||
|
||||
std::vector<uint32_t> global_color_table;
|
||||
if (screen_descriptor.fields & 0x80) {
|
||||
int global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
|
||||
global_color_table.resize(global_color_table_size);
|
||||
for (int i = 0; i < global_color_table_size; ++i) {
|
||||
uint8_t r = buffer[0];
|
||||
uint8_t g = buffer[1];
|
||||
uint8_t b = buffer[2];
|
||||
global_color_table[i] = (r << 16) | (g << 8) | b;
|
||||
buffer += 3;
|
||||
}
|
||||
}
|
||||
return global_color_table;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::processGifStream(const uint8_t *buffer, uint16_t &w, uint16_t &h) {
|
||||
uint8_t header[6];
|
||||
std::memcpy(header, buffer, 6);
|
||||
buffer += 6;
|
||||
|
||||
std::string headerStr(reinterpret_cast<char *>(header), 6);
|
||||
if (headerStr != "GIF87a" && headerStr != "GIF89a") {
|
||||
std::cout << "Formato de archivo GIF inválido: " << headerStr << '\n';
|
||||
throw std::runtime_error("Formato de archivo GIF inválido.");
|
||||
}
|
||||
|
||||
ScreenDescriptor screen_descriptor;
|
||||
readBytes(buffer, &screen_descriptor, sizeof(ScreenDescriptor));
|
||||
|
||||
w = screen_descriptor.width;
|
||||
h = screen_descriptor.height;
|
||||
|
||||
int color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
|
||||
std::vector<RGB> global_color_table;
|
||||
if (screen_descriptor.fields & 0x80) {
|
||||
int global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
|
||||
global_color_table.resize(global_color_table_size);
|
||||
std::memcpy(global_color_table.data(), buffer, 3 * global_color_table_size);
|
||||
buffer += 3 * global_color_table_size;
|
||||
}
|
||||
|
||||
uint8_t block_type = *buffer++;
|
||||
while (block_type != TRAILER) {
|
||||
if (block_type == EXTENSION_INTRODUCER) {
|
||||
uint8_t extension_label = *buffer++;
|
||||
switch (extension_label) {
|
||||
case GRAPHIC_CONTROL: {
|
||||
uint8_t blockSize = *buffer++;
|
||||
buffer += blockSize;
|
||||
uint8_t subBlockSize = *buffer++;
|
||||
while (subBlockSize != 0) {
|
||||
buffer += subBlockSize;
|
||||
subBlockSize = *buffer++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLICATION_EXTENSION:
|
||||
case COMMENT_EXTENSION:
|
||||
case PLAINTEXT_EXTENSION: {
|
||||
uint8_t blockSize = *buffer++;
|
||||
buffer += blockSize;
|
||||
uint8_t subBlockSize = *buffer++;
|
||||
while (subBlockSize != 0) {
|
||||
buffer += subBlockSize;
|
||||
subBlockSize = *buffer++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
uint8_t blockSize = *buffer++;
|
||||
buffer += blockSize;
|
||||
uint8_t subBlockSize = *buffer++;
|
||||
while (subBlockSize != 0) {
|
||||
buffer += subBlockSize;
|
||||
subBlockSize = *buffer++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (block_type == IMAGE_DESCRIPTOR) {
|
||||
return processImageDescriptor(buffer, global_color_table, color_resolution_bits);
|
||||
} else {
|
||||
std::cout << "Unrecognized block type: 0x" << std::hex << static_cast<int>(block_type) << std::dec << '\n';
|
||||
return std::vector<uint8_t>{};
|
||||
}
|
||||
block_type = *buffer++;
|
||||
}
|
||||
|
||||
return std::vector<uint8_t>{};
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Gif::loadGif(const uint8_t *buffer, uint16_t &w, uint16_t &h) {
|
||||
return processGifStream(buffer, w, h);
|
||||
}
|
||||
|
||||
} // namespace GIF
|
||||
92
source/external/gif.hpp
vendored
92
source/external/gif.hpp
vendored
@@ -1,92 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint> // Para uint8_t, uint16_t, uint32_t
|
||||
#include <vector> // Para vector
|
||||
|
||||
namespace GIF {
|
||||
|
||||
// Constantes definidas con constexpr, en lugar de macros
|
||||
constexpr uint8_t EXTENSION_INTRODUCER = 0x21;
|
||||
constexpr uint8_t IMAGE_DESCRIPTOR = 0x2C;
|
||||
constexpr uint8_t TRAILER = 0x3B;
|
||||
constexpr uint8_t GRAPHIC_CONTROL = 0xF9;
|
||||
constexpr uint8_t APPLICATION_EXTENSION = 0xFF;
|
||||
constexpr uint8_t COMMENT_EXTENSION = 0xFE;
|
||||
constexpr uint8_t PLAINTEXT_EXTENSION = 0x01;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct ScreenDescriptor {
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint8_t fields;
|
||||
uint8_t background_color_index;
|
||||
uint8_t pixel_aspect_ratio;
|
||||
};
|
||||
|
||||
struct RGB {
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
struct ImageDescriptor {
|
||||
uint16_t image_left_position;
|
||||
uint16_t image_top_position;
|
||||
uint16_t image_width;
|
||||
uint16_t image_height;
|
||||
uint8_t fields;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct DictionaryEntry {
|
||||
uint8_t byte;
|
||||
int prev;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct Extension {
|
||||
uint8_t extension_code;
|
||||
uint8_t block_size;
|
||||
};
|
||||
|
||||
struct GraphicControlExtension {
|
||||
uint8_t fields;
|
||||
uint16_t delay_time;
|
||||
uint8_t transparent_color_index;
|
||||
};
|
||||
|
||||
struct ApplicationExtension {
|
||||
uint8_t application_id[8];
|
||||
uint8_t version[3];
|
||||
};
|
||||
|
||||
struct PlaintextExtension {
|
||||
uint16_t left, top, width, height;
|
||||
uint8_t cell_width, cell_height;
|
||||
uint8_t foreground_color, background_color;
|
||||
};
|
||||
|
||||
class Gif {
|
||||
public:
|
||||
// Descompone (uncompress) el bloque comprimido usando LZW.
|
||||
// Este método puede lanzar std::runtime_error en caso de error.
|
||||
void decompress(int code_length, const uint8_t *input, int input_length, uint8_t *out);
|
||||
|
||||
// Carga la paleta (global color table) a partir de un buffer,
|
||||
// retornándola en un vector de uint32_t (cada color se compone de R, G, B).
|
||||
std::vector<uint32_t> loadPalette(const uint8_t *buffer);
|
||||
|
||||
// Carga el stream GIF; devuelve un vector con los datos de imagen sin comprimir y
|
||||
// asigna el ancho y alto mediante referencias.
|
||||
std::vector<uint8_t> loadGif(const uint8_t *buffer, uint16_t &w, uint16_t &h);
|
||||
|
||||
private:
|
||||
// Lee los sub-bloques de datos y los acumula en un std::vector<uint8_t>.
|
||||
std::vector<uint8_t> readSubBlocks(const uint8_t *&buffer);
|
||||
|
||||
// Procesa el Image Descriptor y retorna el vector de datos sin comprimir.
|
||||
std::vector<uint8_t> processImageDescriptor(const uint8_t *&buffer, const std::vector<RGB> &gct, int resolution_bits);
|
||||
|
||||
// Procesa el stream completo del GIF y devuelve los datos sin comprimir.
|
||||
std::vector<uint8_t> processGifStream(const uint8_t *buffer, uint16_t &w, uint16_t &h);
|
||||
};
|
||||
|
||||
} // namespace GIF
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "balloon.hpp"
|
||||
#include "game/entities/balloon.hpp"
|
||||
|
||||
#include <algorithm> // Para clamp
|
||||
#include <array> // Para array
|
||||
#include <cmath> // Para fabs
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "param.hpp" // Para Param, ParamBalloon, param
|
||||
#include "sprite.hpp" // Para Sprite
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para Sprite
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "utils/param.hpp" // Para Param, ParamBalloon, param
|
||||
|
||||
// Constructor
|
||||
Balloon::Balloon(const Config& config)
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <string_view> // Para string_view
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils.hpp" // Para Circle
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils/utils.hpp" // Para Circle
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "bullet.hpp"
|
||||
#include "game/entities/bullet.hpp"
|
||||
|
||||
#include <memory> // Para unique_ptr, make_unique
|
||||
#include <string> // Para basic_string, string
|
||||
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "utils/param.hpp" // Para Param, ParamGame, param
|
||||
|
||||
// Constructor
|
||||
Bullet::Bullet(float x, float y, Type type, Color color, int owner)
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <memory> // Para unique_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils.hpp" // Para Circle
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils/utils.hpp" // Para Circle
|
||||
|
||||
// --- Clase Bullet: representa una bala del jugador ---
|
||||
class Bullet {
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "explosions.hpp"
|
||||
#include "game/entities/explosions.hpp"
|
||||
|
||||
#include <utility> // Para std::cmp_less
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
|
||||
class Texture; // lines 4-4
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <utility> // Para move
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "item.hpp"
|
||||
#include "game/entities/item.hpp"
|
||||
|
||||
#include <algorithm> // Para clamp
|
||||
#include <cmath> // Para fmod
|
||||
#include <cstdlib> // Para rand
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils/param.hpp" // Para Param, ParamGame, param
|
||||
|
||||
class Texture; // lines 6-6
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils.hpp" // Para Circle
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "utils/utils.hpp" // Para Circle
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "player.hpp"
|
||||
#include "game/entities/player.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FlipMode
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
#include <cmath> // Para fmod
|
||||
#include <cstdlib> // Para rand
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "cooldown.hpp" // Para Cooldown
|
||||
#include "input.hpp" // Para Input
|
||||
#include "input_types.hpp" // Para InputAction
|
||||
#include "manage_hiscore_table.hpp" // Para ManageHiScoreTable, HiScoreEntry
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "scoreboard.hpp" // Para Scoreboard
|
||||
#include "stage_interface.hpp" // Para IStageInfo
|
||||
#include "texture.hpp" // Para Texture
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/input/input_types.hpp" // Para InputAction
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/texture.hpp" // Para Texture
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "core/system/stage_interface.hpp" // Para IStageInfo
|
||||
#include "game/gameplay/cooldown.hpp" // Para Cooldown
|
||||
#include "game/gameplay/manage_hiscore_table.hpp" // Para ManageHiScoreTable, HiScoreEntry
|
||||
#include "game/gameplay/scoreboard.hpp" // Para Scoreboard
|
||||
#include "utils/param.hpp" // Para Param, ParamGame, param
|
||||
|
||||
// Constructor
|
||||
Player::Player(const Config& config)
|
||||
@@ -9,14 +9,14 @@
|
||||
#include <utility> // Para move, pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "animated_sprite.hpp" // for AnimatedSprite
|
||||
#include "bullet.hpp" // for Bullet
|
||||
#include "cooldown.hpp"
|
||||
#include "enter_name.hpp" // for EnterName
|
||||
#include "input.hpp" // for Input
|
||||
#include "manage_hiscore_table.hpp" // for Table
|
||||
#include "scoreboard.hpp" // for Scoreboard
|
||||
#include "utils.hpp" // for Circle
|
||||
#include "core/input/input.hpp" // for Input
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // for AnimatedSprite
|
||||
#include "game/entities/bullet.hpp" // for Bullet
|
||||
#include "game/gameplay/cooldown.hpp"
|
||||
#include "game/gameplay/enter_name.hpp" // for EnterName
|
||||
#include "game/gameplay/manage_hiscore_table.hpp" // for Table
|
||||
#include "game/gameplay/scoreboard.hpp" // for Scoreboard
|
||||
#include "utils/utils.hpp" // for Circle
|
||||
|
||||
class IStageInfo;
|
||||
class Texture;
|
||||
@@ -1,5 +1,5 @@
|
||||
// IWYU pragma: no_include <bits/std_abs.h>
|
||||
#include "tabe.hpp"
|
||||
#include "game/entities/tabe.hpp"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FlipMode, SDL_GetTicks
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <cstdlib> // Para rand, abs
|
||||
#include <string> // Para basic_string
|
||||
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "param.hpp" // Para Param, param, ParamGame, ParamTabe
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "utils.hpp" // Para Zone
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "utils/param.hpp" // Para Param, param, ParamGame, ParamTabe
|
||||
#include "utils/utils.hpp" // Para Zone
|
||||
|
||||
// Constructor
|
||||
Tabe::Tabe()
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <cstdlib> // Para rand
|
||||
#include <memory> // Para unique_ptr
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
|
||||
// --- Clase Tabe ---
|
||||
class Tabe {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "balloon_formations.hpp"
|
||||
#include "game/gameplay/balloon_formations.hpp"
|
||||
|
||||
#include <algorithm> // Para max, min, copy
|
||||
#include <array> // Para array
|
||||
@@ -12,10 +12,10 @@
|
||||
#include <string> // Para string, char_traits, allocator, operator==, stoi, getline, operator<=>, basic_string
|
||||
#include <utility> // Para std::cmp_less
|
||||
|
||||
#include "asset.hpp" // Para Asset
|
||||
#include "balloon.hpp" // Para Balloon
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "utils.hpp" // Para Zone, BLOCK
|
||||
#include "core/resources/asset.hpp" // Para Asset
|
||||
#include "game/entities/balloon.hpp" // Para Balloon
|
||||
#include "utils/param.hpp" // Para Param, ParamGame, param
|
||||
#include "utils/utils.hpp" // Para Zone, BLOCK
|
||||
|
||||
void BalloonFormations::initFormations() {
|
||||
// Calcular posiciones base
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "balloon.hpp" // for Balloon
|
||||
#include "game/entities/balloon.hpp" // for Balloon
|
||||
|
||||
// --- Clase BalloonFormations ---
|
||||
class BalloonFormations {
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "balloon_manager.hpp"
|
||||
#include "game/gameplay/balloon_manager.hpp"
|
||||
|
||||
#include <algorithm> // Para remove_if
|
||||
#include <array>
|
||||
#include <cstdlib> // Para rand
|
||||
#include <numeric> // Para accumulate
|
||||
|
||||
#include "balloon.hpp" // Para Balloon, Balloon::SCORE.at( )ALLOON_VELX...
|
||||
#include "balloon_formations.hpp" // Para BalloonFormationParams, BalloonForma...
|
||||
#include "color.hpp" // Para Zone, Color, flash_color
|
||||
#include "explosions.hpp" // Para Explosions
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "screen.hpp" // Para Screen
|
||||
#include "stage_interface.hpp" // Para IStageInfo
|
||||
#include "utils.hpp"
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/stage_interface.hpp" // Para IStageInfo
|
||||
#include "game/entities/balloon.hpp" // Para Balloon, Balloon::SCORE.at( )ALLOON_VELX...
|
||||
#include "game/entities/explosions.hpp" // Para Explosions
|
||||
#include "game/gameplay/balloon_formations.hpp" // Para BalloonFormationParams, BalloonForma...
|
||||
#include "utils/color.hpp" // Para Zone, Color, flash_color
|
||||
#include "utils/param.hpp" // Para Param, ParamGame, param
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Constructor
|
||||
BalloonManager::BalloonManager(IStageInfo* stage_info)
|
||||
@@ -8,11 +8,11 @@
|
||||
#include <string> // Para basic_string, string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "balloon.hpp" // for Balloon
|
||||
#include "balloon_formations.hpp" // for BalloonFormations
|
||||
#include "explosions.hpp" // for Explosions
|
||||
#include "param.hpp" // for Param, ParamGame, param
|
||||
#include "utils.hpp" // for Zone
|
||||
#include "game/entities/balloon.hpp" // for Balloon
|
||||
#include "game/entities/explosions.hpp" // for Explosions
|
||||
#include "game/gameplay/balloon_formations.hpp" // for BalloonFormations
|
||||
#include "utils/param.hpp" // for Param, ParamGame, param
|
||||
#include "utils/utils.hpp" // for Zone
|
||||
|
||||
class IStageInfo;
|
||||
class Texture;
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "bullet_manager.hpp"
|
||||
#include "game/gameplay/bullet_manager.hpp"
|
||||
|
||||
#include <algorithm> // Para remove_if
|
||||
#include <utility>
|
||||
|
||||
#include "bullet.hpp" // Para Bullet
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "utils.hpp" // Para Circle, Zone
|
||||
#include "game/entities/bullet.hpp" // Para Bullet
|
||||
#include "utils/param.hpp" // Para Param, ParamGame, param
|
||||
#include "utils/utils.hpp" // Para Circle, Zone
|
||||
|
||||
// Constructor
|
||||
BulletManager::BulletManager()
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user