mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-15 18:39:51 +00:00
text encoding configuration (was using hardcoded settings before)
This commit is contained in:
parent
5b5bf6f37e
commit
8279d307c4
@ -90,6 +90,9 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||||||
|
|
||||||
mCfgMgr.readConfiguration(variables, desc);
|
mCfgMgr.readConfiguration(variables, desc);
|
||||||
|
|
||||||
|
mDocumentManager.setEncoding (
|
||||||
|
ToUTF8::calculateEncoding (variables["encoding"].as<std::string>()));
|
||||||
|
|
||||||
mDocumentManager.setResourceDir (mResources = variables["resources"].as<std::string>());
|
mDocumentManager.setResourceDir (mResources = variables["resources"].as<std::string>());
|
||||||
|
|
||||||
mFsStrict = variables["fs-strict"].as<bool>();
|
mFsStrict = variables["fs-strict"].as<bool>();
|
||||||
|
@ -2204,11 +2204,13 @@ void CSMDoc::Document::createBase()
|
|||||||
|
|
||||||
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir)
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
: mSavePath (savePath), mContentFiles (files), mNew (new_), mTools (mData), mResDir(resDir),
|
ToUTF8::FromType encoding)
|
||||||
|
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding), mTools (mData),
|
||||||
|
mResDir(resDir),
|
||||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
mSaving (*this, mProjectPath)
|
mSaving (*this, mProjectPath, encoding)
|
||||||
{
|
{
|
||||||
if (mContentFiles.empty())
|
if (mContentFiles.empty())
|
||||||
throw std::runtime_error ("Empty content file sequence");
|
throw std::runtime_error ("Empty content file sequence");
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../world/data.hpp"
|
#include "../world/data.hpp"
|
||||||
|
|
||||||
#include "../tools/tools.hpp"
|
#include "../tools/tools.hpp"
|
||||||
@ -70,7 +72,8 @@ namespace CSMDoc
|
|||||||
|
|
||||||
Document (const Files::ConfigurationManager& configuration,
|
Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir);
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
|
ToUTF8::FromType encoding);
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||||
: mConfiguration (configuration)
|
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252)
|
||||||
{
|
{
|
||||||
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ CSMDoc::DocumentManager::~DocumentManager()
|
|||||||
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
||||||
bool new_)
|
bool new_)
|
||||||
{
|
{
|
||||||
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir);
|
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding);
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
@ -80,6 +80,11 @@ void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& par
|
|||||||
mResDir = boost::filesystem::system_complete(parResDir);
|
mResDir = boost::filesystem::system_complete(parResDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::DocumentManager::setEncoding (ToUTF8::FromType encoding)
|
||||||
|
{
|
||||||
|
mEncoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
void CSMDoc::DocumentManager::documentLoaded (Document *document)
|
void CSMDoc::DocumentManager::documentLoaded (Document *document)
|
||||||
{
|
{
|
||||||
emit documentAdded (document);
|
emit documentAdded (document);
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "loader.hpp"
|
#include "loader.hpp"
|
||||||
|
|
||||||
namespace Files
|
namespace Files
|
||||||
@ -28,6 +30,7 @@ namespace CSMDoc
|
|||||||
const Files::ConfigurationManager& mConfiguration;
|
const Files::ConfigurationManager& mConfiguration;
|
||||||
QThread mLoaderThread;
|
QThread mLoaderThread;
|
||||||
Loader mLoader;
|
Loader mLoader;
|
||||||
|
ToUTF8::FromType mEncoding;
|
||||||
|
|
||||||
DocumentManager (const DocumentManager&);
|
DocumentManager (const DocumentManager&);
|
||||||
DocumentManager& operator= (const DocumentManager&);
|
DocumentManager& operator= (const DocumentManager&);
|
||||||
@ -45,6 +48,8 @@ namespace CSMDoc
|
|||||||
|
|
||||||
void setResourceDir (const boost::filesystem::path& parResDir);
|
void setResourceDir (const boost::filesystem::path& parResDir);
|
||||||
|
|
||||||
|
void setEncoding (ToUTF8::FromType encoding);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::filesystem::path mResDir;
|
boost::filesystem::path mResDir;
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
#include "savingstages.hpp"
|
#include "savingstages.hpp"
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath)
|
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath,
|
||||||
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath)
|
ToUTF8::FromType encoding)
|
||||||
|
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding)
|
||||||
{
|
{
|
||||||
// save project file
|
// save project file
|
||||||
appendStage (new OpenSaveStage (mDocument, mState, true));
|
appendStage (new OpenSaveStage (mDocument, mState, true));
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "operation.hpp"
|
#include "operation.hpp"
|
||||||
#include "savingstate.hpp"
|
#include "savingstate.hpp"
|
||||||
|
|
||||||
@ -19,7 +21,8 @@ namespace CSMDoc
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Saving (Document& document, const boost::filesystem::path& projectPath);
|
Saving (Document& document, const boost::filesystem::path& projectPath,
|
||||||
|
ToUTF8::FromType encoding);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
#include "operation.hpp"
|
#include "operation.hpp"
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath)
|
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath,
|
||||||
: mOperation (operation),
|
ToUTF8::FromType encoding)
|
||||||
/// \todo set encoding properly, once config implementation has been fixed.
|
: mOperation (operation), mEncoder (encoding), mProjectPath (projectPath), mProjectFile (false)
|
||||||
mEncoder (ToUTF8::calculateEncoding ("win1252")),
|
|
||||||
mProjectPath (projectPath), mProjectFile (false)
|
|
||||||
{
|
{
|
||||||
mWriter.setEncoder (&mEncoder);
|
mWriter.setEncoder (&mEncoder);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <components/esm/esmwriter.hpp>
|
#include <components/esm/esmwriter.hpp>
|
||||||
|
|
||||||
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Operation;
|
class Operation;
|
||||||
@ -25,7 +27,8 @@ namespace CSMDoc
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SavingState (Operation& operation, const boost::filesystem::path& projectPath);
|
SavingState (Operation& operation, const boost::filesystem::path& projectPath,
|
||||||
|
ToUTF8::FromType encoding);
|
||||||
|
|
||||||
bool hasError() const;
|
bool hasError() const;
|
||||||
|
|
||||||
|
@ -55,10 +55,8 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::Data::Data()
|
CSMWorld::Data::Data (ToUTF8::FromType encoding)
|
||||||
/// \todo set encoding properly, once config implementation has been fixed.
|
: mEncoder (encoding), mRefs (mCells), mReader (0), mDialogue (0)
|
||||||
: mEncoder (ToUTF8::calculateEncoding ("win1252")),
|
|
||||||
mRefs (mCells), mReader (0), mDialogue (0)
|
|
||||||
{
|
{
|
||||||
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
||||||
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
|
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include <components/esm/loadspel.hpp>
|
#include <components/esm/loadspel.hpp>
|
||||||
#include <components/esm/loaddial.hpp>
|
#include <components/esm/loaddial.hpp>
|
||||||
|
|
||||||
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../filter/filter.hpp"
|
#include "../filter/filter.hpp"
|
||||||
|
|
||||||
#include "../doc/stage.hpp"
|
#include "../doc/stage.hpp"
|
||||||
@ -91,7 +93,7 @@ namespace CSMWorld
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Data();
|
Data (ToUTF8::FromType encoding);
|
||||||
|
|
||||||
virtual ~Data();
|
virtual ~Data();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user