-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtimelinelayer.cpp
43 lines (36 loc) · 897 Bytes
/
timelinelayer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "timelinelayer.h"
#include "project.h"
#include <QDir>
TimelineLayer::TimelineLayer(const QString& name)
: mName(name)
{
}
void TimelineLayer::setName(const QString& name)
{
mName = name;
emit nameChanged(mName);
}
void TimelineLayer::setScript(const QString& name)
{
mScript = name;
emit scriptChanged(mScript);
}
QString TimelineLayer::scriptPath() const
{
Q_ASSERT(Project::get() != nullptr);
return QDir(Project::get()->root()).filePath("scripts/" + script() + ".lua");
}
QJsonObject TimelineLayer::toJSON() const
{
QJsonObject layer;
layer["name"] = name();
layer["script"] = script();
layer["events"] = mEvents.toJSON();
return layer;
}
void TimelineLayer::fromJSON(const QJsonObject &layer)
{
setName(layer["name"].toString());
setScript(layer["script"].toString());
mEvents.fromJSON(layer["events"].toArray());
}