@rpg-engine/long-bow 0.1.794 → 0.2.2

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 (129) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/Button.d.ts +1 -0
  4. package/dist/components/Equipment/EquipmentSet.d.ts +5 -3
  5. package/dist/components/Item/Cards/ItemTooltip.d.ts +6 -0
  6. package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -6
  7. package/dist/components/Item/Inventory/ItemContainerTypes.d.ts +6 -0
  8. package/dist/components/Item/Inventory/ItemSlot.d.ts +5 -9
  9. package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -7
  10. package/dist/components/PropertySelect/PropertySelect.d.ts +12 -0
  11. package/dist/components/QuestInfo/QuestInfo.d.ts +14 -0
  12. package/dist/components/RelativeListMenu.d.ts +13 -0
  13. package/dist/index.d.ts +1 -1
  14. package/dist/long-bow.cjs.development.js +748 -1194
  15. package/dist/long-bow.cjs.development.js.map +1 -1
  16. package/dist/long-bow.cjs.production.min.js +1 -1
  17. package/dist/long-bow.cjs.production.min.js.map +1 -1
  18. package/dist/long-bow.esm.js +748 -1196
  19. package/dist/long-bow.esm.js.map +1 -1
  20. package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
  21. package/dist/stories/Button.stories.d.ts +5 -0
  22. package/dist/stories/Chat.stories.d.ts +5 -0
  23. package/dist/stories/CheckButton.stories.d.ts +5 -0
  24. package/dist/stories/DraggableContainer.stories.d.ts +5 -0
  25. package/dist/stories/Dropdown.stories.d.ts +5 -0
  26. package/dist/stories/EquipmentSet.stories.d.ts +5 -0
  27. package/dist/stories/ItemContainer.stories.d.ts +5 -0
  28. package/dist/stories/ListMenu.stories.d.ts +5 -0
  29. package/dist/stories/Multitab.stories.d.ts +6 -0
  30. package/dist/stories/NPCDialog.stories.d.ts +7 -0
  31. package/dist/stories/ProgressBar.stories.d.ts +8 -0
  32. package/dist/stories/PropertySelect.stories.d.ts +5 -0
  33. package/dist/stories/QuestInfo.stories.d.ts +5 -0
  34. package/dist/stories/RPGUIContainers.stories.d.ts +5 -0
  35. package/dist/stories/RadioButton.stories.d.ts +5 -0
  36. package/dist/stories/RangeSlider.stories.d.ts +5 -0
  37. package/dist/stories/ScrollList.stories.d.ts +5 -0
  38. package/dist/stories/SimpleProgressBar.stories.d.ts +5 -0
  39. package/dist/stories/SkillProgressBar.stories.d.ts +5 -0
  40. package/dist/stories/SkillsContainer.stories.d.ts +5 -0
  41. package/dist/stories/Text.stories.d.ts +7 -0
  42. package/package.json +98 -96
  43. package/src/components/Abstractions/SlotsContainer.tsx +42 -42
  44. package/src/components/Button.tsx +30 -29
  45. package/src/components/Chat/Chat.tsx +193 -193
  46. package/src/components/CheckButton.tsx +65 -65
  47. package/src/components/DraggableContainer.tsx +150 -150
  48. package/src/components/Dropdown.tsx +57 -57
  49. package/src/components/Equipment/EquipmentSet.tsx +138 -180
  50. package/src/components/Input.tsx +11 -11
  51. package/src/components/Item/Cards/ItemTooltip.tsx +32 -0
  52. package/src/components/Item/Inventory/ItemContainer.tsx +68 -113
  53. package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -0
  54. package/src/components/Item/Inventory/ItemSlot.tsx +212 -158
  55. package/src/components/Item/Inventory/itemContainerHelper.ts +146 -81
  56. package/src/components/ListMenu.tsx +65 -65
  57. package/src/components/Multitab/Tab.tsx +57 -57
  58. package/src/components/Multitab/TabBody.tsx +13 -13
  59. package/src/components/Multitab/TabsContainer.tsx +97 -97
  60. package/src/components/NPCDialog/NPCDialog.tsx +145 -145
  61. package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
  62. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -242
  63. package/src/components/ProgressBar.tsx +91 -91
  64. package/src/components/PropertySelect/PropertySelect.tsx +101 -0
  65. package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
  66. package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
  67. package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
  68. package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
  69. package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
  70. package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
  71. package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
  72. package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
  73. package/src/components/QuestInfo/QuestInfo.tsx +143 -0
  74. package/src/components/QuestInfo/img/default.png +0 -0
  75. package/src/components/RPGUIContainer.tsx +47 -47
  76. package/src/components/RPGUIRoot.tsx +14 -14
  77. package/src/components/RadioButton.tsx +53 -53
  78. package/src/components/RangeSlider.tsx +68 -68
  79. package/src/components/RelativeListMenu.tsx +83 -0
  80. package/src/components/ScrollList.tsx +77 -77
  81. package/src/components/SimpleProgressBar.tsx +62 -62
  82. package/src/components/SkillProgressBar.tsx +123 -124
  83. package/src/components/SkillsContainer.tsx +196 -235
  84. package/src/components/TextArea.tsx +11 -11
  85. package/src/components/Truncate.tsx +25 -25
  86. package/src/components/shared/Column.tsx +16 -16
  87. package/src/components/shared/SpriteFromAtlas.tsx +99 -99
  88. package/src/components/typography/DynamicText.tsx +49 -49
  89. package/src/constants/uiColors.ts +10 -10
  90. package/src/hooks/useEventListener.ts +21 -21
  91. package/src/hooks/useOutsideAlerter.ts +25 -25
  92. package/src/index.tsx +25 -25
  93. package/src/libs/StringHelpers.ts +3 -3
  94. package/src/mocks/atlas/icons/icons.json +735 -303
  95. package/src/mocks/atlas/icons/icons.png +0 -0
  96. package/src/mocks/atlas/items/items.json +5215 -5195
  97. package/src/mocks/atlas/items/items.png +0 -0
  98. package/src/mocks/equipmentSet.mocks.ts +347 -347
  99. package/src/mocks/itemContainer.mocks.ts +281 -249
  100. package/src/mocks/skills.mocks.ts +122 -122
  101. package/src/stories/Button.stories.tsx +36 -0
  102. package/src/stories/Chat.stories.tsx +170 -0
  103. package/src/stories/CheckButton.stories.tsx +48 -0
  104. package/src/stories/DraggableContainer.stories.tsx +28 -0
  105. package/src/stories/Dropdown.stories.tsx +46 -0
  106. package/src/stories/EquipmentSet.stories.tsx +51 -0
  107. package/src/stories/ItemContainer.stories.tsx +51 -0
  108. package/src/stories/ListMenu.stories.tsx +56 -0
  109. package/src/stories/Multitab.stories.tsx +51 -0
  110. package/src/stories/NPCDialog.stories.tsx +130 -0
  111. package/src/stories/ProgressBar.stories.tsx +23 -0
  112. package/src/stories/PropertySelect.stories.tsx +41 -0
  113. package/src/stories/QuestInfo.stories.tsx +76 -0
  114. package/src/stories/RPGUIContainers.stories.tsx +42 -0
  115. package/src/stories/RadioButton.stories.tsx +49 -0
  116. package/src/stories/RangeSlider.stories.tsx +60 -0
  117. package/src/stories/ScrollList.stories.tsx +85 -0
  118. package/src/stories/SimpleProgressBar.stories.tsx +22 -0
  119. package/src/stories/SkillProgressBar.stories.tsx +30 -0
  120. package/src/stories/SkillsContainer.stories.tsx +31 -0
  121. package/src/stories/Text.stories.tsx +42 -0
  122. package/src/types/eventTypes.ts +4 -4
  123. package/src/types/index.d.ts +2 -2
  124. package/dist/components/Item/Cards/ItemCard.d.ts +0 -9
  125. package/dist/components/shared/SpriteIcon.d.ts +0 -9
  126. package/dist/components/store/UI.store.d.ts +0 -38
  127. package/src/components/Item/Cards/ItemCard.tsx +0 -36
  128. package/src/components/shared/SpriteIcon.tsx +0 -67
  129. package/src/components/store/UI.store.ts +0 -232
