可变动的立绘大小

This commit is contained in:
草莓 2025-01-08 21:11:31 +08:00
parent b5991a4044
commit 572cd40493
4 changed files with 525 additions and 500 deletions

View File

@ -1144,16 +1144,19 @@ textcgDrawingList
| textcgDrawingEmpty;
textcgDrawing
: '立绘' EvalString? '绘制坐标' 'x' Number '变暗'Bool? Newline
: '立绘' EvalString? '绘制坐标' 'x' Number '变暗'Bool? '绘制大小w' IntString? 'h' IntString? '绘制比例(填写后w、h失效,此项默认1.7)' EvalString? Newline
/* textcgDrawing
tooltip : 立绘
helpUrl : /_docs/#/instruction
default : ["tati_050145a.webp",100,false]
default : ["tati_050145a.webp",100,false,"","",""]
colour : this.subColor
allImages : ['EvalString_0']
return '{ "name": "'+EvalString_0+'", "px": '+Number_0+',"filter":'+Bool_0+' },'
if(EvalString_1&&!/^(0|([1-9][0-9]*))(\.[\d]+)?$/.test(EvalString_1))throw new Error("此项仅能填写小数、整数或不填");
IntString_0=IntString_0?(',"w":'+IntString_0+''):''
IntString_1=IntString_1?(',"h":'+IntString_1+''):''
EvalString_1=EvalString_1?(',"scale":'+EvalString_1+''):''
return '{ "name": "'+EvalString_0+'", "px": '+Number_0+',"filter":'+Bool_0+IntString_0+IntString_1+EvalString_1+' },'
*/;
textcgDrawingEmpty
@ -2326,7 +2329,7 @@ return code;
*/;
playanimate_s
: '播放 帧动画/特效' '名称' EvalString '像素x' IntString? 'y' IntString? '跟随勇士' Bool 'x方向缩放' IntString? 'y方向缩放'IntString? Newline
: '播放 帧动画/特效' '名称' EvalString '像素x' IntString? 'y' IntString? '跟随勇士' Bool 'x方向缩放' EvalString? 'y方向缩放'EvalString? Newline
/* playanimate_s
tooltip : playanimate:播放帧动画选择跟随勇士后x、y将失效改为勇士中心坐标
@ -2336,9 +2339,11 @@ default : ["zone","","",false,"",""]
colour : this.soundColor
IntString_0 = IntString_0 ? (', "x": '+IntString_0+'') : '';
IntString_1 = IntString_1 ? (', "y": '+IntString_1+'') : '';
IntString_2 = IntString_2 ? (', "scalex": '+IntString_2+'') : '';
IntString_3 = IntString_3 ? (', "scaley": '+IntString_3+'') : '';
var code = '{"type": "playanimate", "name": "'+EvalString_0+'"'+IntString_0+IntString_1+',"hero":'+Bool_0+IntString_2+IntString_3+'},\n';
if(EvalString_1&&!/^(0|([1-9][0-9]*))(\.[\d]+)?$/.test(EvalString_1))throw new Error("此项仅能填写小数、整数或不填");
if(EvalString_2&&!/^(0|([1-9][0-9]*))(\.[\d]+)?$/.test(EvalString_2))throw new Error("此项仅能填写小数、整数或不填");
EvalString_1 = EvalString_1 ? (', "scalex": '+EvalString_1+'') : '';
EvalString_2 = EvalString_2 ? (', "scaley": '+EvalString_2+'') : '';
var code = '{"type": "playanimate", "name": "'+EvalString_0+'"'+IntString_0+IntString_1+',"hero":'+Bool_0+EvalString_1+EvalString_2+'},\n';
return code;
*/;

View File

@ -551,6 +551,9 @@ MotaActionParser = function () {
one[0],
one[1],
one[2],
one[3],
one[4],
one[5],
res,
]);
}
@ -2901,7 +2904,7 @@ MotaActionParser = function () {
MotaActionFunctions.processcgDrawing = function (bodyList) {
var list = [];
bodyList.forEach(function (one) {
list.push([one.name, one.px, one.filter]);
list.push([one.name, one.px, one.filter, one.w, one.h, one.scale]);
});
return list;
};

File diff suppressed because one or more lines are too long

View File

@ -12919,7 +12919,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
[x + w, y + h],
];
};
const inRect = ([x, y], [[sx, sy], [dx, dy]]) => {
const inRect = ([x, y], [
[sx, sy],
[dx, dy]
]) => {
return sx <= x && x <= dx && sy <= y && y <= dy;
};
const pos = [px, py];
@ -13046,9 +13049,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
config.defaultFont = config.font = config.font || globalAttribute.font;
config.time = config.time || 0;
config.letterSpacing =
config.letterSpacing == null
? textAttribute.letterSpacing || 0
: config.letterSpacing;
config.letterSpacing == null ?
textAttribute.letterSpacing || 0 :
config.letterSpacing;
config.index = 0;
config.currcolor = config.color;
@ -13102,9 +13105,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var block = config.blocks[config.index++];
if (block != null) {
// It works, why?
const scale = config.isHD
? devicePixelRatio * core.domStyle.scale
: 1;
const scale = config.isHD ?
devicePixelRatio * core.domStyle.scale :
1;
ctx.restore();
ctx.save(); //保存设置
if (core.domStyle.isVertical) {
@ -13197,6 +13200,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
const body = core.material.images.images?.[v.name];
if (v.filter) ctx.filter = "brightness(50%)";
if (body) {
if (!v.w && !v.h && !v.scale) v.scale = 1.7
if (!v.w && !v.h) {
ctx.drawImage(
body,
0,
@ -13204,10 +13209,22 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
body.width,
body.height,
v.px,
1248 - body.height * 1.7,
body.width * 1.7,
body.height * 1.7
1248 - body.height * v.scale,
body.width * v.scale,
body.height * v.scale
);
} else {
ctx.drawImage(
body,
0,
0,
body.width,
body.height,
v.px,
1248 - (v.h ?? body.height),
v.w ?? body.width,
v.h ?? body.height)
}
}
ctx.filter = "none";
});
@ -13319,7 +13336,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
}
core.ui.cgText = new cgText();
},
},
"旁白": function () {
// 在此增加新插件
const over = document.createElement("canvas"); //over画布设置