1
0
mirror of https://github.com/ScrelliCopter/tmx2gba.git synced 2025-02-21 03:29:25 +11:00

2 Commits

7 changed files with 29 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR) cmake_minimum_required(VERSION "3.5" FATAL_ERROR)
project(tmx2gba) project(tmx2gba VERSION "0.3")
# Options # Options
option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF) option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF)

View File

@@ -20,6 +20,7 @@ tmx2gba [-h] [-r offset] [-lyc name] [-p 0-15] <-i inpath> <-o outpath>
| Command | Required | Notes | | Command | Required | Notes |
|--------------|----------|-----------------------------------------------------------------------| |--------------|----------|-----------------------------------------------------------------------|
| -h | N/A | Display help & command info. | | -h | N/A | Display help & command info. |
| -v | No | Display version & quit. |
| -l (name) | No | Name of layer to use (default first layer in TMX). | | -l (name) | No | Name of layer to use (default first layer in TMX). |
| -y (name) | No | Layer for palette mappings. | | -y (name) | No | Layer for palette mappings. |
| -c (name) | No | Output a separate 8bit collision map of the specified layer. | | -c (name) | No | Output a separate 8bit collision map of the specified layer. |

View File

@@ -15,8 +15,10 @@
const std::string helpUsage = "Usage: tmx2gba [-h] [-f file] [-r offset] [-lyc name] [-p 0-15] [-m name;id] <-i inpath> <-o outpath>"; const std::string helpUsage = "Usage: tmx2gba [-h] [-f file] [-r offset] [-lyc name] [-p 0-15] [-m name;id] <-i inpath> <-o outpath>";
const std::string helpShort = "Run 'tmx2gba -h' to view all available options."; const std::string helpShort = "Run 'tmx2gba -h' to view all available options.";
const std::string versionStr = "tmx2gba version 0.3, (c) 2015-2022 a dinosaur";
const std::string helpFull = R"( const std::string helpFull = R"(
-h ------------ Display this help & command info. -h ------------ Display this help & command info.
-v ------------ Display version & quit.
-l <name> ----- Name of layer to use (default first layer in TMX). -l <name> ----- Name of layer to use (default first layer in TMX).
-y <name> ----- Layer for palette mappings. -y <name> ----- Layer for palette mappings.
-c <name> ----- Output a separate 8bit collision map of the specified layer. -c <name> ----- Output a separate 8bit collision map of the specified layer.
@@ -29,7 +31,7 @@ const std::string helpFull = R"(
struct Arguments struct Arguments
{ {
bool help = false; bool help = false, showVersion = false;
std::string inPath, outPath; std::string inPath, outPath;
std::string layer, collisionlay, paletteLay; std::string layer, collisionlay, paletteLay;
std::string flagFile; std::string flagFile;
@@ -43,13 +45,16 @@ void ParseArgs(int argc, char** argv, Arguments& p)
{ {
int opt; int opt;
optreset = 1; optreset = 1;
while ((opt = getopt(argc, argv, "hr:l:c:p:y:m:i:o:f:")) > 0) while ((opt = getopt(argc, argv, "hvr:l:c:p:y:m:i:o:f:")) > 0)
{ {
switch (opt) switch (opt)
{ {
case ('h'): case ('h'):
p.help = true; p.help = true;
return; return;
case ('v'):
p.showVersion = true;
return;
case ('l'): p.layer = optarg; break; case ('l'): p.layer = optarg; break;
case ('c'): p.collisionlay = optarg; break; case ('c'): p.collisionlay = optarg; break;
@@ -146,6 +151,11 @@ int main(int argc, char** argv)
std::cout << helpUsage << std::endl << helpFull << std::endl; std::cout << helpUsage << std::endl << helpFull << std::endl;
return 0; return 0;
} }
if (p.showVersion)
{
std::cout << versionStr << std::endl;
return 0;
}
if (!p.flagFile.empty()) if (!p.flagFile.empty())
{ {
@@ -155,7 +165,7 @@ int main(int argc, char** argv)
std::cerr << "Failed to open param file." << std::endl; std::cerr << "Failed to open param file." << std::endl;
return -1; return -1;
} }
std::vector<std::string> fileArgTokens; std::vector<std::string> fileArgTokens;
fileArgTokens.push_back("auu~~"); fileArgTokens.push_back("auu~~");
bool carry = false; bool carry = false;

View File

@@ -1,7 +1,7 @@
/* tmxlayer.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */ /* tmxlayer.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */
#ifndef TMXLAYER_H #ifndef TMXLAYER_HPP
#define TMXLAYER_H #define TMXLAYER_HPP
#include <string> #include <string>
#include <cstdint> #include <cstdint>
@@ -31,4 +31,4 @@ private:
uint32_t* mTileDat; uint32_t* mTileDat;
}; };
#endif//TMXLAYER_H #endif//TMXLAYER_HPP

View File

@@ -1,7 +1,7 @@
/* tmxobject.cpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */ /* tmxobject.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */
#ifndef TMXOBJECT_H #ifndef TMXOBJECT_HPP
#define TMXOBJECT_H #define TMXOBJECT_HPP
#include <string> #include <string>
#include <utility> #include <utility>
@@ -22,4 +22,4 @@ private:
float mX, mY; float mX, mY;
}; };
#endif//TMXOBJECT_H #endif//TMXOBJECT_HPP

View File

@@ -1,7 +1,7 @@
/* tmxreader.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */ /* tmxreader.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */
#ifndef TMXREADER_H #ifndef TMXREADER_HPP
#define TMXREADER_H #define TMXREADER_HPP
#include <istream> #include <istream>
#include <vector> #include <vector>
@@ -47,4 +47,4 @@ private:
}; };
#endif//TMXREADER_H #endif//TMXREADER_HPP

View File

@@ -1,7 +1,7 @@
/* tmxtileset.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */ /* tmxtileset.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */
#ifndef TMXTILESET_H #ifndef TMXTILESET_HPP
#define TMXTILESET_H #define TMXTILESET_HPP
#include <string> #include <string>
#include <cstdint> #include <cstdint>
@@ -26,4 +26,4 @@ private:
}; };
#endif//TMXTILESET_H #endif//TMXTILESET_HPP