actualitzada la carpeta release a SDL3

migrat a resources.pack
This commit is contained in:
2025-10-31 22:58:37 +01:00
parent 70bfced50d
commit 8c6bea897c
513 changed files with 377587 additions and 29821 deletions

View File

@@ -0,0 +1,53 @@
# Makefile for pack_resources tool
# Compiler
CXX := g++
CXXFLAGS := -std=c++20 -Wall -Wextra -O2
# Directories
TOOL_DIR := .
SOURCE_DIR := ../../source/core/resources
# Source files
SOURCES := pack_resources.cpp \
$(SOURCE_DIR)/resource_pack.cpp
# Output
TARGET := pack_resources
# Platform-specific executable extension
ifeq ($(OS),Windows_NT)
TARGET := $(TARGET).exe
endif
# Default target
all: $(TARGET)
# Build the tool
$(TARGET): $(SOURCES)
@echo "Building pack_resources tool..."
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(TARGET)
@echo "Build complete: $(TARGET)"
# Test: create a test pack
test: $(TARGET)
@echo "Creating test pack..."
./$(TARGET) ../../data test_resources.pack
# Create the actual resources.pack
pack: $(TARGET)
@echo "Creating resources.pack..."
./$(TARGET) ../../data ../../resources.pack
# List contents of a pack
list: $(TARGET)
@echo "Listing pack contents..."
./$(TARGET) --list ../../resources.pack
# Clean
clean:
@echo "Cleaning..."
rm -f $(TARGET) test_resources.pack
@echo "Clean complete"
.PHONY: all test pack list clean

Binary file not shown.

View File

@@ -0,0 +1,130 @@
// pack_resources.cpp
// Tool to pack game resources into a single encrypted file
#include <iostream>
#include <string>
#include <vector>
// Include the ResourcePack class
#include "../../source/core/resources/resource_pack.hpp"
void printUsage(const char* program_name) {
std::cout << "Usage:\n";
std::cout << " " << program_name << " [input_dir] [output_file]\n";
std::cout << " " << program_name << " --list <pack_file>\n";
std::cout << "\n";
std::cout << "Examples:\n";
std::cout << " " << program_name << " data resources.pack\n";
std::cout << " " << program_name << " --list resources.pack\n";
std::cout << "\n";
std::cout << "Options:\n";
std::cout << " --list List contents of a pack file\n";
}
int main(int argc, char* argv[]) {
std::cout << "JailDoctor's Dilemma - Resource Packer\n";
std::cout << "======================================\n\n";
// Parse command line arguments
if (argc == 1) {
// Default behavior: pack data/ into resources.pack
std::string input_dir = "data";
std::string output_file = "resources.pack";
std::cout << "Using defaults:\n";
std::cout << " Input: " << input_dir << "/\n";
std::cout << " Output: " << output_file << "\n\n";
jdd::ResourcePack pack;
if (!pack.addDirectory(input_dir)) {
std::cerr << "Error: Failed to add directory: " << input_dir << '\n';
return 1;
}
// Add config/assets.txt to pack (required for release builds)
std::cout << "\nAdding config files...\n";
if (!pack.addFile("config/assets.txt", "config/assets.txt")) {
std::cerr << "Warning: Failed to add config/assets.txt (optional)\n";
}
if (!pack.savePack(output_file)) {
std::cerr << "Error: Failed to save pack file: " << output_file << '\n';
return 1;
}
std::cout << "\nSuccess! Pack created: " << output_file << '\n';
return 0;
}
if (argc == 2) {
std::string arg = argv[1];
if (arg == "--help" || arg == "-h") {
printUsage(argv[0]);
return 0;
}
}
if (argc == 3) {
std::string arg1 = argv[1];
std::string arg2 = argv[2];
// List contents
if (arg1 == "--list" || arg1 == "-l") {
std::cout << "Loading pack: " << arg2 << "\n\n";
jdd::ResourcePack pack;
if (!pack.loadPack(arg2)) {
std::cerr << "Error: Failed to load pack file: " << arg2 << '\n';
return 1;
}
std::cout << "\nPack Contents:\n";
std::cout << "==============\n";
auto resources = pack.getResourceList();
size_t total_size = 0;
for (const auto& resource : resources) {
auto data = pack.getResource(resource);
total_size += data.size();
std::cout << " " << resource << " (" << data.size() << " bytes)\n";
}
std::cout << "\nTotal Resources: " << resources.size() << '\n';
std::cout << "Total Size: " << total_size << " bytes\n";
return 0;
}
// Pack directory
std::string input_dir = arg1;
std::string output_file = arg2;
std::cout << "Input: " << input_dir << "/\n";
std::cout << "Output: " << output_file << "\n\n";
jdd::ResourcePack pack;
if (!pack.addDirectory(input_dir)) {
std::cerr << "Error: Failed to add directory: " << input_dir << '\n';
return 1;
}
// Add config/assets.txt to pack (required for release builds)
std::cout << "\nAdding config files...\n";
if (!pack.addFile("config/assets.txt", "config/assets.txt")) {
std::cerr << "Warning: Failed to add config/assets.txt (optional)\n";
}
if (!pack.savePack(output_file)) {
std::cerr << "Error: Failed to save pack file: " << output_file << '\n';
return 1;
}
std::cout << "\nSuccess! Pack created: " << output_file << '\n';
return 0;
}
// Invalid arguments
std::cerr << "Error: Invalid arguments\n\n";
printUsage(argv[0]);
return 1;
}