Compare commits

...

4 Commits

Author SHA1 Message Date
0af29baeb0 modificats els noms de release
All checks were successful
Release / build-linux (push) Successful in 8m34s
Release / build-windows (push) Successful in 10m10s
Release / create-release (push) Successful in 16s
eliminat el build macos-x64
2025-11-25 13:24:49 +01:00
bcb9628fb2 actualitzat release.yalm
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

corregida la ubicació de project.h

canvis en create-release de release.yml

CORREGIT UN PUTO ESPAI EN RELEASE.YML

sadjasbndk

fiuwhfiusdh

sgdwehgr

eriojgtoie
2025-11-25 09:13:32 +01:00
59e6af62ba millorat printWithDots() i Resource::List per a calcular el nom de fitxer mes llarg correctament
Some checks failed
Release / build-windows (push) Has been cancelled
Release / create-release (push) Has been cancelled
Release / build-linux (push) Has been cancelled
2025-11-23 22:18:41 +01:00
1a6185b3aa eliminades referencies a JailDoctor's Dilemma en el codi 2025-11-23 22:04:29 +01:00
19 changed files with 223 additions and 258 deletions

View File

@@ -1,14 +1,3 @@
# Workflow para crear releases automáticos cuando se crea un tag
#
# Uso:
# git tag v0.2
# git push --tags
#
# Esto disparará el workflow y creará un release con binarios para:
# - Linux x64
# - Windows x64
# - Raspberry Pi ARM64
name: Release
on:
@@ -16,239 +5,117 @@ on:
tags:
- 'v*'
env:
SDL3_VERSION: "3.2.26"
jobs:
# ============================================================================
# BUILD LINUX x64
# BUILD LINUX (Nativo)
# ============================================================================
build-linux:
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
container: ubuntu:latest
steps:
- name: Instalar dependencias
run: |
apt-get update
apt-get install -y \
nodejs npm \
build-essential cmake git pkg-config \
libgl1-mesa-dev libglu1-mesa-dev \
libx11-dev libxext-dev libxrandr-dev libxcursor-dev \
apt-get update && apt-get install -y \
curl gnupg build-essential cmake git pkg-config \
libgl1-mesa-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev \
libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev \
libasound2-dev libpulse-dev libudev-dev libdbus-1-dev \
libwayland-dev libxkbcommon-dev
- name: Compilar SDL3
run: |
cd /tmp
git clone --depth 1 --branch release-${{ env.SDL3_VERSION }} https://github.com/libsdl-org/SDL.git
cd SDL
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
cmake --build build -j$(nproc)
cmake --install build
libasound2-dev libpulse-dev libudev-dev libwayland-dev libxkbcommon-dev \
libxtst-dev libdbus-1-dev libdrm-dev libgbm-dev \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
- name: Checkout
uses: actions/checkout@v4
- name: Generar project.h
- name: Setup SDL3
run: |
GIT_HASH=$(git rev-parse --short=7 HEAD)
RAW_VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//')
TARGET_NAME=$(awk '/^project/ {gsub(/[)(]/, " "); print $2}' CMakeLists.txt)
LONG_NAME=$(grep 'PROJECT_LONG_NAME' CMakeLists.txt | sed 's/.*"\(.*\)".*/\1/')
COPYRIGHT=$(sed -n 's/.*set(PROJECT_COPYRIGHT "\([^"]*\)".*/\1/p' CMakeLists.txt)
sed -e "s/@PROJECT_NAME@/$TARGET_NAME/g" \
-e "s/@PROJECT_LONG_NAME@/$LONG_NAME/g" \
-e "s/@PROJECT_VERSION@/$RAW_VERSION/g" \
-e "s/@PROJECT_COPYRIGHT@/$COPYRIGHT/g" \
-e "s/@GIT_HASH@/$GIT_HASH/g" \
source/project.h.in > source/project.h
git clone https://github.com/libsdl-org/SDL.git /tmp/SDL3 \
&& cd /tmp/SDL3 \
&& mkdir build && cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
&& make -j$(nproc) \
&& make install \
&& rm -rf /tmp/SDL3
- name: Compilar pack_tool
- name: Compilar
run: |
g++ -std=c++20 -Wall -Os -Isource \
tools/pack_resources/pack_resources.cpp \
source/core/resources/resource_pack.cpp \
-o tools/pack_resources/pack_resources
- name: Generar resources.pack
run: ./tools/pack_resources/pack_resources data resources.pack
- name: Compilar para Linux
run: |
TARGET_NAME=$(awk '/^project/ {gsub(/[)(]/, " "); print $2}' CMakeLists.txt)
CPP_FILES=$(find source -name "*.cpp")
g++ $CPP_FILES \
-Isource -DRELEASE_BUILD -DLINUX_BUILD \
-std=c++20 -Wall -Os -ffunction-sections -fdata-sections \
-lSDL3 -lGL \
-o $TARGET_NAME
strip -s -R .comment -R .gnu.version $TARGET_NAME --strip-unneeded
- name: Empaquetar release
run: |
TARGET_NAME=$(awk '/^project/ {gsub(/[)(]/, " "); print $2}' CMakeLists.txt)
VERSION="${{ github.ref_name }}"
RELEASE_NAME="${TARGET_NAME}-${VERSION}-linux-x64.tar.gz"
mkdir -p release_tmp
cp $TARGET_NAME resources.pack LICENSE README.md gamecontrollerdb.txt release_tmp/
tar -czvf $RELEASE_NAME -C release_tmp .
echo "RELEASE_FILE=$RELEASE_NAME" >> $GITHUB_ENV
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
make linux_release
- name: Subir artefacto
uses: actions/upload-artifact@v3
with:
name: linux-build
path: ${{ env.RELEASE_FILE }}
path: ./*-linux-x64.tar.gz
# ============================================================================
# BUILD WINDOWS x64 (cross-compile con MinGW)
# BUILD WINDOWS (Cross-Compile usando el nuevo target del Makefile)
# ============================================================================
build-windows:
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
container: ubuntu:latest
steps:
- name: Instalar dependencias
run: |
apt-get update
apt-get install -y nodejs npm build-essential cmake git pkg-config wget mingw-w64 zip
- name: Descargar SDL3 para Windows
run: |
cd /tmp
wget -q https://github.com/libsdl-org/SDL/releases/download/release-${{ env.SDL3_VERSION }}/SDL3-devel-${{ env.SDL3_VERSION }}-mingw.tar.gz
tar -xzf SDL3-devel-${{ env.SDL3_VERSION }}-mingw.tar.gz
# Copiar a ubicación estándar para MinGW
cp -r SDL3-${{ env.SDL3_VERSION }}/x86_64-w64-mingw32/* /usr/x86_64-w64-mingw32/
apt-get update && apt-get install -y \
curl build-essential cmake git pkg-config wget zip \
mingw-w64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
- name: Checkout
uses: actions/checkout@v4
- name: Generar project.h
- name: Setup SDL3 (MinGW)
run: |
GIT_HASH=$(git rev-parse --short=7 HEAD)
RAW_VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//')
TARGET_NAME=$(awk '/^project/ {gsub(/[)(]/, " "); print $2}' CMakeLists.txt)
LONG_NAME=$(grep 'PROJECT_LONG_NAME' CMakeLists.txt | sed 's/.*"\(.*\)".*/\1/')
COPYRIGHT=$(sed -n 's/.*set(PROJECT_COPYRIGHT "\([^"]*\)".*/\1/p' CMakeLists.txt)
sed -e "s/@PROJECT_NAME@/$TARGET_NAME/g" \
-e "s/@PROJECT_LONG_NAME@/$LONG_NAME/g" \
-e "s/@PROJECT_VERSION@/$RAW_VERSION/g" \
-e "s/@PROJECT_COPYRIGHT@/$COPYRIGHT/g" \
-e "s/@GIT_HASH@/$GIT_HASH/g" \
source/project.h.in > source/project.h
git clone https://github.com/libsdl-org/SDL.git /tmp/SDL3 \
&& cd /tmp/SDL3 \
&& mkdir build-mingw && cd build-mingw \
&& cmake .. \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32 \
&& make -j$(nproc) \
&& make install \
&& rm -rf /tmp/SDL3
- name: Compilar pack_tool
run: |
g++ -std=c++20 -Wall -Os -Isource \
tools/pack_resources/pack_resources.cpp \
source/core/resources/resource_pack.cpp \
-o tools/pack_resources/pack_resources
- name: Generar resources.pack
run: ./tools/pack_resources/pack_resources data resources.pack
- name: Compilar para Windows (cross-compile)
run: |
TARGET_NAME=$(awk '/^project/ {gsub(/[)(]/, " "); print $2}' CMakeLists.txt)
LONG_NAME=$(grep 'PROJECT_LONG_NAME' CMakeLists.txt | sed 's/.*"\(.*\)".*/\1/')
CPP_FILES=$(find source -name "*.cpp")
x86_64-w64-mingw32-g++ $CPP_FILES \
-Isource -DRELEASE_BUILD -DWINDOWS_BUILD \
-std=c++20 -Wall -Os -ffunction-sections -fdata-sections \
-Wl,--gc-sections -static-libstdc++ -static-libgcc \
-Wl,-subsystem,windows \
-lmingw32 -lws2_32 -lSDL3 -lopengl32 \
-o "${LONG_NAME}.exe"
x86_64-w64-mingw32-strip -s -R .comment -R .gnu.version "${LONG_NAME}.exe" --strip-unneeded
- name: Empaquetar release
run: |
TARGET_NAME=$(awk '/^project/ {gsub(/[)(]/, " "); print $2}' CMakeLists.txt)
LONG_NAME=$(grep 'PROJECT_LONG_NAME' CMakeLists.txt | sed 's/.*"\(.*\)".*/\1/')
VERSION="${{ github.ref_name }}"
RELEASE_NAME="${TARGET_NAME}-${VERSION}-win32-x64.zip"
mkdir -p release_tmp
cp "${LONG_NAME}.exe" resources.pack LICENSE README.md gamecontrollerdb.txt release_tmp/
# Copiar SDL3.dll
cp /usr/x86_64-w64-mingw32/bin/SDL3.dll release_tmp/
cd release_tmp && zip -r ../$RELEASE_NAME . && cd ..
echo "RELEASE_FILE=$RELEASE_NAME" >> $GITHUB_ENV
- name: Compilar
run: make windows_cross SDL_DLL_PATH=/usr/x86_64-w64-mingw32/bin/SDL3.dll
- name: Subir artefacto
uses: actions/upload-artifact@v3
with:
name: windows-build
path: ${{ env.RELEASE_FILE }}
path: ./*-windows-x64.zip
# ============================================================================
# BUILD RASPBERRY PI ARM64 - DESACTIVADO TEMPORALMENTE
# Cross-compilation con OpenGL requiere libGL para ARM64 que no está disponible
# Se puede habilitar usando emulación ARM64 con QEMU en el futuro
# ============================================================================
# build-rpi:
# runs-on: ubuntu-latest
# ... (código comentado)
# ============================================================================
# CREAR RELEASE EN GITEA
# RELEASE
# ============================================================================
create-release:
needs: [build-linux, build-windows]
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
steps:
- name: Instalar dependencias
run: |
apt-get update -qq
apt-get install -y -qq nodejs npm git jq curl
- name: Checkout
uses: actions/checkout@v4
- name: Descargar todos los artefactos
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
path: artifacts
merge-multiple: true
- name: Listar artefactos
run: find artifacts -type f
- name: setup go
uses: https://github.com/actions/setup-go@v4
with:
go-version: '>=1.20.1'
- name: Crear Release en Gitea
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Crear release via API de Gitea
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${{ github.ref_name }}\", \"name\": \"${{ github.ref_name }}\", \"body\": \"Release ${{ github.ref_name }}\", \"draft\": false, \"prerelease\": false}" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
uses: https://gitea.com/actions/release-action@main
with:
files: artifacts/*
api_key: ${{ secrets.RELEASE_TOKEN }}
tag: ${{ github.ref_name }}
generate_release_notes: true
echo "Release response: $RELEASE_RESPONSE"
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
echo "Release ID: $RELEASE_ID"
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
echo "Error: No se pudo crear el release"
exit 1
fi
# Subir cada artefacto
for file in artifacts/**/*; do
if [ -f "$file" ]; then
filename=$(basename "$file")
echo "Subiendo: $filename"
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$file" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$filename"
fi
done
echo "Release creado: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}"

