webtalekit-alpha 0.2.13 → 0.2.14
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 +145 -70
- package/package.json +10 -2
- package/parser/checker.js +184 -0
- package/parser/checker.test.ts +491 -0
- package/parser/cli.js +34 -2
- package/parser/parser.js +25 -18
- package/src/core/defaultUIHandler.js +309 -0
- package/src/core/defaultUIHandler.js.map +1 -0
- package/{dist/src → src}/core/drawer.js +65 -40
- package/src/core/drawer.js.map +1 -0
- package/{dist/src → src}/core/index.js +188 -257
- package/{dist/src → src}/core/scenarioManager.js +29 -7
- package/src/core/scenarioManager.js.map +1 -0
- package/src/utils/eventBus.js +88 -0
- package/src/utils/eventBus.js.map +1 -0
- package/{dist/src → src}/utils/logger.js +45 -1
- package/src/utils/logger.js.map +1 -0
- package/{dist/src → src}/utils/store.js +5 -0
- package/src/utils/store.js.map +1 -0
- package/.claude/settings.local.json +0 -12
- package/.clinerules +0 -65
- package/.history/README_20240812174230.md +0 -193
- package/.history/README_20240812175424.md +0 -185
- package/.history/README_20240812191012.md +0 -185
- package/.history/README_20240812191155.md +0 -185
- package/.history/README_20240812191211.md +0 -185
- package/.history/README_20240812192035.md +0 -185
- package/.history/dist/src/core/index_20240815021552.js +0 -474
- package/.history/dist/src/core/index_20240815022042.js +0 -476
- package/.history/dist/src/core/index_20240815022206.js +0 -476
- package/.history/dist/src/core/index_20240815023104.js +0 -478
- package/.history/dist/src/core/index_20240817022019.js +0 -494
- package/.history/dist/src/core/index_20240818013827.js +0 -493
- package/.history/dist/src/core/index_20240820001418.js +0 -502
- package/.history/package_20240812174230.json +0 -45
- package/.history/package_20240825011731.json +0 -45
- package/.history/package_20240825011739.json +0 -44
- package/.history/parser/parser_20240812174230.js +0 -50
- package/.history/parser/parser_20240825012739.js +0 -47
- package/.history/parser/parser_20240825012835.js +0 -52
- package/.history/src/core/drawer_20240813091343.ts +0 -262
- package/.history/src/core/drawer_20240815232345.ts +0 -262
- package/.history/src/core/drawer_20240815232350.ts +0 -262
- package/.history/src/core/drawer_20240816025257.ts +0 -357
- package/.history/src/core/drawer_20240816025358.ts +0 -357
- package/.history/src/core/drawer_20240816030148.ts +0 -365
- package/.history/src/core/drawer_20240816231033.ts +0 -294
- package/.history/src/core/drawer_20240816231107.ts +0 -262
- package/.history/src/core/drawer_20240816231234.ts +0 -268
- package/.history/src/core/drawer_20240817013836.ts +0 -290
- package/.history/src/core/drawer_20240817015150.ts +0 -289
- package/.history/src/core/drawer_20240817015353.ts +0 -290
- package/.history/src/core/drawer_20240817021254.ts +0 -291
- package/.history/src/core/drawer_20240817023440.ts +0 -295
- package/.history/src/core/drawer_20240817023445.ts +0 -295
- package/.history/src/core/drawer_20240818015327.ts +0 -295
- package/.history/src/core/drawer_20240819231006.ts +0 -318
- package/.history/src/core/drawer_20240820002829.ts +0 -317
- package/.history/src/core/drawer_20240820003141.ts +0 -295
- package/.history/src/core/drawer_20240824010043.ts +0 -295
- package/.history/src/core/drawer_20240825013311.ts +0 -293
- package/.history/src/core/drawer_20240902235257.ts +0 -295
- package/.history/src/core/drawer_20240904002038.ts +0 -262
- package/.history/src/core/drawer_20240904004020.ts +0 -262
- package/.history/src/core/drawer_20240904004238.ts +0 -262
- package/.history/src/core/drawer_20240904005648.ts +0 -262
- package/.history/src/core/drawer_20240904005808.ts +0 -262
- package/.history/src/core/drawer_20240904010523.ts +0 -262
- package/.history/src/core/drawer_20240904011611.ts +0 -262
- package/.history/src/core/drawer_20240904011740.ts +0 -262
- package/.history/src/core/index_20240812190102.js +0 -443
- package/.history/src/core/index_20240812190105.js +0 -443
- package/.history/src/core/index_20240812205421.js +0 -452
- package/.history/src/core/index_20240812213441.js +0 -452
- package/.history/src/core/index_20240812214203.js +0 -453
- package/.history/src/core/index_20240813090823.js +0 -453
- package/.history/src/core/index_20240813230449.js +0 -452
- package/.history/src/core/index_20240813230539.js +0 -452
- package/.history/src/core/index_20240813231447.js +0 -453
- package/.history/src/core/index_20240813231449.js +0 -453
- package/.history/src/core/index_20240813231511.js +0 -453
- package/.history/src/core/index_20240813231531.js +0 -453
- package/.history/src/core/index_20240813231913.js +0 -453
- package/.history/src/core/index_20240813232356.js +0 -453
- package/.history/src/core/index_20240813232640.js +0 -453
- package/.history/src/core/index_20240813232900.js +0 -453
- package/.history/src/core/index_20240814221127.js +0 -454
- package/.history/src/core/index_20240814221322.js +0 -454
- package/.history/src/core/index_20240814221526.js +0 -454
- package/.history/src/core/index_20240814222048.js +0 -454
- package/.history/src/core/index_20240814222918.js +0 -459
- package/.history/src/core/index_20240814223136.js +0 -459
- package/.history/src/core/index_20240814223501.js +0 -464
- package/.history/src/core/index_20240814224347.js +0 -468
- package/.history/src/core/index_20240815013712.js +0 -474
- package/.history/src/core/index_20240815021534.js +0 -474
- package/.history/src/core/index_20240815023143.js +0 -477
- package/.history/src/core/index_20240815023207.js +0 -479
- package/.history/src/core/index_20240815023344.js +0 -481
- package/.history/src/core/index_20240815035600.js +0 -479
- package/.history/src/core/index_20240815041549.js +0 -480
- package/.history/src/core/index_20240815185515.js +0 -481
- package/.history/src/core/index_20240815192158.js +0 -481
- package/.history/src/core/index_20240815222912.js +0 -482
- package/.history/src/core/index_20240815224052.js +0 -483
- package/.history/src/core/index_20240815224843.js +0 -484
- package/.history/src/core/index_20240815224850.js +0 -483
- package/.history/src/core/index_20240815231706.js +0 -479
- package/.history/src/core/index_20240816025748.js +0 -483
- package/.history/src/core/index_20240816030102.js +0 -484
- package/.history/src/core/index_20240817013329.js +0 -485
- package/.history/src/core/index_20240817013526.js +0 -485
- package/.history/src/core/index_20240817013819.js +0 -488
- package/.history/src/core/index_20240817013829.js +0 -488
- package/.history/src/core/index_20240817014921.js +0 -494
- package/.history/src/core/index_20240817022057.js +0 -494
- package/.history/src/core/index_20240817023316.js +0 -493
- package/.history/src/core/index_20240818005637.js +0 -493
- package/.history/src/core/index_20240818005721.js +0 -493
- package/.history/src/core/index_20240818011804.js +0 -493
- package/.history/src/core/index_20240818013835.js +0 -493
- package/.history/src/core/index_20240818014310.js +0 -493
- package/.history/src/core/index_20240818014323.js +0 -493
- package/.history/src/core/index_20240818014333.js +0 -493
- package/.history/src/core/index_20240818020725.js +0 -496
- package/.history/src/core/index_20240819195504.js +0 -497
- package/.history/src/core/index_20240819202012.js +0 -495
- package/.history/src/core/index_20240819231228.js +0 -501
- package/.history/src/core/index_20240819232555.js +0 -502
- package/.history/src/core/index_20240819233404.js +0 -502
- package/.history/src/core/index_20240820003114.js +0 -495
- package/.history/src/core/index_20240820003120.js +0 -495
- package/.history/src/core/index_20240820003331.js +0 -495
- package/.history/src/core/index_20240820004126.js +0 -498
- package/.history/src/core/index_20240820004357.js +0 -497
- package/.history/src/core/index_20240820005103.js +0 -498
- package/.history/src/core/index_20240820005110.js +0 -499
- package/.history/src/core/index_20240820005206.js +0 -497
- package/.history/src/core/index_20240820005352.js +0 -497
- package/.history/src/core/index_20240823224904.ts +0 -505
- package/.history/src/core/index_20240823224905.js +0 -505
- package/.history/src/core/index_20240823231631.ts +0 -530
- package/.history/src/core/index_20240823231735.ts +0 -530
- package/.history/src/core/index_20240823232123.ts +0 -539
- package/.history/src/core/index_20240823232329.ts +0 -539
- package/.history/src/core/index_20240823233058.ts +0 -539
- package/.history/src/core/index_20240823234946.ts +0 -539
- package/.history/src/core/index_20240824005956.ts +0 -534
- package/.history/src/core/index_20240824010113.ts +0 -534
- package/.history/src/core/index_20240824010124.ts +0 -534
- package/.history/src/core/index_20240824010212.ts +0 -534
- package/.history/src/core/index_20240824010218.ts +0 -534
- package/.history/src/core/index_20240824010407.ts +0 -534
- package/.history/src/core/index_20240824010611.ts +0 -534
- package/.history/src/core/index_20240824010623.ts +0 -534
- package/.history/src/core/index_20240824010652.ts +0 -534
- package/.history/src/core/index_20240824011007.ts +0 -534
- package/.history/src/core/index_20240824210450.ts +0 -534
- package/.history/src/core/index_20240824210703.ts +0 -534
- package/.history/src/core/index_20240824210708.ts +0 -534
- package/.history/src/core/index_20240824211001.ts +0 -537
- package/.history/src/core/index_20240824211258.ts +0 -537
- package/.history/src/core/index_20240824211654.ts +0 -537
- package/.history/src/core/index_20240824211723.ts +0 -537
- package/.history/src/core/index_20240824211808.ts +0 -538
- package/.history/src/core/index_20240824214041.js +0 -538
- package/.history/src/core/index_20240824215312.ts +0 -538
- package/.history/src/core/index_20240824215341.ts +0 -538
- package/.history/src/core/index_20240824220703.ts +0 -538
- package/.history/src/core/index_20240824220709.ts +0 -538
- package/.history/src/core/index_20240825012244.ts +0 -536
- package/.history/src/core/index_20240825012435.ts +0 -539
- package/.history/src/core/index_20240825012440.ts +0 -539
- package/.history/src/core/index_20240826005054.ts +0 -539
- package/.history/src/core/index_20240826005321.ts +0 -540
- package/.history/src/core/index_20240826005410.ts +0 -539
- package/.history/src/core/index_20240826005418.ts +0 -539
- package/.history/src/core/index_20240830231825.ts +0 -539
- package/.history/src/core/index_20240831022416.ts +0 -539
- package/.history/src/core/index_20240901222314.js +0 -459
- package/.history/src/core/index_20240901222951.js +0 -459
- package/.history/src/core/index_20240901223824.js +0 -471
- package/.history/src/core/index_20240901223833.js +0 -468
- package/.history/src/core/index_20240902223954.js +0 -447
- package/.history/src/core/index_20240902224000.js +0 -446
- package/.history/src/core/index_20240902230345.js +0 -448
- package/.history/src/core/index_20240902231130.js +0 -449
- package/.history/src/core/index_20240902231559.js +0 -449
- package/.history/src/core/index_20240902232135.js +0 -449
- package/.history/src/core/index_20240902232809.js +0 -452
- package/.history/src/core/index_20240902232815.js +0 -452
- package/.history/src/core/index_20240903000104.js +0 -467
- package/.history/src/core/index_20240904001731.js +0 -444
- package/.history/src/core/index_20240904002038.ts +0 -539
- package/.history/src/core/index_20240904011848.js +0 -444
- package/.history/src/core/index_20240904012138.js +0 -444
- package/.history/src/core/index_20240904012743.js +0 -444
- package/.history/src/core/index_20240904013051.js +0 -444
- package/.history/src/core/resourceManager_20240403231531.ts +0 -16
- package/.history/src/core/resourceManager_20240823232627.ts +0 -17
- package/.history/src/core/resourceManager_20240824214014.js +0 -16
- package/.history/src/core/resourceManager_20240824214620.js +0 -17
- package/.history/src/core/scenarioManager_20240812203410.ts +0 -86
- package/.history/src/core/scenarioManager_20240812203839.ts +0 -94
- package/.history/src/core/scenarioManager_20240812213437.ts +0 -85
- package/.history/src/core/scenarioManager_20240813225852.ts +0 -85
- package/.history/src/core/scenarioManager_20240823235010.ts +0 -85
- package/.history/src/core/scenarioManager_20240904002038.ts +0 -94
- package/.history/src/core/scenarioManager_20240904012411.ts +0 -94
- package/.history/src/core/scenarioManager_20240904012519.ts +0 -94
- package/.history/src/index_20240403231531.js +0 -6
- package/.history/src/index_20240429233436.js +0 -8
- package/.history/src/index_20240429233926.js +0 -8
- package/.history/src/index_20240429234401.js +0 -7
- package/.history/src/index_20240429234404.js +0 -6
- package/.history/src/resource/soundObject_20240419004314.ts +0 -71
- package/.history/src/resource/soundObject_20240815034420.ts +0 -66
- package/.history/src/resource/soundObject_20240815034836.ts +0 -79
- package/.history/src/resource/soundObject_20240815034919.ts +0 -87
- package/.history/src/resource/soundObject_20240815040724.ts +0 -81
- package/.history/src/resource/soundObject_20240815041022.ts +0 -87
- package/.history/src/resource/soundObject_20240815042103.ts +0 -87
- package/.history/src/resource/soundObject_20240823235929.ts +0 -91
- package/.history/src/resource/soundObject_20240824213129.ts +0 -99
- package/.history/src/resource/soundObject_20240824213611.ts +0 -101
- package/.history/src/resource/soundObject_20240824215734.ts +0 -101
- package/.history/src/resource/soundObject_20240825004926.ts +0 -101
- package/.history/src/resource/soundObject_20240825004947.ts +0 -101
- package/.history/src/utils/logger_20240812174230.ts +0 -13
- package/.history/src/utils/logger_20240823232736.ts +0 -14
- package/.history/src/utils/logger_20240824214930.js +0 -14
- package/.history/src/utils/store_20240812174230.ts +0 -17
- package/.history/src/utils/store_20240823232948.ts +0 -29
- package/.history/src/utils/store_20240824214020.js +0 -17
- package/.history/src/utils/store_20240824214955.js +0 -29
- package/.history/src/utils/waitUtil_20240812174230.ts +0 -4
- package/.history/src/utils/waitUtil_20240823232739.ts +0 -4
- package/.history/src/utils/waitUtil_20240824214024.js +0 -4
- package/.history/src/utils/waitUtil_20240824215009.js +0 -4
- package/.history/test/js/title_20240428215305.js +0 -254
- package/.history/test/js/title_20240429221911.js +0 -227
- package/.history/test/js/title_20240429222806.js +0 -243
- package/.history/test/js/title_20240429222854.js +0 -263
- package/.history/test/js/title_20240429222906.js +0 -263
- package/.history/test/js/title_20240429235639.js +0 -263
- package/.history/test/js/title_20240429235840.js +0 -263
- package/.history/test/js/title_20240430014721.js +0 -262
- package/.history/test/js/title_20240430014759.js +0 -254
- package/.history/test/js/title_20240430134612.js +0 -285
- package/.history/test/js/title_20240430141051.js +0 -285
- package/.history/test/js/title_20240430173745.js +0 -245
- package/.history/tsconfig_20240812174230.json +0 -22
- package/.history/tsconfig_20240824010157.json +0 -19
- package/.history/tsconfig_20240824220700.json +0 -20
- package/.history/tsconfig_20240825011301.json +0 -20
- package/.history/webpack.config_20240423002825.js +0 -37
- package/.history/webpack.config_20240430001157.js +0 -38
- package/.history/webpack.config_20240430001309.js +0 -37
- package/.history/webpack.config_20240430002112.js +0 -37
- package/CLAUDE.md +0 -96
- package/LICENSE +0 -21
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/core/drawer.ts.html +0 -1264
- package/coverage/lcov-report/core/index.html +0 -146
- package/coverage/lcov-report/core/resourceManager.ts.html +0 -136
- package/coverage/lcov-report/core/scenarioManager.ts.html +0 -373
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/resource/ImageObject.ts.html +0 -433
- package/coverage/lcov-report/resource/index.html +0 -131
- package/coverage/lcov-report/resource/soundObject.ts.html +0 -346
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/utils/TextMeasurer.ts.html +0 -520
- package/coverage/lcov-report/utils/index.html +0 -161
- package/coverage/lcov-report/utils/logger.ts.html +0 -142
- package/coverage/lcov-report/utils/store.ts.html +0 -151
- package/coverage/lcov-report/utils/waitUtil.ts.html +0 -97
- package/coverage/lcov.info +0 -882
- package/dist/README.md +0 -294
- package/dist/engineConfig.json +0 -10
- package/dist/package.json +0 -51
- package/dist/parser/cli.js +0 -61
- package/dist/parser/parser.js +0 -53
- package/dist/src/core/drawer.js.map +0 -1
- package/dist/src/core/scenarioManager.js.map +0 -1
- package/dist/src/utils/logger.js.map +0 -1
- package/dist/src/utils/store.js.map +0 -1
- package/dist/webtalekit-alpha-0.2.13.tgz +0 -0
- package/docs/event-system-specification.md +0 -493
- package/docs/glossary.html +0 -833
- package/docs/index.html +0 -296
- package/docs/tag-reference.html +0 -1317
- package/docs/ui-template-guide.html +0 -1068
- package/example/README.md +0 -29
- package/example/engineConfig.json +0 -10
- package/example/package-lock.json +0 -5145
- package/example/package.json +0 -26
- package/example/src/index.js +0 -13
- package/example/src/resource/background/beach.jpg +0 -0
- package/example/src/resource/background/city.jpg +0 -0
- package/example/src/resource/background/crossroad.jpg +0 -0
- package/example/src/resource/background/forest.jpg +0 -0
- package/example/src/resource/background/laboratory.jpg +0 -0
- package/example/src/resource/background/library.jpg +0 -0
- package/example/src/resource/background/living_room.jpg +0 -0
- package/example/src/resource/background/music_room.jpg +0 -0
- package/example/src/resource/background/stage.jpg +0 -0
- package/example/src/resource/background/sunset.jpg +0 -0
- package/example/src/resource/background/title_bg.png +0 -0
- package/example/src/resource/bgm/calm_music.wav +0 -0
- package/example/src/resource/bgm/doorbell.mp3 +0 -0
- package/example/src/resource/bgm/nc366476_Virtual_Voyage.mp3 +0 -0
- package/example/src/resource/bgm/title_theme.mp3 +0 -0
- package/example/src/resource/chara/dancer.png +0 -0
- package/example/src/resource/chara/guest.png +0 -0
- package/example/src/resource/chara/guide.png +0 -0
- package/example/src/resource/chara/scientist.png +0 -0
- package/example/src/resource/config.js +0 -0
- package/example/src/resource/se/doorbell.mp3 +0 -0
- package/example/src/resource/system/systemPicture/01_message/message.png +0 -0
- package/example/src/resource/system/systemPicture/02_button/button.png +0 -0
- package/example/src/resource/system/systemPicture/02_button/button2.png +0 -0
- package/example/src/resource/system/systemPicture/02_button/button3.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/auto.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/auto2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/close.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/close2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/config.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/config2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/load.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/load2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/log.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/log2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/menu.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/menu2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/qload.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/qload2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/qsave.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/qsave2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/save.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/save2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/screen.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/screen2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/skip.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/skip2.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/title.png +0 -0
- package/example/src/resource/system/systemPicture/03_system_button/title2.png +0 -0
- package/example/src/resource/system/systemPicture//345/210/251/347/224/250/350/246/217/347/264/204.txt +0 -0
- package/example/src/resource/system/wait.gif +0 -0
- package/example/src/scene/animation.scene +0 -28
- package/example/src/scene/background.scene +0 -29
- package/example/src/scene/character.scene +0 -26
- package/example/src/scene/choice.scene +0 -97
- package/example/src/scene/dialog.scene +0 -105
- package/example/src/scene/effects.scene +0 -38
- package/example/src/scene/en/animation.scene +0 -28
- package/example/src/scene/en/background.scene +0 -26
- package/example/src/scene/en/character.scene +0 -26
- package/example/src/scene/en/choice.scene +0 -32
- package/example/src/scene/en/effects.scene +0 -37
- package/example/src/scene/en/sound.scene +0 -26
- package/example/src/scene/en/text.scene +0 -26
- package/example/src/scene/en/title.scene +0 -39
- package/example/src/scene/if_test.scene +0 -37
- package/example/src/scene/resource-error-test.scene +0 -15
- package/example/src/scene/save-load-test.scene +0 -48
- package/example/src/scene/sound.scene +0 -26
- package/example/src/scene/test_error.scene +0 -21
- package/example/src/scene/text.scene +0 -34
- package/example/src/scene/title.scene +0 -51
- package/example/src/screen/incoming.html +0 -474
- package/example/src/screen/title.html +0 -135
- package/example/src/template.html +0 -16
- package/example/test-results/.last-run.json +0 -4
- package/example/webpack.config.js +0 -69
- package/image.png +0 -0
- package/playwright-report/index.html +0 -71
- package/s-plan1-5Light-s-1.jpg +0 -0
- package/test-results/.last-run.json +0 -6
- package/tests/e2e/if-global-attribute.spec.js +0 -90
- package/tests/e2e/resource-error-handling.spec.js +0 -58
- package/tests/e2e/screenshots/before-error-check.png +0 -0
- package/tests/e2e/screenshots/choices.png +0 -0
- package/tests/e2e/screenshots/message-window-click-wait.png +0 -0
- /package/{dist/src → src}/core/resourceManager.js +0 -0
- /package/{dist/src → src}/core/resourceManager.js.map +0 -0
- /package/{dist/src → src}/resource/ImageObject.js +0 -0
- /package/{dist/src → src}/resource/ImageObject.js.map +0 -0
- /package/{dist/src → src}/resource/soundObject.js +0 -0
- /package/{dist/src → src}/resource/soundObject.js.map +0 -0
- /package/{dist/src → src}/utils/fallbackTemplate.js +0 -0
- /package/{dist/src → src}/utils/fallbackTemplate.js.map +0 -0
- /package/{dist/src → src}/utils/waitUtil.js +0 -0
- /package/{dist/src → src}/utils/waitUtil.js.map +0 -0
|
@@ -7,9 +7,12 @@ import engineConfig from '../../engineConfig.json'
|
|
|
7
7
|
import { sleep } from '../utils/waitUtil'
|
|
8
8
|
import { getDefaultDialogTemplate } from '../utils/fallbackTemplate'
|
|
9
9
|
import { generateStore } from '../utils/store'
|
|
10
|
+
import { EventBus } from '../utils/eventBus'
|
|
11
|
+
import { DefaultUIHandler } from './defaultUIHandler'
|
|
12
|
+
import { logError } from '../utils/logger'
|
|
10
13
|
|
|
11
14
|
export class Core {
|
|
12
|
-
constructor() {
|
|
15
|
+
constructor(options = {}) {
|
|
13
16
|
// プロパティの初期化
|
|
14
17
|
this.bgm = null
|
|
15
18
|
this.isAuto = false
|
|
@@ -48,6 +51,12 @@ export class Core {
|
|
|
48
51
|
this.usedSounds = {}
|
|
49
52
|
// ストレージの初期化
|
|
50
53
|
this.store = generateStore()
|
|
54
|
+
// EventBusの初期化
|
|
55
|
+
this.eventBus = new EventBus()
|
|
56
|
+
// DefaultUIHandlerの登録(customUI: trueの場合はスキップ)
|
|
57
|
+
if (!options.customUI) {
|
|
58
|
+
DefaultUIHandler.register(this.eventBus, this.drawer, this.gameContainer, engineConfig.resolution)
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
setConfig(config) {
|
|
@@ -56,6 +65,7 @@ export class Core {
|
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
async start(initScene) {
|
|
68
|
+
try {
|
|
59
69
|
// TODO: ブラウザ用のビルドの場合は、最初にクリックしてもらう
|
|
60
70
|
// titleタグの内容を書き換える
|
|
61
71
|
document.title = engineConfig.title
|
|
@@ -63,42 +73,43 @@ export class Core {
|
|
|
63
73
|
await this.loadScene(initScene || 'title')
|
|
64
74
|
// 画面を表示する
|
|
65
75
|
await this.loadScreen(this.sceneConfig)
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
document.querySelector('#gameContainer').addEventListener('keyup', (e) => {
|
|
76
|
-
if (e.key === 'Control') {
|
|
77
|
-
this.drawer.isSkip = true
|
|
78
|
-
this.isNext = false
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
document.querySelector('#gameContainer').addEventListener('click', (e) => {
|
|
82
|
-
this.onNextHandler()
|
|
76
|
+
// 入力イベントを設定する(DefaultUIHandlerに委譲)
|
|
77
|
+
await this.eventBus.emit('input:bind', {
|
|
78
|
+
onNext: () => { if (this.onNextHandler) this.onNextHandler() },
|
|
79
|
+
setSkip: (drawerSkip, coreNext) => {
|
|
80
|
+
this.drawer.isSkip = drawerSkip
|
|
81
|
+
this.isNext = coreNext
|
|
82
|
+
},
|
|
83
|
+
toggleAuto: () => { this.isAuto = !this.isAuto },
|
|
84
|
+
toggleSkip: () => { this.isSkip = !this.isSkip },
|
|
83
85
|
})
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
await this.textHandler('タップでスタート')
|
|
88
|
+
// BGMを再生する
|
|
89
|
+
await this.soundHandler({
|
|
90
|
+
mode: 'bgm',
|
|
91
|
+
src: this.sceneConfig.bgm,
|
|
92
|
+
loop: true,
|
|
93
|
+
play: true,
|
|
94
|
+
})
|
|
95
|
+
// シナリオを実行する
|
|
96
|
+
while (this.scenarioManager.hasNext()) {
|
|
97
|
+
await this.runScenario()
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
// エラーをログに記録(スタックトレース付き)
|
|
101
|
+
await logError(error, 'Error in runScenario')
|
|
102
|
+
// エラーをアラートで表示
|
|
103
|
+
alert(`システムエラーが発生しました。\n詳細はコンソールで確認してください。:\n${error.message}`)
|
|
104
|
+
throw error
|
|
96
105
|
}
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
async loadScene(sceneFileName) {
|
|
100
109
|
// sceneファイルを読み込む
|
|
101
|
-
|
|
110
|
+
// ESモジュールの名前空間オブジェクトは外部から書き込み不可なため、プレーンオブジェクトにコピーする
|
|
111
|
+
const moduleNamespace = await import(/* webpackChunkName: "[request]" */ `/src/js/${sceneFileName}.js`)
|
|
112
|
+
this.sceneFile = { ...moduleNamespace }
|
|
102
113
|
// sceneファイルの初期化処理を実行
|
|
103
114
|
if (this.sceneFile.init) {
|
|
104
115
|
this.sceneFile.init(this.getAPIForScript())
|
|
@@ -118,16 +129,6 @@ export class Core {
|
|
|
118
129
|
}
|
|
119
130
|
}
|
|
120
131
|
|
|
121
|
-
// ファイルの存在確認を行う関数
|
|
122
|
-
async checkResourceExists(url) {
|
|
123
|
-
try {
|
|
124
|
-
const response = await fetch(url, { method: 'HEAD' })
|
|
125
|
-
return response.ok
|
|
126
|
-
} catch (error) {
|
|
127
|
-
return false
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
132
|
async loadScreen(sceneConfig, options = {}) {
|
|
132
133
|
const {
|
|
133
134
|
isDialog = false, // ダイアログモードかどうか
|
|
@@ -138,53 +139,23 @@ export class Core {
|
|
|
138
139
|
// 画面名を設定する。
|
|
139
140
|
this.scenarioManager.progress.currentScene = sceneConfig.name
|
|
140
141
|
this.scenarioManager.setSceneName(sceneConfig.name)
|
|
141
|
-
//
|
|
142
|
-
// テンプレートの存在確認
|
|
142
|
+
// テンプレートの存在確認(ダイアログ以外のみ)
|
|
143
143
|
if (!isDialog && !(await this.checkResourceExists(sceneConfig.template))) {
|
|
144
144
|
console.error(`Template file not found: ${sceneConfig.template}`)
|
|
145
145
|
throw new Error(`Template file not found: ${sceneConfig.template}`)
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const htmlString = await (await fetch(sceneConfig.template)).text()
|
|
149
|
-
// 読み込んだhtmlからIDにmainを持つdivタグとStyleタグ以下を取り出して、gameContainerに表示する
|
|
150
|
-
let parser = new DOMParser()
|
|
151
|
-
let doc = parser.parseFromString(htmlString, 'text/html')
|
|
152
|
-
|
|
153
|
-
let mainDiv = isDialog ? doc.getElementById('dialogContainer') : doc.getElementById('main')
|
|
154
|
-
|
|
155
|
-
if (!mainDiv) {
|
|
156
|
-
// mainが見つからない場合は、フォールバックテンプレートを使用
|
|
157
|
-
if (fallbackTemplate) {
|
|
158
|
-
console.warn(`Main div not found in template, using fallback: ${fallbackTemplate}`)
|
|
159
|
-
mainDiv = doc.createElement('div')
|
|
160
|
-
const fallbackTemplateText = fallbackTemplate()
|
|
161
|
-
mainDiv.innerHTML = fallbackTemplateText.htmlString
|
|
162
|
-
// フォールバックテンプレートのスタイルを適用
|
|
163
|
-
const styleElement = doc.head.getElementsByTagName('style')[0] || doc.createElement('style')
|
|
164
|
-
styleElement.textContent = fallbackTemplateText.styleString || ''
|
|
165
|
-
doc.head.appendChild(styleElement)
|
|
166
|
-
} else {
|
|
167
|
-
throw new Error('Main div not found in template and no fallback provided.')
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
148
|
if (!this.gameContainer) {
|
|
171
149
|
throw new Error('Game container not found.')
|
|
172
150
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this.drawer.setScreen(this.gameContainer, engineConfig.resolution)
|
|
182
|
-
} else {
|
|
183
|
-
this.gameContainer.appendChild(mainDiv)
|
|
184
|
-
}
|
|
185
|
-
// Styleタグを取り出して、headタグに追加する
|
|
186
|
-
const styleElement = doc.head.getElementsByTagName('style')[0]
|
|
187
|
-
document.head.appendChild(styleElement)
|
|
151
|
+
|
|
152
|
+
// screen:loadイベントを発行してHTMLの読み込み・パース・DOM注入をDefaultUIHandlerに委譲する
|
|
153
|
+
// テンプレートURLとフォールバック関数を渡すことで、UIフレームワークが独自のfetch/描画処理を実装できる
|
|
154
|
+
await this.eventBus.emit('screen:load', {
|
|
155
|
+
template: sceneConfig.template,
|
|
156
|
+
isDialog,
|
|
157
|
+
fallbackTemplate,
|
|
158
|
+
})
|
|
188
159
|
|
|
189
160
|
if (!skipBackground) {
|
|
190
161
|
console.info(`background: ${await this.checkResourceExists(sceneConfig.background)}`)
|
|
@@ -207,6 +178,7 @@ export class Core {
|
|
|
207
178
|
}
|
|
208
179
|
|
|
209
180
|
async runScenario() {
|
|
181
|
+
|
|
210
182
|
let scenarioObject = this.scenarioManager.next()
|
|
211
183
|
if (!scenarioObject) {
|
|
212
184
|
return
|
|
@@ -245,32 +217,21 @@ export class Core {
|
|
|
245
217
|
scenarioObject.content = scenarioObject.content.concat(scenarioObject.then || scenarioObject.error)
|
|
246
218
|
}
|
|
247
219
|
|
|
248
|
-
// 名前が設定されている場合は、名前を表示する
|
|
249
|
-
if (scenarioObject.name) {
|
|
250
|
-
this.drawer.drawName(scenarioObject.name)
|
|
251
|
-
} else {
|
|
252
|
-
this.drawer.drawName('')
|
|
253
|
-
}
|
|
254
|
-
|
|
255
220
|
//prettier-ignore
|
|
256
221
|
this.onNextHandler = () => { this.drawer.isSkip = true }
|
|
257
|
-
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
await this.drawer.drawText(this.expandVariable(text.content[0]), text.speed || 25, container)
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
222
|
+
|
|
223
|
+
// text:clearイベントを発行してテキスト表示領域をクリアする
|
|
224
|
+
await this.eventBus.emit('text:clear')
|
|
225
|
+
|
|
226
|
+
// text:showイベントを発行してテキスト表示をDefaultUIHandlerに委譲する
|
|
227
|
+
await this.eventBus.emit('text:show', {
|
|
228
|
+
name: scenarioObject.name || '',
|
|
229
|
+
content: scenarioObject.content,
|
|
230
|
+
speed: this.isSkip ? 1 : scenarioObject.speed || 25,
|
|
231
|
+
expandVariable: this.expandVariable.bind(this),
|
|
232
|
+
waitFn: this.waitHandler.bind(this),
|
|
233
|
+
})
|
|
234
|
+
|
|
274
235
|
await this.waitHandler({ wait: scenarioObject.time })
|
|
275
236
|
this.drawer.isSkip = false
|
|
276
237
|
this.scenarioManager.setHistory(scenarioObject.content)
|
|
@@ -295,6 +256,12 @@ export class Core {
|
|
|
295
256
|
if (typeof line.wait === 'string' && !isNaN(Number(line.wait))) {
|
|
296
257
|
line.wait = Number(line.wait)
|
|
297
258
|
}
|
|
259
|
+
|
|
260
|
+
// スキップモードが有効な場合は全ての待機をスキップする
|
|
261
|
+
if (this.isSkip) {
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
|
|
298
265
|
if (typeof line.wait === 'number') {
|
|
299
266
|
if (line.wait > 0 || this.isAuto) {
|
|
300
267
|
const waitTime = line.wait || 1500
|
|
@@ -302,8 +269,13 @@ export class Core {
|
|
|
302
269
|
await sleep(waitTime)
|
|
303
270
|
}
|
|
304
271
|
} else {
|
|
305
|
-
|
|
306
|
-
|
|
272
|
+
if (this.isAuto) {
|
|
273
|
+
// オートモードが有効な場合はデフォルト時間後に自動進行する
|
|
274
|
+
await sleep(1500)
|
|
275
|
+
} else {
|
|
276
|
+
// 改行ごとに入力待ち
|
|
277
|
+
await this.clickWait()
|
|
278
|
+
}
|
|
307
279
|
}
|
|
308
280
|
}
|
|
309
281
|
|
|
@@ -312,7 +284,7 @@ export class Core {
|
|
|
312
284
|
this.drawer.setVisibility('#waitCircle', true)
|
|
313
285
|
return new Promise((resolve) => {
|
|
314
286
|
const intervalId = setInterval(() => {
|
|
315
|
-
if (this.isNext) {
|
|
287
|
+
if (this.isNext || this.isAuto || this.isSkip) {
|
|
316
288
|
this.drawer.setVisibility('#waitCircle', false)
|
|
317
289
|
clearInterval(intervalId)
|
|
318
290
|
this.isNext = false
|
|
@@ -330,18 +302,19 @@ export class Core {
|
|
|
330
302
|
}
|
|
331
303
|
|
|
332
304
|
async choiceHandler(line) {
|
|
333
|
-
document.querySelector('#interactiveView').style.visibility = 'visible'
|
|
334
305
|
if (line.prompt) this.textHandler(line.prompt)
|
|
335
306
|
// ムスタッシュ構文があるときは、変数の展開
|
|
336
307
|
line.content.forEach((choice) => {
|
|
337
308
|
choice.label = this.expandVariable(choice.label)
|
|
338
309
|
})
|
|
339
|
-
|
|
310
|
+
// choice:showイベントを発行して選択肢の表示と選択結果の取得をDefaultUIHandlerに委譲する
|
|
311
|
+
const [result] = await this.eventBus.emit('choice:show', line)
|
|
312
|
+
const { selectId, onSelect: selectHandler } = result || {}
|
|
340
313
|
if (selectHandler !== undefined) {
|
|
341
314
|
this.scenarioManager.addScenario(selectHandler)
|
|
342
315
|
}
|
|
343
316
|
this.scenarioManager.setHistory({ line, ...selectId })
|
|
344
|
-
|
|
317
|
+
this.isNext = false
|
|
345
318
|
}
|
|
346
319
|
|
|
347
320
|
jumpHandler(line) {
|
|
@@ -358,10 +331,11 @@ export class Core {
|
|
|
358
331
|
const scenarioList = scenario.slice(line.index, this.scenarioManager.getIndex())
|
|
359
332
|
// sub=falseの行だけを取得
|
|
360
333
|
const subFalseScenario = scenarioList.filter((line) => !line.sub)
|
|
334
|
+
// after に残っている sub=true の要素を除去(前回の選択肢の残骸を除去する)
|
|
335
|
+
const filteredAfter = noEditScenarioList.after.filter((item) => !item.sub)
|
|
361
336
|
// scenarioManagerに追加
|
|
362
|
-
this.scenarioManager.setScenario([...noEditScenarioList.before, ...subFalseScenario, ...
|
|
337
|
+
this.scenarioManager.setScenario([...noEditScenarioList.before, ...subFalseScenario, ...filteredAfter])
|
|
363
338
|
}
|
|
364
|
-
this.newpageHandler()
|
|
365
339
|
this.scenarioManager.setIndex(Number(line.index))
|
|
366
340
|
}
|
|
367
341
|
|
|
@@ -473,12 +447,7 @@ export class Core {
|
|
|
473
447
|
|
|
474
448
|
// ファイルの存在確認
|
|
475
449
|
if (!(await this.checkResourceExists(line.src))) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
// エラーメッセージを表示
|
|
479
|
-
await this.textHandler(`エラー: 画像ファイルが見つかりません: ${line.src}`)
|
|
480
|
-
// 空の画像オブジェクトを返す
|
|
481
|
-
return new ImageObject()
|
|
450
|
+
throw new Error(`Image file not found: ${line.src}`)
|
|
482
451
|
}
|
|
483
452
|
|
|
484
453
|
// 既にインスタンスがある場合は、それを使う
|
|
@@ -505,13 +474,15 @@ export class Core {
|
|
|
505
474
|
} else {
|
|
506
475
|
if ('play' in line) {
|
|
507
476
|
'loop' in line ? soundObject.play(true) : soundObject.play()
|
|
508
|
-
} else if ('stop' in line) {
|
|
509
|
-
soundObject.stop()
|
|
510
|
-
} else if ('pause' in line) {
|
|
511
|
-
soundObject.pause()
|
|
512
477
|
}
|
|
513
478
|
}
|
|
514
479
|
|
|
480
|
+
if ('stop' in line) {
|
|
481
|
+
soundObject.stop()
|
|
482
|
+
} else if ('pause' in line) {
|
|
483
|
+
soundObject.pause()
|
|
484
|
+
}
|
|
485
|
+
|
|
515
486
|
// soundObjectを管理オブジェクトに追加
|
|
516
487
|
const key = line.name || line.src.split('/').pop()
|
|
517
488
|
this.usedSounds[key] = {
|
|
@@ -524,13 +495,10 @@ export class Core {
|
|
|
524
495
|
let resource
|
|
525
496
|
|
|
526
497
|
// ファイルの存在確認
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
await this.textHandler(`エラー: 音声ファイルが見つかりません: ${line.src}`)
|
|
532
|
-
// 空のサウンドオブジェクトを返す
|
|
533
|
-
return new SoundObject()
|
|
498
|
+
if (line.src) {
|
|
499
|
+
if (!(await this.checkResourceExists(line.src))) {
|
|
500
|
+
throw new Error(`Sound file not found: ${line.src}`)
|
|
501
|
+
}
|
|
534
502
|
}
|
|
535
503
|
|
|
536
504
|
// 既にインスタンスがある場合は、それを使う
|
|
@@ -565,14 +533,6 @@ export class Core {
|
|
|
565
533
|
}
|
|
566
534
|
|
|
567
535
|
async routeHandler(line) {
|
|
568
|
-
if (this.bgm.isPlaying) {
|
|
569
|
-
// BGMを停止する
|
|
570
|
-
this.soundHandler({
|
|
571
|
-
mode: 'bgm',
|
|
572
|
-
src: this.sceneConfig.bgm,
|
|
573
|
-
stop: true,
|
|
574
|
-
})
|
|
575
|
-
}
|
|
576
536
|
this.newpageHandler()
|
|
577
537
|
if (this.sceneFile.cleanUp) {
|
|
578
538
|
// 終了処理を実行する
|
|
@@ -592,8 +552,11 @@ export class Core {
|
|
|
592
552
|
}
|
|
593
553
|
|
|
594
554
|
// Sceneファイルに、ビルド時に実行処理を追加して、そこに処理をお願いしたほうがいいかも?
|
|
595
|
-
callHandler(line) {
|
|
596
|
-
this.executeCode(line.method)
|
|
555
|
+
async callHandler(line) {
|
|
556
|
+
const result = this.executeCode(line.method)
|
|
557
|
+
if (result && typeof result.then === 'function') {
|
|
558
|
+
await result
|
|
559
|
+
}
|
|
597
560
|
}
|
|
598
561
|
|
|
599
562
|
async httpHandler(line) {
|
|
@@ -655,76 +618,24 @@ export class Core {
|
|
|
655
618
|
}
|
|
656
619
|
|
|
657
620
|
async dialogHandler(scenarioObject) {
|
|
658
|
-
let result = null
|
|
659
621
|
if (!scenarioObject || !scenarioObject.content) {
|
|
660
622
|
throw new Error('Invalid scenario object for dialog handler.')
|
|
661
623
|
}
|
|
662
|
-
// 既にあるダイアログがある場合は、閉じる
|
|
663
|
-
const existingDialog = document.querySelector('#dialogContainer')
|
|
664
|
-
if (existingDialog) {
|
|
665
|
-
existingDialog.close()
|
|
666
|
-
existingDialog.remove()
|
|
667
|
-
}
|
|
668
624
|
// ダイアログのテンプレートを読み込む
|
|
625
|
+
// screen:loadイベント(isDialog:true)ハンドラ内で既存ダイアログの閉鎖も行われる
|
|
669
626
|
await this.loadScreen(scenarioObject, {
|
|
670
627
|
isDialog: true,
|
|
671
628
|
skipBackground: true,
|
|
672
629
|
skipBgm: true,
|
|
673
630
|
fallbackTemplate: getDefaultDialogTemplate,
|
|
674
631
|
})
|
|
675
|
-
//
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
scenarioObject.content.forEach((content) => {
|
|
681
|
-
if (content.type === 'prompt') {
|
|
682
|
-
let prompt = content
|
|
683
|
-
// プロンプトの内容を設定
|
|
684
|
-
|
|
685
|
-
// ムスタッシュ構文があるときは、変数の展開
|
|
686
|
-
const promptElement = dialogContainer.querySelector('.dialog-prompt')
|
|
687
|
-
if (promptElement) {
|
|
688
|
-
promptElement.innerHTML = prompt.content.map((text) => this.expandVariable(text)).join('\n')
|
|
689
|
-
}
|
|
690
|
-
} else if (content.type === 'actions') {
|
|
691
|
-
// ボタンの追加
|
|
692
|
-
let actions = content.content
|
|
693
|
-
|
|
694
|
-
const buttonContainer = dialogContainer.querySelector('.dialog-buttons')
|
|
695
|
-
actions.forEach((action) => {
|
|
696
|
-
// ムスタッシュ構文があるときは、変数の展開
|
|
697
|
-
action.label = this.expandVariable(action.label)
|
|
698
|
-
// テンプレートのボタン取得
|
|
699
|
-
let button = buttonContainer.querySelector(`#dialog-button-${action.id}`)
|
|
700
|
-
|
|
701
|
-
if (!button) {
|
|
702
|
-
// 無い場合は、新しいボタンを作成
|
|
703
|
-
button = document.createElement('button')
|
|
704
|
-
button.id = `dialog-button-${action.id}`
|
|
705
|
-
button.classList.add('dialog-button')
|
|
706
|
-
button.innerText = action.label
|
|
707
|
-
buttonContainer.appendChild(button)
|
|
708
|
-
}
|
|
709
|
-
button.innerText = action.label
|
|
710
|
-
button.addEventListener('click', () => {
|
|
711
|
-
// 選択されたアクションを処理
|
|
712
|
-
this.scenarioManager.addScenario(action.content)
|
|
713
|
-
result = action.id // 選択されたアクションのIDを保存
|
|
714
|
-
|
|
715
|
-
// ダイアログを閉じる
|
|
716
|
-
dialogContainer.close()
|
|
717
|
-
})
|
|
718
|
-
})
|
|
719
|
-
}
|
|
720
|
-
})
|
|
721
|
-
|
|
722
|
-
dialogContainer.showModal() // ダイアログを表示
|
|
723
|
-
return new Promise((resolve) => {
|
|
724
|
-
dialogContainer.addEventListener('close', () => {
|
|
725
|
-
resolve(result)
|
|
726
|
-
})
|
|
632
|
+
// dialog:showイベントを発行してダイアログのDOM操作をDefaultUIHandlerに委譲する
|
|
633
|
+
const [result] = await this.eventBus.emit('dialog:show', {
|
|
634
|
+
content: scenarioObject.content,
|
|
635
|
+
expandVariable: this.expandVariable.bind(this),
|
|
636
|
+
addScenario: this.scenarioManager.addScenario.bind(this.scenarioManager),
|
|
727
637
|
})
|
|
638
|
+
return result
|
|
728
639
|
}
|
|
729
640
|
|
|
730
641
|
setBackground(image) {
|
|
@@ -737,17 +648,38 @@ export class Core {
|
|
|
737
648
|
|
|
738
649
|
executeCode(code) {
|
|
739
650
|
try {
|
|
740
|
-
const
|
|
741
|
-
const
|
|
742
|
-
|
|
651
|
+
const keys = Object.keys(this.sceneFile).filter((key) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key))
|
|
652
|
+
const declarations = keys.map((key) => `let ${key} = _ctx[${JSON.stringify(key)}];`).join('\n')
|
|
653
|
+
const writeBacks = keys.map((key) => `_ctx[${JSON.stringify(key)}] = ${key};`).join('\n')
|
|
654
|
+
const wrappedCode = `${declarations}\nconst _result = (function() { ${code} })();\n${writeBacks}\nreturn _result;`
|
|
655
|
+
const func = new Function('_ctx', wrappedCode)
|
|
656
|
+
return func(this.sceneFile)
|
|
657
|
+
} catch (error) {
|
|
658
|
+
throw new Error(`Error executing code: ${error.message}`)
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
async executeScenario(scenarioObjects) {
|
|
663
|
+
const snap = this.scenarioManager.snapshot()
|
|
664
|
+
try {
|
|
665
|
+
this.scenarioManager.setScenario(scenarioObjects)
|
|
666
|
+
await this.runScenario()
|
|
667
|
+
return { success: true }
|
|
743
668
|
} catch (error) {
|
|
744
|
-
console.error('
|
|
669
|
+
console.error('scenario error:', error)
|
|
670
|
+
return {
|
|
671
|
+
success: false,
|
|
672
|
+
error: error.message || 'Unknown error',
|
|
673
|
+
}
|
|
674
|
+
} finally {
|
|
675
|
+
this.scenarioManager.restore(snap)
|
|
745
676
|
}
|
|
746
677
|
}
|
|
747
678
|
|
|
748
679
|
// Scriptから安全にアクセスできるメソッドを定義
|
|
749
680
|
getAPIForScript() {
|
|
750
681
|
return {
|
|
682
|
+
eventBus: this.eventBus,
|
|
751
683
|
drawer: {
|
|
752
684
|
drawName: this.drawer.drawName.bind(this.drawer),
|
|
753
685
|
drawText: this.drawer.drawText.bind(this.drawer),
|
|
@@ -822,6 +754,18 @@ export class Core {
|
|
|
822
754
|
getSaveList: () => this.getSaveList(),
|
|
823
755
|
deleteSave: (slot) => this.deleteSave(slot),
|
|
824
756
|
},
|
|
757
|
+
store: this.store,
|
|
758
|
+
playback: {
|
|
759
|
+
toggleAuto: () => { this.isAuto = !this.isAuto },
|
|
760
|
+
setAuto: (value) => { this.isAuto = value },
|
|
761
|
+
getAuto: () => this.isAuto,
|
|
762
|
+
toggleSkip: () => { this.isSkip = !this.isSkip },
|
|
763
|
+
setSkip: (value) => { this.isSkip = value },
|
|
764
|
+
getSkip: () => this.isSkip,
|
|
765
|
+
},
|
|
766
|
+
sandbox: {
|
|
767
|
+
execute: this.executeScenario.bind(this),
|
|
768
|
+
},
|
|
825
769
|
}
|
|
826
770
|
}
|
|
827
771
|
|
|
@@ -872,77 +816,64 @@ export class Core {
|
|
|
872
816
|
async loadHandler(line) {
|
|
873
817
|
const slot = line.slot || 'auto'
|
|
874
818
|
|
|
875
|
-
const saveDataRaw = this.store.get
|
|
819
|
+
const saveDataRaw = this.store.get(`save_${slot}`)
|
|
876
820
|
if (!saveDataRaw) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
if (line.message !== false) {
|
|
880
|
-
await this.textHandler(errorMsg)
|
|
881
|
-
}
|
|
882
|
-
return
|
|
821
|
+
throw new Error(`セーブデータが見つかりません: スロット${slot}`)
|
|
883
822
|
}
|
|
884
823
|
|
|
885
824
|
// ディープコピーで循環参照を回避
|
|
886
825
|
const saveData = JSON.parse(JSON.stringify(saveDataRaw))
|
|
887
826
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
827
|
+
const sceneName = saveData.scenarioManager.sceneName || saveData.sceneConfig.name
|
|
828
|
+
if (!sceneName) {
|
|
829
|
+
throw new Error('Scene name not found in save data')
|
|
830
|
+
}
|
|
893
831
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
832
|
+
// シーンとプログレスを復元
|
|
833
|
+
await this.loadScene(sceneName)
|
|
834
|
+
await this.loadScreen(saveData.sceneConfig, { skipBackground: true, skipBgm: true })
|
|
897
835
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
836
|
+
// 読んだところまで復元
|
|
837
|
+
this.scenarioManager.setSceneName(saveData.scenarioManager.sceneName)
|
|
838
|
+
this.scenarioManager.setIndex(saveData.scenarioManager.currentIndex)
|
|
839
|
+
this.scenarioManager.setHistory(saveData.scenarioManager.history || [])
|
|
840
|
+
this.scenarioManager.progress = { ...this.scenarioManager.progress, ...saveData.scenarioManager.progress }
|
|
903
841
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
}
|
|
842
|
+
// 画面の復元
|
|
843
|
+
this.displayedImages = {}
|
|
844
|
+
if (saveData.backgroundImage) {
|
|
845
|
+
const background = await new ImageObject().setImageAsync(saveData.backgroundImage)
|
|
846
|
+
this.displayedImages['background'] = {
|
|
847
|
+
image: background,
|
|
848
|
+
size: {
|
|
849
|
+
width: this.gameContainer.clientWidth,
|
|
850
|
+
height: this.gameContainer.clientHeight,
|
|
851
|
+
},
|
|
915
852
|
}
|
|
853
|
+
}
|
|
916
854
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
855
|
+
for (const [key, imageData] of Object.entries(saveData.displayedImages)) {
|
|
856
|
+
if (imageData.src) {
|
|
857
|
+
const image = await new ImageObject().setImageAsync(imageData.src)
|
|
858
|
+
this.displayedImages[key] = {
|
|
859
|
+
image: image,
|
|
860
|
+
pos: imageData.pos,
|
|
861
|
+
size: imageData.size,
|
|
862
|
+
look: imageData.look,
|
|
863
|
+
entry: imageData.entry,
|
|
927
864
|
}
|
|
928
865
|
}
|
|
866
|
+
}
|
|
929
867
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
this.drawer.show(this.displayedImages)
|
|
868
|
+
// BGMの復元
|
|
869
|
+
if (saveData.bgmSrc) {
|
|
870
|
+
this.soundHandler({ mode: 'bgm', src: saveData.bgmSrc, loop: true, play: true })
|
|
871
|
+
}
|
|
936
872
|
|
|
937
|
-
|
|
938
|
-
await this.textHandler(`ゲームをロードしました: ${saveData.name}`)
|
|
939
|
-
}
|
|
940
|
-
} catch (error) {
|
|
941
|
-
const errorMsg = `ロードに失敗しました: ${error.message}`
|
|
873
|
+
this.drawer.show(this.displayedImages)
|
|
942
874
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
}
|
|
875
|
+
if (line.message !== false) {
|
|
876
|
+
await this.textHandler(`ゲームをロードしました: ${saveData.name}`)
|
|
946
877
|
}
|
|
947
878
|
}
|
|
948
879
|
|
|
@@ -964,6 +895,6 @@ export class Core {
|
|
|
964
895
|
}
|
|
965
896
|
|
|
966
897
|
deleteSave(slot) {
|
|
967
|
-
|
|
898
|
+
this.store.remove(`save_${slot}`)
|
|
968
899
|
}
|
|
969
900
|
}
|