Skip to content

Commit 8086451

Browse files
committed
Updated file structure. Fixed annoying progress window behavior. Partial support 9-slice.
1 parent 2d1b218 commit 8086451

File tree

109 files changed

+6863
-2992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+6863
-2992
lines changed

.gitmodules

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[submodule "plugin/ThirdParty/SC"]
22
path = plugin/ThirdParty/SC
33
url = https://github.com/scwmake/SupercellFlash
4-
[submodule "plugin/ThirdParty/AtlasGenerator"]
5-
path = plugin/ThirdParty/AtlasGenerator
6-
url = https://github.com/Daniil-SV/Atlas-Generator
7-
[submodule "plugin/ThirdParty/OpenCV"]
8-
path = plugin/ThirdParty/OpenCV
9-
url = https://github.com/Daniil-SV/OpenCV-Binaries.git
4+
[submodule "plugin/ThirdParty/libnest2d"]
5+
path = plugin/ThirdParty/libnest2d
6+
url = https://github.com/Daniil-SV/libnest2d-Binaries

plugin/src/Publisher/ResourcePublisher.cpp ResourcePublisher/ResourcePublisher.cpp

+33-22
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#include "Publisher/ResourcePublisher.h"
1+
#include "ResourcePublisher/ResourcePublisher.h"
22

