存档笔记

This commit is contained in:
ckcz123 2020-06-13 17:50:23 +08:00
parent 2ffc91fa30
commit bbbbf9b565
5 changed files with 185 additions and 4 deletions

View File

@ -3526,6 +3526,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "绘制帮助页面",
"!type": "fn()"
},
"drawNotes": {
"!doc": "绘制存档笔记",
"!type": "fn()"
},
"drawQuickShop": {
"!doc": "绘制快捷商店选择栏",
"!type": "fn()"

View File

@ -262,6 +262,7 @@ actions.prototype._sys_keyDown_lockControl = function (keyCode) {
break;
case 'selectShop':
case 'switchs':
case 'notes':
case 'settings':
case 'syncSave':
case 'syncSelect':
@ -367,6 +368,9 @@ actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
case 'settings':
this._keyUpSettings(keyCode);
break;
case 'notes':
this._keyUpNotes(keyCode);
break;
case 'syncSave':
this._keyUpSyncSave(keyCode);
break;
@ -472,6 +476,7 @@ actions.prototype._sys_onmove_choices = function (x, y) {
if (core.status.event.data.type != 'choices') break;
case 'selectShop':
case 'switchs':
case 'notes':
case 'settings':
case 'syncSave':
case 'syncSelect':
@ -637,6 +642,9 @@ actions.prototype._sys_onclick_lockControl = function (x, y) {
case 'text':
core.drawText();
break;
case 'notes':
this._clickNotes(x, y);
break;
case 'syncSave':
this._clickSyncSave(x, y);
break;
@ -2106,15 +2114,19 @@ actions.prototype._clickSettings = function (x, y) {
break;
case 3:
core.status.event.selection = 0;
core.ui.drawSyncSave();
core.ui.drawNotes();
break;
case 4:
core.status.event.selection = 0;
core.ui.drawGameInfo();
core.ui.drawSyncSave();
break;
case 5:
return core.confirmRestart();
core.status.event.selection = 0;
core.ui.drawGameInfo();
break;
case 6:
return core.confirmRestart();
case 7:
core.ui.closePanel();
break;
}
@ -2131,6 +2143,138 @@ actions.prototype._keyUpSettings = function (keycode) {
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSettings);
}
////// 存档笔记页面时的点击操作 //////
actions.prototype._clickNotes = function (x, y) {
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return;
var choices = core.status.event.ui.choices;
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
if (y >= topIndex && y < topIndex + choices.length) {
var selection = y - topIndex;
core.status.event.selection = selection;
switch (selection) {
case 0:
this._clickNotes_new();
break;
case 1:
this._clickNotes_show();
break;
case 2:
this._clickNotes_edit();
break;
case 3:
this._clickNotes_delete();
break;
case 4:
core.status.event.selection = 3;
core.ui.drawSettings();
break;
}
}
}
actions.prototype.__clickNotes_replaceText = function (data) {
data = (data || "").replace(/[\${}]/g, "_")
.replace(/(\t|\\t)\[.*?\]/g, "")
.replace("\b", "\\b")
.replace(/\\b\[.*?\]/g, "")
.replace(/\n|\\n/g, " ");
if (data.length > 45) data = data.substring(0, 43) + "...";
return data;
}
actions.prototype._clickNotes_new = function () {
core.status.hero.notes = core.status.hero.notes || [];
core.myprompt("请输入一段笔记不超过45字", null, function (data) {
data = core.actions.__clickNotes_replaceText(data);
if (data) {
core.status.hero.notes.push(data);
core.drawText("存档笔记新增成功!");
} else {
core.ui.closePanel();
}
});
}
actions.prototype._clickNotes_show = function () {
core.status.hero.notes = core.status.hero.notes || [];
var result = [];
for (var i = 0; i < core.status.hero.notes.length; i+=5) {
var v = [];
for (var j = i; j < i + 5 && j < core.status.hero.notes.length; ++j) {
v.push(j + 1 + ". " + this.__clickNotes_replaceText(core.status.hero.notes[j]));
}
result.push("\t[存档笔记]" + v.join("\n"));
}
if (result.length == 0) result.push("当前没有存档笔记,试着新增一个吧!");
core.drawText(result);
}
actions.prototype._clickNotes_edit = function () {
core.status.hero.notes = core.status.hero.notes || [];
if (core.status.hero.notes.length == 0) {
core.drawText("当前没有存档笔记,试着新增一个吧!");
} else {
core.myprompt("请输入要编辑的存档笔记编号1 - " + core.status.hero.notes.length + "", "1", function (data) {
if (!data) core.ui.closePanel();
var value = parseInt(data) || 0;
if (!value || value<=0 || value > core.status.hero.notes.length) {
core.drawText("不合法的输入!");
} else {
core.myprompt("请输入新内容不超过45字", core.status.hero.notes[value - 1], function (data) {
data = core.actions.__clickNotes_replaceText(data);
if (data) {
core.status.hero.notes[value - 1] = data;
core.drawText("存档笔记编辑成功!");
} else {
core.ui.closePanel();
}
});
}
})
}
}
actions.prototype._clickNotes_delete = function () {
core.status.hero.notes = core.status.hero.notes || [];
if (core.status.hero.notes.length == 0) {
core.drawText("当前没有存档笔记,无法删除!");
} else {
core.myprompt("请输入要删除的所有存档笔记编号,以逗号分隔。不填则代表删除全部笔记。", null, function (data) {
if (data == null) {
core.ui.closePanel();
return;
}
else if (!data) {
core.status.hero.notes = [];
core.drawText("所有存档笔记删除成功!");
} else {
data = data.split(",").map(function (one) { return parseInt(one); })
.filter(function (one) { return one && one > 0 && one <= core.status.hero.notes.length});
if (data.length == 0) {
core.drawText("没有要删除的笔记!");
} else {
data.sort(function (a, b) { return b - a;})
.forEach(function (index) {
core.status.hero.notes.splice(index - 1, 1);
});
core.drawText("已删除 " + data.sort().join(",") + " 号笔记");
}
}
})
}
}
////// 存档笔记页面时,放开某个键的操作 //////
actions.prototype._keyUpNotes = function (keycode) {
if (keycode == 27 || keycode == 88) {
core.status.event.selection = 3;
core.ui.drawSettings();
return;
}
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickNotes);
}
////// 同步存档界面时的点击操作 //////
actions.prototype._clickSyncSave = function (x, y) {
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return;

View File

@ -1744,7 +1744,17 @@ ui.prototype.drawSwitchs = function() {
ui.prototype.drawSettings = function () {
core.status.event.id = 'settings';
this.drawChoices(null, [
"系统设置", "虚拟键盘", "浏览地图", "同步存档", "游戏信息", "返回标题", "返回游戏"
"系统设置", "虚拟键盘", "浏览地图", "存档笔记", "同步存档", "游戏信息", "返回标题", "返回游戏"
]);
}
////// 绘制存档笔记 //////
ui.prototype.drawNotes = function () {
core.status.event.id = 'notes';
core.status.hero.notes = core.status.hero.notes || [];
core.lockControl();
this.drawChoices(null, [
"新增存档笔记", "查看存档笔记", "编辑存档笔记", "删除存档笔记", "返回上一页"
]);
}
@ -2724,6 +2734,7 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi
core.fillText('ui', title, x, y, highLight?'#FFD700':'#FFFFFF', this._buildFont(17, true));
core.strokeRect('ui', x-size/2, y+15, size, size, cho?strokeColor:'#FFFFFF', cho?6:2);
if (data && data.floorId) {
core.setTextAlign('ui', "center");
var map = core.maps.loadMap(data.maps, data.floorId);
core.extractBlocks(map, data.hero.flags);
core.drawThumbnail(data.floorId, map.blocks, {
@ -2735,6 +2746,22 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi
core.fillRect('ui', x-size/2, y+15, size, size, [0, 0, 0, 0.4]);
core.fillText('ui', data.hard, x, parseInt(y+22+size/2), data.hero.flags.__hardColor__ || 'red', this._buildFont(30,true));
}
// 绘制存档笔记
if (data.hero.notes && data.hero.notes.length > 0) {
core.setTextAlign('ui', 'left');
if (data.hero.notes.length >= 2) {
core.fillRect('ui', x-size/2, y + 15, size, 28, [0,0,0,0.3]);
core.fillBoldText('ui', data.hero.notes.length - 1 + ". " + data.hero.notes[data.hero.notes.length - 2].substring(0, 10),
x - size / 2 + 2, y + 15 + 12, '#FFFFFF', null, this._buildFont(10, false));
core.fillBoldText('ui', data.hero.notes.length + ". " + data.hero.notes[data.hero.notes.length - 1].substring(0, 10),
x - size / 2 + 2, y + 15 + 24);
} else {
core.fillRect('ui', x-size/2, y + 15, size, 16, [0,0,0,0.3]);
core.fillBoldText('ui', data.hero.notes.length + ". " + data.hero.notes[data.hero.notes.length - 1].substring(0, 10),
x - size / 2 + 2, y + 15 + 12, '#FFFFFF', null, this._buildFont(10, false));
}
}
core.setTextAlign('ui', "center");
var v = core.formatBigNumber(data.hero.hp,true)+"/"+core.formatBigNumber(data.hero.atk,true)+"/"+core.formatBigNumber(data.hero.def,true);
var v2 = "/"+core.formatBigNumber(data.hero.mdef,true);
if (core.calWidth('ui', v + v2, this._buildFont(10, false)) <= size) v += v2;

View File

@ -829,6 +829,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
case 72: // H打开帮助页面
core.ui.drawHelp();
break;
case 77: // M打开存档笔记
core.actions._clickNotes_show();
break;
case 78: // N重新开始
core.confirmRestart();
break;

3
runtime.d.ts vendored
View File

@ -2178,6 +2178,9 @@ declare class ui {
/** 绘制系统菜单栏 */
drawSettings(): void
/** 绘制存档笔记 */
drawNotes(): void
/** 绘制快捷商店选择栏 */
drawQuickShop(): void