@rpg-engine/long-bow 0.1.78 → 0.1.794

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.
Files changed (57) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/store/UI.store.d.ts +4 -0
  4. package/dist/long-bow.cjs.development.js +48 -6
  5. package/dist/long-bow.cjs.development.js.map +1 -1
  6. package/dist/long-bow.cjs.production.min.js +1 -1
  7. package/dist/long-bow.cjs.production.min.js.map +1 -1
  8. package/dist/long-bow.esm.js +48 -6
  9. package/dist/long-bow.esm.js.map +1 -1
  10. package/package.json +96 -96
  11. package/src/components/Abstractions/SlotsContainer.tsx +42 -42
  12. package/src/components/Button.tsx +29 -29
  13. package/src/components/Chat/Chat.tsx +193 -193
  14. package/src/components/CheckButton.tsx +65 -65
  15. package/src/components/DraggableContainer.tsx +150 -150
  16. package/src/components/Dropdown.tsx +57 -57
  17. package/src/components/Equipment/EquipmentSet.tsx +180 -179
  18. package/src/components/Input.tsx +11 -11
  19. package/src/components/Item/Cards/ItemCard.tsx +36 -36
  20. package/src/components/Item/Inventory/ItemContainer.tsx +113 -113
  21. package/src/components/Item/Inventory/ItemSlot.tsx +158 -158
  22. package/src/components/Item/Inventory/itemContainerHelper.ts +81 -81
  23. package/src/components/ListMenu.tsx +65 -65
  24. package/src/components/Multitab/Tab.tsx +57 -57
  25. package/src/components/Multitab/TabBody.tsx +13 -13
  26. package/src/components/Multitab/TabsContainer.tsx +97 -97
  27. package/src/components/NPCDialog/NPCDialog.tsx +145 -145
  28. package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
  29. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +242 -242
  30. package/src/components/ProgressBar.tsx +91 -91
  31. package/src/components/RPGUIContainer.tsx +47 -47
  32. package/src/components/RPGUIRoot.tsx +14 -14
  33. package/src/components/RadioButton.tsx +53 -53
  34. package/src/components/RangeSlider.tsx +68 -68
  35. package/src/components/ScrollList.tsx +77 -77
  36. package/src/components/SimpleProgressBar.tsx +62 -62
  37. package/src/components/SkillProgressBar.tsx +124 -124
  38. package/src/components/SkillsContainer.tsx +235 -235
  39. package/src/components/TextArea.tsx +11 -11
  40. package/src/components/Truncate.tsx +25 -25
  41. package/src/components/shared/Column.tsx +16 -16
  42. package/src/components/shared/SpriteFromAtlas.tsx +99 -99
  43. package/src/components/shared/SpriteIcon.tsx +67 -67
  44. package/src/components/store/UI.store.ts +232 -192
  45. package/src/components/typography/DynamicText.tsx +49 -49
  46. package/src/constants/uiColors.ts +10 -10
  47. package/src/hooks/useEventListener.ts +21 -21
  48. package/src/hooks/useOutsideAlerter.ts +25 -25
  49. package/src/index.tsx +25 -25
  50. package/src/libs/StringHelpers.ts +3 -3
  51. package/src/mocks/atlas/icons/icons.json +303 -303
  52. package/src/mocks/atlas/items/items.json +5195 -5195
  53. package/src/mocks/equipmentSet.mocks.ts +347 -347
  54. package/src/mocks/itemContainer.mocks.ts +249 -249
  55. package/src/mocks/skills.mocks.ts +122 -122
  56. package/src/types/eventTypes.ts +4 -4
  57. package/src/types/index.d.ts +2 -2
