Skip to content

Commit

Permalink
add TSX tag and Rust support for EffekNode. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed May 14, 2024
1 parent 790aa87 commit 4b440ba
Show file tree
Hide file tree
Showing 24 changed files with 1,274 additions and 817 deletions.
32 changes: 32 additions & 0 deletions Assets/Script/Lib/Dora/en/EffekNode.d.tl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local Node = require("Node").Type
local Vec2 = require("Vec2").Type

-- A class for playing Effekseer effects.
local record EffekNode

-- Inherits from `Node`.
embed Node

-- Plays an Effekseer effect.
-- @param filename (string) The filename of the effect.
-- @param pos (Vec2) [optional] The XY position to play the effect at.
-- @param z (number) [optional] The Z position to play the effect at.
-- @return (integer) The handle of the effect.
play: function(self: EffekNode, filename: string, pos?: Vec2, z?: number): integer

-- Stops an Effekseer effect.
-- @param handle (integer) The handle of the effect.
stop: function(self: EffekNode, handle: integer)
end

-- A class for creating EffekNode objects.
local record EffekNodeClass
type Type = EffekNode

-- Creates a new EffekNode object.
-- @return (EffekNode) The new EffekNode object.
metamethod __call: function(self: EffekNodeClass): EffekNode
end

local effekNodeClass: EffekNodeClass
return effekNodeClass
4 changes: 4 additions & 0 deletions Assets/Script/Lib/Dora/en/Node.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ local record __SLOT__
-- @param width (number) The width of the node.
-- @param height (number) The height of the node.
["AlignLayout"]: function(width: number, height: number)

-- Triggers when an Effekseer effect has ended.
-- @param handle (integer) The handle of the effect that has ended.
["EffekEnd"]: function(handle: integer)
end

-- A class object for the `Node` class.
Expand Down
58 changes: 56 additions & 2 deletions Assets/Script/Lib/Dora/en/dora.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,7 @@ const enum NodeEvent {
ContactEnd = "ContactEnd",
Finished = "Finished",
AlignLayout = "AlignLayout",
EffekEnd = "EffekEnd",
}

export {NodeEvent as Slot};
Expand Down Expand Up @@ -2561,6 +2562,12 @@ interface NodeEventHandlerMap {
* @param height The height of the node.
*/
AlignLayout(this: void, width: number, height: number): void;

/**
* Triggers when an Effekseer effect has ended.
* @param handle The handle of the effect that has ended.
*/
EffekEnd(this: void, handle: number): void;
}

