大地图绘制缩略图

This commit is contained in:
ckcz123 2020-07-03 22:12:15 +08:00
parent bde409bae2
commit 3523358cba
15 changed files with 205 additions and 133 deletions

View File

@ -1486,13 +1486,12 @@ y: 起点纵坐标,不填视为主角当前的
direction: 移动的方向,不填视为主角面对的方向
floorId: 地图id不填视为当前地图
drawThumbnail: fn(floorId?: string, blocks?: [block], options?: ?, toDraw?: string|CanvasRenderingContext2D|?)
drawThumbnail: fn(floorId?: string, blocks?: [block], options?: ?)
绘制缩略图
例如core.drawThumbnail(); // 绘制当前地图的缩略图
floorId: 地图id不填视为当前地图
blocks: 一般不需要
options: 额外的绘制项可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档
toDraw: 要绘制到的画布名或画布的ctx或还有其他信息如起绘坐标、绘制大小、是否绘制全图、截取中心
hideBlockByIndex: fn(index?: number, floorId?: string)
根据图块的索引来隐藏图块
@ -1846,6 +1845,10 @@ filter: 过滤器可选表示data为数组或对象时拷贝哪些项或
recursion: 过滤器是否递归可选。true表示过滤器也被递归
返回值:拷贝的结果,注意函数将原样返回
cloneArray: fn(data?: [number]|[[number]]) -> [number]|[[number]]
深拷贝一个1D或2D数组对象
例如core.cloneArray(core.status.thisMap.map)
setLocalForage: fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn())
往数据库写入一段数据

View File

