2020-08-03 01:06:55 +00:00
|
|
|
/*
|
2021-01-02 15:06:11 +00:00
|
|
|
* Copyright (c) 2020-2021 The reone project contributors
|
2020-08-03 01:06:55 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-08-02 15:47:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
#include "../src/resource/format/2dafile.h"
|
|
|
|
#include "../src/resource/format/biffile.h"
|
|
|
|
#include "../src/resource/format/erffile.h"
|
2021-01-19 06:56:51 +00:00
|
|
|
#include "../src/resource/format/keyfile.h"
|
2021-02-09 07:53:53 +00:00
|
|
|
#include "../src/resource/format/rimfile.h"
|
2020-08-02 15:47:59 +00:00
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
#include "types.h"
|
2020-08-02 15:47:59 +00:00
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
namespace reone {
|
2020-08-02 15:47:59 +00:00
|
|
|
|
|
|
|
namespace tools {
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class ITool {
|
2020-08-02 15:47:59 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
virtual void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) = 0;
|
2020-08-02 15:47:59 +00:00
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
virtual bool supports(Operation operation, const boost::filesystem::path &target) const = 0;
|
2020-08-02 15:47:59 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class KeyBifTool : public ITool {
|
2020-08-02 15:47:59 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
2020-08-02 15:47:59 +00:00
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
2020-08-02 15:47:59 +00:00
|
|
|
|
|
|
|
private:
|
2021-02-09 07:53:53 +00:00
|
|
|
void listKEY(const resource::KeyFile &key);
|
|
|
|
void listBIF(const resource::KeyFile &key, const resource::BifFile &bif, int bifIdx);
|
|
|
|
void extractBIF(const resource::KeyFile &key, resource::BifFile &bif, int bifIdx, const boost::filesystem::path &destPath);
|
2020-08-02 15:47:59 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class ErfTool : public ITool {
|
2020-08-02 15:47:59 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
2020-08-02 15:47:59 +00:00
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void list(const resource::ErfFile &erf);
|
|
|
|
void extract(resource::ErfFile &erf, const boost::filesystem::path &destPath);
|
2020-08-02 15:47:59 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class RimTool : public ITool {
|
2020-08-02 15:47:59 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
|
|
|
|
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void list(const resource::RimFile &rim);
|
|
|
|
void extract(resource::RimFile &rim, const boost::filesystem::path &destPath);
|
2020-08-02 15:47:59 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class TwoDaTool : public ITool {
|
2020-08-14 04:21:01 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
|
|
|
|
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void toJSON(const boost::filesystem::path &path, const boost::filesystem::path &destPath);
|
|
|
|
void to2DA(const boost::filesystem::path &path, const boost::filesystem::path &destPath);
|
2020-08-14 04:21:01 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class GffTool : public ITool {
|
2021-02-09 05:40:14 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
|
|
|
|
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void toJSON(const boost::filesystem::path &path, const boost::filesystem::path &destPath);
|
2021-02-22 18:45:04 +00:00
|
|
|
void toGFF(const boost::filesystem::path &path, const boost::filesystem::path &destPath);
|
2021-02-09 05:40:14 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class TlkTool : public ITool {
|
2020-08-02 15:47:59 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
|
|
|
|
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
2020-08-02 15:47:59 +00:00
|
|
|
|
|
|
|
private:
|
2021-02-09 07:53:53 +00:00
|
|
|
void toJSON(const boost::filesystem::path &path, const boost::filesystem::path &destPath);
|
2020-08-02 15:47:59 +00:00
|
|
|
};
|
|
|
|
|
2021-02-09 07:53:53 +00:00
|
|
|
class TpcTool : public ITool {
|
2021-01-13 12:59:15 +00:00
|
|
|
public:
|
2021-02-09 07:53:53 +00:00
|
|
|
void invoke(
|
|
|
|
Operation operation,
|
|
|
|
const boost::filesystem::path &target,
|
|
|
|
const boost::filesystem::path &gamePath,
|
|
|
|
const boost::filesystem::path &destPath) override;
|
|
|
|
|
|
|
|
bool supports(Operation operation, const boost::filesystem::path &target) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void toTGA(const boost::filesystem::path &path, const boost::filesystem::path &destPath);
|
2021-01-13 12:59:15 +00:00
|
|
|
};
|
|
|
|
|
2020-08-02 15:47:59 +00:00
|
|
|
} // namespace tools
|
|
|
|
|
|
|
|
} // namespace reone
|