hero any width

This commit is contained in:
oc 2019-04-28 21:14:14 +08:00
parent 9e9025e089
commit f6ac9610cc
6 changed files with 35 additions and 19 deletions

View File

@ -180,7 +180,7 @@
我们可以给文字加上标题或图标,只要以`\t[...]`开头就可以。
其一般写法是`\t[名字,ID]`其中名字为你要显示的标题ID为图块ID只能为open`hero`或者NPC/怪物的图块ID。
其一般写法是`\t[名字,ID]`其中名字为你要显示的标题ID为图块ID只能为`hero`或者NPC/怪物的图块ID。
如果不需要可以不写ID则只会显示标题。

View File

@ -777,9 +777,9 @@ control.prototype.drawHero = function (status, offset) {
core.clearMap('hero');
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) {
core.drawImage('hero', block.img, block.heroIcon[block.status]*32,
block.heroIcon.loc * block.height, 32, block.height,
block.posx, block.posy+32-block.height, 32, block.height);
core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width,
block.heroIcon.loc * block.height, block.width, block.height,
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
});
core.control.updateViewport();
@ -789,6 +789,7 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off
var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0;
drawObjs.push({
"img": core.material.images.hero,
"width": core.material.icons.hero.width || 32,
"height": core.material.icons.hero.height,
"heroIcon": heroIconArr[direction],
"posx": x * 32 - core.bigmap.offsetX + core.utils.scan[direction].x * offset,
@ -799,6 +800,7 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off
(core.status.hero.followers||[]).forEach(function (t) {
drawObjs.push({
"img": core.material.images.images[t.name],
"width": core.material.images.images[t.name].width/4,
"height": core.material.images.images[t.name].height/4,
"heroIcon": heroIconArr[t.direction],
"posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan[t.direction].x*offset),
@ -2345,14 +2347,15 @@ control.prototype.updateHeroIcon = function (name) {
var image = core.material.images.hero;
// 全身图
var height = core.material.icons.hero.height;
var ratio = 32 / height, width = 32 * ratio, left = 16-width/2;
var w = core.material.icons.hero.width || 32;
var h = core.material.icons.hero.height || 48;
var ratio = Math.max(w / h, 1), width = 32 * ratio, left = 16 - width/2;
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
canvas.width = 32;
canvas.height = 32;
context.drawImage(image, 0, 0, 32, height, left, 0, width, 32);
context.drawImage(image, 0, 0, w, h, left, 0, width, 32);
core.statusBar.image.name.src = canvas.toDataURL("image/png");
}

View File

@ -1758,8 +1758,7 @@ events.prototype.hasAsync = function () {
events.prototype.follow = function (name) {
core.status.hero.followers = core.status.hero.followers || [];
name = core.getMappedName(name);
if (core.material.images.images[name]
&& core.material.images.images[name].width == 128) {
if (core.material.images.images[name]) {
core.status.hero.followers.push({"name": name});
core.gatherFollowers();
core.clearMap('hero');
@ -2139,6 +2138,7 @@ events.prototype.jumpHero = function (ex, ey, time, callback) {
core.playSound('jump.mp3');
var jumpInfo = core.maps.__generateJumpInfo(sx, sy, ex, ey, time || 500);
jumpInfo.icon = core.material.icons.hero[core.getHeroLoc('direction')];
jumpInfo.width = core.material.icons.hero.width || 32;
jumpInfo.height = core.material.icons.hero.height;
this._jumpHero_doJump(jumpInfo, callback);
@ -2158,12 +2158,12 @@ events.prototype._jumpHero_doJump = function (jumpInfo, callback) {
events.prototype._jumpHero_jumping = function (jumpInfo) {
core.clearMap('hero');
core.maps.__updateJumpInfo(jumpInfo);
var nowx = jumpInfo.px, nowy = jumpInfo.py, height = jumpInfo.height;
var nowx = jumpInfo.px, nowy = jumpInfo.py, width = jumpInfo.width || 32, height = jumpInfo.height;
core.bigmap.offsetX = core.clamp(nowx - 32*core.__HALF_SIZE__, 0, 32*core.bigmap.width-core.__PIXELS__);
core.bigmap.offsetY = core.clamp(nowy - 32*core.__HALF_SIZE__, 0, 32*core.bigmap.height-core.__PIXELS__);
core.control.updateViewport();
core.drawImage('hero', core.material.images.hero, jumpInfo.icon.stop, jumpInfo.icon.loc * height, 32, height,
nowx - core.bigmap.offsetX, nowy + 32-height - core.bigmap.offsetY, 32, height);
core.drawImage('hero', core.material.images.hero, jumpInfo.icon.stop, jumpInfo.icon.loc * height, width, height,
nowx + (32 - width) / 2 - core.bigmap.offsetX, nowy + 32-height - core.bigmap.offsetY, width, height);
}
events.prototype._jumpHero_finished = function (animate, ex, ey, callback) {
@ -2251,9 +2251,10 @@ events.prototype.canUseQuickShop = function (shopId) {
events.prototype.setHeroIcon = function (name, noDraw) {
name = core.getMappedName(name);
var img = core.material.images.images[name];
if (!img || img.width != 128) return;
if (!img) return;
core.setFlag("heroIcon", name);
core.material.images.hero.onload = function () {
core.material.icons.hero.width = img.width / 4;
core.material.icons.hero.height = img.height / 4;
core.control.updateHeroIcon(name);
if (!noDraw) core.drawHero();

View File

@ -373,7 +373,8 @@ ui.prototype._getTitleAndIcon = function (content) {
title = core.status.hero.name;
image = core.material.images.hero;
icon = 0;
height = core.material.icons.hero.height;
var w = core.material.icons.hero.width || 32;
height = 32 * core.material.icons.hero.height / w;
}
else if (s4.endsWith(".png")) {
s4 = core.getMappedName(s4);
@ -928,11 +929,20 @@ ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, al
core.strokeRect('ui', hPos.left + 15 - 1, image_top-1, 34, titleInfo.height + 2, null, 2);
core.setAlpha('ui', 1);
core.status.boxAnimateObjs = [];
core.status.boxAnimateObjs.push({
'bgx': hPos.left + 15, 'bgy': image_top, 'bgWidth': 32, 'bgHeight': titleInfo.height,
'x': hPos.left + 15, 'y': image_top, 'height': titleInfo.height, 'animate': titleInfo.animate,
'image': titleInfo.image, 'pos': titleInfo.icon * titleInfo.height
});
// --- 勇士
if (titleInfo.image == core.material.images.hero) {
core.clearMap('ui', hPos.left + 15, image_top, 32, titleInfo.height);
core.fillRect('ui', hPos.left + 15, image_top, 32, titleInfo.height, core.material.groundPattern);
core.drawImage('ui', titleInfo.image, 0, 0, core.material.icons.hero.width || 32, core.material.icons.hero.height,
hPos.left + 15, image_top, 32, titleInfo.height);
}
else {
core.status.boxAnimateObjs.push({
'bgx': hPos.left + 15, 'bgy': image_top, 'bgWidth': 32, 'bgHeight': titleInfo.height,
'x': hPos.left + 15, 'y': image_top, 'height': titleInfo.height, 'animate': titleInfo.animate,
'image': titleInfo.image, 'pos': titleInfo.icon * titleInfo.height
});
}
core.drawBoxAnimate();
}
if (titleInfo.image != null && titleInfo.icon == null) { // 头像图

View File

@ -973,6 +973,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
icon = core.getMappedName(icon);
if (core.material.images.images[icon]) {
core.material.images.hero.src = core.material.images.images[icon].src;
core.material.icons.hero.width = core.material.images.images[icon].width / 4;
core.material.icons.hero.height = core.material.images.images[icon].height / 4;
}
// 刷新怪物数据

View File

@ -25,6 +25,7 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
"leftFoot": 1,
"rightFoot": 3
},
"width": 32,
"height": 48
},
"terrains": {