|
73 | 73 | }, |
74 | 74 |
|
75 | 75 | inputLine: function() { |
| 76 | + this.inputBunnyhop(); |
| 77 | + |
| 78 | + if (this.mouseend && this.notInputted()) { |
| 79 | + var cell = this.getcell(); |
| 80 | + if (!cell.isValid()) { |
| 81 | + return; |
| 82 | + } |
| 83 | + |
| 84 | + var dx = this.inputPoint.bx - cell.bx, |
| 85 | + dy = this.inputPoint.by - cell.by; |
| 86 | + |
| 87 | + if (dx < 0 && dy < 0) { |
| 88 | + cell.toggleLineHalf(16); |
| 89 | + } else if (dx > 0 && dy < 0) { |
| 90 | + cell.toggleLineHalf(32); |
| 91 | + } else if (dx < 0 && dy > 0) { |
| 92 | + cell.toggleLineHalf(48); |
| 93 | + } else if (dx > 0 && dy > 0) { |
| 94 | + cell.toggleLineHalf(64); |
| 95 | + } |
| 96 | + |
| 97 | + cell.draw(); |
| 98 | + } |
| 99 | + }, |
| 100 | + inputBunnyhop: function() { |
76 | 101 | var pos = this.getpos(0.35); |
77 | 102 | if (this.prevPos.equals(pos)) { |
78 | 103 | return; |
|
180 | 205 | } |
181 | 206 | }, |
182 | 207 | Cell: { |
| 208 | + toggleLineHalf: function(val) { |
| 209 | + // TODO merge lines, enforce single value etc. |
| 210 | + var newVal = this.qsub; |
| 211 | + |
| 212 | + var prev = this.qsub & (7 << 4); |
| 213 | + newVal &= ~(7 << 4); |
| 214 | + |
| 215 | + if (prev !== val) { |
| 216 | + newVal |= val; |
| 217 | + } |
| 218 | + this.setQsub(newVal); |
| 219 | + }, |
| 220 | + |
183 | 221 | posthook: { |
184 | 222 | ques: function(num) { |
185 | 223 | if (!num) { |
|
223 | 261 | this.drawBGCells(); |
224 | 262 | this.drawGrid(); |
225 | 263 | this.drawLines(); |
| 264 | + this.drawHalfLines(); |
226 | 265 | this.drawCaps(); |
227 | 266 | this.drawPekes(); |
228 | 267 | }, |
229 | 268 |
|
230 | 269 | repaintLines: function(blist) { |
231 | 270 | var xlist = blist.crossinside(); |
| 271 | + var clist = blist.cellinside(); |
232 | 272 |
|
233 | 273 | this.range.borders = blist; |
234 | 274 | this.range.crosses = xlist; |
| 275 | + this.range.cells = clist; |
235 | 276 | this.drawLines(); |
| 277 | + this.drawHalfLines(); |
236 | 278 | this.drawCaps(); |
237 | 279 |
|
238 | 280 | if (this.context.use.canvas) { |
239 | 281 | this.repaintParts(blist); |
| 282 | + this.repaintParts(clist); |
240 | 283 | this.repaintParts(xlist); |
241 | 284 | } |
242 | 285 | }, |
|
265 | 308 | return color; |
266 | 309 | }, |
267 | 310 |
|
| 311 | + drawHalfLines: function() { |
| 312 | + var g = this.vinc("halves"); |
| 313 | + var basewidth = Math.max(this.bw / 4, 2); |
| 314 | + |
| 315 | + var clist = this.range.cells; |
| 316 | + |
| 317 | + var dirs = [ |
| 318 | + [-1, -1], |
| 319 | + [1, -1], |
| 320 | + [-1, 1], |
| 321 | + [1, 1] |
| 322 | + ]; |
| 323 | + |
| 324 | + for (var i = 0; i < clist.length; i++) { |
| 325 | + var cell = clist[i]; |
| 326 | + g.vid = "c_half" + cell.id; |
| 327 | + |
| 328 | + var half = (cell.qsub >> 4) & 7; |
| 329 | + if (half) { |
| 330 | + var px = cell.bx * this.bw, |
| 331 | + py = cell.by * this.bh, |
| 332 | + addwidth = 0; |
| 333 | + |
| 334 | + if (cell.trial && this.puzzle.execConfig("irowake")) { |
| 335 | + addwidth = -basewidth / 2; |
| 336 | + } |
| 337 | + |
| 338 | + g.lineWidth = basewidth + addwidth; |
| 339 | + // TODO get color |
| 340 | + // TODO draw cap as well |
| 341 | + g.strokeStyle = this.linecolor; |
| 342 | + |
| 343 | + var dir = dirs[half - 1]; |
| 344 | + |
| 345 | + g.beginPath(); |
| 346 | + g.moveTo(px + this.bw * dir[0] * 0.2, py + this.bh * dir[1] * 0.2); |
| 347 | + g.lineTo(px + this.bw * dir[0], py + this.bh * dir[1]); |
| 348 | + g.stroke(); |
| 349 | + } else { |
| 350 | + g.vhide(); |
| 351 | + } |
| 352 | + } |
| 353 | + }, |
| 354 | + |
268 | 355 | drawCaps: function() { |
269 | 356 | var g = this.vinc("caps"); |
270 | 357 | g.strokeStyle = null; |
|
0 commit comments