mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-02-28 17:37:07 +08:00
refactor: Winskin.image
This commit is contained in:
parent
52c5126997
commit
c7b2e6dd30
@ -278,7 +278,7 @@ export class Icon extends RenderItem<EIconEvent> implements IAnimateFrame {
|
|||||||
if (isNil(this.pendingIcon)) {
|
if (isNil(this.pendingIcon)) {
|
||||||
loading.once('loaded', () => {
|
loading.once('loaded', () => {
|
||||||
this.setIconRenderable(this.pendingIcon ?? 0);
|
this.setIconRenderable(this.pendingIcon ?? 0);
|
||||||
this.pendingIcon = void 0;
|
delete this.pendingIcon;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.pendingIcon = num;
|
this.pendingIcon = num;
|
||||||
@ -346,6 +346,8 @@ export class Winskin extends RenderItem<EWinskinEvent> {
|
|||||||
/** 边框宽度 */
|
/** 边框宽度 */
|
||||||
borderSize: number = 32;
|
borderSize: number = 32;
|
||||||
|
|
||||||
|
private pendingImage?: ImageIds;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
image: SizedCanvasImageSource,
|
image: SizedCanvasImageSource,
|
||||||
type: RenderItemPosition = 'static'
|
type: RenderItemPosition = 'static'
|
||||||
@ -507,6 +509,29 @@ export class Winskin extends RenderItem<EWinskinEvent> {
|
|||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过图片名称设置winskin
|
||||||
|
* @param name 图片名称
|
||||||
|
*/
|
||||||
|
setImageByName(name: ImageIds) {
|
||||||
|
const loading = Mota.require('var', 'loading');
|
||||||
|
if (loading.loaded) {
|
||||||
|
const image = core.material.images.images[name];
|
||||||
|
this.setImage(image);
|
||||||
|
} else {
|
||||||
|
if (isNil(this.pendingImage)) {
|
||||||
|
loading.once('loaded', () => {
|
||||||
|
const id = this.pendingImage;
|
||||||
|
if (!id) return;
|
||||||
|
const image = core.material.images.images[id];
|
||||||
|
this.setImage(image);
|
||||||
|
delete this.pendingImage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.pendingImage = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置边框大小
|
* 设置边框大小
|
||||||
* @param size 边框大小
|
* @param size 边框大小
|
||||||
@ -525,7 +550,8 @@ export class Winskin extends RenderItem<EWinskinEvent> {
|
|||||||
): void {
|
): void {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'image':
|
case 'image':
|
||||||
this.setImage(nextValue);
|
if (!this.assertType(nextValue, 'string', key)) return;
|
||||||
|
this.setImageByName(nextValue);
|
||||||
return;
|
return;
|
||||||
case 'borderSize':
|
case 'borderSize':
|
||||||
if (!this.assertType(nextValue, 'number', key)) return;
|
if (!this.assertType(nextValue, 'number', key)) return;
|
||||||
|
@ -183,6 +183,6 @@ export interface IconProps extends BaseProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface WinskinProps extends BaseProps {
|
export interface WinskinProps extends BaseProps {
|
||||||
image: SizedCanvasImageSource;
|
image: ImageIds;
|
||||||
borderSize: number;
|
borderSize?: number;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user