增加预览页介绍信息显示
This commit is contained in:
@@ -1031,7 +1031,59 @@ bool ProjectWorkspace::setEntityDisplayName(const QString& id, const QString& di
|
||||
return applyEntities(ents, true, QStringLiteral("重命名实体"));
|
||||
}
|
||||
|
||||
bool ProjectWorkspace::setEntityUserScale(const QString& id, double userScale) {
|
||||
bool ProjectWorkspace::setEntityIntroContent(const QString& id, const EntityIntroContent& intro) {
|
||||
if (m_projectDir.isEmpty() || id.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
auto ents = m_project.entities();
|
||||
bool found = false;
|
||||
for (auto& e : ents) {
|
||||
if (e.id != id) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
e.intro = intro;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
return applyEntities(ents, true, QStringLiteral("实体介绍"));
|
||||
}
|
||||
|
||||
bool ProjectWorkspace::importEntityIntroImageFromFile(const QString& id, const QString& absoluteImagePath,
|
||||
QString* outRelativePath) {
|
||||
if (m_projectDir.isEmpty() || id.isEmpty() || absoluteImagePath.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
const QFileInfo srcFi(absoluteImagePath);
|
||||
if (!srcFi.exists() || !srcFi.isFile()) {
|
||||
return false;
|
||||
}
|
||||
const QString entsDir = ensureEntitiesDir();
|
||||
if (entsDir.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
const QString suf = fileSuffixWithDot(absoluteImagePath);
|
||||
for (int n = 0; n < 100000; ++n) {
|
||||
const QString base = id + QStringLiteral("-intro-%1").arg(n) + suf;
|
||||
const QString destAbs = QDir(entsDir).filePath(base);
|
||||
if (!QFileInfo::exists(destAbs)) {
|
||||
if (!QFile::copy(absoluteImagePath, destAbs)) {
|
||||
return false;
|
||||
}
|
||||
const QString rel =
|
||||
QString::fromUtf8(kAssetsDirName) + QStringLiteral("/entities/") + base;
|
||||
if (outRelativePath) {
|
||||
*outRelativePath = rel;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProjectWorkspace::setEntityUserScale(const QString& id, double userScale, int keyframeAtFrame) {
|
||||
if (m_projectDir.isEmpty() || id.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1043,10 +1095,13 @@ bool ProjectWorkspace::setEntityUserScale(const QString& id, double userScale) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
if (qFuzzyCompare(e.userScale + 1.0, u + 1.0)) {
|
||||
const bool baseSame = qFuzzyCompare(e.userScale + 1.0, u + 1.0);
|
||||
e.userScale = u;
|
||||
if (keyframeAtFrame >= 0) {
|
||||
upsertKey(e.userScaleKeys, keyframeAtFrame, std::clamp(u, 1e-6, 1e3));
|
||||
} else if (baseSame) {
|
||||
return true;
|
||||
}
|
||||
e.userScale = u;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
@@ -1196,8 +1251,17 @@ bool ProjectWorkspace::moveEntityBy(const QString& id, const QPointF& delta, int
|
||||
e.originWorld,
|
||||
KeyInterpolation::Linear);
|
||||
upsertKey(e.locationKeys, currentFrame, sampled + delta);
|
||||
} else if (e.locationKeys.isEmpty()) {
|
||||
e.originWorld += delta;
|
||||
e.imageTopLeftWorld += delta;
|
||||
} else if (currentFrame >= 0) {
|
||||
// 已有位置曲线但未勾选「自动关键帧」时,仍应移动当前帧上的位置,否则画布仍按关键帧插值,看起来不生效
|
||||
const QPointF sampled = sampleLocation(e.locationKeys,
|
||||
currentFrame,
|
||||
e.originWorld,
|
||||
KeyInterpolation::Linear);
|
||||
upsertKey(e.locationKeys, currentFrame, sampled + delta);
|
||||
} else {
|
||||
// 无自动关键帧时,直接修改“基准”位置
|
||||
e.originWorld += delta;
|
||||
e.imageTopLeftWorld += delta;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user