@ -2725,6 +2725,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "深拷贝一个对象(函数将原样返回)<br/>例如core.clone(core.status.hero, (name, value) => (name == 'items' || typeof value == 'number'), false); // 深拷贝主角的属性和道具<br/>data: 待拷贝对象<br/>filter: 过滤器可选表示data为数组或对象时拷贝哪些项或属性true表示拷贝<br/>recursion: 过滤器是否递归可选。true表示过滤器也被递归<br/>返回值:拷贝的结果,注意函数将原样返回",
"!type": "fn(data?: ?, filter?: fn(name: string, value: ?) -> bool, recursion?: bool)"
},
"cloneArray": {
"!doc": "深拷贝一个1D或2D数组对象<br/>例如core.cloneArray(core.status.thisMap.map)",
"!type": "fn(data?: [number]|[[number]]) -> [number]|[[number]]"
},
"setLocalForage": {
"!doc": "往数据库写入一段数据",
"!type": "fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn())"
@ -3275,8 +3279,8 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!type": "fn(x?: number, y?: number, direction?: string, floorId?: string) -> bool"
},
"drawThumbnail": {
"!doc": "绘制缩略图<br/>例如core.drawThumbnail(); // 绘制当前地图的缩略图<br/>floorId: 地图id不填视为当前地图<br/>blocks: 一般不需要<br/>options: 额外的绘制项可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档<br/>toDraw: 要绘制到的画布名或画布的ctx或还有其他信息如起绘坐标、绘制大小、是否绘制全图、截取中心",
"!type": "fn(floorId?: string, blocks?: [block], options?: ?, toDraw?: string|CanvasRenderingContext2D|?)"
"!doc": "绘制缩略图<br/>例如core.drawThumbnail(); // 绘制当前地图的缩略图<br/>floorId: 地图id不填视为当前地图<br/>blocks: 一般不需要<br/>options: 绘制信息可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档,同时包含要绘制到的画布名或画布的ctx或还有其他信息如起绘坐标、绘制大小、是否绘制全图、截取中心",
"!type": "fn(floorId?: string, blocks?: [block], options?: ?)"
},
"hideBlockByIndex": {
"!doc": "根据图块的索引来隐藏图块",

View File

@ -1 +1 @@
{"lastUsed":[{"idnum":151,"id":"autotile1","images":"autotile","y":0,"recent":1593758059851,"frequent":7},{"idnum":213,"id":"zombie","images":"enemys","y":12,"recent":1593758008027,"frequent":2},{"idnum":211,"id":"skeletonCaptain","images":"enemys","y":10,"recent":1593758003830,"frequent":2},{"idnum":206,"id":"bigBat","images":"enemys","y":5,"recent":1593758000245,"frequent":1},{"idnum":209,"id":"skeleton","images":"enemys","y":8,"recent":1593757393597,"frequent":4},{"idnum":210,"id":"skeletonWarrior","images":"enemys","y":9,"recent":1593757252851,"frequent":2},{"idnum":205,"id":"bat","images":"enemys","y":4,"recent":1593757205645,"frequent":1},{"idnum":201,"id":"greenSlime","images":"enemys","y":0,"recent":1593757197512,"frequent":1}],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample2","disableBlocklyReplace":false,"disableBlocklyExpandCompare":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}}
{"lastUsed":[{"idnum":45,"id":"book","images":"items","y":9,"recent":1593783767918,"frequent":1},{"idnum":151,"id":"autotile1","images":"autotile","y":0,"recent":1593758059851,"frequent":7},{"idnum":213,"id":"zombie","images":"enemys","y":12,"recent":1593758008027,"frequent":2},{"idnum":211,"id":"skeletonCaptain","images":"enemys","y":10,"recent":1593758003830,"frequent":2},{"idnum":206,"id":"bigBat","images":"enemys","y":5,"recent":1593758000245,"frequent":1},{"idnum":209,"id":"skeleton","images":"enemys","y":8,"recent":1593757393597,"frequent":4},{"idnum":210,"id":"skeletonWarrior","images":"enemys","y":9,"recent":1593757252851,"frequent":2},{"idnum":205,"id":"bat","images":"enemys","y":4,"recent":1593757205645,"frequent":1},{"idnum":201,"id":"greenSlime","images":"enemys","y":0,"recent":1593757197512,"frequent":1}],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample2","disableBlocklyReplace":false,"disableBlocklyExpandCompare":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0},"viewportLoc":[0,0]}

View File

@ -223,12 +223,17 @@ editor.prototype.init = function (callback) {
for (var one in canvases) {
canvases[one].width = canvases[one].height = core.__PIXELS__;
}
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps));
var lastFloorId = editor.config.get('editorLastFloorId', core.status.floorId);
if (core.floorIds.indexOf(lastFloorId) < 0) lastFloorId = core.status.floorId;
core.changeFloor(lastFloorId, null, {x: 0, y: 0, direction:"up"}, null, function () {
afterCoreReset();
}, true);
core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.cloneArray(core.initStatus.maps));
var floorId = editor.config.get('editorLastFloorId', core.status.floorId);
if (core.floorIds.indexOf(floorId) < 0) floorId = core.status.floorId;
core.status.floorId = floorId;
core.resizeMap(floorId);
core.clearMap('all');
core.generateGroundPattern(floorId);
core.extractBlocks(floorId);
core.status.thisMap = core.status.maps[floorId];
afterCoreReset();
});
}
@ -238,11 +243,13 @@ editor.prototype.init = function (callback) {
editor.drawInitData(core.icons.icons); // 初始化绘图
editor.game.fetchMapFromCore();
editor.pos = {x: 0, y: 0};
editor.updateMap();
editor.buildMark();
var viewportLoc = editor.config.get('viewportLoc', []);
editor.setViewport(viewportLoc[0] || 0, viewportLoc[1] || 0);
editor.drawEventBlock();
editor.pos = {x: 0, y: 0};
editor.mode.loc();
editor.info = editor.ids[editor.indexs[201]];
editor.mode.enemyitem();
@ -334,20 +341,26 @@ editor.prototype.changeFloor = function (floorId, callback) {
editor.uivalues.preMapData = [];
editor.uivalues.postMapData = [];
editor.uifunctions._extraEvent_bindSpecialDoor_doAction(true);
core.changeFloor(floorId, null, {"x": 0, "y": 0, "direction": "up"}, null, function () {
editor.game.fetchMapFromCore();
editor.updateMap();
editor_mode.floor();
editor.drawEventBlock();
editor.viewportLoc = editor.viewportLoc || {};
var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0;
editor.setViewport(x, y);
editor.uifunctions.unhighlightSaveFloorButton();
core.status.floorId = floorId;
core.resizeMap(floorId);
core.clearMap('all');
core.generateGroundPattern(floorId);
core.extractBlocks(floorId);
core.status.thisMap = core.status.maps[floorId];
editor.config.set('editorLastFloorId', floorId, function() {
if (callback) callback();
});
editor.game.fetchMapFromCore();
editor.updateMap();
editor_mode.floor();
editor.drawEventBlock();
editor.viewportLoc = editor.viewportLoc || {};
var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0;
editor.setViewport(x, y);
editor.uifunctions.unhighlightSaveFloorButton();
editor.config.set('editorLastFloorId', floorId, function() {
if (callback) callback();
});
}
@ -444,8 +457,7 @@ editor.prototype._updateMap_bigmap = function () {
bm.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
bm.fillStyle = '#000000';
bm.fillRect(0, 0, core.__PIXELS__, core.__PIXELS__);
core.drawThumbnail(editor.currentFloorId, core.status.thisMap.blocks, null,
{ctx: bm, all: true});
core.drawThumbnail(editor.currentFloorId, core.status.thisMap.blocks, {ctx: bm, all: true});
var width = editor.currentFloorData.width;
var height = editor.currentFloorData.height;
editor.uivalues.bigmapInfo.top = core.__PIXELS__ * Math.max(0, (1 - height / width) / 2);
@ -572,6 +584,7 @@ editor.prototype.setViewport=function (x, y) {
editor.viewportLoc = editor.viewportLoc || {};
editor.viewportLoc[editor.currentFloorId] = [core.bigmap.offsetX, core.bigmap.offsetY];
core.control.updateViewport();
editor.config.set('viewportLoc', editor.viewportLoc[editor.currentFloorId]);
editor.buildMark();
editor.drawPosSelection();
}

View File

@ -375,7 +375,7 @@ editor_ui_wrapper = function (editor) {
// 绘制UI
var background = uievent.elements.selectBackground.value;
if (background == 'thumbnail') {
core.drawThumbnail(editor.currentFloorId, null, {}, 'uievent');
core.drawThumbnail(editor.currentFloorId, null, {ctx: 'uievent'});
}
else {
core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background);
@ -482,11 +482,10 @@ editor_ui_wrapper = function (editor) {
if (redraw) {
core.setAlpha('uievent', 1);
core.clearMap('uievent');
core.drawThumbnail(uievent.values.floorId, null, null,
{
ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__,
centerY: uievent.values.top + core.__HALF_SIZE__, all: uievent.values.bigmap
});
core.drawThumbnail(uievent.values.floorId, null, {
ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__,
centerY: uievent.values.top + core.__HALF_SIZE__, all: uievent.values.bigmap
});
uievent.values.multipoints = uievent.values.multipoints || [];
core.setTextAlign('uievent', 'right');
for (var i = 0; i < uievent.values.multipoints.length; ++i) {
@ -857,7 +856,7 @@ editor_ui_wrapper = function (editor) {
var canvas = document.createElement('canvas');
canvas.width = canvas.height = core.__PIXELS__;
canvas.style.position = 'absolute';
core.drawThumbnail(editor.currentFloorId, null, {}, canvas.getContext('2d'));
core.drawThumbnail(editor.currentFloorId, null, {ctx: canvas.getContext('2d')});
dom.appendChild(canvas);
var canvas2 = document.createElement('canvas');
canvas2.style.position = 'absolute';

View File

@ -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 () {

View File

@ -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
}});

View File

@ -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);

View File

@ -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为目标floorIdblocks为地图的图块可为null使用floorId对应默认的
// options为绘制选项可为null包括
// heroLoc: 勇士位置heroIcon勇士图标默认当前勇士damage是否绘制显伤flags当前的flags存读档时使用
// toDraw为要绘制到的信息可为null或为一个画布名包括
// ctx要绘制到的画布x,y起点横纵坐标默认0size大小默认416/480
// all是否绘制全图默认falsecenterX,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);
}
}
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -130,7 +130,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"loc": {
"direction": "up",
"x": 6,
"y": 10
"y": 12
},
"flags": {},
"followers": [],

View File

@ -14,14 +14,14 @@ main.floors.sample2=
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,206, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

View File

@ -353,7 +353,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event'));
// 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后)
document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('efg'));
document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm'));
// 原本有三个图层 从4开始添加
var num = 4;
// 新增图层存入editor.dom中
@ -424,29 +424,31 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
////// 绘制背景和前景层 //////
core.maps._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.clearMap('bg2');
core.clearMap(cacheCtx);
if (config.onMap) {
core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
core.clearMap('bg2');
core.clearMap(cacheCtx);
}
core.maps._drawBgFgMap(floorId, 'bg2', config);
core.drawImage(config.onMap ? 'bg2' : toDrawCtx, cacheCtx.canvas, offset, offset);
if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
config.ctx = toDrawCtx;
}
core.maps._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.clearMap('fg2');
core.clearMap(cacheCtx);
if (config.onMap) {
core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
core.clearMap('fg2');
core.clearMap(cacheCtx);
}
core.maps._drawBgFgMap(floorId, 'fg2', config);
core.drawImage(config.onMap ? 'fg2' : toDrawCtx, cacheCtx.canvas, offset, offset);
if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
config.ctx = toDrawCtx;
}

6
runtime.d.ts vendored
View File

@ -1530,9 +1530,8 @@ declare class maps {
* @param floorId id
* @param blocks
* @param options flags用于存读档
* @param toDraw ctx或还有其他信息
*/
drawThumbnail(floorId?: string, blocks?: Block[], options?: object, toDraw?: string | CanvasRenderingContext2D | object): void
drawThumbnail(floorId?: string, blocks?: Block[], options?: object): void
/**
* cannotIn属性
@ -2376,6 +2375,9 @@ declare class utils {
*/
clone<T>(data?: T, filter?: (name: string, value: any) => boolean, recursion?: boolean): T
/** 深拷贝一个1D或2D的数组 */
cloneArray(data?: Array<number>|Array<Array<number>>): Array<number>|Array<Array<number>>
/**
*
* @example core.splitImage(core.material.images.images['npc48.png'], 32, 48); // 把npc48.png切分成若干32×48px的小人