-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (65 loc) · 2.28 KB
/
main.cpp
File metadata and controls
77 lines (65 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "BeatmapParser/BeatmapParser.hpp"
#include <filesystem>
#include <iostream>
#include <string>
namespace {
std::filesystem::path getDefaultMapPath() {
const std::filesystem::path mapsDir = "Maps";
if (!std::filesystem::exists(mapsDir) || !std::filesystem::is_directory(mapsDir)) {
return {};
}
for (const auto& entry : std::filesystem::directory_iterator(mapsDir)) {
if (!entry.is_regular_file()) {
continue;
}
if (entry.path().extension() != ".osu") {
continue;
}
return entry.path();
}
return {};
}
} // namespace
int main(int argc, char* argv[]) {
std::filesystem::path mapPath;
if (argc >= 2) {
mapPath = argv[1];
} else {
mapPath = getDefaultMapPath();
}
if (mapPath.empty()) {
std::cerr << "Usage: ParserUpgrade <path-to-map.osu>\n";
std::cerr << "No default .osu file found in Maps/.\n";
return 1;
}
BeatmapParser parser;
if (!parser.parse(mapPath)) {
std::cerr << "Failed to parse beatmap: " << mapPath.string() << "\n";
return 1;
}
std::cout << "Parsed beatmap: " << parser.currentBeatmap.fileName << "\n";
std::cout << "HitObjects: " << parser.currentBeatmap.hitObjects.objects.size() << "\n\n";
std::cout << "Slider output:\n";
int sliderIndex = 0;
for (const auto& obj : parser.currentBeatmap.hitObjects.objects) {
if (!obj.isSlider) {
continue;
}
++sliderIndex;
std::cout << "Slider #" << sliderIndex
<< " | time-range: " << obj.timeToHit << " -> " << obj.endTimeToHit
<< " | position-range: (" << obj.x << ", " << obj.y << ") -> ("
<< obj.endX << ", " << obj.endY << ")\n";
std::cout << " curve=" << obj.sliderCurveType
<< " repeats=" << obj.sliderRepeats
<< " length=" << obj.sliderPixelLength
<< " points=" << obj.sliderPoints.size() << "\n";
for (size_t i = 0; i < obj.sliderPoints.size(); ++i) {
std::cout << " p" << i << ": (" << obj.sliderPoints[i].x << ", " << obj.sliderPoints[i].y << ")\n";
}
}
if (sliderIndex == 0) {
std::cout << "No sliders in map.\n";
}
return 0;
}