mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
ESSImport: convert to utf8, based on encoding setting in openmw.cfg
This commit is contained in:
parent
417f60f467
commit
081c8c8615
@ -21,6 +21,8 @@
|
||||
#include <components/esm/loadlevlist.hpp>
|
||||
#include <components/esm/loadglob.hpp>
|
||||
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
||||
#include "importercontext.hpp"
|
||||
|
||||
#include "converter.hpp"
|
||||
@ -44,9 +46,10 @@ namespace
|
||||
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)
|
||||
, mOutFile(outfile)
|
||||
, mEncoding(encoding)
|
||||
{
|
||||
|
||||
}
|
||||
@ -188,10 +191,10 @@ namespace ESSImport
|
||||
Ogre::LogManager logman;
|
||||
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.open(mEssFile);
|
||||
esm.setEncoder(&encoder);
|
||||
|
||||
Context context;
|
||||
|
||||
|
@ -9,7 +9,7 @@ namespace ESSImport
|
||||
class Importer
|
||||
{
|
||||
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();
|
||||
|
||||
@ -18,6 +18,7 @@ namespace ESSImport
|
||||
private:
|
||||
std::string mEssFile;
|
||||
std::string mOutFile;
|
||||
std::string mEncoding;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include "importer.hpp"
|
||||
|
||||
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")
|
||||
("output,o", bpo::value<std::string>(), "output file (.omwsave)")
|
||||
("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);
|
||||
|
||||
bpo::variables_map vm;
|
||||
bpo::variables_map variables;
|
||||
|
||||
bpo::parsed_options parsed = bpo::command_line_parser(argc, argv)
|
||||
.options(desc)
|
||||
.positional(p_desc)
|
||||
.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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bpo::notify(vm);
|
||||
bpo::notify(variables);
|
||||
|
||||
std::string essFile = vm["mwsave"].as<std::string>();
|
||||
std::string outputFile = vm["output"].as<std::string>();
|
||||
Files::ConfigurationManager cfgManager;
|
||||
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();
|
||||
else
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ void ESM::CellRef::blank()
|
||||
mLockLevel = 0;
|
||||
mKey.clear();
|
||||
mTrap.clear();
|
||||
mReferenceBlocked = 0;
|
||||
mReferenceBlocked = -1;
|
||||
mTeleport = false;
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
|
Loading…
Reference in New Issue
Block a user