arreglos en make y cmake
This commit is contained in:
@@ -117,36 +117,46 @@ set(DEBUG_SOURCES
|
|||||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||||
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
||||||
|
|
||||||
# --- SHADER COMPILATION ---
|
# --- SHADER COMPILATION (Linux/Windows only - macOS uses Metal) ---
|
||||||
find_program(GLSLC_EXE NAMES glslc)
|
if(NOT APPLE)
|
||||||
|
find_program(GLSLC_EXE NAMES glslc)
|
||||||
|
|
||||||
set(SHADER_VERT_SRC "${CMAKE_SOURCE_DIR}/data/shaders/postfx.vert")
|
set(SHADER_VERT_SRC "${CMAKE_SOURCE_DIR}/data/shaders/postfx.vert")
|
||||||
set(SHADER_FRAG_SRC "${CMAKE_SOURCE_DIR}/data/shaders/postfx.frag")
|
set(SHADER_FRAG_SRC "${CMAKE_SOURCE_DIR}/data/shaders/postfx.frag")
|
||||||
set(SHADER_VERT_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/postfx_vert_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_FRAG_H "${CMAKE_SOURCE_DIR}/source/core/rendering/sdl3gpu/postfx_frag_spv.h")
|
||||||
|
|
||||||
if(GLSLC_EXE)
|
if(GLSLC_EXE)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${SHADER_VERT_H}" "${SHADER_FRAG_H}"
|
OUTPUT "${SHADER_VERT_H}" "${SHADER_FRAG_H}"
|
||||||
COMMAND "${CMAKE_SOURCE_DIR}/tools/shaders/compile_spirv.sh"
|
COMMAND "${CMAKE_SOURCE_DIR}/tools/shaders/compile_spirv.sh"
|
||||||
DEPENDS "${SHADER_VERT_SRC}" "${SHADER_FRAG_SRC}"
|
DEPENDS "${SHADER_VERT_SRC}" "${SHADER_FRAG_SRC}"
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
COMMENT "Compilando shaders SPIR-V..."
|
COMMENT "Compilando shaders SPIR-V..."
|
||||||
)
|
)
|
||||||
add_custom_target(shaders DEPENDS "${SHADER_VERT_H}" "${SHADER_FRAG_H}")
|
add_custom_target(shaders DEPENDS "${SHADER_VERT_H}" "${SHADER_FRAG_H}")
|
||||||
message(STATUS "glslc encontrado: shaders se compilarán automáticamente")
|
message(STATUS "glslc encontrado: shaders se compilarán automáticamente")
|
||||||
else()
|
else()
|
||||||
message(STATUS "glslc no encontrado - usando headers SPIR-V precompilados")
|
if(NOT EXISTS "${SHADER_VERT_H}" OR NOT EXISTS "${SHADER_FRAG_H}")
|
||||||
if(NOT EXISTS "${SHADER_VERT_H}" OR NOT EXISTS "${SHADER_FRAG_H}")
|
message(FATAL_ERROR
|
||||||
message(WARNING "glslc no disponible y headers SPIR-V no encontrados. Ejecuta tools/shaders/compile_spirv.sh manualmente.")
|
"glslc no encontrado y headers SPIR-V no existen.\n"
|
||||||
|
" Instala glslc: sudo apt install glslang-tools (Linux)\n"
|
||||||
|
" choco install vulkan-sdk (Windows)\n"
|
||||||
|
" O genera los headers manualmente: tools/shaders/compile_spirv.sh"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "glslc no encontrado - usando headers SPIR-V precompilados")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "macOS: shaders SPIR-V omitidos (usa Metal)")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- 2. AÑADIR EJECUTABLE ---
|
# --- 2. AÑADIR EJECUTABLE ---
|
||||||
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${RENDERING_SOURCES})
|
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${RENDERING_SOURCES})
|
||||||
|
|
||||||
# Shaders deben compilarse antes que el ejecutable (si glslc disponible)
|
# Shaders deben compilarse antes que el ejecutable (Linux/Windows con glslc)
|
||||||
if(GLSLC_EXE)
|
if(NOT APPLE AND GLSLC_EXE)
|
||||||
add_dependencies(${PROJECT_NAME} shaders)
|
add_dependencies(${PROJECT_NAME} shaders)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
40
Makefile
40
Makefile
@@ -30,6 +30,14 @@ endif
|
|||||||
PACK_SOURCES := $(DIR_TOOLS)pack_resources/pack_resources.cpp source/core/resources/resource_pack.cpp
|
PACK_SOURCES := $(DIR_TOOLS)pack_resources/pack_resources.cpp source/core/resources/resource_pack.cpp
|
||||||
PACK_INCLUDES := -Isource
|
PACK_INCLUDES := -Isource
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# SHADERS
|
||||||
|
# ==============================================================================
|
||||||
|
SHADER_SCRIPT := $(DIR_ROOT)tools/shaders/compile_spirv.sh
|
||||||
|
SHADER_VERT_H := $(DIR_ROOT)source/core/rendering/sdl3gpu/postfx_vert_spv.h
|
||||||
|
SHADER_FRAG_H := $(DIR_ROOT)source/core/rendering/sdl3gpu/postfx_frag_spv.h
|
||||||
|
GLSLC := $(shell command -v glslc 2>/dev/null)
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# VERSION (extracted from defines.hpp)
|
# VERSION (extracted from defines.hpp)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -157,6 +165,25 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# REGLAS PARA COMPILACIÓN DE SHADERS
|
||||||
|
# ==============================================================================
|
||||||
|
compile_shaders:
|
||||||
|
ifdef GLSLC
|
||||||
|
@echo "Compilando shaders SPIR-V..."
|
||||||
|
@$(SHADER_SCRIPT)
|
||||||
|
@echo "✓ Shaders compilados"
|
||||||
|
else
|
||||||
|
@if [ -f "$(SHADER_VERT_H)" ] && [ -f "$(SHADER_FRAG_H)" ]; then \
|
||||||
|
echo "⚠ glslc no encontrado - usando headers SPIR-V precompilados"; \
|
||||||
|
else \
|
||||||
|
echo "ERROR: glslc no encontrado y headers SPIR-V no existen."; \
|
||||||
|
echo " Instala glslc: sudo apt install glslang-tools"; \
|
||||||
|
echo " O ejecuta manualmente: tools/shaders/compile_spirv.sh"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
endif
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# REGLAS PARA HERRAMIENTA DE EMPAQUETADO Y RESOURCES.PACK
|
# REGLAS PARA HERRAMIENTA DE EMPAQUETADO Y RESOURCES.PACK
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -185,6 +212,7 @@ windows:
|
|||||||
strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(WIN_TARGET_FILE).exe" --strip-unneeded
|
||||||
|
|
||||||
windows_release:
|
windows_release:
|
||||||
|
@$(MAKE) compile_shaders
|
||||||
@$(MAKE) resources.pack
|
@$(MAKE) resources.pack
|
||||||
@echo off
|
@echo off
|
||||||
@echo Creando release para Windows - Version: $(VERSION)
|
@echo Creando release para Windows - Version: $(VERSION)
|
||||||
@@ -230,7 +258,7 @@ macos:
|
|||||||
clang++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
clang++ $(ALL_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
@$(MAKE) pack_tool
|
@$(MAKE) compile_shaders
|
||||||
@$(MAKE) resources.pack
|
@$(MAKE) resources.pack
|
||||||
@echo "Creando release para macOS - Version: $(VERSION)"
|
@echo "Creando release para macOS - Version: $(VERSION)"
|
||||||
|
|
||||||
@@ -274,7 +302,6 @@ macos_release:
|
|||||||
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
||||||
|
|
||||||
# Empaqueta el .dmg de la versión Intel con create-dmg
|
# Empaqueta el .dmg de la versión Intel con create-dmg
|
||||||
$(MKDIR) "$(DIST_DIR)"
|
|
||||||
@echo "Creando DMG Intel con iconos de 96x96..."
|
@echo "Creando DMG Intel con iconos de 96x96..."
|
||||||
create-dmg \
|
create-dmg \
|
||||||
--volname "$(APP_NAME)" \
|
--volname "$(APP_NAME)" \
|
||||||
@@ -329,7 +356,7 @@ linux:
|
|||||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
|
||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
@$(MAKE) pack_tool
|
@$(MAKE) compile_shaders
|
||||||
@$(MAKE) resources.pack
|
@$(MAKE) resources.pack
|
||||||
@echo "Creando release para Linux - Version: $(VERSION)"
|
@echo "Creando release para Linux - Version: $(VERSION)"
|
||||||
|
|
||||||
@@ -338,12 +365,9 @@ linux_release:
|
|||||||
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
|
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
|
||||||
sed "s/@GIT_HASH@/$$GIT_HASH/g" source/version.h.in > source/version.h
|
sed "s/@GIT_HASH@/$$GIT_HASH/g" source/version.h.in > source/version.h
|
||||||
|
|
||||||
# Elimina carpetas previas
|
# Elimina carpeta temporal previa y la recrea (crea dist/ si no existe)
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Crea la carpeta temporal para realizar el lanzamiento
|
|
||||||
$(MKDIR) "$(RELEASE_FOLDER)"
|
$(MKDIR) "$(RELEASE_FOLDER)"
|
||||||
$(MKDIR) "$(DIST_DIR)"
|
|
||||||
|
|
||||||
# Copia ficheros
|
# Copia ficheros
|
||||||
cp resources.pack "$(RELEASE_FOLDER)"
|
cp resources.pack "$(RELEASE_FOLDER)"
|
||||||
@@ -387,4 +411,4 @@ help:
|
|||||||
|
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
.PHONY: windows windows_release macos macos_release linux linux_release pack_tool resources.pack show_version help
|
.PHONY: windows windows_release macos macos_release linux linux_release compile_shaders pack_tool resources.pack show_version help
|
||||||
|
|||||||
@@ -9,15 +9,15 @@
|
|||||||
#include <iterator> // Para istreambuf_iterator, operator==
|
#include <iterator> // Para istreambuf_iterator, operator==
|
||||||
#include <string> // Para char_traits, string, operator+, operator==
|
#include <string> // Para char_traits, string, operator+, operator==
|
||||||
|
|
||||||
#include "core/input/mouse.hpp" // Para updateCursorVisibility
|
#include "core/input/mouse.hpp" // Para updateCursorVisibility
|
||||||
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader
|
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader
|
||||||
#include "core/rendering/surface.hpp" // Para Surface, readPalFile
|
#include "core/rendering/surface.hpp" // Para Surface, readPalFile
|
||||||
#include "core/rendering/text.hpp" // Para Text
|
#include "core/rendering/text.hpp" // Para Text
|
||||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||||
#include "core/resources/resource_list.hpp" // Para Asset, AssetType
|
#include "core/resources/resource_list.hpp" // Para Asset, AssetType
|
||||||
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
|
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
|
||||||
#include "game/ui/notifier.hpp" // Para Notifier
|
#include "game/ui/notifier.hpp" // Para Notifier
|
||||||
|
|
||||||
// [SINGLETON]
|
// [SINGLETON]
|
||||||
Screen* Screen::screen = nullptr;
|
Screen* Screen::screen = nullptr;
|
||||||
@@ -459,8 +459,7 @@ auto loadData(const std::string& filepath) -> std::vector<uint8_t> {
|
|||||||
void Screen::applyCurrentPostFXPreset() {
|
void Screen::applyCurrentPostFXPreset() {
|
||||||
if (shader_backend_ && !Options::postfx_presets.empty()) {
|
if (shader_backend_ && !Options::postfx_presets.empty()) {
|
||||||
const auto& p = Options::postfx_presets[static_cast<size_t>(Options::current_postfx_preset)];
|
const auto& p = Options::postfx_presets[static_cast<size_t>(Options::current_postfx_preset)];
|
||||||
Rendering::PostFXParams params{p.vignette, p.scanlines, p.chroma,
|
Rendering::PostFXParams params{p.vignette, p.scanlines, p.chroma, p.mask, p.gamma, p.curvature, p.bleeding};
|
||||||
p.mask, p.gamma, p.curvature, p.bleeding};
|
|
||||||
shader_backend_->setPostFXParams(params);
|
shader_backend_->setPostFXParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
#include <SDL3/SDL_pixels.h> // Para Uint32
|
||||||
|
|
||||||
#include <cstddef> // Para size_t
|
#include <cstddef> // Para size_t
|
||||||
#include <memory> // Para shared_ptr, __shared_ptr_access
|
#include <memory> // Para shared_ptr, __shared_ptr_access
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include <SDL3/SDL_pixels.h> // Para Uint32
|
|
||||||
|
|
||||||
#include "utils/utils.hpp" // Para Color
|
#include "utils/utils.hpp" // Para Color
|
||||||
class Surface;
|
class Surface;
|
||||||
class Text;
|
class Text;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -218,9 +218,7 @@ auto SDL3GPUShader::init(SDL_Window* window,
|
|||||||
device_ = nullptr;
|
device_ = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SDL_SetGPUSwapchainParameters(device_, window_,
|
SDL_SetGPUSwapchainParameters(device_, window_, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, vsync_ ? SDL_GPU_PRESENTMODE_VSYNC : SDL_GPU_PRESENTMODE_IMMEDIATE);
|
||||||
SDL_GPU_SWAPCHAINCOMPOSITION_SDR,
|
|
||||||
vsync_ ? SDL_GPU_PRESENTMODE_VSYNC : SDL_GPU_PRESENTMODE_IMMEDIATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
@@ -292,15 +290,11 @@ auto SDL3GPUShader::createPipeline() -> bool {
|
|||||||
const SDL_GPUTextureFormat SWAPCHAIN_FMT = SDL_GetGPUSwapchainTextureFormat(device_, window_);
|
const SDL_GPUTextureFormat SWAPCHAIN_FMT = SDL_GetGPUSwapchainTextureFormat(device_, window_);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
SDL_GPUShader* vert = createShaderMSL(device_, POSTFX_VERT_MSL, "postfx_vs",
|
SDL_GPUShader* vert = createShaderMSL(device_, POSTFX_VERT_MSL, "postfx_vs", SDL_GPU_SHADERSTAGE_VERTEX, 0, 0);
|
||||||
SDL_GPU_SHADERSTAGE_VERTEX, 0, 0);
|
SDL_GPUShader* frag = createShaderMSL(device_, POSTFX_FRAG_MSL, "postfx_fs", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
||||||
SDL_GPUShader* frag = createShaderMSL(device_, POSTFX_FRAG_MSL, "postfx_fs",
|
|
||||||
SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
|
||||||
#else
|
#else
|
||||||
SDL_GPUShader* vert = createShaderSPIRV(device_, kpostfx_vert_spv, kpostfx_vert_spv_size,
|
SDL_GPUShader* vert = createShaderSPIRV(device_, kpostfx_vert_spv, kpostfx_vert_spv_size, "main", SDL_GPU_SHADERSTAGE_VERTEX, 0, 0);
|
||||||
"main", SDL_GPU_SHADERSTAGE_VERTEX, 0, 0);
|
SDL_GPUShader* frag = createShaderSPIRV(device_, kpostfx_frag_spv, kpostfx_frag_spv_size, "main", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
||||||
SDL_GPUShader* frag = createShaderSPIRV(device_, kpostfx_frag_spv, kpostfx_frag_spv_size,
|
|
||||||
"main", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((vert == nullptr) || (frag == nullptr)) {
|
if ((vert == nullptr) || (frag == nullptr)) {
|
||||||
@@ -418,9 +412,7 @@ void SDL3GPUShader::render() {
|
|||||||
float vw = 0.0F;
|
float vw = 0.0F;
|
||||||
float vh = 0.0F;
|
float vh = 0.0F;
|
||||||
if (integer_scale_) {
|
if (integer_scale_) {
|
||||||
const int scale = std::max(1, std::min(
|
const int scale = std::max(1, std::min(static_cast<int>(sw) / tex_width_, static_cast<int>(sh) / tex_height_));
|
||||||
static_cast<int>(sw) / tex_width_,
|
|
||||||
static_cast<int>(sh) / tex_height_));
|
|
||||||
vw = static_cast<float>(tex_width_ * scale);
|
vw = static_cast<float>(tex_width_ * scale);
|
||||||
vh = static_cast<float>(tex_height_ * scale);
|
vh = static_cast<float>(tex_height_ * scale);
|
||||||
} else {
|
} else {
|
||||||
@@ -543,19 +535,17 @@ auto SDL3GPUShader::createShaderSPIRV(SDL_GPUDevice* device,
|
|||||||
void SDL3GPUShader::setPostFXParams(const PostFXParams& p) {
|
void SDL3GPUShader::setPostFXParams(const PostFXParams& p) {
|
||||||
uniforms_.vignette_strength = p.vignette;
|
uniforms_.vignette_strength = p.vignette;
|
||||||
uniforms_.scanline_strength = p.scanlines;
|
uniforms_.scanline_strength = p.scanlines;
|
||||||
uniforms_.chroma_strength = p.chroma;
|
uniforms_.chroma_strength = p.chroma;
|
||||||
uniforms_.mask_strength = p.mask;
|
uniforms_.mask_strength = p.mask;
|
||||||
uniforms_.gamma_strength = p.gamma;
|
uniforms_.gamma_strength = p.gamma;
|
||||||
uniforms_.curvature = p.curvature;
|
uniforms_.curvature = p.curvature;
|
||||||
uniforms_.bleeding = p.bleeding;
|
uniforms_.bleeding = p.bleeding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL3GPUShader::setVSync(bool vsync) {
|
void SDL3GPUShader::setVSync(bool vsync) {
|
||||||
vsync_ = vsync;
|
vsync_ = vsync;
|
||||||
if (device_ != nullptr && window_ != nullptr) {
|
if (device_ != nullptr && window_ != nullptr) {
|
||||||
SDL_SetGPUSwapchainParameters(device_, window_,
|
SDL_SetGPUSwapchainParameters(device_, window_, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, vsync_ ? SDL_GPU_PRESENTMODE_VSYNC : SDL_GPU_PRESENTMODE_IMMEDIATE);
|
||||||
SDL_GPU_SWAPCHAINCOMPOSITION_SDR,
|
|
||||||
vsync_ ? SDL_GPU_PRESENTMODE_VSYNC : SDL_GPU_PRESENTMODE_IMMEDIATE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class SDL3GPUShader : public ShaderBackend {
|
|||||||
|
|
||||||
void render() override;
|
void render() override;
|
||||||
void setTextureSize(float width, float height) override {}
|
void setTextureSize(float width, float height) override {}
|
||||||
void cleanup() override; // Libera pipeline/texturas pero mantiene el device vivo
|
void cleanup() override; // Libera pipeline/texturas pero mantiene el device vivo
|
||||||
void destroy(); // Limpieza completa (device + swapchain); llamar solo al cerrar
|
void destroy(); // Limpieza completa (device + swapchain); llamar solo al cerrar
|
||||||
[[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; }
|
[[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; }
|
||||||
|
|
||||||
// Sube píxeles ARGB8888 desde CPU; llamado antes de render()
|
// Sube píxeles ARGB8888 desde CPU; llamado antes de render()
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ namespace Rendering {
|
|||||||
* Definido a nivel de namespace para facilitar el uso desde subclases y screen.cpp
|
* Definido a nivel de namespace para facilitar el uso desde subclases y screen.cpp
|
||||||
*/
|
*/
|
||||||
struct PostFXParams {
|
struct PostFXParams {
|
||||||
float vignette = 0.0F; // Intensidad de la viñeta
|
float vignette = 0.0F; // Intensidad de la viñeta
|
||||||
float scanlines = 0.0F; // Intensidad de las scanlines
|
float scanlines = 0.0F; // Intensidad de las scanlines
|
||||||
float chroma = 0.0F; // Aberración cromática
|
float chroma = 0.0F; // Aberración cromática
|
||||||
float mask = 0.0F; // Máscara de fósforo RGB
|
float mask = 0.0F; // Máscara de fósforo RGB
|
||||||
float gamma = 0.0F; // Corrección gamma (blend 0=off, 1=full)
|
float gamma = 0.0F; // Corrección gamma (blend 0=off, 1=full)
|
||||||
float curvature = 0.0F; // Curvatura barrel CRT
|
float curvature = 0.0F; // Curvatura barrel CRT
|
||||||
float bleeding = 0.0F; // Sangrado de color NTSC
|
float bleeding = 0.0F; // Sangrado de color NTSC
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -480,9 +480,7 @@ void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Idem però reemplaçant un color índex
|
// Idem però reemplaçant un color índex
|
||||||
void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height,
|
void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, SDL_FRect* src_rect) {
|
||||||
Uint8 source_color, Uint8 target_color,
|
|
||||||
SDL_FRect* src_rect) {
|
|
||||||
const int SX = src_rect ? static_cast<int>(src_rect->x) : 0;
|
const int SX = src_rect ? static_cast<int>(src_rect->x) : 0;
|
||||||
const int SY = src_rect ? static_cast<int>(src_rect->y) : 0;
|
const int SY = src_rect ? static_cast<int>(src_rect->y) : 0;
|
||||||
const int SW = src_rect ? static_cast<int>(src_rect->w) : static_cast<int>(surface_data_->width);
|
const int SW = src_rect ? static_cast<int>(src_rect->w) : static_cast<int>(surface_data_->width);
|
||||||
|
|||||||
@@ -88,9 +88,7 @@ class Surface {
|
|||||||
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, SDL_FRect* src_rect = nullptr);
|
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, SDL_FRect* src_rect = nullptr);
|
||||||
|
|
||||||
// Idem però reemplaçant un color índex (per a sprites sobre fons del mateix color)
|
// Idem però reemplaçant un color índex (per a sprites sobre fons del mateix color)
|
||||||
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height,
|
void renderWithVerticalFade(int x, int y, int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color, SDL_FRect* src_rect = nullptr);
|
||||||
Uint8 source_color, Uint8 target_color,
|
|
||||||
SDL_FRect* src_rect = nullptr);
|
|
||||||
|
|
||||||
// Establece un color en la paleta
|
// Establece un color en la paleta
|
||||||
void setColor(int index, Uint32 color);
|
void setColor(int index, Uint32 color);
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ static auto pixelRank(int col, int row) -> float {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rang per a un píxel tenint en compte direcció (70% direccional + 30% aleatori)
|
// Rang per a un píxel tenint en compte direcció (70% direccional + 30% aleatori)
|
||||||
auto SurfaceDissolveSprite::computePixelRank(int col, int row, int frame_h,
|
auto SurfaceDissolveSprite::computePixelRank(int col, int row, int frame_h, DissolveDirection dir) -> float {
|
||||||
DissolveDirection dir) -> float {
|
|
||||||
const float RANDOM = pixelRank(col, row);
|
const float RANDOM = pixelRank(col, row);
|
||||||
if (dir == DissolveDirection::NONE || frame_h <= 0) {
|
if (dir == DissolveDirection::NONE || frame_h <= 0) {
|
||||||
return RANDOM;
|
return RANDOM;
|
||||||
@@ -83,7 +82,7 @@ void SurfaceDissolveSprite::rebuildDisplaySurface() {
|
|||||||
// Esborra frame anterior si ha canviat
|
// Esborra frame anterior si ha canviat
|
||||||
if (prev_clip_.w > 0 && prev_clip_.h > 0 &&
|
if (prev_clip_.w > 0 && prev_clip_.h > 0 &&
|
||||||
(prev_clip_.x != CLIP.x || prev_clip_.y != CLIP.y ||
|
(prev_clip_.x != CLIP.x || prev_clip_.y != CLIP.y ||
|
||||||
prev_clip_.w != CLIP.w || prev_clip_.h != CLIP.h)) {
|
prev_clip_.w != CLIP.w || prev_clip_.h != CLIP.h)) {
|
||||||
surface_display_->fillRect(&prev_clip_, TRANSPARENT);
|
surface_display_->fillRect(&prev_clip_, TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
class Surface;
|
class Surface;
|
||||||
|
|
||||||
// Direcció de la dissolució
|
// Direcció de la dissolució
|
||||||
enum class DissolveDirection { NONE, DOWN, UP };
|
enum class DissolveDirection { NONE,
|
||||||
|
DOWN,
|
||||||
|
UP };
|
||||||
|
|
||||||
// Sprite que pot dissoldre's o generar-se de forma aleatòria en X mil·lisegons.
|
// Sprite que pot dissoldre's o generar-se de forma aleatòria en X mil·lisegons.
|
||||||
// progress_ va de 0.0 (totalment visible) a 1.0 (totalment invisible).
|
// progress_ va de 0.0 (totalment visible) a 1.0 (totalment invisible).
|
||||||
@@ -39,11 +41,13 @@ class SurfaceDissolveSprite : public SurfaceAnimatedSprite {
|
|||||||
void setColorReplace(Uint8 source, Uint8 target);
|
void setColorReplace(Uint8 source, Uint8 target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class TransitionMode { NONE, DISSOLVING, GENERATING };
|
enum class TransitionMode { NONE,
|
||||||
|
DISSOLVING,
|
||||||
|
GENERATING };
|
||||||
|
|
||||||
std::shared_ptr<Surface> surface_display_; // Superfície amb els píxels filtrats
|
std::shared_ptr<Surface> surface_display_; // Superfície amb els píxels filtrats
|
||||||
|
|
||||||
float progress_{0.0F}; // [0=visible, 1=invisible]
|
float progress_{0.0F}; // [0=visible, 1=invisible]
|
||||||
DissolveDirection direction_{DissolveDirection::NONE};
|
DissolveDirection direction_{DissolveDirection::NONE};
|
||||||
TransitionMode transition_mode_{TransitionMode::NONE};
|
TransitionMode transition_mode_{TransitionMode::NONE};
|
||||||
float transition_duration_{0.0F};
|
float transition_duration_{0.0F};
|
||||||
@@ -54,6 +58,5 @@ class SurfaceDissolveSprite : public SurfaceAnimatedSprite {
|
|||||||
Uint8 target_color_{0};
|
Uint8 target_color_{0};
|
||||||
|
|
||||||
void rebuildDisplaySurface();
|
void rebuildDisplaySurface();
|
||||||
[[nodiscard]] static auto computePixelRank(int col, int row, int frame_h,
|
[[nodiscard]] static auto computePixelRank(int col, int row, int frame_h, DissolveDirection dir) -> float;
|
||||||
DissolveDirection dir) -> float;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,15 +33,22 @@ void SurfaceSprite::render(Uint8 source_color, Uint8 target_color) {
|
|||||||
|
|
||||||
void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height) {
|
void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height) {
|
||||||
surface_->renderWithVerticalFade(
|
surface_->renderWithVerticalFade(
|
||||||
static_cast<int>(pos_.x), static_cast<int>(pos_.y),
|
static_cast<int>(pos_.x),
|
||||||
fade_h, canvas_height, &clip_);
|
static_cast<int>(pos_.y),
|
||||||
|
fade_h,
|
||||||
|
canvas_height,
|
||||||
|
&clip_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height,
|
void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color) {
|
||||||
Uint8 source_color, Uint8 target_color) {
|
|
||||||
surface_->renderWithVerticalFade(
|
surface_->renderWithVerticalFade(
|
||||||
static_cast<int>(pos_.x), static_cast<int>(pos_.y),
|
static_cast<int>(pos_.x),
|
||||||
fade_h, canvas_height, source_color, target_color, &clip_);
|
static_cast<int>(pos_.y),
|
||||||
|
fade_h,
|
||||||
|
canvas_height,
|
||||||
|
source_color,
|
||||||
|
target_color,
|
||||||
|
&clip_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición del objeto
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ class SurfaceSprite {
|
|||||||
virtual ~SurfaceSprite() = default;
|
virtual ~SurfaceSprite() = default;
|
||||||
|
|
||||||
// Actualización y renderizado
|
// Actualización y renderizado
|
||||||
virtual void update(float delta_time); // Actualiza el estado del sprite (time-based)
|
virtual void update(float delta_time); // Actualiza el estado del sprite (time-based)
|
||||||
virtual void render(); // Muestra el sprite por pantalla
|
virtual void render(); // Muestra el sprite por pantalla
|
||||||
virtual void render(Uint8 source_color, Uint8 target_color); // Renderiza con reemplazo de color
|
virtual void render(Uint8 source_color, Uint8 target_color); // Renderiza con reemplazo de color
|
||||||
virtual void renderWithVerticalFade(int fade_h, int canvas_height); // Renderiza amb dissolució vertical (hash 2D, sense parpelleig)
|
virtual void renderWithVerticalFade(int fade_h, int canvas_height); // Renderiza amb dissolució vertical (hash 2D, sense parpelleig)
|
||||||
virtual void renderWithVerticalFade(int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color); // Idem amb reemplaç de color
|
virtual void renderWithVerticalFade(int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color); // Idem amb reemplaç de color
|
||||||
|
|
||||||
// Gestión de estado
|
// Gestión de estado
|
||||||
|
|||||||
@@ -682,25 +682,39 @@ auto loadPostFXFromFile() -> bool {
|
|||||||
preset.name = p["name"].get_value<std::string>();
|
preset.name = p["name"].get_value<std::string>();
|
||||||
}
|
}
|
||||||
if (p.contains("vignette")) {
|
if (p.contains("vignette")) {
|
||||||
try { preset.vignette = p["vignette"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.vignette = p["vignette"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
if (p.contains("scanlines")) {
|
if (p.contains("scanlines")) {
|
||||||
try { preset.scanlines = p["scanlines"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.scanlines = p["scanlines"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
if (p.contains("chroma")) {
|
if (p.contains("chroma")) {
|
||||||
try { preset.chroma = p["chroma"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.chroma = p["chroma"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
if (p.contains("mask")) {
|
if (p.contains("mask")) {
|
||||||
try { preset.mask = p["mask"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.mask = p["mask"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
if (p.contains("gamma")) {
|
if (p.contains("gamma")) {
|
||||||
try { preset.gamma = p["gamma"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.gamma = p["gamma"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
if (p.contains("curvature")) {
|
if (p.contains("curvature")) {
|
||||||
try { preset.curvature = p["curvature"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.curvature = p["curvature"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
if (p.contains("bleeding")) {
|
if (p.contains("bleeding")) {
|
||||||
try { preset.bleeding = p["bleeding"].get_value<float>(); } catch (...) {}
|
try {
|
||||||
|
preset.bleeding = p["bleeding"].get_value<float>();
|
||||||
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
postfx_presets.push_back(preset);
|
postfx_presets.push_back(preset);
|
||||||
}
|
}
|
||||||
@@ -794,11 +808,11 @@ auto savePostFXToFile() -> bool {
|
|||||||
|
|
||||||
// Cargar los presets recién creados
|
// Cargar los presets recién creados
|
||||||
postfx_presets.clear();
|
postfx_presets.clear();
|
||||||
postfx_presets.push_back({"CRT", 0.6F, 0.7F, 0.15F, 0.6F, 0.8F, 0.0F, 0.0F});
|
postfx_presets.push_back({"CRT", 0.6F, 0.7F, 0.15F, 0.6F, 0.8F, 0.0F, 0.0F});
|
||||||
postfx_presets.push_back({"NTSC", 0.4F, 0.5F, 0.2F, 0.4F, 0.5F, 0.0F, 0.6F});
|
postfx_presets.push_back({"NTSC", 0.4F, 0.5F, 0.2F, 0.4F, 0.5F, 0.0F, 0.6F});
|
||||||
postfx_presets.push_back({"CURVED", 0.5F, 0.6F, 0.1F, 0.5F, 0.7F, 0.8F, 0.0F});
|
postfx_presets.push_back({"CURVED", 0.5F, 0.6F, 0.1F, 0.5F, 0.7F, 0.8F, 0.0F});
|
||||||
postfx_presets.push_back({"SCANLINES",0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F});
|
postfx_presets.push_back({"SCANLINES", 0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F});
|
||||||
postfx_presets.push_back({"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.3F, 0.0F, 0.0F});
|
postfx_presets.push_back({"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.3F, 0.0F, 0.0F});
|
||||||
current_postfx_preset = 0;
|
current_postfx_preset = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -116,14 +116,14 @@ struct Game {
|
|||||||
|
|
||||||
// Estructura para un preset de PostFX
|
// Estructura para un preset de PostFX
|
||||||
struct PostFXPreset {
|
struct PostFXPreset {
|
||||||
std::string name; // Nombre del preset
|
std::string name; // Nombre del preset
|
||||||
float vignette{0.6F}; // Intensidad de la viñeta (0.0 = ninguna, 1.0 = máxima)
|
float vignette{0.6F}; // Intensidad de la viñeta (0.0 = ninguna, 1.0 = máxima)
|
||||||
float scanlines{0.7F}; // Intensidad de las scanlines (0.0 = desactivadas, 1.0 = máximas)
|
float scanlines{0.7F}; // Intensidad de las scanlines (0.0 = desactivadas, 1.0 = máximas)
|
||||||
float chroma{0.15F}; // Intensidad de la aberración cromática (0.0 = ninguna, 1.0 = máxima)
|
float chroma{0.15F}; // Intensidad de la aberración cromática (0.0 = ninguna, 1.0 = máxima)
|
||||||
float mask{0.0F}; // Intensidad de la máscara de fósforo RGB (0.0 = desactivada, 1.0 = máxima)
|
float mask{0.0F}; // Intensidad de la máscara de fósforo RGB (0.0 = desactivada, 1.0 = máxima)
|
||||||
float gamma{0.0F}; // Corrección gamma input 2.4 / output 2.2 (0.0 = off, 1.0 = plena)
|
float gamma{0.0F}; // Corrección gamma input 2.4 / output 2.2 (0.0 = off, 1.0 = plena)
|
||||||
float curvature{0.0F}; // Distorsión barrel CRT (0.0 = plana, 1.0 = máxima curvatura)
|
float curvature{0.0F}; // Distorsión barrel CRT (0.0 = plana, 1.0 = máxima curvatura)
|
||||||
float bleeding{0.0F}; // Sangrado de color NTSC horizontal Y/C (0.0 = off, 1.0 = máximo)
|
float bleeding{0.0F}; // Sangrado de color NTSC horizontal Y/C (0.0 = off, 1.0 = máximo)
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Variables globales ---
|
// --- Variables globales ---
|
||||||
@@ -148,12 +148,12 @@ inline int current_postfx_preset{0}; // Índice del preset de Pos
|
|||||||
inline std::string postfx_file_path{}; // Ruta del fichero postfx.yaml
|
inline std::string postfx_file_path{}; // Ruta del fichero postfx.yaml
|
||||||
|
|
||||||
// --- Funciones públicas ---
|
// --- Funciones públicas ---
|
||||||
void init(); // Crea e inicializa las opciones del programa
|
void init(); // Crea e inicializa las opciones del programa
|
||||||
void setConfigFile(const std::string& path); // Establece la ruta del fichero de configuración
|
void setConfigFile(const std::string& path); // Establece la ruta del fichero de configuración
|
||||||
auto loadFromFile() -> bool; // Carga las opciones desde el fichero configurado
|
auto loadFromFile() -> bool; // Carga las opciones desde el fichero configurado
|
||||||
auto saveToFile() -> bool; // Guarda las opciones al fichero configurado
|
auto saveToFile() -> bool; // Guarda las opciones al fichero configurado
|
||||||
void setPostFXFile(const std::string& path); // Establece la ruta del fichero de PostFX
|
void setPostFXFile(const std::string& path); // Establece la ruta del fichero de PostFX
|
||||||
auto loadPostFXFromFile() -> bool; // Carga los presets de PostFX desde el fichero
|
auto loadPostFXFromFile() -> bool; // Carga los presets de PostFX desde el fichero
|
||||||
auto savePostFXToFile() -> bool; // Guarda los presets de PostFX por defecto
|
auto savePostFXToFile() -> bool; // Guarda los presets de PostFX por defecto
|
||||||
|
|
||||||
} // namespace Options
|
} // namespace Options
|
||||||
@@ -34,7 +34,7 @@ enum class Options {
|
|||||||
|
|
||||||
// --- Variables de estado globales ---
|
// --- Variables de estado globales ---
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
inline Scene current = Scene::GAME; // Escena actual
|
inline Scene current = Scene::GAME; // Escena actual
|
||||||
inline Options options = Options::LOGO_TO_LOADING_SCREEN; // Opciones de la escena actual
|
inline Options options = Options::LOGO_TO_LOADING_SCREEN; // Opciones de la escena actual
|
||||||
#else
|
#else
|
||||||
inline Scene current = Scene::LOGO; // Escena actual
|
inline Scene current = Scene::LOGO; // Escena actual
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class Ending {
|
|||||||
static constexpr float TEXT_PIXELS_PER_SECOND = 30.0F; // Filas de texto reveladas por segundo
|
static constexpr float TEXT_PIXELS_PER_SECOND = 30.0F; // Filas de texto reveladas por segundo
|
||||||
static constexpr float IMAGE_PIXELS_PER_SECOND = 60.0F; // Filas de imagen reveladas por segundo
|
static constexpr float IMAGE_PIXELS_PER_SECOND = 60.0F; // Filas de imagen reveladas por segundo
|
||||||
static constexpr float STEP_DURATION = 2.0F / 60.0F; // Segundos por paso de revelado (2 frames @ 60fps)
|
static constexpr float STEP_DURATION = 2.0F / 60.0F; // Segundos por paso de revelado (2 frames @ 60fps)
|
||||||
static constexpr int REVEAL_STEPS = 4; // Pasos de revelado por fila
|
static constexpr int REVEAL_STEPS = 4; // Pasos de revelado por fila
|
||||||
static constexpr float TEXT_LAPSE = 1.333F; // 80 frames @ 60fps
|
static constexpr float TEXT_LAPSE = 1.333F; // 80 frames @ 60fps
|
||||||
static constexpr float FADEOUT_START_OFFSET = 1.667F; // Inicio cortinilla 100 frames antes del fin
|
static constexpr float FADEOUT_START_OFFSET = 1.667F; // Inicio cortinilla 100 frames antes del fin
|
||||||
static constexpr float COVER_PIXELS_PER_SECOND = 120.0F; // Filas cubiertas por segundo
|
static constexpr float COVER_PIXELS_PER_SECOND = 120.0F; // Filas cubiertas por segundo
|
||||||
|
|||||||
@@ -288,17 +288,12 @@ void Ending2::updateSprites(float delta) {
|
|||||||
const float CANVAS_H = static_cast<float>(Options::game.height);
|
const float CANVAS_H = static_cast<float>(Options::game.height);
|
||||||
|
|
||||||
// Checkpoint inferior: sprite entra per baix → generar de dalt a baix
|
// Checkpoint inferior: sprite entra per baix → generar de dalt a baix
|
||||||
if (Y > static_cast<float>(ENTRY_EXIT_PADDING)
|
if (Y > static_cast<float>(ENTRY_EXIT_PADDING) && Y <= CANVAS_H - H - ENTRY_EXIT_PADDING && sprite->getProgress() >= 1.0F && sprite->isTransitionDone()) {
|
||||||
&& Y <= CANVAS_H - H - ENTRY_EXIT_PADDING
|
|
||||||
&& sprite->getProgress() >= 1.0F
|
|
||||||
&& sprite->isTransitionDone()) {
|
|
||||||
sprite->startGenerate(TRANSITION_DURATION_MS, DissolveDirection::UP);
|
sprite->startGenerate(TRANSITION_DURATION_MS, DissolveDirection::UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checkpoint superior: sprite surt per dalt → dissoldre de dalt a baix
|
// Checkpoint superior: sprite surt per dalt → dissoldre de dalt a baix
|
||||||
if (Y <= static_cast<float>(ENTRY_EXIT_PADDING)
|
if (Y <= static_cast<float>(ENTRY_EXIT_PADDING) && sprite->getProgress() <= 0.0F && sprite->isTransitionDone()) {
|
||||||
&& sprite->getProgress() <= 0.0F
|
|
||||||
&& sprite->isTransitionDone()) {
|
|
||||||
sprite->startDissolve(TRANSITION_DURATION_MS, DissolveDirection::DOWN);
|
sprite->startDissolve(TRANSITION_DURATION_MS, DissolveDirection::DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,16 +308,11 @@ void Ending2::updateTextSprites(float delta) {
|
|||||||
const float H = sprite->getHeight();
|
const float H = sprite->getHeight();
|
||||||
const float CANVAS_H = static_cast<float>(Options::game.height);
|
const float CANVAS_H = static_cast<float>(Options::game.height);
|
||||||
|
|
||||||
if (Y > static_cast<float>(ENTRY_EXIT_PADDING)
|
if (Y > static_cast<float>(ENTRY_EXIT_PADDING) && Y <= CANVAS_H - H - ENTRY_EXIT_PADDING && sprite->getProgress() >= 1.0F && sprite->isTransitionDone()) {
|
||||||
&& Y <= CANVAS_H - H - ENTRY_EXIT_PADDING
|
|
||||||
&& sprite->getProgress() >= 1.0F
|
|
||||||
&& sprite->isTransitionDone()) {
|
|
||||||
sprite->startGenerate(TRANSITION_DURATION_MS, DissolveDirection::UP);
|
sprite->startGenerate(TRANSITION_DURATION_MS, DissolveDirection::UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Y <= static_cast<float>(ENTRY_EXIT_PADDING)
|
if (Y <= static_cast<float>(ENTRY_EXIT_PADDING) && sprite->getProgress() <= 0.0F && sprite->isTransitionDone()) {
|
||||||
&& sprite->getProgress() <= 0.0F
|
|
||||||
&& sprite->isTransitionDone()) {
|
|
||||||
sprite->startDissolve(TRANSITION_DURATION_MS, DissolveDirection::DOWN);
|
sprite->startDissolve(TRANSITION_DURATION_MS, DissolveDirection::DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,17 +328,12 @@ void Ending2::updateTexts(float delta) {
|
|||||||
const float CANVAS_H = static_cast<float>(Options::game.height);
|
const float CANVAS_H = static_cast<float>(Options::game.height);
|
||||||
|
|
||||||
// Checkpoint inferior: text entra per baix → generar de dalt a baix
|
// Checkpoint inferior: text entra per baix → generar de dalt a baix
|
||||||
if (Y > static_cast<float>(ENTRY_EXIT_PADDING)
|
if (Y > static_cast<float>(ENTRY_EXIT_PADDING) && Y <= CANVAS_H - H - ENTRY_EXIT_PADDING && sprite->getProgress() >= 1.0F && sprite->isTransitionDone()) {
|
||||||
&& Y <= CANVAS_H - H - ENTRY_EXIT_PADDING
|
|
||||||
&& sprite->getProgress() >= 1.0F
|
|
||||||
&& sprite->isTransitionDone()) {
|
|
||||||
sprite->startGenerate(TRANSITION_DURATION_MS, DissolveDirection::UP);
|
sprite->startGenerate(TRANSITION_DURATION_MS, DissolveDirection::UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checkpoint superior: text surt per dalt → dissoldre de dalt a baix
|
// Checkpoint superior: text surt per dalt → dissoldre de dalt a baix
|
||||||
if (Y <= static_cast<float>(ENTRY_EXIT_PADDING)
|
if (Y <= static_cast<float>(ENTRY_EXIT_PADDING) && sprite->getProgress() <= 0.0F && sprite->isTransitionDone()) {
|
||||||
&& sprite->getProgress() <= 0.0F
|
|
||||||
&& sprite->isTransitionDone()) {
|
|
||||||
sprite->startDissolve(TRANSITION_DURATION_MS, DissolveDirection::DOWN);
|
sprite->startDissolve(TRANSITION_DURATION_MS, DissolveDirection::DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@
|
|||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "utils/defines.hpp" // Para GameCanvas::WIDTH, GameCanvas::FIRST_QUAR...
|
|
||||||
|
|
||||||
#include "core/rendering/surface_dissolve_sprite.hpp" // Para SurfaceDissolveSprite
|
#include "core/rendering/surface_dissolve_sprite.hpp" // Para SurfaceDissolveSprite
|
||||||
|
#include "utils/defines.hpp" // Para GameCanvas::WIDTH, GameCanvas::FIRST_QUAR...
|
||||||
|
|
||||||
class SurfaceMovingSprite;
|
class SurfaceMovingSprite;
|
||||||
class DeltaTimer;
|
class DeltaTimer;
|
||||||
@@ -44,8 +43,8 @@ class Ending2 {
|
|||||||
static constexpr int DIST_SPRITE_SPRITE = 0; // Distancia entre dos sprites de la misma columna
|
static constexpr int DIST_SPRITE_SPRITE = 0; // Distancia entre dos sprites de la misma columna
|
||||||
static constexpr int INITIAL_Y_OFFSET = 40; // Offset inicial en Y para posicionar sprites
|
static constexpr int INITIAL_Y_OFFSET = 40; // Offset inicial en Y para posicionar sprites
|
||||||
static constexpr int SCREEN_MESH_HEIGHT = 8; // Altura de la malla superior/inferior de la pantalla
|
static constexpr int SCREEN_MESH_HEIGHT = 8; // Altura de la malla superior/inferior de la pantalla
|
||||||
static constexpr int FADE_H = 24; // Alçada de la zona de dissolució als cantons (files)
|
static constexpr int FADE_H = 24; // Alçada de la zona de dissolució als cantons (files)
|
||||||
static constexpr float TRANSITION_DURATION_MS = 500.0F; // ms per canviar d'estat (generar o dissoldre)
|
static constexpr float TRANSITION_DURATION_MS = 500.0F; // ms per canviar d'estat (generar o dissoldre)
|
||||||
static constexpr int ENTRY_EXIT_PADDING = 2; // px de padding als bordes per activar dissolució/generació
|
static constexpr int ENTRY_EXIT_PADDING = 2; // px de padding als bordes per activar dissolució/generació
|
||||||
static constexpr int TEXT_SPACING_MULTIPLIER = 2; // Multiplicador para espaciado entre líneas de texto
|
static constexpr int TEXT_SPACING_MULTIPLIER = 2; // Multiplicador para espaciado entre líneas de texto
|
||||||
|
|
||||||
@@ -80,8 +79,8 @@ class Ending2 {
|
|||||||
// Objetos y punteros a recursos
|
// Objetos y punteros a recursos
|
||||||
std::vector<std::shared_ptr<SurfaceDissolveSprite>> sprites_; // Vector con todos los sprites a dibujar
|
std::vector<std::shared_ptr<SurfaceDissolveSprite>> sprites_; // Vector con todos los sprites a dibujar
|
||||||
std::vector<std::shared_ptr<SurfaceDissolveSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites
|
std::vector<std::shared_ptr<SurfaceDissolveSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites
|
||||||
std::vector<std::shared_ptr<SurfaceDissolveSprite>> texts_; // Vector con los sprites de texto
|
std::vector<std::shared_ptr<SurfaceDissolveSprite>> texts_; // Vector con los sprites de texto
|
||||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para time-based update
|
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para time-based update
|
||||||
|
|
||||||
// Variables de estado
|
// Variables de estado
|
||||||
State state_; // Controla el estado de la clase
|
State state_; // Controla el estado de la clase
|
||||||
|
|||||||
Reference in New Issue
Block a user