Skip to content

Commit af735a5

Browse files
NostritiusDrMcCoy
authored andcommitted
FEV2XML: Add initial fev2xml tool
1 parent e77449d commit af735a5

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Makefile.in
116116
/src/fixnwn2xml
117117
/src/keybif
118118
/src/rim
119+
/src/fev2xml
119120

120121
# Windows binaries
121122
/src/gff2xml.exe
@@ -147,3 +148,4 @@ Makefile.in
147148
/src/fixnwn2xml.exe
148149
/src/keybif.exe
149150
/src/rim.exe
151+
/src/fev2xml.exe

src/fev2xml.cpp

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* xoreos-tools - Tools to help with xoreos development
2+
*
3+
* xoreos-tools is the legal property of its developers, whose names
4+
* can be found in the AUTHORS file distributed with this source
5+
* distribution.
6+
*
7+
* xoreos-tools is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU General Public License
9+
* as published by the Free Software Foundation; either version 3
10+
* of the License, or (at your option) any later version.
11+
*
12+
* xoreos-tools is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with xoreos-tools. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/** @file
22+
* Tool to convert TLK files into XML.
23+
*/
24+
25+
#include <cstring>
26+
#include <cstdio>
27+
28+
#include "src/version/version.h"
29+
30+
#include "src/common/scopedptr.h"
31+
#include "src/common/ustring.h"
32+
#include "src/common/util.h"
33+
#include "src/common/error.h"
34+
#include "src/common/platform.h"
35+
#include "src/common/readfile.h"
36+
#include "src/common/writefile.h"
37+
#include "src/common/cli.h"
38+
39+
#include "src/aurora/types.h"
40+
41+
#include "src/xml/fevdumper.h"
42+
43+
#include "src/util.h"
44+
45+
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
46+
Common::UString &inFile, Common::UString &outFile);
47+
48+
void dumpFEV(const Common::UString &inFile, const Common::UString &outFile);
49+
50+
int main(int argc, char **argv) {
51+
initPlatform();
52+
53+
try {
54+
std::vector<Common::UString> args;
55+
Common::Platform::getParameters(argc, argv, args);
56+
57+
int returnValue = 1;
58+
Common::UString inFile, outFile;
59+
60+
if (!parseCommandLine(args, returnValue, inFile, outFile))
61+
return returnValue;
62+
63+
dumpFEV(inFile, outFile);
64+
} catch (...) {
65+
Common::exceptionDispatcherError();
66+
}
67+
68+
return 0;
69+
}
70+
71+
bool parseCommandLine(const std::vector<Common::UString> &argv, int &returnValue,
72+
Common::UString &inFile, Common::UString &outFile) {
73+
using Common::CLI::NoOption;
74+
using Common::CLI::Parser;
75+
using Common::CLI::ValGetter;
76+
using Common::CLI::makeEndArgs;
77+
78+
NoOption inFileOpt(false, new ValGetter<Common::UString &>(inFile, "input file"));
79+
NoOption outFileOpt(true, new ValGetter<Common::UString &>(outFile, "output file"));
80+
Parser parser(argv[0], "FMOD FEV to XML converter",
81+
"If no output file is given, the output is written to stdout.\n",
82+
returnValue,
83+
makeEndArgs(&inFileOpt, &outFileOpt));
84+
85+
return parser.process(argv);
86+
}
87+
88+
void dumpFEV(const Common::UString &inFile, const Common::UString &outFile) {
89+
Common::ScopedPtr<Common::SeekableReadStream> fev(new Common::ReadFile(inFile));
90+
Common::ScopedPtr<Common::WriteStream> out(openFileOrStdOut(outFile));
91+
92+
XML::FEVDumper::dump(*out, *fev);
93+
94+
out->flush();
95+
96+
if (!outFile.empty())
97+
status("Converted \"%s\" to \"%s\"", inFile.c_str(), outFile.c_str());
98+
}

src/rules.mk

+14
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,20 @@ src_rim_LDADD = \
398398
$(LDADD) \
399399
$(EMPTY)
400400

401+
bin_PROGRAMS += src/fev2xml
402+
src_fev2xml_SOURCES = \
403+
src/fev2xml.cpp \
404+
src/util.cpp \
405+
$(EMPTY)
406+
src_fev2xml_LDADD = \
407+
src/xml/libxml.la \
408+
src/sound/libsound.la \
409+
src/aurora/libaurora.la \
410+
src/common/libcommon.la \
411+
src/version/libversion.la \
412+
$(LDADD) \
413+
$(EMPTY)
414+
401415
# Subdirectories
402416

403417
include src/version/rules.mk

0 commit comments

Comments
 (0)