@rpg-engine/long-bow 0.1.21 → 0.1.24

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.
@@ -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 t=require("react"),n=e(t),i=e(require("styled-components"));require("rpgui/rpgui.css"),require("rpgui/rpgui.js");var o=function(e){return n.createElement("div",{className:"rpgui-content"},e.children)},r=function(e){var t=e.width;return n.createElement(a,{width:void 0===t?"50%":t,className:"rpgui-container "+e.type},e.children)},a=i.div.withConfig({displayName:"RPGUIContainer__Container",componentId:"sc-3xvrxc-0"})(["max-width:",";"],(function(e){return e.width}));const l=require("./alice.png"),c=require("./space.gif");var s,u=function(e){var i=e.text,o=e.onFinish,r=e.onStart,a=t.useState(""),l=a[0],c=a[1];return t.useEffect((function(){var e=0,t=setInterval((function(){0===e&&r&&r(),e<i.length?(c(i.substring(0,e+1)),e++):(clearInterval(t),o&&o())}),50);return function(){clearInterval(t)}}),[i]),n.createElement(p,null,l)},p=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;"]),m=function(e){var i=e.onClose,o=e.onEndStep,r=e.onStartStep,a=e.text.match(new RegExp(".{1,85}","g")),l=t.useState(0),c=l[0],s=l[1],p=function(e){if("Space"===e.code){console.log("space pressed!");var t=(null==a?void 0:a[c+1])||!1;console.log(a),console.log(c),console.log(t),t?s((function(e){return e+1})):i()}};return t.useEffect((function(){return document.addEventListener("keydown",p),function(){return document.removeEventListener("keydown",p)}}),[c]),n.createElement(d,null,n.createElement(u,{text:(null==a?void 0:a[c])||"",onFinish:o,onStart:r}))},d=i.div.withConfig({displayName:"NPCDialogText__Container",componentId:"sc-ahseq0-0"})([""]);(s=exports.NPCDialogType||(exports.NPCDialogType={})).TextOnly="TextOnly",s.TextAndThumbnail="TextAndThumbnail";var g=i.div.withConfig({displayName:"NPCDialog__Container",componentId:"sc-omm2zk-0"})(["display:flex;width:100%;height:125px;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]),x=i.div.withConfig({displayName:"NPCDialog__TextContainer",componentId:"sc-omm2zk-1"})(["flex:"," 0 0;width:355px;"],(function(e){return e.flex})),f=i.div.withConfig({displayName:"NPCDialog__ThumbnailContainer",componentId:"sc-omm2zk-2"})(["flex:30% 0 0;display:flex;justify-content:flex-end;"]),h=i.img.withConfig({displayName:"NPCDialog__NPCThumbnail",componentId:"sc-omm2zk-3"})(["image-rendering:pixelated;height:128px;width:128px;"]),C=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.DynamicText=u,exports.NPCDialog=function(e){var i=e.text,a=e.type,s=e.onClose,u=e.imagePath,p=t.useState(!0),d=p[0],y=p[1],v=t.useState(!1),N=v[0],T=v[1];return d?n.createElement(o,null,n.createElement(r,{type:"framed-golden"},n.createElement(g,null,n.createElement(x,{flex:a===exports.NPCDialogType.TextAndThumbnail?"70%":"100%"},n.createElement(m,{onStartStep:function(){return T(!1)},onEndStep:function(){return T(!0)},text:i,onClose:function(){s&&(s(),y(!1))}})),a===exports.NPCDialogType.TextAndThumbnail&&n.createElement(f,null,n.createElement(h,{src:u||l}))),N&&n.createElement(C,{right:a===exports.NPCDialogType.TextOnly?"1rem":"10.5rem",src:c}))):null},exports.RPGUI=o,exports.RPGUIContainer=r;
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;"]),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(g,null,l)},g=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;"]),x=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}))},g=n.useState(m()),x=g[0],h=g[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)===x.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)===x.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==x||!x.nextQuestionId)return void o();s(i.find((function(e){return e.id===x.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==x?void 0:x.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.options,i=e.onSelected;return t.createElement(a,null,t.createElement(l,null,t.createElement("p",null,e.title,": "),t.createElement("ul",{className:"rpgui-list-imp",style:{overflow:"hidden"}},n.map((function(e){return t.createElement("li",{key:e.text,onClick:function(){i(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,g=n.useState(!1),h=g[0],v=g[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(x,{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],g=m[1];u("mouseup",(function(){f&&x(),g(!1)}));var x=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:x,onMouseDown:function(){return g(!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 [isOpen, setIsOpen] = useState<boolean>(true);\n const [showGoNextIndicator, setShowGoNextIndicator] =\n useState<boolean>(false);\n\n return isOpen ? (\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 setIsOpen(false);\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 ) : null;\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 console.log('space pressed!');\n\n const hasNextChunk = textChunks?.[chunkIndex + 1] || false;\n console.log(textChunks);\n console.log(chunkIndex);\n console.log(hasNextChunk);\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","console","log","hasNextChunk","prev","document","addEventListener","removeEventListener","flex","ThumbnailContainer","NPCThumbnail","PressSpaceIndicator","right","imagePath","isOpen","setIsOpen","showGoNextIndicator","setShowGoNextIndicator","TextAndThumbnail","src","aliceDefaultThumbnail","TextOnly","pressSpaceGif"],"mappings":"mQAQaA,EAA0B,mBAC9BC,uBAAKC,UAAU,mBADkBC,WCC7BC,EAAmC,oBAG9CC,aAGEJ,gBAACK,GAAUD,iBAHL,QAGmBH,+BAJ3BK,QADAJ,WAeIG,EAAYE,EAAOC,mFAAPD,qBACH,qBAAGH,SC1BlB,MAAMK,EAAMC,QAAQ,eCAdD,EAAMC,QAAQ,eCAb,ICOKC,ECECC,EAAgC,gBAAGC,IAAAA,KAAMC,IAAAA,SAAUC,IAAAA,UAC5BC,WAAiB,IAA5CC,OAAWC,cAElBC,aAAU,eACJC,EAAI,EACFC,EAAWC,aAAY,WAGjB,IAANF,GACEL,GACFA,IAIAK,EAAIP,EAAKU,QACXL,EAAaL,EAAKW,UAAU,EAAGJ,EAAI,IACnCA,MAEAK,cAAcJ,GACVP,GACFA,OAGH,WAEI,WACLW,cAAcJ,MAEf,CAACR,IAEGb,gBAAC0B,OAAeT,IAGnBS,EAAgBnB,EAAOoB,kFAAPpB,oGC9BTqB,EAAkC,gBAE7CC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,YAEMC,IALNnB,KHZWoB,MAAM,IAAIC,OAAO,UAAuB,QGmBflB,WAAiB,GAA9CmB,OAAYC,OAEbC,EAAqB,SAACC,MACP,UAAfA,EAAMC,KAAkB,CAC1BC,QAAQC,IAAI,sBAENC,SAAeV,SAAAA,EAAaG,EAAa,MAAM,EACrDK,QAAQC,IAAIT,GACZQ,QAAQC,IAAIN,GACZK,QAAQC,IAAIC,GAERA,EACFN,GAAc,SAACO,UAASA,EAAO,KAG/Bd,aAKNV,aAAU,kBACRyB,SAASC,iBAAiB,UAAWR,GAE9B,kBAAMO,SAASE,oBAAoB,UAAWT,MACpD,CAACF,IAGFnC,gBAACK,OACCL,gBAACY,GACCC,YAAMmB,SAAAA,EAAaG,KAAe,GAClCrB,SAAUgB,EACVf,QAASgB,MAMX1B,EAAYE,EAAOC,kFAAPD,QFlDNI,EAAAA,wBAAAA,+CAEVA,0CAwDIN,EAAYE,EAAOC,8EAAPD,kIAcZmB,EAAgBnB,EAAOC,kFAAPD,gCACZ,qBAAGwC,QAIPC,EAAqBzC,EAAOC,uFAAPD,0DAMrB0C,EAAe1C,EAAOE,iFAAPF,0DAUf2C,EAAsB3C,EAAOE,wFAAPF,uGAEjB,qBAAG4C,iDAnFsC,gBAClDtC,IAAAA,KACAP,IAAAA,KACAuB,IAAAA,QACAuB,IAAAA,YAE4BpC,YAAkB,GAAvCqC,OAAQC,SAEbtC,YAAkB,GADbuC,OAAqBC,cAGrBH,EACLrD,gBAACD,OACCC,gBAACG,GAAeG,KAAK,iBACnBN,gBAACK,OACCL,gBAAC0B,GACCqB,KAAMzC,IAASK,sBAAc8C,iBAAmB,MAAQ,QAExDzD,gBAAC4B,GACCG,YAAa,kBAAMyB,GAAuB,IAC1C1B,UAAW,kBAAM0B,GAAuB,IACxC3C,KAAMA,EACNgB,QAAS,WACHA,IACFA,IACAyB,GAAU,QAKjBhD,IAASK,sBAAc8C,kBACtBzD,gBAACgD,OACChD,gBAACiD,GAAaS,IAAKN,GAAaO,MAIrCJ,GACCvD,gBAACkD,GACCC,MAAO7C,IAASK,sBAAciD,SAAW,OAAS,UAClDF,IAAKG,MAKX"}
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 options: [\n {\n id: string;\n text: string;\n }\n ];\n onSelected: (selectedOptionId: string) => void;\n}\n\nexport const ListMenu: React.FC<IListMenuProps> = ({\n title,\n options,\n onSelected,\n}) => {\n return (\n <RPGUIRoot>\n <Container>\n <p>{title}: </p>\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\nconst Container = styled.div`\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: start;\n align-items: flex-start;\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","useEventListener","type","handler","el","window","savedHandler","useRef","useEffect","current","listener","e","addEventListener","removeEventListener","RPGUIContainer","width","height","props","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","options","onSelected","title","style","overflow","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,WC8BxCC,EAAYC,EAAOC,6EAAPD,kGCtCLE,EAAmB,SAACC,EAAMC,EAASC,YAAAA,IAAAA,EAAKC,YAC7CC,EAAeX,EAAMY,SAE3BZ,EAAMa,WAAU,WACdF,EAAaG,QAAUN,IACtB,CAACA,IAEJR,EAAMa,WAAU,eAERE,EAAW,SAACC,UAAML,EAAaG,QAAQE,WAE7CP,EAAGQ,iBAAiBV,EAAMQ,GAEnB,WACLN,E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BjI,gBAACD,OACCC,uBACEoI,UAAWN,EACXO,YAAa,kBAAMR,GAAqB,KAExC7H,gBAACsG,GACCrG,UACEM,IAASyF,mBAAWsC,OAChBtC,mBAAWsC,OACXtC,mBAAWuC,WAEjBhI,KAAK,QACLoG,MAAO,CAAEvF,MAAOA,GAChBoH,IAAKjB,EACLkB,IAAKjB,EACLrD,mBAAoBuD"}
@@ -1,29 +1,80 @@
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 RPGUI = function RPGUI(_ref) {
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 title = _ref.title,
17
+ options = _ref.options,
18
+ onSelected = _ref.onSelected;
19
+ return React.createElement(RPGUIRoot, null, React.createElement(Container, null, React.createElement("p", null, title, ": "), React.createElement("ul", {
20
+ className: "rpgui-list-imp",
21
+ style: {
22
+ overflow: 'hidden'
23
+ }
24
+ }, options.map(function (params) {
25
+ return React.createElement("li", {
26
+ key: params.text,
27
+ onClick: function onClick() {
28
+ onSelected(params.id);
29
+ }
30
+ }, params.text);
31
+ }))));
32
+ };
33
+ var Container = /*#__PURE__*/styled.div.withConfig({
34
+ displayName: "ListMenu__Container",
35
+ componentId: "sc-i9097t-0"
36
+ })(["display:flex;flex-direction:column;width:100%;justify-content:start;align-items:flex-start;"]);
37
+
38
+ var useEventListener = function useEventListener(type, handler, el) {
39
+ if (el === void 0) {
40
+ el = window;
41
+ }
42
+
43
+ var savedHandler = React.useRef();
44
+ React.useEffect(function () {
45
+ savedHandler.current = handler;
46
+ }, [handler]);
47
+ React.useEffect(function () {
48
+ //@ts-ignore
49
+ var listener = function listener(e) {
50
+ return savedHandler.current(e);
51
+ };
52
+
53
+ el.addEventListener(type, listener);
54
+ return function () {
55
+ el.removeEventListener(type, listener);
56
+ };
57
+ }, [type, el]);
58
+ };
59
+
13
60
  var RPGUIContainer = function RPGUIContainer(_ref) {
14
61
  var children = _ref.children,
15
62
  type = _ref.type,
16
63
  _ref$width = _ref.width,
17
- width = _ref$width === void 0 ? '50%' : _ref$width;
18
- return React.createElement(Container, {
64
+ width = _ref$width === void 0 ? '50%' : _ref$width,
65
+ height = _ref.height;
66
+ return React.createElement(Container$1, {
19
67
  width: width,
68
+ height: height || 'auto',
20
69
  className: "rpgui-container " + type
21
70
  }, children);
22
71
  };
23
- var Container = /*#__PURE__*/styled.div.withConfig({
72
+ var Container$1 = /*#__PURE__*/styled.div.withConfig({
24
73
  displayName: "RPGUIContainer__Container",
25
74
  componentId: "sc-3xvrxc-0"
26
- })(["max-width:", ";"], function (_ref2) {
75
+ })(["height:", ";width:", ";display:flex;flex-wrap:wrap;"], function (props) {
76
+ return props.height;
77
+ }, function (_ref2) {
27
78
  var width = _ref2.width;
28
79
  return width;
29
80
  });
@@ -75,7 +126,7 @@ var DynamicText = function DynamicText(_ref) {
75
126
  var TextContainer = /*#__PURE__*/styled.p.withConfig({
76
127
  displayName: "DynamicText__TextContainer",
77
128
  componentId: "sc-acj2q5-0"
78
- })(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;"]);
129
+ })(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;word-break:normal;"]);
79
130
 
80
131
  var NPCDialogText = function NPCDialogText(_ref) {
81
132
  var text = _ref.text,
@@ -90,11 +141,7 @@ var NPCDialogText = function NPCDialogText(_ref) {
90
141
 
91
142
  var onHandleSpacePress = function onHandleSpacePress(event) {
92
143
  if (event.code === 'Space') {
93
- console.log('space pressed!');
94
144
  var hasNextChunk = (textChunks == null ? void 0 : textChunks[chunkIndex + 1]) || false;
95
- console.log(textChunks);
96
- console.log(chunkIndex);
97
- console.log(hasNextChunk);
98
145
 
99
146
  if (hasNextChunk) {
100
147
  setChunkIndex(function (prev) {
@@ -113,17 +160,201 @@ var NPCDialogText = function NPCDialogText(_ref) {
113
160
  return document.removeEventListener('keydown', onHandleSpacePress);
114
161
  };
115
162
  }, [chunkIndex]);
116
- return React.createElement(Container$1, null, React.createElement(DynamicText, {
163
+ return React.createElement(Container$2, null, React.createElement(DynamicText, {
117
164
  text: (textChunks == null ? void 0 : textChunks[chunkIndex]) || '',
118
165
  onFinish: onEndStep,
119
166
  onStart: onStartStep
120
167
  }));
121
168
  };
122
- var Container$1 = /*#__PURE__*/styled.div.withConfig({
169
+ var Container$2 = /*#__PURE__*/styled.div.withConfig({
123
170
  displayName: "NPCDialogText__Container",
124
171
  componentId: "sc-ahseq0-0"
125
172
  })([""]);
126
173
 
174
+ var QuestionDialog = function QuestionDialog(_ref) {
175
+ var questions = _ref.questions,
176
+ answers = _ref.answers,
177
+ onClose = _ref.onClose;
178
+
179
+ var _useState = useState(questions[0]),
180
+ currentQuestion = _useState[0],
181
+ setCurrentQuestion = _useState[1];
182
+
183
+ var _useState2 = useState(false),
184
+ canShowAnswers = _useState2[0],
185
+ setCanShowAnswers = _useState2[1];
186
+
187
+ var onGetFirstAnswer = function onGetFirstAnswer() {
188
+ if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {
189
+ return null;
190
+ }
191
+
192
+ var firstAnswerId = currentQuestion.answerIds[0];
193
+ return answers.find(function (answer) {
194
+ return answer.id === firstAnswerId;
195
+ });
196
+ };
197
+
198
+ var _useState3 = useState(onGetFirstAnswer()),
199
+ currentAnswer = _useState3[0],
200
+ setCurrentAnswer = _useState3[1];
201
+
202
+ useEffect(function () {
203
+ setCurrentAnswer(onGetFirstAnswer());
204
+ }, [currentQuestion]);
205
+
206
+ var onGetAnswers = function onGetAnswers(answerIds) {
207
+ return answerIds.map(function (answerId) {
208
+ return answers.find(function (answer) {
209
+ return answer.id === answerId;
210
+ });
211
+ });
212
+ };
213
+
214
+ var onKeyPress = function onKeyPress(e) {
215
+ switch (e.key) {
216
+ case 'ArrowDown':
217
+ // select next answer, if any.
218
+ // if no next answer, select first answer
219
+ // const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
220
+ // (answer) => answer?.id === currentAnswer!.id + 1
221
+ // );
222
+ var nextAnswerIndex = onGetAnswers(currentQuestion.answerIds).findIndex(function (answer) {
223
+ return (answer == null ? void 0 : answer.id) === currentAnswer.id + 1;
224
+ });
225
+ var nextAnswerID = currentQuestion.answerIds[nextAnswerIndex]; // console.log(nextAnswerIndex);
226
+
227
+ var nextAnswer = onGetAnswers(currentQuestion.answerIds).find(function (answer) {
228
+ return (answer == null ? void 0 : answer.id) === nextAnswerID;
229
+ });
230
+ setCurrentAnswer(nextAnswer || onGetFirstAnswer());
231
+ break;
232
+
233
+ case 'ArrowUp':
234
+ // select previous answer, if any.
235
+ // if no previous answer, select last answer
236
+ var previousAnswerIndex = onGetAnswers(currentQuestion.answerIds).findIndex(function (answer) {
237
+ return (answer == null ? void 0 : answer.id) === currentAnswer.id - 1;
238
+ });
239
+ var previousAnswerID = currentQuestion.answerIds && currentQuestion.answerIds[previousAnswerIndex];
240
+ var previousAnswer = onGetAnswers(currentQuestion.answerIds).find(function (answer) {
241
+ return (answer == null ? void 0 : answer.id) === previousAnswerID;
242
+ });
243
+
244
+ if (previousAnswer) {
245
+ setCurrentAnswer(previousAnswer);
246
+ } else {
247
+ setCurrentAnswer(onGetAnswers(currentQuestion.answerIds).pop());
248
+ }
249
+
250
+ break;
251
+
252
+ case 'Enter':
253
+ setCanShowAnswers(false);
254
+
255
+ if (!(currentAnswer != null && currentAnswer.nextQuestionId)) {
256
+ onClose();
257
+ return;
258
+ } else {
259
+ setCurrentQuestion(questions.find(function (question) {
260
+ return question.id === currentAnswer.nextQuestionId;
261
+ }));
262
+ }
263
+
264
+ break;
265
+ }
266
+ };
267
+
268
+ useEventListener('keydown', onKeyPress);
269
+
270
+ var onAnswerClick = function onAnswerClick(answer) {
271
+ setCanShowAnswers(false);
272
+
273
+ if (answer.nextQuestionId) {
274
+ // if there is a next question, go to it
275
+ setCurrentQuestion(questions.find(function (question) {
276
+ return question.id === answer.nextQuestionId;
277
+ }));
278
+ } else {
279
+ // else, finish dialog!
280
+ onClose();
281
+ }
282
+ };
283
+
284
+ var onRenderCurrentAnswers = function onRenderCurrentAnswers() {
285
+ var answerIds = currentQuestion.answerIds;
286
+
287
+ if (!answerIds) {
288
+ return null;
289
+ }
290
+
291
+ var answers = onGetAnswers(answerIds);
292
+
293
+ if (!answers) {
294
+ return null;
295
+ }
296
+
297
+ return answers.map(function (answer) {
298
+ var isSelected = (currentAnswer == null ? void 0 : currentAnswer.id) === (answer == null ? void 0 : answer.id);
299
+ var selectedColor = isSelected ? 'yellow' : 'white';
300
+
301
+ if (answer) {
302
+ return React.createElement(AnswerRow, {
303
+ key: "answer_" + answer.id
304
+ }, React.createElement(AnswerSelectedIcon, {
305
+ color: selectedColor
306
+ }, isSelected ? 'X' : null), React.createElement(Answer, {
307
+ key: answer.id,
308
+ onClick: function onClick() {
309
+ return onAnswerClick(answer);
310
+ },
311
+ color: selectedColor
312
+ }, answer.text));
313
+ }
314
+
315
+ return null;
316
+ });
317
+ };
318
+
319
+ return React.createElement(Container$3, null, React.createElement(QuestionContainer, null, React.createElement(DynamicText, {
320
+ text: currentQuestion.text,
321
+ onStart: function onStart() {
322
+ return setCanShowAnswers(false);
323
+ },
324
+ onFinish: function onFinish() {
325
+ return setCanShowAnswers(true);
326
+ }
327
+ })), canShowAnswers && React.createElement(AnswersContainer, null, onRenderCurrentAnswers()));
328
+ };
329
+ var Container$3 = /*#__PURE__*/styled.div.withConfig({
330
+ displayName: "QuestionDialog__Container",
331
+ componentId: "sc-15nvgq5-0"
332
+ })(["display:flex;word-break:break-all;box-sizing:border-box;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;"]);
333
+ var QuestionContainer = /*#__PURE__*/styled.div.withConfig({
334
+ displayName: "QuestionDialog__QuestionContainer",
335
+ componentId: "sc-15nvgq5-1"
336
+ })(["flex:100%;width:100%;"]);
337
+ var AnswersContainer = /*#__PURE__*/styled.div.withConfig({
338
+ displayName: "QuestionDialog__AnswersContainer",
339
+ componentId: "sc-15nvgq5-2"
340
+ })(["flex:100%;"]);
341
+ var Answer = /*#__PURE__*/styled.p.withConfig({
342
+ displayName: "QuestionDialog__Answer",
343
+ componentId: "sc-15nvgq5-3"
344
+ })(["flex:auto;color:", " !important;font-size:0.65rem !important;background:inherit;border:none;"], function (props) {
345
+ return props.color;
346
+ });
347
+ var AnswerSelectedIcon = /*#__PURE__*/styled.span.withConfig({
348
+ displayName: "QuestionDialog__AnswerSelectedIcon",
349
+ componentId: "sc-15nvgq5-4"
350
+ })(["flex:5% 0 0;color:", " !important;"], function (props) {
351
+ return props.color;
352
+ });
353
+ var AnswerRow = /*#__PURE__*/styled.div.withConfig({
354
+ displayName: "QuestionDialog__AnswerRow",
355
+ componentId: "sc-15nvgq5-5"
356
+ })(["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;}"]);
357
+
127
358
  var NPCDialogType;
128
359
 
129
360
  (function (NPCDialogType) {
@@ -135,19 +366,33 @@ var NPCDialog = function NPCDialog(_ref) {
135
366
  var text = _ref.text,
136
367
  type = _ref.type,
137
368
  _onClose = _ref.onClose,
138
- imagePath = _ref.imagePath;
139
-
140
- var _useState = useState(true),
141
- isOpen = _useState[0],
142
- setIsOpen = _useState[1];
369
+ imagePath = _ref.imagePath,
370
+ _ref$isQuestionDialog = _ref.isQuestionDialog,
371
+ isQuestionDialog = _ref$isQuestionDialog === void 0 ? false : _ref$isQuestionDialog,
372
+ questions = _ref.questions,
373
+ answers = _ref.answers;
143
374
 
144
- var _useState2 = useState(false),
145
- showGoNextIndicator = _useState2[0],
146
- setShowGoNextIndicator = _useState2[1];
375
+ var _useState = useState(false),
376
+ showGoNextIndicator = _useState[0],
377
+ setShowGoNextIndicator = _useState[1];
147
378
 
148
- return isOpen ? React.createElement(RPGUI, null, React.createElement(RPGUIContainer, {
149
- type: "framed-golden"
150
- }, React.createElement(Container$2, null, React.createElement(TextContainer$1, {
379
+ return React.createElement(RPGUIRoot, null, React.createElement(RPGUIContainer, {
380
+ type: "framed-golden",
381
+ width: isQuestionDialog ? '600px' : '50%',
382
+ height: '180px'
383
+ }, isQuestionDialog && questions && answers ? React.createElement(React.Fragment, null, React.createElement(TextContainer$1, {
384
+ flex: type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'
385
+ }, React.createElement(QuestionDialog, {
386
+ questions: questions,
387
+ answers: answers,
388
+ onClose: function onClose() {
389
+ if (_onClose) {
390
+ _onClose();
391
+ }
392
+ }
393
+ })), type === NPCDialogType.TextAndThumbnail && React.createElement(ThumbnailContainer, null, React.createElement(NPCThumbnail, {
394
+ src: imagePath || img
395
+ }))) : React.createElement(React.Fragment, null, React.createElement(Container$4, null, React.createElement(TextContainer$1, {
151
396
  flex: type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'
152
397
  }, React.createElement(NPCDialogText, {
153
398
  onStartStep: function onStartStep() {
@@ -156,12 +401,10 @@ var NPCDialog = function NPCDialog(_ref) {
156
401
  onEndStep: function onEndStep() {
157
402
  return setShowGoNextIndicator(true);
158
403
  },
159
- text: text,
404
+ text: text || 'No text provided.',
160
405
  onClose: function onClose() {
161
406
  if (_onClose) {
162
407
  _onClose();
163
-
164
- setIsOpen(false);
165
408
  }
166
409
  }
167
410
  })), type === NPCDialogType.TextAndThumbnail && React.createElement(ThumbnailContainer, null, React.createElement(NPCThumbnail, {
@@ -169,12 +412,12 @@ var NPCDialog = function NPCDialog(_ref) {
169
412
  }))), showGoNextIndicator && React.createElement(PressSpaceIndicator, {
170
413
  right: type === NPCDialogType.TextOnly ? '1rem' : '10.5rem',
171
414
  src: img$1
172
- }))) : null;
415
+ }))));
173
416
  };
174
- var Container$2 = /*#__PURE__*/styled.div.withConfig({
417
+ var Container$4 = /*#__PURE__*/styled.div.withConfig({
175
418
  displayName: "NPCDialog__Container",
176
419
  componentId: "sc-omm2zk-0"
177
- })(["display:flex;width:100%;height:125px;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]);
420
+ })(["display:flex;width:100%;height:100%;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]);
178
421
  var TextContainer$1 = /*#__PURE__*/styled.div.withConfig({
179
422
  displayName: "NPCDialog__TextContainer",
180
423
  componentId: "sc-omm2zk-1"
@@ -198,5 +441,61 @@ var PressSpaceIndicator = /*#__PURE__*/styled.img.withConfig({
198
441
  return right;
199
442
  });
200
443
 
201
- export { DynamicText, NPCDialog, NPCDialogType, RPGUI, RPGUIContainer };
444
+ var SliderType;
445
+
446
+ (function (SliderType) {
447
+ SliderType["Slider"] = "rpgui-slider";
448
+ SliderType["GoldSlider"] = "rpgui-slider golden";
449
+ })(SliderType || (SliderType = {}));
450
+
451
+ var RPGUISlider = function RPGUISlider(_ref) {
452
+ var type = _ref.type,
453
+ valueMin = _ref.valueMin,
454
+ valueMax = _ref.valueMax,
455
+ width = _ref.width,
456
+ onChange = _ref.onChange;
457
+ var sliderId = v4();
458
+
459
+ var _useState = useState(false),
460
+ wasMouseDownFirst = _useState[0],
461
+ setWasMouseDownFirst = _useState[1];
462
+
463
+ useEventListener('mouseup', function () {
464
+ if (wasMouseDownFirst) {
465
+ onHandleMouseUp();
466
+ }
467
+
468
+ setWasMouseDownFirst(false);
469
+ });
470
+
471
+ var onHandleMouseUp = function onHandleMouseUp() {
472
+ var rpguiSlider = document.getElementById("rpgui-slider-" + sliderId);
473
+
474
+ var value = _RPGUI.get_value(rpguiSlider);
475
+
476
+ onChange(Number(value));
477
+ };
478
+
479
+ return React.createElement(RPGUIRoot, null, React.createElement("div", {
480
+ onMouseUp: onHandleMouseUp,
481
+ onMouseDown: function onMouseDown() {
482
+ return setWasMouseDownFirst(true);
483
+ }
484
+ }, React.createElement(Input, {
485
+ className: type === SliderType.Slider ? SliderType.Slider : SliderType.GoldSlider,
486
+ type: "range",
487
+ style: {
488
+ width: width
489
+ },
490
+ min: valueMin,
491
+ max: valueMax,
492
+ id: "rpgui-slider-" + sliderId
493
+ })));
494
+ };
495
+ var Input = /*#__PURE__*/styled.input.withConfig({
496
+ displayName: "RPGUISlider__Input",
497
+ componentId: "sc-1sjghaz-0"
498
+ })(["opacity:0;"]);
499
+
500
+ export { DynamicText, ListMenu, NPCDialog, NPCDialogType, QuestionDialog, RPGUIContainer, RPGUIRoot, RPGUISlider, SliderType, _RPGUI, useEventListener };
202
501
  //# sourceMappingURL=long-bow.esm.js.map