about summary refs log tree commit diff stats
path: root/Source/Panel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Panel.cpp')
-rw-r--r--Source/Panel.cpp16
1 files changed, 2 insertions, 14 deletions
diff --git a/Source/Panel.cpp b/Source/Panel.cpp index c0fb7ec..ea65142 100644 --- a/Source/Panel.cpp +++ b/Source/Panel.cpp
@@ -12,8 +12,7 @@ int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
12 return -1; 12 return -1;
13} 13}
14 14
15Panel::Panel(int id) { 15Panel::Panel(const std::shared_ptr<Memory>& memory, int id) : _memory(memory) {
16 _memory = std::make_shared<Memory>("witness64_d3d11.exe");
17 _width = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_X, 1)[0] - 1; 16 _width = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_X, 1)[0] - 1;
18 _height = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_Y, 1)[0] - 1; 17 _height = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_Y, 1)[0] - 1;
19 _grid.resize(_width); 18 _grid.resize(_width);
@@ -45,7 +44,7 @@ nlohmann::json Panel::Serialize() {
45 for (int x=0; x<_width; x++) { 44 for (int x=0; x<_width; x++) {
46 for (int y=0; y<_height; y++) { 45 for (int y=0; y<_height; y++) {
47 if (x%2 == 1 && y%2 == 1) { 46 if (x%2 == 1 && y%2 == 1) {
48 puzzle["grid"][x][y] = Decoration::to_json(_grid[x][y]); 47 puzzle["grid"][x][y] = Decoration_to_json(_grid[x][y]);
49 } else { 48 } else {
50 if (_grid[x][y] & IntersectionFlags::HAS_DOT) { 49 if (_grid[x][y] & IntersectionFlags::HAS_DOT) {
51 puzzle["dots"].emplace_back(nlohmann::json({{"x", x}, {"y", y}})); 50 puzzle["dots"].emplace_back(nlohmann::json({{"x", x}, {"y", y}}));
@@ -69,17 +68,6 @@ nlohmann::json Panel::Serialize() {
69 return puzzle; 68 return puzzle;
70} 69}
71 70
72void Panel::Random() {
73/*
74 for (auto& row : _decorations) {
75 for (auto& cell : row) {
76 cell.SetShape(cell.GetShape() & 0xFFFFFFF0);
77 cell.SetShape(cell.GetShape() | Random::RandInt(1, 10));
78 }
79 }
80*/
81}
82
83void Panel::ReadDecorations(int id) { 71void Panel::ReadDecorations(int id) {
84 int numDecorations = _memory->ReadPanelData<int>(id, NUM_DECORATIONS, 1)[0]; 72 int numDecorations = _memory->ReadPanelData<int>(id, NUM_DECORATIONS, 1)[0];
85 std::vector<int> decorations = _memory->ReadArray<int>(id, DECORATIONS, numDecorations); 73 std::vector<int> decorations = _memory->ReadArray<int>(id, DECORATIONS, numDecorations);