@@ -1,179 +1,180 @@
1
- import {
2
- IEquipementSet,
3
- IItem,
4
- IItemContainer,
5
- ItemSlotType,
6
- ItemSocketEvents,
7
- } from '@rpg-engine/shared';
8
- import { observer } from 'mobx-react';
9
- import React, { useState } from 'react';
10
- import styled from 'styled-components';
11
- import { IPosition } from '../../types/eventTypes';
12
- import { DraggableContainer } from '../DraggableContainer';
13
- import { ItemCard } from '../Item/Cards/ItemCard';
14
- import { ItemSlot, SlotContainerType } from '../Item/Inventory/ItemSlot';
15
- import { ListMenu } from '../ListMenu';
16
- import { RPGUIContainerTypes } from '../RPGUIContainer';
17
- import { uiStore } from '../store/UI.store';
18
-
19
- export interface IEquipmentSetProps {
20
- equipmentSet: IEquipementSet;
21
- onClose?: () => void;
22
- onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
23
- onActionSelected?: (payload: any) => void;
24
- initialPosition?: { x: number; y: number };
25
- }
26
-
27
- export const EquipmentSet: React.FC<IEquipmentSetProps> = observer(
28
- ({
29
- equipmentSet,
30
- onClose,
31
- onMouseOver,
32
- onActionSelected,
33
- initialPosition = { x: 0, y: 0 },
34
- }) => {
35
- const {
36
- neck,
37
- leftHand,
38
- ring,
39
- head,
40
- armor,
41
- legs,
42
- boot,
43
- inventory,
44
- rightHand,
45
- accessory,
46
- } = equipmentSet;
47
-
48
- const equipmentData = [
49
- neck,
50
- leftHand,
51
- ring,
52
- head,
53
- armor,
54
- legs,
55
- boot,
56
- inventory,
57
- rightHand,
58
- accessory,
59
- ];
60
-
61
- const equipmentMaskSlots = [
62
- ItemSlotType.Neck,
63
- ItemSlotType.LeftHand,
64
- ItemSlotType.Ring,
65
- ItemSlotType.Head,
66
- ItemSlotType.Torso,
67
- ItemSlotType.Legs,
68
- ItemSlotType.Feet,
69
- ItemSlotType.Inventory,
70
- ItemSlotType.RightHand,
71
- ItemSlotType.Accessory,
72
- ];
73
-
74
- // we use this draggable position to offset the menu position, after the container is dragged (otherwise, it bugs!)
75
- const [draggablePosition, setDraggablePosition] = useState<IPosition>(
76
- initialPosition
77
- );
78
-
79
- const handleOnMouseHover = (
80
- event: any,
81
- slotIndex: number,
82
- item: IItem | null,
83
- x: number,
84
- y: number
85
- ) => {
86
- uiStore.handleOnMouseHover(event, slotIndex, item, x, y, onMouseOver);
87
- };
88
-
89
- const onSelected = (selectedActionId: ItemSocketEvents | string): void => {
90
- uiStore.onSelected(selectedActionId, onActionSelected);
91
- };
92
-
93
- const onRenderEquipmentSlotRange = (start: number, end: number) => {
94
- const equipmentRange = equipmentData.slice(start, end);
95
- const slotMaksRange = equipmentMaskSlots.slice(start, end);
96
-
97
- return equipmentRange.map((data, i) => {
98
- const item = data as IItem;
99
- const itemContainer =
100
- (item && (item.itemContainer as IItemContainer)) ?? null;
101
- return (
102
- <ItemSlot
103
- key={i}
104
- slotIndex={i}
105
- item={item}
106
- itemContainer={itemContainer}
107
- slotContainerType={SlotContainerType.EQUIPMENT_SET}
108
- slotSpriteMask={slotMaksRange[i]}
109
- onMouseOver={handleOnMouseHover}
110
- onMouseOut={() => {
111
- uiStore.clearItemHoverDetail();
112
- }}
113
- onClick={uiStore.handleOnItemClick}
114
- onCancelContextMenu={() => {
115
- uiStore.clearContextMenu();
116
- }}
117
- />
118
- );
119
- });
120
- };
121
-
122
- return (
123
- <DraggableContainer
124
- title={'Equipments'}
125
- type={RPGUIContainerTypes.Framed}
126
- onCloseButton={() => {
127
- if (onClose) onClose();
128
- }}
129
- width="330px"
130
- cancelDrag=".equipment-container-body"
131
- onPositionChange={({ x, y }) => {
132
- setDraggablePosition({ x, y });
133
- }}
134
- onOutsideClick={() => {
135
- uiStore.clearContextMenu();
136
- uiStore.clearItemHoverDetail();
137
- }}
138
- >
139
- <EquipmentSetContainer className="equipment-container-body">
140
- <EquipmentColumn>{onRenderEquipmentSlotRange(0, 3)}</EquipmentColumn>
141
- <EquipmentColumn>{onRenderEquipmentSlotRange(3, 7)}</EquipmentColumn>
142
- <EquipmentColumn>{onRenderEquipmentSlotRange(7, 10)}</EquipmentColumn>
143
- </EquipmentSetContainer>
144
-
145
- {uiStore.contextMenu?.visible ? (
146
- <ListMenu
147
- x={uiStore.contextMenu.posX - draggablePosition.x}
148
- y={uiStore.contextMenu.posY - draggablePosition.y}
149
- options={uiStore.contextMenu.contextActions}
150
- onSelected={onSelected}
151
- />
152
- ) : null}
153
-
154
- {uiStore.onHoverDetail?.visible ? (
155
- <ItemCard
156
- item={uiStore.onHoverDetail.item}
157
- x={uiStore.onHoverDetail.posX - draggablePosition.x}
158
- y={uiStore.onHoverDetail.posY - draggablePosition.y}
159
- />
160
- ) : null}
161
- </DraggableContainer>
162
- );
163
- }
164
- );
165
-
166
- const EquipmentSetContainer = styled.div`
167
- width: inherit;
168
- display: flex;
169
- justify-content: center;
170
- flex-wrap: wrap;
171
- flex-direction: row;
172
- `;
173
-
174
- const EquipmentColumn = styled.div`
175
- display: flex;
176
- justify-content: center;
177
- flex-wrap: wrap;
178
- flex-direction: column;
179
- `;
1
+ import {
2
+ IEquipementSet,
3
+ IItem,
4
+ IItemContainer,
5
+ ItemSlotType,
6
+ ItemSocketEvents,
7
+ } from '@rpg-engine/shared';
8
+ import { observer } from 'mobx-react';
9
+ import React, { useState } from 'react';
10
+ import styled from 'styled-components';
11
+ import { IPosition } from '../../types/eventTypes';
12
+ import { DraggableContainer } from '../DraggableContainer';
13
+ import { ItemCard } from '../Item/Cards/ItemCard';
14
+ import { ItemSlot, SlotContainerType } from '../Item/Inventory/ItemSlot';
15
+ import { ListMenu } from '../ListMenu';
16
+ import { RPGUIContainerTypes } from '../RPGUIContainer';
17
+ import { uiStore } from '../store/UI.store';
18
+
19
+ export interface IEquipmentSetProps {
20
+ equipmentSet: IEquipementSet;
21
+ onClose?: () => void;
22
+ onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
23
+ onActionSelected?: (payload: any) => void;
24
+ initialPosition?: { x: number; y: number };
25
+ }
26
+
27
+ export const EquipmentSet: React.FC<IEquipmentSetProps> = observer(
28
+ ({
29
+ equipmentSet,
30
+ onClose,
31
+ onMouseOver,
32
+ onActionSelected,
33
+ initialPosition = { x: 0, y: 0 },
34
+ }) => {
35
+ const {
36
+ neck,
37
+ leftHand,
38
+ ring,
39
+ head,
40
+ armor,
41
+ legs,
42
+ boot,
43
+ inventory,
44
+ rightHand,
45
+ accessory,
46
+ } = equipmentSet;
47
+
48
+ const equipmentData = [
49
+ neck,
50
+ leftHand,
51
+ ring,
52
+ head,
53
+ armor,
54
+ legs,
55
+ boot,
56
+ inventory,
57
+ rightHand,
58
+ accessory,
59
+ ];
60
+
61
+ const equipmentMaskSlots = [
62
+ ItemSlotType.Neck,
63
+ ItemSlotType.LeftHand,
64
+ ItemSlotType.Ring,
65
+ ItemSlotType.Head,
66
+ ItemSlotType.Torso,
67
+ ItemSlotType.Legs,
68
+ ItemSlotType.Feet,
69
+ ItemSlotType.Inventory,
70
+ ItemSlotType.RightHand,
71
+ ItemSlotType.Accessory,
72
+ ];
73
+ // we use this draggable position to offset the menu position, after the container is dragged (otherwise, it bugs!)
74
+ // uiStore.setDraggablePosition(initialPosition)
75
+ const [draggablePosition, setDraggablePosition] = useState<IPosition>(
76
+ initialPosition
77
+ );
78
+
79
+ const handleOnMouseHover = (
80
+ event: any,
81
+ slotIndex: number,
82
+ item: IItem | null,
83
+ x: number,
84
+ y: number
85
+ ) => {
86
+ uiStore.handleOnMouseHover(event, slotIndex, item, x, y, onMouseOver);
87
+ };
88
+
89
+ const onSelected = (selectedActionId: ItemSocketEvents | string): void => {
90
+ uiStore.onSelected(selectedActionId, onActionSelected);
91
+ };
92
+
93
+ const onRenderEquipmentSlotRange = (start: number, end: number) => {
94
+ const equipmentRange = equipmentData.slice(start, end);
95
+ const slotMaksRange = equipmentMaskSlots.slice(start, end);
96
+
97
+ return equipmentRange.map((data, i) => {
98
+ const item = data as IItem;
99
+ const itemContainer =
100
+ (item && (item.itemContainer as IItemContainer)) ?? null;
101
+ return (
102
+ <ItemSlot
103
+ key={i}
104
+ slotIndex={i}
105
+ item={item}
106
+ itemContainer={itemContainer}
107
+ slotContainerType={SlotContainerType.EQUIPMENT_SET}
108
+ slotSpriteMask={slotMaksRange[i]}
109
+ onMouseOver={handleOnMouseHover}
110
+ onMouseOut={() => {
111
+ uiStore.clearItemHoverDetail();
112
+ }}
113
+ onClick={uiStore.handleOnItemClick}
114
+ onCancelContextMenu={() => {
115
+ uiStore.clearContextMenu();
116
+ }}
117
+ />
118
+ );
119
+ });
120
+ };
121
+
122
+ return (
123
+ <DraggableContainer
124
+ title={'Equipments'}
125
+ type={RPGUIContainerTypes.Framed}
126
+ onCloseButton={() => {
127
+ if (onClose) onClose();
128
+ }}
129
+ width="330px"
130
+ cancelDrag=".equipment-container-body"
131
+ onPositionChange={({ x, y }) => {
132
+ setDraggablePosition({ x, y });
133
+ console.log(draggablePosition)
134
+ }}
135
+ onOutsideClick={() => {
136
+ uiStore.clearContextMenu();
137
+ uiStore.clearItemHoverDetail();
138
+ }}
139
+ >
140
+ <EquipmentSetContainer className="equipment-container-body">
141
+ <EquipmentColumn>{onRenderEquipmentSlotRange(0, 3)}</EquipmentColumn>
142
+ <EquipmentColumn>{onRenderEquipmentSlotRange(3, 7)}</EquipmentColumn>
143
+ <EquipmentColumn>{onRenderEquipmentSlotRange(7, 10)}</EquipmentColumn>
144
+ </EquipmentSetContainer>
145
+
146
+ {uiStore.contextMenu?.visible ? (
147
+ <ListMenu
148
+ x={uiStore.contextMenu.posX - uiStore.draggablePosition.x}
149
+ y={uiStore.contextMenu.posY - uiStore.draggablePosition.y}
150
+ options={uiStore.contextMenu.contextActions}
151
+ onSelected={onSelected}
152
+ />
153
+ ) : null}
154
+
155
+ {uiStore.onHoverDetail?.visible ? (
156
+ <ItemCard
157
+ item={uiStore.onHoverDetail.item}
158
+ x={uiStore.onHoverDetail.posX}
159
+ y={uiStore.onHoverDetail.posY}
160
+ />
161
+ ) : null}
162
+ </DraggableContainer>
163
+ );
164
+ }
165
+ );
166
+
167
+ const EquipmentSetContainer = styled.div`
168
+ width: inherit;
169
+ display: flex;
170
+ justify-content: center;
171
+ flex-wrap: wrap;
172
+ flex-direction: row;
173
+ `;
174
+
175
+ const EquipmentColumn = styled.div`
176
+ display: flex;
177
+ justify-content: center;
178
+ flex-wrap: wrap;
179
+ flex-direction: column;
180
+ `;
@@ -1,11 +1,11 @@
1
- import React from 'react';
2
-
3
- export interface IInputProps
4
- extends React.DetailedHTMLProps<
5
- React.InputHTMLAttributes<HTMLInputElement>,
6
- HTMLInputElement
7
- > {}
8
-
9
- export const Input: React.FC<IInputProps> = ({ ...props }) => {
10
- return <input {...props} />;
11
- };
1
+ import React from 'react';
2
+
3
+ export interface IInputProps
4
+ extends React.DetailedHTMLProps<
5
+ React.InputHTMLAttributes<HTMLInputElement>,
6
+ HTMLInputElement
7
+ > {}
8
+
9
+ export const Input: React.FC<IInputProps> = ({ ...props }) => {
10
+ return <input {...props} />;
11
+ };
@@ -1,36 +1,36 @@
1
- import { IItem } from '@rpg-engine/shared';
2
- import React from 'react';
3
- import styled from 'styled-components';
4
-
5
- interface IProps {
6
- item: IItem | null;
7
- x: number;
8
- y: number;
9
- }
10
-
11
- export const ItemCard: React.FC<IProps> = ({ item, x, y }) => {
12
- return (
13
- <Container x={x} y={y}>
14
- {item?.name}
15
- </Container>
16
- );
17
- };
18
-
19
- interface IContainerProps {
20
- x?: number;
21
- y?: number;
22
- fontSize?: number;
23
- }
24
- const Container = styled.div<IContainerProps>`
25
- position: absolute;
26
- top: ${props => props.y || 0}px;
27
- left: ${props => props.x || 0}px;
28
- font-size: 0.5rem;
29
- color: white;
30
- background-color: black;
31
- border-radius: 5px;
32
- padding: 0.5rem;
33
- min-width: 20px;
34
-
35
- opacity: 0.5;
36
- `;
1
+ import { IItem } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+
5
+ interface IProps {
6
+ item: IItem | null;
7
+ x: number;
8
+ y: number;
9
+ }
10
+
11
+ export const ItemCard: React.FC<IProps> = ({ item, x, y }) => {
12
+ return (
13
+ <Container x={x} y={y}>
14
+ {item?.name}
15
+ </Container>
16
+ );
17
+ };
18
+
19
+ interface IContainerProps {
20
+ x?: number;
21
+ y?: number;
22
+ fontSize?: number;
23
+ }
24
+ const Container = styled.div<IContainerProps>`
25
+ position: absolute;
26
+ top: ${props => props.y || 0}px;
27
+ left: ${props => props.x || 0}px;
28
+ font-size: 0.5rem;
29
+ color: white;
30
+ background-color: black;
31
+ border-radius: 5px;
32
+ padding: 0.5rem;
33
+ min-width: 20px;
34
+
35
+ opacity: 0.5;
36
+ `;