@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,158 +1,212 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
) => void;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
) => void;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
1
|
+
import {
|
|
2
|
+
IItem,
|
|
3
|
+
IItemContainer,
|
|
4
|
+
ItemContainerType,
|
|
5
|
+
ItemSlotType,
|
|
6
|
+
ItemType,
|
|
7
|
+
} from '@rpg-engine/shared';
|
|
8
|
+
|
|
9
|
+
import { observer } from 'mobx-react-lite';
|
|
10
|
+
import React, { useEffect, useState } from 'react';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
import atlasJSON from '../../../mocks/atlas/items/items.json';
|
|
13
|
+
import atlasIMG from '../../../mocks/atlas/items/items.png';
|
|
14
|
+
import { RelativeListMenu } from '../../RelativeListMenu';
|
|
15
|
+
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
16
|
+
import { ItemTooltip } from '../Cards/ItemTooltip';
|
|
17
|
+
import { generateContextMenu, IContextMenuItem } from './itemContainerHelper';
|
|
18
|
+
|
|
19
|
+
const EquipmentSlotSpriteByType: any = {
|
|
20
|
+
Neck: 'accessories/corruption-necklace.png',
|
|
21
|
+
LeftHand: 'swords/broad-sword.png',
|
|
22
|
+
Ring: 'rings/iron-ring.png',
|
|
23
|
+
Head: 'helmets/viking-helmet.png',
|
|
24
|
+
Torso: 'armors/iron-armor.png',
|
|
25
|
+
Legs: 'legs/studded-legs.png',
|
|
26
|
+
Feet: 'boots/iron-boots.png',
|
|
27
|
+
Inventory: 'containers/bag.png',
|
|
28
|
+
RightHand: 'shields/plate-shield.png',
|
|
29
|
+
Accessory: 'gloves/plate-gloves.png',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
interface IProps {
|
|
33
|
+
slotIndex: number;
|
|
34
|
+
item: IItem | null;
|
|
35
|
+
itemContainer?: IItemContainer | null;
|
|
36
|
+
itemContainerType: ItemContainerType | null;
|
|
37
|
+
slotSpriteMask?: ItemSlotType | null;
|
|
38
|
+
onSelected: (selectedOption: string, item: IItem) => void;
|
|
39
|
+
onMouseOver: (
|
|
40
|
+
event: any,
|
|
41
|
+
slotIndex: number,
|
|
42
|
+
item: IItem | null,
|
|
43
|
+
x: number,
|
|
44
|
+
y: number
|
|
45
|
+
) => void;
|
|
46
|
+
onMouseOut?: () => void;
|
|
47
|
+
onClick: (
|
|
48
|
+
ItemType: ItemType,
|
|
49
|
+
itemContainerType: ItemContainerType | null,
|
|
50
|
+
item: IItem
|
|
51
|
+
) => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const ItemSlot: React.FC<IProps> = observer(
|
|
55
|
+
({
|
|
56
|
+
slotIndex,
|
|
57
|
+
item,
|
|
58
|
+
itemContainerType: containerType,
|
|
59
|
+
slotSpriteMask,
|
|
60
|
+
onMouseOver,
|
|
61
|
+
onMouseOut,
|
|
62
|
+
onClick,
|
|
63
|
+
onSelected,
|
|
64
|
+
}) => {
|
|
65
|
+
const [isTooltipVisible, setTooltipVisible] = useState(false);
|
|
66
|
+
|
|
67
|
+
const [isContextMenuVisible, setIsContextMenuVisible] = useState(false);
|
|
68
|
+
|
|
69
|
+
const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (item) {
|
|
75
|
+
setContextActions(generateContextMenu(item.type, containerType));
|
|
76
|
+
}
|
|
77
|
+
}, [item]);
|
|
78
|
+
|
|
79
|
+
const getLeftPositionValue = (quantity: number) => {
|
|
80
|
+
if (quantity > 0 && quantity < 10) return '2.5rem';
|
|
81
|
+
else if (quantity > 9 && quantity < 100) return '2.0rem';
|
|
82
|
+
else if (quantity > 99) return '1rem';
|
|
83
|
+
return '2.5rem';
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const renderItem = (itemToRender: IItem | null) => {
|
|
87
|
+
const element = [];
|
|
88
|
+
if (itemToRender?.texturePath) {
|
|
89
|
+
element.push(
|
|
90
|
+
<SpriteFromAtlas
|
|
91
|
+
key={itemToRender._id}
|
|
92
|
+
atlasIMG={atlasIMG}
|
|
93
|
+
atlasJSON={atlasJSON}
|
|
94
|
+
spriteKey={itemToRender.texturePath}
|
|
95
|
+
imgScale={3}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (itemToRender?.isStackable && itemToRender?.stackQty) {
|
|
100
|
+
element.push(
|
|
101
|
+
<ItemQty
|
|
102
|
+
left={getLeftPositionValue(itemToRender.stackQty)}
|
|
103
|
+
key={`qty-${itemToRender._id}`}
|
|
104
|
+
>
|
|
105
|
+
{' '}
|
|
106
|
+
{itemToRender.stackQty}{' '}
|
|
107
|
+
</ItemQty>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return element;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const renderEquipment = (itemToRender: IItem | null) => {
|
|
114
|
+
if (
|
|
115
|
+
itemToRender?.texturePath &&
|
|
116
|
+
itemToRender.allowedEquipSlotType?.includes(slotSpriteMask!)
|
|
117
|
+
) {
|
|
118
|
+
return (
|
|
119
|
+
<SpriteFromAtlas
|
|
120
|
+
key={itemToRender._id}
|
|
121
|
+
atlasIMG={atlasIMG}
|
|
122
|
+
atlasJSON={atlasJSON}
|
|
123
|
+
spriteKey={itemToRender.texturePath}
|
|
124
|
+
imgScale={3}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
} else {
|
|
128
|
+
return (
|
|
129
|
+
<SpriteFromAtlas
|
|
130
|
+
atlasIMG={atlasIMG}
|
|
131
|
+
atlasJSON={atlasJSON}
|
|
132
|
+
spriteKey={EquipmentSlotSpriteByType[slotSpriteMask!]}
|
|
133
|
+
imgScale={3}
|
|
134
|
+
grayScale={true}
|
|
135
|
+
opacity={0.4}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const onRenderSlot = (itemToRender: IItem | null) => {
|
|
142
|
+
switch (containerType) {
|
|
143
|
+
case ItemContainerType.Equipment:
|
|
144
|
+
return renderEquipment(itemToRender);
|
|
145
|
+
case ItemContainerType.Inventory:
|
|
146
|
+
return renderItem(itemToRender);
|
|
147
|
+
default:
|
|
148
|
+
return renderItem(itemToRender);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<Container
|
|
154
|
+
className="rpgui-icon empty-slot"
|
|
155
|
+
onMouseOver={event =>
|
|
156
|
+
onMouseOver(event, slotIndex, item, event.clientX, event.clientY)
|
|
157
|
+
}
|
|
158
|
+
onMouseOut={() => {
|
|
159
|
+
if (onMouseOut) onMouseOut();
|
|
160
|
+
}}
|
|
161
|
+
onMouseEnter={() => setTooltipVisible(true)}
|
|
162
|
+
onMouseLeave={() => setTooltipVisible(false)}
|
|
163
|
+
onClick={() => {
|
|
164
|
+
setTooltipVisible(false);
|
|
165
|
+
|
|
166
|
+
if (item) {
|
|
167
|
+
setIsContextMenuVisible(!isContextMenuVisible);
|
|
168
|
+
onClick(item.type, containerType, item);
|
|
169
|
+
}
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
{isContextMenuVisible && contextActions && (
|
|
173
|
+
<RelativeListMenu
|
|
174
|
+
options={contextActions}
|
|
175
|
+
onSelected={(optionId: string) => {
|
|
176
|
+
setIsContextMenuVisible(false);
|
|
177
|
+
if (item) {
|
|
178
|
+
onSelected(optionId, item);
|
|
179
|
+
}
|
|
180
|
+
}}
|
|
181
|
+
onOutsideClick={() => {
|
|
182
|
+
setIsContextMenuVisible(false);
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
|
|
187
|
+
{isTooltipVisible && item && <ItemTooltip label={item.name} />}
|
|
188
|
+
|
|
189
|
+
{onRenderSlot(item)}
|
|
190
|
+
</Container>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const Container = styled.div`
|
|
196
|
+
margin: 0.1rem;
|
|
197
|
+
.sprite-from-atlas-img {
|
|
198
|
+
position: relative;
|
|
199
|
+
top: 1.5rem;
|
|
200
|
+
left: 1.5rem;
|
|
201
|
+
}
|
|
202
|
+
position: relative;
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
interface IItemQtyProps {
|
|
206
|
+
left: string;
|
|
207
|
+
}
|
|
208
|
+
const ItemQty = styled.span<IItemQtyProps>`
|
|
209
|
+
position: relative;
|
|
210
|
+
top: 1.5rem;
|
|
211
|
+
left: ${props => props.left};
|
|
212
|
+
`;
|
|
@@ -1,81 +1,146 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ActionsForEquipmentSet,
|
|
3
|
+
ActionsForInventory,
|
|
4
|
+
ActionsForLoot,
|
|
5
|
+
ActionsForMapContainer,
|
|
6
|
+
ItemContainerType,
|
|
7
|
+
ItemSocketEventsDisplayLabels,
|
|
8
|
+
ItemType
|
|
9
|
+
} from '@rpg-engine/shared';
|
|
10
|
+
|
|
11
|
+
export interface IContextMenuItem {
|
|
12
|
+
id: string;
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const generateContextMenuListOptions = (actionsByTypeList: any) => {
|
|
17
|
+
const contextMenu: IContextMenuItem[] = actionsByTypeList.map(
|
|
18
|
+
(action: string) => {
|
|
19
|
+
return { id: action, text: ItemSocketEventsDisplayLabels[action] };
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
return contextMenu;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const generateContextMenu = (
|
|
26
|
+
itemType: ItemType,
|
|
27
|
+
itemContainerType: ItemContainerType | null
|
|
28
|
+
) => {
|
|
29
|
+
let contextActionMenu: IContextMenuItem[] = [];
|
|
30
|
+
|
|
31
|
+
if (itemContainerType === ItemContainerType.Inventory) {
|
|
32
|
+
switch (itemType) {
|
|
33
|
+
case ItemType.Weapon:
|
|
34
|
+
case ItemType.Armor:
|
|
35
|
+
case ItemType.Accessory:
|
|
36
|
+
case ItemType.Jewelry:
|
|
37
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
38
|
+
ActionsForInventory.Equipment
|
|
39
|
+
);
|
|
40
|
+
break;
|
|
41
|
+
case ItemType.Container:
|
|
42
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
43
|
+
ActionsForInventory.Container
|
|
44
|
+
);
|
|
45
|
+
break;
|
|
46
|
+
case ItemType.Consumable:
|
|
47
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
48
|
+
ActionsForInventory.Consumable
|
|
49
|
+
);
|
|
50
|
+
break;
|
|
51
|
+
case ItemType.CraftMaterial:
|
|
52
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
53
|
+
ActionsForInventory.CraftMaterial
|
|
54
|
+
);
|
|
55
|
+
break;
|
|
56
|
+
case ItemType.Tool:
|
|
57
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
58
|
+
ActionsForInventory.Tool
|
|
59
|
+
);
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
default:
|
|
63
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
64
|
+
ActionsForInventory.Other
|
|
65
|
+
);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (itemContainerType === ItemContainerType.Equipment) {
|
|
70
|
+
switch (itemType) {
|
|
71
|
+
case ItemType.Container:
|
|
72
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
73
|
+
ActionsForEquipmentSet.Container
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
79
|
+
ActionsForEquipmentSet.Equipment
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (itemContainerType === ItemContainerType.Loot) {
|
|
84
|
+
switch (itemType) {
|
|
85
|
+
case ItemType.Weapon:
|
|
86
|
+
case ItemType.Armor:
|
|
87
|
+
case ItemType.Accessory:
|
|
88
|
+
case ItemType.Jewelry:
|
|
89
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
90
|
+
ActionsForLoot.Equipment
|
|
91
|
+
);
|
|
92
|
+
break;
|
|
93
|
+
case ItemType.Consumable:
|
|
94
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
95
|
+
ActionsForLoot.Consumable
|
|
96
|
+
);
|
|
97
|
+
break;
|
|
98
|
+
case ItemType.CraftMaterial:
|
|
99
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
100
|
+
ActionsForLoot.CraftMaterial
|
|
101
|
+
);
|
|
102
|
+
break;
|
|
103
|
+
case ItemType.Tool:
|
|
104
|
+
contextActionMenu = generateContextMenuListOptions(ActionsForLoot.Tool);
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
108
|
+
ActionsForLoot.Other
|
|
109
|
+
);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (itemContainerType === ItemContainerType.MapContainer) {
|
|
114
|
+
switch (itemType) {
|
|
115
|
+
case ItemType.Weapon:
|
|
116
|
+
case ItemType.Armor:
|
|
117
|
+
case ItemType.Accessory:
|
|
118
|
+
case ItemType.Jewelry:
|
|
119
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
120
|
+
ActionsForMapContainer.Equipment
|
|
121
|
+
);
|
|
122
|
+
break;
|
|
123
|
+
case ItemType.Consumable:
|
|
124
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
125
|
+
ActionsForMapContainer.Consumable
|
|
126
|
+
);
|
|
127
|
+
break;
|
|
128
|
+
case ItemType.CraftMaterial:
|
|
129
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
130
|
+
ActionsForMapContainer.CraftMaterial
|
|
131
|
+
);
|
|
132
|
+
break;
|
|
133
|
+
case ItemType.Tool:
|
|
134
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
135
|
+
ActionsForMapContainer.Tool
|
|
136
|
+
);
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
contextActionMenu = generateContextMenuListOptions(
|
|
140
|
+
ActionsForMapContainer.Other
|
|
141
|
+
);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return contextActionMenu;
|
|
146
|
+
};
|