Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineUserConfig } from "vuepress";
import theme from "./theme.js";
import { searchPlugin } from "@vuepress/plugin-search";
import { shikiPlugin } from "@vuepress/plugin-shiki";
import path from 'path'
import path from "path";
export default defineUserConfig({
base: "/",
plugins: [
Expand Down Expand Up @@ -34,9 +34,15 @@ export default defineUserConfig({
scopeName: "source.webgal",
path: path.resolve(__dirname, "../grammar/webgal.tmLanguage.json"),
},
"ts", "bash", "json", "xml", "kotlin",
"ts",
"bash",
"json",
"xml",
"kotlin",
"tsx",
"scss",
"html",
],

}),
],
locales: {
Expand Down
23 changes: 23 additions & 0 deletions src/.vuepress/sidebar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const zhSidebar = sidebar({
"variable",
"animation",
"special-effect",
"custom-ui",
]
},
{
Expand Down Expand Up @@ -105,5 +106,27 @@ export const zhSidebar = sidebar({
},
],
},
{
text: "模板参考",
prefix: "template-reference/",
children: [
{
text: "用户界面",
prefix: "ui/",
children: [
"choose",
"textbox",
"title",
],
},
{
text: "其他",
prefix: "others/",
children: [
"config",
],
},
]
},
],
});
65 changes: 65 additions & 0 deletions src/template-reference/others/config.md
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"
}
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在 JSON 格式中,数组或对象的最后一个元素后面不能有逗号(trailing comma)。如果保留此逗号,标准的 JSON 解析器(如 JSON.parse)在解析 template.json 时会报错,导致模板无法加载。建议移除该逗号。

Suggested change
],
]

}
```

### 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)。
42 changes: 42 additions & 0 deletions src/template-reference/ui/choose.md
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

选择按钮被禁用时的样式。
Loading
Loading