webtalekit-alpha 0.2.10

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/README.md ADDED
@@ -0,0 +1,193 @@
1
+ # webTaleKit
2
+
3
+ ![wabTaleKitロゴ](s-plan1-5Light-s-1.jpg)
4
+
5
+ ## 目次
6
+
7
+ - 概要
8
+ - デモ
9
+ - 環境構築手順
10
+ - 動作確認手順
11
+ - Quick Start(デモゲームを弄ってみよう)
12
+ - できること
13
+ - できないこと
14
+ - フィードバックフォームのご案内
15
+
16
+ ## 概要
17
+
18
+ TypeScript(JavaScript) ベースのビジュアルノベルゲームエンジンです。
19
+ UIをHTML・CSS・JavaScriptで柔軟に作成でき、シナリオをマークアップ言語とJavaScriptで制御できます。
20
+ 自動スケーリング機能で、様々なウインドウで遊ぶことができます。
21
+ VS Codeの拡張機能を用いたGUIエディタやREST API呼び出しによる生成AI連携の追加を提供予定です。
22
+
23
+ ## デモ
24
+
25
+ Firefoxでも、Chromeでも、Edgeでも、好きなブラウザを使いたまえ・・・!
26
+ <https://test-game-chi.vercel.app/>
27
+ ![alt text](image.png)
28
+
29
+ ## 環境構築手順
30
+
31
+ 1. Node.js(20以降)が必要です。(nvm等お好みの方法がある場合は、そちらでも構いません)
32
+ - Windowsの場合は、Node.js公式サイト (<https://nodejs.org/>) からインストールしてください。
33
+ - Macの場合は、`brew install node` を実行してインストールしてください。
34
+ - Linuxの場合は、以下のコマンドを実行して、インストールしてください。
35
+
36
+ ```bash
37
+ curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
38
+ sudo apt-get install -y nodejs
39
+ ```
40
+
41
+ 2. 以下のコマンドを実行してください
42
+
43
+ ``` bash
44
+ npm create tale-game your-game-title
45
+ ```
46
+
47
+ プロジェクトに移動して、`npm run play`を実行して、デモゲームが起動すれば、構築は完了です。
48
+
49
+ ## 動作確認手順
50
+
51
+ 以下のコマンドを実行してください。
52
+
53
+ ```bash
54
+ git clone https://github.com/EndoHizumi/testGame.git
55
+ npm install
56
+ npm run play
57
+ ```
58
+
59
+ ## Quick Start(デモゲームを弄ってみよう
60
+
61
+ ### 画像を差し替える
62
+
63
+ - キャラを変える場合
64
+ - src/resource/chara/guide.png に上書きしてください。
65
+ - 背景画像を変える
66
+ - src/resource/background/title_bg.png に上書きしてください。
67
+ - BGMを変える
68
+ - src/resource/bgm/title_theme.mp3 に上書きしてください。
69
+
70
+ - 選択肢の画像を変える
71
+ - src\resource\system\systemPicture\02_button\button.png に上書きしてください。
72
+ - 選択肢(マウスオーバー時)の画像を変える
73
+ - src\resource\system\systemPicture\02_button\button2.png に上書きしてください。
74
+ - 選択肢(クリック時)の画像を変える
75
+ - src\resource\system\systemPicture\02_button\button3.png に上書きしてください。
76
+
77
+ - キャラを増やす
78
+ - src\resource\character 以下に表示したい画像を置きます。
79
+ - 登場させたい行数で、`<show src="表示したい画像のパス"></show>` を記述する
80
+ - セリフを増やす
81
+ - セリフを表示させたい行数で、`<say name="キャラの名前">セリフをここに入れる</say>` を記述する
82
+ - 地の文を増やす
83
+ - 地の文を表示させたい行数で、`<text>セリフをここに入れる</text>` を記述する
84
+
85
+ - 選択肢を増やす
86
+ - 43行目のchoiceタグの中(44行-50行)で、以下のように記述すると、選択されたときに、地の文を表示する
87
+
88
+ ``` html
89
+ <item label='選択肢の文言'>
90
+ <text>セリフをここに入れる</text>
91
+ </item>
92
+ ```
93
+
94
+ 実装例
95
+
96
+ ``` html
97
+ <choice prompt="ゲームを始めますか?">
98
+ <item label="はい">
99
+ <jump index="5" />
100
+ </item>
101
+ <item label="いいえ">
102
+ <jump index="16" />
103
+ </item>
104
+ <item label='ちょっと待ってくれ'>
105
+ <text>承知しました。</text>
106
+ <jump index="1" />
107
+ </item>
108
+ </choice>
109
+ ```
110
+
111
+ ## 現在の状況
112
+
113
+ webTaleKitは、現在アルファ版です。
114
+
115
+ 開発進捗は、[@endo_hizumi](https://x.com/endo_hizumi) で行っております。
116
+ 実装予定の項目については、こちらの[Trello](https://trello.com/b/qYNGh7MY)からも確認できます。
117
+
118
+ デモをプレイした感想・WebTaleKitを使って気になったことなど、意見・感想はこちらで受け付けています!
119
+ [https://forms.gle/uejQwvwAb99wcJht7](https://forms.gle/uejQwvwAb99wcJht7)
120
+
121
+ 検索Hashtag: #webTalekit
122
+
123
+ ## アルファ版で、できること
124
+
125
+ - 地の文の表示
126
+ - キャラクターのセリフの表示・ボイスの再生
127
+ - キャラクターの画像の表示・位置変更・アニメーション
128
+ - その他の画像の画像の表示・位置変更・アニメーション
129
+ - キャラクターの複数表示・位置変更・アニメーション
130
+ - CGの表示・変更
131
+ - 背景画像の表示・変更
132
+ - 画像のフィルター操作
133
+ - モノクロ化
134
+ - セピア化
135
+ - 透明度の変更
136
+ - サイズの変更
137
+ - REST API呼び出し(レスポンスの表示)
138
+ - 定義した変数の表示
139
+ - 表示する文章・画像の条件分岐
140
+ - 選択肢の表示
141
+ - 選択肢の画像の変更
142
+ - 通常時
143
+ - マウスオーバー
144
+ - 選択時
145
+ - セリフのジャンプ
146
+ - Ctrlキーでの強制スキップ
147
+ - Enterキーで全文表示
148
+ - シナリオ(シーン)の切り替え
149
+ - BGMの再生・停止
150
+ - SEの再生・停止
151
+ - HTMLで作った画面の表示
152
+ - 解像度の設定変更
153
+ - JavaScript連携
154
+ - メソッドの呼び出し
155
+ - 式の実行
156
+ - 変数の定義・値の変更
157
+
158
+ ## アルファ版(0.2.x-0.1.x)で出来ないこと
159
+
160
+ - Desktopアプリケーションへのビルド
161
+ - Android(iOS)向けのビルド
162
+ - 画面各種のボタン
163
+ - sayタグの以下の機能
164
+ - キャラが表示されていないときは、表示する
165
+ - セーブ&ロード機能
166
+ - showタグ / hideタグの以下の機能
167
+ - 子要素でフィルター指定
168
+ - 子要素でアニメーション指定
169
+ - スラッシュで区切ってリソース種類を指定
170
+ - JavaScript側での背景画像の変更
171
+ - soundタグの以下の機能
172
+ - pause
173
+ - setVolume
174
+ - getVolume
175
+ - bgmエイリアス
176
+ - voiceエイリアス
177
+ - seエイリアス
178
+ - quakeタグ(画面を揺らす)
179
+ - maskタグ(画面の暗転)
180
+ - JavaScriptでのリソースの動的定義
181
+ - セーブファイルの一覧の取得
182
+ - ゲーム設定ファイルの反映
183
+ - 画面用HTMLのcss・jsのインライン化・minify化
184
+
185
+ ## アイコン素材
186
+
187
+ - <https://www.silhouette-illust.com/>
188
+
189
+ ## カラーコード
190
+
191
+ 青: #3178C6 (TypeScript BLue)
192
+ 緑: #02a889 (WebTaleKit Green)
193
+ 白: #f8f8f8 (White Smoke)
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "NO TITLE",
3
+ "description": "NO DESCRIPTION",
4
+ "resolution": {
5
+ "width": 1280,
6
+ "height": 720
7
+ },
8
+ "fullScreen": "false",
9
+ "url": ""
10
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "webtalekit-alpha",
3
+ "version": "0.2.10",
4
+ "description": "Web知識でノベルゲーを作ることを目指したやつ",
5
+ "main": "./src/index.js",
6
+ "scripts": {
7
+ "lint": "eslint . --ext .ts --ext .js",
8
+ "test": "jest",
9
+ "build": "rimraf ./dist/ && tsc && cp -r package.json README.md engineConfig.json parser/ dist/ && cp src/core/index.js dist/src/core/"
10
+ },
11
+ "bin": {
12
+ "wtc": "parser/cli.js"
13
+ },
14
+ "author": "EndoHizumi",
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "html-minifier": "^4.0.0",
18
+ "html-to-json-parser": "^2.0.1",
19
+ "rimraf": "^6.0.1",
20
+ "stacktrace-js": "^2.0.2",
21
+ "storejs": "^2.1.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/jest": "^29.5.12",
25
+ "@types/node": "^20.11.28",
26
+ "@types/storejs": "^2.0.3",
27
+ "autoprefixer": "^10.4.20",
28
+ "esdoc": "^1.1.0",
29
+ "esdoc-standard-plugin": "^1.0.0",
30
+ "eslint": "^8.57.0",
31
+ "eslint-config-prettier": "^9.1.0",
32
+ "eslint-config-standard": "^17.1.0",
33
+ "eslint-plugin-import": "^2.29.1",
34
+ "eslint-plugin-n": "^16.6.2",
35
+ "eslint-plugin-promise": "^6.1.1",
36
+ "html-webpack-plugin": "^5.6.0",
37
+ "jest": "^29.7.0",
38
+ "postcss": "^8.4.49",
39
+ "prettier": "^3.2.5",
40
+ "tailwindcss": "^3.4.15",
41
+ "ts-jest": "^29.1.2",
42
+ "ts-loader": "^9.5.1",
43
+ "ts-node": "^10.9.2",
44
+ "typescript": "^5.4.2",
45
+ "webpack": "^5.90.3",
46
+ "webpack-cli": "^5.1.4",
47
+ "webpack-dev-server": "^5.0.2"
48
+ }
49
+ }
package/parser/cli.js ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ const parse = require('./parser.js')
3
+ const fs = require('fs')
4
+ const path = require('path')
5
+ /**
6
+ * WebTaleScript Parser CLI
7
+ */
8
+
9
+ const exec = (targetScript) => {
10
+ // ファイル名を取得する。(拡張子を除く)
11
+ const fileName = path.basename(targetScript).split('.')[0]
12
+ let outputPath = process.argv.slice(2)[1] || ''
13
+ // 末尾にスラッシュがない場合、追加する
14
+ if (outputPath.length > 0) {
15
+ if (outputPath.slice(-1) !== '/') {
16
+ outputPath += '/'
17
+ }
18
+ }
19
+
20
+ // sceneファイルを読み込んで、JSファイルに変換する
21
+ fs.readFile(targetScript, 'utf8', async (err, data) => {
22
+ if (err) {
23
+ console.error(err)
24
+ return
25
+ }
26
+ // パーサーを呼び出す。
27
+ const { scenario, script, lang } = await parse(data)
28
+ // jsディレクトリがない場合、作成する
29
+ if (!fs.existsSync(outputPath)) {
30
+ fs.mkdirSync(outputPath)
31
+ }
32
+ // JSファイルを出力する(lang=tsの場合は、tsファイルを出力する)
33
+ fs.writeFile(
34
+ `${outputPath}${fileName}.${lang == 'text/typescript' ? 'ts' : 'js'}`,
35
+ `${script};\nexport const scenario = ${JSON.stringify(scenario)}; `,
36
+ (err) => {
37
+ if (err) {
38
+ console.error(err)
39
+ return
40
+ }
41
+ console.log(`Output: ${outputPath}${fileName}.${lang == 'text/typescript' ? 'ts' : 'js'}`)
42
+ },
43
+ )
44
+ })
45
+ }
46
+
47
+ // コマンドライン引数から、ファイル一覧を取得する
48
+ const targetScripts = process.argv.slice(2)[0]
49
+ if (fs.statSync(targetScripts).isDirectory()) {
50
+ fs.readdir(targetScripts, (err, files) => {
51
+ if (err) {
52
+ console.error(err)
53
+ return
54
+ }
55
+ files.forEach((file) => {
56
+ exec(`${targetScripts}/${file}`)
57
+ })
58
+ })
59
+ } else {
60
+ exec(targetScripts)
61
+ }
@@ -0,0 +1,53 @@
1
+ const { HTMLToJSON } = require('html-to-json-parser')
2
+ const { minify } = require('html-minifier')
3
+
4
+ module.exports = async (data) => {
5
+ let scenario = []
6
+ let script = []
7
+ let lang = 'js'
8
+
9
+ /**
10
+ * 渡されたオブジェクトを展開する
11
+ * @param {Object} jsObject
12
+ */
13
+ const flattenAttributes = (jsObject) => {
14
+ if (Array.isArray(jsObject)) {
15
+ return jsObject.map(flattenAttributes)
16
+ }
17
+ if (typeof jsObject !== 'object' || jsObject === null) {
18
+ return jsObject
19
+ }
20
+ const { attributes, ...rest } = jsObject
21
+ if (attributes) {
22
+ Object.assign(rest, attributes)
23
+ }
24
+ if (rest.content) {
25
+ rest.content = rest.content.map(flattenAttributes)
26
+ }
27
+ return rest
28
+ }
29
+
30
+ /**
31
+ * HTMLとして解析され、変換されたオブジェクトを、WTS仕様に変換する
32
+ * @param {string} html 読み込んだWSTファイル
33
+ */
34
+ /** HTMLを読み込む */
35
+ const html = minify(data, {
36
+ removeTagWhitespace: true,
37
+ collapseWhitespace: true,
38
+ removeComments: true,
39
+ minifyJS: true,
40
+ minifyCSS: true,
41
+ })
42
+ // HTMLをJSONに変換
43
+ const parseJson = await HTMLToJSON(html)
44
+ parseJson.content.forEach((element) => {
45
+ if (element.type === 'scenario') {
46
+ scenario = flattenAttributes(element.content)
47
+ } else {
48
+ script = element.content
49
+ lang = element.attributes?.type
50
+ }
51
+ })
52
+ return { scenario, script, lang }
53
+ }