mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 03:59:56 +00:00
Improve format version in content selector
This commit is contained in:
parent
78459314bf
commit
93e50cc7aa
10 changed files with 24 additions and 33 deletions
|
@ -341,7 +341,7 @@ namespace
|
|||
{
|
||||
std::cout << "Author: " << esm.getAuthor() << '\n'
|
||||
<< "Description: " << esm.getDesc() << '\n'
|
||||
<< "File format version: " << esm.getFVer() << '\n';
|
||||
<< "File format version: " << esm.esmVersionF() << '\n';
|
||||
std::vector<ESM::Header::MasterData> masterData = esm.getGameFiles();
|
||||
if (!masterData.empty())
|
||||
{
|
||||
|
@ -508,7 +508,7 @@ namespace
|
|||
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(info.encoding));
|
||||
esm.setEncoder(&encoder);
|
||||
esm.setHeader(data.mHeader);
|
||||
esm.setVersion(ESM::VER_13);
|
||||
esm.setVersion(ESM::VER_130);
|
||||
esm.setRecordCount(recordCount);
|
||||
|
||||
std::fstream save(info.outname, std::fstream::out | std::fstream::binary);
|
||||
|
|
|
@ -489,7 +489,7 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf
|
|||
fileReader.setEncoder(&encoder);
|
||||
fileReader.open(std::move(stream), filepath);
|
||||
file->setAuthor(QString::fromUtf8(fileReader.getAuthor().c_str()));
|
||||
file->setFormat(fileReader.getFormatVersion());
|
||||
file->setFormat(QString::number(fileReader.esmVersionF()));
|
||||
file->setDescription(QString::fromUtf8(fileReader.getDesc().c_str()));
|
||||
for (const auto& master : fileReader.getGameFiles())
|
||||
file->addGameFile(QString::fromUtf8(master.name.c_str()));
|
||||
|
@ -505,11 +505,11 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf
|
|||
case ESM::Format::Tes4:
|
||||
{
|
||||
ToUTF8::StatelessUtf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString()));
|
||||
ESM4::Reader reader(std::move(stream), filepath, nullptr, &encoder, true);
|
||||
file->setAuthor(QString::fromUtf8(reader.getAuthor().c_str()));
|
||||
file->setFormat(reader.esmVersion());
|
||||
file->setDescription(QString::fromUtf8(reader.getDesc().c_str()));
|
||||
for (const auto& master : reader.getGameFiles())
|
||||
ESM4::Reader fileReader(std::move(stream), filepath, nullptr, &encoder, true);
|
||||
file->setAuthor(QString::fromUtf8(fileReader.getAuthor().c_str()));
|
||||
file->setFormat(QString::number(fileReader.esmVersionF()));
|
||||
file->setDescription(QString::fromUtf8(fileReader.getDesc().c_str()));
|
||||
for (const auto& master : fileReader.getGameFiles())
|
||||
file->addGameFile(QString::fromUtf8(master.name.c_str()));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void ContentSelectorModel::EsmFile::setDate(const QDateTime& modified)
|
|||
mModified = modified;
|
||||
}
|
||||
|
||||
void ContentSelectorModel::EsmFile::setFormat(int format)
|
||||
void ContentSelectorModel::EsmFile::setFormat(const QString& format)
|
||||
{
|
||||
mVersion = format;
|
||||
}
|
||||
|
@ -51,8 +51,7 @@ QByteArray ContentSelectorModel::EsmFile::encodedData() const
|
|||
QByteArray encodedData;
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
stream << mFileName << mAuthor << QString::number(mVersion) << mModified.toString() << mPath << mDescription
|
||||
<< mGameFiles;
|
||||
stream << mFileName << mAuthor << mVersion << mModified.toString() << mPath << mDescription << mGameFiles;
|
||||
|
||||
return encodedData;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace ContentSelectorModel
|
|||
void setAuthor(const QString& author);
|
||||
void setSize(const int size);
|
||||
void setDate(const QDateTime& modified);
|
||||
void setFormat(const int format);
|
||||
void setFormat(const QString& format);
|
||||
void setFilePath(const QString& path);
|
||||
void setGameFiles(const QStringList& gameFiles);
|
||||
void setDescription(const QString& description);
|
||||
|
@ -51,7 +51,7 @@ namespace ContentSelectorModel
|
|||
QString fileName() const { return mFileName; }
|
||||
QString author() const { return mAuthor; }
|
||||
QDateTime modified() const { return mModified; }
|
||||
ESM::FormatVersion formatVersion() const { return mVersion; }
|
||||
QString formatVersion() const { return mVersion; }
|
||||
QString filePath() const { return mPath; }
|
||||
|
||||
/// @note Contains file names, not paths.
|
||||
|
@ -76,7 +76,7 @@ namespace ContentSelectorModel
|
|||
private:
|
||||
QString mTooltipTemlate = tr(
|
||||
"<b>Author:</b> %1<br/>"
|
||||
"<b>Version:</b> %2<br/>"
|
||||
"<b>Format version:</b> %2<br/>"
|
||||
"<b>Modified:</b> %3<br/>"
|
||||
"<b>Path:</b><br/>%4<br/>"
|
||||
"<br/><b>Description:</b><br/>%5<br/>"
|
||||
|
@ -85,7 +85,7 @@ namespace ContentSelectorModel
|
|||
QString mFileName;
|
||||
QString mAuthor;
|
||||
QDateTime mModified;
|
||||
ESM::FormatVersion mVersion = ESM::DefaultFormatVersion;
|
||||
QString mVersion = QString::number(ESM::DefaultFormatVersion);
|
||||
QString mPath;
|
||||
QStringList mGameFiles;
|
||||
QString mDescription;
|
||||
|
|
|
@ -13,12 +13,6 @@
|
|||
|
||||
namespace ESM
|
||||
{
|
||||
enum Version
|
||||
{
|
||||
VER_12 = 0x3f99999a,
|
||||
VER_13 = 0x3fa66666
|
||||
};
|
||||
|
||||
enum RecordFlag
|
||||
{
|
||||
// This flag exists, but is not used to determine if a record has been deleted while loading
|
||||
|
|
|
@ -53,9 +53,9 @@ namespace ESM
|
|||
*
|
||||
*************************************************************************/
|
||||
|
||||
int getVer() const { return mHeader.mData.version; }
|
||||
int getVer() const { return mHeader.mData.version.ui; }
|
||||
int getRecordCount() const { return mHeader.mData.records; }
|
||||
float getFVer() const { return (mHeader.mData.version == VER_12) ? 1.2f : 1.3f; }
|
||||
float esmVersionF() const { return (mHeader.mData.version.f); }
|
||||
const std::string& getAuthor() const { return mHeader.mData.author; }
|
||||
const std::string& getDesc() const { return mHeader.mData.desc; }
|
||||
const std::vector<Header::MasterData>& getGameFiles() const { return mHeader.mMaster; }
|
||||
|
|
|
@ -84,12 +84,12 @@ namespace ESM
|
|||
|
||||
unsigned int ESMWriter::getVersion() const
|
||||
{
|
||||
return mHeader.mData.version;
|
||||
return mHeader.mData.version.ui;
|
||||
}
|
||||
|
||||
void ESMWriter::setVersion(unsigned int ver)
|
||||
{
|
||||
mHeader.mData.version = ver;
|
||||
mHeader.mData.version.ui = ver;
|
||||
}
|
||||
|
||||
void ESMWriter::setType(int type)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
#include <components/esm/common.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -83,7 +84,7 @@ namespace ESM
|
|||
|
||||
esm.writeHNOCString("FNAM", mName);
|
||||
|
||||
if (esm.getVersion() == VER_12)
|
||||
if (esm.getVersion() == VER_120)
|
||||
esm.writeHNT("WEAT", mData.mProbabilities, mData.mProbabilities.size() - 2);
|
||||
else
|
||||
esm.writeHNT("WEAT", mData.mProbabilities);
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace ESM
|
|||
|
||||
void Header::blank()
|
||||
{
|
||||
mData.version = VER_13;
|
||||
mData.version.ui = VER_130;
|
||||
mData.type = 0;
|
||||
mData.author.clear();
|
||||
mData.desc.clear();
|
||||
|
@ -26,7 +26,7 @@ namespace ESM
|
|||
if (esm.isNextSub("HEDR"))
|
||||
{
|
||||
esm.getSubHeader();
|
||||
esm.getT(mData.version);
|
||||
esm.getT(mData.version.ui);
|
||||
esm.getT(mData.type);
|
||||
mData.author = esm.getMaybeFixedStringSize(32);
|
||||
mData.desc = esm.getMaybeFixedStringSize(256);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "components/esm/common.hpp"
|
||||
#include "components/esm/esmcommon.hpp"
|
||||
#include "components/esm3/formatversion.hpp"
|
||||
|
||||
|
@ -13,11 +14,7 @@ namespace ESM
|
|||
|
||||
struct Data
|
||||
{
|
||||
/* File format version. This is actually a float, the supported
|
||||
versions are 1.2 and 1.3. These correspond to:
|
||||
1.2 = 0x3f99999a and 1.3 = 0x3fa66666
|
||||
*/
|
||||
uint32_t version;
|
||||
ESM::ESMVersion version;
|
||||
int32_t type; // 0=esp, 1=esm, 32=ess (unused)
|
||||
std::string author; // Author's name
|
||||
std::string desc; // File description
|
||||
|
|
Loading…
Reference in a new issue