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