Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import React, { useContext } from 'react'; import { css } from '@emotion/react'; import { Swiper, SwiperSlide, useSwiper } from 'swiper/react'; import { Virtual } from 'swiper'; import { VisualNovelScreen as VisualNovelScreenModel } from '@uniquegood/realworld-web-interface/lib/models/game/Screen/VisualNovel'; import styled from '@emotion/styled'; import { useRunStatement } from '@lib/utils/Game/Statement'; import { GameStateContext } from '@lib/providers/GameState'; import { MAX_HEIGHT_DP, MAX_WIDTH_DP } from '@uniquegood/realworld-web-interface/lib/constants/game'; import Conversation from './Conversation'; import { calculateBackground } from './utils'; export default function VisualNovelScreen({ style, actionMap, speakerList, conversationList }: VisualNovelScreenModel) { const { render, saveOnServer } = useContext(GameStateContext); const { runStatement } = useRunStatement(); async function onVisualNovelScreenLeave() { if (actionMap.onVisualNovelScreenLeave) { const { statementList } = actionMap.onVisualNovelScreenLeave; for await (const statement of statementList) { await runStatement({ statement }); } saveOnServer(); render(); } } return ( <Swiper // TODO: Show Progressbar modules={[Virtual]} css={screenContainer} shortSwipes={false} effect="fade" noSwiping noSwipingClass="swiper-slide" speed={0} > {conversationList.map((conversation, index) => ( <SwiperSlide style={{ background: calculateBackground(style, conversation.style), backgroundSize: 'cover', backgroundRepeat: 'no-repeat', backgroundPosition: 'center' }} virtualIndex={index} > <Conversation speakerList={speakerList} conversation={conversation} index={index} isLastIndex={conversationList.length === index + 1} onVisualNovelScreenLeave={onVisualNovelScreenLeave} screenBackgroundColor={style.backgroundColor} /> </SwiperSlide> ))} </Swiper> ); } const screenContainer = css` position: absolute; top: 0; left: 0; width: ${MAX_WIDTH_DP}px; height: ${MAX_HEIGHT_DP}px; justify-content: space-between; `; |