Skip to content

Commit 6bb6120

Browse files
committed
Update snapshots with current user-editable config values before restoring
1 parent 05a637a commit 6bb6120

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

editor/window/Properties.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
#include "App.h"
2525
#include "Backend.h"
2626
#include "component/ActionComponent.h"
27+
#include "component/AlphaActionComponent.h"
2728
#include "component/AnimationComponent.h"
2829
#include "component/BoneComponent.h"
30+
#include "component/ColorActionComponent.h"
2931
#include "component/KeyframeTracksComponent.h"
30-
#include "component/TranslateTracksComponent.h"
32+
#include "component/PositionActionComponent.h"
3133
#include "component/RotateTracksComponent.h"
34+
#include "component/RotationActionComponent.h"
35+
#include "component/ScaleActionComponent.h"
3236
#include "component/ScaleTracksComponent.h"
37+
#include "component/TimedActionComponent.h"
38+
#include "component/TranslateTracksComponent.h"
3339
#include "component/MorphTracksComponent.h"
3440
#include "util/SHA1.h"
3541
#include "util/ProjectUtils.h"
@@ -7072,6 +7078,31 @@ void editor::Properties::startActionPreview(Entity entity, Scene* scene, ScenePr
70727078
void editor::Properties::stopActionPreview(Scene* scene, SceneProject* sceneProject) {
70737079
if (!actionPreviewing) return;
70747080

7081+
// Update snapshots with current user-editable config values before restoring
7082+
for (ActionPreviewState& state : actionPreviewStates) {
7083+
if (state.entity == NULL_ENTITY || !scene->isEntityCreated(state.entity) || !state.components || state.components.IsNull()) {
7084+
continue;
7085+
}
7086+
if (auto* comp = scene->findComponent<TimedActionComponent>(state.entity)) {
7087+
state.components[Catalog::getComponentName(ComponentType::TimedActionComponent, true)] = Stream::encodeTimedActionComponent(*comp);
7088+
}
7089+
if (auto* comp = scene->findComponent<PositionActionComponent>(state.entity)) {
7090+
state.components[Catalog::getComponentName(ComponentType::PositionActionComponent, true)] = Stream::encodePositionActionComponent(*comp);
7091+
}
7092+
if (auto* comp = scene->findComponent<RotationActionComponent>(state.entity)) {
7093+
state.components[Catalog::getComponentName(ComponentType::RotationActionComponent, true)] = Stream::encodeRotationActionComponent(*comp);
7094+
}
7095+
if (auto* comp = scene->findComponent<ScaleActionComponent>(state.entity)) {
7096+
state.components[Catalog::getComponentName(ComponentType::ScaleActionComponent, true)] = Stream::encodeScaleActionComponent(*comp);
7097+
}
7098+
if (auto* comp = scene->findComponent<ColorActionComponent>(state.entity)) {
7099+
state.components[Catalog::getComponentName(ComponentType::ColorActionComponent, true)] = Stream::encodeColorActionComponent(*comp);
7100+
}
7101+
if (auto* comp = scene->findComponent<AlphaActionComponent>(state.entity)) {
7102+
state.components[Catalog::getComponentName(ComponentType::AlphaActionComponent, true)] = Stream::encodeAlphaActionComponent(*comp);
7103+
}
7104+
}
7105+
70757106
for (const ActionPreviewState& state : actionPreviewStates) {
70767107
if (state.entity == NULL_ENTITY || !scene->isEntityCreated(state.entity) || !state.components || state.components.IsNull()) {
70777108
continue;

0 commit comments

Comments
 (0)