Skip to content

Commit

Permalink
sashikazune: Add directional aux marks
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep committed Aug 4, 2023
1 parent ac42ad0 commit afa8e8c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
63 changes: 62 additions & 1 deletion src/variety/loute.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,16 @@
"MouseEvent@sashikazune": {
inputModes: {
edit: ["number", "clear"],
play: ["border", "subline"]
play: ["diraux", "border", "subline"]
},
mouseinput_other: function() {
if (this.inputMode === "diraux") {
this.inputarrow_cell();
}
},
inputarrow_cell_main: function(cell, dir) {
var value = 1 << (dir + 1);
cell.setQsub(cell.qsub ^ value);
},
autoedit_func: "qnum",
autoplay_func: "border"
Expand Down Expand Up @@ -397,6 +406,7 @@
this.drawCircles();
} else {
this.drawQuesNumbers();
this.drawArrowAuxMarks();
}

this.drawBorderQsubs();
Expand Down Expand Up @@ -429,6 +439,55 @@
}
}
},
"Graphic@sashikazune": {
fontsizeratio: 0.75,
drawArrowAuxMarks: function() {
var g = this.vinc("cell_ticks", "auto");
g.lineWidth = (1 + this.cw / 40) | 0;
var size = this.cw * 0.15;
if (size < 3) {
size = 3;
}

for (var c = 0; c < this.board.cell.length; c++) {
var cell = this.board.cell[c];
var bx = cell.bx,
by = cell.by,
px = bx * this.bw,
py = by * this.bh;
var color = "rgb(127,127,255)";
g.strokeStyle = color;
var tickMods = [
[-1, 1],
[1, 1],
[-1, 0],
[1, 0]
];
for (var m = 0; m < tickMods.length; m++) {
g.vid = "ut_cell" + m + "_" + cell.id;

if (cell.qsub & (1 << (m + 2))) {
var xmult = tickMods[m][0],
isvert = tickMods[m][1];
var c1 = !isvert ? px : py,
c2 = !isvert ? py : px,
p1 = [c1 + xmult * this.bw - 1.0 * xmult * size, c2 + size],
p2 = [c1 + xmult * this.bw - 0.5 * xmult * size, c2],
p3 = [c1 + xmult * this.bw - 1.0 * xmult * size, c2 - size];
g.beginPath();
g.moveTo(p1[+!!isvert], p1[+!isvert]);
g.lineTo(p2[+!!isvert], p2[+!isvert]);
g.lineTo(p3[+!!isvert], p3[+!isvert]);
g.moveTo(p2[+!!isvert], p2[+!isvert]);
g.closePath();
g.stroke();
} else {
g.vhide();
}
}
}
}
},

//---------------------------------------------------------
// URLエンコード/デコード処理
Expand Down Expand Up @@ -620,10 +679,12 @@
decodeData: function() {
this.decodeCellQnum();
this.decodeBorderAns();
this.decodeCellQsub();
},
encodeData: function() {
this.encodeCellQnum();
this.encodeBorderAns();
this.encodeCellQsub();
}
},

Expand Down
16 changes: 15 additions & 1 deletion test/script/sashikazune.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,19 @@ ui.debug.addDebugData("sashikazune", {
"pzprv3/sashikazune/6/6/3 . . . . . /4 . . 3 4 5 /. . . . . . /. . . . . . /1 . 3 . . 2 /. . . . . . /0 0 1 1 1 /1 1 1 1 1 /1 0 1 1 1 /1 0 0 1 1 /0 1 0 0 1 /0 0 0 0 0 /1 1 0 0 0 0 /0 0 1 0 0 0 /0 1 1 0 0 0 /0 1 1 1 0 0 /1 1 1 1 1 0 /"
]
],
inputs: []
inputs: [
{
input: [
"newboard,2,1",
"playmode,diraux",
"mouse,left,1,1,3,1",
"mouse,left,1,1,1,3"
],
result: "pzprv3/sashikazune/1/2/. . /0 /40 0 /"
},
{
input: ["mouse,left,1,1,3,1"],
result: "pzprv3/sashikazune/1/2/. . /0 /8 0 /"
}
]
});

0 comments on commit afa8e8c

Please sign in to comment.