用户调整游戏放缩

This commit is contained in:
ckcz123 2020-05-19 21:11:50 +08:00
parent 1567b736e1
commit 9143d687d4
6 changed files with 103 additions and 56 deletions

View File

@ -1919,7 +1919,7 @@ actions.prototype._clickSwitchs = function (x, y) {
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 != 2 && selection != 3 && selection != 4) return;
if (selection != 1 && selection != 2 && selection != 3 && selection != 4) return;
}
var width = choices[selection].width;
var leftPos = (core.__PIXELS__ - width) / 2, rightPos = (core.__PIXELS__ + width) / 2;
@ -1928,32 +1928,32 @@ actions.prototype._clickSwitchs = function (x, y) {
core.status.event.selection = selection;
switch (selection) {
case 0:
return this._clickSwitchs_bgm();
return this._clickSwitchs_bgmSound();
case 1:
return this._clickSwitchs_sound();
case 2:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_userVolume(-1);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_userVolume(1);
return;
case 3:
case 2:
if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_moveSpeed(-10);
if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_moveSpeed(10);
return;
case 4:
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_displayCritical();
return this._clickSwitchs_displayCriticalExtra();
case 7:
return this._clickSwitchs_displayExtraDamage();
case 8:
return this._clickSwitchs_potionNoRouting();
case 9:
case 8:
return this._clickSwitchs_clickMove();
case 10:
case 9:
core.status.event.selection = 0;
core.ui.drawSettings();
break;
@ -1961,13 +1961,23 @@ actions.prototype._clickSwitchs = function (x, y) {
}
}
actions.prototype._clickSwitchs_bgm = function () {
core.triggerBgm();
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_sound = function () {
core.musicStatus.soundStatus = !core.musicStatus.soundStatus;
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();
}
@ -1995,6 +2005,17 @@ actions.prototype._clickSwitchs_floorChangeTime = function (delta) {
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_setSize = function (delta) {
var index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
if (index < 0) return;
index += delta;
if (index < 0 || index >= core.domStyle.availableScale.length);
core.domStyle.scale = core.domStyle.availableScale[index];
core.setLocalStorage('scale', core.domStyle.scale);
core.resize();
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_displayEnemyDamage = function () {
core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;
core.updateDamage();
@ -2002,16 +2023,26 @@ actions.prototype._clickSwitchs_displayEnemyDamage = function () {
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_displayCritical = function () {
core.flags.displayCritical = !core.flags.displayCritical;
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;
core.updateDamage();
core.setLocalStorage('critical', core.flags.displayCritical);
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_displayExtraDamage = function () {
core.flags.displayExtraDamage = !core.flags.displayExtraDamage;
core.updateDamage();
core.setLocalStorage('extraDamage', core.flags.displayExtraDamage);
core.ui.drawSwitchs();
}

View File

@ -2679,17 +2679,28 @@ control.prototype._doResize = function (obj) {
control.prototype.resize = function() {
if (main.mode=='editor')return;
var clientWidth = main.dom.body.clientWidth, clientHeight = main.dom.body.clientHeight;
var CANVAS_WIDTH = core.__PIXELS__ + 6, BAR_WIDTH = Math.round(core.__PIXELS__ * 0.31) + 3;
var CANVAS_WIDTH = core.__PIXELS__, BAR_WIDTH = Math.round(core.__PIXELS__ * 0.31);
var BORDER = 3;
if (clientWidth >= CANVAS_WIDTH + BAR_WIDTH || (clientWidth > clientHeight && clientHeight < CANVAS_WIDTH)) {
if (clientWidth - 3 * BORDER >= CANVAS_WIDTH + BAR_WIDTH || (clientWidth > clientHeight && clientHeight - 2 * BORDER < CANVAS_WIDTH)) {
// 横屏
core.domStyle.isVertical = false;
core.domStyle.scale = Math.min(1, clientHeight / CANVAS_WIDTH);
core.domStyle.availableScale = [];
[1, 1.25, 1.5, 2].forEach(function (v) {
if (clientWidth - 3 * BORDER >= v*(CANVAS_WIDTH + BAR_WIDTH) && clientHeight - 2 * BORDER >= v * CANVAS_WIDTH) {
core.domStyle.availableScale.push(v); // 64x64
}
});
if (core.domStyle.availableScale.indexOf(core.domStyle.scale) < 0) {
core.domStyle.scale = Math.min(1, (clientHeight - 2 * BORDER) / CANVAS_WIDTH);
}
}
else {
// 竖屏
core.domStyle.isVertical = true;
core.domStyle.scale = Math.min(1, clientWidth / CANVAS_WIDTH);
core.domStyle.scale = Math.min(1, (clientWidth - 2 * BORDER) / CANVAS_WIDTH);
core.domStyle.availableScale = [];
}
var statusDisplayArr = this._shouldDisplayStatus(), count = statusDisplayArr.length;
@ -2705,15 +2716,16 @@ control.prototype.resize = function() {
clientWidth: clientWidth,
clientHeight: clientHeight,
CANVAS_WIDTH: CANVAS_WIDTH,
BORDER: BORDER,
BAR_WIDTH: BAR_WIDTH,
outerSize: CANVAS_WIDTH * core.domStyle.scale,
outerSize: CANVAS_WIDTH * core.domStyle.scale + 2 * BORDER,
globalAttribute: globalAttribute,
border: '3px ' + globalAttribute.borderColor + ' solid',
statusDisplayArr: statusDisplayArr,
count: count,
col: col,
statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 6 : 0,
toolbarHeightInVertical: core.domStyle.isVertical ? 44 * core.domStyle.scale + 6 : 0,
statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 2 * BORDER : 0,
toolbarHeightInVertical: core.domStyle.isVertical ? 44 * core.domStyle.scale + 2 * BORDER : 0,
is15x15: core.__SIZE__ == 15
};
@ -2730,7 +2742,7 @@ control.prototype._resize_gameGroup = function (obj) {
totalHeight = obj.outerSize + obj.statusBarHeightInVertical + obj.toolbarHeightInVertical
}
else {
totalWidth = (obj.CANVAS_WIDTH + obj.BAR_WIDTH) * core.domStyle.scale;
totalWidth = obj.outerSize + obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER;
totalHeight = obj.outerSize;
}
gameGroup.style.width = totalWidth + "px";
@ -2739,8 +2751,8 @@ control.prototype._resize_gameGroup = function (obj) {
gameGroup.style.top = (obj.clientHeight - totalHeight) / 2 + "px";
// floorMsgGroup
var floorMsgGroup = core.dom.floorMsgGroup;
floorMsgGroup.style.width = obj.outerSize - 6 + "px";
floorMsgGroup.style.height = totalHeight - 6 + "px";
floorMsgGroup.style.width = obj.outerSize - 2 * obj.BORDER + "px";
floorMsgGroup.style.height = totalHeight - 2 * obj.BORDER + "px";
floorMsgGroup.style.background = obj.globalAttribute.floorChangingBackground;
floorMsgGroup.style.color = obj.globalAttribute.floorChangingTextColor;
// musicBtn
@ -2754,7 +2766,7 @@ control.prototype._resize_gameGroup = function (obj) {
}
control.prototype._resize_canvas = function (obj) {
var innerSize = (obj.outerSize - 6) + "px";
var innerSize = (obj.CANVAS_WIDTH * core.domStyle.scale) + "px";
for (var i = 0; i < core.dom.gameCanvas.length; ++i)
core.dom.gameCanvas[i].style.width = core.dom.gameCanvas[i].style.height = innerSize;
core.dom.gif.style.width = core.dom.gif.style.height = innerSize;
@ -2779,8 +2791,6 @@ control.prototype._resize_canvas = function (obj) {
// resize next
main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px";
main.dom.next.style.borderBottomWidth = main.dom.next.style.borderRightWidth = 4 * core.domStyle.scale + "px";
}
control.prototype._resize_statusBar = function (obj) {
@ -2793,7 +2803,7 @@ control.prototype._resize_statusBar = function (obj) {
statusBar.style.fontSize = 16 * core.domStyle.scale + "px";
}
else {
statusBar.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
statusBar.style.width = (obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER) + "px";
statusBar.style.height = obj.outerSize + "px";
statusBar.style.background = obj.globalAttribute.statusLeftBackground;
// --- 计算文字大小
@ -2805,22 +2815,22 @@ control.prototype._resize_statusBar = function (obj) {
statusBar.style.borderBottom = core.domStyle.isVertical ? '' : obj.border;
// 自绘状态栏
if (core.domStyle.isVertical) {
core.dom.statusCanvas.style.width = obj.outerSize - 6 + "px";
core.dom.statusCanvas.width = core.__PIXELS__;
core.dom.statusCanvas.style.width = obj.CANVAS_WIDTH + "px";
core.dom.statusCanvas.width = obj.CANVAS_WIDTH;
core.dom.statusCanvas.style.height = obj.statusBarHeightInVertical - 3 + "px";
core.dom.statusCanvas.height = obj.col * 32 + 9;
}
else {
core.dom.statusCanvas.style.width = obj.BAR_WIDTH * core.domStyle.scale - 3 + "px";
core.dom.statusCanvas.width = obj.BAR_WIDTH - 3;
core.dom.statusCanvas.style.height = obj.outerSize - 6 + "px";
core.dom.statusCanvas.height = core.__PIXELS__;
core.dom.statusCanvas.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
core.dom.statusCanvas.width = obj.BAR_WIDTH;
core.dom.statusCanvas.style.height = obj.outerSize - 2 * obj.BORDER + "px";
core.dom.statusCanvas.height = obj.CANVAS_WIDTH;
}
core.dom.statusCanvas.style.display = core.flags.statusCanvas ? "block" : "none";
}
control.prototype._resize_status = function (obj) {
var statusHeight = (core.domStyle.isVertical ? 1 : (core.__HALF_SIZE__ + 3) / obj.count) * 32 * core.domStyle.scale * 0.8;
var statusHeight = (core.domStyle.isVertical ? 1 : (core.__HALF_SIZE__ + obj.BORDER) / obj.count) * 32 * core.domStyle.scale * 0.8;
// status
for (var i = 0; i < core.dom.status.length; ++i) {
var id = core.dom.status[i].id, style = core.dom.status[i].style;
@ -2828,7 +2838,7 @@ control.prototype._resize_status = function (obj) {
style.display = core.flags.statusCanvas || obj.statusDisplayArr.indexOf(id) < 0 ? 'none': 'block';
style.margin = 3 * core.domStyle.scale + "px";
style.height = statusHeight + "px";
style.maxWidth = obj.BAR_WIDTH * core.domStyle.scale * (core.domStyle.isVertical ? 0.95 : 1) + "px";
style.maxWidth = obj.BAR_WIDTH * core.domStyle.scale * (core.domStyle.isVertical ? 0.95 : 1) + obj.BORDER + "px";
if (obj.is15x15 && !core.domStyle.isVertical)
style.marginLeft = 11 * core.domStyle.scale + "px";
}
@ -2860,7 +2870,7 @@ control.prototype._resize_toolBar = function (obj) {
toolBar.style.background = obj.globalAttribute.toolsBackground;
}
else {
toolBar.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px";
toolBar.style.width = obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER + "px";
toolBar.style.top = 0.718 * obj.outerSize + "px";
toolBar.style.height = 0.281 * obj.outerSize + "px";
toolBar.style.background = 'transparent';

View File

@ -84,6 +84,7 @@ function core() {
// 样式
this.domStyle = {
scale: 1.0,
availableScale: [],
isVertical: false,
showStatusBar: true,
toolbarBtn: false,
@ -291,6 +292,10 @@ core.prototype._init_sys_flags = function () {
// 行走速度
core.values.moveSpeed = core.getLocalStorage('moveSpeed', 100);
core.values.floorChangeTime = core.getLocalStorage('floorChangeTime', 500);
core.domStyle.scale = core.getLocalStorage('scale', 1);
if (core.domStyle.scale != 1) {
core.resize();
}
}
core.prototype._init_platform = function () {

View File

@ -1655,16 +1655,15 @@ 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]"),
"音乐/音效: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]") + " "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"),
//显示为 0~10 十挡
" < 音量:" + Math.round(Math.sqrt(100 * core.musicStatus.userVolume)) + " > ",
//数值越大耗时越长
" < 步时:" + 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.flags.displayCritical ? "[ON]" : "[OFF]")+" "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
"血瓶绕路: "+(core.hasFlag('__potionNoRouting__') ? "[ON]":"[OFF]"),
"单击瞬移: "+(!core.hasFlag("__noClickMove__") ? "[ON]":"[OFF]"),
"返回主菜单"

View File

@ -74,7 +74,7 @@
color: #fff;
font-size: 0.6rem;
position: absolute;
top: 8%;
top: 10%;
left: 5%;
z-index: 15;
}

View File

@ -51,7 +51,7 @@
地图拉框选择复制剪切删除
额外素材区拖动选择一个区域
(已完成!) 素材替换
大屏幕下放大游戏界面
(已完成!) 大屏幕下放大游戏界面
(已完成!) 最近使用/最常使用的图块
(已完成!) loader并行加载
合并items.js
@ -60,6 +60,8 @@
(已完成!) 32x48的门
(已完成!) 难度分歧的图块颜色含SL界面
装备同时加属性和比例
removeMap和resumeMap
-------------
@ -93,7 +95,7 @@
(已完成!) 27. 勇士后退时跟随者很鬼畜,建议优化(每步聚集算是一种简陋的办法)
(不处理) 28. 勇士的移动帧只有2建议改为允许作者指定
(不处理) 29. 建议加一对“勇士开始抖动”和“勇士停止抖动”事件指令,来让勇士像图块一样原地抖动(即全局动画)。目前这个效果还只能通过隐藏勇士(或切换透明行走图)并转变图块/图层块来实现且只能用于事件处理中QAQ
30. 建议加一个“视角锁定”事件指令,从而允许用事件改变勇士位置、朝向或行走图时不会使视角重置到以其为中心,用于一些演出效果
(不处理) 30. 建议加一个“视角锁定”事件指令,从而允许用事件改变勇士位置、朝向或行走图时不会使视角重置到以其为中心,用于一些演出效果
(已完成!) 31. 楼层切换事件绿点一旦使用blockly编辑就会无视全塔属性的切换时间只能手动在表格中删除时间数据相关“楼层切换”事件指令也有这个问题有群友还希望这个默认时间能像步时和音量一样由玩家设定来节约拆塔时间。使用blockly编辑也无法做出“ignoretrue”的效果用来覆盖全塔属性的禁止穿透建议优化
(已完成!) 32. 关于CC的来回回档优化版据其称清空存档后会出现bug此外他使用了W键导致二倍斩失效了js的switch语句遇到duplicate cases居然不报错吗...
(已完成!) 33. 疑似已被CC修复楼传平面塔模式在记录离开位置时会错误地把读档也算作离开