about summary refs log tree commit diff stats
path: root/Source/Panel.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Panel.h')
-rw-r--r--Source/Panel.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/Source/Panel.h b/Source/Panel.h index 565b4c3..b8e67df 100644 --- a/Source/Panel.h +++ b/Source/Panel.h
@@ -45,7 +45,7 @@ enum IntersectionFlags {
45 IS_ENDPOINT = 0x1, 45 IS_ENDPOINT = 0x1,
46 IS_STARTPOINT = 0x2, 46 IS_STARTPOINT = 0x2,
47 IS_GAP = 0x10000, 47 IS_GAP = 0x10000,
48 HAS_DOT = 0x20, 48 HAS_DOT = 0x40020,
49 DOT_IS_BLUE = 0x100, 49 DOT_IS_BLUE = 0x100,
50 DOT_IS_ORANGE = 0x200, 50 DOT_IS_ORANGE = 0x200,
51 DOT_IS_INVISIBLE = 0x1000, 51 DOT_IS_INVISIBLE = 0x1000,
@@ -110,7 +110,7 @@ public:
110 110
111private: 111private:
112 // For testing 112 // For testing
113 Panel(); 113 Panel() = default;
114 114
115 void ReadIntersections(int id); 115 void ReadIntersections(int id);
116 void WriteIntersections(int id); 116 void WriteIntersections(int id);
@@ -121,8 +121,11 @@ private:
121 // TODO: Decoration colors 121 // TODO: Decoration colors
122 122
123 std::tuple<int, int> loc_to_xy(int location) { 123 std::tuple<int, int> loc_to_xy(int location) {
124 int x = 2 * (location % ((_width + 1) / 2)); 124 int height2 = (_height - 1) / 2;
125 int y = (_height - 1) - 2 * (location / ((_width + 1) / 2)); 125 int width2 = (_width + 1) / 2;
126
127 int x = 2 * (location % width2);
128 int y = 2 * (height2 - location / width2);
126 return {x, y}; 129 return {x, y};
127 } 130 }
128 131
@@ -134,7 +137,24 @@ private:
134 return rowsFromBottom * width2 + x/2; 137 return rowsFromBottom * width2 + x/2;
135 } 138 }
136 139
137 Memory _memory = Memory("witness64_d3d11.exe"); 140 std::tuple<int, int> dloc_to_xy(int location) {
141 int height2 = (_height - 3) / 2;
142 int width2 = (_width - 1) / 2;
143
144 int x = 2 * (location % width2) + 1;
145 int y = 2 * (height2 - location / width2) + 1;
146 return {x, y};
147 }
148
149 int xy_to_dloc(int x, int y) {
150 int height2 = (_height - 3) / 2;
151 int width2 = (_width - 1) / 2;
152
153 int rowsFromBottom = height2 - (y - 1)/2;
154 return rowsFromBottom * width2 + (x - 1)/2;
155 }
156
157 std::shared_ptr<Memory> _memory;
138 158
139 int _width, _height; 159 int _width, _height;
140 160