about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/wittle/puzzle.js5
-rw-r--r--app/assets/javascripts/wittle/serializer.js3
-rw-r--r--app/assets/javascripts/wittle/trace2.js23
-rw-r--r--app/assets/javascripts/wittle/utilities.js.erb4
-rw-r--r--ext/wittle_generator/Generate.cpp4
-rw-r--r--ext/wittle_generator/Panel.cpp10
-rw-r--r--ext/wittle_generator/Panel.h3
-rw-r--r--ext/wittle_generator/Serializer.h3
8 files changed, 45 insertions, 10 deletions
diff --git a/app/assets/javascripts/wittle/puzzle.js b/app/assets/javascripts/wittle/puzzle.js index a7ad10a..4d6b0fb 100644 --- a/app/assets/javascripts/wittle/puzzle.js +++ b/app/assets/javascripts/wittle/puzzle.js
@@ -35,9 +35,12 @@ window.Puzzle = class {
35 35
36 // If true, custom mechanics are displayed (and validated) in this puzzle. 36 // If true, custom mechanics are displayed (and validated) in this puzzle.
37 CUSTOM_MECHANICS: false, 37 CUSTOM_MECHANICS: false,
38 38
39 // If true, polyominos may be placed partially off of the grid as an intermediate solution step. 39 // If true, polyominos may be placed partially off of the grid as an intermediate solution step.
40 // OUT_OF_BOUNDS_POLY: false, 40 // OUT_OF_BOUNDS_POLY: false,
41
42 // If true, the symmetry line will be invisible.
43 INVISIBLE_SYMMETRY: false,
41 } 44 }
42 } 45 }
43 46
diff --git a/app/assets/javascripts/wittle/serializer.js b/app/assets/javascripts/wittle/serializer.js index e440569..1598d9b 100644 --- a/app/assets/javascripts/wittle/serializer.js +++ b/app/assets/javascripts/wittle/serializer.js
@@ -43,6 +43,7 @@ window.serializePuzzle = function(puzzle) {
43 if (puzzle.settings.FLASH_FOR_ERRORS) settingsFlags |= SETTINGS_FLAG_FFE 43 if (puzzle.settings.FLASH_FOR_ERRORS) settingsFlags |= SETTINGS_FLAG_FFE
44 if (puzzle.settings.FAT_STARTPOINTS) settingsFlags |= SETTINGS_FLAG_FS 44 if (puzzle.settings.FAT_STARTPOINTS) settingsFlags |= SETTINGS_FLAG_FS
45 if (puzzle.settings.CUSTOM_MECHANICS) settingsFlags |= SETTINGS_FLAG_CM 45 if (puzzle.settings.CUSTOM_MECHANICS) settingsFlags |= SETTINGS_FLAG_CM
46 if (puzzle.settings.INVISIBLE_SYMMETRY) settingsFlags |= SETTINGS_FLAG_IS
46 s.writeByte(settingsFlags) 47 s.writeByte(settingsFlags)
47 48
48 return s.str() 49 return s.str()
@@ -93,6 +94,7 @@ window.deserializePuzzle = function(data) {
93 FLASH_FOR_ERRORS: (settingsFlags & SETTINGS_FLAG_FFE) != 0, 94 FLASH_FOR_ERRORS: (settingsFlags & SETTINGS_FLAG_FFE) != 0,
94 FAT_STARTPOINTS: (settingsFlags & SETTINGS_FLAG_FS) != 0, 95 FAT_STARTPOINTS: (settingsFlags & SETTINGS_FLAG_FS) != 0,
95 CUSTOM_MECHANICS: (settingsFlags & SETTINGS_FLAG_CM) != 0, 96 CUSTOM_MECHANICS: (settingsFlags & SETTINGS_FLAG_CM) != 0,
97 INVISIBLE_SYMMETRY: (settingsFlags & SETTINGS_FLAG_IS) != 0,
96 } 98 }
97 99
98 s.destroy() 100 s.destroy()
@@ -342,5 +344,6 @@ var SETTINGS_FLAG_PP = 4
342var SETTINGS_FLAG_FFE = 8 344var SETTINGS_FLAG_FFE = 8
343var SETTINGS_FLAG_FS = 16 345var SETTINGS_FLAG_FS = 16
344var SETTINGS_FLAG_CM = 32 346var SETTINGS_FLAG_CM = 32
347var SETTINGS_FLAG_IS = 64
345 348
346}) 349})
diff --git a/app/assets/javascripts/wittle/trace2.js b/app/assets/javascripts/wittle/trace2.js index 01e4ccd..7a77564 100644 --- a/app/assets/javascripts/wittle/trace2.js +++ b/app/assets/javascripts/wittle/trace2.js
@@ -138,10 +138,18 @@ class PathSegment {
138 data.svg.insertBefore(this.symCirc, data.cursor) 138 data.svg.insertBefore(this.symCirc, data.cursor)
139 data.svg.insertBefore(this.symPoly2, data.cursor) 139 data.svg.insertBefore(this.symPoly2, data.cursor)
140 data.svg.insertBefore(this.symPillarCirc, data.cursor) 140 data.svg.insertBefore(this.symPillarCirc, data.cursor)
141 this.symPoly1.setAttribute('class', 'line-3 ' + data.svg.id) 141
142 this.symCirc.setAttribute('class', 'line-3 ' + data.svg.id) 142 if (data.puzzle.settings.INVISIBLE_SYMMETRY) {
143 this.symPoly2.setAttribute('class', 'line-3 ' + data.svg.id) 143 this.symPoly1.setAttribute('class', 'line-4 ' + data.svg.id)
144 this.symPillarCirc.setAttribute('class', 'line-3 ' + data.svg.id) 144 this.symCirc.setAttribute('class', 'line-4 ' + data.svg.id)
145 this.symPoly2.setAttribute('class', 'line-4 ' + data.svg.id)
146 this.symPillarCirc.setAttribute('class', 'line-4 ' + data.svg.id)
147 } else {
148 this.symPoly1.setAttribute('class', 'line-3 ' + data.svg.id)
149 this.symCirc.setAttribute('class', 'line-3 ' + data.svg.id)
150 this.symPoly2.setAttribute('class', 'line-3 ' + data.svg.id)
151 this.symPillarCirc.setAttribute('class', 'line-3 ' + data.svg.id)
152 }
145 153
146 this.symCirc.setAttribute('cx', data.symbbox.middle.x) 154 this.symCirc.setAttribute('cx', data.symbbox.middle.x)
147 this.symCirc.setAttribute('cy', data.symbbox.middle.y) 155 this.symCirc.setAttribute('cy', data.symbbox.middle.y)
@@ -345,6 +353,7 @@ function clearGrid(svg, puzzle) {
345 window.deleteElementsByClassName(svg, 'line-1') 353 window.deleteElementsByClassName(svg, 'line-1')
346 window.deleteElementsByClassName(svg, 'line-2') 354 window.deleteElementsByClassName(svg, 'line-2')
347 window.deleteElementsByClassName(svg, 'line-3') 355 window.deleteElementsByClassName(svg, 'line-3')
356 window.deleteElementsByClassName(svg, 'line-4')
348 puzzle.clearLines() 357 puzzle.clearLines()
349} 358}
350 359
@@ -506,7 +515,11 @@ window.onTraceStart = function(puzzle, pos, svg, start, symStart=null) {
506 515
507 data.symcursor = createElement('circle') 516 data.symcursor = createElement('circle')
508 svg.insertBefore(data.symcursor, data.cursor) 517 svg.insertBefore(data.symcursor, data.cursor)
509 data.symcursor.setAttribute('class', 'line-3 ' + data.svg.id) 518 if (data.puzzle.settings.INVISIBLE_SYMMETRY) {
519 data.symcursor.setAttribute('class', 'line-4 ' + data.svg.id)
520 } else {
521 data.symcursor.setAttribute('class', 'line-3 ' + data.svg.id)
522 }
510 data.symcursor.setAttribute('cx', symStart.getAttribute('cx')) 523 data.symcursor.setAttribute('cx', symStart.getAttribute('cx'))
511 data.symcursor.setAttribute('cy', symStart.getAttribute('cy')) 524 data.symcursor.setAttribute('cy', symStart.getAttribute('cy'))
512 data.symcursor.setAttribute('r', 12) 525 data.symcursor.setAttribute('r', 12)
diff --git a/app/assets/javascripts/wittle/utilities.js.erb b/app/assets/javascripts/wittle/utilities.js.erb index 487af6e..6bf3a17 100644 --- a/app/assets/javascripts/wittle/utilities.js.erb +++ b/app/assets/javascripts/wittle/utilities.js.erb
@@ -153,6 +153,10 @@ l('.line-3 {')
153l(' fill: ' + window.LINE_SECONDARY + ';') 153l(' fill: ' + window.LINE_SECONDARY + ';')
154l(' pointer-events: none;') 154l(' pointer-events: none;')
155l('}') 155l('}')
156l('.line-4 {')
157l(' display: none;')
158l(' pointer-events: none;')
159l('}')
156l('@keyframes line-success {to {fill: ' + window.LINE_SUCCESS + ';}}') 160l('@keyframes line-success {to {fill: ' + window.LINE_SUCCESS + ';}}')
157l('@keyframes line-fail {to {fill: ' + window.LINE_FAIL + ';}}') 161l('@keyframes line-fail {to {fill: ' + window.LINE_FAIL + ';}}')
158l('@keyframes error {to {fill: red;}}') 162l('@keyframes error {to {fill: red;}}')
diff --git a/ext/wittle_generator/Generate.cpp b/ext/wittle_generator/Generate.cpp index ed5f2f5..a5c0af9 100644 --- a/ext/wittle_generator/Generate.cpp +++ b/ext/wittle_generator/Generate.cpp
@@ -136,6 +136,10 @@ void Generate::initPanel() {
136 if (pathWidth != 1) 136 if (pathWidth != 1)
137 _panel->pathWidth = pathWidth; // Init path scale. "1" is considered the 137 _panel->pathWidth = pathWidth; // Init path scale. "1" is considered the
138 // default, and therefore means no change. 138 // default, and therefore means no change.
139
140 if (hasFlag(Config::WriteInvisible)) {
141 _panel->SetInvisibleSymmetry(true);
142 }
139} 143}
140 144
141// Place a specific symbol into the puzzle at the specified location. The 145// Place a specific symbol into the puzzle at the specified location. The
diff --git a/ext/wittle_generator/Panel.cpp b/ext/wittle_generator/Panel.cpp index 892d4cc..879d205 100644 --- a/ext/wittle_generator/Panel.cpp +++ b/ext/wittle_generator/Panel.cpp
@@ -225,9 +225,13 @@ std::string Panel::Write() {
225 } 225 }
226 226
227 serializer.writeInt(0); 227 serializer.writeInt(0);
228 serializer.writeByte(Serializer::NegationsCancelNegations | 228
229 Serializer::PrecisePolyominos | 229 char settings = Serializer::NegationsCancelNegations |
230 Serializer::FlashForErrors); 230 Serializer::PrecisePolyominos | Serializer::FlashForErrors;
231 if (_invisible_symmetry) {
232 settings |= Serializer::InvisibleSymmetry;
233 }
234 serializer.writeByte(settings);
231 235
232 return serializer.str(); 236 return serializer.str();
233} 237}
diff --git a/ext/wittle_generator/Panel.h b/ext/wittle_generator/Panel.h index b8dec2f..95832b5 100644 --- a/ext/wittle_generator/Panel.h +++ b/ext/wittle_generator/Panel.h
@@ -169,6 +169,8 @@ class Panel {
169 int get(int x, int y) { return _grid[x][y]; } 169 int get(int x, int y) { return _grid[x][y]; }
170 void set(int x, int y, int val) { _grid[x][y] = val; } 170 void set(int x, int y, int val) { _grid[x][y] = val; }
171 171
172 void SetInvisibleSymmetry(bool val) { _invisible_symmetry = val; }
173
172 std::string Write(); 174 std::string Write();
173 175
174 enum Style { 176 enum Style {
@@ -447,6 +449,7 @@ class Panel {
447 float minx, miny, maxx, maxy, unitWidth, unitHeight; 449 float minx, miny, maxx, maxy, unitWidth, unitHeight;
448 int _style; 450 int _style;
449 bool _resized; 451 bool _resized;
452 bool _invisible_symmetry = false;
450}; 453};
451 454
452#endif /* end of include guard: PANEL_H_FC471D68 */ 455#endif /* end of include guard: PANEL_H_FC471D68 */
diff --git a/ext/wittle_generator/Serializer.h b/ext/wittle_generator/Serializer.h index 86b262d..6eeb887 100644 --- a/ext/wittle_generator/Serializer.h +++ b/ext/wittle_generator/Serializer.h
@@ -56,7 +56,8 @@ class Serializer {
56 PrecisePolyominos = 4, 56 PrecisePolyominos = 4,
57 FlashForErrors = 8, 57 FlashForErrors = 8,
58 FatStartpoints = 16, 58 FatStartpoints = 16,
59 CustomMechanics = 32 59 CustomMechanics = 32,
60 InvisibleSymmetry = 64,
60 }; 61 };
61 62
62 enum GapType : char { GapNone = 0, GapBreak = 1, GapFull = 2 }; 63 enum GapType : char { GapNone = 0, GapBreak = 1, GapFull = 2 };