mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 13:19:40 +00:00
ESSImport: convert to utf8, based on encoding setting in openmw.cfg
This commit is contained in:
parent
417f60f467
commit
081c8c8615
4 changed files with 24 additions and 13 deletions
|
@ -21,6 +21,8 @@
|
||||||
#include <components/esm/loadlevlist.hpp>
|
#include <components/esm/loadlevlist.hpp>
|
||||||
#include <components/esm/loadglob.hpp>
|
#include <components/esm/loadglob.hpp>
|
||||||
|
|
||||||
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "importercontext.hpp"
|
#include "importercontext.hpp"
|
||||||
|
|
||||||
#include "converter.hpp"
|
#include "converter.hpp"
|
||||||
|
@ -44,9 +46,10 @@ namespace
|
||||||
namespace ESSImport
|
namespace ESSImport
|
||||||
{
|
{
|
||||||
|
|
||||||
Importer::Importer(const std::string &essfile, const std::string &outfile)
|
Importer::Importer(const std::string &essfile, const std::string &outfile, const std::string &encoding)
|
||||||
: mEssFile(essfile)
|
: mEssFile(essfile)
|
||||||
, mOutFile(outfile)
|
, mOutFile(outfile)
|
||||||
|
, mEncoding(encoding)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -188,10 +191,10 @@ namespace ESSImport
|
||||||
Ogre::LogManager logman;
|
Ogre::LogManager logman;
|
||||||
Ogre::Root root;
|
Ogre::Root root;
|
||||||
|
|
||||||
// TODO: set up encoding on ESMReader based on openmw.cfg / --encoding switch
|
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding));
|
||||||
|
|
||||||
ESM::ESMReader esm;
|
ESM::ESMReader esm;
|
||||||
esm.open(mEssFile);
|
esm.open(mEssFile);
|
||||||
|
esm.setEncoder(&encoder);
|
||||||
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ESSImport
|
||||||
class Importer
|
class Importer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Importer(const std::string& essfile, const std::string& outfile);
|
Importer(const std::string& essfile, const std::string& outfile, const std::string& encoding);
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ namespace ESSImport
|
||||||
private:
|
private:
|
||||||
std::string mEssFile;
|
std::string mEssFile;
|
||||||
std::string mOutFile;
|
std::string mOutFile;
|
||||||
|
std::string mEncoding;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include "importer.hpp"
|
#include "importer.hpp"
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
@ -23,31 +25,36 @@ int main(int argc, char** argv)
|
||||||
("mwsave,m", bpo::value<std::string>(), "morrowind .ess save file")
|
("mwsave,m", bpo::value<std::string>(), "morrowind .ess save file")
|
||||||
("output,o", bpo::value<std::string>(), "output file (.omwsave)")
|
("output,o", bpo::value<std::string>(), "output file (.omwsave)")
|
||||||
("compare,c", "compare two .ess files")
|
("compare,c", "compare two .ess files")
|
||||||
|
("encoding", boost::program_options::value<std::string>()->default_value("win1252"), "encoding of the save file")
|
||||||
;
|
;
|
||||||
p_desc.add("mwsave", 1).add("output", 1);
|
p_desc.add("mwsave", 1).add("output", 1);
|
||||||
|
|
||||||
bpo::variables_map vm;
|
bpo::variables_map variables;
|
||||||
|
|
||||||
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv)
|
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv)
|
||||||
.options(desc)
|
.options(desc)
|
||||||
.positional(p_desc)
|
.positional(p_desc)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
bpo::store(parsed, vm);
|
bpo::store(parsed, variables);
|
||||||
|
|
||||||
if(vm.count("help") || !vm.count("mwsave") || !vm.count("output")) {
|
if(variables.count("help") || !variables.count("mwsave") || !variables.count("output")) {
|
||||||
std::cout << desc;
|
std::cout << desc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bpo::notify(vm);
|
bpo::notify(variables);
|
||||||
|
|
||||||
std::string essFile = vm["mwsave"].as<std::string>();
|
Files::ConfigurationManager cfgManager;
|
||||||
std::string outputFile = vm["output"].as<std::string>();
|
cfgManager.readConfiguration(variables, desc);
|
||||||
|
|
||||||
ESSImport::Importer importer(essFile, outputFile);
|
std::string essFile = variables["mwsave"].as<std::string>();
|
||||||
|
std::string outputFile = variables["output"].as<std::string>();
|
||||||
|
std::string encoding = variables["encoding"].as<std::string>();
|
||||||
|
|
||||||
if (vm.count("compare"))
|
ESSImport::Importer importer(essFile, outputFile, encoding);
|
||||||
|
|
||||||
|
if (variables.count("compare"))
|
||||||
importer.compare();
|
importer.compare();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,7 +153,7 @@ void ESM::CellRef::blank()
|
||||||
mLockLevel = 0;
|
mLockLevel = 0;
|
||||||
mKey.clear();
|
mKey.clear();
|
||||||
mTrap.clear();
|
mTrap.clear();
|
||||||
mReferenceBlocked = 0;
|
mReferenceBlocked = -1;
|
||||||
mTeleport = false;
|
mTeleport = false;
|
||||||
|
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
|
|
Loading…
Reference in a new issue