@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.
- package/LICENSE +20 -20
- package/README.md +181 -181
- package/dist/components/Button.d.ts +1 -0
- package/dist/components/Equipment/EquipmentSet.d.ts +5 -3
- package/dist/components/Item/Cards/ItemTooltip.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -6
- package/dist/components/Item/Inventory/ItemContainerTypes.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +5 -9
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -7
- package/dist/components/PropertySelect/PropertySelect.d.ts +12 -0
- package/dist/components/QuestInfo/QuestInfo.d.ts +14 -0
- package/dist/components/RelativeListMenu.d.ts +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +748 -1194
- 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 +748 -1196
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
- package/dist/stories/Button.stories.d.ts +5 -0
- package/dist/stories/Chat.stories.d.ts +5 -0
- package/dist/stories/CheckButton.stories.d.ts +5 -0
- package/dist/stories/DraggableContainer.stories.d.ts +5 -0
- package/dist/stories/Dropdown.stories.d.ts +5 -0
- package/dist/stories/EquipmentSet.stories.d.ts +5 -0
- package/dist/stories/ItemContainer.stories.d.ts +5 -0
- package/dist/stories/ListMenu.stories.d.ts +5 -0
- package/dist/stories/Multitab.stories.d.ts +6 -0
- package/dist/stories/NPCDialog.stories.d.ts +7 -0
- package/dist/stories/ProgressBar.stories.d.ts +8 -0
- package/dist/stories/PropertySelect.stories.d.ts +5 -0
- package/dist/stories/QuestInfo.stories.d.ts +5 -0
- package/dist/stories/RPGUIContainers.stories.d.ts +5 -0
- package/dist/stories/RadioButton.stories.d.ts +5 -0
- package/dist/stories/RangeSlider.stories.d.ts +5 -0
- package/dist/stories/ScrollList.stories.d.ts +5 -0
- package/dist/stories/SimpleProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillsContainer.stories.d.ts +5 -0
- package/dist/stories/Text.stories.d.ts +7 -0
- package/package.json +98 -96
- package/src/components/Abstractions/SlotsContainer.tsx +42 -42
- package/src/components/Button.tsx +30 -29
- package/src/components/Chat/Chat.tsx +193 -193
- package/src/components/CheckButton.tsx +65 -65
- package/src/components/DraggableContainer.tsx +150 -150
- package/src/components/Dropdown.tsx +57 -57
- package/src/components/Equipment/EquipmentSet.tsx +138 -180
- package/src/components/Input.tsx +11 -11
- package/src/components/Item/Cards/ItemTooltip.tsx +32 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +68 -113
- package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +212 -158
- package/src/components/Item/Inventory/itemContainerHelper.ts +146 -81
- package/src/components/ListMenu.tsx +65 -65
- package/src/components/Multitab/Tab.tsx +57 -57
- package/src/components/Multitab/TabBody.tsx +13 -13
- package/src/components/Multitab/TabsContainer.tsx +97 -97
- package/src/components/NPCDialog/NPCDialog.tsx +145 -145
- package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
- package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -242
- package/src/components/ProgressBar.tsx +91 -91
- package/src/components/PropertySelect/PropertySelect.tsx +101 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
- package/src/components/QuestInfo/QuestInfo.tsx +143 -0
- package/src/components/QuestInfo/img/default.png +0 -0
- package/src/components/RPGUIContainer.tsx +47 -47
- package/src/components/RPGUIRoot.tsx +14 -14
- package/src/components/RadioButton.tsx +53 -53
- package/src/components/RangeSlider.tsx +68 -68
- package/src/components/RelativeListMenu.tsx +83 -0
- package/src/components/ScrollList.tsx +77 -77
- package/src/components/SimpleProgressBar.tsx +62 -62
- package/src/components/SkillProgressBar.tsx +123 -124
- package/src/components/SkillsContainer.tsx +196 -235
- package/src/components/TextArea.tsx +11 -11
- package/src/components/Truncate.tsx +25 -25
- package/src/components/shared/Column.tsx +16 -16
- package/src/components/shared/SpriteFromAtlas.tsx +99 -99
- package/src/components/typography/DynamicText.tsx +49 -49
- package/src/constants/uiColors.ts +10 -10
- package/src/hooks/useEventListener.ts +21 -21
- package/src/hooks/useOutsideAlerter.ts +25 -25
- package/src/index.tsx +25 -25
- package/src/libs/StringHelpers.ts +3 -3
- package/src/mocks/atlas/icons/icons.json +735 -303
- package/src/mocks/atlas/icons/icons.png +0 -0
- package/src/mocks/atlas/items/items.json +5215 -5195
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +347 -347
- package/src/mocks/itemContainer.mocks.ts +281 -249
- package/src/mocks/skills.mocks.ts +122 -122
- package/src/stories/Button.stories.tsx +36 -0
- package/src/stories/Chat.stories.tsx +170 -0
- package/src/stories/CheckButton.stories.tsx +48 -0
- package/src/stories/DraggableContainer.stories.tsx +28 -0
- package/src/stories/Dropdown.stories.tsx +46 -0
- package/src/stories/EquipmentSet.stories.tsx +51 -0
- package/src/stories/ItemContainer.stories.tsx +51 -0
- package/src/stories/ListMenu.stories.tsx +56 -0
- package/src/stories/Multitab.stories.tsx +51 -0
- package/src/stories/NPCDialog.stories.tsx +130 -0
- package/src/stories/ProgressBar.stories.tsx +23 -0
- package/src/stories/PropertySelect.stories.tsx +41 -0
- package/src/stories/QuestInfo.stories.tsx +76 -0
- package/src/stories/RPGUIContainers.stories.tsx +42 -0
- package/src/stories/RadioButton.stories.tsx +49 -0
- package/src/stories/RangeSlider.stories.tsx +60 -0
- package/src/stories/ScrollList.stories.tsx +85 -0
- package/src/stories/SimpleProgressBar.stories.tsx +22 -0
- package/src/stories/SkillProgressBar.stories.tsx +30 -0
- package/src/stories/SkillsContainer.stories.tsx +31 -0
- package/src/stories/Text.stories.tsx +42 -0
- package/src/types/eventTypes.ts +4 -4
- package/src/types/index.d.ts +2 -2
- package/dist/components/Item/Cards/ItemCard.d.ts +0 -9
- package/dist/components/shared/SpriteIcon.d.ts +0 -9
- package/dist/components/store/UI.store.d.ts +0 -38
- package/src/components/Item/Cards/ItemCard.tsx +0 -36
- package/src/components/shared/SpriteIcon.tsx +0 -67
- package/src/components/store/UI.store.ts +0 -232
|
@@ -1,180 +1,138 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
IItem,
|
|
4
|
-
IItemContainer,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import React
|
|
10
|
-
import styled from 'styled-components';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
`;
|
package/src/components/Input.tsx
CHANGED
|
@@ -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,
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
+
`;
|