about summary refs log tree commit diff stats
path: root/Source/Panel.h
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-11-02 21:22:29 -0700
committerjbzdarkid <jbzdarkid@gmail.com>2018-11-02 21:22:29 -0700
commite48ce4469cee270687e04bc1a2b91d3c2bba0789 (patch)
treea024c63f620805fb3c4eef0af6a8412e501f0efd /Source/Panel.h
parent5de975b03c7200cc66188a4b1a76e1213524975d (diff)
downloadwitness-tutorializer-e48ce4469cee270687e04bc1a2b91d3c2bba0789.tar.gz
witness-tutorializer-e48ce4469cee270687e04bc1a2b91d3c2bba0789.tar.bz2
witness-tutorializer-e48ce4469cee270687e04bc1a2b91d3c2bba0789.zip
arglbargl
Diffstat (limited to 'Source/Panel.h')
-rw-r--r--Source/Panel.h109
1 files changed, 76 insertions, 33 deletions
diff --git a/Source/Panel.h b/Source/Panel.h index fa3f750..4982f17 100644 --- a/Source/Panel.h +++ b/Source/Panel.h
@@ -6,50 +6,95 @@ class Decoration
6{ 6{
7public: 7public:
8 enum Shape { 8 enum Shape {
9 Stone = 100, 9 Stone = 0x100,
10 Star = 200, 10 Star = 0x200,
11 Poly = 400, 11 Poly = 0x400,
12 Eraser = 500, 12 Eraser = 0x500,
13 Triangle = 600, 13 Triangle = 0x600,
14 };
15 enum Color {
16 Black = 0x1,
17 White = 0x2,
18 Red = 0x3,
19 Blue = 0x4,
20 Green = 0x5,
14 }; 21 };
15 22
16 Decoration() = default; 23 static nlohmann::json to_json(int decoration) {
17 explicit Decoration(int shape); 24 nlohmann::json json = {};
18 25 int shape = decoration & 0x00000F00;
19 int GetValue(); 26 if (shape == Shape::Stone) json["type"] = "square";
27 if (shape == Shape::Star) json["type"] = "star";
28 if (shape == Shape::Poly) json["type"] = "poly";
29 if (shape == Shape::Eraser) json["type"] = "eraser";
30 if (shape == Shape::Triangle) json["type"] = "triangle";
31
32 int color = decoration & 0x0000000F;
33 if (color == Color::Black) json["color"] = "black";
34 if (color == Color::White) json["color"] = "white";
35 if (color == Color::Red) json["color"] = "red";
36 if (color == Color::Blue) json["color"] = "blue";
37 if (color == Color::Green) json["color"] = "green";
38
39 if (json.empty()) return false;
40 return json;
41 }
42};
20 43
21//private: 44enum IntersectionFlags {
22 int _shape; 45 IS_ENDPOINT = 0x1,
46 IS_STARTPOINT = 0x2,
47 IS_GAP = 0x10000,
48 HAS_DOT = 0x8,
49 DOT_IS_BLUE = 0x100,
50 DOT_IS_ORANGE = 0x200,
51 DOT_IS_INVISIBLE = 0x1000,
23}; 52};
24 53
25class Intersection 54class Endpoint {
26{
27public: 55public:
28 enum Flags { 56 enum Direction {
29 IS_ENDPOINT = 0x1, 57 LEFT,
30 IS_STARTPOINT = 0x2, 58 RIGHT,
31 IS_GAP = 0x10000, 59 UP,
32 HAS_DOT = 0x8, 60 DOWN
33 DOT_IS_BLUE = 0x100,
34 DOT_IS_ORANGE = 0x200,
35 DOT_IS_INVISIBLE = 0x1000,
36 }; 61 };
37 62
38 Intersection() = default; 63 Endpoint(int x, int y, Direction dir) {
39 explicit Intersection(float x, float y, int flags); 64 _x = x;
65 _y = y;
66 _dir = dir;
67 }
68
69 int GetX() {return _x;}
70 void SetX(int x) {_x = x;}
71 int GetY() {return _y;}
72 void SetY(int y) {_y = y;}
73 Direction GetDir() {return _dir;}
74 void SetDir(Direction dir) {_dir = dir;}
75
76 nlohmann::json to_json() {
77 nlohmann::json json = {{"x", _x}, {"y", _y}};
78 if (_dir == LEFT) json["dir"] = "left";
79 if (_dir == RIGHT) json["dir"] = "right";
80 if (_dir == UP) json["dir"] = "up";
81 if (_dir == DOWN) json["dir"] = "down";
82 return json;
83 }
40 84
41 int GetValue(); 85private:
42 86 int _x, _y;
43// private: 87 Direction _dir;
44 float _x, _y;
45 int _flags;
46}; 88};
47 89
48class Panel 90class Panel
49{ 91{
50public: 92public:
51 explicit Panel(int id); 93 explicit Panel(int id);
94 // explicit Panel(nlohmann::json json);
95
52 void Write(int id); 96 void Write(int id);
97 nlohmann::json Serialize();
53 98
54 void Random(); 99 void Random();
55 100
@@ -72,14 +117,12 @@ private:
72 // TODO: Reflection data 117 // TODO: Reflection data
73 // TODO: Decoration colors 118 // TODO: Decoration colors
74 119
75
76 Memory _memory = Memory("witness64_d3d11.exe"); 120 Memory _memory = Memory("witness64_d3d11.exe");
77 121
78 int _width, _height; 122 int _width, _height;
79 123
80 std::vector<std::vector<Decoration>> _decorations; 124 std::vector<std::vector<int>> _grid;
81 std::vector<std::vector<Intersection>> _intersections; 125 std::vector<Endpoint> _endpoints;
82 std::vector<Intersection> _endpoints; 126 std::vector<std::pair<int ,int>> _startpoints;
83 std::vector<Intersection> _gaps;
84 int _style; 127 int _style;
85}; \ No newline at end of file 128}; \ No newline at end of file