33
namespace sc {
44
namespace Adobe {
5-
void ResourcePublisher::Publish(AppContext& context) {
6-
context.window->ui->SetProgress(
7-
(uint8_t)PublisherExportStage::LibraryProcessing
5+
void ResourcePublisher::Publish(Context& context) {
6+
context.progressBar->window->SetProgress(
7+
(uint8_t)PublisherStage::LibraryProcessing
88
);
9-
context.window->ui->SetStatus("");
9+
context.progressBar->window->SetStatus("");
1010

1111
FCM::Double fps;
1212
FCM::U_Int8 framesPerSec;
@@ -20,32 +20,32 @@ namespace sc {
2020
shared_ptr<SharedWriter> writer;
2121
switch (context.config.method) {
2222
case PublisherMethod::SWF:
23-
writer = shared_ptr<SharedWriter>(new Writer(context));
23+
writer = shared_ptr<SharedWriter>(new SCWriter());
2424
break;
2525
case PublisherMethod::JSON:
26-
writer = shared_ptr<SharedWriter>(new JSONWriter(context));
26+
writer = shared_ptr<SharedWriter>(new JSONWriter());
2727
break;
2828
default:
2929
throw exception("Failed to get writer");
3030
}
3131

32-
writer->Init();
32+
writer->Init(context);
3333

3434
ResourcePublisher resources(context, writer.get());
3535
resources.InitDocument(framesPerSec);
3636

3737
std::vector<std::u16string> paths;
3838
GetItemsPaths(context, libraryItems, paths);
3939

40-
ProgressBar* itemProgress = context.window->ui->GetAvailableProgressBar();
40+
StatusComponent* itemProgress = context.progressBar->window->GetAvailableProgressBar();
4141
ASSERT(itemProgress != nullptr);
4242
itemProgress->SetRange(paths.size());
4343
itemProgress->SetLabel(wxStringU16(context.locale.Get("TID_BAR_LABEL_LIBRARY_ITEMS")));
4444

4545
for (uint32_t i = 0; paths.size() > i; i++) {
4646
std::u16string& path = paths[i];
4747

48-
if (resources.context.window->ui->aboutToExit) {
48+
if (resources.context.progressBar->window->aboutToExit) {
4949
resources.context.close();
5050
return;
5151
}
@@ -65,7 +65,7 @@ namespace sc {
6565
context.close();
6666
}
6767

68-
void ResourcePublisher::GetItemsPaths(AppContext& context, FCM::FCMListPtr libraryItems, std::vector<std::u16string>& paths) {
68+
void ResourcePublisher::GetItemsPaths(Context& context, FCM::FCMListPtr libraryItems, std::vector<std::u16string>& paths) {
6969
uint32_t itemCount = 0;
7070
libraryItems->Count(itemCount);
7171

@@ -114,13 +114,13 @@ namespace sc {
114114
ASSERT(symbolItem != nullptr || mediaItem != nullptr);
115115

116116
if (symbolItem) {
117+
SymbolBehaviorInfo symbolBehavior;
118+
117119
FCM::AutoPtr<FCM::IFCMDictionary> properties;
118120
item->GetProperties(properties.m_Ptr);
121+
Utils::ReadString(properties, kLibProp_SymbolType_DictKey, symbolBehavior.type);
119122

120-
std::string symbolType;
121-
Utils::ReadString(properties, kLibProp_SymbolType_DictKey, symbolType);
122-
123-
return AddSymbol(name, symbolItem, symbolType);
123+
return AddSymbol(name, symbolItem, symbolBehavior);
124124
}
125125
else if (mediaItem) {
126126
pSharedShapeWriter shape = m_writer->AddShape();
@@ -143,30 +143,41 @@ namespace sc {
143143
uint16_t ResourcePublisher::AddSymbol(
144144
std::u16string name,
145145
DOM::LibraryItem::ISymbolItem* item,
146-
std::string symbolType
146+
SymbolBehaviorInfo& symbolBehavior
147147
) {
148148
FCM::AutoPtr<DOM::ITimeline> timeline;
149149
item->GetTimeLine(timeline.m_Ptr);
150150

151+
assert(timeline != nullptr);
152+
151153
uint16_t result = UINT16_MAX;
152154

153-
if (symbolType != "MovieClip") {
155+
if (symbolBehavior.type != "MovieClip") {
154156
result = AddShape(name, timeline);
155157
}
156158

157159
if (result == UINT16_MAX) {
158-
return AddMovieclip(name, timeline);
160+
return AddMovieclip(name, timeline, symbolBehavior);
159161
}
160162

161163
return result;
162164
};
163165

164166
uint16_t ResourcePublisher::AddMovieclip(
165167
u16string name,
166-
FCM::AutoPtr<DOM::ITimeline> timeline
168+
FCM::AutoPtr<DOM::ITimeline1> timeline,
169+
SymbolBehaviorInfo& symbolBehavior
167170
) {
171+
CDocumentPage* symbol = timeline->GetDocPage();
172+
symbolBehavior.hasSlice9 = symbol->GetScale9();
173+
if (symbolBehavior.hasSlice9)
174+
{
175+
symbol->GetScale9Rect(symbolBehavior.slice9);
176+
}
177+
168178
pSharedMovieclipWriter movieclip = m_writer->AddMovieclip();
169-
timelineBuilder->Generate(movieclip, timeline);
179+
180+
timelineBuilder->Generate(context, movieclip, symbolBehavior, timeline);
170181

171182
uint16_t identifer = m_id++;
172183
m_symbolsData[name] = identifer;
@@ -178,7 +189,7 @@ namespace sc {
178189

179190
uint16_t ResourcePublisher::AddShape(
180191
u16string name,
181-
FCM::AutoPtr<DOM::ITimeline> timeline
192+
FCM::AutoPtr<DOM::ITimeline1> timeline
182193
) {
183194
bool isShape = ShapeGenerator::Validate(timeline);
184195

@@ -237,7 +248,7 @@ namespace sc {
237248

238249
uint16_t identifer = m_id++;
239250

240-
shape->AddFilledShape(filledShape, false);
251+
shape->AddFilledShape(filledShape);
241252

242253
shape->Finalize(identifer);
243254
m_filledShapeDict.push_back({ filledShape , identifer });

plugin/src/Publisher/ShapeGenerator.cpp ResourcePublisher/SymbolGenerator/GraphicGenerator.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "Publisher/ShapeGenerator.h"
2-
#include "Publisher/ResourcePublisher.h"
1+
#include "ResourcePublisher/SymbolGenerator/GraphicGenerator.h"
2+
#include "ResourcePublisher/ResourcePublisher.h"
33

44
#include "DOM/FrameElement/IShape.h"
55

@@ -76,7 +76,7 @@ namespace sc {
7676
{
7777
FilledShape shape(m_resources.context, shape);
7878

79-
writer->AddFilledShape(shape, false);
79+
writer->AddFilledShape(shape);
8080
}
8181

8282
// Group of elements

plugin/src/Publisher/TimelineBuilder/Builder.cpp ResourcePublisher/SymbolGenerator/MovieClipGenerator.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include "Publisher/TimelineBuilder/Builder.h"
2-
#include "Publisher/ResourcePublisher.h"
1+
#include "ResourcePublisher/SymbolGenerator/MovieClipGenerator.h"
2+
#include "ResourcePublisher/ResourcePublisher.h"
33

44
namespace sc {
55
namespace Adobe {
6-
void TimelineBuilder::GetLayerBuilder(FCM::FCMListPtr& layers, ResourcePublisher& resources, vector<LayerBuilder>& result) {
6+
void TimelineBuilder::GetLayerBuilder(FCM::FCMListPtr& layers, ResourcePublisher& resources, SymbolBehaviorInfo& info, vector<LayerBuilder>& result) {
77
uint32_t layerCount = 0;
88
layers->Count(layerCount);
99

@@ -24,35 +24,35 @@ namespace sc {
2424
FCM::FCMListPtr folderLayers;
2525
folderLayer->GetChildren(folderLayers.m_Ptr);
2626

27-
TimelineBuilder::GetLayerBuilder(folderLayers, resources, result);
27+
TimelineBuilder::GetLayerBuilder(folderLayers, resources, info, result);
2828
continue;
2929
}
3030
else if (guideLayer) {
3131
FCM::FCMListPtr guideChildren;
3232
guideLayer->GetChildren(guideChildren.m_Ptr);
3333

34-
TimelineBuilder::GetLayerBuilder(guideChildren, resources, result);
34+
TimelineBuilder::GetLayerBuilder(guideChildren, resources, info, result);
3535
continue;
3636
}
3737
else if (normalLayer) {
3838
result.push_back(
39-
LayerBuilder(normalLayer, resources)
39+
LayerBuilder(normalLayer, resources, info)
4040
);
4141
}
4242
}
4343
};
4444

45-
void TimelineBuilder::Generate(pSharedMovieclipWriter writer, FCM::AutoPtr<DOM::ITimeline> timeline) {
45+
void TimelineBuilder::Generate(Context& context, pSharedMovieclipWriter writer, SymbolBehaviorInfo& info, FCM::AutoPtr<DOM::ITimeline1> timeline) {
4646
uint32_t duration = 0;
4747
timeline->GetMaxFrameCount(duration);
4848

49-
writer->InitTimeline(duration);
49+
writer->Init(context, info, duration);
5050

5151
FCM::FCMListPtr layers;
5252
timeline->GetLayers(layers.m_Ptr);
5353

5454
vector<LayerBuilder> layerBuilders;
55-
TimelineBuilder::GetLayerBuilder(layers, m_resources, layerBuilders);
55+
TimelineBuilder::GetLayerBuilder(layers, m_resources, info, layerBuilders);
5656

5757
for (uint32_t t = 0; duration > t; t++) {
5858
uint32_t i = (uint32_t)layerBuilders.size();

plugin/src/Publisher/TimelineBuilder/FrameBuilder.cpp ResourcePublisher/SymbolGenerator/TimelineBuilder/FrameBuilder.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include "Publisher/TimelineBuilder/FrameBuilder.h"
2-
3-
#include "Publisher/ResourcePublisher.h"
1+
#include "ResourcePublisher/SymbolGenerator/TimelineBuilder/FrameBuilder.h"
2+
#include "ResourcePublisher/ResourcePublisher.h"
43

54
// Textfields
65
#include "DOM/FrameElement/IClassicText.h"
@@ -355,7 +354,8 @@ namespace sc {
355354
id,
356355
blendMode,
357356
name
358-
});
357+
}
358+
);
359359

360360
m_matrices.push_back(
361361
shared_ptr<MATRIX2D>(matrix)

plugin/src/Publisher/TimelineBuilder/FrameElements/FilledShape.cpp ResourcePublisher/SymbolGenerator/TimelineBuilder/FrameElements/FilledShape.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "Publisher/TimelineBuilder/FrameElements/FilledShape.h"
3+
#include "ResourcePublisher/SymbolGenerator/TimelineBuilder/FrameElements/FilledShape.h"
44

55
#define STEP_COUNT 14
66

plugin/src/Publisher/TimelineBuilder/FrameElements/TextField.cpp ResourcePublisher/SymbolGenerator/TimelineBuilder/FrameElements/TextField.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Publisher/TimelineBuilder/FrameElements/TextField.h"
1+
#include "ResourcePublisher/SymbolGenerator/TimelineBuilder/FrameElements/TextField.h"
22

33
#define isEqual(a,b) (fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * 0.01))
44

plugin/src/Publisher/TimelineBuilder/LayerBuilder.cpp ResourcePublisher/SymbolGenerator/TimelineBuilder/LayerBuilder.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#include "Publisher/TimelineBuilder/LayerBuilder.h"
2-
3-
// TimelineBuilder for masked layers building
4-
#include "Publisher/TimelineBuilder/Builder.h"
5-
6-
#include "Publisher/ResourcePublisher.h"
1+
#include "ResourcePublisher/SymbolGenerator/TimelineBuilder/LayerBuilder.h"
2+
#include "ResourcePublisher/ResourcePublisher.h"
3+
#include "ResourcePublisher/SymbolGenerator/MovieClipGenerator.h"
74

85
namespace sc {
96
namespace Adobe {
@@ -33,8 +30,9 @@ namespace sc {
3330

3431
LayerBuilder::LayerBuilder(
3532
FCM::AutoPtr<DOM::Layer::ILayerNormal> layer,
36-
ResourcePublisher& resources
37-
) : m_layer(layer), m_resources(resources), m_frameBuilder(resources)
33+
ResourcePublisher& resources,
34+
SymbolBehaviorInfo& info
35+
) : m_layer(layer), m_resources(resources), m_frameBuilder(resources), m_behavior(info)
3836
{
3937
m_layer->GetTotalDuration(m_duration);
4038
layer->GetKeyFrames(m_keyframes.m_Ptr);
@@ -47,9 +45,9 @@ namespace sc {
4745
FCM::FCMListPtr maskedLayers;
4846
maskLayer->GetChildren(maskedLayers.m_Ptr);
4947

50-
TimelineBuilder::GetLayerBuilder(maskedLayers, resources, m_maskedLayers);
48+
m_behavior.hasSlice9 = false;
49+
TimelineBuilder::GetLayerBuilder(maskedLayers, resources, m_behavior, m_maskedLayers);
5150
}
52-
5351
}
5452

5553
void LayerBuilder::next() {

plugin/src/Publisher/JSON/JSONMovieclipWriter.cpp ResourcePublisher/Writer/JSON/JSONMovieclipWriter.cpp

+24-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
#include "Publisher/JSON/JSONMovieclipWriter.h"
2-
3-
#include "Publisher/JSON/JSONWriter.h"
1+
#include "ResourcePublisher/Writer/JSON/JSONWriter.h"
2+
#include "ResourcePublisher/Writer/JSON/JSONMovieclipWriter.h"
3+
#include "Module/Context.h"
44

55
namespace sc {
66
namespace Adobe {
7-
void JSONMovieclipWriter::Init(JSONWriter* writer) {
8-
if (writer) {
9-
m_writer = writer;
10-
}
11-
else {
12-
throw exception("Failed to get writer");
13-
}
14-
}
15-
16-
void JSONMovieclipWriter::InitTimeline(uint32_t frameCount) {
7+
void JSONMovieclipWriter::Init(Context&, SymbolBehaviorInfo& info, uint32_t frameCount) {
178
m_frames.clear();
189

1910
for (uint32_t i = 0; frameCount > i; i++) {
20-
m_frames.push_back({
21-
{"elements", json::array()}
22-
});
11+
m_frames.push_back(
12+
{
13+
{"elements", json::array()}
14+
}
15+
);
16+
}
17+
18+
if (info.hasSlice9)
19+
{
20+
DOM::Utils::RECT& rect = info.slice9;
21+
m_9scale = json::array({ rect.topLeft.y, rect.bottomRight.y, rect.topLeft.x + rect.bottomRight.y, rect.bottomRight.x + rect.topLeft.y });
2322
}
2423
}
2524

26-
void JSONMovieclipWriter::SetLabel(std::u16string label) {
25+
void JSONMovieclipWriter::SetLabel(std::u16string& label) {
2726
m_frames.at(m_position)["label"] = label;
2827
}
2928

@@ -99,7 +98,7 @@ namespace sc {
9998
matrix->ty
10099
};
101100
}
102-
101+
103102
if (color != nullptr) {
104103
frameElement["color"] = {
105104
{"rMul", color->matrix[0][0]},
@@ -120,15 +119,15 @@ namespace sc {
120119

121120
void JSONMovieclipWriter::Finalize(uint16_t id, uint8_t fps) {
122121
ordered_json root = ordered_json::object(
123-
{
124-
{"id", id},
125-
{"exports", json::array()},
126-
{"fps", fps},
127-
{"frames", m_frames}
128-
});
122+
{
123+
{"id", id},
124+
{"exports", json::array()},
125+
{"fps", fps},
126+
{"nineScale", m_9scale},
127+
{"frames", m_frames}
128+
});
129129

130130
m_writer->AddMovieclip(root);
131-
132131
}
133132
}
134133
}

0 commit comments

Comments
 (0)