fix:修复自动缩放炸录像的问题

This commit is contained in:
ShakeFlower 2025-03-01 00:00:33 +08:00
parent 7b9f5b29aa
commit d977075f34

123
main.js
View File

@ -195,7 +195,8 @@ function main () {
main.prototype.init = function (mode, callback) { main.prototype.init = function (mode, callback) {
for (var i = 0; i < main.dom.gameCanvas.length; i++) { for (var i = 0; i < main.dom.gameCanvas.length; i++) {
main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d'); main.canvas[main.dom.gameCanvas[i].id] =
main.dom.gameCanvas[i].getContext('2d');
} }
main.mode = mode; main.mode = mode;
@ -213,7 +214,7 @@ main.prototype.init = function (mode, callback) {
(function (span, str_) { (function (span, str_) {
span.onclick = function () { span.onclick = function () {
core.events.startGame(str_); core.events.startGame(str_);
} };
})(span, value.name || ''); })(span, value.name || '');
main.dom.levelChooseButtons.appendChild(span); main.dom.levelChooseButtons.appendChild(span);
}); });
@ -231,67 +232,83 @@ main.prototype.init = function (mode, callback) {
main.loadFloors(function () { main.loadFloors(function () {
var coreData = {}; var coreData = {};
["dom", "statusBar", "canvas", "images", "tilesets", "materials", [
"animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) { 'dom',
coreData[t] = main[t]; 'statusBar',
}) 'canvas',
'images',
'tilesets',
'materials',
'animates',
'bgms',
'sounds',
'floorIds',
'floors',
'floorPartitions'
].forEach(function (t) {
coreData[t] = main[t];
});
main.core.init(coreData, callback); main.core.init(coreData, callback);
main.core.resize(); main.core.resize();
// 自动放缩最大化 // 自动放缩最大化
if (core.getLocalStorage('autoScale') == null) { if (!main.replayChecking) {
core.setLocalStorage('autoScale', true); if (core.getLocalStorage('autoScale') == null) {
} core.setLocalStorage('autoScale', true);
if ( }
core.getLocalStorage('autoScale') && if (
!core.domStyle.isVertical core.getLocalStorage('autoScale') &&
) { !core.domStyle.isVertical
try { ) {
if (main.core) { try {
var index = if (main.core) {
main.core.domStyle.availableScale.indexOf( var index =
core.domStyle.scale main.core.domStyle.availableScale.indexOf(
core.domStyle.scale
);
main.core.control.setDisplayScale(
main.core.domStyle.availableScale.length -
1 -
index
); );
main.core.control.setDisplayScale( if (
main.core.domStyle.availableScale.length - !main.core.isPlaying() &&
1 - main.core.flags.enableHDCanvas
index ) {
); main.core.domStyle.ratio = Math.max(
if ( window.devicePixelRatio || 1,
!main.core.isPlaying() && main.core.domStyle.scale
main.core.flags.enableHDCanvas );
) { main.core.resize();
main.core.domStyle.ratio = Math.max(
window.devicePixelRatio || 1,
main.core.domStyle.scale
);
main.core.resize();
}
requestAnimationFrame(function () {
var style = getComputedStyle(
main.dom.gameGroup
);
var height = parseFloat(style.height);
if (height > window.innerHeight * 0.95) {
main.core.control.setDisplayScale(-1);
if (
!main.core.isPlaying() &&
main.core.flags.enableHDCanvas
) {
main.core.domStyle.ratio = Math.max(
window.devicePixelRatio || 1,
main.core.domStyle.scale
);
main.core.resize();
}
} }
}); requestAnimationFrame(function () {
var style = getComputedStyle(
main.dom.gameGroup
);
var height = parseFloat(style.height);
if (height > window.innerHeight * 0.95) {
main.core.control.setDisplayScale(-1);
if (
!main.core.isPlaying() &&
main.core.flags.enableHDCanvas
) {
main.core.domStyle.ratio = Math.max(
window.devicePixelRatio || 1,
main.core.domStyle.scale
);
main.core.resize();
}
}
});
}
} catch (e) {
console.error(e);
} }
} catch (e) { console.error(e) }; }
} }
}); });
}); });
}); });
} };
////// 动态加载所有核心JS文件 ////// ////// 动态加载所有核心JS文件 //////
main.prototype.loadJs = function (dir, loadList, callback) { main.prototype.loadJs = function (dir, loadList, callback) {