Skip to content

Commit

Permalink
meta格式满足2种需求
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Nov 14, 2024
1 parent 55fc861 commit b67de15
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/metaBuilder/editorTables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BaseBuilder } from './baseBuilder';
import { EditorTables } from "../customDefine/editorTables";

const template =
`---@enum(key, partial) y3.Const.%{NAME}
`---@enum(key, partial) y3.Const.%{NAME}
local %{NAME} = {
%{ATTR_ENUMS}
}
Expand Down
12 changes: 8 additions & 4 deletions src/metaBuilder/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { define } from '../customDefine';
import { BaseBuilder } from './baseBuilder';

const template =
`---@enum(key, partial) y3.Const.FloatTextType
local fonts = {
`y3.const.FloatTextType = y3.const.FloatTextType or {}
%{FONTS}
}
y3.util.tableMerge(y3.const.FloatTextType or {}, fonts)
---@enum(key, partial) y3.Const.FloatTextType
local FloatTextType = {
%{META_FONTS}
}
`;


Expand All @@ -26,6 +28,8 @@ export class Font extends BaseBuilder {
return;
}
return template.replace('%{FONTS}', datas.map(data => {
return `y3.const.FloatTextType["${data.name}"] = "${data.uid}"`;
}).join('\r\n')).replace('%{META_FONTS}', datas.map(data => {
return ` ["${data.name}"] = "${data.uid}",`;
}).join('\r\n'));
}
Expand Down
12 changes: 8 additions & 4 deletions src/metaBuilder/jumpword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { define } from '../customDefine';
import { BaseBuilder } from './baseBuilder';

const template =
`---@enum(key, partial) y3.Const.FloatTextJumpType
local jumpWords = {
`y3.const.FloatTextJumpType = y3.const.FloatTextJumpType or {}
%{JUMPWORDS}
}
y3.util.tableMerge(y3.const.FloatTextJumpType or {}, jumpWords)
---@enum(key, partial) y3.Const.FloatTextJumpType
local FloatTextJumpType = {
%{META_JUMPWORDS}
}
`;


Expand All @@ -26,6 +28,8 @@ export class JumpWord extends BaseBuilder {
return;
}
return template.replace('%{JUMPWORDS}', datas.map(data => {
return `y3.const.FloatTextJumpType["${data.name}"] = ${data.uid}`;
}).join('\r\n')).replace('%{META_JUMPWORDS}', datas.map(data => {
return ` ["${data.name}"] = ${data.uid},`;
}).join('\r\n'));
}
Expand Down
12 changes: 8 additions & 4 deletions src/metaBuilder/playerAttrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { define } from '../customDefine';
import { BaseBuilder } from './baseBuilder';

const template =
`---@enum(key, partial) y3.Const.PlayerAttr
local PlayerAttr = {
`y3.const.PlayerAttr = y3.const.PlayerAttr or {}
%{ATTR_ENUMS}
}
y3.util.tableMerge(y3.const.PlayerAttr or {}, PlayerAttr)
---@enum(key, partial) y3.Const.PlayerAttr
local PlayerAttr = {
%{META_ATTR_ENUMS}
}
`;

export class PlayerAttrs extends BaseBuilder {
Expand All @@ -25,6 +27,8 @@ export class PlayerAttrs extends BaseBuilder {
return;
}
return template.replace('%{ATTR_ENUMS}', attrs.map(attr => {
return `y3.const.PlayerAttr["${attr.name}"] = "${attr.key}"`;
}).join('\r\n')).replace('%{META_ATTR_ENUMS}', attrs.map(attr => {
return ` ["${attr.name}"] = "${attr.key}",`;
}).join('\r\n'));
}
Expand Down
12 changes: 8 additions & 4 deletions src/metaBuilder/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { define } from '../customDefine';
import { BaseBuilder } from './baseBuilder';

const template =
`---@enum(key, partial) y3.Const.SceneUI
local SceneUI = {
`y3.const.SceneUI = y3.const.SceneUI or {}
%{UI_ENUMS}
}
y3.util.tableMerge(y3.const.SceneUI or {}, SceneUI)
---@enum(key, partial) y3.Const.SceneUI
local SceneUI = {
%{META_UI_ENUMS}
}
`;

export class UI extends BaseBuilder {
Expand All @@ -26,6 +28,8 @@ export class UI extends BaseBuilder {
return;
}
return template.replace('%{UI_ENUMS}', sceneUIs.map(sceneUI => {
return `y3.const.SceneUI["${sceneUI.name}"] = "${sceneUI.uid}"`;
}).join('\r\n')).replace('%{META_UI_ENUMS}', sceneUIs.map(sceneUI => {
return ` ["${sceneUI.name}"] = "${sceneUI.uid}",`;
}).join('\r\n'));
}
Expand Down
12 changes: 8 additions & 4 deletions src/metaBuilder/uiAnim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { define } from '../customDefine';
import { BaseBuilder } from './baseBuilder';

const template =
`---@enum(key, partial) y3.Const.UIAnimKey
local UIAnimKey = {
`y3.const.UIAnimKey = y3.const.UIAnimKey or {}
%{UI_ANIM_KEYS}
}
y3.util.tableMerge(y3.const.UIAnimKey or {}, UIAnimKey)
---@enum(key, partial) y3.Const.UIAnimKey
local UIAnimKey = {
%{META_UI_ANIM_KEYS}
}
`;


Expand All @@ -26,6 +28,8 @@ export class UIAnim extends BaseBuilder {
return;
}
return template.replace('%{UI_ANIM_KEYS}', anims.map(anim => {
return `y3.const.UIAnimKey["${anim.name}"] = "${anim.uid}"`;
}).join('\r\n')).replace('%{META_UI_ANIM_KEYS}', anims.map(anim => {
return ` ["${anim.name}"] = "${anim.uid}",`;
}).join('\r\n'));
}
Expand Down
13 changes: 8 additions & 5 deletions src/metaBuilder/unitAttrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { define } from '../customDefine';
import { BaseBuilder } from './baseBuilder';

const template =
`---@enum(key, partial) y3.Const.UnitAttr
local UnitAttr = {
`y3.const.UnitAttr = y3.const.UnitAttr or {}
%{ATTR_ENUMS}
}
y3.util.tableMerge(y3.const.UnitAttr or {}, UnitAttr)
---@enum(key, partial) y3.Const.UnitAttr
local UnitAttr = {
%{META_ATTR_ENUMS}
}
`;

export class UnitAttrs extends BaseBuilder {
Expand All @@ -25,8 +27,9 @@ export class UnitAttrs extends BaseBuilder {
return;
}
return template.replace('%{ATTR_ENUMS}', attrs.map(attr => {
return `y3.const.UnitAttr["${attr.name}"] = "${attr.key}"`;
}).join('\r\n')).replace('%{META_ATTR_ENUMS}', attrs.map(attr => {
return ` ["${attr.name}"] = "${attr.key}",`;
}).join('\r\n'));
}

}

0 comments on commit b67de15

Please sign in to comment.