@kurot/cli 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +34 -10
- package/dist/core/template.d.ts.map +1 -1
- package/dist/core/template.js +1 -0
- package/dist/core/template.js.map +1 -1
- package/docs/ai-context.md +21 -15
- package/docs/architecture.md +1 -1
- package/docs/game-template.md +60 -0
- package/docs/label-text-layout.md +1 -1
- package/package.json +1 -1
- package/templates/game/package.json +2 -1
- package/templates/game/resource/assets/fonts/ChakraPetch-Bold.ttf +0 -0
- package/templates/game/resource/assets/fonts/ChakraPetch-Regular.ttf +0 -0
- package/templates/game/resource/assets/fonts/OFL.txt +93 -0
- package/templates/game/resource/config/locale.json +4 -0
- package/templates/game/resource/config/style.json +16 -0
- package/templates/game/resource/default.res.json +11 -1
- package/templates/game/resource/lang/lang_en_US.properties +5 -0
- package/templates/game/resource/ui/skins/ButtonSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/CheckBoxSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/ComboBoxSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/ItemRendererSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/PanelSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/ProgressBarSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/RadioButtonSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/TextInputSkin.kui.xml +1 -1
- package/templates/game/resource/ui/skins/ToggleButtonSkin.kui.xml +1 -1
- package/templates/game/src/LocaleManager.ts +109 -0
- package/templates/game/src/Main.ts +58 -34
- package/templates/game/src/StyleManager.ts +57 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ and CLI command/configuration APIs follow [Semantic Versioning](https://semver.o
|
|
|
7
7
|
The early KUI XML contract follows the pre-1.0 `ui-document` kernel; authored
|
|
8
8
|
format changes are documented explicitly in each release.
|
|
9
9
|
|
|
10
|
+
## 3.2.1 — 2026-10-06
|
|
11
|
+
|
|
12
|
+
### Game Template
|
|
13
|
+
|
|
14
|
+
- Include fixed style.json and locale.json configuration, English properties,
|
|
15
|
+
Chakra Petch regular/bold fonts and their SIL Open Font License.
|
|
16
|
+
- Load and publish project fonts before creating any UI, then register preload
|
|
17
|
+
translations using the URL language or configured default with English/key fallback.
|
|
18
|
+
- Use shared ui-document font/color validation and named disabled text colors;
|
|
19
|
+
default skins inherit the project font instead of hardcoded Tahoma.
|
|
20
|
+
- Keep the empty template minimal. Existing projects are not rewritten by scaffolding.
|
|
21
|
+
- Create resource/ui/app alongside the reusable component directories so the
|
|
22
|
+
application Skin workspace is ready for the Editor.
|
|
23
|
+
|
|
24
|
+
### Dependencies and Compatibility
|
|
25
|
+
|
|
26
|
+
- New game projects include ui-document for the shared stylesheet parser. The
|
|
27
|
+
compiler retains its existing ui-document ^0.10.0 dependency.
|
|
28
|
+
- Command/configuration APIs, KUI XML semantics and document format version 2
|
|
29
|
+
remain unchanged. Existing projects receive no automatic migration.
|
|
30
|
+
|
|
31
|
+
### Tests
|
|
32
|
+
|
|
33
|
+
- Validate bundled fonts/licenses, stylesheet colors, translation registration,
|
|
34
|
+
locale fallback, failed initialization and the unchanged empty template.
|
|
35
|
+
- Compile all bundled default skins with the project palette and verify newly
|
|
36
|
+
generated projects through strict builds, type checking and browser rendering.
|
|
37
|
+
|
|
10
38
|
## 3.2.0 — 2026-10-06
|
|
11
39
|
|
|
12
40
|
### Added
|
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Build tooling for the Kurot UI Editor workflow. It uses esbuild, emits ES2022
|
|
4
4
|
ESM, and compiles canonical KUI XML skins into runtime theme modules.
|
|
5
5
|
|
|
6
|
-
> **Current
|
|
6
|
+
> **Current version: 3.2.1 (prepared for publication).** Requires `@kurot/ui-document@^0.10.0`
|
|
7
|
+
> and Node.js 20 or later. The CLI runs only at build time.
|
|
7
8
|
|
|
8
9
|
> **Release scope:** The 3.x line is dedicated to Kurot Editor integration.
|
|
9
10
|
> Existing game projects that use EXML should remain on
|
|
@@ -12,6 +13,9 @@ ESM, and compiles canonical KUI XML skins into runtime theme modules.
|
|
|
12
13
|
|
|
13
14
|
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
14
15
|
|
|
16
|
+
Version 3.2.1 adds project styles, bundled fonts and English translations to the
|
|
17
|
+
game template. Existing projects are not rewritten. See [game template setup](docs/game-template.md).
|
|
18
|
+
|
|
15
19
|
## Label text fitting in 3.1.0
|
|
16
20
|
|
|
17
21
|
The shared ui-document catalog supports Label `textFit` and `minFontSize`
|
|
@@ -37,7 +41,7 @@ See the [compilation contract](docs/label-text-layout.md) and
|
|
|
37
41
|
The CLI does not require a global install.
|
|
38
42
|
|
|
39
43
|
```bash
|
|
40
|
-
npx @kurot/cli create my-game
|
|
44
|
+
npx @kurot/cli@3.2.1 create my-game
|
|
41
45
|
cd my-game
|
|
42
46
|
pnpm install
|
|
43
47
|
pnpm dev
|
|
@@ -45,7 +49,7 @@ pnpm dev
|
|
|
45
49
|
|
|
46
50
|
Scaffolded projects expose `build`, `dev`, and `clean` scripts. For an
|
|
47
51
|
Editor-managed KUI XML project, install the package with
|
|
48
|
-
`pnpm add -D @kurot/cli@^3.2.
|
|
52
|
+
`pnpm add -D @kurot/cli@^3.2.1`. Existing EXML projects should keep their current
|
|
49
53
|
1.3.x dependency.
|
|
50
54
|
|
|
51
55
|
## Commands
|
|
@@ -56,9 +60,11 @@ Editor-managed KUI XML project, install the package with
|
|
|
56
60
|
kurot create <name> [--template game|empty]
|
|
57
61
|
```
|
|
58
62
|
|
|
59
|
-
The `game` template includes `@kurot/core`, `@kurot/game`, `@kurot/ui`,
|
|
60
|
-
skins,
|
|
61
|
-
|
|
63
|
+
The `game` template includes `@kurot/core`, `@kurot/game`, `@kurot/ui`,
|
|
64
|
+
`@kurot/ui-document`, KUI skins, project styles/fonts, English translations,
|
|
65
|
+
resource loading, and an editable HTML template. Fonts load before creating UI;
|
|
66
|
+
translations register after preload. The `empty` template contains a minimal
|
|
67
|
+
`Sprite` application without UI/style/language dependencies.
|
|
62
68
|
|
|
63
69
|
### `kurot build`
|
|
64
70
|
|
|
@@ -153,7 +159,7 @@ use `property.state` on the affected node, so internal graphics remain unnamed.
|
|
|
153
159
|
Image sources use their resource key directly, for example
|
|
154
160
|
`source="button_up_png"`.
|
|
155
161
|
|
|
156
|
-
Version 3.2.
|
|
162
|
+
Version 3.2.1 uses `@kurot/ui-document@^0.10.0` and retains its literal-string XML rules.
|
|
157
163
|
For example, `<Label text="100.80" text.down="false" size="48" />` compiles
|
|
158
164
|
the exact strings `100.80` and `false`, while the font size stays numeric.
|
|
159
165
|
String properties no longer add or remove backslash type escapes. Remove old
|
|
@@ -206,17 +212,33 @@ my-game/
|
|
|
206
212
|
├── kurot.config.ts
|
|
207
213
|
├── resource/
|
|
208
214
|
│ ├── default.res.json
|
|
209
|
-
│ ├──
|
|
215
|
+
│ ├── config/
|
|
216
|
+
│ │ ├── style.json
|
|
217
|
+
│ │ └── locale.json
|
|
218
|
+
│ ├── lang/lang_en_US.properties
|
|
219
|
+
│ ├── assets/fonts/
|
|
220
|
+
│ │ ├── ChakraPetch-Regular.ttf
|
|
221
|
+
│ │ ├── ChakraPetch-Bold.ttf
|
|
222
|
+
│ │ └── OFL.txt
|
|
210
223
|
│ └── ui/
|
|
224
|
+
│ ├── app/
|
|
211
225
|
│ ├── components/
|
|
212
226
|
│ └── skins/*.kui.xml
|
|
213
227
|
├── src/
|
|
214
228
|
│ ├── components/
|
|
215
|
-
│ ├──
|
|
229
|
+
│ ├── Preloader.ts
|
|
230
|
+
│ ├── StyleManager.ts
|
|
231
|
+
│ ├── LocaleManager.ts
|
|
216
232
|
│ └── Main.ts
|
|
217
233
|
└── template/web/index.html
|
|
218
234
|
```
|
|
219
235
|
|
|
236
|
+
StyleManager uses the same ui-document stylesheet parser as the compiler/Editor.
|
|
237
|
+
`style.json` is read directly, independently of the manifest; locale.json and
|
|
238
|
+
enabled properties files are registered in `preload`. Replace fonts by changing
|
|
239
|
+
the resource-relative files/paths, and add languages through the Editor.
|
|
240
|
+
See [game template setup](docs/game-template.md) for lifecycle and fallback rules.
|
|
241
|
+
|
|
220
242
|
## Resource defaults in 3.0.0
|
|
221
243
|
|
|
222
244
|
KUI builds validate `resource/default.res.json` and inherit image or sheet-frame
|
|
@@ -253,7 +275,9 @@ An absent stylesheet is allowed when no Skin references its colors. An existing
|
|
|
253
275
|
stylesheet must contain valid font definitions even if the build only consumes
|
|
254
276
|
colors; see the shared [project style contract](../ui-document/docs/project-styles.md).
|
|
255
277
|
The CLI does not load fonts, apply runtime CSS or introduce live game theme
|
|
256
|
-
switching.
|
|
278
|
+
switching. CLI-built skins run directly through `@kurot/ui`; `@kurot/ui-runtime`
|
|
279
|
+
is not required for this compilation path. Node.js >= 20 and semantic format
|
|
280
|
+
version 2 remain unchanged.
|
|
257
281
|
|
|
258
282
|
The previous `@token:color:<key>` XML prefix is rejected by ui-document 0.10.
|
|
259
283
|
Update those references explicitly before adopting CLI 3.2; ordinary text stays
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,SAAS,4BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,SAAS,4BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BzF"}
|
package/dist/core/template.js
CHANGED
|
@@ -33,6 +33,7 @@ export async function scaffoldProject(name, template) {
|
|
|
33
33
|
await Promise.all([
|
|
34
34
|
ensureDir(path.join(destDir, 'src/components')),
|
|
35
35
|
ensureDir(path.join(destDir, 'resource/ui/components')),
|
|
36
|
+
ensureDir(path.join(destDir, 'resource/ui/app')),
|
|
36
37
|
]);
|
|
37
38
|
}
|
|
38
39
|
const pkgPath = path.join(destDir, 'package.json');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AASvE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AACjE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC;AAOpD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY,EAAE,QAAsB;IACzE,MAAM,WAA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AAE,CAAC,CAAC;QACpE,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAyB,CAAC;YACxD,IAAI,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7C,CAAC;IACF,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAwB,CAAC;IACnF,OAAO,GAAG,CAAC,OAAO,CAAC;AACpB,CAAC"}
|
package/docs/ai-context.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @kurot/cli — AI context map
|
|
2
2
|
|
|
3
3
|
Read this before exploring `src/`. [`architecture.md`](./architecture.md)
|
|
4
|
-
explains the plugin pipeline. The package is `@kurot/cli@3.2.
|
|
4
|
+
explains the plugin pipeline. The package is `@kurot/cli@3.2.1`, runs on
|
|
5
5
|
Node.js 20+, and is installed as a project dev dependency.
|
|
6
6
|
|
|
7
7
|
## Directory map
|
|
@@ -24,6 +24,11 @@ src/
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Project templates are under `templates/game` and `templates/empty`.
|
|
27
|
+
The 3.2.1 game template includes fixed style/locale configuration,
|
|
28
|
+
English properties and licensed regular/bold font files. StyleManager finishes
|
|
29
|
+
font loading before Main creates Player/Preloader; LocaleManager registers
|
|
30
|
+
preload texts before creating the scene. See [game-template.md](game-template.md).
|
|
31
|
+
Version 3.2.1 is prepared for publication; 3.2.0 is already published.
|
|
27
32
|
|
|
28
33
|
## KUI compilation
|
|
29
34
|
|
|
@@ -39,7 +44,7 @@ and layout apply to the runtime Skin, and its direct visual children become
|
|
|
39
44
|
`property.state` attributes. Storage IDs and runtime mapping metadata are not
|
|
40
45
|
authored XML fields.
|
|
41
46
|
|
|
42
|
-
CLI 3.2.
|
|
47
|
+
CLI 3.2.1 requires `@kurot/ui-document@^0.10.0`. Schema-defined strings, including
|
|
43
48
|
numeric/boolean-looking text and state text, are literal attributes without
|
|
44
49
|
backslash type escaping. Old synthetic prefixes become literal characters;
|
|
45
50
|
do not migrate them silently. Numeric/boolean properties and schema-free
|
|
@@ -116,19 +121,20 @@ in `namespace-external-plugin.ts`.
|
|
|
116
121
|
|
|
117
122
|
## Configuration lookup
|
|
118
123
|
|
|
119
|
-
| Task | File
|
|
120
|
-
| -------------------------------- |
|
|
121
|
-
| Add or validate a config field | `src/core/config.ts`
|
|
122
|
-
| Resolve an absolute project path | `src/core/project.ts`
|
|
123
|
-
| Change KUI scanning/theme output | `src/core/plugins/compile-kui.ts`
|
|
124
|
-
| Change KUI node code generation | `src/core/kui/kui-parser.ts`, `codegen.ts`
|
|
125
|
-
| Add a built-in component tag | `src/core/kui/registry.ts`
|
|
126
|
-
| Change generated part types | `src/core/kui/skin-parts-declaration.ts`
|
|
127
|
-
| Change component pairing | `src/core/components/discover-components.ts`
|
|
128
|
-
| Change watch behavior | `src/core/dev-server.ts`
|
|
129
|
-
| Change output HTML/import maps | `src/core/plugins/generate-html.ts`
|
|
130
|
-
| Change scaffolding | `src/core/template.ts`, `templates/`
|
|
131
|
-
|
|
|
124
|
+
| Task | File |
|
|
125
|
+
| -------------------------------- | ------------------------------------------------------------------- |
|
|
126
|
+
| Add or validate a config field | `src/core/config.ts` |
|
|
127
|
+
| Resolve an absolute project path | `src/core/project.ts` |
|
|
128
|
+
| Change KUI scanning/theme output | `src/core/plugins/compile-kui.ts` |
|
|
129
|
+
| Change KUI node code generation | `src/core/kui/kui-parser.ts`, `codegen.ts` |
|
|
130
|
+
| Add a built-in component tag | `src/core/kui/registry.ts` |
|
|
131
|
+
| Change generated part types | `src/core/kui/skin-parts-declaration.ts` |
|
|
132
|
+
| Change component pairing | `src/core/components/discover-components.ts` |
|
|
133
|
+
| Change watch behavior | `src/core/dev-server.ts` |
|
|
134
|
+
| Change output HTML/import maps | `src/core/plugins/generate-html.ts` |
|
|
135
|
+
| Change scaffolding | `src/core/template.ts`, `templates/` |
|
|
136
|
+
| Change project style/locale boot | `templates/game/src/StyleManager.ts`, `LocaleManager.ts`, `Main.ts` |
|
|
137
|
+
| Add a diagnostic code | `src/core/diagnostics/codes.ts` |
|
|
132
138
|
|
|
133
139
|
## Verification
|
|
134
140
|
|
package/docs/architecture.md
CHANGED
|
@@ -39,7 +39,7 @@ factory variables, property assignments, semantic layout children, and state
|
|
|
39
39
|
property overrides. Document contracts, reusable instances, data bindings, and
|
|
40
40
|
actions remain `UIDocument` concepts.
|
|
41
41
|
|
|
42
|
-
CLI 3.2.
|
|
42
|
+
CLI 3.2.1 consumes ui-document 0.10.x, retaining Label text-fitting metadata. The
|
|
43
43
|
compiler emits `textFit`, `minFontSize`, base font sizes and state overrides;
|
|
44
44
|
native UI owns measurement and derives drawing sizes after layout validation.
|
|
45
45
|
See [Label compilation](label-text-layout.md). The application supplies UI
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Project styles and languages in the game template
|
|
2
|
+
|
|
3
|
+
CLI 3.2.1 includes this template update and is prepared for publication. It adds
|
|
4
|
+
project-owned initialization without changing Core/UI APIs or migrating existing
|
|
5
|
+
projects. The empty template stays minimal.
|
|
6
|
+
|
|
7
|
+
## Files
|
|
8
|
+
|
|
9
|
+
- resource/config/style.json declares the primary font role and disabled-text color.
|
|
10
|
+
- resource/assets/fonts contains unmodified Chakra Petch regular (400) and bold (700)
|
|
11
|
+
files, with OFL.txt. Source: [Google Fonts](https://github.com/google/fonts/tree/main/ofl/chakrapetch).
|
|
12
|
+
- resource/config/locale.json enables English and selects en_US by default.
|
|
13
|
+
- resource/lang/lang_en_US.properties contains the scene title, button and descriptions.
|
|
14
|
+
- default.res.json registers locale_json and lang_en_US_properties in preload.
|
|
15
|
+
style.json and fonts are read directly and need no manifest entries.
|
|
16
|
+
|
|
17
|
+
## Startup order
|
|
18
|
+
|
|
19
|
+
1. StyleManager reads and validates the stylesheet through published ui-document.
|
|
20
|
+
2. It loads every configured FontFace; only after all succeed does it register
|
|
21
|
+
faces and publish the default CSS font family and numeric color palette.
|
|
22
|
+
3. Main sets TextField.default_fontFamily, then creates Player and the Preloader.
|
|
23
|
+
4. Main loads the manifest, theme and preload resources.
|
|
24
|
+
5. LocaleManager registers the enabled text files, selects the language and creates
|
|
25
|
+
the translated scene. Startup errors are reported through console.error.
|
|
26
|
+
|
|
27
|
+
This ordering includes loading-screen Labels in the project font. The loading
|
|
28
|
+
screen's startup messages stay in English because translations are not loaded yet.
|
|
29
|
+
Templates do not implement live font/theme/language replacement.
|
|
30
|
+
|
|
31
|
+
## Change fonts and colors
|
|
32
|
+
|
|
33
|
+
Font keys such as primary produce stable aliases such as kurot-primary. Replace
|
|
34
|
+
files and update style.json resource-relative paths, retaining weight 400 and
|
|
35
|
+
unique weights. Default skins inherit the configured font; explicit Label fontFamily
|
|
36
|
+
values still override it. Existing stylesheet files must contain valid font definitions.
|
|
37
|
+
Keep the font's applicable license with any replacement distribution.
|
|
38
|
+
|
|
39
|
+
Label state colors use textColor.disabled="@style:colors:disabled-text". The CLI
|
|
40
|
+
compiles these references into numbers. Dynamic application code reads the same
|
|
41
|
+
palette through StyleManager.getColor('disabled-text'); enabled state behavior and
|
|
42
|
+
restoration of a normal color remain application responsibilities.
|
|
43
|
+
|
|
44
|
+
## Add languages
|
|
45
|
+
|
|
46
|
+
Use the Editor's language window to add a code, create its properties file and
|
|
47
|
+
update locale.json/default.res.json together. Only English is initially enabled.
|
|
48
|
+
Manual additions must use lang_<code>_properties text resources in preload.
|
|
49
|
+
|
|
50
|
+
LocaleManager accepts the project default or URL ?lang=fr / ?lang=fr_FR / ?lang=fr-FR.
|
|
51
|
+
A full code match wins, then a matching base language, then the configured default.
|
|
52
|
+
The default may be empty. Absent configuration or an empty language list clears registrations;
|
|
53
|
+
enabled languages with unavailable text resources or an invalid default fail before
|
|
54
|
+
publishing the new set. The last successful set is retained on initialization failure.
|
|
55
|
+
|
|
56
|
+
getString(key, ...args) reads the current translation, then English, then the key.
|
|
57
|
+
An explicitly empty translation remains empty. The simple properties format uses
|
|
58
|
+
one key=value per line, #/! comments, common escapes including newline/Unicode,
|
|
59
|
+
and {0}, {1} placeholders. Continuation lines and Java properties' colon-only
|
|
60
|
+
separators are not supported. UI translation is explicit; it is not an engine binding.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Label text compilation
|
|
2
2
|
|
|
3
|
-
CLI 3.2.
|
|
3
|
+
CLI 3.2.1 consumes ui-document 0.10.x and compiles KUI text-fitting properties
|
|
4
4
|
through the existing UIDocument → SkinIR → ESM factory pipeline. The semantic
|
|
5
5
|
document format remains version 2.
|
|
6
6
|
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2018 The Chakra Petch Project Authors (https://github.com/m4rc1e/Chakra-Petch.git)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"fonts": {
|
|
4
|
+
"default": "primary",
|
|
5
|
+
"families": {
|
|
6
|
+
"primary": {
|
|
7
|
+
"fallback": ["Arial", "sans-serif"],
|
|
8
|
+
"faces": [
|
|
9
|
+
{ "url": "assets/fonts/ChakraPetch-Regular.ttf", "weight": 400 },
|
|
10
|
+
{ "url": "assets/fonts/ChakraPetch-Bold.ttf", "weight": 700 }
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"colors": { "disabled-text": "#999999" }
|
|
16
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"groups": [
|
|
3
3
|
{
|
|
4
|
-
"keys": "eui",
|
|
4
|
+
"keys": "eui,locale_json,lang_en_US_properties",
|
|
5
5
|
"name": "preload"
|
|
6
6
|
}
|
|
7
7
|
],
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
"name": "eui",
|
|
11
11
|
"type": "sheet",
|
|
12
12
|
"url": "assets/ui/eui/eui.json"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "locale_json",
|
|
16
|
+
"type": "json",
|
|
17
|
+
"url": "config/locale.json"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "lang_en_US_properties",
|
|
21
|
+
"type": "text",
|
|
22
|
+
"url": "lang/lang_en_US.properties"
|
|
13
23
|
}
|
|
14
24
|
]
|
|
15
25
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<Skin xmlns="https://kurot.dev/ui/1" class="skins.ButtonSkin" states="disabled,down,up" minHeight="50" minWidth="100">
|
|
3
3
|
<Image height="100%" scale9Grid="1,3,8,8" source="button_up_png" width="100%" alpha.disabled="0.5" source.down="button_down_png" />
|
|
4
|
-
<Label id="labelDisplay" bottom="8" left="8" right="8" size="20" textAlign="center" textColor="#FFFFFF" top="8" verticalAlign="middle" />
|
|
4
|
+
<Label id="labelDisplay" bottom="8" left="8" right="8" size="20" textAlign="center" textColor="#FFFFFF" textColor.disabled="@style:colors:disabled-text" top="8" verticalAlign="middle" />
|
|
5
5
|
<Image id="iconDisplay" horizontalCenter="0" verticalCenter="0" />
|
|
6
6
|
</Skin>
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
<HorizontalLayout verticalAlign="middle" />
|
|
6
6
|
</layout>
|
|
7
7
|
<Image alpha="1" fillMode="scale" source="checkbox_unselect_png" alpha.disabled="0.5" source.disabledAndSelected="checkbox_select_disabled_png" alpha.down="0.7" source.downAndSelected="checkbox_select_down_png" source.upAndSelected="checkbox_select_up_png" />
|
|
8
|
-
<Label id="labelDisplay"
|
|
8
|
+
<Label id="labelDisplay" size="20" textAlign="center" textColor="#707070" verticalAlign="middle" />
|
|
9
9
|
</Group>
|
|
10
10
|
</Skin>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<Skin xmlns="https://kurot.dev/ui/1" class="skins.ComboBoxSkin" states="disabled,normal,open" minHeight="36" minWidth="100">
|
|
3
3
|
<Rect fillColor="#1A1A2E" height="36" strokeColor="#0F3460" strokeWeight="1" width="100%" fillColor.disabled="#16213E" strokeColor.disabled="#4A5459" fillColor.open="#16213E" strokeColor.open="#6C5CE7" />
|
|
4
|
-
<Label id="labelDisplay" height="36" left="10" right="36" size="14" textColor="#DFE6E9" top="0" verticalAlign="middle" textColor.disabled="
|
|
4
|
+
<Label id="labelDisplay" height="36" left="10" right="36" size="14" textColor="#DFE6E9" top="0" verticalAlign="middle" textColor.disabled="@style:colors:disabled-text" />
|
|
5
5
|
<Label height="36" right="4" size="10" text="▼" textAlign="center" textColor="#636E72" top="0" verticalAlign="middle" width="24" textColor.open="#6C5CE7" />
|
|
6
6
|
<Scroller id="dropDown" height="180" left="0" right="0" top="36" visible="false">
|
|
7
7
|
<List id="list" height="180" width="100%" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<Skin xmlns="https://kurot.dev/ui/1" class="skins.ItemRendererSkin" states="disabled,down,up" minHeight="50" minWidth="100">
|
|
3
3
|
<Image height="100%" scale9Grid="1,3,8,8" source="button_up_png" width="100%" alpha.disabled="0.5" source.down="button_down_png" />
|
|
4
|
-
<Label id="labelDisplay" bottom="8"
|
|
4
|
+
<Label id="labelDisplay" bottom="8" left="8" right="8" size="20" textAlign="center" textColor="#FFFFFF" top="8" verticalAlign="middle" />
|
|
5
5
|
</Skin>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<Image bottom="0" left="0" right="0" scale9Grid="2,2,12,12" source="border_png" top="0" />
|
|
4
4
|
<Group id="moveArea" height="45" left="0" right="0" top="0">
|
|
5
5
|
<Image bottom="0" left="0" right="0" scale9Grid="2,2,12,12" source="header_png" top="0" />
|
|
6
|
-
<Label id="titleDisplay"
|
|
6
|
+
<Label id="titleDisplay" left="15" right="5" size="20" textColor="#FFFFFF" verticalCenter="0" wordWrap="false" />
|
|
7
7
|
</Group>
|
|
8
8
|
<Button id="closeButton" bottom="5" horizontalCenter="0" label="close" />
|
|
9
9
|
</Skin>
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
<Skin xmlns="https://kurot.dev/ui/1" class="skins.ProgressBarSkin" minHeight="18" minWidth="30">
|
|
3
3
|
<Image height="100%" scale9Grid="1,1,4,4" source="track_pb_png" verticalCenter="0" width="100%" />
|
|
4
4
|
<Image id="thumb" height="100%" scale9Grid="1,1,4,4" source="thumb_pb_png" width="100%" />
|
|
5
|
-
<Label id="labelDisplay"
|
|
5
|
+
<Label id="labelDisplay" horizontalCenter="0" size="15" textAlign="center" textColor="#707070" verticalAlign="middle" verticalCenter="0" />
|
|
6
6
|
</Skin>
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
<HorizontalLayout verticalAlign="middle" />
|
|
6
6
|
</layout>
|
|
7
7
|
<Image alpha="1" fillMode="scale" source="radiobutton_unselect_png" alpha.disabled="0.5" source.disabledAndSelected="radiobutton_select_disabled_png" alpha.down="0.7" source.downAndSelected="radiobutton_select_down_png" source.upAndSelected="radiobutton_select_up_png" />
|
|
8
|
-
<Label id="labelDisplay"
|
|
8
|
+
<Label id="labelDisplay" size="20" textAlign="center" textColor="#707070" verticalAlign="middle" />
|
|
9
9
|
</Group>
|
|
10
10
|
</Skin>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<Skin xmlns="https://kurot.dev/ui/1" class="skins.TextInputSkin" states="disabled,disabledWithPrompt,normal,normalWithPrompt" minHeight="40" minWidth="300">
|
|
3
3
|
<Rect fillColor="#FFFFFF" height="100%" width="100%" alpha.disabled="0.5" />
|
|
4
|
-
<EditableText id="textDisplay" height="24" left="10" right="10" size="20" textColor="#000000" verticalAlign="middle" verticalCenter="0" textColor.disabled="
|
|
4
|
+
<EditableText id="textDisplay" height="24" left="10" right="10" size="20" textColor="#000000" verticalAlign="middle" verticalCenter="0" textColor.disabled="@style:colors:disabled-text" />
|
|
5
5
|
<Label id="promptDisplay" height="24" left="10" multiline="false" right="10" size="20" textColor="#A9A9A9" touchEnabled="false" verticalAlign="middle" verticalCenter="0" visible="false" wordWrap="false" visible.disabledWithPrompt="true" visible.normalWithPrompt="true" />
|
|
6
6
|
</Skin>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<Skin xmlns="https://kurot.dev/ui/1" class="skins.ToggleButtonSkin" states="disabled,disabledAndSelected,down,downAndSelected,up,upAndSelected" minHeight="50" minWidth="100">
|
|
3
3
|
<Rect fillColor="#636E72" height="100%" strokeColor="#4A5459" strokeWeight="1" width="100%" fillColor.disabled="#2D3436" fillColor.disabledAndSelected="#2D3436" fillColor.down="#4A5459" fillColor.downAndSelected="#5A4BD1" fillColor.upAndSelected="#6C5CE7" />
|
|
4
|
-
<Label id="labelDisplay" bottom="8" left="8" right="8" size="16" textAlign="center" textColor="#DFE6E9" top="8" verticalAlign="middle" textColor.disabled="
|
|
4
|
+
<Label id="labelDisplay" bottom="8" left="8" right="8" size="16" textAlign="center" textColor="#DFE6E9" top="8" verticalAlign="middle" textColor.disabled="@style:colors:disabled-text" textColor.upAndSelected="#FFFFFF" />
|
|
5
5
|
</Skin>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* preload 完成后注册项目翻译。URL 的 lang 优先,缺失翻译回退英语,再回退键名。
|
|
3
|
+
* 不监听 UI、不自动重写文本;界面创建时主动调用 getString。
|
|
4
|
+
*/
|
|
5
|
+
export class LocaleManager {
|
|
6
|
+
private static _locales = new Map<string, ReadonlyMap<string, string>>();
|
|
7
|
+
private static _currentLocale = '';
|
|
8
|
+
|
|
9
|
+
public static get currentLocale(): string {
|
|
10
|
+
return this._currentLocale;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 先验证整份配置及语言资源,成功后一起替换,避免加载失败留下半套翻译。
|
|
15
|
+
*/
|
|
16
|
+
public static init(config: unknown, readResource: (name: string) => unknown, requestedLocale = ''): void {
|
|
17
|
+
const locales = new Map<string, ReadonlyMap<string, string>>();
|
|
18
|
+
let defaultLocale = '';
|
|
19
|
+
if (config !== undefined) {
|
|
20
|
+
if (!isRecord(config) || !Array.isArray(config.locale)) {
|
|
21
|
+
throw new Error('locale.json must contain a locale array.');
|
|
22
|
+
}
|
|
23
|
+
for (const entry of config.locale as unknown[]) {
|
|
24
|
+
if (
|
|
25
|
+
!isRecord(entry) ||
|
|
26
|
+
typeof entry.code !== 'string' ||
|
|
27
|
+
!/^[a-z]{2}_[A-Z]{2}$/.test(entry.code) ||
|
|
28
|
+
typeof entry.name !== 'string' ||
|
|
29
|
+
entry.name.trim() === ''
|
|
30
|
+
) {
|
|
31
|
+
throw new Error('Each project language must have a language code and name.');
|
|
32
|
+
}
|
|
33
|
+
if (locales.has(entry.code)) {
|
|
34
|
+
throw new Error(`Duplicate project language: ${entry.code}.`);
|
|
35
|
+
}
|
|
36
|
+
const source = readResource(`lang_${entry.code}_properties`);
|
|
37
|
+
if (typeof source !== 'string') {
|
|
38
|
+
throw new Error(`Language resource is unavailable: ${entry.code}.`);
|
|
39
|
+
}
|
|
40
|
+
locales.set(entry.code, this._parse(source));
|
|
41
|
+
}
|
|
42
|
+
const configuredDefault =
|
|
43
|
+
config.defaultLocale === undefined ? (locales.has('en_US') ? 'en_US' : '') : config.defaultLocale;
|
|
44
|
+
if (
|
|
45
|
+
typeof configuredDefault !== 'string' ||
|
|
46
|
+
(configuredDefault !== '' && !locales.has(configuredDefault))
|
|
47
|
+
) {
|
|
48
|
+
throw new Error('defaultLocale must name an enabled language or be empty.');
|
|
49
|
+
}
|
|
50
|
+
defaultLocale = configuredDefault;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const normalized = requestedLocale.trim().replace(/-/g, '_').toLowerCase();
|
|
54
|
+
const codes = [...locales.keys()];
|
|
55
|
+
const exact = codes.find(code => code.toLowerCase() === normalized);
|
|
56
|
+
const base = normalized.split('_')[0];
|
|
57
|
+
this._currentLocale = exact ?? codes.find(code => code.toLowerCase().split('_')[0] === base) ?? defaultLocale;
|
|
58
|
+
this._locales = locales;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public static getString(key: string, ...args: Array<string | number>): string {
|
|
62
|
+
const text = this._locales.get(this._currentLocale)?.get(key) ?? this._locales.get('en_US')?.get(key) ?? key;
|
|
63
|
+
return text.replace(/\{(\d+)\}/g, (placeholder: string, index: string) => {
|
|
64
|
+
const argument = args[Number(index)];
|
|
65
|
+
return argument === undefined ? placeholder : String(argument);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private static _parse(source: string): ReadonlyMap<string, string> {
|
|
70
|
+
const values = new Map<string, string>();
|
|
71
|
+
for (const line of source.split(/\r?\n/)) {
|
|
72
|
+
const content = line.trim();
|
|
73
|
+
if (!content || content.startsWith('#') || content.startsWith('!')) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const split = line.indexOf('=');
|
|
77
|
+
if (split < 0) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const key = line.slice(0, split).trim();
|
|
81
|
+
if (key) {
|
|
82
|
+
values.set(key, this._decodeValue(line.slice(split + 1).trim()));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return values;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private static _decodeValue(value: string): string {
|
|
89
|
+
return value.replace(/\\(u[0-9a-fA-F]{4}|[nrt\\=: ])/g, (_match: string, escape: string) => {
|
|
90
|
+
if (escape.startsWith('u')) {
|
|
91
|
+
return String.fromCharCode(Number.parseInt(escape.slice(1), 16));
|
|
92
|
+
}
|
|
93
|
+
switch (escape) {
|
|
94
|
+
case 'n':
|
|
95
|
+
return '\n';
|
|
96
|
+
case 'r':
|
|
97
|
+
return '\r';
|
|
98
|
+
case 't':
|
|
99
|
+
return '\t';
|
|
100
|
+
default:
|
|
101
|
+
return escape;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
108
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
109
|
+
}
|
|
@@ -5,15 +5,18 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Lifecycle: constructor → ADDED_TO_STAGE → $onAddToStage → runGame → load → createGameScene → startAnimation
|
|
7
7
|
*/
|
|
8
|
-
import { createPlayer, Event, resource } from '@kurot/core';
|
|
8
|
+
import { createPlayer, Event, resource, TextField } from '@kurot/core';
|
|
9
9
|
import { Button, Label, Rect, Theme, UILayer, setAssetAdapter } from '@kurot/ui';
|
|
10
10
|
import { Tween } from '@kurot/game';
|
|
11
11
|
import { AssetAdapter } from '@/AssetAdapter';
|
|
12
12
|
import { LifecycleHandler } from '@/LifecycleHandler';
|
|
13
13
|
import { Preloader } from '@/Preloader';
|
|
14
|
+
import { LocaleManager } from '@/LocaleManager';
|
|
15
|
+
import { StyleManager } from '@/StyleManager';
|
|
14
16
|
|
|
15
17
|
class Main extends UILayer {
|
|
16
18
|
private readonly _preloader = new Preloader();
|
|
19
|
+
private _description!: Label;
|
|
17
20
|
|
|
18
21
|
createChildren(): void {
|
|
19
22
|
super.createChildren();
|
|
@@ -24,25 +27,25 @@ class Main extends UILayer {
|
|
|
24
27
|
setAssetAdapter(new AssetAdapter());
|
|
25
28
|
LifecycleHandler.init(stage);
|
|
26
29
|
|
|
27
|
-
void this.
|
|
30
|
+
void this._runGame().catch(error => {
|
|
28
31
|
console.error('[Main] Unable to start game:', error);
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
private async
|
|
33
|
-
await this.
|
|
34
|
-
await this.
|
|
35
|
+
private async _runGame(): Promise<void> {
|
|
36
|
+
await this._createPreloader();
|
|
37
|
+
await this._load();
|
|
35
38
|
this._preloader.destroy();
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
39
|
+
this._createGameScene();
|
|
40
|
+
this._startAnimation();
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
private async
|
|
41
|
-
await this.
|
|
43
|
+
private async _load(): Promise<void> {
|
|
44
|
+
await this._updatePreloader('Loading resource configuration...', 1, 2);
|
|
42
45
|
await resource.loadConfig('resource/default.res.json', 'resource/');
|
|
43
46
|
|
|
44
|
-
await this.
|
|
45
|
-
await this.
|
|
47
|
+
await this._updatePreloader('Loading theme...', 2, 2);
|
|
48
|
+
await this._loadTheme();
|
|
46
49
|
|
|
47
50
|
if (resource.hasGroup('preload')) {
|
|
48
51
|
this._preloader.updateText('Loading resources...');
|
|
@@ -50,39 +53,44 @@ class Main extends UILayer {
|
|
|
50
53
|
this._preloader.onProgress(loaded, total);
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
// 翻译依赖 preload 中的文本资源;加载完毕后再创建业务界面。
|
|
58
|
+
LocaleManager.init(
|
|
59
|
+
resource.get('locale_json'),
|
|
60
|
+
name => resource.get(name),
|
|
61
|
+
new URLSearchParams(window.location.search).get('lang') ?? '',
|
|
62
|
+
);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
private async
|
|
65
|
+
private async _createPreloader(): Promise<void> {
|
|
56
66
|
await this._preloader.init();
|
|
57
67
|
this.addChild(this._preloader);
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
private async
|
|
70
|
+
private async _updatePreloader(message: string, current: number, total: number): Promise<void> {
|
|
61
71
|
this._preloader.updateText(message);
|
|
62
72
|
this._preloader.updateProgress(current, total);
|
|
63
|
-
await this.
|
|
73
|
+
await this._wait(0.1);
|
|
64
74
|
}
|
|
65
75
|
|
|
66
|
-
private async
|
|
76
|
+
private async _loadTheme(): Promise<void> {
|
|
67
77
|
// Load the theme and its default UI skin mappings.
|
|
68
78
|
const theme = new Theme('resource/default.thm.json');
|
|
69
79
|
await new Promise<void>(resolve => theme.addEventListener(Event.COMPLETE, () => resolve()));
|
|
70
80
|
}
|
|
71
81
|
|
|
72
|
-
private
|
|
82
|
+
private _wait(timeout: number): Promise<void> {
|
|
73
83
|
return new Promise<void>(resolve => {
|
|
74
84
|
setTimeout(resolve, timeout * 1000);
|
|
75
85
|
});
|
|
76
86
|
}
|
|
77
87
|
|
|
78
|
-
private textfield!: Label;
|
|
79
|
-
|
|
80
88
|
/**
|
|
81
89
|
* Create the game scene.
|
|
82
90
|
*
|
|
83
91
|
* Build a responsive view with EUI components and constraint-based layout.
|
|
84
92
|
*/
|
|
85
|
-
private
|
|
93
|
+
private _createGameScene(): void {
|
|
86
94
|
// Responsive background
|
|
87
95
|
const sky = new Rect();
|
|
88
96
|
sky.left = 0;
|
|
@@ -111,7 +119,7 @@ class Main extends UILayer {
|
|
|
111
119
|
colorLabel.height = 48;
|
|
112
120
|
colorLabel.textAlign = 'center';
|
|
113
121
|
colorLabel.verticalAlign = 'middle';
|
|
114
|
-
colorLabel.text = '
|
|
122
|
+
colorLabel.text = LocaleManager.getString('label.title');
|
|
115
123
|
colorLabel.size = 36;
|
|
116
124
|
this.addChild(colorLabel);
|
|
117
125
|
|
|
@@ -127,11 +135,11 @@ class Main extends UILayer {
|
|
|
127
135
|
textfield.verticalAlign = 'middle';
|
|
128
136
|
textfield.size = 24;
|
|
129
137
|
textfield.textColor = 0xffffff;
|
|
130
|
-
this.
|
|
138
|
+
this._description = textfield;
|
|
131
139
|
|
|
132
140
|
// UI button using the default theme
|
|
133
141
|
const button = new Button();
|
|
134
|
-
button.label = '
|
|
142
|
+
button.label = LocaleManager.getString('label.button');
|
|
135
143
|
button.horizontalCenter = 0;
|
|
136
144
|
button.top = 200;
|
|
137
145
|
button.width = 200;
|
|
@@ -141,16 +149,20 @@ class Main extends UILayer {
|
|
|
141
149
|
/**
|
|
142
150
|
* Play a looping text fade animation.
|
|
143
151
|
*/
|
|
144
|
-
private
|
|
145
|
-
const texts = [
|
|
152
|
+
private _startAnimation(): void {
|
|
153
|
+
const texts = [
|
|
154
|
+
LocaleManager.getString('label.description.open_source'),
|
|
155
|
+
LocaleManager.getString('label.description.push_forward'),
|
|
156
|
+
LocaleManager.getString('label.description.engine'),
|
|
157
|
+
];
|
|
146
158
|
let count = -1;
|
|
147
159
|
const change = () => {
|
|
148
160
|
count++;
|
|
149
161
|
if (count >= texts.length) {
|
|
150
162
|
count = 0;
|
|
151
163
|
}
|
|
152
|
-
this.
|
|
153
|
-
const tw = Tween.get(this.
|
|
164
|
+
this._description.text = texts[count];
|
|
165
|
+
const tw = Tween.get(this._description);
|
|
154
166
|
tw.to({ alpha: 1 }, 200);
|
|
155
167
|
tw.wait(2000);
|
|
156
168
|
tw.to({ alpha: 0 }, 200);
|
|
@@ -161,12 +173,24 @@ class Main extends UILayer {
|
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
// ── Bootstrap ─────────────────────────────────────────────────────────────
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
176
|
+
async function start(): Promise<void> {
|
|
177
|
+
// 包括 Preloader 在内的所有 Label 首次测量都使用已就绪的项目字体。
|
|
178
|
+
await StyleManager.init();
|
|
179
|
+
TextField.default_fontFamily = StyleManager.fontFamily;
|
|
180
|
+
const canvas = document.getElementById('gameCanvas');
|
|
181
|
+
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
182
|
+
throw new Error('Missing gameCanvas.');
|
|
183
|
+
}
|
|
184
|
+
const app = createPlayer({
|
|
185
|
+
canvas,
|
|
186
|
+
contentWidth: 640,
|
|
187
|
+
contentHeight: 1136,
|
|
188
|
+
scaleMode: 'showAll',
|
|
189
|
+
frameRate: 60,
|
|
190
|
+
});
|
|
191
|
+
app.start(new Main());
|
|
192
|
+
}
|
|
171
193
|
|
|
172
|
-
|
|
194
|
+
void start().catch(error => {
|
|
195
|
+
console.error('[Main] Unable to start project:', error);
|
|
196
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getUIStyleColor, getUIStyleFontAlias, getUIStyleFontFamily, parseUIStyleSheet } from '@kurot/ui-document';
|
|
2
|
+
import type { UIStyleFontFace } from '@kurot/ui-document';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 项目启动时加载固定样式表,字体全部就绪后再创建 Player 和 UI。
|
|
6
|
+
* 字体别名保持稳定,换字体文件不需要逐个修改皮肤。
|
|
7
|
+
*/
|
|
8
|
+
export class StyleManager {
|
|
9
|
+
private static _colors: Readonly<Record<string, number>> = Object.freeze({});
|
|
10
|
+
private static _fontFamily?: string;
|
|
11
|
+
|
|
12
|
+
public static get fontFamily(): string {
|
|
13
|
+
if (this._fontFamily === undefined) {
|
|
14
|
+
throw new Error('Project styles are not initialized.');
|
|
15
|
+
}
|
|
16
|
+
return this._fontFamily;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static async init(): Promise<void> {
|
|
20
|
+
const resourceRoot = new URL('resource/', document.baseURI);
|
|
21
|
+
const response = await fetch(new URL('config/style.json', resourceRoot));
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
throw new Error(`Unable to load resource/config/style.json: HTTP ${response.status}.`);
|
|
24
|
+
}
|
|
25
|
+
const stylesheet = parseUIStyleSheet(await response.json());
|
|
26
|
+
const loading = Object.entries(stylesheet.fonts.families).flatMap(([key, family]) =>
|
|
27
|
+
family.faces.map(face => this._loadFace(key, face, resourceRoot)),
|
|
28
|
+
);
|
|
29
|
+
const faces = await Promise.all(loading);
|
|
30
|
+
|
|
31
|
+
// 全部成功后一次性发布,失败时不留下半套字体或新的默认值。
|
|
32
|
+
for (const face of faces) {
|
|
33
|
+
document.fonts.add(face);
|
|
34
|
+
}
|
|
35
|
+
this._fontFamily = getUIStyleFontFamily(stylesheet);
|
|
36
|
+
this._colors = stylesheet.colors;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 业务代码需要动态设置文字颜色时,读取与皮肤编译相同的颜色表。
|
|
41
|
+
*/
|
|
42
|
+
public static getColor(key: string): number {
|
|
43
|
+
return getUIStyleColor(this._colors, key);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private static async _loadFace(key: string, definition: UIStyleFontFace, resourceRoot: URL): Promise<FontFace> {
|
|
47
|
+
const url = new URL(definition.url.split('/').map(encodeURIComponent).join('/'), resourceRoot);
|
|
48
|
+
const face = new FontFace(getUIStyleFontAlias(key), `url("${url.href}")`, {
|
|
49
|
+
weight: String(definition.weight),
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
return await face.load();
|
|
53
|
+
} catch (cause) {
|
|
54
|
+
throw new Error(`Unable to load project font ${key} (${definition.weight}): ${definition.url}.`, { cause });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|