@rpg-engine/long-bow 0.2.16 → 0.2.18
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/components/RPGUIForceRenderStart.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +88 -21
- 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 +88 -22
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Dropdown.tsx +19 -12
- package/src/components/Item/Inventory/ItemSlot.tsx +1 -1
- package/src/components/RPGUIForceRenderStart.tsx +45 -0
- package/src/components/RangeSlider.tsx +21 -27
- package/src/index.tsx +1 -0
- package/src/stories/RangeSlider.stories.tsx +3 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import { RPGUIForceRenderStart } from './RPGUIForceRenderStart';
|
|
3
4
|
import { _RPGUI } from './RPGUIRoot';
|
|
4
5
|
|
|
5
6
|
export interface IOptionsProps {
|
|
@@ -40,18 +41,24 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
40
41
|
}, [selectedValue]);
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
<RPGUIForceRenderStart
|
|
45
|
+
elementDOMId={`rpgui-dropdown-${dropdownId}`}
|
|
46
|
+
elementRenderedDOMKey='[data-rpguitype="dropdown"]'
|
|
47
|
+
RPGUICreateFunction="dropdown"
|
|
47
48
|
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
<select
|
|
50
|
+
id={`rpgui-dropdown-${dropdownId}`}
|
|
51
|
+
style={{ width: width }}
|
|
52
|
+
className="rpgui-dropdown"
|
|
53
|
+
>
|
|
54
|
+
{options.map(option => {
|
|
55
|
+
return (
|
|
56
|
+
<option key={option.id} value={option.value}>
|
|
57
|
+
{option.option}
|
|
58
|
+
</option>
|
|
59
|
+
);
|
|
60
|
+
})}
|
|
61
|
+
</select>
|
|
62
|
+
</RPGUIForceRenderStart>
|
|
56
63
|
);
|
|
57
64
|
};
|
|
@@ -26,7 +26,7 @@ const EquipmentSlotSpriteByType: any = {
|
|
|
26
26
|
Feet: 'boots/iron-boots.png',
|
|
27
27
|
Inventory: 'containers/bag.png',
|
|
28
28
|
RightHand: 'shields/plate-shield.png',
|
|
29
|
-
Accessory: '
|
|
29
|
+
Accessory: 'ranged-weapons/arrow.png',
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
interface IProps {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { _RPGUI } from './RPGUIRoot';
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
elementDOMId: string;
|
|
6
|
+
elementRenderedDOMKey: string; // this is what "proves" the element is rendered
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
RPGUICreateFunction:
|
|
9
|
+
| 'dropdown'
|
|
10
|
+
| 'slider'
|
|
11
|
+
| 'checkbox'
|
|
12
|
+
| 'draggable'
|
|
13
|
+
| 'progress'
|
|
14
|
+
| 'radio'
|
|
15
|
+
| 'list';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const RPGUIForceRenderStart: React.FC<IProps> = ({
|
|
19
|
+
children,
|
|
20
|
+
elementDOMId,
|
|
21
|
+
elementRenderedDOMKey,
|
|
22
|
+
RPGUICreateFunction,
|
|
23
|
+
}) => {
|
|
24
|
+
const [isRendered, setIsRendered] = useState<boolean>(false);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (_RPGUI) {
|
|
28
|
+
const element = document.getElementById(elementDOMId);
|
|
29
|
+
|
|
30
|
+
// create an interval to wait for the element to be rendered
|
|
31
|
+
// if it's not, trigger the rendering forcefully
|
|
32
|
+
const interval = setInterval(() => {
|
|
33
|
+
const dropdown = document.querySelector(elementRenderedDOMKey);
|
|
34
|
+
|
|
35
|
+
if (!dropdown && !isRendered) {
|
|
36
|
+
_RPGUI.__create_funcs[RPGUICreateFunction](element);
|
|
37
|
+
setIsRendered(true);
|
|
38
|
+
clearInterval(interval);
|
|
39
|
+
}
|
|
40
|
+
}, 10);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
return <>{children}</>;
|
|
45
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import {
|
|
4
|
+
import { RPGUIForceRenderStart } from './RPGUIForceRenderStart';
|
|
5
5
|
import { _RPGUI } from './RPGUIRoot';
|
|
6
6
|
|
|
7
7
|
export enum RangeSliderType {
|
|
@@ -26,15 +26,6 @@ export const RangeSlider: React.FC<IRangeSliderProps> = ({
|
|
|
26
26
|
}) => {
|
|
27
27
|
const sliderId = uuidv4();
|
|
28
28
|
|
|
29
|
-
const [wasMouseDownFirst, setWasMouseDownFirst] = useState<boolean>(false);
|
|
30
|
-
|
|
31
|
-
useEventListener('mouseup', () => {
|
|
32
|
-
if (wasMouseDownFirst) {
|
|
33
|
-
onHandleMouseUp();
|
|
34
|
-
}
|
|
35
|
-
setWasMouseDownFirst(false);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
29
|
const onHandleMouseUp = () => {
|
|
39
30
|
const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);
|
|
40
31
|
const value = _RPGUI.get_value(rpguiSlider);
|
|
@@ -43,23 +34,26 @@ export const RangeSlider: React.FC<IRangeSliderProps> = ({
|
|
|
43
34
|
};
|
|
44
35
|
|
|
45
36
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
<RPGUIForceRenderStart
|
|
38
|
+
elementDOMId={`rpgui-slider-${sliderId}`}
|
|
39
|
+
elementRenderedDOMKey="[data-rpguitype='slider']"
|
|
40
|
+
RPGUICreateFunction="slider"
|
|
49
41
|
>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
<div onMouseUp={onHandleMouseUp}>
|
|
43
|
+
<Input
|
|
44
|
+
className={
|
|
45
|
+
type === RangeSliderType.Slider
|
|
46
|
+
? RangeSliderType.Slider
|
|
47
|
+
: RangeSliderType.GoldSlider
|
|
48
|
+
}
|
|
49
|
+
type="range"
|
|
50
|
+
style={{ width: width }}
|
|
51
|
+
min={valueMin}
|
|
52
|
+
max={valueMax}
|
|
53
|
+
id={`rpgui-slider-${sliderId}`}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
</RPGUIForceRenderStart>
|
|
63
57
|
);
|
|
64
58
|
};
|
|
65
59
|
|
package/src/index.tsx
CHANGED
|
@@ -14,6 +14,7 @@ export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
|
|
|
14
14
|
export * from './components/ProgressBar';
|
|
15
15
|
export * from './components/PropertySelect/PropertySelect';
|
|
16
16
|
export * from './components/QuestInfo/QuestInfo';
|
|
17
|
+
export * from './components/QuestList';
|
|
17
18
|
export * from './components/RadioButton';
|
|
18
19
|
export * from './components/RangeSlider';
|
|
19
20
|
export * from './components/RPGUIContainer';
|