Skip to content

Commit

Permalink
feat: 拆分levels.json文件
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 21, 2022
1 parent 63d33bc commit 8e15e55
Show file tree
Hide file tree
Showing 1,467 changed files with 935,532 additions and 935,506 deletions.
21 changes: 4 additions & 17 deletions 3rdparty/include/Arknights-Tile-Pos/TileCalc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Map
class TileCalc
{
public:
TileCalc(int width, int height, const std::filesystem::path& dir);
TileCalc(int width, int height, const json::array& json);

bool contains(const std::string& any_key);
bool contains(const LevelKey& key);
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace Map
}
}

inline TileCalc::TileCalc(int width, int height, const std::filesystem::path& dir)
inline TileCalc::TileCalc(int width, int height, const json::array& json)
{
this->width = width;
this->height = height;
Expand All @@ -117,21 +117,8 @@ namespace Map
{ -sin(10 * degree), 0, cos(10 * degree), 0 },
{ 0, 0, 0, 1 } };
InitMat4x4(this->MatrixY, matrixY);
std::ifstream ifs(dir, std::ios::in);
if (!ifs.is_open()) {
std::cerr << "Read resource failed" << std::endl;
throw "Read resource failed";
}
std::stringstream iss;
iss << ifs.rdbuf();
ifs.close();
std::string content = iss.str();
auto ret = json::parse(content);
if (!ret) {
std::cerr << "Parsing failed" << std::endl;
throw "Parsing failed";
}
for (const json::value& item : ret.value().as_array()) {

for (const json::value& item : json) {
this->levels.emplace_back(item);
}
}
Expand Down

0 comments on commit 8e15e55

Please sign in to comment.