@@ -1,180 +1,138 @@
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
+ import {
2
+ IEquipmentSet,
3
+ IItem,
4
+ IItemContainer,
5
+ ItemContainerType,
6
+ ItemSlotType,
7
+ ItemType,
8
+ } from '@rpg-engine/shared';
9
+ import React from 'react';
10
+ import styled from 'styled-components';
11
+ import { DraggableContainer } from '../DraggableContainer';
12
+ import { ItemSlot } from '../Item/Inventory/ItemSlot';
13
+ import { RPGUIContainerTypes } from '../RPGUIContainer';
14
+
15
+ export interface IEquipmentSetProps {
16
+ equipmentSet: IEquipmentSet;
17
+ onClose?: () => void;
18
+ onItemClick?: (
19
+ ItemType: ItemType,
20
+ item: IItem,
21
+ itemContainerType: ItemContainerType | null
22
+ ) => void;
23
+ onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
24
+ onSelected?: (optionId: string) => void;
25
+ initialPosition?: { x: number; y: number };
26
+ type: ItemContainerType | null;
27
+ }
28
+
29
+ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
30
+ equipmentSet,
31
+ onClose,
32
+ onMouseOver,
33
+ onSelected,
34
+ onItemClick,
35
+ }) => {
36
+ const {
37
+ neck,
38
+ leftHand,
39
+ ring,
40
+ head,
41
+ armor,
42
+ legs,
43
+ boot,
44
+ inventory,
45
+ rightHand,
46
+ accessory,
47
+ } = equipmentSet;
48
+
49
+ const equipmentData = [
50
+ neck,
51
+ leftHand,
52
+ ring,
53
+ head,
54
+ armor,
55
+ legs,
56
+ boot,
57
+ inventory,
58
+ rightHand,
59
+ accessory,
60
+ ];
61
+
62
+ const equipmentMaskSlots = [
63
+ ItemSlotType.Neck,
64
+ ItemSlotType.LeftHand,
65
+ ItemSlotType.Ring,
66
+ ItemSlotType.Head,
67
+ ItemSlotType.Torso,
68
+ ItemSlotType.Legs,
69
+ ItemSlotType.Feet,
70
+ ItemSlotType.Inventory,
71
+ ItemSlotType.RightHand,
72
+ ItemSlotType.Accessory,
73
+ ];
74
+
75
+ const onRenderEquipmentSlotRange = (start: number, end: number) => {
76
+ const equipmentRange = equipmentData.slice(start, end);
77
+ const slotMaksRange = equipmentMaskSlots.slice(start, end);
78
+
79
+ return equipmentRange.map((data, i) => {
80
+ const item = data as IItem;
81
+ const itemContainer =
82
+ (item && (item.itemContainer as IItemContainer)) ?? null;
83
+
84
+ return (
85
+ <ItemSlot
86
+ key={i}
87
+ slotIndex={i}
88
+ item={item}
89
+ itemContainer={itemContainer}
90
+ itemContainerType={ItemContainerType.Equipment}
91
+ slotSpriteMask={slotMaksRange[i]}
92
+ onMouseOver={(event, slotIndex, item) => {
93
+ if (onMouseOver) onMouseOver(event, slotIndex, item);
94
+ }}
95
+ onClick={(itemType, ContainerType) => {
96
+ if (onItemClick) onItemClick(itemType, item, ContainerType);
97
+ }}
98
+ onSelected={(optionId: string) => {
99
+ if (onSelected) onSelected(optionId);
100
+ }}
101
+ />
102
+ );
103
+ });
104
+ };
105
+
106
+ return (
107
+ <DraggableContainer
108
+ title={'Equipments'}
109
+ type={RPGUIContainerTypes.Framed}
110
+ onCloseButton={() => {
111
+ if (onClose) onClose();
112
+ }}
113
+ width="330px"
114
+ cancelDrag=".equipment-container-body"
115
+ >
116
+ <EquipmentSetContainer className="equipment-container-body">
117
+ <EquipmentColumn>{onRenderEquipmentSlotRange(0, 3)}</EquipmentColumn>
118
+ <EquipmentColumn>{onRenderEquipmentSlotRange(3, 7)}</EquipmentColumn>
119
+ <EquipmentColumn>{onRenderEquipmentSlotRange(7, 10)}</EquipmentColumn>
120
+ </EquipmentSetContainer>
121
+ </DraggableContainer>
122
+ );
123
+ };
124
+
125
+ const EquipmentSetContainer = styled.div`
126
+ width: inherit;
127
+ display: flex;
128
+ justify-content: center;
129
+ flex-wrap: wrap;
130
+ flex-direction: row;
131
+ `;
132
+
133
+ const EquipmentColumn = styled.div`
134
+ display: flex;
135
+ justify-content: center;
136
+ flex-wrap: wrap;
137
+ flex-direction: column;
138
+ `;
@@ -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
+ };
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ interface IProps {
5
+ label: string;
6
+ }
7
+
8
+ export const ItemTooltip: React.FC<IProps> = ({ label }) => {
9
+ return (
10
+ <Container>
11
+ <div>{label}</div>
12
+ </Container>
13
+ );
14
+ };
15
+
16
+ const Container = styled.div`
17
+ z-index: 2;
18
+ position: absolute;
19
+ top: 1rem;
20
+ left: 4rem;
21
+
22
+ font-size: 0.5rem;
23
+ color: white;
24
+ background-color: black;
25
+ border-radius: 5px;
26
+ padding: 0.5rem;
27
+ min-width: 20px;
28
+ width: 100%;
29
+ text-align: center;
30
+
31
+ opacity: 0.75;
32
+ `;
@@ -1,113 +1,68 @@
1
- import { IItem, IItemContainer, ItemSocketEvents } from '@rpg-engine/shared';
2
- import { observer } from 'mobx-react';
3
- import React, { useState } from 'react';
4
- import styled from 'styled-components';
5
- import { IPosition } from '../../../types/eventTypes';
6
- import { SlotsContainer } from '../../Abstractions/SlotsContainer';
7
- import { ListMenu } from '../../ListMenu';
8
- import { uiStore } from '../../store/UI.store';
9
- import { ItemCard } from '../Cards/ItemCard';
10
- import { ItemSlot, SlotContainerType } from './ItemSlot';
11
-
12
- export interface IItemContainerProps {
13
- itemContainer: IItemContainer;
14
- onClose?: () => void;
15
- onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
16
- onActionSelected?: (payload: any) => void;
17
- initialPosition?: { x: number; y: number };
18
- }
19
-
20
- export const ItemContainer: React.FC<IItemContainerProps> = observer(
21
- ({
22
- itemContainer,
23
- onClose,
24
- onMouseOver,
25
- onActionSelected,
26
- initialPosition = { x: 0, y: 0 },
27
- }) => {
28
- // we use this draggable position to offset the menu position, after the container is dragged (otherwise, it bugs!)
29
- const [draggablePosition, setDraggablePosition] = useState<IPosition>(
30
- initialPosition
31
- );
32
-
33
- const handleOnMouseHover = (
34
- event: any,
35
- slotIndex: number,
36
- item: IItem | null,
37
- x: number,
38
- y: number
39
- ) => {
40
- uiStore.handleOnMouseHover(event, slotIndex, item, x, y, onMouseOver);
41
- };
42
-
43
- const onSelected = (selectedActionId: ItemSocketEvents | string): void => {
44
- uiStore.onSelected(selectedActionId, onActionSelected);
45
- };
46
-
47
- const onRenderSlots = () => {
48
- const slots = [];
49
-
50
- for (let i = 0; i < itemContainer.slotQty; i++) {
51
- slots.push(
52
- <ItemSlot
53
- key={i}
54
- slotIndex={i}
55
- item={itemContainer.slots?.[i] || null}
56
- slotContainerType={SlotContainerType.INVENTORY}
57
- onMouseOver={handleOnMouseHover}
58
- onClick={uiStore.handleOnItemClick}
59
- onMouseOut={() => {
60
- uiStore.clearItemHoverDetail();
61
- }}
62
- onCancelContextMenu={() => {
63
- uiStore.clearContextMenu();
64
- }}
65
- />
66
- );
67
- }
68
- return slots;
69
- };
70
-
71
- return (
72
- <SlotsContainer
73
- title={itemContainer.name || 'Container'}
74
- onPositionChange={({ x, y }) => {
75
- setDraggablePosition({ x, y });
76
- }}
77
- onOutsideClick={() => {
78
- uiStore.clearContextMenu();
79
- uiStore.clearItemHoverDetail();
80
- }}
81
- onClose={onClose}
82
- >
83
- <ItemsContainer className="item-container-body">
84
- {onRenderSlots()}
85
- </ItemsContainer>
86
-
87
- {uiStore.contextMenu?.visible ? (
88
- <ListMenu
89
- x={uiStore.contextMenu.posX - draggablePosition.x}
90
- y={uiStore.contextMenu.posY - draggablePosition.y}
91
- options={uiStore.contextMenu.contextActions}
92
- onSelected={onSelected}
93
- />
94
- ) : null}
95
-
96
- {uiStore.onHoverDetail?.visible ? (
97
- <ItemCard
98
- item={uiStore.onHoverDetail.item}
99
- x={uiStore.onHoverDetail.posX - draggablePosition.x}
100
- y={uiStore.onHoverDetail.posY - draggablePosition.y}
101
- />
102
- ) : null}
103
- </SlotsContainer>
104
- );
105
- }
106
- );
107
-
108
- const ItemsContainer = styled.div`
109
- max-width: 280px;
110
- display: flex;
111
- justify-content: center;
112
- flex-wrap: wrap;
113
- `;
1
+ import { IItem, IItemContainer, ItemContainerType } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { SlotsContainer } from '../../Abstractions/SlotsContainer';
5
+
6
+ import { ItemSlot } from './ItemSlot';
7
+
8
+ export interface IItemContainerProps {
9
+ itemContainer: IItemContainer;
10
+ onClose?: () => void;
11
+ onItemClick?: (
12
+ item: IItem,
13
+ ItemType: IItem['type'],
14
+ itemContainerType: ItemContainerType | null
15
+ ) => void;
16
+ onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
17
+ onSelected?: (optionId: string, item: IItem) => void;
18
+ type: ItemContainerType;
19
+ }
20
+
21
+ export const ItemContainer: React.FC<IItemContainerProps> = ({
22
+ itemContainer,
23
+ onClose,
24
+ onMouseOver,
25
+ onSelected,
26
+ onItemClick,
27
+ type,
28
+ }) => {
29
+ const onRenderSlots = () => {
30
+ const slots = [];
31
+
32
+ for (let i = 0; i < itemContainer.slotQty; i++) {
33
+ slots.push(
34
+ <ItemSlot
35
+ key={i}
36
+ slotIndex={i}
37
+ item={itemContainer.slots?.[i] || null}
38
+ itemContainerType={type}
39
+ onMouseOver={(event, slotIndex, item) => {
40
+ if (onMouseOver) onMouseOver(event, slotIndex, item);
41
+ }}
42
+ onClick={(ItemType, ContainerType, item) => {
43
+ if (onItemClick) onItemClick(item, ItemType, ContainerType);
44
+ }}
45
+ onSelected={(optionId: string, item: IItem) => {
46
+ if (onSelected) onSelected(optionId, item);
47
+ }}
48
+ />
49
+ );
50
+ }
51
+ return slots;
52
+ };
53
+
54
+ return (
55
+ <SlotsContainer title={itemContainer.name || 'Container'} onClose={onClose}>
56
+ <ItemsContainer className="item-container-body">
57
+ {onRenderSlots()}
58
+ </ItemsContainer>
59
+ </SlotsContainer>
60
+ );
61
+ };
62
+
63
+ const ItemsContainer = styled.div`
64
+ max-width: 280px;
65
+ display: flex;
66
+ justify-content: center;
67
+ flex-wrap: wrap;
68
+ `;
@@ -0,0 +1,6 @@
1
+ export enum SlotContainerType {
2
+ INVENTORY = 'Inventory',
3
+ EQUIPMENT_SET = 'EquipmentSet',
4
+ LOOT = 'Loot',
5
+ MAP_CONTAINER = 'Map-Container',
6
+ }