diff --git a/README.md b/README.md index 9c24a29..924aab6 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ Inspired by the work **dpethes** (https://github.com/dpethes/rerogue) This set of git repos are a compilation of tools coded in C to make RS modding far more than a dream! The collection consist of few independants modules, each of them deals with specific data like sound, textures, heightmaps, etc... - - All modules are independants. This is the **'TEXTURE'** module. **CAUTION! Master branch is hugely buggy and should not be used, please take only released versions.** @@ -15,9 +13,21 @@ All modules are independants. This is the **'TEXTURE'** module. It's extract texture datas from Rogue Squadron 3D (PC) game files (DAT). +This module can do: +- Extract textures inside HMT files to PNG format, +- Extract automatically inside subfolder (usefull when you have a lot of pictures to extract), +- Manage transparent textures, +- Fixed some error RGB color encoding. + ### Using -*TODO...* +`Texture-Extractor_"version" [options] ` + +### Options + +- -h Print this message +- -v Activate verbose output +- -no-subdir Extract textures directly inside current folder ### Dependencies diff --git a/src/Image_Exporter.c b/src/Image_Exporter.c index c7e7774..1642e10 100644 --- a/src/Image_Exporter.c +++ b/src/Image_Exporter.c @@ -1,7 +1,7 @@ #include "Image_Exporter.h" -//extern int _options; // Global options settings variable +extern int _options; // Global options settings variable int saveToPNG(RS_IMAGE *img, char *tex_path, char *hmt_fileName) { if (tex_path == NULL || img == NULL) return EXIT_FAILURE; @@ -15,13 +15,17 @@ int saveToPNG(RS_IMAGE *img, char *tex_path, char *hmt_fileName) { //int pixel_size = 3; //int depth = 8; //bit par color channel (RGB) - strcpy(export_path, hmt_fileName); - #ifdef _WIN32 - strcat(export_path, "-out\\"); - #else - strcat(export_path, "-out/"); - #endif - strcat(export_path, tex_path); + if (_options & OUTPUT_DIR) { + strcpy(export_path, hmt_fileName); + #ifdef _WIN32 + strcat(export_path, "-out\\"); + #else + strcat(export_path, "-out/"); + #endif + strcat(export_path, tex_path); + } else { + strcpy(export_path, tex_path); + } strcat(export_path, ".png"); _png_f = fopen(export_path, "wb"); if (_png_f == NULL) return EXIT_FAILURE; diff --git a/src/Image_Exporter.h b/src/Image_Exporter.h index d4a61e2..d552081 100644 --- a/src/Image_Exporter.h +++ b/src/Image_Exporter.h @@ -1,7 +1,7 @@ #ifndef IMAGE_EXPORTER_H_ #define IMAGE_EXPORTER_H_ -//#include "options.h" +#include "options.h" #include "RS_images.h" #include #include diff --git a/src/Texture-Extractor.c b/src/Texture-Extractor.c index 51a3c53..0e6ae8c 100644 --- a/src/Texture-Extractor.c +++ b/src/Texture-Extractor.c @@ -20,7 +20,7 @@ int main(int argc, char *argv[]) { // Check if filenames arguments exist if (argc < 2) { - printf("\nNo input file/commands specified!\n\nCorrect syntax is:\n$> Texture-Extractor \n"); //TODO: add help function + printf("\nNo input file/commands specified!\n\nCorrect syntax is:\n$> Texture-Extractor \n"); return EXCEPTION_NONCONTINUABLE; //TODO: implement own error codes system } _options = checkArgs(argv, argc); // Analyse program arguments @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { } int checkArgs(char *args[], int arg_nbr) { - int _o = 0x0000; + int _o = 0x0002; // Default options parameters char test[256]; int i; @@ -53,7 +53,7 @@ int checkArgs(char *args[], int arg_nbr) { _o |= VERBOSE_ENABLED; printf("[INFO] Verbose enabled.\n"); } else if (strcmp(args[i], "-no-subdir") == 0) { - _o |= NO_OUTPUT_DIR; + _o &= ~OUTPUT_DIR; printf("[INFO] Extract to current directory.\n"); } else { printf("[INFO] Unknown option: %s\n", args[i]); @@ -99,7 +99,7 @@ int exportTextures(HMT_FILE *hmt_f, char *filename) { int i; if(hmt_f->texture_count > 0) { - createSubDir(filename); + if (_options & OUTPUT_DIR) createSubDir(filename); for (i=0; itexture_count; i++) { switch (hmt_f->textures_list[i].image.type_) { case 0: @@ -123,7 +123,7 @@ void dispHelp() { printf("\n"); printf("RogueSquadron Data Extractor - TEXTURE module\n"); printf("\n"); - printf("Options:\n -h Print this message\n -v Activate verbose output\n -no-subdir Extract textures directly inside current folder\n"); + printf("Options:\n -h Print this message\n -v Activate verbose console output\n -no-subdir Extract textures inside current folder\n"); printf("\n"); printf("Usage: Texture-Extractor_\"version\" [options] \n"); printf("\n"); diff --git a/src/options.h b/src/options.h index 42635ba..4fc44b8 100644 --- a/src/options.h +++ b/src/options.h @@ -2,7 +2,7 @@ #define OPTIONS_H_ #define VERBOSE_ENABLED 0x0001 -#define NO_OUTPUT_DIR 0x0002 +#define OUTPUT_DIR 0x0002 int _options;