const enum GlobalEvent {
Expand Down Expand Up @@ -4083,8 +4090,8 @@ export namespace DrawNode {
}

/**
* A class for creating DrawNode objects.
*/
* A class for creating DrawNode objects.
*/
interface DrawNodeClass {
/**
* Creates a new DrawNode object.
Expand Down Expand Up @@ -4155,6 +4162,49 @@ export namespace AlignNode {
const alignNodeClass: AlignNodeClass;
export {alignNodeClass as AlignNode};

/**
* A class for playing Effekseer effects.
*/
class EffekNode extends Node {
private constructor();

/**
* Plays an Effekseer effect.
*
* @param filename The filename of the effect.
* @param pos The XY position to play the effect at.
* @param z The Z position to play the effect at.
* @returns The handle of the effect.
*/
play(filename: string, pos?: Vec2, z?: number): number;

/**
* Stops an Effekseer effect.
*
* @param handle The handle of the effect.
*/
stop(handle: number): void;
}

/**
* A class for creating EffekNode objects.
*/
interface EffekNodeClass {
/**
* Creates a new EffekNode object.
*
* @returns The new EffekNode object.
*/
(this: void): EffekNode
}

export namespace EffekNode {
export type Type = EffekNode;
}

const effekNodeClass: EffekNodeClass;
export {effekNodeClass as EffekNode};

/**
* Emits a global event with the given name and arguments to all listeners registered by `node.gslot()` function.
* @param eventName The name of the event to emit.
Expand Down Expand Up @@ -6480,6 +6530,8 @@ export const enum TypeName {
Particle = "Particle",
SVG = "SVG",
VGNode = "VGNode",
AlignNode = "AlignNode",
EffekNode = "EffekNode",
}

export interface TypeMap {
Expand Down Expand Up @@ -6528,6 +6580,8 @@ export interface TypeMap {
[TypeName.Particle]: Particle;
[TypeName.SVG]: SVG;
[TypeName.VGNode]: VGNode;
[TypeName.AlignNode]: AlignNode;
[TypeName.EffekNode]: EffekNode;
}

/**
Expand Down
47 changes: 47 additions & 0 deletions Assets/Script/Lib/Dora/en/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,45 @@ class AlignNode extends Node {
onMount?(this: void, self: dora.AlignNode.Type): void;
}

class EffekNode extends Node {
ref?: Ref<dora.EffekNode.Type>;

/**
* Triggers when this node element is instantialized.
* @param self The node element that was instantialized.
*/
onMount?(this: void, self: dora.EffekNode.Type): void;
}

class Effek {
ref?: Ref<number>;

/**
* The filename of the Effekseer effect file to load.
*/
file: string;

/**
* The x position of the effect.
*/
x?: number;

/**
* The y position of the effect.
*/
y?: number;

/**
* The z position of the effect.
*/
z?: number;

/**
* Triggers when the effect is finished playing.
*/
onEnd?(): void;
}

class Action {
ref?: Ref<dora.ActionDef.Type>;
children: any[] | any;
Expand Down Expand Up @@ -1842,6 +1881,14 @@ interface IntrinsicElements {
* A class for aligning child nodes within a parent node.
*/
'align-node': AlignNode;
/**
* A class for creating a Effekseer node.
*/
'effek-node': EffekNode;
/**
* A class for playing a Effekseer effect. Must be placed under <effek-node> to take effect.
*/
'effek': Effek;
}

interface ElementChildrenAttribute {
Expand Down
32 changes: 32 additions & 0 deletions Assets/Script/Lib/Dora/zh-Hans/EffekNode.d.tl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local Node = require("Node").Type
local Vec2 = require("Vec2").Type

-- 用于播放 Effekseer 特效的类。
local record EffekNode

-- 继承自`Node`.
embed Node

-- 播放一个 Effekseer 特效。
-- @param filename (string) 要播放的特效文件的路径。
-- @param pos (Vec2) [optional] 要播放特效的XY坐标位置。
-- @param z (number) [optional] 要播放特效的Z坐标位置。
-- @return (integer) 用于控制特效的句柄。
play: function(self: EffekNode, filename: string, pos?: Vec2, z?: number): integer

-- 停止一个 Effekseer 特效。
-- @param handle (integer) 要停止的特效的句柄。
stop: function(self: EffekNode, handle: integer)
end

-- 用于创建 EffekNode 对象的类。
local record EffekNodeClass
type Type = EffekNode

-- 创建一个新的 EffekNode 对象。
-- @return (EffekNode) 新创建的 EffekNode 对象。
metamethod __call: function(self: EffekNodeClass): EffekNode
end

local effekNodeClass: EffekNodeClass
return effekNodeClass
4 changes: 4 additions & 0 deletions Assets/Script/Lib/Dora/zh-Hans/Node.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ local record __SLOT__
-- @param width (number) 节点的宽度。
-- @param height (number) 节点的高度。
["AlignLayout"]: function(width: number, height: number)

-- 当一个 Effekseer 特效结束时触发。
-- @param handle (integer) 结束的特效的句柄。
["EffekEnd"]: function(handle: integer)
end

-- 用于创建场景节点实例的类。
Expand Down
2 changes: 2 additions & 0 deletions Assets/Script/Lib/Dora/zh-Hans/dora.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ local HttpServer = require("HttpServer")
local HttpClient = require("HttpClient")
local Profiler = require("Profiler")
local AlignNode = require("AlignNode")
local EffekNode = require("EffekNode")
local teal = require("teal")
local yue = require("yue")
global p = require("p")
Expand Down Expand Up @@ -225,4 +226,5 @@ global dora = {
HttpClient = HttpClient,
Profiler = Profiler,
AlignNode = AlignNode,
EffekNode = EffekNode,
}
58 changes: 56 additions & 2 deletions Assets/Script/Lib/Dora/zh-Hans/dora.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,7 @@ const enum NodeEvent {
ContactEnd = "ContactEnd",
Finished = "Finished",
AlignLayout = "AlignLayout",
EffekEnd = "EffekEnd",
}

export {NodeEvent as Slot};
Expand Down Expand Up @@ -2562,6 +2563,12 @@ interface NodeEventHandlerMap {
* @param height 节点的高度。
*/
AlignLayout(this: void, width: number, height: number): void;

/**
* 当一个 Effekseer 特效结束时触发。
* @param handle 结束的特效的句柄。
*/
EffekEnd(this: void, handle: number): void;
}

const enum GlobalEvent {
Expand Down Expand Up @@ -4087,8 +4094,8 @@ export namespace DrawNode {
}

/**
* 用于创建DrawNode对象的类。
*/
* 用于创建DrawNode对象的类。
*/
interface DrawNodeClass {
/**
* 创建新的DrawNode对象。
Expand Down Expand Up @@ -4160,6 +4167,49 @@ export namespace AlignNode {
const alignNodeClass: AlignNodeClass;
export {alignNodeClass as AlignNode};

/**
* 用于播放 Effekseer 特效的类。
*/
class EffekNode extends Node {
private constructor();

/**
* 播放一个 Effekseer 特效。
*
* @param filename 要播放的特效文件的名称。
* @param pos 要播放特效的XY坐标位置。
* @param z 要播放特效的Z坐标位置。
* @returns 用于控制特效的句柄。
*/
play(filename: string, pos?: Vec2, z?: number): number;

/**
* 停止一个 Effekseer 特效。
*
* @param handle 要停止的特效的句柄。
*/
stop(handle: number): void;
}

/**
* 用于创建 EffekNode 对象的类。
*/
interface EffekNodeClass {
/**
* 创建一个新的 EffekNode 对象。
*
* @returns 新创建的 EffekNode 对象。
*/
(this: void): EffekNode
}

export namespace EffekNode {
export type Type = EffekNode;
}

const effekNodeClass: EffekNodeClass;
export {effekNodeClass as EffekNode};

/**
* 发送具有特定名称和参数的全局事件,传递给所有由`node.gslot()`函数注册的事件监听器。
* @param eventName 要发出的事件的名称。
Expand Down Expand Up @@ -6484,6 +6534,8 @@ export const enum TypeName {
Particle = "Particle",
SVG = "SVG",
VGNode = "VGNode",
AlignNode = "AlignNode",
EffekNode = "EffekNode",
}

export interface TypeMap {
Expand Down Expand Up @@ -6532,6 +6584,8 @@ export interface TypeMap {
[TypeName.Particle]: Particle;
[TypeName.SVG]: SVG;
[TypeName.VGNode]: VGNode;
[TypeName.AlignNode]: AlignNode;
[TypeName.EffekNode]: EffekNode;
}

/**
Expand Down
Loading

0 comments on commit 4b440ba

Please sign in to comment.