reading walls
This commit is contained in:
parent
465f32092a
commit
483ed9a867
|
@ -23,6 +23,7 @@ protected:
|
|||
const json& base;
|
||||
|
||||
std::vector<Note> notes;
|
||||
std::vector<Wall> walls;
|
||||
|
||||
public:
|
||||
BeatLevelImpl(std::weak_ptr<BeatSet> p, std::shared_ptr<FileReader> r, const json& j);
|
||||
|
@ -37,6 +38,7 @@ public:
|
|||
|
||||
//TODO: get level content
|
||||
virtual const std::vector<Note>& getNotes() const override;
|
||||
virtual const std::vector<Wall>& getWalls() const override;
|
||||
|
||||
virtual void printDebug() const override;
|
||||
|
||||
|
|
|
@ -8,5 +8,6 @@ using json = nlohmann::json;
|
|||
namespace Beatsaber {
|
||||
|
||||
void from_json(const json& j, Note& n);
|
||||
void from_json(const json& j, Wall& n);
|
||||
|
||||
}
|
|
@ -27,6 +27,7 @@ public:
|
|||
|
||||
//TODO: get level content
|
||||
virtual const std::vector<Note>& getNotes() const = 0;
|
||||
virtual const std::vector<Wall>& getWalls() const = 0;
|
||||
|
||||
virtual void printDebug() const = 0;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace Beatsaber {
|
||||
|
||||
|
@ -10,6 +11,16 @@ struct Note {
|
|||
std::uint_fast8_t layer; //layer 0 = bottom, 2 = top
|
||||
std::uint_fast8_t type; //0 = rednote, 1 = bluenote, 2 = unused, 3 = bomb
|
||||
std::uint_fast8_t cutdir;
|
||||
std::string customdata;
|
||||
};
|
||||
|
||||
struct Wall {
|
||||
std::uint32_t time; // time in beats when the note reaches the player
|
||||
std::uint_fast8_t line; //0-3, 0 = left, 3 = right
|
||||
std::uint_fast8_t type; // 0 = fullhight, 1 = crouch
|
||||
std::int32_t duration; //time in beats the wall is there, might be nagtive...
|
||||
std::int_fast8_t width; //might be negative (should be between 0-4)
|
||||
std::string customdata;
|
||||
};
|
||||
|
||||
}
|
|
@ -36,6 +36,15 @@ BeatLevelImpl::BeatLevelImpl(std::weak_ptr<BeatSet> p, std::shared_ptr<FileReade
|
|||
notes.push_back(note);
|
||||
}
|
||||
}
|
||||
|
||||
//load walls
|
||||
const json& jwalls = diffjson["_obstacles"];
|
||||
if(jwalls.is_array()) {
|
||||
walls.reserve(jwalls.size());
|
||||
for(const json& wall : jwalls) {
|
||||
walls.push_back(wall);
|
||||
}
|
||||
}
|
||||
} catch(...) {
|
||||
std::cout << "Could not load difficulty: " << filename << std::endl;
|
||||
}
|
||||
|
@ -75,12 +84,16 @@ const std::vector<Note>& BeatLevelImpl::getNotes() const {
|
|||
return notes;
|
||||
}
|
||||
|
||||
const std::vector<Wall>& BeatLevelImpl::getWalls() const {
|
||||
return walls;
|
||||
}
|
||||
|
||||
void BeatLevelImpl::printDebug() const {
|
||||
std::cout <<
|
||||
" Difficulty: " << Difficulty::toString(dif) << " (" << diffRank << ")"
|
||||
<< "\n Filename: " << getFilename()
|
||||
<< "\n njs: " << getNoteJumpSpeed() << " nso: " << getNoteStartOffset()
|
||||
<< "\n noteCount: " << notes.size()
|
||||
<< "\n noteCount: " << notes.size() << " wallCount: " << walls.size()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Beatsaber {
|
|||
|
||||
bool BeatMapImpl::load() {
|
||||
// try to open info.dat
|
||||
std::shared_ptr<std::istream> stream = reader->getFileStream("Info.dat");
|
||||
std::shared_ptr<std::istream> stream = reader->getFileStream("info.dat");
|
||||
try {
|
||||
(*stream) >> infobase;
|
||||
|
||||
|
@ -26,7 +26,7 @@ bool BeatMapImpl::load() {
|
|||
|
||||
return true;
|
||||
} catch(const nlohmann::detail::exception& e) { //catch any json errors
|
||||
std::cout << "Could not Read BeatMap: " << e.what() << std::endl;
|
||||
std::cout << "Could not read BeatMap: " << e.what() << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5,11 +5,26 @@
|
|||
namespace Beatsaber {
|
||||
|
||||
void from_json(const json& j, Note& n) {
|
||||
n.time = j["_time"];
|
||||
n.line = j["_lineIndex"];
|
||||
n.layer = j["_lineLayer"];
|
||||
n.type = j["_type"];
|
||||
n.cutdir = j["_cutDirection"];
|
||||
n.time = j.value("_time", 0);
|
||||
n.line = j.value("_lineIndex", 0);
|
||||
n.layer = j.value("_lineLayer", 0);
|
||||
n.type = j.value("_type", 0);
|
||||
n.cutdir = j.value("_cutDirection", 0);
|
||||
if(j.contains("_customData")) {
|
||||
n.customdata = j["_customData"].dump();
|
||||
}
|
||||
}
|
||||
|
||||
void from_json(const json& j, Wall& w) {
|
||||
w.time = j.value("_time", 0);
|
||||
w.line = j.value("_lineIndex", 0);
|
||||
w.type = j.value("_type", 0);
|
||||
w.duration = j.value("_duration", 0);
|
||||
w.width = j.value("_width", 1);
|
||||
|
||||
if(j.contains("_customData")) {
|
||||
w.customdata = j["_customData"].dump();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -58,7 +58,7 @@ ZipReader::~ZipReader() {
|
|||
std::shared_ptr<std::istream> ZipReader::getFileStream(const std::string& filename) {
|
||||
std::shared_ptr<std::istream> stream = file.getInputStream(filename);
|
||||
|
||||
if(stream) {
|
||||
if(!stream) {
|
||||
//search for other files
|
||||
std::vector<std::string> entrys;
|
||||
getEntrys(entrys);
|
||||
|
|
Loading…
Reference in New Issue