Skip to content

Commit

Permalink
Remove Kanpen export support
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep committed Dec 31, 2024
1 parent 7ebe972 commit 758c254
Show file tree
Hide file tree
Showing 32 changed files with 14 additions and 1,066 deletions.
25 changes: 1 addition & 24 deletions src-ui/js/ui/PopupMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,17 +487,9 @@ ui.popupmgr.addpopup("urloutput", {
},

reset: function(px, py) {
var form = this.form,
pid = ui.puzzle.pid,
exists = pzpr.variety(pid).exists,
parser = pzpr.parser;
var parser = pzpr.parser;
var url = ui.puzzle.getURL(parser.URL_PZPRV3);
this.urlanchor.href = this.urlanchor.textContent = url;
form.kanpen.style.display = form.kanpen.nextSibling.style.display = exists.kanpen
? ""
: "none";
form.heyaapp.style.display = form.heyaapp.nextSibling.style.display =
pid === "heyawake" ? "" : "none";
},

show: function(px, py) {
Expand All @@ -513,17 +505,11 @@ ui.popupmgr.addpopup("urloutput", {
var url = "",
parser = pzpr.parser;
switch (e.target.name) {
case "kanpen":
url = ui.puzzle.getURL(parser.URL_KANPEN);
break;
case "pzprv3e":
url = ui.puzzle
.getURL(parser.URL_PZPRV3)
.replace(/\?(\w+)/, "?$1_edit");
break;
case "heyaapp":
url = ui.puzzle.getURL(parser.URL_HEYAAPP);
break;
}
this.urlanchor.href = this.urlanchor.textContent = url;
}
Expand Down Expand Up @@ -577,9 +563,6 @@ ui.popupmgr.addpopup("filesave", {
},
reset: function() {
/* ファイル形式選択オプション */
var ispencilbox = pzpr.variety(ui.puzzle.pid).exists.pencilbox;
this.form.filetype.options[1].disabled = !ispencilbox;
this.form.filetype.options[2].disabled = !ispencilbox;
var parser = pzpr.parser;
this.form.ta.value = ui.puzzle.getFileData(parser.FILE_PZPR, {});
this.form.ta2.value = this.form.ta.value.replace(/\n/g, "/");
Expand Down Expand Up @@ -637,12 +620,6 @@ ui.popupmgr.addpopup("filesave", {
filetype = parser.FILE_PZPR,
option = {};
switch (form.filetype.value) {
case "filesave2":
filetype = parser.FILE_PBOX;
break;
case "filesave4":
filetype = parser.FILE_PBOX_XML;
break;
case "filesave3":
filetype = parser.FILE_PZPR;
option.history = true;
Expand Down
4 changes: 0 additions & 4 deletions src-ui/p.html
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,6 @@ <h2 id="title2">読み込み中です...</h2>
<form name="urloutput">
<a id="urlanchor" class="urlanchor" target="_blank"></a>
<br>
<button type="button" class="btn" data-button-exec="urloutput" name="kanpen" >__urloutput.kanpen__</button><br>
<button type="button" class="btn" data-button-exec="urloutput" name="heyaapp">__urloutput.heyaapp__</button><br>
<button type="button" class="btn" data-button-exec="urloutput" name="pzprv3e">__urloutput.pzprv3e__</button><br>
<br>
<button type="button" class="btn" data-button-exec="close">__close__</button>
Expand Down Expand Up @@ -603,8 +601,6 @@ <h2 id="title2">読み込み中です...</h2>
<span>__filesave.format__</span>
<select name="filetype" data-change-exec="changefilename">
<option value="filesave">__filesave.format.pzprv3__</option>
<option value="filesave2">__filesave.format.penciltxt__</option>
<option value="filesave4">__filesave.format.pencilxml__</option>
</select>
<br>
<span>__filesave.filename__</span>
Expand Down
4 changes: 0 additions & 4 deletions src-ui/res/p.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,12 @@
"urlinput.title": "Load from URL",
"urlinput.submit": "Load",
"urloutput.title": "Export URL",
"urloutput.kanpen": "Change to Kanpen URL",
"urloutput.heyaapp": "Change to Heyawake-Applet URL",
"urloutput.pzprv3e": "Change to PUZ-PRE v3 Re-Edit URL",
"fileopen.title": "Open File",
"fileopen.choose": "Choose file",
"filesave.title": "Save File",
"filesave.format": "File format",
"filesave.format.pzprv3": "Puz-Pre v3 format",
"filesave.format.penciltxt": "Pencilbox Text format",
"filesave.format.pencilxml": "Pencilbox XML format",
"filesave.filename": "Filename",
"filesave.submit": "Save",
"filesave.invalid": "The filename contains invalid characters.",
Expand Down
4 changes: 0 additions & 4 deletions src-ui/res/p.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,12 @@
"urlinput.title": "URL入力",
"urlinput.submit": "読み込む",
"urloutput.title": "URL出力",
"urloutput.kanpen": "カンペンのURLを出力する",
"urloutput.heyaapp": "へやわけアプレットのURLを出力する",
"urloutput.pzprv3e": "ぱずぷれv3の再編集用URLを出力する",
"fileopen.title": "ファイルを開く",
"fileopen.choose": "ファイル選択",
"filesave.title": "ファイルを保存する",
"filesave.format": "ファイル形式",
"filesave.format.pzprv3": "ファイル形式",
"filesave.format.penciltxt": "pencilbox形式",
"filesave.format.pencilxml": "pencilbox XML形式",
"filesave.filename": "ファイル名",
"filesave.submit": "保存",
"filesave.invalid": "ファイル名として使用できない文字が含まれています。",
Expand Down
36 changes: 1 addition & 35 deletions src/puzzle/Encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ pzpr.classmgr.makeCommon({
bd = puzzle.board;
var pzl = new pzpr.parser.URLData("", mode);

type =
type || pzl.URL_PZPRV3; /* type===pzl.URL_AUTO(0)もまとめて変換する */
if (type === pzl.URL_KANPEN && pid === "lits") {
type = pzl.URL_KANPENP;
}
type = type || pzl.URL_PZPRV3;

this.outpflag = null;
var variant = puzzle.getConfig("variant");
Expand All @@ -109,30 +105,6 @@ pzpr.classmgr.makeCommon({
this.outbstr = lines.join("/");
break;

case pzl.URL_PZPRAPP:
throw Error("no implementation");

case pzl.URL_KANPENP:
if (!puzzle.info.exists.kanpen) {
throw Error("no implementation");
}
this.encodePzpr(pzl.URL_PZPRAPP);
this.outpflag = this.outpflag || "";
break;

case pzl.URL_KANPEN:
this.fio = new puzzle.klass.FileIO();
this.encodeKanpen();
this.outbstr = this.fio.datastr
.replace(/\r?\n/g, "/")
.replace(/ /g, "_");
this.fio = null;
break;

case pzl.URL_HEYAAPP:
this.encodeHeyaApp();
break;

default:
throw Error("invalid URL Type");
}
Expand All @@ -158,14 +130,8 @@ pzpr.classmgr.makeCommon({
decodeKanpen: function() {
throw Error("no implementation");
},
encodeKanpen: function() {
throw Error("no implementation");
},
decodeHeyaApp: function() {
throw Error("no implementation");
},
encodeHeyaApp: function() {
throw Error("no implementation");
}
}
});
86 changes: 1 addition & 85 deletions src/puzzle/FileData.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@

this.filever = 0;
this.datastr = "";
if (filetype === pzl.FILE_PBOX_XML) {
this.xmldoc = new DOMParser().parseFromString(
'<?xml version="1.0" encoding="utf-8" ?><puzzle />',
"text/xml"
);
var puzzlenode = this.xmldoc.querySelector("puzzle");
puzzlenode.appendChild(this.createXMLNode("board"));
puzzlenode.appendChild(this.createXMLNode("answer"));
}

// メイン処理
switch (filetype) {
Expand All @@ -104,14 +95,6 @@
}
break;

case pzl.FILE_PBOX:
this.kanpenSave();
break;

case pzl.FILE_PBOX_XML:
this.kanpenSaveXML();
break;

default:
throw Error("invalid filetype");
}
Expand All @@ -120,11 +103,7 @@
pzl.filever = this.filever;
pzl.cols = bd.cols;
pzl.rows = bd.rows;
if (filetype !== pzl.FILE_PBOX_XML) {
pzl.body = this.datastr;
} else {
pzl.body = this.xmldoc;
}
pzl.body = this.datastr;
pzl.metadata.update(puzzle.metadata);
if (option.history && filetype === pzl.FILE_PZPR) {
pzl.history = puzzle.opemgr.encodeHistory({ time: !!option.time });
Expand All @@ -139,9 +118,7 @@
decodeData: throwNoImplementation,
encodeData: throwNoImplementation,
kanpenOpen: throwNoImplementation,
kanpenSave: throwNoImplementation,
kanpenOpenXML: throwNoImplementation,
kanpenSaveXML: throwNoImplementation,

//---------------------------------------------------------------------------
// fio.decodeTrial() 仮置きデータを復旧する
Expand Down Expand Up @@ -447,10 +424,6 @@
// fio.decodeCellXMLBoard() 配列で、個別文字列から個別セルの設定を行う (XML board用)
// fio.decodeCellXMLBrow() 配列で、個別文字列から個別セルの設定を行う (XML board用)
// fio.decodeCellXMLArow() 配列で、個別文字列から個別セルの設定を行う (XML answer用)
// fio.encodeCellXMLBoard() 個別セルデータから個別文字列の設定を行う (XML board用)
// fio.encodeCellXMLBrow() 個別セルデータから個別文字列の設定を行う (XML board用)
// fio.encodeCellXMLArow() 個別セルデータから個別文字列の設定を行う (XML answer用)
// fio.createXMLNode() 指定されたattributeを持つXMLのノードを作成する
//---------------------------------------------------------------------------
decodeCellXMLBoard: function(func) {
var nodes = this.xmldoc.querySelectorAll("board number");
Expand All @@ -465,37 +438,14 @@
}
}
},
encodeCellXMLBoard: function(func) {
var boardnode = this.xmldoc.querySelector("board");
var bd = this.board;
for (var i = 0; i < bd.cell.length; i++) {
var cell = bd.cell[i],
val = func(cell);
if (val !== null) {
boardnode.appendChild(
this.createXMLNode("number", {
r: ((cell.by / 2) | 0) + 1,
c: ((cell.bx / 2) | 0) + 1,
n: val
})
);
}
}
},

PBOX_ADJUST: 0,
decodeCellXMLBrow: function(func) {
this.decodeCellXMLrow_com(func, "board", "brow");
},
encodeCellXMLBrow: function(func) {
this.encodeCellXMLrow_com(func, "board", "brow");
},
decodeCellXMLArow: function(func) {
this.decodeCellXMLrow_com(func, "answer", "arow");
},
encodeCellXMLArow: function(func) {
this.encodeCellXMLrow_com(func, "answer", "arow");
},
decodeCellXMLrow_com: function(func, parentnodename, targetnodename) {
var rownodes = this.xmldoc.querySelectorAll(
parentnodename + " " + targetnodename
Expand All @@ -522,40 +472,6 @@
}
}
}
},
encodeCellXMLrow_com: function(func, parentnodename, targetnodename) {
var boardnode = this.xmldoc.querySelector(parentnodename);
var ADJ = this.PBOX_ADJUST;
var bd = this.board;
for (var by = 1 - ADJ; by <= bd.maxby; by += 2) {
var rownode = this.createXMLNode(targetnodename, {
row: (((by + ADJ) / 2) | 0) + 1
});
for (var bx = 1 - ADJ; bx <= bd.maxbx; bx += 2) {
var piece = bd.getobj(bx, by),
nodename = func(piece),
node;
if (nodename.match(/n(\d\d+)/) || nodename.match(/n(\-\d+)/)) {
node = this.createXMLNode("n", { v: RegExp.$1 });
} else if (nodename === "n0") {
node = this.createXMLNode("z");
} else {
node = this.createXMLNode(nodename);
}
rownode.appendChild(node);
}
boardnode.appendChild(rownode);
}
},

createXMLNode: function(name, attrs) {
var node = this.xmldoc.createElement(name);
if (!!attrs) {
for (var i in attrs) {
node.setAttribute(i, attrs[i]);
}
}
return node;
}
}
});
Expand Down
Loading

0 comments on commit 758c254

Please sign in to comment.