10
.gitignore vendored
View File

@@ -1,3 +1,4 @@
# Genericos
.vscode/
*.DS_Store
thumbs.db
@@ -11,16 +12,23 @@ desktop.ini
*.app
*_debug*
*.Identifier
pollo*
# Herramientas de build
build/
resources.pack
pollo_release/
tools/pack_resources/pack_resources
tools/pack_resources/pack_resources.exe
# Archivos generados
source/project.h
# CI/CD runner data (local)
docker/runner-data/
docker/config.yaml
# Claude Code local settings (mantener carpeta .claude/ para comandos)
.claude/settings.local.json
# Ejecutables
pollo

View File

@@ -1,7 +1,7 @@
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(pollo VERSION 0.1)
project(pollo VERSION 0.1.0)
# Info del proyecto para version.h
set(PROJECT_LONG_NAME "Los pollos hermanos")
@@ -36,7 +36,7 @@ else()
endif()
# Configurar archivo de versión
configure_file(${CMAKE_SOURCE_DIR}/source/project.h.in ${CMAKE_SOURCE_DIR}/source/project.h @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/source/project.h.in ${CMAKE_BINARY_DIR}/project.h @ONLY)
# --- 1. LISTA EXPLÍCITA DE FUENTES ---
set(APP_SOURCES

131
Makefile
View File

@@ -58,10 +58,10 @@ endif
# ==============================================================================
# RELEASE NAMES
# ==============================================================================
WINDOWS_RELEASE := $(TARGET_NAME)-$(VERSION)-win32-x64.zip
MACOS_INTEL_RELEASE := $(TARGET_NAME)-$(VERSION)-macos-intel.dmg
MACOS_APPLE_SILICON_RELEASE := $(TARGET_NAME)-$(VERSION)-macos-apple-silicon.dmg
LINUX_RELEASE := $(TARGET_NAME)-$(VERSION)-linux.tar.gz
WINDOWS_RELEASE := $(TARGET_NAME)-$(VERSION)-windows-x64.zip
MACOS_INTEL_RELEASE := $(TARGET_NAME)-$(VERSION)-macos-x64.dmg
MACOS_APPLE_SILICON_RELEASE := $(TARGET_NAME)-$(VERSION)-macos-arm64.dmg
LINUX_RELEASE := $(TARGET_NAME)-$(VERSION)-linux-x64.tar.gz
RPI_RELEASE := $(TARGET_NAME)-$(VERSION)-rpi-arm64.tar.gz
# ==============================================================================
@@ -118,7 +118,7 @@ ALL_SOURCES := $(APP_SOURCES)
# ==============================================================================
# INCLUDES
# ==============================================================================
INCLUDES := -Isource
INCLUDES := -Isource -Ibuild
# ==============================================================================
# COMPILER FLAGS (OS-specific)
@@ -196,7 +196,8 @@ windows_release:
# Generate project.h from project.h.in
@echo "Generando project.h..."
@powershell -Command "$$GIT_HASH = (git rev-parse --short=7 HEAD 2>$$null); if (-not $$GIT_HASH) { $$GIT_HASH = 'unknown' }; $$RAW_VERSION = '$(VERSION)' -replace '^v', ''; $$COPYRIGHT = (Select-String -Path 'CMakeLists.txt' -Pattern 'set\(PROJECT_COPYRIGHT \"(.+?)\"').Matches.Groups[1].Value; (Get-Content source/project.h.in) -replace '@PROJECT_NAME@', '$(TARGET_NAME)' -replace '@PROJECT_LONG_NAME@', '$(LONG_NAME)' -replace '@PROJECT_VERSION@', $$RAW_VERSION -replace '@PROJECT_COPYRIGHT@', $$COPYRIGHT -replace '@GIT_HASH@', $$GIT_HASH | Set-Content source/project.h"
@powershell if (-not (Test-Path "build")) {New-Item "build" -ItemType Directory}
@powershell -Command "$$GIT_HASH = (git rev-parse --short=7 HEAD 2>$$null); if (-not $$GIT_HASH) { $$GIT_HASH = 'unknown' }; $$RAW_VERSION = '$(VERSION)' -replace '^v', ''; $$COPYRIGHT = (Select-String -Path 'CMakeLists.txt' -Pattern 'set\(PROJECT_COPYRIGHT \"(.+?)\"').Matches.Groups[1].Value; (Get-Content source/project.h.in) -replace '@PROJECT_NAME@', '$(TARGET_NAME)' -replace '@PROJECT_LONG_NAME@', '$(LONG_NAME)' -replace '@PROJECT_VERSION@', $$RAW_VERSION -replace '@PROJECT_COPYRIGHT@', $$COPYRIGHT -replace '@GIT_HASH@', $$GIT_HASH | Set-Content build/project.h"
# Crea carpeta temporal 'RELEASE_FOLDER'
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
@@ -245,6 +246,7 @@ macos_release:
# Generate project.h from project.h.in
@echo "Generando project.h..."
@$(MKDIR) build
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
RAW_VERSION=$$(echo "$(VERSION)" | sed 's/^v//'); \
COPYRIGHT=$$(sed -n 's/.*set(PROJECT_COPYRIGHT "\([^"]*\)".*/\1/p' CMakeLists.txt); \
@@ -253,7 +255,7 @@ macos_release:
-e "s/@PROJECT_VERSION@/$$RAW_VERSION/g" \
-e "s/@PROJECT_COPYRIGHT@/$$COPYRIGHT/g" \
-e "s/@GIT_HASH@/$$GIT_HASH/g" \
source/project.h.in > source/project.h
source/project.h.in > build/project.h
# Elimina datos de compilaciones anteriores
$(RMDIR) "$(RELEASE_FOLDER)"
@@ -289,28 +291,28 @@ macos_release:
sed -i '' '/<key>CFBundleShortVersionString<\/key>/{n;s|<string>.*</string>|<string>'"$$RAW_VERSION"'</string>|;}' "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Info.plist"; \
sed -i '' '/<key>CFBundleVersion<\/key>/{n;s|<string>.*</string>|<string>'"$$RAW_VERSION"'</string>|;}' "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/Info.plist"
# Compila la versión para procesadores Intel
clang++ $(ALL_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD -std=$(CPP_STANDARD) -Wall -Os -framework SDL3 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos13.3 -mmacosx-version-min=13.3 -D_LIBCPP_DISABLE_AVAILABILITY
# Firma la aplicación
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
# Empaqueta el .dmg de la versión Intel con create-dmg
@echo "Creando DMG Intel con iconos de 96x96..."
create-dmg \
--volname "$(APP_NAME)" \
--window-pos 200 120 \
--window-size 720 300 \
--icon-size 96 \
--text-size 12 \
--icon "$(APP_NAME).app" 278 102 \
--icon "LICENSE" 441 102 \
--icon "README.md" 604 102 \
--app-drop-link 115 102 \
--hide-extension "$(APP_NAME).app" \
"$(MACOS_INTEL_RELEASE)" \
"$(RELEASE_FOLDER)" || true
@echo "Release Intel creado: $(MACOS_INTEL_RELEASE)"
## Compila la versión para procesadores Intel
# clang++ $(ALL_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD -std=$(CPP_STANDARD) -Wall -Os -framework SDL3 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos13.3 -mmacosx-version-min=13.3 -D_LIBCPP_DISABLE_AVAILABILITY
#
## Firma la aplicación
# codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
#
## Empaqueta el .dmg de la versión Intel con create-dmg
# @echo "Creando DMG Intel con iconos de 96x96..."
# create-dmg \
# --volname "$(APP_NAME)" \
# --window-pos 200 120 \
# --window-size 720 300 \
# --icon-size 96 \
# --text-size 12 \
# --icon "$(APP_NAME).app" 278 102 \
# --icon "LICENSE" 441 102 \
# --icon "README.md" 604 102 \
# --app-drop-link 115 102 \
# --hide-extension "$(APP_NAME).app" \
# "$(MACOS_INTEL_RELEASE)" \
# "$(RELEASE_FOLDER)" || true
# @echo "Release Intel creado: $(MACOS_INTEL_RELEASE)"
# Compila la versión para procesadores Apple Silicon
clang++ $(ALL_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD -std=$(CPP_STANDARD) -Wall -Os -framework SDL3 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos13.3 -mmacosx-version-min=13.3 -D_LIBCPP_DISABLE_AVAILABILITY
@@ -358,6 +360,7 @@ linux_release:
# Generate project.h from project.h.in
@echo "Generando project.h..."
@$(MKDIR) build
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
RAW_VERSION=$$(echo "$(VERSION)" | sed 's/^v//'); \
COPYRIGHT=$$(sed -n 's/.*set(PROJECT_COPYRIGHT "\([^"]*\)".*/\1/p' CMakeLists.txt); \
@@ -366,7 +369,7 @@ linux_release:
-e "s/@PROJECT_VERSION@/$$RAW_VERSION/g" \
-e "s/@PROJECT_COPYRIGHT@/$$COPYRIGHT/g" \
-e "s/@GIT_HASH@/$$GIT_HASH/g" \
source/project.h.in > source/project.h
source/project.h.in > build/project.h
# Elimina carpetas previas
$(RMDIR) "$(RELEASE_FOLDER)"
@@ -407,6 +410,7 @@ rpi_release:
# Generate project.h from project.h.in
@echo "Generando project.h..."
@$(MKDIR) build
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
RAW_VERSION=$$(echo "$(VERSION)" | sed 's/^v//'); \
COPYRIGHT=$$(sed -n 's/.*set(PROJECT_COPYRIGHT "\([^"]*\)".*/\1/p' CMakeLists.txt); \
@@ -415,7 +419,7 @@ rpi_release:
-e "s/@PROJECT_VERSION@/$$RAW_VERSION/g" \
-e "s/@PROJECT_COPYRIGHT@/$$COPYRIGHT/g" \
-e "s/@GIT_HASH@/$$GIT_HASH/g" \
source/project.h.in > source/project.h
source/project.h.in > build/project.h
# Elimina carpetas previas
$(RMDIR) "$(RELEASE_FOLDER)"
@@ -441,6 +445,70 @@ rpi_release:
# Elimina la carpeta temporal
$(RMDIR) "$(RELEASE_FOLDER)"
# ==============================================================================
# CROSS-COMPILATION (Linux -> Windows)
# ==============================================================================
CROSS_CXX := x86_64-w64-mingw32-g++
CROSS_STRIP := x86_64-w64-mingw32-strip
CROSS_WINDRES := x86_64-w64-mingw32-windres
CROSS_ZIP_FILE := $(TARGET_NAME)-$(VERSION)-win32-x64.zip
CROSS_CXXFLAGS := -std=$(CPP_STANDARD) -Wall -Os -ffunction-sections -fdata-sections \
-Wl,--gc-sections -static-libstdc++ -static-libgcc \
-Wl,-subsystem,windows -DWINDOWS_BUILD -DRELEASE_BUILD
CROSS_LDFLAGS := -lmingw32 -lws2_32 -lSDL3 -lopengl32
windows_cross:
@$(MAKE) pack_tool
@$(MAKE) resources.pack
@echo "Cross-compiling para Windows desde Linux..."
# 1. Generar project.h
@GIT_HASH=$$(git rev-parse --short=7 HEAD 2>/dev/null || echo "unknown"); \
RAW_VERSION=$$(echo "$(VERSION)" | sed 's/^v//'); \
COPYRIGHT=$$(sed -n 's/.*set(PROJECT_COPYRIGHT "\([^"]*\)".*/\1/p' CMakeLists.txt); \
sed -e "s/@PROJECT_NAME@/$(TARGET_NAME)/g" \
-e "s/@PROJECT_LONG_NAME@/$(LONG_NAME)/g" \
-e "s/@PROJECT_VERSION@/$$RAW_VERSION/g" \
-e "s/@PROJECT_COPYRIGHT@/$$COPYRIGHT/g" \
-e "s/@GIT_HASH@/$$GIT_HASH/g" \
source/project.h.in > source/project.h
# 2. Preparar carpetas
$(RMDIR) "$(RELEASE_FOLDER)"
$(MKDIR) "$(RELEASE_FOLDER)"
# 3. Copiar recursos base
cp resources.pack "$(RELEASE_FOLDER)"
cp LICENSE "$(RELEASE_FOLDER)"
cp README.md "$(RELEASE_FOLDER)"
cp gamecontrollerdb.txt "$(RELEASE_FOLDER)"
# 4. GESTIÓN DE DLLs (Aquí está la mejora)
# [cite_start]Copia las DLLs locales si existen (como en tu windows_release) [cite: 16]
@if [ -d "release/dll" ] && [ "$$(ls -A release/dll/*.dll 2>/dev/null)" ]; then \
cp release/dll/*.dll "$(RELEASE_FOLDER)"; \
echo "Copiadas DLLs locales desde release/dll/"; \
fi
# Copia la DLL de SDL3 externa si se pasa como argumento (Para el CI)
@if [ -n "$(SDL_DLL_PATH)" ]; then \
cp "$(SDL_DLL_PATH)" "$(RELEASE_FOLDER)"; \
echo "Copiada SDL3 DLL desde $(SDL_DLL_PATH)"; \
fi
# 5. Compilar
@echo "Compilando recursos e icono..."
$(CROSS_WINDRES) release/$(TARGET_NAME).rc -O coff -o $(RESOURCE_FILE)
@echo "Compilando ejecutable..."
$(CROSS_CXX) $(ALL_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CROSS_CXXFLAGS) $(CROSS_LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).exe"
$(CROSS_STRIP) -s "$(RELEASE_FOLDER)/$(APP_NAME).exe"
# 6. Empaquetar
@echo "Empaquetando en $(CROSS_ZIP_FILE)..."
cd $(RELEASE_FOLDER) && zip -r ../$(CROSS_ZIP_FILE) .
$(RMDIR) "$(RELEASE_FOLDER)"
@echo "✓ Release de Windows (Cross) completado: $(CROSS_ZIP_FILE)"
# ==============================================================================
# SETUP
# ==============================================================================
@@ -463,6 +531,7 @@ help:
@echo " windows - Compilar para Windows"
@echo " windows_debug - Compilar debug para Windows"
@echo " windows_release - Crear release completo para Windows"
@echo " windows_cross - Crear release completo para Windows desde entorno Linux"
@echo " linux - Compilar para Linux"
@echo " linux_debug - Compilar debug para Linux"
@echo " linux_release - Crear release completo para Linux"

2
release/pollo.rc Normal file
View File

@@ -0,0 +1,2 @@
// pollo.rc
IDI_ICON1 ICON "icon.ico"

BIN
release/pollo.res Normal file

Binary file not shown.

View File

@@ -16,7 +16,9 @@
#include "core/rendering/gif.hpp" // Para Gif
#include "core/rendering/screen.hpp" // Para Screen
#include "core/resources/resource_list.hpp" // Para Resource::List::get()->getPrintWidth
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "utils/utils.hpp" // Para printWithDots
// Carga una paleta desde un archivo .gif
auto loadPalette(const std::string& file_path) -> Palette {
@@ -37,7 +39,7 @@ auto loadPalette(const std::string& file_path) -> Palette {
std::copy_n(pal.begin(), std::min(pal.size(), palette.size()), palette.begin());
// Mensaje de depuración
printWithDots("Palette : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
printWithDots("Palette : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]", Resource::List::get()->getPrintWidth());
return palette;
}
@@ -86,7 +88,7 @@ auto readPalFile(const std::string& file_path) -> Palette {
}
}
printWithDots("Palette : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
printWithDots("Palette : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]", Resource::List::get()->getPrintWidth());
return palette;
}
@@ -128,7 +130,7 @@ auto Surface::loadSurface(const std::string& file_path) -> SurfaceData {
std::memcpy(pixels.get(), raw_pixels.data(), pixel_count);
// Crear y devolver directamente el objeto SurfaceData
printWithDots("Surface : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
printWithDots("Surface : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]", Resource::List::get()->getPrintWidth());
return {static_cast<float>(w), static_cast<float>(h), pixels};
}

View File

@@ -8,7 +8,8 @@
#include <utility>
#include "core/rendering/surface.hpp" // Para Surface
#include "core/resources/resource_cache.hpp" // Para Resource
#include "core/resources/resource_cache.hpp" // Para Resource::Cache
#include "core/resources/resource_list.hpp" // Para Resource::List::get()->getPrintWidth
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "external/fkyaml_node.hpp" // Para fkyaml::node
#include "utils/utils.hpp" // Para printWithDots
@@ -46,7 +47,7 @@ auto SurfaceAnimatedSprite::loadAnimationsFromYAML(const std::string& file_path,
throw std::runtime_error("Animation file not found: " + file_path);
}
printWithDots("Animation : ", FILE_NAME, "[ LOADED ]");
printWithDots("Animation : ", FILE_NAME, "[ LOADED ]", Resource::List::get()->getPrintWidth());
// Parse YAML from string
std::string yaml_content(file_data.begin(), file_data.end());

View File

@@ -11,6 +11,7 @@
#include "core/rendering/screen.hpp" // Para Screen
#include "core/rendering/surface.hpp" // Para Surface
#include "core/rendering/surface_sprite.hpp" // Para SSprite
#include "core/resources/resource_list.hpp" // Para Resource::List::get()->getPrintWidth
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "utils/utils.hpp" // Para getFileName, stringToColor, printWithDots
@@ -75,7 +76,7 @@ auto Text::loadTextFile(const std::string& file_path) -> std::shared_ptr<File> {
line_read++;
};
printWithDots("Text File : ", getFileName(file_path), "[ LOADED ]");
printWithDots("Text File : ", getFileName(file_path), "[ LOADED ]", Resource::List::get()->getPrintWidth());
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho
for (int i = 32; i < 128; ++i) {

View File

@@ -9,7 +9,8 @@
#include <utility>
#include <vector> // Para vector
#include "utils/utils.hpp" // Para getFileName, ColorRGB, printWithDots
#include "core/resources/resource_list.hpp" // Para Resource::List::get()->getPrintWidth
#include "utils/utils.hpp" // Para getFileName, ColorRGB, printWithDots
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // para stbi_failure_reason, stbi_image_free
@@ -51,7 +52,7 @@ auto Texture::loadFromFile(const std::string& file_path) -> bool {
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << '\n';
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
}
printWithDots("Image : ", getFileName(file_path), "[ LOADED ]");
printWithDots("Image : ", getFileName(file_path), "[ LOADED ]", Resource::List::get()->getPrintWidth());
int pitch;
SDL_PixelFormat pixel_format;

View File

@@ -212,7 +212,7 @@ void Cache::loadSounds() {
}
sounds_.emplace_back(SoundResource{.name = name, .sound = sound});
printWithDots("Sound : ", name, "[ LOADED ]");
printWithDots("Sound : ", name, "[ LOADED ]", List::get()->getPrintWidth());
updateLoadingProgress();
} catch (const std::exception& e) {
throwLoadError("SOUND", l, e);
@@ -247,7 +247,7 @@ void Cache::loadMusics() {
}
musics_.emplace_back(MusicResource{.name = name, .music = music});
printWithDots("Music : ", name, "[ LOADED ]");
printWithDots("Music : ", name, "[ LOADED ]", List::get()->getPrintWidth());
updateLoadingProgress(1);
} catch (const std::exception& e) {
throwLoadError("MUSIC", l, e);
@@ -325,7 +325,7 @@ void Cache::loadAnimations() {
}
animations_.emplace_back(AnimationResource{.name = name, .yaml_data = yaml_bytes});
printWithDots("Animation : ", name, "[ LOADED ]");
printWithDots("Animation : ", name, "[ LOADED ]", List::get()->getPrintWidth());
updateLoadingProgress();
} catch (const std::exception& e) {
throwLoadError("ANIMATION", l, e);
@@ -343,7 +343,7 @@ void Cache::loadRooms() {
try {
auto name = getFileName(l);
rooms_.emplace_back(RoomResource{.name = name, .room = std::make_shared<Room::Data>(Room::loadYAML(l))});
printWithDots("Room : ", name, "[ LOADED ]");
printWithDots("Room : ", name, "[ LOADED ]", List::get()->getPrintWidth());
updateLoadingProgress();
} catch (const std::exception& e) {
throwLoadError("ROOM", l, e);
@@ -369,7 +369,7 @@ void Cache::createText() {
for (const auto& res_info : resources) {
texts_.emplace_back(TextResource{.name = res_info.key, .text = std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file))});
printWithDots("Text : ", res_info.key, "[ DONE ]");
printWithDots("Text : ", res_info.key, "[ DONE ]", List::get()->getPrintWidth());
}
}

View File

@@ -144,6 +144,9 @@ void List::loadFromString(const std::string& config_content, const std::string&
std::cout << "Loaded " << file_list_.size() << " assets from YAML config" << '\n';
// Calcular el ancho para printWithDots basándose en los nombres de archivo
calculatePrintWidth();
} catch (const fkyaml::exception& e) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"YAML parsing error: %s",
@@ -317,4 +320,21 @@ auto List::parseOptions(const std::string& options, bool& required, bool& absolu
}
}
// Calcula el ancho para printWithDots basándose en el nombre de archivo más largo
void List::calculatePrintWidth() {
size_t max_filename_length = 0;
for (const auto& [filename, item] : file_list_) {
if (filename.length() > max_filename_length) {
max_filename_length = filename.length();
}
}
// Ancho total = prefijo más largo (12: "Animation : ") + nombre + 2 puntos mínimos + sufijo (10: "[ LOADED ]")
constexpr size_t MAX_PREFIX_LENGTH = 12; // "Animation : " o "Text File : "
constexpr size_t SUFFIX_LENGTH = 10; // "[ LOADED ]"
constexpr size_t MIN_DOTS = 2; // Mínimo de puntos
print_width_ = MAX_PREFIX_LENGTH + max_filename_length + MIN_DOTS + SUFFIX_LENGTH;
}
} // namespace Resource

View File

@@ -39,6 +39,7 @@ class List {
[[nodiscard]] auto loadData(const std::string& filename) const -> std::vector<uint8_t>; // Carga datos del archivo
[[nodiscard]] auto getListByType(Type type) const -> std::vector<std::string>;
[[nodiscard]] auto exists(const std::string& filename) const -> bool; // Verifica si un asset existe
[[nodiscard]] auto getPrintWidth() const -> size_t { return print_width_; } // Ancho para printWithDots
private:
// --- Estructuras privadas ---
@@ -56,6 +57,7 @@ class List {
// --- Variables internas ---
std::unordered_map<std::string, Item> file_list_; // Mapa para búsqueda O(1)
std::string executable_path_; // Ruta del ejecutable
size_t print_width_{50}; // Ancho para printWithDots (calculado dinámicamente)
// --- Métodos internos ---
[[nodiscard]] static auto getTypeName(Type type) -> std::string; // Obtiene el nombre del tipo
@@ -63,6 +65,7 @@ class List {
void addToMap(const std::string& file_path, Type type, bool required, bool absolute); // Añade archivo al mapa
[[nodiscard]] static auto replaceVariables(const std::string& path, const std::string& prefix, const std::string& system_folder) -> std::string; // Reemplaza variables en la ruta
static auto parseOptions(const std::string& options, bool& required, bool& absolute) -> void; // Parsea opciones
void calculatePrintWidth(); // Calcula el ancho para printWithDots
// --- Constructores y destructor privados (singleton) ---
explicit List(std::string executable_path) // Constructor privado

View File

@@ -1,5 +1,5 @@
// resource_pack.cpp
// Resource pack implementation for JailDoctor's Dilemma
// Resource pack implementation for Los Pollos Hermanos
#include "resource_pack.hpp"

View File

@@ -1,5 +1,5 @@
// resource_pack.hpp
// Resource pack file format and management for JailDoctor's Dilemma
// Resource pack file format and management for Los Pollos Hermanos
#pragma once
@@ -20,7 +20,7 @@ struct ResourceEntry {
};
// Resource pack file format
// Header: "JDDI" (4 bytes) + Version (4 bytes)
// Header: "POLL" (4 bytes) + Version (4 bytes)
// Metadata: Count + array of ResourceEntry
// Data: Encrypted data block
class Pack {
@@ -49,9 +49,9 @@ class Pack {
auto calculatePackChecksum() const -> uint32_t; // Validation
private:
static constexpr std::array<char, 4> MAGIC_HEADER = {'J', 'D', 'D', 'I'}; // Pack format constants
static constexpr std::array<char, 4> MAGIC_HEADER = {'P', 'O', 'L', 'L'}; // Pack format constants
static constexpr uint32_t VERSION = 1;
static constexpr const char* DEFAULT_ENCRYPT_KEY = "JDDI_RESOURCES_2024";
static constexpr const char* DEFAULT_ENCRYPT_KEY = "POLL_RESOURCES_2025";
static auto calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t; // Utility methods

View File

@@ -550,7 +550,7 @@ auto saveToFile() -> bool {
}
// Escribe el fichero manualmente para controlar el orden y los comentarios
file << "# JailDoctor's Dilemma - Configuration File\n";
file << "# Los Pollos Hermanos - Configuration File\n";
file << "# \n";
file << "# This file is automatically generated and managed by the game.\n";
file << "# Manual edits are preserved if valid.\n";

View File

@@ -1,9 +0,0 @@
#pragma once
namespace Project {
constexpr const char* NAME = "pollo";
constexpr const char* LONG_NAME = "Los pollos hermanos";
constexpr const char* VERSION = "0.1";
constexpr const char* COPYRIGHT = "@2025 JailDesigner";
constexpr const char* GIT_HASH = "ea30c24";
} // namespace Project

View File

@@ -320,11 +320,11 @@ auto getPath(const std::string& full_path) -> std::string {
}
// Imprime por pantalla una linea de texto de tamaño fijo rellena con puntos
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3) {
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3, size_t width) {
std::cout.setf(std::ios::left, std::ios::adjustfield);
std::cout << text1;
std::cout.width(50 - text1.length() - text3.length());
std::cout.width(static_cast<std::streamsize>(width - text1.length() - text3.length()));
std::cout.fill('.');
std::cout << text2;

View File

@@ -78,4 +78,4 @@ auto getPath(const std::string& full_path) -> std::string; // Extrae directorio
void fillTextureWithColor(SDL_Renderer* renderer, SDL_Texture* texture, Uint8 r, Uint8 g, Uint8 b, Uint8 a); // Rellena textura
// OUTPUT Y UTILIDADES DE CONSOLA
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3); // Imprime línea con puntos
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3, size_t width); // Imprime línea con puntos