#pragma once #include #include #include #include namespace core { class Project { public: void setName(const QString& name) { m_name = name; } const QString& name() const { return m_name; } // 背景图在项目目录内的相对路径,例如 "assets/background.png" void setBackgroundImagePath(const QString& relativePath) { m_backgroundImagePath = relativePath; } const QString& backgroundImagePath() const { return m_backgroundImagePath; } // 背景在视口/预览中的显隐(默认显示) void setBackgroundVisible(bool on) { m_backgroundVisible = on; } bool backgroundVisible() const { return m_backgroundVisible; } void setDepthComputed(bool on) { m_depthComputed = on; } bool depthComputed() const { return m_depthComputed; } // 深度图在项目目录内的相对路径,例如 "assets/depth.png" void setDepthMapPath(const QString& relativePath) { m_depthMapPath = relativePath; } const QString& depthMapPath() const { return m_depthMapPath; } void setFrameStart(int f) { m_frameStart = f; } int frameStart() const { return m_frameStart; } void setFrameEnd(int f) { m_frameEnd = f; } int frameEnd() const { return m_frameEnd; } void setFps(int fps) { m_fps = std::max(1, fps); } int fps() const { return m_fps; } struct Entity { QString id; QString displayName; // 显示名(空则界面用 id) bool visible = true; // Outliner 眼睛:默认显示 // 可移动实体形状:存为局部坐标(相对 originWorld) QVector polygonLocal; // 从背景中抠洞的位置:固定在创建时的 world 坐标,不随实体移动 QVector cutoutPolygonWorld; QPointF originWorld; int depth = 0; // 0..255 QString imagePath; // 相对路径,例如 "assets/entities/entity-1.png" QPointF imageTopLeftWorld; // 贴图左上角 world 坐标 // 人为整体缩放,与深度驱动的距离缩放相乘(画布中 visualScale = distanceScale * userScale) double userScale = 1.0; struct KeyframeVec2 { int frame = 0; QPointF value; }; struct KeyframeFloat01 { int frame = 0; double value = 0.5; // 0..1,默认 0.5 -> scale=1.0(0.5..1.5 映射) }; struct KeyframeDouble { int frame = 0; double value = 1.0; }; struct ImageFrame { int frame = 0; QString imagePath; // 相对路径 }; // v2:project.json 仅存 id + payload,几何与动画在 entityPayloadPath(.hfe)中。 QString entityPayloadPath; // 例如 "assets/entities/entity-1.hfe" // 仅打开 v1 项目时由 JSON 的 animationBundle 填入,用于合并旧 .anim;保存 v2 前应为空。 QString legacyAnimSidecarPath; QVector locationKeys; QVector depthScaleKeys; QVector userScaleKeys; QVector imageFrames; }; void setEntities(const QVector& entities) { m_entities = entities; } const QVector& entities() const { return m_entities; } private: QString m_name; QString m_backgroundImagePath; bool m_backgroundVisible = true; bool m_depthComputed = false; QString m_depthMapPath; int m_frameStart = 0; int m_frameEnd = 600; int m_fps = 60; QVector m_entities; }; } // namespace core