mirror of
https://github.com/ScrelliCopter/tmx2gba.git
synced 2025-02-21 03:29:25 +11:00
Added CMake build.
Code changes to support Linux. Updated documentation & README.md, which were sorely out of date. Updated copyrights. *yawn*
This commit is contained in:
45
CMakeLists.txt
Normal file
45
CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# tmx2gba - CMakeLists.txt
|
||||||
|
# Copyright (C) 2018 Nicholas Curtis (a dinosaur)
|
||||||
|
#
|
||||||
|
# This software is provided 'as-is', without any express or implied
|
||||||
|
# warranty. In no event will the authors be held liable for any damages
|
||||||
|
# arising from the use of this software.
|
||||||
|
#
|
||||||
|
# Permission is granted to anyone to use this software for any purpose,
|
||||||
|
# including commercial applications, and to alter it and redistribute it
|
||||||
|
# freely, subject to the following restrictions:
|
||||||
|
#
|
||||||
|
# 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
# claim that you wrote the original software. If you use this software
|
||||||
|
# in a product, an acknowledgment in the product documentation would be
|
||||||
|
# appreciated but is not required.
|
||||||
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
# misrepresented as being the original software.
|
||||||
|
# 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(tmx2gba)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
include_directories(inc)
|
||||||
|
set(SOURCES
|
||||||
|
src/tmx2gba.cpp
|
||||||
|
src/tmxlayer.cpp src/tmxlayer.h
|
||||||
|
src/tmxobject.cpp src/tmxobject.h
|
||||||
|
src/tmxreader.cpp src/tmxreader.h
|
||||||
|
src/tmxtileset.cpp src/tmxtileset.h
|
||||||
|
|
||||||
|
src/base64.cpp inc/base64.h
|
||||||
|
inc/miniz.h
|
||||||
|
|
||||||
|
inc/rapidxml/rapidxml.hpp
|
||||||
|
inc/rapidxml/rapidxml_iterators.hpp
|
||||||
|
inc/rapidxml/rapidxml_print.hpp
|
||||||
|
inc/rapidxml/rapidxml_utils.hpp)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set(SOURCES ${SOURCES} src/XGetopt.cpp inc/XGetopt.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(tmx2gba ${SOURCES})
|
||||||
33
README.md
33
README.md
@@ -1,6 +1,6 @@
|
|||||||
# tmx2gba #
|
# tmx2gba #
|
||||||
tmx2gba is a simple command line utility that converts Tiled (http://www.mapeditor.org/) .tmx maps to Game Boy Advance compatible charmaps.
|
tmx2gba is a simple command line utility that converts [Tiled](http://www.mapeditor.org/) .tmx maps to Game Boy Advance compatible charmaps.
|
||||||
Originally developed for my own personal use, I've thrown it up on glorious Github in case this is of use to anyone else.
|
Originally developed for my own personal use, I've thrown it up on glorious Github/Gitlab/whatever in case this is of use to anyone else.
|
||||||
|
|
||||||
If you find a bug, please open an issue.
|
If you find a bug, please open an issue.
|
||||||
|
|
||||||
@@ -18,25 +18,40 @@ 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.
|
||||||
-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.
|
||||||
-r (offset) | No | Offset tile indices (default 0).
|
-r (offset) | No | Offset tile indices (default 0).
|
||||||
-p (0-15) | No | Select which palette to use for 4-bit tilesets.
|
-p (0-15) | No | Select which palette to use for 4-bit tilesets.
|
||||||
|
-m (name;id)| No | Map an object name to an ID, will enable object exports.
|
||||||
-i (path) | *Yes* | Path to input TMX file.
|
-i (path) | *Yes* | Path to input TMX file.
|
||||||
-o (path) | *Yes* | Path to output files.
|
-o (path) | *Yes* | Path to output files.
|
||||||
|
-f <file> | No | Command line instructions list for easy integration with buildscripts
|
||||||
|
|
||||||
|
### How do I build it? ###
|
||||||
|
|
||||||
|
Dependencies for building are CMake 3.x and a C++11 compliant compiler,
|
||||||
|
all other dependencies are in-tree so you should be able to build with:
|
||||||
|
```bash
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
Optionally, to make it convenient for my dkp projects:
|
||||||
|
```bash
|
||||||
|
sudo cp tmx2gba $DEVKITPRO/tools/bin/tmx2gba
|
||||||
|
```
|
||||||
|
|
||||||
### Todo list ###
|
### Todo list ###
|
||||||
* Add support for multi-SBB prepared charmaps.
|
* Add support for multi-SBB prepared charmaps.
|
||||||
* Test on & write Makefile for Linux.
|
* Test CMakeLists for Windows compatibility.
|
||||||
* Export to C/ASM with width/height info.
|
|
||||||
* Check if this works for NDS as well.
|
* Check if this works for NDS as well.
|
||||||
* Implement some kind of grit-style parameters file for easy integration into buildscripts.
|
|
||||||
* Revamp command line arguments.
|
|
||||||
* Compression support.
|
* Compression support.
|
||||||
* Refactor & Fix bugs.
|
* Prehaps use GNU style getopt_long?
|
||||||
|
* Refactor & Fix bugs. *(duh)*
|
||||||
|
|
||||||
### License ###
|
### License ###
|
||||||
tmx2gba is licensed under the zlib license.
|
tmx2gba is licensed under the zlib license.
|
||||||
@@ -45,7 +60,7 @@ René Nyffenegger's base64.cpp is licensed under the zlib license.
|
|||||||
XGetopt & miniz are both public domain software.
|
XGetopt & miniz are both public domain software.
|
||||||
|
|
||||||
```
|
```
|
||||||
Copyright (C) 2015 Nicholas Curtis
|
Copyright (C) 2015-2018 Nicholas Curtis (a dinosaur)
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg, *next;
|
extern char *optarg, *next;
|
||||||
|
|
||||||
void getoptClear ();
|
|
||||||
int getopt(int argc, char *argv[], char *optstring);
|
int getopt(int argc, char *argv[], char *optstring);
|
||||||
|
|
||||||
#endif //XGETOPT_H
|
#endif //XGETOPT_H
|
||||||
|
|||||||
@@ -149,13 +149,6 @@ char *optarg; // global argument pointer
|
|||||||
char *next;
|
char *next;
|
||||||
int optind = 0; // global argv index
|
int optind = 0; // global argv index
|
||||||
|
|
||||||
void getoptClear ()
|
|
||||||
{
|
|
||||||
optarg = nullptr;
|
|
||||||
next = nullptr;
|
|
||||||
optind = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getopt(int argc, char *argv[], char *optstring)
|
int getopt(int argc, char *argv[], char *optstring)
|
||||||
{
|
{
|
||||||
if (optind == 0)
|
if (optind == 0)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
base64.cpp and base64.h
|
base64.cpp and base64.h
|
||||||
|
|
||||||
Copyright (C) 2004-2008 René Nyffenegger
|
Copyright (C) 2004-2008 René Nyffenegger
|
||||||
|
|
||||||
This source code is provided 'as-is', without any express or implied
|
This source code is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the author be held liable for any damages
|
warranty. In no event will the author be held liable for any damages
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* tmx2gba.cpp
|
/* tmx2gba.cpp
|
||||||
|
|
||||||
Copyright (C) 2015 Nicholas Curtis
|
Copyright (C) 2015-2018 Nicholas Curtis (a dinosaur)
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
@@ -31,7 +31,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <XGetopt.h>
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <XGetopt.h>
|
||||||
|
#else
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
@@ -58,7 +63,7 @@ static const string g_strHelpFull = R"(
|
|||||||
-m <name;id> -- Map an object name to an ID, will enable object exports.
|
-m <name;id> -- Map an object name to an ID, will enable object exports.
|
||||||
-i <path> ----- Path to input TMX file.
|
-i <path> ----- Path to input TMX file.
|
||||||
-o <path> ----- Path to output files.
|
-o <path> ----- Path to output files.
|
||||||
-f <file> ----- Specify a file to use for flags, will override any options specified in the cmd line.)";
|
-f <file> ----- Specify a file to use for flags, will override any options specified on the command line.)";
|
||||||
|
|
||||||
struct SParams
|
struct SParams
|
||||||
{
|
{
|
||||||
@@ -72,10 +77,19 @@ struct SParams
|
|||||||
bool objExport = false;
|
bool objExport = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void GetoptClear ()
|
||||||
|
{
|
||||||
|
optarg = nullptr;
|
||||||
|
optind = 0;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
next = nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void ParseArgs ( int argc, char** argv, SParams* params )
|
void ParseArgs ( int argc, char** argv, SParams* params )
|
||||||
{
|
{
|
||||||
char cOption;
|
char cOption;
|
||||||
getoptClear ();
|
GetoptClear ();
|
||||||
while ( ( cOption = (char)getopt ( argc, argv, "hr:l:c:p:y:m:i:o:f:" ) ) > 0 )
|
while ( ( cOption = (char)getopt ( argc, argv, "hr:l:c:p:y:m:i:o:f:" ) ) > 0 )
|
||||||
{
|
{
|
||||||
switch ( cOption )
|
switch ( cOption )
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <rapidxml/rapidxml.hpp>
|
||||||
|
|
||||||
class CTmxTileset;
|
class CTmxTileset;
|
||||||
class CTmxLayer;
|
class CTmxLayer;
|
||||||
class CTmxObject;
|
class CTmxObject;
|
||||||
namespace rapidxml { template<class Ch = char> class xml_node; }
|
|
||||||
|
|
||||||
class CTmxReader
|
class CTmxReader
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user