大地图绘制缩略图
This commit is contained in:
1 parent
bde409bae2
commit
3523358cba
15 files changed
+205
-133
No files matched your search
+3
-3
@@ -1211,11 +1211,11 @@ actions.prototype._clickViewMaps = function (x, y) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (x >= per && x <= this.LAST - per && y <= per - 1 && mh > this.SIZE) {
|
||||
if (x >= per && x <= this.LAST - per && y <= per - 1 && (!core.status.event.data.all && mh > this.SIZE)) {
|
||||
core.ui.drawMaps(index, cx, cy - 1);
|
||||
return;
|
||||
}
|
||||
if (x >= per && x <= this.LAST - per && y >= this.SIZE - per && mh > this.SIZE) {
|
||||
if (x >= per && x <= this.LAST - per && y >= this.SIZE - per && (!core.status.event.data.all && mh > this.SIZE)) {
|
||||
core.ui.drawMaps(index, cx, cy + 1);
|
||||
return;
|
||||
}
|
||||
@@ -2531,7 +2531,7 @@ actions.prototype._clickReplay = function (x, y) {
|
||||
|
||||
actions.prototype._clickReplay_fromBeginning = function () {
|
||||
core.ui.closePanel();
|
||||
core.startGame(core.status.hard, core.getFlag('__seed__'), core.clone(core.status.route));
|
||||
core.startGame(core.status.hard, core.getFlag('__seed__'), core.cloneArray(core.status.route));
|
||||
}
|
||||
|
||||
actions.prototype._clickReplay_fromLoad = function () {
|
||||
|
||||
+4
-4
@@ -1231,7 +1231,7 @@ control.prototype._drawDamage_draw = function (ctx, onMap) {
|
||||
core.fillBoldText(cacheCtx, one.text, px, py, one.color);
|
||||
});
|
||||
|
||||
core.setTextAlign(ctx, 'center');
|
||||
core.setTextAlign(cacheCtx, 'center');
|
||||
core.status.damage.extraData.forEach(function (one) {
|
||||
var px = one.px, py = one.py;
|
||||
if (onMap && core.bigmap.v2) {
|
||||
@@ -1270,7 +1270,7 @@ control.prototype.startReplay = function (list) {
|
||||
core.status.replay.replaying=true;
|
||||
core.status.replay.pausing=true;
|
||||
core.status.replay.speed=1.0;
|
||||
core.status.replay.toReplay = core.clone(list);
|
||||
core.status.replay.toReplay = core.cloneArray(list);
|
||||
core.status.replay.totalList = core.status.route.concat(list);
|
||||
core.status.replay.steps = 0;
|
||||
core.status.replay.save = [];
|
||||
@@ -1525,8 +1525,8 @@ control.prototype._replay_save = function () {
|
||||
if (core.status.replay.save.length == 30)
|
||||
core.status.replay.save.shift();
|
||||
core.status.replay.save.push({"data": core.saveData(), "replay": {
|
||||
"totalList": core.clone(core.status.replay.totalList),
|
||||
"toReplay": core.clone(core.status.replay.toReplay),
|
||||
"totalList": core.cloneArray(core.status.replay.totalList),
|
||||
"toReplay": core.cloneArray(core.status.replay.toReplay),
|
||||
"speed": core.status.replay.speed,
|
||||
"steps": core.status.replay.steps
|
||||
}});
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ events.prototype.startGame = function (hard, seed, route, callback) {
|
||||
|
||||
events.prototype._startGame_start = function (hard, seed, route, callback) {
|
||||
console.log('开始游戏');
|
||||
core.resetGame(core.firstData.hero, hard, null, core.clone(core.initStatus.maps));
|
||||
core.resetGame(core.firstData.hero, hard, null, core.cloneArray(core.initStatus.maps));
|
||||
core.setHeroLoc('x', -1);
|
||||
core.setHeroLoc('y', -1);
|
||||
|
||||
|
||||
+101
-59
@@ -313,14 +313,14 @@ maps.prototype.decompressMap = function (mapArr, floorId) {
|
||||
var mh = core.floors[floorId].height;
|
||||
var floorMap = this._processInvalidMap(core.floors[floorId].map, mw, mh);
|
||||
|
||||
if (!mapArr) return core.clone(floorMap);
|
||||
if (!mapArr) return core.cloneArray(floorMap);
|
||||
|
||||
for (var x = 0; x < mh; x++) {
|
||||
if (x >= mapArr.length) {
|
||||
mapArr.push(0);
|
||||
}
|
||||
if (mapArr[x] === 0) {
|
||||
mapArr[x] = core.clone(floorMap[x]);
|
||||
mapArr[x] = core.cloneArray(floorMap[x]);
|
||||
}
|
||||
else {
|
||||
for (var y = 0; y < mw; y++) {
|
||||
@@ -450,9 +450,9 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) {
|
||||
return core.status[name + "maps"][floorId];
|
||||
|
||||
var arr = (main.mode == 'editor' && !(window.editor && editor.uievent && editor.uievent.isOpen))
|
||||
? core.clone(editor[name + 'map']) : null;
|
||||
? core.cloneArray(editor[name + 'map']) : null;
|
||||
if (arr == null)
|
||||
arr = core.clone(core.floors[floorId][name + "map"] || []);
|
||||
arr = core.cloneArray(core.floors[floorId][name + "map"] || []);
|
||||
|
||||
for (var y = 0; y < height; ++y) {
|
||||
if (arr[y] == null) arr[y] = Array(width).fill(0);
|
||||
@@ -926,22 +926,24 @@ maps.prototype.drawBg = function (floorId, config) {
|
||||
var toDrawCtx = core.getContextByName(config.ctx);
|
||||
if (!toDrawCtx) return;
|
||||
|
||||
var cacheCtx = core.bigmap.cacheCanvas;
|
||||
cacheCtx.canvas.width = toDrawCtx.canvas.width;
|
||||
cacheCtx.canvas.height = toDrawCtx.canvas.height;
|
||||
if (config.onMap && core.bigmap.v2) cacheCtx.translate(32, 32);
|
||||
var cacheCtx = toDrawCtx;
|
||||
if (config.onMap) {
|
||||
cacheCtx = core.bigmap.cacheCanvas;
|
||||
cacheCtx.canvas.width = toDrawCtx.canvas.width;
|
||||
cacheCtx.canvas.height = toDrawCtx.canvas.height;
|
||||
if (core.bigmap.v2) cacheCtx.translate(32, 32);
|
||||
}
|
||||
this._drawBg_draw(floorId, toDrawCtx, cacheCtx, config);
|
||||
cacheCtx.translate(0, 0);
|
||||
if (config.onMap) cacheCtx.translate(0, 0);
|
||||
}
|
||||
|
||||
maps.prototype._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
|
||||
config.ctx = cacheCtx;
|
||||
var offset = config.onMap && core.bigmap.v2 ? -32 : 0;
|
||||
core.maps._drawBg_drawBackground(floorId, config);
|
||||
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
|
||||
core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap);
|
||||
core.maps._drawBgFgMap(floorId, 'bg', config);
|
||||
core.drawImage(toDrawCtx, cacheCtx.canvas, offset, offset);
|
||||
if (config.onMap) core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
|
||||
config.ctx = toDrawCtx;
|
||||
}
|
||||
|
||||
@@ -978,15 +980,18 @@ maps.prototype.drawEvents = function (floorId, blocks, config) {
|
||||
var toDrawCtx = core.getContextByName(config.ctx);
|
||||
if (!toDrawCtx) return;
|
||||
|
||||
var cacheCtx = core.bigmap.cacheCanvas;
|
||||
cacheCtx.canvas.width = toDrawCtx.canvas.width;
|
||||
cacheCtx.canvas.height = toDrawCtx.canvas.height;
|
||||
if (config.onMap && core.bigmap.v2) {
|
||||
cacheCtx.translate(32, 32);
|
||||
var cacheCtx = toDrawCtx;
|
||||
if (config.onMap) {
|
||||
cacheCtx = core.bigmap.cacheCanvas;
|
||||
cacheCtx.canvas.width = toDrawCtx.canvas.width;
|
||||
cacheCtx.canvas.height = toDrawCtx.canvas.height;
|
||||
if (core.bigmap.v2) cacheCtx.translate(32, 32);
|
||||
}
|
||||
|
||||
core.extractBlocks(floorId);
|
||||
if (!blocks) blocks = core.status.maps[floorId].blocks;
|
||||
if (!blocks) {
|
||||
core.extractBlocks(floorId);
|
||||
blocks = core.status.maps[floorId].blocks;
|
||||
}
|
||||
var arr = this._getMapArrayFromBlocks(blocks, core.floors[floorId].width, core.floors[floorId].height);
|
||||
|
||||
blocks.filter(function (block) {
|
||||
@@ -995,10 +1000,11 @@ maps.prototype.drawEvents = function (floorId, blocks, config) {
|
||||
core.maps._drawMap_drawBlockInfo(cacheCtx, block, core.maps.getBlockInfo(block), arr, config.onMap);
|
||||
});
|
||||
|
||||
var offset = config.onMap && core.bigmap.v2 ? -32 : 0;
|
||||
core.drawImage(toDrawCtx, cacheCtx.canvas, offset, offset);
|
||||
cacheCtx.translate(0, 0);
|
||||
if (config.onMap) core.status.autotileAnimateObjs.map = arr;
|
||||
if (config.onMap) {
|
||||
core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
|
||||
cacheCtx.translate(0, 0);
|
||||
core.status.autotileAnimateObjs.map = arr;
|
||||
}
|
||||
}
|
||||
|
||||
////// 绘制前景层 //////
|
||||
@@ -1017,21 +1023,23 @@ maps.prototype.drawFg = function (floorId, config) {
|
||||
var toDrawCtx = core.getContextByName(config.ctx);
|
||||
if (!toDrawCtx) return;
|
||||
|
||||
var cacheCtx = core.bigmap.cacheCanvas;
|
||||
cacheCtx.canvas.width = toDrawCtx.canvas.width;
|
||||
cacheCtx.canvas.height = toDrawCtx.canvas.height;
|
||||
if (config.onMap && core.bigmap.v2) cacheCtx.translate(32, 32);
|
||||
var cacheCtx = toDrawCtx;
|
||||
if (config.onMap) {
|
||||
cacheCtx = core.bigmap.cacheCanvas;
|
||||
cacheCtx.canvas.width = toDrawCtx.canvas.width;
|
||||
cacheCtx.canvas.height = toDrawCtx.canvas.height;
|
||||
if (core.bigmap.v2) cacheCtx.translate(32, 32);
|
||||
}
|
||||
this._drawFg_draw(floorId, toDrawCtx, cacheCtx, config);
|
||||
cacheCtx.translate(0, 0);
|
||||
if (config.onMap) cacheCtx.translate(0, 0);
|
||||
}
|
||||
|
||||
maps.prototype._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
|
||||
config.ctx = cacheCtx;
|
||||
var offset = config.onMap && core.bigmap.v2 ? -32 : 0;
|
||||
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
|
||||
core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap);
|
||||
core.maps._drawBgFgMap(floorId, 'fg', config);
|
||||
core.drawImage(toDrawCtx, cacheCtx.canvas, offset, offset);
|
||||
if (config.onMap) core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
|
||||
config.ctx = toDrawCtx;
|
||||
}
|
||||
|
||||
@@ -1067,11 +1075,11 @@ maps.prototype._drawBgFgMap = function (floorId, name, config) {
|
||||
var blur = false, alpha;
|
||||
if (eventArr != null && eventArr[y][x] != 0) {
|
||||
blur = true;
|
||||
alpha = ctx.globalAlpha;
|
||||
ctx.globalAlpha = 0.6;
|
||||
alpha = config.ctx.globalAlpha;
|
||||
config.ctx.globalAlpha = 0.6;
|
||||
}
|
||||
this._drawMap_drawBlockInfo(config.ctx, block, blockInfo, arr, config.onMap);
|
||||
if (blur) ctx.globalAlpha = alpha;
|
||||
if (blur) config.ctx.globalAlpha = alpha;
|
||||
}
|
||||
}
|
||||
if (config.onMap)
|
||||
@@ -1376,16 +1384,19 @@ maps.prototype._makeAutotileEdges = function () {
|
||||
// 此函数将绘制一个缩略图,floorId为目标floorId,blocks为地图的图块(可为null使用floorId对应默认的)
|
||||
// options为绘制选项(可为null),包括:
|
||||
// heroLoc: 勇士位置;heroIcon:勇士图标(默认当前勇士);damage:是否绘制显伤;flags:当前的flags(存读档时使用)
|
||||
// toDraw为要绘制到的信息(可为null,或为一个画布名),包括:
|
||||
// ctx:要绘制到的画布(名);x,y:起点横纵坐标(默认0);size:大小(默认416/480);
|
||||
// all:是否绘制全图(默认false);centerX,centerY:截取中心(默认为地图正中心)
|
||||
maps.prototype.drawThumbnail = function (floorId, blocks, options, toDraw) {
|
||||
maps.prototype.drawThumbnail = function (floorId, blocks, options) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
if (!floorId) return;
|
||||
options = options || {};
|
||||
if (typeof options == 'string' || options.canvas) options = {ctx: options};
|
||||
var ctx = options.ctx;
|
||||
// Step1:绘制到tempCanvas上
|
||||
this._drawThumbnail_drawTempCanvas(floorId, blocks, options);
|
||||
options.ctx = ctx;
|
||||
// Step2:从tempCanvas绘制到对应的画布上
|
||||
this._drawThumbnail_drawToTarget(floorId, toDraw);
|
||||
this._drawThumbnail_drawToTarget(floorId, options);
|
||||
}
|
||||
|
||||
maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, options) {
|
||||
@@ -1397,10 +1408,35 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option
|
||||
var height = core.floors[floorId].height;
|
||||
// 绘制到tempCanvas上面
|
||||
var tempCanvas = core.bigmap.tempCanvas;
|
||||
var tempWidth = width * 32, tempHeight = height * 32;
|
||||
tempCanvas.canvas.width = tempWidth;
|
||||
tempCanvas.canvas.height = tempHeight;
|
||||
tempCanvas.clearRect(0, 0, tempWidth, tempHeight);
|
||||
|
||||
// 如果是大地图模式?
|
||||
if (options.all) {
|
||||
// 计算比例
|
||||
var scaleX = core.__SIZE__ / width;
|
||||
var scaleY = core.__SIZE__ / height;
|
||||
tempCanvas.canvas.width = width * 32 * scaleX;
|
||||
tempCanvas.canvas.height = height * 32 * scaleY;
|
||||
tempCanvas.scale(scaleX, scaleY);
|
||||
} else if (width * height > core.bigmap.threshold) {
|
||||
options.v2 = true;
|
||||
tempCanvas.canvas.width = core.__PIXELS__;
|
||||
tempCanvas.canvas.height = core.__PIXELS__;
|
||||
var centerX = options.centerX, centerY = options.centerY;
|
||||
if (centerX == null) centerX = Math.floor(width / 2);
|
||||
if (centerY == null) centerY = Math.floor(height / 2);
|
||||
var offsetX = core.clamp(centerX - core.__HALF_SIZE__, 0, width - core.__SIZE__),
|
||||
offsetY = core.clamp(centerY - core.__HALF_SIZE__, 0, height - core.__SIZE__);
|
||||
tempCanvas.translate(-32 * offsetX, -32 * offsetY);
|
||||
} else {
|
||||
options.v2 = false;
|
||||
tempCanvas.canvas.width = width * 32;
|
||||
tempCanvas.canvas.height = height * 32;
|
||||
}
|
||||
options.ctx = tempCanvas;
|
||||
|
||||
// 地图过大的缩略图不绘制显伤
|
||||
if (width * height > (core.__SIZE__ + 2 * core.bigmap.extend) * (core.__SIZE__ + 2 * core.bigmap.extend))
|
||||
options.damage = false;
|
||||
|
||||
// --- 暂存 flags
|
||||
var hasHero = core.status.hero != null, flags = null;
|
||||
@@ -1410,48 +1446,49 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option
|
||||
core.status.hero.flags = options.flags;
|
||||
}
|
||||
|
||||
this._drawThumbnail_realDrawTempCanvas(floorId, blocks, options, tempCanvas);
|
||||
this._drawThumbnail_realDrawTempCanvas(floorId, blocks, options);
|
||||
|
||||
// --- 恢复 flags
|
||||
if (!hasHero) delete core.status.hero;
|
||||
else if (flags != null) core.status.hero.flags = flags;
|
||||
tempCanvas.setTransform(1, 0, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, options, tempCanvas) {
|
||||
maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, options) {
|
||||
// 缩略图:背景
|
||||
this.drawBg(floorId, tempCanvas);
|
||||
this.drawBg(floorId, options);
|
||||
// 缩略图:事件
|
||||
this.drawEvents(floorId, blocks, tempCanvas);
|
||||
this.drawEvents(floorId, blocks, options);
|
||||
// 缩略图:勇士
|
||||
if (options.heroLoc) {
|
||||
options.heroIcon = options.heroIcon || core.status.hero.image || 'hero.png';
|
||||
options.heroIcon = core.getMappedName(options.heroIcon);
|
||||
var icon = core.material.icons.hero[options.heroLoc.direction];
|
||||
var height = core.material.images.images[options.heroIcon].height / 4;
|
||||
core.drawImage(tempCanvas, core.material.images.images[options.heroIcon], icon.stop * 32, icon.loc * height, 32, height,
|
||||
core.drawImage(options.ctx, core.material.images.images[options.heroIcon], icon.stop * 32, icon.loc * height, 32, height,
|
||||
32 * options.heroLoc.x, 32 * options.heroLoc.y + 32 - height, 32, height);
|
||||
}
|
||||
// 缩略图:前景
|
||||
this.drawFg(floorId, tempCanvas);
|
||||
this.drawFg(floorId, options);
|
||||
// 缩略图:显伤
|
||||
if (options.damage)
|
||||
core.control.updateDamage(floorId, tempCanvas);
|
||||
if (options.damage && core.hasItem('book')) {
|
||||
core.updateCheckBlock(floorId);
|
||||
core.control.updateDamage(floorId, options.ctx);
|
||||
}
|
||||
}
|
||||
|
||||
maps.prototype._drawThumbnail_drawToTarget = function (floorId, toDraw) {
|
||||
if (toDraw == null) return;
|
||||
if (typeof toDraw == 'string' || toDraw.canvas) toDraw = {ctx: toDraw};
|
||||
var ctx = core.getContextByName(toDraw.ctx);
|
||||
maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
|
||||
var ctx = core.getContextByName(options.ctx);
|
||||
if (ctx == null) return;
|
||||
var x = toDraw.x || 0, y = toDraw.y || 0, size = toDraw.size || core.__PIXELS__;
|
||||
var x = options.x || 0, y = options.y || 0, size = options.size || core.__PIXELS__;
|
||||
var width = core.floors[floorId].width, height = core.floors[floorId].height;
|
||||
var centerX = toDraw.centerX, centerY = toDraw.centerY;
|
||||
var centerX = options.centerX, centerY = options.centerY;
|
||||
if (centerX == null) centerX = Math.floor(width / 2);
|
||||
if (centerY == null) centerY = Math.floor(height / 2);
|
||||
var tempCanvas = core.bigmap.tempCanvas, tempWidth = 32 * width, tempHeight = 32 * height;
|
||||
var tempCanvas = core.bigmap.tempCanvas;
|
||||
|
||||
// core.clearMap(ctx, x, y, size, size);
|
||||
if (toDraw.all) {
|
||||
if (options.all) {
|
||||
var tempWidth = tempCanvas.canvas.width, tempHeight = tempCanvas.canvas.height;
|
||||
// 绘制全景图
|
||||
if (tempWidth <= tempHeight) {
|
||||
var realHeight = size, realWidth = realHeight * tempWidth / tempHeight;
|
||||
@@ -1470,9 +1507,14 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, toDraw) {
|
||||
}
|
||||
else {
|
||||
// 只绘制可见窗口
|
||||
var offsetX = core.clamp(centerX - core.__HALF_SIZE__, 0, width - core.__SIZE__),
|
||||
offsetY = core.clamp(centerY - core.__HALF_SIZE__, 0, height - core.__SIZE__);
|
||||
core.drawImage(ctx, tempCanvas.canvas, offsetX * 32, offsetY * 32, core.__PIXELS__, core.__PIXELS__, x, y, size, size);
|
||||
if (options.v2) {
|
||||
core.drawImage(ctx, tempCanvas.canvas, 0, 0, core.__PIXELS__, core.__PIXELS__, x, y, size, size);
|
||||
} else {
|
||||
var offsetX = core.clamp(centerX - core.__HALF_SIZE__, 0, width - core.__SIZE__),
|
||||
offsetY = core.clamp(centerY - core.__HALF_SIZE__, 0, height - core.__SIZE__);
|
||||
core.drawImage(ctx, tempCanvas.canvas, offsetX * 32, offsetY * 32, core.__PIXELS__, core.__PIXELS__, x, y, size, size);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -2280,7 +2280,7 @@ ui.prototype.drawFly = function(page) {
|
||||
}
|
||||
var size = this.PIXEL - 143;
|
||||
core.strokeRect('ui', 20, 100, size, size, '#FFFFFF', 2);
|
||||
core.drawThumbnail(floorId, null, null, {ctx: 'ui', x: 20, y: 100, size: size});
|
||||
core.drawThumbnail(floorId, null, {ctx: 'ui', x: 20, y: 100, size: size});
|
||||
}
|
||||
|
||||
////// 绘制中心对称飞行器
|
||||
@@ -2292,8 +2292,7 @@ ui.prototype.drawCenterFly = function () {
|
||||
var toX = core.bigmap.width - 1 - core.getHeroLoc('x'), toY = core.bigmap.height - 1 - core.getHeroLoc('y');
|
||||
this.clearUI();
|
||||
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000');
|
||||
core.drawThumbnail(null, null, {heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image},
|
||||
{ctx: 'ui', centerX: toX, centerY: toY});
|
||||
core.drawThumbnail(null, null, {heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image, ctx: 'ui', centerX: toX, centerY: toY});
|
||||
var offsetX = core.clamp(toX - core.__HALF_SIZE__, 0, core.bigmap.width - core.__SIZE__),
|
||||
offsetY = core.clamp(toY - core.__HALF_SIZE__, 0, core.bigmap.height - core.__SIZE__);
|
||||
core.fillRect('ui', (toX - offsetX) * 32, (toY - offsetY) * 32, 32, 32, fillstyle);
|
||||
@@ -2312,8 +2311,7 @@ ui.prototype.drawMaps = function (index, x, y) {
|
||||
core.status.checkBlock.cache = {};
|
||||
var data = this._drawMaps_buildData(index, x, y);
|
||||
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000');
|
||||
core.drawThumbnail(data.floorId, null, {damage: data.damage},
|
||||
{ctx: 'ui', centerX: data.x, centerY: data.y, all: data.all});
|
||||
core.drawThumbnail(data.floorId, null, {damage: data.damage, ctx: 'ui', centerX: data.x, centerY: data.y, all: data.all});
|
||||
core.clearMap('data');
|
||||
core.setTextAlign('data', 'left');
|
||||
core.setFont('data', '16px Arial');
|
||||
@@ -2780,8 +2778,7 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi
|
||||
var map = core.maps.loadMap(data.maps, data.floorId);
|
||||
core.extractBlocksForUI(map, data.hero.flags);
|
||||
core.drawThumbnail(data.floorId, map.blocks, {
|
||||
heroLoc: data.hero.loc, heroIcon: data.hero.image, flags: data.hero.flags
|
||||
}, {
|
||||
heroLoc: data.hero.loc, heroIcon: data.hero.image, flags: data.hero.flags,
|
||||
ctx: 'ui', x: x-size/2, y: y+15, size: size, centerX: data.hero.loc.x, centerY: data.hero.loc.y
|
||||
});
|
||||
if (core.isPlaying() && core.getFlag("hard") != data.hero.flags.hard) {
|
||||
|
||||
+11
-1
@@ -350,6 +350,16 @@ utils.prototype.clone = function (data, filter, recursion) {
|
||||
return data;
|
||||
}
|
||||
|
||||
////// 深拷贝1D/2D数组优化 //////
|
||||
utils.prototype.cloneArray = function (data) {
|
||||
if (!(data instanceof Array)) return this.clone(data);
|
||||
if (data[0] instanceof Array) {
|
||||
return data.map(function (one) { return one.slice(); });
|
||||
} else {
|
||||
return data.slice();
|
||||
}
|
||||
}
|
||||
|
||||
////// 裁剪图片 //////
|
||||
utils.prototype.splitImage = function (image, width, height) {
|
||||
if (typeof image == "string") {
|
||||
@@ -668,7 +678,7 @@ utils.prototype.isset = function (val) {
|
||||
utils.prototype.subarray = function (a, b) {
|
||||
if (!(a instanceof Array) || !(b instanceof Array) || a.length < b.length)
|
||||
return null;
|
||||
var na = core.clone(a), nb = core.clone(b);
|
||||
var na = core.cloneArray(a), nb = core.cloneArray(b);
|
||||
while (nb.length > 0) {
|
||||
if (na.shift() != nb.shift()) return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user