Fix: Carga de recursos en macOS Bundle + limpieza Makefile

- Arreglar getExecutableDirectory() para usar _NSGetExecutablePath en macOS
- Añadir getResourcesDirectory() con soporte MACOS_BUNDLE
- Actualizar main.cpp y engine.cpp para buscar recursos correctamente
- Eliminar referencias obsoletas a directorio 'config' en Makefile

Ahora resources.pack se busca en ../Resources/ cuando MACOS_BUNDLE está
definido, permitiendo que la app bundle funcione correctamente.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-05 10:17:46 +02:00
parent f41fbb6e6b
commit a7c9304214
4 changed files with 30 additions and 9 deletions

View File

@@ -231,6 +231,9 @@ constexpr float PI = 3.14159265358979323846f; // Constante PI
#include <filesystem>
#ifdef _WIN32
#include <windows.h>
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
#include <limits.h>
#else
#include <unistd.h>
#include <limits.h>
@@ -242,7 +245,16 @@ inline std::string getExecutableDirectory() {
GetModuleFileNameA(NULL, buffer, MAX_PATH);
std::filesystem::path exe_path(buffer);
return exe_path.parent_path().string();
#elif defined(__APPLE__)
char buffer[PATH_MAX];
uint32_t size = sizeof(buffer);
if (_NSGetExecutablePath(buffer, &size) == 0) {
std::filesystem::path exe_path(buffer);
return exe_path.parent_path().string();
}
return ".";
#else
// Linux y otros Unix
char buffer[PATH_MAX];
ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
if (len != -1) {
@@ -252,4 +264,18 @@ inline std::string getExecutableDirectory() {
}
return ".";
#endif
}
// Función auxiliar para obtener la ruta del directorio de recursos
inline std::string getResourcesDirectory() {
std::string exe_dir = getExecutableDirectory();
#ifdef MACOS_BUNDLE
// En macOS Bundle: ejecutable está en Contents/MacOS/, recursos en Contents/Resources/
std::filesystem::path resources_path = std::filesystem::path(exe_dir) / ".." / "Resources";
return resources_path.string();
#else
// En desarrollo o releases normales: recursos están junto al ejecutable
return exe_dir;
#endif
}