增加预览页介绍信息显示
This commit is contained in:
@@ -30,6 +30,36 @@ void sortByFrame(QVector<Project::Entity::ImageFrame>& v) {
|
||||
std::sort(v.begin(), v.end(), [](const auto& a, const auto& b) { return a.frame < b.frame; });
|
||||
}
|
||||
|
||||
void writeIntroBlock(QDataStream& ds, const Project::Entity& entity) {
|
||||
ds << entity.intro.title << entity.intro.bodyText;
|
||||
ds << qint32(entity.intro.imagePathsRelative.size());
|
||||
for (const auto& p : entity.intro.imagePathsRelative) {
|
||||
ds << p;
|
||||
}
|
||||
ds << entity.intro.videoPathRelative;
|
||||
}
|
||||
|
||||
bool readIntroBlock(QDataStream& ds, EntityIntroContent& intro) {
|
||||
ds >> intro.title >> intro.bodyText;
|
||||
qint32 n = 0;
|
||||
ds >> n;
|
||||
if (ds.status() != QDataStream::Ok || n < 0 || n > 2048) {
|
||||
return false;
|
||||
}
|
||||
intro.imagePathsRelative.clear();
|
||||
intro.imagePathsRelative.reserve(n);
|
||||
for (qint32 i = 0; i < n; ++i) {
|
||||
QString p;
|
||||
ds >> p;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
intro.imagePathsRelative.push_back(std::move(p));
|
||||
}
|
||||
ds >> intro.videoPathRelative;
|
||||
return ds.status() == QDataStream::Ok;
|
||||
}
|
||||
|
||||
bool readAnimationBlock(QDataStream& ds, Project::Entity& out, bool hasUserScaleKeys) {
|
||||
out.locationKeys.clear();
|
||||
out.depthScaleKeys.clear();
|
||||
@@ -220,7 +250,8 @@ public:
|
||||
}
|
||||
|
||||
writeAnimationBlock(ds, entity, true);
|
||||
ds << entity.displayName << double(entity.userScale);
|
||||
ds << entity.displayName << double(entity.userScale) << double(entity.distanceScaleCalibMult);
|
||||
writeIntroBlock(ds, entity);
|
||||
}
|
||||
|
||||
bool readBody(QDataStream& ds) override {
|
||||
@@ -231,12 +262,17 @@ public:
|
||||
}
|
||||
QString dn;
|
||||
double us = 1.0;
|
||||
ds >> dn >> us;
|
||||
double cal = 0.0;
|
||||
ds >> dn >> us >> cal;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
tmp.displayName = dn;
|
||||
tmp.userScale = std::clamp(us, 1e-3, 1e3);
|
||||
tmp.distanceScaleCalibMult = (cal > 0.0) ? std::clamp(cal, 1e-6, 10.0) : 0.0;
|
||||
if (!readIntroBlock(ds, tmp.intro)) {
|
||||
return false;
|
||||
}
|
||||
*m_dst = std::move(tmp);
|
||||
return true;
|
||||
}
|
||||
@@ -293,7 +329,7 @@ bool EntityPayloadBinary::load(const QString& absolutePath, Project::Entity& ent
|
||||
if (ds.status() != QDataStream::Ok || magic != kMagicPayload) {
|
||||
return false;
|
||||
}
|
||||
if (ver != 1 && ver != 2 && ver != 3) {
|
||||
if (ver != 1 && ver != 2 && ver != 3 && ver != 4 && ver != 5) {
|
||||
return false;
|
||||
}
|
||||
Project::Entity tmp;
|
||||
@@ -309,6 +345,19 @@ bool EntityPayloadBinary::load(const QString& absolutePath, Project::Entity& ent
|
||||
}
|
||||
tmp.displayName = dn;
|
||||
tmp.userScale = std::clamp(us, 1e-3, 1e3);
|
||||
if (ver >= 4) {
|
||||
double cal = 0.0;
|
||||
ds >> cal;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
tmp.distanceScaleCalibMult = (cal > 0.0) ? std::clamp(cal, 1e-6, 10.0) : 0.0;
|
||||
}
|
||||
if (ver >= 5) {
|
||||
if (!readIntroBlock(ds, tmp.intro)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tmp.displayName.clear();
|
||||
tmp.userScale = 1.0;
|
||||
|
||||
Reference in New Issue
Block a user