@rpg-engine/long-bow 0.1.22 → 0.1.25
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/dist/NPCDialog/NPCDialog.d.ts +5 -1
- package/dist/NPCDialog/QuestionDialog/QuestionDialog.d.ts +17 -0
- package/dist/RPGUI/RPGUIContainer.d.ts +1 -0
- package/dist/RPGUI/RPGUIRoot.d.ts +9 -0
- package/dist/RPGUI/RPGUISlider.d.ts +13 -0
- package/dist/components/ListMenu.d.ts +12 -0
- package/dist/index.d.ts +5 -1
- package/dist/long-bow.cjs.development.js +339 -19
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +336 -19
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +5 -2
- package/src/NPCDialog/NPCDialog.tsx +70 -32
- package/src/NPCDialog/QuestionDialog/QuestionDialog.tsx +240 -0
- package/src/RPGUI/RPGUIContainer.tsx +12 -2
- package/src/RPGUI/RPGUIRoot.tsx +14 -0
- package/src/RPGUI/RPGUISlider.tsx +71 -0
- package/src/components/ListMenu.tsx +58 -0
- package/src/index.tsx +5 -1
- package/src/typography/DynamicText.tsx +1 -0
- package/dist/RPGUI/RPGUI.d.ts +0 -8
- package/src/RPGUI/RPGUI.tsx +0 -11
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=e(require("styled-components"));require("rpgui/rpgui.min.css"),require("rpgui/rpgui.min.js");var r=require("uuid"),o=RPGUI,a=function(e){return t.createElement("div",{className:"rpgui-content"},e.children)},l=i.div.withConfig({displayName:"ListMenu__Container",componentId:"sc-i9097t-0"})(["display:flex;flex-direction:column;width:100%;justify-content:start;align-items:flex-start;position:absolute;top:","px;left:","px;"],(function(e){return e.y||0}),(function(e){return e.x||0})),u=function(e,n,i){void 0===i&&(i=window);var r=t.useRef();t.useEffect((function(){r.current=n}),[n]),t.useEffect((function(){var n=function(e){return r.current(e)};return i.addEventListener(e,n),function(){i.removeEventListener(e,n)}}),[e,i])},s=function(e){var n=e.width;return t.createElement(c,{width:void 0===n?"50%":n,height:e.height||"auto",className:"rpgui-container "+e.type},e.children)},c=i.div.withConfig({displayName:"RPGUIContainer__Container",componentId:"sc-3xvrxc-0"})(["height:",";width:",";display:flex;flex-wrap:wrap;"],(function(e){return e.height}),(function(e){return e.width}));const d=require("./alice.png"),p=require("./space.gif");var m,f=function(e){var i=e.text,r=e.onFinish,o=e.onStart,a=n.useState(""),l=a[0],u=a[1];return n.useEffect((function(){var e=0,n=setInterval((function(){0===e&&o&&o(),e<i.length?(u(i.substring(0,e+1)),e++):(clearInterval(n),r&&r())}),50);return function(){clearInterval(n)}}),[i]),t.createElement(x,null,l)},x=i.p.withConfig({displayName:"DynamicText__TextContainer",componentId:"sc-acj2q5-0"})(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;word-break:normal;"]),g=function(e){var i=e.onClose,r=e.onEndStep,o=e.onStartStep,a=e.text.match(new RegExp(".{1,85}","g")),l=n.useState(0),u=l[0],s=l[1],c=function(e){"Space"===e.code&&((null==a?void 0:a[u+1])?s((function(e){return e+1})):i())};return n.useEffect((function(){return document.addEventListener("keydown",c),function(){return document.removeEventListener("keydown",c)}}),[u]),t.createElement(h,null,t.createElement(f,{text:(null==a?void 0:a[u])||"",onFinish:r,onStart:o}))},h=i.div.withConfig({displayName:"NPCDialogText__Container",componentId:"sc-ahseq0-0"})([""]),w=function(e){var i=e.questions,r=e.answers,o=e.onClose,a=n.useState(i[0]),l=a[0],s=a[1],c=n.useState(!1),d=c[0],p=c[1],m=function(){if(!l.answerIds||0===l.answerIds.length)return null;var e=l.answerIds[0];return r.find((function(n){return n.id===e}))},x=n.useState(m()),g=x[0],h=x[1];n.useEffect((function(){h(m())}),[l]);var w=function(e){return e.map((function(e){return r.find((function(n){return n.id===e}))}))};return u("keydown",(function(e){switch(e.key){case"ArrowDown":var n=w(l.answerIds).findIndex((function(e){return(null==e?void 0:e.id)===g.id+1})),t=l.answerIds[n],r=w(l.answerIds).find((function(e){return(null==e?void 0:e.id)===t}));h(r||m());break;case"ArrowUp":var a=w(l.answerIds).findIndex((function(e){return(null==e?void 0:e.id)===g.id-1})),u=l.answerIds&&l.answerIds[a],c=w(l.answerIds).find((function(e){return(null==e?void 0:e.id)===u}));h(c||w(l.answerIds).pop());break;case"Enter":if(p(!1),null==g||!g.nextQuestionId)return void o();s(i.find((function(e){return e.id===g.nextQuestionId})))}})),t.createElement(v,null,t.createElement(y,null,t.createElement(f,{text:l.text,onStart:function(){return p(!1)},onFinish:function(){return p(!0)}})),d&&t.createElement(C,null,function(){var e=l.answerIds;if(!e)return null;var n=w(e);return n?n.map((function(e){var n=(null==g?void 0:g.id)===(null==e?void 0:e.id),r=n?"yellow":"white";return e?t.createElement(N,{key:"answer_"+e.id},t.createElement(I,{color:r},n?"X":null),t.createElement(E,{key:e.id,onClick:function(){return function(e){p(!1),e.nextQuestionId?s(i.find((function(n){return n.id===e.nextQuestionId}))):o()}(e)},color:r},e.text)):null})):null}()))},v=i.div.withConfig({displayName:"QuestionDialog__Container",componentId:"sc-15nvgq5-0"})(["display:flex;word-break:break-all;box-sizing:border-box;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;"]),y=i.div.withConfig({displayName:"QuestionDialog__QuestionContainer",componentId:"sc-15nvgq5-1"})(["flex:100%;width:100%;"]),C=i.div.withConfig({displayName:"QuestionDialog__AnswersContainer",componentId:"sc-15nvgq5-2"})(["flex:100%;"]),E=i.p.withConfig({displayName:"QuestionDialog__Answer",componentId:"sc-15nvgq5-3"})(["flex:auto;color:"," !important;font-size:0.65rem !important;background:inherit;border:none;"],(function(e){return e.color})),I=i.span.withConfig({displayName:"QuestionDialog__AnswerSelectedIcon",componentId:"sc-15nvgq5-4"})(["flex:5% 0 0;color:"," !important;"],(function(e){return e.color})),N=i.div.withConfig({displayName:"QuestionDialog__AnswerRow",componentId:"sc-15nvgq5-5"})(["display:flex;flex-wrap:wrap;justify-content:center;align-items:center;margin-bottom:0.5rem;height:22px;p{line-height:unset;margin-top:0;margin-bottom:0rem;}"]);(m=exports.NPCDialogType||(exports.NPCDialogType={})).TextOnly="TextOnly",m.TextAndThumbnail="TextAndThumbnail";var _,T=i.div.withConfig({displayName:"NPCDialog__Container",componentId:"sc-omm2zk-0"})(["display:flex;width:100%;height:100%;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]),S=i.div.withConfig({displayName:"NPCDialog__TextContainer",componentId:"sc-omm2zk-1"})(["flex:"," 0 0;width:355px;"],(function(e){return e.flex})),b=i.div.withConfig({displayName:"NPCDialog__ThumbnailContainer",componentId:"sc-omm2zk-2"})(["flex:30% 0 0;display:flex;justify-content:flex-end;"]),D=i.img.withConfig({displayName:"NPCDialog__NPCThumbnail",componentId:"sc-omm2zk-3"})(["image-rendering:pixelated;height:128px;width:128px;"]),P=i.img.withConfig({displayName:"NPCDialog__PressSpaceIndicator",componentId:"sc-omm2zk-4"})(["position:absolute;right:",";bottom:1rem;height:20.7px;image-rendering:-webkit-optimize-contrast;"],(function(e){return e.right}));(_=exports.SliderType||(exports.SliderType={})).Slider="rpgui-slider",_.GoldSlider="rpgui-slider golden";var k=i.input.withConfig({displayName:"RPGUISlider__Input",componentId:"sc-1sjghaz-0"})(["opacity:0;"]);exports.DynamicText=f,exports.ListMenu=function(e){var n=e.onSelected;return t.createElement(a,null,t.createElement(l,{x:e.x,y:e.y},t.createElement("ul",{className:"rpgui-list-imp",style:{overflow:"hidden"}},e.options.map((function(e){return t.createElement("li",{key:e.text,onClick:function(){n(e.id)}},e.text)})))))},exports.NPCDialog=function(e){var i=e.text,r=e.type,o=e.onClose,l=e.imagePath,u=e.isQuestionDialog,c=void 0!==u&&u,m=e.questions,f=e.answers,x=n.useState(!1),h=x[0],v=x[1];return t.createElement(a,null,t.createElement(s,{type:"framed-golden",width:c?"600px":"50%",height:"180px"},c&&m&&f?t.createElement(t.Fragment,null,t.createElement(S,{flex:r===exports.NPCDialogType.TextAndThumbnail?"70%":"100%"},t.createElement(w,{questions:m,answers:f,onClose:function(){o&&o()}})),r===exports.NPCDialogType.TextAndThumbnail&&t.createElement(b,null,t.createElement(D,{src:l||d}))):t.createElement(t.Fragment,null,t.createElement(T,null,t.createElement(S,{flex:r===exports.NPCDialogType.TextAndThumbnail?"70%":"100%"},t.createElement(g,{onStartStep:function(){return v(!1)},onEndStep:function(){return v(!0)},text:i||"No text provided.",onClose:function(){o&&o()}})),r===exports.NPCDialogType.TextAndThumbnail&&t.createElement(b,null,t.createElement(D,{src:l||d}))),h&&t.createElement(P,{right:r===exports.NPCDialogType.TextOnly?"1rem":"10.5rem",src:p}))))},exports.QuestionDialog=w,exports.RPGUIContainer=s,exports.RPGUIRoot=a,exports.RPGUISlider=function(e){var i=e.type,l=e.valueMin,s=e.valueMax,c=e.width,d=e.onChange,p=r.v4(),m=n.useState(!1),f=m[0],x=m[1];u("mouseup",(function(){f&&g(),x(!1)}));var g=function(){var e=document.getElementById("rpgui-slider-"+p),n=o.get_value(e);d(Number(n))};return t.createElement(a,null,t.createElement("div",{onMouseUp:g,onMouseDown:function(){return x(!0)}},t.createElement(k,{className:i===exports.SliderType.Slider?exports.SliderType.Slider:exports.SliderType.GoldSlider,type:"range",style:{width:c},min:l,max:s,id:"rpgui-slider-"+p})))},exports._RPGUI=o,exports.useEventListener=u;
|
|
2
2
|
//# sourceMappingURL=long-bow.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"long-bow.cjs.production.min.js","sources":["../src/RPGUI/RPGUI.tsx","../src/RPGUI/RPGUIContainer.tsx","../src/NPCDialog/img/npcDialog/npcThumbnails/alice.png","../src/NPCDialog/img/space.gif","../src/libs/StringHelpers.ts","../src/NPCDialog/NPCDialog.tsx","../src/typography/DynamicText.tsx","../src/NPCDialog/NPCDialogText.tsx"],"sourcesContent":["import React from 'react';\nimport 'rpgui/rpgui.css';\nimport 'rpgui/rpgui.js';\n\ninterface IProps {\n children: React.ReactNode;\n}\n\nexport const RPGUI: React.FC<IProps> = ({ children }) => {\n return <div className=\"rpgui-content\">{children}</div>;\n};\n","import React from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n type: 'framed' | 'framed-golden' | 'framed-golden-2' | 'framed-grey';\n children: React.ReactNode;\n width?: string;\n}\n\nexport const RPGUIContainer: React.FC<IProps> = ({\n children,\n type,\n width = '50%',\n}) => {\n return (\n <Container width={width} className={`rpgui-container ${type}`}>\n {children}\n </Container>\n );\n};\n\ninterface IContainerProps {\n width: string;\n}\n\nconst Container = styled.div<IContainerProps>`\n max-width: ${({ width }) => width};\n`;\n","const img = require('./alice.png'); export default img;","const img = require('./space.gif'); export default img;","export const chunkString = (str: string, length: number) => {\n return str.match(new RegExp('.{1,' + length + '}', 'g'));\n};\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { RPGUI } from '../RPGUI/RPGUI';\nimport { RPGUIContainer } from '../RPGUI/RPGUIContainer';\nimport aliceDefaultThumbnail from './img/npcDialog/npcThumbnails/alice.png';\nimport pressSpaceGif from './img/space.gif';\nimport { NPCDialogText } from './NPCDialogText';\nexport enum NPCDialogType {\n TextOnly = 'TextOnly',\n TextAndThumbnail = 'TextAndThumbnail',\n}\n\nexport interface INPCDialogProps {\n text: string;\n type: NPCDialogType;\n imagePath?: string;\n onClose?: () => void;\n}\n\nexport const NPCDialog: React.FC<INPCDialogProps> = ({\n text,\n type,\n onClose,\n imagePath,\n}) => {\n const [showGoNextIndicator, setShowGoNextIndicator] =\n useState<boolean>(false);\n\n return (\n <RPGUI>\n <RPGUIContainer type=\"framed-golden\">\n <Container>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <NPCDialogText\n onStartStep={() => setShowGoNextIndicator(false)}\n onEndStep={() => setShowGoNextIndicator(true)}\n text={text}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </Container>\n {showGoNextIndicator && (\n <PressSpaceIndicator\n right={type === NPCDialogType.TextOnly ? '1rem' : '10.5rem'}\n src={pressSpaceGif}\n />\n )}\n </RPGUIContainer>\n </RPGUI>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n width: 100%;\n height: 125px;\n box-sizing: border-box;\n justify-content: center;\n align-items: flex-start;\n position: relative;\n`;\n\ninterface ITextContainerProps {\n flex: string;\n}\n\nconst TextContainer = styled.div<ITextContainerProps>`\n flex: ${({ flex }) => flex} 0 0;\n width: 355px;\n`;\n\nconst ThumbnailContainer = styled.div`\n flex: 30% 0 0;\n display: flex;\n justify-content: flex-end;\n`;\n\nconst NPCThumbnail = styled.img`\n image-rendering: pixelated;\n height: 128px;\n width: 128px;\n`;\n\ninterface IPressSpaceIndicatorProps {\n right: string;\n}\n\nconst PressSpaceIndicator = styled.img<IPressSpaceIndicatorProps>`\n position: absolute;\n right: ${({ right }) => right};\n bottom: 1rem;\n height: 20.7px;\n image-rendering: -webkit-optimize-contrast;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n text: string;\n onFinish?: () => void;\n onStart?: () => void;\n}\n\nexport const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {\n const [textState, setTextState] = useState<string>('');\n\n useEffect(() => {\n let i = 0;\n const interval = setInterval(() => {\n // on every interval, show one more character\n\n if (i === 0) {\n if (onStart) {\n onStart();\n }\n }\n\n if (i < text.length) {\n setTextState(text.substring(0, i + 1));\n i++;\n } else {\n clearInterval(interval);\n if (onFinish) {\n onFinish();\n }\n }\n }, 50);\n\n return () => {\n clearInterval(interval);\n };\n }, [text]);\n\n return <TextContainer>{textState}</TextContainer>;\n};\n\nconst TextContainer = styled.p`\n font-size: 0.7rem !important;\n color: white;\n text-shadow: 1px 1px 0px #000000;\n letter-spacing: 1.2px;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { chunkString } from '../libs/StringHelpers';\nimport { DynamicText } from '../typography/DynamicText';\n\ninterface IProps {\n text: string;\n onClose: () => void;\n onEndStep: () => void;\n onStartStep: () => void;\n}\n\nexport const NPCDialogText: React.FC<IProps> = ({\n text,\n onClose,\n onEndStep,\n onStartStep,\n}) => {\n const textChunks = chunkString(text, 85);\n\n const [chunkIndex, setChunkIndex] = useState<number>(0);\n\n const onHandleSpacePress = (event: KeyboardEvent) => {\n if (event.code === 'Space') {\n const hasNextChunk = textChunks?.[chunkIndex + 1] || false;\n\n if (hasNextChunk) {\n setChunkIndex((prev) => prev + 1);\n } else {\n // if there's no more text chunks, close the dialog\n onClose();\n }\n }\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onHandleSpacePress);\n\n return () => document.removeEventListener('keydown', onHandleSpacePress);\n }, [chunkIndex]);\n\n return (\n <Container>\n <DynamicText\n text={textChunks?.[chunkIndex] || ''}\n onFinish={onEndStep}\n onStart={onStartStep}\n />\n </Container>\n );\n};\n\nconst Container = styled.div``;\n"],"names":["RPGUI","React","className","children","RPGUIContainer","width","Container","type","styled","div","img","require","NPCDialogType","DynamicText","text","onFinish","onStart","useState","textState","setTextState","useEffect","i","interval","setInterval","length","substring","clearInterval","TextContainer","p","NPCDialogText","onClose","onEndStep","onStartStep","textChunks","match","RegExp","chunkIndex","setChunkIndex","onHandleSpacePress","event","code","prev","document","addEventListener","removeEventListener","flex","ThumbnailContainer","NPCThumbnail","PressSpaceIndicator","right","imagePath","showGoNextIndicator","setShowGoNextIndicator","TextAndThumbnail","src","a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BtC,EAAOC,uFAAPD,0DAMrBuC,EAAevC,EAAOE,iFAAPF,0DAUfwC,EAAsBxC,EAAOE,wFAAPF,uGAEjB,qBAAGyC,iDAjFsC,gBAClDnC,IAAAA,KACAP,IAAAA,KACAuB,IAAAA,QACAoB,IAAAA,YAGEjC,YAAkB,GADbkC,OAAqBC,cAI1BnD,gBAACD,OACCC,gBAACG,GAAeG,KAAK,iBACnBN,gBAACK,OACCL,gBAAC0B,GACCkB,KAAMtC,IAASK,sBAAcyC,iBAAmB,MAAQ,QAExDpD,gBAAC4B,GACCG,YAAa,kBAAMoB,GAAuB,IAC1CrB,UAAW,kBAAMqB,GAAuB,IACxCtC,KAAMA,EACNgB,QAAS,WACHA,GACFA,QAKPvB,IAASK,sBAAcyC,kBACtBpD,gBAAC6C,OACC7C,gBAAC8C,GAAaO,IAAKJ,GAAaK,MAIrCJ,GACClD,gBAAC+C,GACCC,MAAO1C,IAASK,sBAAc4C,SAAW,OAAS,UAClDF,IAAKG"}
|
|
1
|
+
{"version":3,"file":"long-bow.cjs.production.min.js","sources":["../src/RPGUI/RPGUIRoot.tsx","../src/components/ListMenu.tsx","../src/hooks/useEventListener.ts","../src/RPGUI/RPGUIContainer.tsx","../src/NPCDialog/img/npcDialog/npcThumbnails/alice.png","../src/NPCDialog/img/space.gif","../src/libs/StringHelpers.ts","../src/NPCDialog/NPCDialog.tsx","../src/typography/DynamicText.tsx","../src/NPCDialog/NPCDialogText.tsx","../src/NPCDialog/QuestionDialog/QuestionDialog.tsx","../src/RPGUI/RPGUISlider.tsx"],"sourcesContent":["import React from 'react';\nimport 'rpgui/rpgui.min.css';\nimport 'rpgui/rpgui.min.js';\n\ninterface IProps {\n children: React.ReactNode;\n}\n\n//@ts-ignore\nexport const _RPGUI = RPGUI;\n\nexport const RPGUIRoot: React.FC<IProps> = ({ children }) => {\n return <div className=\"rpgui-content\">{children}</div>;\n};\n","import React from 'react';\nimport styled from 'styled-components';\nimport { RPGUIRoot } from '../RPGUI/RPGUIRoot';\n\nexport interface IListMenuProps {\n title: string;\n x: number;\n y: number;\n options: [\n {\n id: string;\n text: string;\n }\n ];\n onSelected: (selectedOptionId: string) => void;\n}\n\nexport const ListMenu: React.FC<IListMenuProps> = ({\n options,\n onSelected,\n x,\n y,\n}) => {\n return (\n <RPGUIRoot>\n <Container x={x} y={y}>\n <ul className=\"rpgui-list-imp\" style={{ overflow: 'hidden' }}>\n {options.map((params) => (\n <li\n key={params.text}\n onClick={() => {\n onSelected(params.id);\n }}\n >\n {params.text}\n </li>\n ))}\n </ul>\n </Container>\n </RPGUIRoot>\n );\n};\n\ninterface IContainerProps {\n x?: number;\n y?: number;\n}\n\nconst Container = styled.div<IContainerProps>`\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: start;\n align-items: flex-start;\n position: absolute;\n top: ${(props) => props.y || 0}px;\n left: ${(props) => props.x || 0}px;\n`;\n","import React from 'react';\n\n//@ts-ignore\nexport const useEventListener = (type, handler, el = window) => {\n const savedHandler = React.useRef();\n\n React.useEffect(() => {\n savedHandler.current = handler;\n }, [handler]);\n\n React.useEffect(() => {\n //@ts-ignore\n const listener = (e) => savedHandler.current(e);\n\n el.addEventListener(type, listener);\n\n return () => {\n el.removeEventListener(type, listener);\n };\n }, [type, el]);\n};\n","import React from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n type: 'framed' | 'framed-golden' | 'framed-golden-2' | 'framed-grey';\n children: React.ReactNode;\n width?: string;\n height?: string;\n}\n\nexport const RPGUIContainer: React.FC<IProps> = ({\n children,\n type,\n width = '50%',\n height,\n}) => {\n return (\n <Container\n width={width}\n height={height || 'auto'}\n className={`rpgui-container ${type}`}\n >\n {children}\n </Container>\n );\n};\n\ninterface IContainerProps {\n width: string;\n height: string;\n}\n\nconst Container = styled.div<IContainerProps>`\n height: ${(props) => props.height};\n width: ${({ width }) => width};\n display: flex;\n flex-wrap: wrap;\n`;\n","const img = require('./alice.png'); export default img;","const img = require('./space.gif'); export default img;","export const chunkString = (str: string, length: number) => {\n return str.match(new RegExp('.{1,' + length + '}', 'g'));\n};\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { IQuestionDialog, IQuestionDialogAnswer } from '..';\nimport { RPGUIContainer } from '../RPGUI/RPGUIContainer';\nimport { RPGUIRoot } from '../RPGUI/RPGUIRoot';\nimport aliceDefaultThumbnail from './img/npcDialog/npcThumbnails/alice.png';\nimport pressSpaceGif from './img/space.gif';\nimport { NPCDialogText } from './NPCDialogText';\nimport { QuestionDialog } from './QuestionDialog/QuestionDialog';\nexport enum NPCDialogType {\n TextOnly = 'TextOnly',\n TextAndThumbnail = 'TextAndThumbnail',\n}\n\nexport interface INPCDialogProps {\n text?: string;\n type: NPCDialogType;\n imagePath?: string;\n onClose?: () => void;\n isQuestionDialog: boolean;\n answers?: IQuestionDialogAnswer[];\n questions?: IQuestionDialog[];\n}\n\nexport const NPCDialog: React.FC<INPCDialogProps> = ({\n text,\n type,\n onClose,\n imagePath,\n isQuestionDialog = false,\n questions,\n answers,\n}) => {\n const [showGoNextIndicator, setShowGoNextIndicator] =\n useState<boolean>(false);\n\n return (\n <RPGUIRoot>\n <RPGUIContainer\n type=\"framed-golden\"\n width={isQuestionDialog ? '600px' : '50%'}\n height={'180px'}\n >\n {isQuestionDialog && questions && answers ? (\n <>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <QuestionDialog\n questions={questions}\n answers={answers}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </>\n ) : (\n <>\n <Container>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <NPCDialogText\n onStartStep={() => setShowGoNextIndicator(false)}\n onEndStep={() => setShowGoNextIndicator(true)}\n text={text || 'No text provided.'}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </Container>\n {showGoNextIndicator && (\n <PressSpaceIndicator\n right={type === NPCDialogType.TextOnly ? '1rem' : '10.5rem'}\n src={pressSpaceGif}\n />\n )}\n </>\n )}\n </RPGUIContainer>\n </RPGUIRoot>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n width: 100%;\n height: 100%;\n\n box-sizing: border-box;\n justify-content: center;\n align-items: flex-start;\n position: relative;\n`;\n\ninterface ITextContainerProps {\n flex: string;\n}\n\nconst TextContainer = styled.div<ITextContainerProps>`\n flex: ${({ flex }) => flex} 0 0;\n width: 355px;\n`;\n\nconst ThumbnailContainer = styled.div`\n flex: 30% 0 0;\n display: flex;\n justify-content: flex-end;\n`;\n\nconst NPCThumbnail = styled.img`\n image-rendering: pixelated;\n height: 128px;\n width: 128px;\n`;\n\ninterface IPressSpaceIndicatorProps {\n right: string;\n}\n\nconst PressSpaceIndicator = styled.img<IPressSpaceIndicatorProps>`\n position: absolute;\n right: ${({ right }) => right};\n bottom: 1rem;\n height: 20.7px;\n image-rendering: -webkit-optimize-contrast;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n text: string;\n onFinish?: () => void;\n onStart?: () => void;\n}\n\nexport const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {\n const [textState, setTextState] = useState<string>('');\n\n useEffect(() => {\n let i = 0;\n const interval = setInterval(() => {\n // on every interval, show one more character\n\n if (i === 0) {\n if (onStart) {\n onStart();\n }\n }\n\n if (i < text.length) {\n setTextState(text.substring(0, i + 1));\n i++;\n } else {\n clearInterval(interval);\n if (onFinish) {\n onFinish();\n }\n }\n }, 50);\n\n return () => {\n clearInterval(interval);\n };\n }, [text]);\n\n return <TextContainer>{textState}</TextContainer>;\n};\n\nconst TextContainer = styled.p`\n font-size: 0.7rem !important;\n color: white;\n text-shadow: 1px 1px 0px #000000;\n letter-spacing: 1.2px;\n word-break: normal;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { chunkString } from '../libs/StringHelpers';\nimport { DynamicText } from '../typography/DynamicText';\n\ninterface IProps {\n text: string;\n onClose: () => void;\n onEndStep: () => void;\n onStartStep: () => void;\n}\n\nexport const NPCDialogText: React.FC<IProps> = ({\n text,\n onClose,\n onEndStep,\n onStartStep,\n}) => {\n const textChunks = chunkString(text, 85);\n\n const [chunkIndex, setChunkIndex] = useState<number>(0);\n\n const onHandleSpacePress = (event: KeyboardEvent) => {\n if (event.code === 'Space') {\n const hasNextChunk = textChunks?.[chunkIndex + 1] || false;\n\n if (hasNextChunk) {\n setChunkIndex((prev) => prev + 1);\n } else {\n // if there's no more text chunks, close the dialog\n onClose();\n }\n }\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onHandleSpacePress);\n\n return () => document.removeEventListener('keydown', onHandleSpacePress);\n }, [chunkIndex]);\n\n return (\n <Container>\n <DynamicText\n text={textChunks?.[chunkIndex] || ''}\n onFinish={onEndStep}\n onStart={onStartStep}\n />\n </Container>\n );\n};\n\nconst Container = styled.div``;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { useEventListener } from '../../hooks/useEventListener';\nimport { DynamicText } from '../../typography/DynamicText';\n\nexport interface IQuestionDialogAnswer {\n id: number;\n text: string;\n nextQuestionId?: number;\n}\n\nexport interface IQuestionDialog {\n id: number;\n text: string;\n answerIds?: number[];\n}\n\nexport interface IProps {\n questions: IQuestionDialog[];\n answers: IQuestionDialogAnswer[];\n onClose: () => void;\n}\n\nexport const QuestionDialog: React.FC<IProps> = ({\n questions,\n answers,\n onClose,\n}) => {\n const [currentQuestion, setCurrentQuestion] = useState(questions[0]);\n\n const [canShowAnswers, setCanShowAnswers] = useState<boolean>(false);\n\n const onGetFirstAnswer = () => {\n if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {\n return null;\n }\n\n const firstAnswerId = currentQuestion.answerIds![0];\n\n return answers.find((answer) => answer.id === firstAnswerId);\n };\n\n const [currentAnswer, setCurrentAnswer] =\n useState<IQuestionDialogAnswer | null>(onGetFirstAnswer()!);\n\n useEffect(() => {\n setCurrentAnswer(onGetFirstAnswer()!);\n }, [currentQuestion]);\n\n const onGetAnswers = (answerIds: number[]) => {\n return answerIds.map((answerId: number) =>\n answers.find((answer) => answer.id === answerId)\n );\n };\n\n const onKeyPress = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n // select next answer, if any.\n // if no next answer, select first answer\n // const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n // (answer) => answer?.id === currentAnswer!.id + 1\n // );\n\n const nextAnswerIndex = onGetAnswers(\n currentQuestion.answerIds!\n ).findIndex((answer) => answer?.id === currentAnswer!.id + 1);\n\n const nextAnswerID = currentQuestion.answerIds![nextAnswerIndex];\n\n // console.log(nextAnswerIndex);\n\n const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n (answer) => answer?.id === nextAnswerID\n );\n\n setCurrentAnswer(nextAnswer || onGetFirstAnswer()!);\n\n break;\n case 'ArrowUp':\n // select previous answer, if any.\n // if no previous answer, select last answer\n\n const previousAnswerIndex = onGetAnswers(\n currentQuestion.answerIds!\n ).findIndex((answer) => answer?.id === currentAnswer!.id - 1);\n\n const previousAnswerID =\n currentQuestion.answerIds &&\n currentQuestion.answerIds[previousAnswerIndex];\n\n const previousAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n (answer) => answer?.id === previousAnswerID\n );\n\n if (previousAnswer) {\n setCurrentAnswer(previousAnswer);\n } else {\n setCurrentAnswer(onGetAnswers(currentQuestion.answerIds!).pop()!);\n }\n\n break;\n case 'Enter':\n setCanShowAnswers(false);\n\n if (!currentAnswer?.nextQuestionId) {\n onClose();\n return;\n } else {\n setCurrentQuestion(\n questions.find(\n (question) => question.id === currentAnswer!.nextQuestionId\n )!\n );\n }\n\n break;\n }\n };\n useEventListener('keydown', onKeyPress);\n\n const onAnswerClick = (answer: IQuestionDialogAnswer) => {\n setCanShowAnswers(false);\n if (answer.nextQuestionId) {\n // if there is a next question, go to it\n setCurrentQuestion(\n questions.find((question) => question.id === answer.nextQuestionId)!\n );\n } else {\n // else, finish dialog!\n onClose();\n }\n };\n\n const onRenderCurrentAnswers = () => {\n const answerIds = currentQuestion.answerIds;\n if (!answerIds) {\n return null;\n }\n\n const answers = onGetAnswers(answerIds);\n\n if (!answers) {\n return null;\n }\n\n return answers.map((answer) => {\n const isSelected = currentAnswer?.id === answer?.id;\n const selectedColor = isSelected ? 'yellow' : 'white';\n\n if (answer) {\n return (\n <AnswerRow key={`answer_${answer.id}`}>\n <AnswerSelectedIcon color={selectedColor}>\n {isSelected ? 'X' : null}\n </AnswerSelectedIcon>\n\n <Answer\n key={answer.id}\n onClick={() => onAnswerClick(answer)}\n color={selectedColor}\n >\n {answer.text}\n </Answer>\n </AnswerRow>\n );\n }\n\n return null;\n });\n };\n\n return (\n <Container>\n <QuestionContainer>\n <DynamicText\n text={currentQuestion.text}\n onStart={() => setCanShowAnswers(false)}\n onFinish={() => setCanShowAnswers(true)}\n />\n </QuestionContainer>\n\n {canShowAnswers && (\n <AnswersContainer>{onRenderCurrentAnswers()}</AnswersContainer>\n )}\n </Container>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n\n word-break: break-all;\n\n box-sizing: border-box;\n justify-content: flex-start;\n align-items: flex-start;\n flex-wrap: wrap;\n`;\n\nconst QuestionContainer = styled.div`\n flex: 100%;\n width: 100%;\n`;\n\nconst AnswersContainer = styled.div`\n flex: 100%;\n`;\n\ninterface IAnswerProps {\n color: string;\n}\n\nconst Answer = styled.p<IAnswerProps>`\n flex: auto;\n color: ${(props) => props.color} !important;\n font-size: 0.65rem !important;\n background: inherit;\n border: none;\n`;\n\nconst AnswerSelectedIcon = styled.span<IAnswerProps>`\n flex: 5% 0 0;\n color: ${(props) => props.color} !important;\n`;\n\nconst AnswerRow = styled.div`\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n margin-bottom: 0.5rem;\n height: 22px;\n\n p {\n line-height: unset;\n margin-top: 0;\n margin-bottom: 0rem;\n }\n`;\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useEventListener } from '../hooks/useEventListener';\nimport { RPGUIRoot, _RPGUI } from './RPGUIRoot';\n\nexport enum SliderType {\n Slider = 'rpgui-slider',\n GoldSlider = 'rpgui-slider golden',\n}\n\nexport interface ISliderProps {\n type: SliderType;\n valueMin: number;\n valueMax: number;\n width: string;\n\n onChange: (value: number) => void;\n}\n\nexport const RPGUISlider: React.FC<ISliderProps> = ({\n type,\n valueMin,\n valueMax,\n width,\n onChange,\n}) => {\n const sliderId = uuidv4();\n\n const [wasMouseDownFirst, setWasMouseDownFirst] = useState<boolean>(false);\n\n useEventListener('mouseup', () => {\n if (wasMouseDownFirst) {\n onHandleMouseUp();\n }\n setWasMouseDownFirst(false);\n });\n\n const onHandleMouseUp = () => {\n const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);\n const value = _RPGUI.get_value(rpguiSlider);\n\n onChange(Number(value));\n };\n\n return (\n <RPGUIRoot>\n <div\n onMouseUp={onHandleMouseUp}\n onMouseDown={() => setWasMouseDownFirst(true)}\n >\n <Input\n className={\n type === SliderType.Slider\n ? SliderType.Slider\n : SliderType.GoldSlider\n }\n type=\"range\"\n style={{ width: width }}\n min={valueMin}\n max={valueMax}\n id={`rpgui-slider-${sliderId}`}\n />\n </div>\n </RPGUIRoot>\n );\n};\n\nconst Input = styled.input`\n opacity: 0;\n`;\n"],"names":["_RPGUI","RPGUI","RPGUIRoot","React","className","children","Container","styled","div","props","y","x","useEventListener","type","handler","el","window","savedHandler","useRef","useEffect","current","listener","e","addEventListener","removeEventListener","RPGUIContainer","width","height","img","require","NPCDialogType","DynamicText","text","onFinish","onStart","useState","textState","setTextState","i","interval","setInterval","length","substring","clearInterval","TextContainer","p","NPCDialogText","onClose","onEndStep","onStartStep","textChunks","match","RegExp","chunkIndex","setChunkIndex","onHandleSpacePress","event","code","prev","document","QuestionDialog","questions","answers","currentQuestion","setCurrentQuestion","canShowAnswers","setCanShowAnswers","onGetFirstAnswer","answerIds","firstAnswerId","find","answer","id","currentAnswer","setCurrentAnswer","onGetAnswers","map","answerId","key","nextAnswerIndex","findIndex","nextAnswerID","nextAnswer","previousAnswerIndex","previousAnswerID","previousAnswer","pop","nextQuestionId","question","QuestionContainer","AnswersContainer","isSelected","selectedColor","AnswerRow","AnswerSelectedIcon","color","Answer","onClick","onAnswerClick","onRenderCurrentAnswers","span","SliderType","flex","ThumbnailContainer","NPCThumbnail","PressSpaceIndicator","right","Input","input","onSelected","style","overflow","options","params","imagePath","isQuestionDialog","showGoNextIndicator","setShowGoNextIndicator","TextAndThumbnail","src","aliceDefaultThumbnail","TextOnly","pressSpaceGif","valueMin","valueMax","onChange","sliderId","uuidv4","wasMouseDownFirst","setWasMouseDownFirst","onHandleMouseUp","rpguiSlider","getElementById","value","get_value","Number","onMouseUp","onMouseDown","Slider","GoldSlider","min","max"],"mappings":"6RASaA,EAASC,MAETC,EAA8B,mBAClCC,uBAAKC,UAAU,mBADsBC,WCqCxCC,EAAYC,EAAOC,6EAAPD,yIAOT,SAACE,UAAUA,EAAMC,GAAK,KACrB,SAACD,UAAUA,EAAME,GAAK,KCrDnBC,EAAmB,SAACC,EAAMC,EAASC,YAAAA,IAAAA,EAAKC,YAC7CC,EAAed,EAAMe,SAE3Bf,EAAMgB,WAAU,WACdF,EAAaG,QAAUN,IACtB,CAACA,IAEJX,EAAMgB,WAAU,eAERE,EAAW,SAACC,UAAML,EAAaG,QAAQE,WAE7CP,EAAGQ,iBAAiBV,EAAMQ,GAEnB,WACLN,EAAGS,oBAAoBX,EAAMQ,MAE9B,CAACR,EAAME,KCTCU,EAAmC,oBAG9CC,aAIEvB,gBAACG,GACCoB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ASwF,mBAAWqC,OAChBrC,mBAAWqC,OACXrC,mBAAWsC,WAEjB9H,KAAK,QACLiG,MAAO,CAAEpF,MAAOA,GAChBkH,IAAKjB,EACLkB,IAAKjB,EACLpD,mBAAoBsD"}
|
package/dist/long-bow.esm.js
CHANGED
|
@@ -1,29 +1,88 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import 'rpgui/rpgui.css';
|
|
4
|
-
import 'rpgui/rpgui.js';
|
|
3
|
+
import 'rpgui/rpgui.min.css';
|
|
4
|
+
import 'rpgui/rpgui.min.js';
|
|
5
|
+
import { v4 } from 'uuid';
|
|
5
6
|
|
|
6
|
-
var
|
|
7
|
+
var _RPGUI = RPGUI;
|
|
8
|
+
var RPGUIRoot = function RPGUIRoot(_ref) {
|
|
7
9
|
var children = _ref.children;
|
|
8
10
|
return React.createElement("div", {
|
|
9
11
|
className: "rpgui-content"
|
|
10
12
|
}, children);
|
|
11
13
|
};
|
|
12
14
|
|
|
15
|
+
var ListMenu = function ListMenu(_ref) {
|
|
16
|
+
var options = _ref.options,
|
|
17
|
+
onSelected = _ref.onSelected,
|
|
18
|
+
x = _ref.x,
|
|
19
|
+
y = _ref.y;
|
|
20
|
+
return React.createElement(RPGUIRoot, null, React.createElement(Container, {
|
|
21
|
+
x: x,
|
|
22
|
+
y: y
|
|
23
|
+
}, React.createElement("ul", {
|
|
24
|
+
className: "rpgui-list-imp",
|
|
25
|
+
style: {
|
|
26
|
+
overflow: 'hidden'
|
|
27
|
+
}
|
|
28
|
+
}, options.map(function (params) {
|
|
29
|
+
return React.createElement("li", {
|
|
30
|
+
key: params.text,
|
|
31
|
+
onClick: function onClick() {
|
|
32
|
+
onSelected(params.id);
|
|
33
|
+
}
|
|
34
|
+
}, params.text);
|
|
35
|
+
}))));
|
|
36
|
+
};
|
|
37
|
+
var Container = /*#__PURE__*/styled.div.withConfig({
|
|
38
|
+
displayName: "ListMenu__Container",
|
|
39
|
+
componentId: "sc-i9097t-0"
|
|
40
|
+
})(["display:flex;flex-direction:column;width:100%;justify-content:start;align-items:flex-start;position:absolute;top:", "px;left:", "px;"], function (props) {
|
|
41
|
+
return props.y || 0;
|
|
42
|
+
}, function (props) {
|
|
43
|
+
return props.x || 0;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var useEventListener = function useEventListener(type, handler, el) {
|
|
47
|
+
if (el === void 0) {
|
|
48
|
+
el = window;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var savedHandler = React.useRef();
|
|
52
|
+
React.useEffect(function () {
|
|
53
|
+
savedHandler.current = handler;
|
|
54
|
+
}, [handler]);
|
|
55
|
+
React.useEffect(function () {
|
|
56
|
+
//@ts-ignore
|
|
57
|
+
var listener = function listener(e) {
|
|
58
|
+
return savedHandler.current(e);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
el.addEventListener(type, listener);
|
|
62
|
+
return function () {
|
|
63
|
+
el.removeEventListener(type, listener);
|
|
64
|
+
};
|
|
65
|
+
}, [type, el]);
|
|
66
|
+
};
|
|
67
|
+
|
|
13
68
|
var RPGUIContainer = function RPGUIContainer(_ref) {
|
|
14
69
|
var children = _ref.children,
|
|
15
70
|
type = _ref.type,
|
|
16
71
|
_ref$width = _ref.width,
|
|
17
|
-
width = _ref$width === void 0 ? '50%' : _ref$width
|
|
18
|
-
|
|
72
|
+
width = _ref$width === void 0 ? '50%' : _ref$width,
|
|
73
|
+
height = _ref.height;
|
|
74
|
+
return React.createElement(Container$1, {
|
|
19
75
|
width: width,
|
|
76
|
+
height: height || 'auto',
|
|
20
77
|
className: "rpgui-container " + type
|
|
21
78
|
}, children);
|
|
22
79
|
};
|
|
23
|
-
var Container = /*#__PURE__*/styled.div.withConfig({
|
|
80
|
+
var Container$1 = /*#__PURE__*/styled.div.withConfig({
|
|
24
81
|
displayName: "RPGUIContainer__Container",
|
|
25
82
|
componentId: "sc-3xvrxc-0"
|
|
26
|
-
})(["
|
|
83
|
+
})(["height:", ";width:", ";display:flex;flex-wrap:wrap;"], function (props) {
|
|
84
|
+
return props.height;
|
|
85
|
+
}, function (_ref2) {
|
|
27
86
|
var width = _ref2.width;
|
|
28
87
|
return width;
|
|
29
88
|
});
|
|
@@ -75,7 +134,7 @@ var DynamicText = function DynamicText(_ref) {
|
|
|
75
134
|
var TextContainer = /*#__PURE__*/styled.p.withConfig({
|
|
76
135
|
displayName: "DynamicText__TextContainer",
|
|
77
136
|
componentId: "sc-acj2q5-0"
|
|
78
|
-
})(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;"]);
|
|
137
|
+
})(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;word-break:normal;"]);
|
|
79
138
|
|
|
80
139
|
var NPCDialogText = function NPCDialogText(_ref) {
|
|
81
140
|
var text = _ref.text,
|
|
@@ -109,17 +168,201 @@ var NPCDialogText = function NPCDialogText(_ref) {
|
|
|
109
168
|
return document.removeEventListener('keydown', onHandleSpacePress);
|
|
110
169
|
};
|
|
111
170
|
}, [chunkIndex]);
|
|
112
|
-
return React.createElement(Container$
|
|
171
|
+
return React.createElement(Container$2, null, React.createElement(DynamicText, {
|
|
113
172
|
text: (textChunks == null ? void 0 : textChunks[chunkIndex]) || '',
|
|
114
173
|
onFinish: onEndStep,
|
|
115
174
|
onStart: onStartStep
|
|
116
175
|
}));
|
|
117
176
|
};
|
|
118
|
-
var Container$
|
|
177
|
+
var Container$2 = /*#__PURE__*/styled.div.withConfig({
|
|
119
178
|
displayName: "NPCDialogText__Container",
|
|
120
179
|
componentId: "sc-ahseq0-0"
|
|
121
180
|
})([""]);
|
|
122
181
|
|
|
182
|
+
var QuestionDialog = function QuestionDialog(_ref) {
|
|
183
|
+
var questions = _ref.questions,
|
|
184
|
+
answers = _ref.answers,
|
|
185
|
+
onClose = _ref.onClose;
|
|
186
|
+
|
|
187
|
+
var _useState = useState(questions[0]),
|
|
188
|
+
currentQuestion = _useState[0],
|
|
189
|
+
setCurrentQuestion = _useState[1];
|
|
190
|
+
|
|
191
|
+
var _useState2 = useState(false),
|
|
192
|
+
canShowAnswers = _useState2[0],
|
|
193
|
+
setCanShowAnswers = _useState2[1];
|
|
194
|
+
|
|
195
|
+
var onGetFirstAnswer = function onGetFirstAnswer() {
|
|
196
|
+
if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
var firstAnswerId = currentQuestion.answerIds[0];
|
|
201
|
+
return answers.find(function (answer) {
|
|
202
|
+
return answer.id === firstAnswerId;
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var _useState3 = useState(onGetFirstAnswer()),
|
|
207
|
+
currentAnswer = _useState3[0],
|
|
208
|
+
setCurrentAnswer = _useState3[1];
|
|
209
|
+
|
|
210
|
+
useEffect(function () {
|
|
211
|
+
setCurrentAnswer(onGetFirstAnswer());
|
|
212
|
+
}, [currentQuestion]);
|
|
213
|
+
|
|
214
|
+
var onGetAnswers = function onGetAnswers(answerIds) {
|
|
215
|
+
return answerIds.map(function (answerId) {
|
|
216
|
+
return answers.find(function (answer) {
|
|
217
|
+
return answer.id === answerId;
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var onKeyPress = function onKeyPress(e) {
|
|
223
|
+
switch (e.key) {
|
|
224
|
+
case 'ArrowDown':
|
|
225
|
+
// select next answer, if any.
|
|
226
|
+
// if no next answer, select first answer
|
|
227
|
+
// const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
|
|
228
|
+
// (answer) => answer?.id === currentAnswer!.id + 1
|
|
229
|
+
// );
|
|
230
|
+
var nextAnswerIndex = onGetAnswers(currentQuestion.answerIds).findIndex(function (answer) {
|
|
231
|
+
return (answer == null ? void 0 : answer.id) === currentAnswer.id + 1;
|
|
232
|
+
});
|
|
233
|
+
var nextAnswerID = currentQuestion.answerIds[nextAnswerIndex]; // console.log(nextAnswerIndex);
|
|
234
|
+
|
|
235
|
+
var nextAnswer = onGetAnswers(currentQuestion.answerIds).find(function (answer) {
|
|
236
|
+
return (answer == null ? void 0 : answer.id) === nextAnswerID;
|
|
237
|
+
});
|
|
238
|
+
setCurrentAnswer(nextAnswer || onGetFirstAnswer());
|
|
239
|
+
break;
|
|
240
|
+
|
|
241
|
+
case 'ArrowUp':
|
|
242
|
+
// select previous answer, if any.
|
|
243
|
+
// if no previous answer, select last answer
|
|
244
|
+
var previousAnswerIndex = onGetAnswers(currentQuestion.answerIds).findIndex(function (answer) {
|
|
245
|
+
return (answer == null ? void 0 : answer.id) === currentAnswer.id - 1;
|
|
246
|
+
});
|
|
247
|
+
var previousAnswerID = currentQuestion.answerIds && currentQuestion.answerIds[previousAnswerIndex];
|
|
248
|
+
var previousAnswer = onGetAnswers(currentQuestion.answerIds).find(function (answer) {
|
|
249
|
+
return (answer == null ? void 0 : answer.id) === previousAnswerID;
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (previousAnswer) {
|
|
253
|
+
setCurrentAnswer(previousAnswer);
|
|
254
|
+
} else {
|
|
255
|
+
setCurrentAnswer(onGetAnswers(currentQuestion.answerIds).pop());
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
break;
|
|
259
|
+
|
|
260
|
+
case 'Enter':
|
|
261
|
+
setCanShowAnswers(false);
|
|
262
|
+
|
|
263
|
+
if (!(currentAnswer != null && currentAnswer.nextQuestionId)) {
|
|
264
|
+
onClose();
|
|
265
|
+
return;
|
|
266
|
+
} else {
|
|
267
|
+
setCurrentQuestion(questions.find(function (question) {
|
|
268
|
+
return question.id === currentAnswer.nextQuestionId;
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
useEventListener('keydown', onKeyPress);
|
|
277
|
+
|
|
278
|
+
var onAnswerClick = function onAnswerClick(answer) {
|
|
279
|
+
setCanShowAnswers(false);
|
|
280
|
+
|
|
281
|
+
if (answer.nextQuestionId) {
|
|
282
|
+
// if there is a next question, go to it
|
|
283
|
+
setCurrentQuestion(questions.find(function (question) {
|
|
284
|
+
return question.id === answer.nextQuestionId;
|
|
285
|
+
}));
|
|
286
|
+
} else {
|
|
287
|
+
// else, finish dialog!
|
|
288
|
+
onClose();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
var onRenderCurrentAnswers = function onRenderCurrentAnswers() {
|
|
293
|
+
var answerIds = currentQuestion.answerIds;
|
|
294
|
+
|
|
295
|
+
if (!answerIds) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
var answers = onGetAnswers(answerIds);
|
|
300
|
+
|
|
301
|
+
if (!answers) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return answers.map(function (answer) {
|
|
306
|
+
var isSelected = (currentAnswer == null ? void 0 : currentAnswer.id) === (answer == null ? void 0 : answer.id);
|
|
307
|
+
var selectedColor = isSelected ? 'yellow' : 'white';
|
|
308
|
+
|
|
309
|
+
if (answer) {
|
|
310
|
+
return React.createElement(AnswerRow, {
|
|
311
|
+
key: "answer_" + answer.id
|
|
312
|
+
}, React.createElement(AnswerSelectedIcon, {
|
|
313
|
+
color: selectedColor
|
|
314
|
+
}, isSelected ? 'X' : null), React.createElement(Answer, {
|
|
315
|
+
key: answer.id,
|
|
316
|
+
onClick: function onClick() {
|
|
317
|
+
return onAnswerClick(answer);
|
|
318
|
+
},
|
|
319
|
+
color: selectedColor
|
|
320
|
+
}, answer.text));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return null;
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
return React.createElement(Container$3, null, React.createElement(QuestionContainer, null, React.createElement(DynamicText, {
|
|
328
|
+
text: currentQuestion.text,
|
|
329
|
+
onStart: function onStart() {
|
|
330
|
+
return setCanShowAnswers(false);
|
|
331
|
+
},
|
|
332
|
+
onFinish: function onFinish() {
|
|
333
|
+
return setCanShowAnswers(true);
|
|
334
|
+
}
|
|
335
|
+
})), canShowAnswers && React.createElement(AnswersContainer, null, onRenderCurrentAnswers()));
|
|
336
|
+
};
|
|
337
|
+
var Container$3 = /*#__PURE__*/styled.div.withConfig({
|
|
338
|
+
displayName: "QuestionDialog__Container",
|
|
339
|
+
componentId: "sc-15nvgq5-0"
|
|
340
|
+
})(["display:flex;word-break:break-all;box-sizing:border-box;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;"]);
|
|
341
|
+
var QuestionContainer = /*#__PURE__*/styled.div.withConfig({
|
|
342
|
+
displayName: "QuestionDialog__QuestionContainer",
|
|
343
|
+
componentId: "sc-15nvgq5-1"
|
|
344
|
+
})(["flex:100%;width:100%;"]);
|
|
345
|
+
var AnswersContainer = /*#__PURE__*/styled.div.withConfig({
|
|
346
|
+
displayName: "QuestionDialog__AnswersContainer",
|
|
347
|
+
componentId: "sc-15nvgq5-2"
|
|
348
|
+
})(["flex:100%;"]);
|
|
349
|
+
var Answer = /*#__PURE__*/styled.p.withConfig({
|
|
350
|
+
displayName: "QuestionDialog__Answer",
|
|
351
|
+
componentId: "sc-15nvgq5-3"
|
|
352
|
+
})(["flex:auto;color:", " !important;font-size:0.65rem !important;background:inherit;border:none;"], function (props) {
|
|
353
|
+
return props.color;
|
|
354
|
+
});
|
|
355
|
+
var AnswerSelectedIcon = /*#__PURE__*/styled.span.withConfig({
|
|
356
|
+
displayName: "QuestionDialog__AnswerSelectedIcon",
|
|
357
|
+
componentId: "sc-15nvgq5-4"
|
|
358
|
+
})(["flex:5% 0 0;color:", " !important;"], function (props) {
|
|
359
|
+
return props.color;
|
|
360
|
+
});
|
|
361
|
+
var AnswerRow = /*#__PURE__*/styled.div.withConfig({
|
|
362
|
+
displayName: "QuestionDialog__AnswerRow",
|
|
363
|
+
componentId: "sc-15nvgq5-5"
|
|
364
|
+
})(["display:flex;flex-wrap:wrap;justify-content:center;align-items:center;margin-bottom:0.5rem;height:22px;p{line-height:unset;margin-top:0;margin-bottom:0rem;}"]);
|
|
365
|
+
|
|
123
366
|
var NPCDialogType;
|
|
124
367
|
|
|
125
368
|
(function (NPCDialogType) {
|
|
@@ -131,15 +374,33 @@ var NPCDialog = function NPCDialog(_ref) {
|
|
|
131
374
|
var text = _ref.text,
|
|
132
375
|
type = _ref.type,
|
|
133
376
|
_onClose = _ref.onClose,
|
|
134
|
-
imagePath = _ref.imagePath
|
|
377
|
+
imagePath = _ref.imagePath,
|
|
378
|
+
_ref$isQuestionDialog = _ref.isQuestionDialog,
|
|
379
|
+
isQuestionDialog = _ref$isQuestionDialog === void 0 ? false : _ref$isQuestionDialog,
|
|
380
|
+
questions = _ref.questions,
|
|
381
|
+
answers = _ref.answers;
|
|
135
382
|
|
|
136
383
|
var _useState = useState(false),
|
|
137
384
|
showGoNextIndicator = _useState[0],
|
|
138
385
|
setShowGoNextIndicator = _useState[1];
|
|
139
386
|
|
|
140
|
-
return React.createElement(
|
|
141
|
-
type: "framed-golden"
|
|
142
|
-
|
|
387
|
+
return React.createElement(RPGUIRoot, null, React.createElement(RPGUIContainer, {
|
|
388
|
+
type: "framed-golden",
|
|
389
|
+
width: isQuestionDialog ? '600px' : '50%',
|
|
390
|
+
height: '180px'
|
|
391
|
+
}, isQuestionDialog && questions && answers ? React.createElement(React.Fragment, null, React.createElement(TextContainer$1, {
|
|
392
|
+
flex: type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'
|
|
393
|
+
}, React.createElement(QuestionDialog, {
|
|
394
|
+
questions: questions,
|
|
395
|
+
answers: answers,
|
|
396
|
+
onClose: function onClose() {
|
|
397
|
+
if (_onClose) {
|
|
398
|
+
_onClose();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
})), type === NPCDialogType.TextAndThumbnail && React.createElement(ThumbnailContainer, null, React.createElement(NPCThumbnail, {
|
|
402
|
+
src: imagePath || img
|
|
403
|
+
}))) : React.createElement(React.Fragment, null, React.createElement(Container$4, null, React.createElement(TextContainer$1, {
|
|
143
404
|
flex: type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'
|
|
144
405
|
}, React.createElement(NPCDialogText, {
|
|
145
406
|
onStartStep: function onStartStep() {
|
|
@@ -148,7 +409,7 @@ var NPCDialog = function NPCDialog(_ref) {
|
|
|
148
409
|
onEndStep: function onEndStep() {
|
|
149
410
|
return setShowGoNextIndicator(true);
|
|
150
411
|
},
|
|
151
|
-
text: text,
|
|
412
|
+
text: text || 'No text provided.',
|
|
152
413
|
onClose: function onClose() {
|
|
153
414
|
if (_onClose) {
|
|
154
415
|
_onClose();
|
|
@@ -159,12 +420,12 @@ var NPCDialog = function NPCDialog(_ref) {
|
|
|
159
420
|
}))), showGoNextIndicator && React.createElement(PressSpaceIndicator, {
|
|
160
421
|
right: type === NPCDialogType.TextOnly ? '1rem' : '10.5rem',
|
|
161
422
|
src: img$1
|
|
162
|
-
})));
|
|
423
|
+
}))));
|
|
163
424
|
};
|
|
164
|
-
var Container$
|
|
425
|
+
var Container$4 = /*#__PURE__*/styled.div.withConfig({
|
|
165
426
|
displayName: "NPCDialog__Container",
|
|
166
427
|
componentId: "sc-omm2zk-0"
|
|
167
|
-
})(["display:flex;width:100%;height:
|
|
428
|
+
})(["display:flex;width:100%;height:100%;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]);
|
|
168
429
|
var TextContainer$1 = /*#__PURE__*/styled.div.withConfig({
|
|
169
430
|
displayName: "NPCDialog__TextContainer",
|
|
170
431
|
componentId: "sc-omm2zk-1"
|
|
@@ -188,5 +449,61 @@ var PressSpaceIndicator = /*#__PURE__*/styled.img.withConfig({
|
|
|
188
449
|
return right;
|
|
189
450
|
});
|
|
190
451
|
|
|
191
|
-
|
|
452
|
+
var SliderType;
|
|
453
|
+
|
|
454
|
+
(function (SliderType) {
|
|
455
|
+
SliderType["Slider"] = "rpgui-slider";
|
|
456
|
+
SliderType["GoldSlider"] = "rpgui-slider golden";
|
|
457
|
+
})(SliderType || (SliderType = {}));
|
|
458
|
+
|
|
459
|
+
var RPGUISlider = function RPGUISlider(_ref) {
|
|
460
|
+
var type = _ref.type,
|
|
461
|
+
valueMin = _ref.valueMin,
|
|
462
|
+
valueMax = _ref.valueMax,
|
|
463
|
+
width = _ref.width,
|
|
464
|
+
onChange = _ref.onChange;
|
|
465
|
+
var sliderId = v4();
|
|
466
|
+
|
|
467
|
+
var _useState = useState(false),
|
|
468
|
+
wasMouseDownFirst = _useState[0],
|
|
469
|
+
setWasMouseDownFirst = _useState[1];
|
|
470
|
+
|
|
471
|
+
useEventListener('mouseup', function () {
|
|
472
|
+
if (wasMouseDownFirst) {
|
|
473
|
+
onHandleMouseUp();
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
setWasMouseDownFirst(false);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
var onHandleMouseUp = function onHandleMouseUp() {
|
|
480
|
+
var rpguiSlider = document.getElementById("rpgui-slider-" + sliderId);
|
|
481
|
+
|
|
482
|
+
var value = _RPGUI.get_value(rpguiSlider);
|
|
483
|
+
|
|
484
|
+
onChange(Number(value));
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
return React.createElement(RPGUIRoot, null, React.createElement("div", {
|
|
488
|
+
onMouseUp: onHandleMouseUp,
|
|
489
|
+
onMouseDown: function onMouseDown() {
|
|
490
|
+
return setWasMouseDownFirst(true);
|
|
491
|
+
}
|
|
492
|
+
}, React.createElement(Input, {
|
|
493
|
+
className: type === SliderType.Slider ? SliderType.Slider : SliderType.GoldSlider,
|
|
494
|
+
type: "range",
|
|
495
|
+
style: {
|
|
496
|
+
width: width
|
|
497
|
+
},
|
|
498
|
+
min: valueMin,
|
|
499
|
+
max: valueMax,
|
|
500
|
+
id: "rpgui-slider-" + sliderId
|
|
501
|
+
})));
|
|
502
|
+
};
|
|
503
|
+
var Input = /*#__PURE__*/styled.input.withConfig({
|
|
504
|
+
displayName: "RPGUISlider__Input",
|
|
505
|
+
componentId: "sc-1sjghaz-0"
|
|
506
|
+
})(["opacity:0;"]);
|
|
507
|
+
|
|
508
|
+
export { DynamicText, ListMenu, NPCDialog, NPCDialogType, QuestionDialog, RPGUIContainer, RPGUIRoot, RPGUISlider, SliderType, _RPGUI, useEventListener };
|
|
192
509
|
//# sourceMappingURL=long-bow.esm.js.map
|