webtalekit-alpha 0.2.10 → 0.2.13
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/.claude/settings.local.json +12 -0
- package/.clinerules +65 -0
- package/.history/README_20240812174230.md +193 -0
- package/.history/README_20240812175424.md +185 -0
- package/.history/README_20240812191012.md +185 -0
- package/.history/README_20240812191155.md +185 -0
- package/.history/README_20240812191211.md +185 -0
- package/.history/README_20240812192035.md +185 -0
- package/.history/dist/src/core/index_20240815021552.js +474 -0
- package/.history/dist/src/core/index_20240815022042.js +476 -0
- package/.history/dist/src/core/index_20240815022206.js +476 -0
- package/.history/dist/src/core/index_20240815023104.js +478 -0
- package/.history/dist/src/core/index_20240817022019.js +494 -0
- package/.history/dist/src/core/index_20240818013827.js +493 -0
- package/.history/dist/src/core/index_20240820001418.js +502 -0
- package/.history/package_20240812174230.json +45 -0
- package/.history/package_20240825011731.json +45 -0
- package/.history/package_20240825011739.json +44 -0
- package/.history/parser/parser_20240812174230.js +50 -0
- package/.history/parser/parser_20240825012739.js +47 -0
- package/.history/parser/parser_20240825012835.js +52 -0
- package/.history/src/core/drawer_20240813091343.ts +262 -0
- package/.history/src/core/drawer_20240815232345.ts +262 -0
- package/.history/src/core/drawer_20240815232350.ts +262 -0
- package/.history/src/core/drawer_20240816025257.ts +357 -0
- package/.history/src/core/drawer_20240816025358.ts +357 -0
- package/.history/src/core/drawer_20240816030148.ts +365 -0
- package/.history/src/core/drawer_20240816231033.ts +294 -0
- package/.history/src/core/drawer_20240816231107.ts +262 -0
- package/.history/src/core/drawer_20240816231234.ts +268 -0
- package/.history/src/core/drawer_20240817013836.ts +290 -0
- package/.history/src/core/drawer_20240817015150.ts +289 -0
- package/.history/src/core/drawer_20240817015353.ts +290 -0
- package/.history/src/core/drawer_20240817021254.ts +291 -0
- package/.history/src/core/drawer_20240817023440.ts +295 -0
- package/.history/src/core/drawer_20240817023445.ts +295 -0
- package/.history/src/core/drawer_20240818015327.ts +295 -0
- package/.history/src/core/drawer_20240819231006.ts +318 -0
- package/.history/src/core/drawer_20240820002829.ts +317 -0
- package/.history/src/core/drawer_20240820003141.ts +295 -0
- package/.history/src/core/drawer_20240824010043.ts +295 -0
- package/.history/src/core/drawer_20240825013311.ts +293 -0
- package/.history/src/core/drawer_20240902235257.ts +295 -0
- package/.history/src/core/drawer_20240904002038.ts +262 -0
- package/.history/src/core/drawer_20240904004020.ts +262 -0
- package/.history/src/core/drawer_20240904004238.ts +262 -0
- package/.history/src/core/drawer_20240904005648.ts +262 -0
- package/.history/src/core/drawer_20240904005808.ts +262 -0
- package/.history/src/core/drawer_20240904010523.ts +262 -0
- package/.history/src/core/drawer_20240904011611.ts +262 -0
- package/.history/src/core/drawer_20240904011740.ts +262 -0
- package/.history/src/core/index_20240812190102.js +443 -0
- package/.history/src/core/index_20240812190105.js +443 -0
- package/.history/src/core/index_20240812205421.js +452 -0
- package/.history/src/core/index_20240812213441.js +452 -0
- package/.history/src/core/index_20240812214203.js +453 -0
- package/.history/src/core/index_20240813090823.js +453 -0
- package/.history/src/core/index_20240813230449.js +452 -0
- package/.history/src/core/index_20240813230539.js +452 -0
- package/.history/src/core/index_20240813231447.js +453 -0
- package/.history/src/core/index_20240813231449.js +453 -0
- package/.history/src/core/index_20240813231511.js +453 -0
- package/.history/src/core/index_20240813231531.js +453 -0
- package/.history/src/core/index_20240813231913.js +453 -0
- package/.history/src/core/index_20240813232356.js +453 -0
- package/.history/src/core/index_20240813232640.js +453 -0
- package/.history/src/core/index_20240813232900.js +453 -0
- package/.history/src/core/index_20240814221127.js +454 -0
- package/.history/src/core/index_20240814221322.js +454 -0
- package/.history/src/core/index_20240814221526.js +454 -0
- package/.history/src/core/index_20240814222048.js +454 -0
- package/.history/src/core/index_20240814222918.js +459 -0
- package/.history/src/core/index_20240814223136.js +459 -0
- package/.history/src/core/index_20240814223501.js +464 -0
- package/.history/src/core/index_20240814224347.js +468 -0
- package/.history/src/core/index_20240815013712.js +474 -0
- package/.history/src/core/index_20240815021534.js +474 -0
- package/.history/src/core/index_20240815023143.js +477 -0
- package/.history/src/core/index_20240815023207.js +479 -0
- package/.history/src/core/index_20240815023344.js +481 -0
- package/.history/src/core/index_20240815035600.js +479 -0
- package/.history/src/core/index_20240815041549.js +480 -0
- package/.history/src/core/index_20240815185515.js +481 -0
- package/.history/src/core/index_20240815192158.js +481 -0
- package/.history/src/core/index_20240815222912.js +482 -0
- package/.history/src/core/index_20240815224052.js +483 -0
- package/.history/src/core/index_20240815224843.js +484 -0
- package/.history/src/core/index_20240815224850.js +483 -0
- package/.history/src/core/index_20240815231706.js +479 -0
- package/.history/src/core/index_20240816025748.js +483 -0
- package/.history/src/core/index_20240816030102.js +484 -0
- package/.history/src/core/index_20240817013329.js +485 -0
- package/.history/src/core/index_20240817013526.js +485 -0
- package/.history/src/core/index_20240817013819.js +488 -0
- package/.history/src/core/index_20240817013829.js +488 -0
- package/.history/src/core/index_20240817014921.js +494 -0
- package/.history/src/core/index_20240817022057.js +494 -0
- package/.history/src/core/index_20240817023316.js +493 -0
- package/.history/src/core/index_20240818005637.js +493 -0
- package/.history/src/core/index_20240818005721.js +493 -0
- package/.history/src/core/index_20240818011804.js +493 -0
- package/.history/src/core/index_20240818013835.js +493 -0
- package/.history/src/core/index_20240818014310.js +493 -0
- package/.history/src/core/index_20240818014323.js +493 -0
- package/.history/src/core/index_20240818014333.js +493 -0
- package/.history/src/core/index_20240818020725.js +496 -0
- package/.history/src/core/index_20240819195504.js +497 -0
- package/.history/src/core/index_20240819202012.js +495 -0
- package/.history/src/core/index_20240819231228.js +501 -0
- package/.history/src/core/index_20240819232555.js +502 -0
- package/.history/src/core/index_20240819233404.js +502 -0
- package/.history/src/core/index_20240820003114.js +495 -0
- package/.history/src/core/index_20240820003120.js +495 -0
- package/.history/src/core/index_20240820003331.js +495 -0
- package/.history/src/core/index_20240820004126.js +498 -0
- package/.history/src/core/index_20240820004357.js +497 -0
- package/.history/src/core/index_20240820005103.js +498 -0
- package/.history/src/core/index_20240820005110.js +499 -0
- package/.history/src/core/index_20240820005206.js +497 -0
- package/.history/src/core/index_20240820005352.js +497 -0
- package/{src/core/index.js → .history/src/core/index_20240823224904.ts} +75 -224
- package/.history/src/core/index_20240823224905.js +505 -0
- package/.history/src/core/index_20240823231631.ts +530 -0
- package/.history/src/core/index_20240823231735.ts +530 -0
- package/.history/src/core/index_20240823232123.ts +539 -0
- package/.history/src/core/index_20240823232329.ts +539 -0
- package/.history/src/core/index_20240823233058.ts +539 -0
- package/.history/src/core/index_20240823234946.ts +539 -0
- package/.history/src/core/index_20240824005956.ts +534 -0
- package/.history/src/core/index_20240824010113.ts +534 -0
- package/.history/src/core/index_20240824010124.ts +534 -0
- package/.history/src/core/index_20240824010212.ts +534 -0
- package/.history/src/core/index_20240824010218.ts +534 -0
- package/.history/src/core/index_20240824010407.ts +534 -0
- package/.history/src/core/index_20240824010611.ts +534 -0
- package/.history/src/core/index_20240824010623.ts +534 -0
- package/.history/src/core/index_20240824010652.ts +534 -0
- package/.history/src/core/index_20240824011007.ts +534 -0
- package/.history/src/core/index_20240824210450.ts +534 -0
- package/.history/src/core/index_20240824210703.ts +534 -0
- package/.history/src/core/index_20240824210708.ts +534 -0
- package/.history/src/core/index_20240824211001.ts +537 -0
- package/.history/src/core/index_20240824211258.ts +537 -0
- package/.history/src/core/index_20240824211654.ts +537 -0
- package/.history/src/core/index_20240824211723.ts +537 -0
- package/.history/src/core/index_20240824211808.ts +538 -0
- package/.history/src/core/index_20240824214041.js +538 -0
- package/.history/src/core/index_20240824215312.ts +538 -0
- package/.history/src/core/index_20240824215341.ts +538 -0
- package/.history/src/core/index_20240824220703.ts +538 -0
- package/.history/src/core/index_20240824220709.ts +538 -0
- package/.history/src/core/index_20240825012244.ts +536 -0
- package/.history/src/core/index_20240825012435.ts +539 -0
- package/.history/src/core/index_20240825012440.ts +539 -0
- package/.history/src/core/index_20240826005054.ts +539 -0
- package/.history/src/core/index_20240826005321.ts +540 -0
- package/.history/src/core/index_20240826005410.ts +539 -0
- package/.history/src/core/index_20240826005418.ts +539 -0
- package/.history/src/core/index_20240830231825.ts +539 -0
- package/.history/src/core/index_20240831022416.ts +539 -0
- package/.history/src/core/index_20240901222314.js +459 -0
- package/.history/src/core/index_20240901222951.js +459 -0
- package/.history/src/core/index_20240901223824.js +471 -0
- package/.history/src/core/index_20240901223833.js +468 -0
- package/.history/src/core/index_20240902223954.js +447 -0
- package/.history/src/core/index_20240902224000.js +446 -0
- package/.history/src/core/index_20240902230345.js +448 -0
- package/.history/src/core/index_20240902231130.js +449 -0
- package/.history/src/core/index_20240902231559.js +449 -0
- package/.history/src/core/index_20240902232135.js +449 -0
- package/.history/src/core/index_20240902232809.js +452 -0
- package/.history/src/core/index_20240902232815.js +452 -0
- package/.history/src/core/index_20240903000104.js +467 -0
- package/.history/src/core/index_20240904001731.js +444 -0
- package/.history/src/core/index_20240904002038.ts +539 -0
- package/.history/src/core/index_20240904011848.js +444 -0
- package/.history/src/core/index_20240904012138.js +444 -0
- package/.history/src/core/index_20240904012743.js +444 -0
- package/.history/src/core/index_20240904013051.js +444 -0
- package/.history/src/core/resourceManager_20240403231531.ts +16 -0
- package/.history/src/core/resourceManager_20240823232627.ts +17 -0
- package/.history/src/core/resourceManager_20240824214014.js +16 -0
- package/.history/src/core/resourceManager_20240824214620.js +17 -0
- package/.history/src/core/scenarioManager_20240812203410.ts +86 -0
- package/.history/src/core/scenarioManager_20240812203839.ts +94 -0
- package/.history/src/core/scenarioManager_20240812213437.ts +85 -0
- package/.history/src/core/scenarioManager_20240813225852.ts +85 -0
- package/.history/src/core/scenarioManager_20240823235010.ts +85 -0
- package/.history/src/core/scenarioManager_20240904002038.ts +94 -0
- package/.history/src/core/scenarioManager_20240904012411.ts +94 -0
- package/.history/src/core/scenarioManager_20240904012519.ts +94 -0
- package/.history/src/index_20240403231531.js +6 -0
- package/.history/src/index_20240429233436.js +8 -0
- package/.history/src/index_20240429233926.js +8 -0
- package/.history/src/index_20240429234401.js +7 -0
- package/.history/src/index_20240429234404.js +6 -0
- package/.history/src/resource/soundObject_20240419004314.ts +71 -0
- package/.history/src/resource/soundObject_20240815034420.ts +66 -0
- package/.history/src/resource/soundObject_20240815034836.ts +79 -0
- package/.history/src/resource/soundObject_20240815034919.ts +87 -0
- package/.history/src/resource/soundObject_20240815040724.ts +81 -0
- package/.history/src/resource/soundObject_20240815041022.ts +87 -0
- package/.history/src/resource/soundObject_20240815042103.ts +87 -0
- package/.history/src/resource/soundObject_20240823235929.ts +91 -0
- package/.history/src/resource/soundObject_20240824213129.ts +99 -0
- package/.history/src/resource/soundObject_20240824213611.ts +101 -0
- package/.history/src/resource/soundObject_20240824215734.ts +101 -0
- package/.history/src/resource/soundObject_20240825004926.ts +101 -0
- package/.history/src/resource/soundObject_20240825004947.ts +101 -0
- package/.history/src/utils/logger_20240812174230.ts +13 -0
- package/.history/src/utils/logger_20240823232736.ts +14 -0
- package/.history/src/utils/logger_20240824214930.js +14 -0
- package/.history/src/utils/store_20240812174230.ts +17 -0
- package/.history/src/utils/store_20240823232948.ts +29 -0
- package/.history/src/utils/store_20240824214020.js +17 -0
- package/.history/src/utils/store_20240824214955.js +29 -0
- package/.history/src/utils/waitUtil_20240812174230.ts +4 -0
- package/.history/src/utils/waitUtil_20240823232739.ts +4 -0
- package/.history/src/utils/waitUtil_20240824214024.js +4 -0
- package/.history/src/utils/waitUtil_20240824215009.js +4 -0
- package/.history/test/js/title_20240428215305.js +254 -0
- package/.history/test/js/title_20240429221911.js +227 -0
- package/.history/test/js/title_20240429222806.js +243 -0
- package/.history/test/js/title_20240429222854.js +263 -0
- package/.history/test/js/title_20240429222906.js +263 -0
- package/.history/test/js/title_20240429235639.js +263 -0
- package/.history/test/js/title_20240429235840.js +263 -0
- package/.history/test/js/title_20240430014721.js +262 -0
- package/.history/test/js/title_20240430014759.js +254 -0
- package/.history/test/js/title_20240430134612.js +285 -0
- package/.history/test/js/title_20240430141051.js +285 -0
- package/.history/test/js/title_20240430173745.js +245 -0
- package/.history/tsconfig_20240812174230.json +22 -0
- package/.history/tsconfig_20240824010157.json +19 -0
- package/.history/tsconfig_20240824220700.json +20 -0
- package/.history/tsconfig_20240825011301.json +20 -0
- package/.history/webpack.config_20240423002825.js +37 -0
- package/.history/webpack.config_20240430001157.js +38 -0
- package/.history/webpack.config_20240430001309.js +37 -0
- package/.history/webpack.config_20240430002112.js +37 -0
- package/CLAUDE.md +96 -0
- package/LICENSE +21 -0
- package/README.md +149 -48
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/core/drawer.ts.html +1264 -0
- package/coverage/lcov-report/core/index.html +146 -0
- package/coverage/lcov-report/core/resourceManager.ts.html +136 -0
- package/coverage/lcov-report/core/scenarioManager.ts.html +373 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/resource/ImageObject.ts.html +433 -0
- package/coverage/lcov-report/resource/index.html +131 -0
- package/coverage/lcov-report/resource/soundObject.ts.html +346 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/utils/TextMeasurer.ts.html +520 -0
- package/coverage/lcov-report/utils/index.html +161 -0
- package/coverage/lcov-report/utils/logger.ts.html +142 -0
- package/coverage/lcov-report/utils/store.ts.html +151 -0
- package/coverage/lcov-report/utils/waitUtil.ts.html +97 -0
- package/coverage/lcov.info +882 -0
- package/dist/README.md +294 -0
- package/dist/engineConfig.json +10 -0
- package/dist/package.json +51 -0
- package/dist/parser/cli.js +61 -0
- package/dist/parser/parser.js +53 -0
- package/{src → dist/src}/core/drawer.js +2 -11
- package/dist/src/core/drawer.js.map +1 -0
- package/dist/src/core/index.js +969 -0
- package/{src → dist/src}/core/scenarioManager.js +5 -6
- package/dist/src/core/scenarioManager.js.map +1 -0
- package/{src → dist/src}/resource/ImageObject.js +2 -2
- package/{src → dist/src}/resource/soundObject.js +6 -4
- package/dist/src/resource/soundObject.js.map +1 -0
- package/dist/src/utils/fallbackTemplate.js +13 -0
- package/dist/src/utils/fallbackTemplate.js.map +1 -0
- package/{src → dist/src}/utils/logger.js +4 -3
- package/dist/src/utils/logger.js.map +1 -0
- package/{src → dist/src}/utils/waitUtil.js +4 -3
- package/dist/src/utils/waitUtil.js.map +1 -0
- package/dist/webtalekit-alpha-0.2.13.tgz +0 -0
- package/docs/event-system-specification.md +493 -0
- package/docs/glossary.html +833 -0
- package/docs/index.html +296 -0
- package/docs/tag-reference.html +1317 -0
- package/docs/ui-template-guide.html +1068 -0
- package/example/README.md +29 -0
- package/example/engineConfig.json +10 -0
- package/example/package-lock.json +5145 -0
- package/example/package.json +26 -0
- package/example/src/index.js +13 -0
- 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 +28 -0
- package/example/src/scene/background.scene +29 -0
- package/example/src/scene/character.scene +26 -0
- package/example/src/scene/choice.scene +97 -0
- package/example/src/scene/dialog.scene +105 -0
- package/example/src/scene/effects.scene +38 -0
- package/example/src/scene/en/animation.scene +28 -0
- package/example/src/scene/en/background.scene +26 -0
- package/example/src/scene/en/character.scene +26 -0
- package/example/src/scene/en/choice.scene +32 -0
- package/example/src/scene/en/effects.scene +37 -0
- package/example/src/scene/en/sound.scene +26 -0
- package/example/src/scene/en/text.scene +26 -0
- package/example/src/scene/en/title.scene +39 -0
- package/example/src/scene/if_test.scene +37 -0
- package/example/src/scene/resource-error-test.scene +15 -0
- package/example/src/scene/save-load-test.scene +48 -0
- package/example/src/scene/sound.scene +26 -0
- package/example/src/scene/test_error.scene +21 -0
- package/example/src/scene/text.scene +34 -0
- package/example/src/scene/title.scene +51 -0
- package/example/src/screen/incoming.html +474 -0
- package/example/src/screen/title.html +135 -0
- package/example/src/template.html +16 -0
- package/example/test-results/.last-run.json +4 -0
- package/example/webpack.config.js +69 -0
- package/image.png +0 -0
- package/package.json +3 -1
- package/playwright-report/index.html +71 -0
- package/s-plan1-5Light-s-1.jpg +0 -0
- package/test-results/.last-run.json +6 -0
- package/tests/e2e/if-global-attribute.spec.js +90 -0
- package/tests/e2e/resource-error-handling.spec.js +58 -0
- 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/src/core/drawer.js.map +0 -1
- package/src/core/scenarioManager.js.map +0 -1
- package/src/resource/soundObject.js.map +0 -1
- package/src/utils/logger.js.map +0 -1
- package/src/utils/waitUtil.js.map +0 -1
- /package/{src → dist/src}/core/resourceManager.js +0 -0
- /package/{src → dist/src}/core/resourceManager.js.map +0 -0
- /package/{src → dist/src}/resource/ImageObject.js.map +0 -0
- /package/{src → dist/src}/utils/store.js +0 -0
- /package/{src → dist/src}/utils/store.js.map +0 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { ImageObject } from '../resource/ImageObject'
|
|
2
|
+
import { outputLog } from '../utils/logger'
|
|
3
|
+
import { sleep } from '../utils/waitUtil'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
drawerの目的
|
|
7
|
+
UIのHTMLとcanvasを描画する。
|
|
8
|
+
*/
|
|
9
|
+
export class Drawer {
|
|
10
|
+
private gameScreen: HTMLElement
|
|
11
|
+
private nameView!: HTMLElement
|
|
12
|
+
private messageText!: HTMLElement
|
|
13
|
+
private interactiveView!: HTMLElement
|
|
14
|
+
private ctx!: CanvasRenderingContext2D
|
|
15
|
+
private screenHtml!: HTMLElement
|
|
16
|
+
private config: any
|
|
17
|
+
isSkip: boolean = false
|
|
18
|
+
readySkip: boolean = false
|
|
19
|
+
|
|
20
|
+
constructor(gameContainer: HTMLElement) {
|
|
21
|
+
this.gameScreen = gameContainer
|
|
22
|
+
// ウィンドウのリサイズ時にスケールを調整
|
|
23
|
+
window.addEventListener('resize', () => this.adjustScale(this.gameScreen))
|
|
24
|
+
// 初期ロード時にもスケールを調整
|
|
25
|
+
this.adjustScale(this.gameScreen)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setScreen(screenHtml: HTMLElement, resolution: { width: number; height: number }) {
|
|
29
|
+
this.screenHtml = screenHtml
|
|
30
|
+
this.nameView = screenHtml.querySelector('#nameView') as HTMLElement
|
|
31
|
+
this.messageText = screenHtml.querySelector('#messageView') as HTMLElement
|
|
32
|
+
this.interactiveView = screenHtml.querySelector(
|
|
33
|
+
'#interactiveView',
|
|
34
|
+
) as HTMLElement
|
|
35
|
+
|
|
36
|
+
// canvasをDOMに追加する
|
|
37
|
+
const canvas = document.createElement('canvas')
|
|
38
|
+
canvas.width = (resolution.width || 1280) * devicePixelRatio;
|
|
39
|
+
canvas.height = (resolution.height || 720) * devicePixelRatio;
|
|
40
|
+
// canvasのコンテキストを取得する
|
|
41
|
+
this.gameScreen.appendChild(canvas)
|
|
42
|
+
this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D
|
|
43
|
+
// 黒で塗りつぶす
|
|
44
|
+
this.ctx.fillStyle = 'black'
|
|
45
|
+
this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
|
|
46
|
+
// 初期ロード時にもスケールを調整
|
|
47
|
+
this.adjustScale(this.gameScreen)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
drawName(name: string) {
|
|
51
|
+
this.nameView.innerHTML = name
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async drawText(text: string, wait: number, containerElement?: HTMLElement) {
|
|
55
|
+
outputLog('drawText', 'debug', { text, wait, containerElement })
|
|
56
|
+
let element: HTMLElement = this.messageText
|
|
57
|
+
if(containerElement) {
|
|
58
|
+
this.messageText.appendChild(containerElement);
|
|
59
|
+
element = containerElement
|
|
60
|
+
}
|
|
61
|
+
for (const char of text) {
|
|
62
|
+
//prettier-ignore
|
|
63
|
+
setTimeout(() => { this.readySkip = true, wait });
|
|
64
|
+
// 100ミリ秒待ってから、スキップボタンが押されたら即座に表示
|
|
65
|
+
if (!this.isSkip) {
|
|
66
|
+
element.textContent += char
|
|
67
|
+
await sleep(wait)
|
|
68
|
+
} else {
|
|
69
|
+
if (this.readySkip) {
|
|
70
|
+
element.textContent += text.slice(element.textContent!.length);
|
|
71
|
+
this.readySkip = false
|
|
72
|
+
this.isSkip = false
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
clearText() {
|
|
80
|
+
if (this.messageText) {
|
|
81
|
+
this.messageText.innerHTML = '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
createDecoratedElement(element: any): HTMLElement {
|
|
86
|
+
switch (element.type) {
|
|
87
|
+
case 'color':
|
|
88
|
+
const span = document.createElement('span');
|
|
89
|
+
span.style.color = element.value;
|
|
90
|
+
return span;
|
|
91
|
+
case 'ruby':
|
|
92
|
+
const ruby = document.createElement('ruby');
|
|
93
|
+
const rt = document.createElement('rt');
|
|
94
|
+
rt.textContent = element.text;
|
|
95
|
+
ruby.appendChild(rt);
|
|
96
|
+
return ruby;
|
|
97
|
+
case 'b':
|
|
98
|
+
return document.createElement('strong');
|
|
99
|
+
case 'i':
|
|
100
|
+
return document.createElement('em');
|
|
101
|
+
default:
|
|
102
|
+
outputLog(`Unknown decoration type: ${element.type}`, 'warn');
|
|
103
|
+
return document.createElement('span');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async drawChoices(choices: any) {
|
|
108
|
+
let isSelect = false
|
|
109
|
+
let selectId = 0
|
|
110
|
+
let onSelect = 0
|
|
111
|
+
|
|
112
|
+
// 選択肢ボタンの配置を設定する
|
|
113
|
+
const interactiveView = document.querySelector(
|
|
114
|
+
'#interactiveView',
|
|
115
|
+
) as HTMLElement
|
|
116
|
+
if (choices.position == 'auto' || choices.position === undefined) {
|
|
117
|
+
interactiveView.className = 'auto'
|
|
118
|
+
} else {
|
|
119
|
+
interactiveView.className = 'manual'
|
|
120
|
+
}
|
|
121
|
+
// 選択肢を表示
|
|
122
|
+
for (const choice of choices.content) {
|
|
123
|
+
const defaultImage =
|
|
124
|
+
choice.default !== undefined
|
|
125
|
+
? choice.default
|
|
126
|
+
: './src/resource/system/systemPicture/02_button/button.png'
|
|
127
|
+
const hoverImage =
|
|
128
|
+
choice.hover !== undefined
|
|
129
|
+
? choice.hover
|
|
130
|
+
: './src/resource/system/systemPicture/02_button/button2.png'
|
|
131
|
+
const selectImage =
|
|
132
|
+
choice.select !== undefined
|
|
133
|
+
? choice.select
|
|
134
|
+
: './src/resource/system/systemPicture/02_button/button3.png'
|
|
135
|
+
const button = document.createElement('div')
|
|
136
|
+
button.className = 'choice'
|
|
137
|
+
if (interactiveView.className == 'manual') {
|
|
138
|
+
button.style.position = 'absolute'
|
|
139
|
+
button.style.top = choice.position?.y || 0
|
|
140
|
+
button.style.left = choice.position?.x || 0
|
|
141
|
+
}
|
|
142
|
+
button.style.color =
|
|
143
|
+
choice.color !== undefined ? choice.color.default : 'black'
|
|
144
|
+
button.style.width = '100%'
|
|
145
|
+
button.style.height = '50px'
|
|
146
|
+
button.style.backgroundImage = `url(${defaultImage})`
|
|
147
|
+
button.style.textAlign = 'center'
|
|
148
|
+
button.style.backgroundRepeat = 'no-repeat'
|
|
149
|
+
button.style.backgroundPosition = 'center'
|
|
150
|
+
button.style.paddingTop = '20px'
|
|
151
|
+
button.addEventListener('mouseenter', function () {
|
|
152
|
+
// マウスが要素の上にあるときの背景色
|
|
153
|
+
this.style.backgroundImage = `url(${hoverImage})`
|
|
154
|
+
this.style.color =
|
|
155
|
+
choice.color !== undefined ? choice.color.hover : 'black'
|
|
156
|
+
})
|
|
157
|
+
button.addEventListener('mouseleave', function () {
|
|
158
|
+
// マウスが要素から離れたときの背景色
|
|
159
|
+
this.style.backgroundImage = `url(${defaultImage})`
|
|
160
|
+
this.style.color =
|
|
161
|
+
choice.color !== undefined ? choice.color.default : 'black'
|
|
162
|
+
})
|
|
163
|
+
button.addEventListener('mousedown', function () {
|
|
164
|
+
// マウスが要素を選択したときの背景色
|
|
165
|
+
this.style.backgroundImage = `url(${selectImage})`
|
|
166
|
+
this.style.color =
|
|
167
|
+
choice.color !== undefined ? choice.color.select : 'black'
|
|
168
|
+
})
|
|
169
|
+
button.innerHTML = choice.label
|
|
170
|
+
button.onclick = () => {
|
|
171
|
+
outputLog('click', 'debug', choice)
|
|
172
|
+
this.interactiveView.querySelectorAll('.choice').forEach((element) => {
|
|
173
|
+
element.parentNode?.removeChild(element)
|
|
174
|
+
})
|
|
175
|
+
selectId = choice.id
|
|
176
|
+
onSelect = choice.content
|
|
177
|
+
isSelect = true
|
|
178
|
+
}
|
|
179
|
+
this.interactiveView.appendChild(button)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 選択待ち
|
|
183
|
+
return new Promise((resolve) => {
|
|
184
|
+
const intervalId = setInterval(() => {
|
|
185
|
+
if (isSelect) {
|
|
186
|
+
clearInterval(intervalId)
|
|
187
|
+
resolve({ selectId, onSelect })
|
|
188
|
+
}
|
|
189
|
+
}, 100)
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
clear() {
|
|
194
|
+
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
show(displayedImages: any) {
|
|
198
|
+
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
|
|
199
|
+
for (let key in displayedImages) {
|
|
200
|
+
const img: ImageObject = displayedImages[key].image
|
|
201
|
+
const pos: { x: number; y: number } = displayedImages[key].pos || {
|
|
202
|
+
x: 0,
|
|
203
|
+
y: 0,
|
|
204
|
+
}
|
|
205
|
+
const size: { width: number; height: number } = displayedImages[key].size
|
|
206
|
+
const reverse: boolean = displayedImages[key].look || false
|
|
207
|
+
const entry: { time: number; wait: boolean } = displayedImages[key]
|
|
208
|
+
.entry || { time: 1, wait: false }
|
|
209
|
+
if (entry.wait) {
|
|
210
|
+
// 表示開始までの遅延処理
|
|
211
|
+
setTimeout(() => {
|
|
212
|
+
this.drawCanvas(img, pos, size, reverse)
|
|
213
|
+
}, entry.time * 1000)
|
|
214
|
+
} else {
|
|
215
|
+
this.drawCanvas(img, pos, size, reverse)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
moveTo(name: string, displayedImages: any, pos: { x: number; y: number }, durning: number) {
|
|
221
|
+
return new Promise((resolve) => {
|
|
222
|
+
const target = displayedImages[name];
|
|
223
|
+
const startPos = { x: target.pos.x, y: target.pos.y };
|
|
224
|
+
const dest = { x: startPos.x + Number(pos.x), y: startPos.y + Number(pos.y) };
|
|
225
|
+
const startTime = performance.now();
|
|
226
|
+
|
|
227
|
+
const move = (currentTime:any) => {
|
|
228
|
+
const elapsedTime = (currentTime - startTime) / 1000; // 秒単位の経過時間
|
|
229
|
+
const progress = Math.min(elapsedTime / durning, 1); // 0から1の進捗
|
|
230
|
+
|
|
231
|
+
target.pos.x = startPos.x + (dest.x - startPos.x) * progress;
|
|
232
|
+
target.pos.y = startPos.y + (dest.y - startPos.y) * progress;
|
|
233
|
+
|
|
234
|
+
this.show(displayedImages);
|
|
235
|
+
|
|
236
|
+
if (progress < 1) {
|
|
237
|
+
window.requestAnimationFrame(move);
|
|
238
|
+
} else {
|
|
239
|
+
// 最終位置を正確に設定
|
|
240
|
+
target.pos.x = dest.x;
|
|
241
|
+
target.pos.y = dest.y;
|
|
242
|
+
this.show(displayedImages);
|
|
243
|
+
resolve(null);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
window.requestAnimationFrame(move);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
drawCanvas(img: ImageObject, pos: any, size: any, reverse: any) {
|
|
251
|
+
outputLog('drawCanvas', 'debug', {img, pos, size, reverse})
|
|
252
|
+
const canvas = img.draw(reverse).getCanvas()
|
|
253
|
+
// canvasから画像を取得して、this.ctxに描画
|
|
254
|
+
const imageWidth = size !== undefined ? size.width : canvas.width
|
|
255
|
+
const imageHeight = size !== undefined ? size.height : canvas.height
|
|
256
|
+
this.ctx.drawImage(
|
|
257
|
+
canvas,
|
|
258
|
+
0,
|
|
259
|
+
0,
|
|
260
|
+
canvas.width,
|
|
261
|
+
canvas.height,
|
|
262
|
+
pos.x,
|
|
263
|
+
pos.y,
|
|
264
|
+
imageWidth,
|
|
265
|
+
imageHeight,
|
|
266
|
+
) //CanvasRenderingContext2D.drawImage: Passed-in canvas is empty
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
adjustScale(targetElement: HTMLElement) {
|
|
270
|
+
// ターゲット要素の元の幅と高さ
|
|
271
|
+
const originalWidth = targetElement.scrollWidth // 例: 1280px
|
|
272
|
+
const originalHeight = targetElement.scrollHeight // 例: 720px
|
|
273
|
+
|
|
274
|
+
// ビューポートの幅と高さを取得
|
|
275
|
+
const viewportWidth = window.innerWidth
|
|
276
|
+
const viewportHeight = window.innerHeight
|
|
277
|
+
|
|
278
|
+
// 幅と高さのスケールを計算
|
|
279
|
+
const scaleX = viewportWidth / originalWidth
|
|
280
|
+
const scaleY = viewportHeight / originalHeight
|
|
281
|
+
|
|
282
|
+
// 幅と高さのうち、小さい方のスケールを選択(アスペクト比を維持)
|
|
283
|
+
const scale = Math.min(scaleX, scaleY)
|
|
284
|
+
|
|
285
|
+
// ターゲット要素にスケールを適用
|
|
286
|
+
targetElement.style.transform = `scale(${scale})`
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
setVisibility(name: string, isVisible: boolean) {
|
|
290
|
+
const target = this.screenHtml.querySelector(name) as HTMLElement
|
|
291
|
+
if (target) {
|
|
292
|
+
target.style.visibility = isVisible ? 'visible' : 'hidden'
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { ImageObject } from '../resource/ImageObject'
|
|
2
|
+
import { outputLog } from '../utils/logger'
|
|
3
|
+
import { sleep } from '../utils/waitUtil'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
drawerの目的
|
|
7
|
+
UIのHTMLとcanvasを描画する。
|
|
8
|
+
*/
|
|
9
|
+
export class Drawer {
|
|
10
|
+
private gameScreen: HTMLElement
|
|
11
|
+
private nameView!: HTMLElement
|
|
12
|
+
private messageText!: HTMLElement
|
|
13
|
+
private interactiveView!: HTMLElement
|
|
14
|
+
private ctx!: CanvasRenderingContext2D
|
|
15
|
+
private screenHtml!: HTMLElement
|
|
16
|
+
private config: any
|
|
17
|
+
isSkip: boolean = false
|
|
18
|
+
readySkip: boolean = false
|
|
19
|
+
|
|
20
|
+
constructor(gameContainer: HTMLElement) {
|
|
21
|
+
this.gameScreen = gameContainer
|
|
22
|
+
// ウィンドウのリサイズ時にスケールを調整
|
|
23
|
+
window.addEventListener('resize', () => this.adjustScale(this.gameScreen))
|
|
24
|
+
// 初期ロード時にもスケールを調整
|
|
25
|
+
this.adjustScale(this.gameScreen)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setScreen(screenHtml: HTMLElement, resolution: { width: number; height: number }) {
|
|
29
|
+
this.screenHtml = screenHtml
|
|
30
|
+
this.nameView = screenHtml.querySelector('#nameView') as HTMLElement
|
|
31
|
+
this.messageText = screenHtml.querySelector('#messageView') as HTMLElement
|
|
32
|
+
this.interactiveView = screenHtml.querySelector(
|
|
33
|
+
'#interactiveView',
|
|
34
|
+
) as HTMLElement
|
|
35
|
+
|
|
36
|
+
// canvasをDOMに追加する
|
|
37
|
+
const canvas = document.createElement('canvas')
|
|
38
|
+
canvas.width = (resolution.width || 1280) * devicePixelRatio;
|
|
39
|
+
canvas.height = (resolution.height || 720) * devicePixelRatio;
|
|
40
|
+
// canvasのコンテキストを取得する
|
|
41
|
+
this.gameScreen.appendChild(canvas)
|
|
42
|
+
this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D
|
|
43
|
+
// 黒で塗りつぶす
|
|
44
|
+
this.ctx.fillStyle = 'black'
|
|
45
|
+
this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
|
|
46
|
+
// 初期ロード時にもスケールを調整
|
|
47
|
+
this.adjustScale(this.gameScreen)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
drawName(name: string) {
|
|
51
|
+
this.nameView.innerHTML = name
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async drawText(text: string, wait: number, containerElement?: HTMLElement) {
|
|
55
|
+
outputLog('drawText', 'debug', { text, wait, containerElement })
|
|
56
|
+
let element: HTMLElement = this.messageText
|
|
57
|
+
if(containerElement) {
|
|
58
|
+
this.messageText.appendChild(containerElement);
|
|
59
|
+
element = containerElement;
|
|
60
|
+
}
|
|
61
|
+
for (const char of text) {
|
|
62
|
+
//prettier-ignore
|
|
63
|
+
setTimeout(() => { this.readySkip = true, wait });
|
|
64
|
+
// 100ミリ秒待ってから、スキップボタンが押されたら即座に表示
|
|
65
|
+
if (!this.isSkip) {
|
|
66
|
+
element.textContent += char
|
|
67
|
+
await sleep(wait)
|
|
68
|
+
} else {
|
|
69
|
+
if (this.readySkip) {
|
|
70
|
+
element.textContent += text.slice(element.textContent!.length);
|
|
71
|
+
this.readySkip = false
|
|
72
|
+
this.isSkip = false
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
clearText() {
|
|
80
|
+
if (this.messageText) {
|
|
81
|
+
this.messageText.innerHTML = '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
createDecoratedElement(element: any): HTMLElement {
|
|
86
|
+
switch (element.type) {
|
|
87
|
+
case 'color':
|
|
88
|
+
const span = document.createElement('span');
|
|
89
|
+
span.style.color = element.value;
|
|
90
|
+
return span;
|
|
91
|
+
case 'ruby':
|
|
92
|
+
const ruby = document.createElement('ruby');
|
|
93
|
+
const rt = document.createElement('rt');
|
|
94
|
+
rt.textContent = element.text;
|
|
95
|
+
ruby.appendChild(rt);
|
|
96
|
+
return ruby;
|
|
97
|
+
case 'b':
|
|
98
|
+
return document.createElement('strong');
|
|
99
|
+
case 'i':
|
|
100
|
+
return document.createElement('em');
|
|
101
|
+
default:
|
|
102
|
+
outputLog(`Unknown decoration type: ${element.type}`, 'warn');
|
|
103
|
+
return document.createElement('span');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async drawChoices(choices: any) {
|
|
108
|
+
let isSelect = false
|
|
109
|
+
let selectId = 0
|
|
110
|
+
let onSelect = 0
|
|
111
|
+
|
|
112
|
+
// 選択肢ボタンの配置を設定する
|
|
113
|
+
const interactiveView = document.querySelector(
|
|
114
|
+
'#interactiveView',
|
|
115
|
+
) as HTMLElement
|
|
116
|
+
if (choices.position == 'auto' || choices.position === undefined) {
|
|
117
|
+
interactiveView.className = 'auto'
|
|
118
|
+
} else {
|
|
119
|
+
interactiveView.className = 'manual'
|
|
120
|
+
}
|
|
121
|
+
// 選択肢を表示
|
|
122
|
+
for (const choice of choices.content) {
|
|
123
|
+
const defaultImage =
|
|
124
|
+
choice.default !== undefined
|
|
125
|
+
? choice.default
|
|
126
|
+
: './src/resource/system/systemPicture/02_button/button.png'
|
|
127
|
+
const hoverImage =
|
|
128
|
+
choice.hover !== undefined
|
|
129
|
+
? choice.hover
|
|
130
|
+
: './src/resource/system/systemPicture/02_button/button2.png'
|
|
131
|
+
const selectImage =
|
|
132
|
+
choice.select !== undefined
|
|
133
|
+
? choice.select
|
|
134
|
+
: './src/resource/system/systemPicture/02_button/button3.png'
|
|
135
|
+
const button = document.createElement('div')
|
|
136
|
+
button.className = 'choice'
|
|
137
|
+
if (interactiveView.className == 'manual') {
|
|
138
|
+
button.style.position = 'absolute'
|
|
139
|
+
button.style.top = choice.position?.y || 0
|
|
140
|
+
button.style.left = choice.position?.x || 0
|
|
141
|
+
}
|
|
142
|
+
button.style.color =
|
|
143
|
+
choice.color !== undefined ? choice.color.default : 'black'
|
|
144
|
+
button.style.width = '100%'
|
|
145
|
+
button.style.height = '50px'
|
|
146
|
+
button.style.backgroundImage = `url(${defaultImage})`
|
|
147
|
+
button.style.textAlign = 'center'
|
|
148
|
+
button.style.backgroundRepeat = 'no-repeat'
|
|
149
|
+
button.style.backgroundPosition = 'center'
|
|
150
|
+
button.style.paddingTop = '20px'
|
|
151
|
+
button.addEventListener('mouseenter', function () {
|
|
152
|
+
// マウスが要素の上にあるときの背景色
|
|
153
|
+
this.style.backgroundImage = `url(${hoverImage})`
|
|
154
|
+
this.style.color =
|
|
155
|
+
choice.color !== undefined ? choice.color.hover : 'black'
|
|
156
|
+
})
|
|
157
|
+
button.addEventListener('mouseleave', function () {
|
|
158
|
+
// マウスが要素から離れたときの背景色
|
|
159
|
+
this.style.backgroundImage = `url(${defaultImage})`
|
|
160
|
+
this.style.color =
|
|
161
|
+
choice.color !== undefined ? choice.color.default : 'black'
|
|
162
|
+
})
|
|
163
|
+
button.addEventListener('mousedown', function () {
|
|
164
|
+
// マウスが要素を選択したときの背景色
|
|
165
|
+
this.style.backgroundImage = `url(${selectImage})`
|
|
166
|
+
this.style.color =
|
|
167
|
+
choice.color !== undefined ? choice.color.select : 'black'
|
|
168
|
+
})
|
|
169
|
+
button.innerHTML = choice.label
|
|
170
|
+
button.onclick = () => {
|
|
171
|
+
outputLog('click', 'debug', choice)
|
|
172
|
+
this.interactiveView.querySelectorAll('.choice').forEach((element) => {
|
|
173
|
+
element.parentNode?.removeChild(element)
|
|
174
|
+
})
|
|
175
|
+
selectId = choice.id
|
|
176
|
+
onSelect = choice.content
|
|
177
|
+
isSelect = true
|
|
178
|
+
}
|
|
179
|
+
this.interactiveView.appendChild(button)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 選択待ち
|
|
183
|
+
return new Promise((resolve) => {
|
|
184
|
+
const intervalId = setInterval(() => {
|
|
185
|
+
if (isSelect) {
|
|
186
|
+
clearInterval(intervalId)
|
|
187
|
+
resolve({ selectId, onSelect })
|
|
188
|
+
}
|
|
189
|
+
}, 100)
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
clear() {
|
|
194
|
+
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
show(displayedImages: any) {
|
|
198
|
+
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
|
|
199
|
+
for (let key in displayedImages) {
|
|
200
|
+
const img: ImageObject = displayedImages[key].image
|
|
201
|
+
const pos: { x: number; y: number } = displayedImages[key].pos || {
|
|
202
|
+
x: 0,
|
|
203
|
+
y: 0,
|
|
204
|
+
}
|
|
205
|
+
const size: { width: number; height: number } = displayedImages[key].size
|
|
206
|
+
const reverse: boolean = displayedImages[key].look || false
|
|
207
|
+
const entry: { time: number; wait: boolean } = displayedImages[key]
|
|
208
|
+
.entry || { time: 1, wait: false }
|
|
209
|
+
if (entry.wait) {
|
|
210
|
+
// 表示開始までの遅延処理
|
|
211
|
+
setTimeout(() => {
|
|
212
|
+
this.drawCanvas(img, pos, size, reverse)
|
|
213
|
+
}, entry.time * 1000)
|
|
214
|
+
} else {
|
|
215
|
+
this.drawCanvas(img, pos, size, reverse)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
moveTo(name: string, displayedImages: any, pos: { x: number; y: number }, durning: number) {
|
|
221
|
+
return new Promise((resolve) => {
|
|
222
|
+
const target = displayedImages[name];
|
|
223
|
+
const startPos = { x: target.pos.x, y: target.pos.y };
|
|
224
|
+
const dest = { x: startPos.x + Number(pos.x), y: startPos.y + Number(pos.y) };
|
|
225
|
+
const startTime = performance.now();
|
|
226
|
+
|
|
227
|
+
const move = (currentTime:any) => {
|
|
228
|
+
const elapsedTime = (currentTime - startTime) / 1000; // 秒単位の経過時間
|
|
229
|
+
const progress = Math.min(elapsedTime / durning, 1); // 0から1の進捗
|
|
230
|
+
|
|
231
|
+
target.pos.x = startPos.x + (dest.x - startPos.x) * progress;
|
|
232
|
+
target.pos.y = startPos.y + (dest.y - startPos.y) * progress;
|
|
233
|
+
|
|
234
|
+
this.show(displayedImages);
|
|
235
|
+
|
|
236
|
+
if (progress < 1) {
|
|
237
|
+
window.requestAnimationFrame(move);
|
|
238
|
+
} else {
|
|
239
|
+
// 最終位置を正確に設定
|
|
240
|
+
target.pos.x = dest.x;
|
|
241
|
+
target.pos.y = dest.y;
|
|
242
|
+
this.show(displayedImages);
|
|
243
|
+
resolve(null);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
window.requestAnimationFrame(move);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
drawCanvas(img: ImageObject, pos: any, size: any, reverse: any) {
|
|
251
|
+
outputLog('drawCanvas', 'debug', {img, pos, size, reverse})
|
|
252
|
+
const canvas = img.draw(reverse).getCanvas()
|
|
253
|
+
// canvasから画像を取得して、this.ctxに描画
|
|
254
|
+
const imageWidth = size !== undefined ? size.width : canvas.width
|
|
255
|
+
const imageHeight = size !== undefined ? size.height : canvas.height
|
|
256
|
+
this.ctx.drawImage(
|
|
257
|
+
canvas,
|
|
258
|
+
0,
|
|
259
|
+
0,
|
|
260
|
+
canvas.width,
|
|
261
|
+
canvas.height,
|
|
262
|
+
pos.x,
|
|
263
|
+
pos.y,
|
|
264
|
+
imageWidth,
|
|
265
|
+
imageHeight,
|
|
266
|
+
) //CanvasRenderingContext2D.drawImage: Passed-in canvas is empty
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
adjustScale(targetElement: HTMLElement) {
|
|
270
|
+
// ターゲット要素の元の幅と高さ
|
|
271
|
+
const originalWidth = targetElement.scrollWidth // 例: 1280px
|
|
272
|
+
const originalHeight = targetElement.scrollHeight // 例: 720px
|
|
273
|
+
|
|
274
|
+
// ビューポートの幅と高さを取得
|
|
275
|
+
const viewportWidth = window.innerWidth
|
|
276
|
+
const viewportHeight = window.innerHeight
|
|
277
|
+
|
|
278
|
+
// 幅と高さのスケールを計算
|
|
279
|
+
const scaleX = viewportWidth / originalWidth
|
|
280
|
+
const scaleY = viewportHeight / originalHeight
|
|
281
|
+
|
|
282
|
+
// 幅と高さのうち、小さい方のスケールを選択(アスペクト比を維持)
|
|
283
|
+
const scale = Math.min(scaleX, scaleY)
|
|
284
|
+
|
|
285
|
+
// ターゲット要素にスケールを適用
|
|
286
|
+
targetElement.style.transform = `scale(${scale})`
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
setVisibility(name: string, isVisible: boolean) {
|
|
290
|
+
const target = this.screenHtml.querySelector(name) as HTMLElement
|
|
291
|
+
if (target) {
|
|
292
|
+
target.style.visibility = isVisible ? 'visible' : 'hidden'
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|