系统设置二级菜单

This commit is contained in:
ckcz123 2020-11-04 11:53:28 +08:00
parent 5ac89601d6
commit 2c662a2b26
5 changed files with 276 additions and 109 deletions

View File

@ -290,6 +290,9 @@ actions.prototype._sys_keyDown_lockControl = function (keyCode) {
break;
case 'selectShop':
case 'switchs':
case 'switchs-sounds':
case 'switchs-display':
case 'switchs-action':
case 'notes':
case 'settings':
case 'syncSave':
@ -393,6 +396,15 @@ actions.prototype._sys_keyUp_lockControl = function (keyCode, altKey) {
case 'switchs':
this._keyUpSwitchs(keyCode);
break;
case 'switchs-sounds':
this._keyUpSwitchs_sounds(keyCode);
break;
case 'switchs-display':
this._keyUpSwitchs_display(keyCode);
break;
case 'switchs-action':
this._keyUpSwitchs_action(keyCode);
break;
case 'settings':
this._keyUpSettings(keyCode);
break;
@ -507,6 +519,9 @@ actions.prototype._sys_onmove_choices = function (x, y) {
if (core.status.event.data.type != 'choices') break;
case 'selectShop':
case 'switchs':
case 'switchs-sounds':
case 'switchs-display':
case 'switchs-action':
case 'notes':
case 'settings':
case 'syncSave':
@ -643,6 +658,15 @@ actions.prototype._sys_onclick_lockControl = function (x, y) {
case 'switchs':
this._clickSwitchs(x, y);
break;
case 'switchs-sounds':
this._clickSwitchs_sounds(x, y);
break;
case 'switchs-display':
this._clickSwitchs_display(x, y);
break;
case 'switchs-action':
this._clickSwitchs_action(x, y);
break;
case 'settings':
this._clickSettings(x, y);
break;
@ -1983,11 +2007,45 @@ actions.prototype._keyUpSL = function (keycode) {
////// 系统设置界面时的点击操作 //////
actions.prototype._clickSwitchs = function (x, y) {
var choices = core.status.event.ui.choices;
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
var selection = y - topIndex;
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return;
if (selection >= 0 && selection < choices.length) {
core.status.event.selection = selection;
switch (selection) {
case 0:
core.status.event.selection = 0;
return core.ui._drawSwitchs_sounds();
case 1:
core.status.event.selection = 0;
return core.ui._drawSwitchs_display();
case 2:
core.status.event.selection = 0;
return core.ui._drawSwitchs_action();
case 3:
core.status.event.selection = 0;
return core.ui._drawSettings();
}
}
}
////// 系统设置界面时,放开某个键的操作 //////
actions.prototype._keyUpSwitchs = function (keycode) {
if (keycode == 27 || keycode == 88) {
core.status.event.selection = 0;
core.ui._drawSettings();
return;
}
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSwitchs);
}
actions.prototype._clickSwitchs_sounds = function (x, y) {
var choices = core.status.event.ui.choices;
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
var selection = y - topIndex;
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) {
if (selection != 1 && selection != 2 && selection != 3 && selection != 4) return;
if (selection != 2) return;
}
if (selection >= 0 && selection < choices.length) {
var width = choices[selection].width;
@ -1996,63 +2054,33 @@ actions.prototype._clickSwitchs = function (x, y) {
core.status.event.selection = selection;
switch (selection) {
case 0:
return this._clickSwitchs_bgmSound();
return this._clickSwitchs_sounds_bgm();
case 1:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_userVolume(-1);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_userVolume(1);
return;
return this._clickSwitchs_sounds_se();
case 2:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_moveSpeed(-10);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_moveSpeed(10);
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_sounds_userVolume(-1);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_sounds_userVolume(1);
return;
case 3:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_floorChangeTime(-100);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_floorChangeTime(100);
return;
case 4:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_setSize(-1);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_setSize(1);
return;
case 5:
return this._clickSwitchs_displayEnemyDamage();
case 6:
return this._clickSwitchs_displayCriticalExtra();
case 7:
return this._clickSwitchs_potionNoRouting();
case 8:
return this._clickSwitchs_clickMove();
case 9:
return this._clickSwitchs_leftHandPrefer();
case 10:
core.status.event.selection = 0;
core.ui._drawSettings();
break;
core.ui._drawSwitchs();
return;
}
}
}
actions.prototype._clickSwitchs_bgmSound = function () {
var bgm = core.musicStatus.bgmStatus;
var sound = core.musicStatus.soundStatus;
if (bgm && sound) {
sound = false;
} else if (bgm && !sound) {
bgm = false;
sound = true;
} else if (!bgm && sound) {
sound = false;
} else {
bgm = true;
sound = true;
}
if (bgm != core.musicStatus.bgmStatus)
core.triggerBgm();
core.musicStatus.soundStatus = sound;
core.setLocalStorage('soundStatus', core.musicStatus.soundStatus);
core.ui._drawSwitchs();
actions.prototype._clickSwitchs_sounds_bgm = function () {
core.triggerBgm();
core.ui._drawSwitchs_sounds();
}
actions.prototype._clickSwitchs_userVolume = function (delta) {
actions.prototype._clickSwitchs_sounds_se = function () {
core.musicStatus.soundStatus = !core.musicStatus.soundStatus;
core.setLocalStorage('soundStatus', core.musicStatus.soundStatus);
core.ui._drawSwitchs_sounds();
}
actions.prototype._clickSwitchs_sounds_userVolume = function (delta) {
var value = Math.round(Math.sqrt(100 * core.musicStatus.userVolume));
if (value == 0 && delta < 0) return;
core.musicStatus.userVolume = core.clamp(Math.pow(value + delta, 2) / 100, 0, 1);
@ -2060,22 +2088,61 @@ actions.prototype._clickSwitchs_userVolume = function (delta) {
if (core.musicStatus.gainNode != null) core.musicStatus.gainNode.gain.value = core.musicStatus.userVolume;
if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume;
core.setLocalStorage('userVolume', core.musicStatus.userVolume);
core.ui._drawSwitchs();
core.ui._drawSwitchs_sounds();
}
actions.prototype._clickSwitchs_moveSpeed = function (delta) {
core.values.moveSpeed = core.clamp(core.values.moveSpeed + delta, 50, 200);
core.setLocalStorage("moveSpeed", core.values.moveSpeed);
core.ui._drawSwitchs();
actions.prototype._keyUpSwitchs_sounds = function (keycode) {
if (keycode == 27 || keycode == 88) {
core.status.event.selection = 0;
core.ui._drawSwitchs();
return;
}
if (keycode == 37) {
switch (core.status.event.selection) {
case 2: return this._clickSwitchs_sounds_userVolume(-1);
}
} else if (keycode == 39) {
switch (core.status.event.selection) {
case 2: return this._clickSwitchs_sounds_userVolume(1);
}
}
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSwitchs_sounds);
}
actions.prototype._clickSwitchs_floorChangeTime = function (delta) {
core.values.floorChangeTime = core.clamp(core.values.floorChangeTime + delta, 0, 2000);
core.setLocalStorage("floorChangeTime", core.values.floorChangeTime);
core.ui._drawSwitchs();
actions.prototype._clickSwitchs_display = function (x, y) {
var choices = core.status.event.ui.choices;
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
var selection = y - topIndex;
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) {
if (selection != 0) return;
}
if (selection >= 0 && selection < choices.length) {
var width = choices[selection].width;
var leftPos = (core.__PIXELS__ - width) / 2, rightPos = (core.__PIXELS__ + width) / 2;
var leftGrid = parseInt(leftPos / 32), rightGrid = parseInt(rightPos / 32) - 1;
core.status.event.selection = selection;
switch (selection) {
case 0:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_display_setSize(-1);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_display_setSize(1);
return;
case 1:
return this._clickSwitchs_display_enemyDamage();
case 2:
return this._clickSwitchs_display_critical();
case 3:
return this._clickSwitchs_display_extraDamage();
case 4:
return this._clickSwitchs_display_extraDamageType();
case 5:
core.status.event.selection = 1;
core.ui._drawSwitchs();
return;
}
}
}
actions.prototype._clickSwitchs_setSize = function (delta) {
actions.prototype._clickSwitchs_display_setSize = function (delta) {
var index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
if (index < 0) return;
index += delta;
@ -2087,84 +2154,140 @@ actions.prototype._clickSwitchs_setSize = function (delta) {
if (currentRatio > core.domStyle.ratio) {
core.drawTip("需刷新页面以调整UI清晰度");
}
core.ui._drawSwitchs();
core.ui._drawSwitchs_display();
}
actions.prototype._clickSwitchs_displayEnemyDamage = function () {
actions.prototype._clickSwitchs_display_enemyDamage = function () {
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
core.updateDamage();
core.setLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
core.ui._drawSwitchs();
core.ui._drawSwitchs_display();
}
actions.prototype._clickSwitchs_displayCriticalExtra = function () {
var critical = core.flags.displayCritical;
var extra = core.flags.displayExtraDamage;
if (critical && extra) {
extra = false;
} else if (critical && !extra) {
critical = false;
extra = true;
} else if (!critical && extra) {
critical = false;
extra = false;
} else {
critical = true;
extra = true;
}
core.flags.displayCritical = critical;
core.flags.displayExtraDamage = extra;
actions.prototype._clickSwitchs_display_critical = function () {
core.flags.displayCritical = !core.flags.displayCritical;
core.updateDamage();
core.setLocalStorage('critical', core.flags.displayCritical);
core.setLocalStorage('extraDamage', core.flags.displayExtraDamage);
core.ui._drawSwitchs();
core.setLocalStorage('critical', core.flags.displayExtraDamage);
core.ui._drawSwitchs_display();
}
actions.prototype._clickSwitchs_potionNoRouting = function () {
actions.prototype._clickSwitchs_display_extraDamage = function () {
core.flags.displayExtraDamage = !core.flags.displayExtraDamage;
core.updateDamage();
core.setLocalStorage('extraDamage', core.flags.displayExtraDamage);
core.ui._drawSwitchs_display();
}
actions.prototype._clickSwitchs_display_extraDamageType = function () {
core.flags.extraDamageType = (core.flags.extraDamageType + 1) % 3;
core.updateDamage();
core.setLocalStorage('extraDamageType', core.flags.extraDamageType);
core.ui._drawSwitchs_display();
}
actions.prototype._keyUpSwitchs_display = function (keycode) {
if (keycode == 27 || keycode == 88) {
core.status.event.selection = 0;
core.ui._drawSwitchs();
return;
}
if (keycode == 37) {
switch (core.status.event.selection) {
case 0: return this._clickSwitchs_display_setSize(-1);
}
} else if (keycode == 39) {
switch (core.status.event.selection) {
case 0: return this._clickSwitchs_display_setSize(1);
}
}
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSwitchs_display);
}
actions.prototype._clickSwitchs_action = function (x, y) {
var choices = core.status.event.ui.choices;
var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0);
var selection = y - topIndex;
if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) {
if (selection != 0 && selection != 1) return;
}
if (selection >= 0 && selection < choices.length) {
var width = choices[selection].width;
var leftPos = (core.__PIXELS__ - width) / 2, rightPos = (core.__PIXELS__ + width) / 2;
var leftGrid = parseInt(leftPos / 32), rightGrid = parseInt(rightPos / 32) - 1;
core.status.event.selection = selection;
switch (selection) {
case 0:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_action_moveSpeed(-10);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_action_moveSpeed(10);
return;
case 1:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_action_floorChangeTime(-100);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_action_floorChangeTime(100);
case 2:
return this._clickSwitchs_action_potionNoRouting();
case 3:
return this._clickSwitchs_action_clickMove();
case 4:
return this._clickSwitchs_action_leftHandPrefer();
case 5:
core.status.event.selection = 2;
core.ui._drawSwitchs();
return;
}
}
}
actions.prototype._clickSwitchs_action_moveSpeed = function (delta) {
core.values.moveSpeed = core.clamp(core.values.moveSpeed + delta, 50, 200);
core.setLocalStorage("moveSpeed", core.values.moveSpeed);
core.ui._drawSwitchs_action();
}
actions.prototype._clickSwitchs_action_floorChangeTime = function (delta) {
core.values.floorChangeTime = core.clamp(core.values.floorChangeTime + delta, 0, 2000);
core.setLocalStorage("floorChangeTime", core.values.floorChangeTime);
core.ui._drawSwitchs_action();
}
actions.prototype._clickSwitchs_action_potionNoRouting = function () {
if (core.hasFlag('__potionNoRouting__')) core.removeFlag('__potionNoRouting__');
else core.setFlag('__potionNoRouting__', true);
core.ui._drawSwitchs();
core.ui._drawSwitchs_action();
}
actions.prototype._clickSwitchs_clickMove = function () {
actions.prototype._clickSwitchs_action_clickMove = function () {
if (core.hasFlag('__noClickMove__')) core.removeFlag('__noClickMove__');
else core.setFlag('__noClickMove__', true);
core.ui._drawSwitchs();
core.ui._drawSwitchs_action();
}
actions.prototype._clickSwitchs_leftHandPrefer = function () {
actions.prototype._clickSwitchs_action_leftHandPrefer = function () {
core.flags.leftHandPrefer = !core.flags.leftHandPrefer;
core.setLocalStorage('leftHandPrefer', core.flags.leftHandPrefer);
if (core.flags.leftHandPrefer) {
core.myconfirm("左手模式已开启!\n此模式下WASD将用于移动勇士IJKL对应于原始的WASD进行存读档等操作。")
}
core.ui._drawSwitchs();
core.ui._drawSwitchs_action();
}
////// 系统设置界面时,放开某个键的操作 //////
actions.prototype._keyUpSwitchs = function (keycode) {
actions.prototype._keyUpSwitchs_action = function (keycode) {
if (keycode == 27 || keycode == 88) {
core.status.event.selection = 0;
core.ui._drawSettings();
core.ui._drawSwitchs();
return;
}
if (keycode == 37) {
switch (core.status.event.selection) {
case 1: return this._clickSwitchs_userVolume(-1);
case 2: return this._clickSwitchs_moveSpeed(-10);
case 3: return this._clickSwitchs_floorChangeTime(-100);
case 4: return this._clickSwitchs_setSize(-1);
case 0: return this._clickSwitchs_action_moveSpeed(-10);
case 1: return this._clickSwitchs_action_floorChangeTime(-100);
}
} else if (keycode == 39) {
switch (core.status.event.selection) {
case 1: return this._clickSwitchs_userVolume(1);
case 2: return this._clickSwitchs_moveSpeed(10);
case 3: return this._clickSwitchs_floorChangeTime(100);
case 4: return this._clickSwitchs_setSize(1);
case 0: return this._clickSwitchs_action_moveSpeed(10);
case 1: return this._clickSwitchs_action_floorChangeTime(100);
}
}
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSwitchs);
this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSwitchs_action);
}
////// 系统菜单栏界面时的点击操作 //////

View File

@ -1173,15 +1173,19 @@ control.prototype._updateDamage_extraDamage = function (floorId, onMap) {
for (var x=startX;x<endX;x++) {
for (var y=startY;y<endY;y++) {
if (core.noPass(x, y, floorId)) continue;
var alpha = 1;
if (core.noPass(x, y, floorId)) {
if (core.flags.extraDamageType == 2) alpha = 0;
else if (core.flags.extraDamageType == 1) alpha = 0.6;
}
var damage = core.status.checkBlock.damage[x+","+y]||0;
if (damage>0) { // 该点伤害
damage = core.formatBigNumber(damage, true);
core.status.damage.extraData.push({text: damage, px: 32*x+16, py: 32*(y+1)-14, color: '#ffaa33'});
core.status.damage.extraData.push({text: damage, px: 32*x+16, py: 32*(y+1)-14, color: '#ffaa33', alpha: alpha});
}
else { // 检查捕捉
if (core.status.checkBlock.ambush[x+","+y]) {
core.status.damage.extraData.push({text: '!', px: 32*x+16, py: 32*(y+1)-14, color: '#ffaa33'});
core.status.damage.extraData.push({text: '!', px: 32*x+16, py: 32*(y+1)-14, color: '#ffaa33', alpha: alpha});
}
}
}
@ -1239,7 +1243,10 @@ control.prototype._drawDamage_draw = function (ctx, onMap) {
if (px < -32 || px > core.__PIXELS__ + 32 || py < -32 || py > core.__PIXELS__ + 32)
return;
}
var alpha = cacheCtx.globalAlpha;
cacheCtx.globalAlpha = one.alpha;
core.fillBoldText(cacheCtx, one.text, px, py, one.color);
cacheCtx.globalAlpha = alpha;
});
cacheCtx.translate(0, 0);

View File

@ -326,6 +326,7 @@ core.prototype._init_sys_flags = function () {
core.flags.displayCritical = core.getLocalStorage('critical', core.flags.displayCritical);
core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage);
core.flags.leftHandPrefer = core.getLocalStorage('leftHandPrefer', false);
core.flags.extraDamageType = core.getLocalStorage('extraDamageType', 0);
// 行走速度
core.values.moveSpeed = core.getLocalStorage('moveSpeed', 100);
core.values.floorChangeTime = core.getLocalStorage('floorChangeTime', core.values.floorChangeTime);

View File

@ -235,6 +235,12 @@ events.prototype._gameOver_askRate = function (ending) {
}
if (ending == null) {
if (!core.hasSave(0)) {
core.ui.closePanel();
core.restart();
return;
}
core.status.event.selection = 0;
core.ui.drawConfirmBox("你想读取自动存档么?", function () {
core.ui.closePanel();

View File

@ -1775,19 +1775,49 @@ ui.prototype.drawWaiting = function(text) {
ui.prototype._drawSwitchs = function() {
core.status.event.id = 'switchs';
var choices = [
"音乐/音效: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]") + " "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
//显示为 0~10 十挡
"音效设置",
"显示设置",
"操作设置",
"返回主菜单"
];
this.drawChoices(null, choices);
}
ui.prototype._drawSwitchs_sounds = function () {
core.status.event.id = 'switchs-sounds';
var choices = [
"音乐: " + (core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"),
"音效: " + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
// 显示为 0~10 十挡
" < 音量:" + Math.round(Math.sqrt(100 * core.musicStatus.userVolume)) + " > ",
//数值越大耗时越长
"返回上一级"
];
this.drawChoices(null, choices);
}
ui.prototype._drawSwitchs_display = function () {
core.status.event.id = 'switchs-display';
var choices = [
" < 放缩:" + Math.max(core.domStyle.scale, 1) + "x > ",
"怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
"临界显伤: " + (core.flags.displayCritical ? "[ON]" : "[OFF]"),
"领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
"领域模式: " + (core.flags.extraDamageType == 2 ? "[最简]" : core.flags.extraDamageType == 1 ? "[半透明]" : "[完整]" ),
"返回上一级",
];
this.drawChoices(null, choices);
}
ui.prototype._drawSwitchs_action = function () {
core.status.event.id = 'switchs-action';
var choices = [
// 数值越大耗时越长
" < 步时:" + core.values.moveSpeed + " > ",
" < 转场:" + core.values.floorChangeTime + " > ",
" < 放缩:" + Math.max(core.domStyle.scale, 1) + "x > ",
"怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"),
"临界/领域: "+(core.flags.displayCritical ? "[ON]" : "[OFF]")+" "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
"血瓶绕路: "+(core.hasFlag('__potionNoRouting__') ? "[ON]":"[OFF]"),
"单击瞬移: "+(!core.hasFlag("__noClickMove__") ? "[ON]":"[OFF]"),
"左手模式: "+(core.flags.leftHandPrefer ? "[ON]":"[OFF]"),
"返回主菜单"
"返回上一级",
];
this.drawChoices(null, choices);
}