自动放缩最大化
This commit is contained in:
parent
6a478f67d3
commit
518c139556
@ -3276,7 +3276,7 @@ control.prototype.resize = function () {
|
||||
core.domStyle.isVertical = false;
|
||||
|
||||
core.domStyle.availableScale = [];
|
||||
[1, 1.25, 1.5, 1.75, 2].forEach(function (v) {
|
||||
[1, 1.25, 1.5, 1.75, 2, 2.25, 2.5].forEach(function (v) {
|
||||
if (clientWidth - 3 * BORDER >= v * (CANVAS_WIDTH + BAR_WIDTH) && horizontalMaxRatio >= v) {
|
||||
core.domStyle.availableScale.push(v);
|
||||
}
|
||||
@ -3371,8 +3371,16 @@ control.prototype._resize_gameGroup = function (obj) {
|
||||
|
||||
control.prototype._resize_canvas = function (obj) {
|
||||
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;
|
||||
for (var i = 0; i < core.dom.gameCanvas.length; ++i) {
|
||||
var ctx = core.dom.gameCanvas[i].getContext('2d');
|
||||
// core.maps._setHDCanvasSize(ctx);
|
||||
core.resizeCanvas(ctx, core.__PIXELS__, core.__PIXELS__);
|
||||
if (core.status && core.status.maps) {
|
||||
core.redrawMap();
|
||||
core.drawHero();
|
||||
core.setWeather(core.animateFrame.weather.type, core.animateFrame.weather.level);
|
||||
}
|
||||
}
|
||||
core.dom.gif.style.width = core.dom.gif.style.height = innerSize;
|
||||
core.dom.gif2.style.width = core.dom.gif2.style.height = innerSize;
|
||||
core.dom.gameDraw.style.width = core.dom.gameDraw.style.height = innerSize;
|
||||
@ -3388,6 +3396,7 @@ control.prototype._resize_canvas = function (obj) {
|
||||
// resize dynamic canvas
|
||||
for (var name in core.dymCanvas) {
|
||||
var ctx = core.dymCanvas[name], canvas = ctx.canvas;
|
||||
core.maps._setHDCanvasSize(ctx, parseFloat(canvas.getAttribute('_width')), parseFloat(canvas.getAttribute('_height')));
|
||||
canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px";
|
||||
canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px";
|
||||
var scale = canvas.getAttribute('_scale');
|
||||
|
||||
24
main.js
24
main.js
@ -1,3 +1,4 @@
|
||||
/// <reference path="./runtime.d.ts" />
|
||||
function main () {
|
||||
|
||||
//------------------------ 用户修改内容 ------------------------//
|
||||
@ -236,6 +237,17 @@ main.prototype.init = function (mode, callback) {
|
||||
})
|
||||
main.core.init(coreData, callback);
|
||||
main.core.resize();
|
||||
// 自动放缩最大化
|
||||
try {
|
||||
if (main.core) {
|
||||
var index = main.core.domStyle.availableScale.indexOf(core.domStyle.scale);
|
||||
main.core.control.setDisplayScale(main.core.domStyle.availableScale.length - 1 - index);
|
||||
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) };
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -785,18 +797,6 @@ main.prototype.listen = function () {
|
||||
} catch (ee) { console.error(ee) }
|
||||
}
|
||||
|
||||
main.dom.enlargeBtn.onclick = function () {
|
||||
try {
|
||||
if (main.core) {
|
||||
main.core.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) };
|
||||
}
|
||||
|
||||
window.onblur = function () {
|
||||
if (main.core && main.core.control) {
|
||||
try {
|
||||
|
||||
14
runtime.d.ts
vendored
14
runtime.d.ts
vendored
@ -1638,13 +1638,18 @@ declare class maps {
|
||||
automaticRoute(destX: number, destY: number): Array<{ direction: direction, x: number, y: number }>
|
||||
|
||||
/**
|
||||
* 地图重绘
|
||||
* @example core.drawMap(); // 重绘当前地图,常用于更改贴图后或自动元件的刷新
|
||||
* 地图绘制
|
||||
* @example core.drawMap(); // 绘制当前地图
|
||||
* @param floorId 地图id,省略表示当前楼层
|
||||
* @param callback 重绘完毕后的回调函数,可选
|
||||
*/
|
||||
drawMap(floorId?: string, callback?: () => void): void
|
||||
|
||||
/**
|
||||
* 重绘地图
|
||||
*/
|
||||
redrawMap(): void
|
||||
|
||||
/**
|
||||
* 绘制背景层(含贴图,其与背景层矩阵的绘制顺序可通过复写此函数来改变)
|
||||
* @example core.drawBg(); // 绘制当前地图的背景层
|
||||
@ -2937,9 +2942,9 @@ type core = {
|
||||
|
||||
} & control & events & loader & enemys & items & maps & ui & utils & icons & actions & plugin
|
||||
|
||||
declare class main {
|
||||
type main = {
|
||||
readonly core: core
|
||||
readonly dom = core.dom
|
||||
readonly dom: { [key: string]: HTMLElement }
|
||||
/** 游戏版本,发布后会被随机,请勿使用该属性 */
|
||||
readonly version: string
|
||||
readonly useCompress: boolean
|
||||
@ -2957,6 +2962,7 @@ declare class main {
|
||||
log(e: string | Error, error: boolean): void
|
||||
}
|
||||
|
||||
declare let main: main
|
||||
declare let core: core
|
||||
declare let flags: { [x: string]: any }
|
||||
declare let hero = core.status.hero
|
||||
@ -108,6 +108,7 @@
|
||||
}
|
||||
|
||||
#startLogo {
|
||||
user-select: none;
|
||||
position: absolute;
|
||||
z-index: 290;
|
||||
left: 0;
|
||||
@ -121,6 +122,7 @@
|
||||
}
|
||||
|
||||
#startTitle {
|
||||
user-select: none;
|
||||
position: absolute;
|
||||
z-index: 280;
|
||||
}
|
||||
@ -215,6 +217,7 @@
|
||||
padding: 3px;
|
||||
}
|
||||
#statusBar .status{
|
||||
user-select: none;
|
||||
position: relative;
|
||||
display: block;
|
||||
float: left;
|
||||
@ -227,10 +230,12 @@
|
||||
max-height: 1.6em;
|
||||
}
|
||||
#statusBar span{
|
||||
user-select: none;
|
||||
font: bold italic 1.1em Verdana;
|
||||
display: inline;
|
||||
}
|
||||
#statusBar p {
|
||||
user-select: none;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 60%;
|
||||
@ -256,6 +261,7 @@
|
||||
}
|
||||
|
||||
p#hard {
|
||||
user-select: none;
|
||||
width: 6em;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
@ -267,6 +273,7 @@ p#hard {
|
||||
}
|
||||
|
||||
span#poison, span#weak, span#curse, span#pickaxe, span#bomb, span#fly {
|
||||
user-select: none;
|
||||
font-style: normal;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user