chore(tools): Cleanup, drop unimplemented operations
JSON to GFF and JSON to TLK converters need more analysis.
This commit is contained in:
parent
2f4d568c15
commit
c02bfb4931
5 changed files with 17 additions and 20 deletions
|
@ -63,8 +63,7 @@ void TwoDaTool::toJSON(const fs::path &path, const fs::path &destPath) {
|
|||
fs::path jsonPath(destPath);
|
||||
jsonPath.append(path.filename().string() + ".json");
|
||||
|
||||
fs::ofstream json(jsonPath);
|
||||
pt::write_json(json, tree);
|
||||
pt::write_json(jsonPath.string(), tree);
|
||||
}
|
||||
|
||||
void TwoDaTool::to2DA(const fs::path &path, const fs::path &destPath) {
|
||||
|
@ -97,8 +96,7 @@ void TwoDaTool::to2DA(const fs::path &path, const fs::path &destPath) {
|
|||
bool TwoDaTool::supports(Operation operation, const fs::path &target) const {
|
||||
return
|
||||
!fs::is_directory(target) &&
|
||||
(target.extension() == ".2da" || target.extension() == ".json") &&
|
||||
(operation == Operation::ToJSON || operation == Operation::To2DA);
|
||||
((target.extension() == ".2da" && operation == Operation::ToJSON) || (target.extension() == ".json" && operation == Operation::To2DA));
|
||||
}
|
||||
|
||||
} // namespace tools
|
||||
|
|
|
@ -65,10 +65,10 @@ static pt::ptree getPropertyTree(const GffStruct &gffs) {
|
|||
case GffFieldType::Orientation:
|
||||
values = field.asFloatArray();
|
||||
child.clear();
|
||||
child.put("A", values[0]);
|
||||
child.put("B", values[1]);
|
||||
child.put("C", values[2]);
|
||||
child.put("D", values[3]);
|
||||
child.put("W", values[0]);
|
||||
child.put("X", values[1]);
|
||||
child.put("Y", values[2]);
|
||||
child.put("Z", values[3]);
|
||||
tree.add_child(field.label(), child);
|
||||
break;
|
||||
|
||||
|
@ -100,12 +100,13 @@ void GffTool::toJSON(const fs::path &path, const fs::path &destPath) {
|
|||
fs::path jsonPath(destPath);
|
||||
jsonPath.append(path.filename().string() + ".json");
|
||||
|
||||
fs::ofstream json(jsonPath);
|
||||
pt::write_json(json, tree);
|
||||
pt::write_json(jsonPath.string(), tree);
|
||||
}
|
||||
|
||||
bool GffTool::supports(Operation operation, const fs::path &target) const {
|
||||
return !fs::is_directory(target) && operation == Operation::ToJSON;
|
||||
return
|
||||
!fs::is_directory(target) &&
|
||||
operation == Operation::ToJSON;
|
||||
}
|
||||
|
||||
} // namespace tools
|
||||
|
|
|
@ -47,9 +47,7 @@ static const unordered_map<string, Operation> g_operations {
|
|||
{ "extract", Operation::Extract },
|
||||
{ "to-json", Operation::ToJSON },
|
||||
{ "to-tga", Operation::ToTGA },
|
||||
{ "to-2da", Operation::To2DA },
|
||||
{ "to-gff", Operation::ToGFF },
|
||||
{ "to-tlk", Operation::ToTLK }
|
||||
{ "to-2da", Operation::To2DA }
|
||||
};
|
||||
|
||||
Program::Program(int argc, char **argv) : _argc(argc), _argv(argv) {
|
||||
|
@ -91,7 +89,6 @@ void Program::initOptions() {
|
|||
("to-tga", "convert TPC image to TGA")
|
||||
("to-2da", "convert JSON to 2DA")
|
||||
("to-gff", "convert JSON to GFF")
|
||||
("to-tlk", "convert JSON to TLK")
|
||||
("target", po::value<string>(), "target name or path to input file");
|
||||
}
|
||||
|
||||
|
@ -142,6 +139,10 @@ void Program::determineGameID() {
|
|||
}
|
||||
|
||||
void Program::loadTools() {
|
||||
// Tools are queried in the order of addition, whether they support a
|
||||
// particular operation on a particular file, or not. The first tool
|
||||
// to return true gets chosen.
|
||||
|
||||
_tools.push_back(make_shared<KeyBifTool>());
|
||||
_tools.push_back(make_shared<ErfTool>());
|
||||
_tools.push_back(make_shared<RimTool>());
|
||||
|
|
|
@ -60,8 +60,7 @@ void TlkTool::toJSON(const fs::path &path, const fs::path &destPath) {
|
|||
fs::path jsonPath(destPath);
|
||||
jsonPath.append(path.filename().string() + ".json");
|
||||
|
||||
fs::ofstream json(jsonPath);
|
||||
pt::write_json(json, tree);
|
||||
pt::write_json(jsonPath.string(), tree);
|
||||
}
|
||||
|
||||
bool TlkTool::supports(Operation operation, const fs::path &target) const {
|
||||
|
|
|
@ -27,9 +27,7 @@ enum class Operation {
|
|||
Extract,
|
||||
ToJSON,
|
||||
ToTGA,
|
||||
To2DA,
|
||||
ToGFF,
|
||||
ToTLK
|
||||
To2DA
|
||||
};
|
||||
|
||||
} // namespace tools
|
||||
|
|
Loading…
Reference in a new issue