Implementar sistema de release Windows completo + carga dinámica de recursos

SISTEMA DE RELEASE (Makefile):
- Adaptado windows_release de Coffee Crisis a ViBe3 Physics
- Comandos Unix-style (rm/cp/mkdir) compatibles con Git Bash/MSYS2
- Compresión ZIP via PowerShell Compress-Archive
- LICENSE opcional (si no existe, continúa)
- Genera: vibe3_physics-YYYY-MM-DD-win32-x64.zip

CARGA DINÁMICA DE RECURSOS:
- Añadido Texture::getPackResourceList() - Lista recursos del pack
- Añadido Texture::isPackLoaded() - Verifica si pack está cargado
- engine.cpp: Descubrimiento dinámico de texturas desde pack
- Sin listas hardcodeadas - Usa ResourcePack::getResourceList()
- Filtra recursos por patrón "balls/*.png" automáticamente

ARQUITECTURA:
- Descubrimiento de texturas híbrido:
  1. Si existe data/balls/ → escanear disco
  2. Si no existe + pack cargado → listar desde pack
  3. Ordenar por tamaño (automático)

TESTING CONFIRMADO:
-  Release con resources.pack funciona sin data/
-  Carga 4 texturas desde pack dinámicamente
-  make windows_release genera ZIP válido
-  Ejecutable arranca correctamente desde release/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-05 09:50:19 +02:00
parent f5d6c993d3
commit 597f26461a
5 changed files with 511 additions and 19 deletions

View File

@@ -131,17 +131,17 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
std::string exe_dir = getExecutableDirectory();
std::string balls_dir = exe_dir + "/data/balls";
struct TextureInfo {
std::string name;
std::shared_ptr<Texture> texture;
int width;
};
std::vector<TextureInfo> texture_files;
// Buscar todas las texturas PNG en data/balls/
namespace fs = std::filesystem;
if (fs::exists(balls_dir) && fs::is_directory(balls_dir)) {
struct TextureInfo {
std::string name;
std::shared_ptr<Texture> texture;
int width;
};
std::vector<TextureInfo> texture_files;
// Cargar todas las texturas (solo una vez)
// Cargar todas las texturas desde disco
for (const auto& entry : fs::directory_iterator(balls_dir)) {
if (entry.is_regular_file() && entry.path().extension() == ".png") {
std::string filename = entry.path().stem().string();
@@ -154,23 +154,41 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
texture_files.push_back({filename, texture, width});
}
}
} else {
// Fallback: cargar texturas desde pack usando la lista del ResourcePack
if (Texture::isPackLoaded()) {
auto pack_resources = Texture::getPackResourceList();
// Ordenar por tamaño (grande → pequeño): big(16) → normal(10) → small(6) → tiny(4)
std::sort(texture_files.begin(), texture_files.end(),
[](const TextureInfo& a, const TextureInfo& b) {
return a.width > b.width; // Descendente por tamaño
});
// Filtrar solo los recursos en balls/ con extensión .png
for (const auto& resource : pack_resources) {
if (resource.substr(0, 6) == "balls/" && resource.substr(resource.size() - 4) == ".png") {
std::string tex_name = resource.substr(6); // Quitar "balls/"
std::string name = tex_name.substr(0, tex_name.find('.')); // Quitar extensión
// Guardar texturas ya cargadas en orden (0=big, 1=normal, 2=small, 3=tiny)
for (const auto& info : texture_files) {
textures_.push_back(info.texture);
texture_names_.push_back(info.name);
auto texture = std::make_shared<Texture>(renderer_, resource);
int width = texture->getWidth();
texture_files.push_back({name, texture, width});
}
}
}
}
// Fallback si no hay texturas (no debería pasar)
// Ordenar por tamaño (grande → pequeño): big(16) → normal(10) → small(6) → tiny(4)
std::sort(texture_files.begin(), texture_files.end(),
[](const TextureInfo& a, const TextureInfo& b) {
return a.width > b.width; // Descendente por tamaño
});
// Guardar texturas ya cargadas en orden (0=big, 1=normal, 2=small, 3=tiny)
for (const auto& info : texture_files) {
textures_.push_back(info.texture);
texture_names_.push_back(info.name);
}
// Verificar que se cargaron texturas
if (textures_.empty()) {
std::cerr << "ERROR: No se encontraron texturas en data/balls/" << std::endl;
std::cerr << "ERROR: No se pudieron cargar texturas" << std::endl;
success = false;
}