Skip to content

Commit 43cc2e4

Browse files
committed
Load current costume correctly
1 parent a8156fa commit 43cc2e4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/internal/scratch3reader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,6 @@ bool Scratch3Reader::load()
193193

194194
// TODO: Add comments
195195

196-
// currentCostume
197-
READER_STEP(step, "target -> currentCostume");
198-
target->setCurrentCostume(jsonTarget["currentCostume"]);
199-
200196
// costumes
201197
READER_STEP(step, "target -> costumes");
202198
auto costumes = jsonTarget["costumes"];
@@ -218,6 +214,10 @@ bool Scratch3Reader::load()
218214
target->addCostume(costume);
219215
}
220216

217+
// currentCostume
218+
READER_STEP(step, "target -> currentCostume");
219+
target->setCurrentCostume(jsonToValue(jsonTarget["currentCostume"]).toInt() + 1);
220+
221221
// sounds
222222
READER_STEP(step, "target -> sounds");
223223
auto sounds = jsonTarget["sounds"];

test/load_project/load_project_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TEST(LoadProjectTest, EmptyProject)
4040
ASSERT_EQ(stage->blocks().size(), 0);
4141
ASSERT_EQ(stage->costumes().size(), 1);
4242
// TODO: Add comments
43-
ASSERT_EQ(stage->currentCostume(), 0);
43+
ASSERT_EQ(stage->currentCostume(), 1);
4444
ASSERT_EQ(stage->sounds().size(), 0);
4545
ASSERT_EQ(stage->layerOrder(), 0);
4646
ASSERT_EQ(stage->volume(), 100);
@@ -104,6 +104,7 @@ TEST(LoadProjectTest, LoadTestProject)
104104
ASSERT_EQ(sprite1->lists().size(), 1);
105105
ASSERT_EQ(sprite1->blocks().size(), 18);
106106
ASSERT_EQ(sprite1->costumes().size(), 2);
107+
ASSERT_EQ(sprite1->currentCostume(), 2);
107108
ASSERT_EQ(sprite1->sounds().size(), 1);
108109
ASSERT_TRUE(sprite1->visible());
109110
ASSERT_EQ(sprite1->x(), 0);

0 commit comments

Comments
 (0)