From feecb3a380c203b0cee970a3e99e5d53a8c820a0 Mon Sep 17 00:00:00 2001
From: unanmed <1319491857@qq.com>
Date: Tue, 3 Dec 2024 17:09:48 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20winskin=E6=A1=86=E6=9E=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/core/render/preset/graphics.ts | 8 ++++---
src/core/render/preset/misc.ts | 31 +++++++++++++++++++++++++++
src/core/render/renderer/elements.tsx | 26 ++++++++++++++--------
src/core/render/renderer/map.ts | 12 ++++++++++-
src/core/render/renderer/props.ts | 2 ++
5 files changed, 66 insertions(+), 13 deletions(-)
diff --git a/src/core/render/preset/graphics.ts b/src/core/render/preset/graphics.ts
index c863e3e..e17ec40 100644
--- a/src/core/render/preset/graphics.ts
+++ b/src/core/render/preset/graphics.ts
@@ -1,10 +1,10 @@
import { MotaOffscreenCanvas2D } from '@/core/fx/canvas2d';
-import { RenderItem } from '../item';
+import { ERenderItemEvent, RenderItem } from '../item';
import { Transform } from '../transform';
import { ElementNamespace, ComponentInternalInstance } from 'vue';
/*
- * Expected usage (this comment needs to be deleted after implements correctly):
+ * Expected usage (this comment needs to be deleted after implementing correctly):
*
*
*
@@ -50,8 +50,10 @@ export const enum GraphicMode {
StrokeAndFill
}
+export interface EGraphicItemEvent extends ERenderItemEvent {}
+
export abstract class GraphicItemBase
- extends RenderItem
+ extends RenderItem
implements IGraphicProperty
{
mode: number = GraphicMode.Fill;
diff --git a/src/core/render/preset/misc.ts b/src/core/render/preset/misc.ts
index 2bd6ae3..bdedeac 100644
--- a/src/core/render/preset/misc.ts
+++ b/src/core/render/preset/misc.ts
@@ -248,3 +248,34 @@ export class Icon extends RenderItem {
super.patchProp(key, prevValue, nextValue, namespace, parentComponent);
}
}
+
+export interface EWinskinEvent extends ERenderItemEvent {}
+
+export class Winskin extends RenderItem {
+ image: SizedCanvasImageSource;
+
+ constructor(
+ image: SizedCanvasImageSource,
+ type: RenderItemPosition = 'static'
+ ) {
+ super(type, false, false);
+ this.image = image;
+ }
+
+ protected render(
+ canvas: MotaOffscreenCanvas2D,
+ transform: Transform
+ ): void {}
+
+ patchProp(
+ key: string,
+ prevValue: any,
+ nextValue: any,
+ namespace?: ElementNamespace,
+ parentComponent?: ComponentInternalInstance | null
+ ): void {
+ switch (key) {
+ }
+ super.patchProp(key, prevValue, nextValue, namespace, parentComponent);
+ }
+}
diff --git a/src/core/render/renderer/elements.tsx b/src/core/render/renderer/elements.tsx
index 0d7566d..2d08c29 100644
--- a/src/core/render/renderer/elements.tsx
+++ b/src/core/render/renderer/elements.tsx
@@ -28,17 +28,24 @@ import {
RectProps,
ShaderProps,
SpriteProps,
- TextProps
+ TextProps,
+ WinskinProps
} from './props';
import { ERenderItemEvent, RenderItem } from '../item';
import { ESpriteEvent, Sprite } from '../sprite';
import { EContainerEvent } from '../container';
import { EGL2Event } from '../gl2';
-import { EIconEvent, EImageEvent, ETextEvent } from '../preset/misc';
+import {
+ EIconEvent,
+ EImageEvent,
+ ETextEvent,
+ EWinskinEvent
+} from '../preset/misc';
import { ELayerEvent, ELayerGroupEvent } from '../preset/layer';
import { EAnimateEvent } from '../preset/animate';
import { EDamageEvent } from '../preset/damage';
import { EShaderEvent } from '../shader';
+import { EGraphicItemEvent } from '../preset/graphics';
export type WrapEventEmitterEvents =
T extends string | symbol
@@ -87,14 +94,15 @@ declare module 'vue/jsx-runtime' {
'layer-group': TagDefine;
damage: TagDefine;
animation: TagDefine;
- 'g-rect': TagDefine;
- 'g-circle': TagDefine;
- 'g-ellipse': TagDefine;
- 'g-line': TagDefine;
- 'g-bezier': TagDefine;
- 'g-quad': TagDefine;
- 'g-path': TagDefine;
+ 'g-rect': TagDefine;
+ 'g-circle': TagDefine;
+ 'g-ellipse': TagDefine;
+ 'g-line': TagDefine;
+ 'g-bezier': TagDefine;
+ 'g-quad': TagDefine;
+ 'g-path': TagDefine;
icon: TagDefine;
+ winskin: TagDefine;
}
}
}
diff --git a/src/core/render/renderer/map.ts b/src/core/render/renderer/map.ts
index 071ebbf..e6a5446 100644
--- a/src/core/render/renderer/map.ts
+++ b/src/core/render/renderer/map.ts
@@ -4,7 +4,7 @@ import { ElementNamespace, VNodeProps } from 'vue';
import { Container } from '../container';
import { MotaRenderer } from '../render';
import { Sprite } from '../sprite';
-import { Comment, Icon, Image, Text } from '../preset/misc';
+import { Comment, Icon, Image, Text, Winskin } from '../preset/misc';
import { Shader } from '../shader';
import { Animate, Damage, EDamageEvent, Layer, LayerGroup } from '../preset';
import {
@@ -189,3 +189,13 @@ tagMap.register('g-bezier', standardElementNoCache(BezierCurve));
tagMap.register('g-quad', standardElementNoCache(QuadraticCurve));
tagMap.register('g-path', standardElementNoCache(Path));
tagMap.register('icon', standardElementNoCache(Icon));
+tagMap.register('winskin', (_0, _1, props) => {
+ if (!props) return new Winskin(core.material.images.images['winskin.png']);
+ else {
+ const {
+ image = core.material.images.images['winskin.png'],
+ type = 'static'
+ } = props;
+ return new Winskin(image, type);
+ }
+});
diff --git a/src/core/render/renderer/props.ts b/src/core/render/renderer/props.ts
index 85b79b4..7f0e974 100644
--- a/src/core/render/renderer/props.ts
+++ b/src/core/render/renderer/props.ts
@@ -105,3 +105,5 @@ export interface QuadraticProps extends BaseProps {}
export interface PathProps extends BaseProps {}
export interface IconProps extends BaseProps {}
+
+export interface WinskinProps extends BaseProps {}