Skip to content

Commit ffd1b3c

Browse files
committed
fix CCPoint values reading on level import
1 parent 25ffdf9 commit ffd1b3c

1 file changed

Lines changed: 8 additions & 22 deletions

File tree

include/level.hpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ namespace level {
6565
json.set("updateDate", std::string_view(level->m_updateDate.c_str())); //["updateDate"] = std::string_view(level->m_updateDate.c_str());
6666
json.set("lockedEditorLayers", std::string_view(level->m_lockedEditorLayers.c_str())); //["lockedEditorLayers"] = std::string_view(level->m_lockedEditorLayers.c_str());
6767
json.set("savedCameraPositions", std::string_view(level->m_savedCameraPositions.c_str())); //["savedCameraPositions"] = std::string_view(level->m_savedCameraPositions.c_str());
68-
{ // cocos::CCPoint m_previewLock
69-
json::Value pt;
70-
pt.set("x", level->m_previewLock.x); //["x"] = level->m_previewLock.x;
71-
pt.set("y", level->m_previewLock.y); //["y"] = level->m_previewLock.y;
72-
json.set("previewLock", pt); //["previewLock"] = pt;
73-
}
68+
json.set("previewLock.x", level->m_previewLock.x);
69+
json.set("previewLock.y", level->m_previewLock.y);
7470
json.set("userID", level->m_userID.value()); //["userID"] = level->m_userID.value();
7571
json.set("accountID", level->m_accountID.value()); //["accountID"] = level->m_accountID.value();
7672
json.set("difficulty", static_cast<int>(level->m_difficulty)); //["difficulty"] = static_cast<int>(level->m_difficulty);
@@ -147,12 +143,8 @@ namespace level {
147143
json.set("levelNotDownloaded", level->m_levelNotDownloaded); //"["levelNotDownloaded"] = level->m_levelNotDownloaded;
148144
json.set("requiredCoins", level->m_requiredCoins); //"["requiredCoins"] = level->m_requiredCoins;
149145
json.set("isUnlocked", level->m_isUnlocked); //"["isUnlocked"] = level->m_isUnlocked;
150-
{ // cocos::CCPoint m_lastCameraPos
151-
json::Value pt;
152-
pt.set("x", level->m_lastCameraPos.x); //"["x"] = level->m_lastCameraPos.x;
153-
pt.set("y", level->m_lastCameraPos.y); //"["y"] = level->m_lastCameraPos.y;
154-
json.set("lastCameraPos", pt); //["lastCameraPos"] = pt;
155-
}
146+
json.set("lastCameraPos.x", level->m_lastCameraPos.x);
147+
json.set("lastCameraPos.y", level->m_lastCameraPos.y);
156148
json.set("lastEditorZoom", level->m_lastEditorZoom); //["lastEditorZoom"] = level->m_lastEditorZoom;
157149
json.set("lastBuildTab", level->m_lastBuildTab); //["lastBuildTab"] = level->m_lastBuildTab;
158150
json.set("lastBuildPage", level->m_lastBuildPage); //["lastBuildPage"] = level->m_lastBuildPage;
@@ -202,11 +194,8 @@ namespace level {
202194
asString(updateDate);// = json["updateDate"].asString().unwrapOr().c_str();
203195
asString(lockedEditorLayers);// = json["lockedEditorLayers"].asString().unwrapOr().c_str();
204196
asString(savedCameraPositions);// = json["savedCameraPositions"].asString().unwrapOr().c_str();
205-
{ // cocos::CCPoint m_previewLock
206-
json::Value pt = json["previewLock"];
207-
asDouble(previewLock.x);// = pt["x"].asDouble().unwrapOr();
208-
asDouble(previewLock.y);// = pt["y"].asDouble().unwrapOr();
209-
}
197+
asDouble(previewLock.x);// = pt["x"].asDouble().unwrapOr();
198+
asDouble(previewLock.y);// = pt["y"].asDouble().unwrapOr();
210199
asSeed(userID);// = json["userID"].asInt().unwrapOr();
211200
asSeed(accountID);// = json["accountID"].asInt().unwrapOr();
212201
asInt(difficulty, static_cast<GJDifficulty>);// = (json["difficulty"].asInt().unwrapOr());
@@ -283,11 +272,8 @@ namespace level {
283272
asBool(levelNotDownloaded);// = json["levelNotDownloaded"].asBool().unwrapOr();
284273
asInt(requiredCoins);// = json["requiredCoins"].asInt().unwrapOr();
285274
asBool(isUnlocked);// = json["isUnlocked"].asBool().unwrapOr();
286-
{ // cocos::CCPoint m_lastCameraPos
287-
json::Value pt = json["lastCameraPos"];
288-
asDouble(lastCameraPos.x);// = pt["x"].asDouble().unwrapOr();
289-
asDouble(lastCameraPos.y);// = pt["y"].asDouble().unwrapOr();
290-
}
275+
asDouble(lastCameraPos.x);// = pt["x"].asDouble().unwrapOr();
276+
asDouble(lastCameraPos.y);
291277
asDouble(lastEditorZoom);// = json["lastEditorZoom"].asDouble().unwrapOr();
292278
asInt(lastBuildTab);// = json["lastBuildTab"].asInt().unwrapOr();
293279
asInt(lastBuildPage);// = json["lastBuildPage"].asInt().unwrapOr();

0 commit comments

Comments
 (0)