-
Notifications
You must be signed in to change notification settings - Fork 60
docs: add template reference #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HardyNLee
wants to merge
2
commits into
OpenWebGAL:main
Choose a base branch
from
HardyNLee:doc/template-reference
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # 模板配置文件 {#config} | ||
|
|
||
| 位于 `您的游戏名称目录/game/template/template.json` 的模板配置文件是一个 JSON 格式的文件,用于定义游戏中使用的模板的相关信息和配置项。 | ||
|
|
||
| ## 模板配置项 {#config-item} | ||
|
|
||
| ``` json | ||
| { | ||
| "name": "My New Template", | ||
| "id": "my-new-template", | ||
| "webgal-version": "4.6.0", | ||
| "fonts": [ | ||
| { | ||
| "font-family": "某圆体", | ||
| "url": "assets/fonts/some_font.ttf", | ||
| "type": "truetype", | ||
| "weight": "normal", | ||
| "style": "normal", | ||
| "display": "auto" | ||
| } | ||
| ], | ||
| } | ||
| ``` | ||
|
|
||
| ### name | ||
|
|
||
| - 字符串 | ||
|
|
||
| 模板的名称。目前仅编辑器使用。 | ||
|
|
||
| ### id | ||
|
|
||
| - 字符串 | ||
|
|
||
| 模板的唯一标识符。目前仅编辑器使用。不同模板的 id 不能相同,否则会导致编辑器无法正确识别和加载模板。 | ||
|
|
||
| ### webgal-version | ||
|
|
||
| - 字符串 | ||
|
|
||
| 模板适配的 WebGal 引擎版本。必须符合语义化版本规范(SemVer),例如 "4.6.0"。 | ||
|
|
||
| 如果模板不适配当前使用的 WebGal 引擎版本,可能会导致模板无法正常工作或出现兼容性问题。 | ||
|
|
||
| ### fonts | ||
|
|
||
| - 数组 | ||
|
|
||
| 模板使用的字体列表。每个字体对象包含以下属性: | ||
|
|
||
| - font-family: 字体名称,字符串类型。以该名称显示在设置界面中,供玩家选择使用。 | ||
| - url: 字体文件的 URL,字符串类型。以 `您的游戏名称目录/game/template/` 为根目录。 | ||
| - type: 字体类型,字符串类型。可选值包括 | ||
|
|
||
| - "truetype":TrueType 字体文件,通常以 .ttf 结尾。 | ||
| - "opentype":OpenType 字体文件,通常以 .otf 结尾。 | ||
| - "woff":Web Open Font Format 字体文件,通常以 .woff 结尾。 | ||
| - "woff2":Web Open Font Format 2 字体文件,通常以 .woff2 结尾。 | ||
| - "embedded-opentype":Embedded OpenType 字体文件,通常以 .eot 结尾。 | ||
| - "svg":SVG 字体文件,通常以 .svg 结尾。 | ||
| - "collection":字体集合文件,通常以 .ttc 结尾。 | ||
|
|
||
| - weight: 字体粗细,字符串类型。可选值为 "normal"、"bold" 等,详情请参考[font-weight](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@font-face/font-weight)。 | ||
| - style: 字体样式,字符串类型。可选值为 "normal"、"italic" 等,详情请参考[font-style](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@font-face/font-style)。 | ||
| - display: 字体显示策略,字符串类型。可选值为 "auto"、"block"、"swap"、"fallback"、"optional",详情请参考[font-display](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@font-face/font-display)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # 选择 {#choose} | ||
|
|
||
| `choose` 命令调用的选择按钮列表。 | ||
|
|
||
| 基础样式请查看[源码](https://github.com/OpenWebGAL/WebGAL/blob/main/packages/webgal/src/Core/gameScripts/choose/choose.module.scss) | ||
|
|
||
| ## 结构 {#structure} | ||
|
|
||
| ```tsx | ||
| return ( | ||
| <div class="Choose_Main"> | ||
| {getChoices().map((choice) => ( | ||
| <div class="Choose_item_outer"> | ||
| <div | ||
| class={choice.disabled ? "Choose_item_disabled" : "Choose_item"} | ||
| style={{fontFamily: getFontFamily()}} | ||
| > | ||
| {choice.text} | ||
| </div> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| ); | ||
| ``` | ||
|
|
||
| ## 样式 {#style} | ||
|
|
||
| ### Choose_Main | ||
|
|
||
| 选择按钮列表的容器样式。 | ||
|
|
||
| ### Choose_item_outer | ||
|
|
||
| 选择按钮的外层元素样式。 | ||
|
|
||
| ### Choose_item | ||
|
|
||
| 选择按钮的内层元素样式。 | ||
|
|
||
| ### Choose_item_disabled | ||
|
|
||
| 选择按钮被禁用时的样式。 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 JSON 格式中,数组或对象的最后一个元素后面不能有逗号(trailing comma)。如果保留此逗号,标准的 JSON 解析器(如
JSON.parse)在解析template.json时会报错,导致模板无法加载。建议移除该逗号。