Finish add all options

Update readme with news info
This commit is contained in:
JackCarterSmith 2019-07-21 17:40:18 +02:00
parent f70f4a698b
commit a2a03f96b6
5 changed files with 32 additions and 18 deletions

View File

@ -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] <hmt files...>`
### Options
- -h Print this message
- -v Activate verbose output
- -no-subdir Extract textures directly inside current folder
### Dependencies

View File

@ -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;

View File

@ -1,7 +1,7 @@
#ifndef IMAGE_EXPORTER_H_
#define IMAGE_EXPORTER_H_
//#include "options.h"
#include "options.h"
#include "RS_images.h"
#include <zlib.h>
#include <png.h>

View File

@ -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 <texture_hmt_file>\n"); //TODO: add help function
printf("\nNo input file/commands specified!\n\nCorrect syntax is:\n$> Texture-Extractor <texture_hmt_file>\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; i<hmt_f->texture_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] <hmt files...>\n");
printf("\n");

View File

@ -2,7 +2,7 @@
#define OPTIONS_H_
#define VERBOSE_ENABLED 0x0001
#define NO_OUTPUT_DIR 0x0002
#define OUTPUT_DIR 0x0002
int _options;