@rpg-engine/long-bow 0.1.66 → 0.1.69
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/DraggableContainer.d.ts +4 -1
- package/dist/components/Item/Inventory/ItemContainer.d.ts +7 -3
- package/dist/components/Item/Inventory/ItemSlot.d.ts +3 -2
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +7 -0
- package/dist/components/Item/SpriteFromAtlas.d.ts +2 -0
- package/dist/components/SimpleProgressBar.d.ts +3 -4
- package/dist/components/SkillProgressBar.d.ts +6 -4
- package/dist/components/SkillsContainer.d.ts +7 -0
- package/dist/constants/uiColors.d.ts +7 -0
- package/dist/hooks/useOutsideAlerter.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +4221 -644
- 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 +4223 -646
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/skills.mocks.d.ts +115 -0
- package/dist/types/eventTypes.d.ts +4 -0
- package/package.json +7 -7
- package/src/components/DraggableContainer.tsx +20 -5
- package/src/components/I_Book.png +0 -0
- package/src/components/Item/Cards/ItemCard.tsx +7 -1
- package/src/components/Item/Inventory/ItemContainer.tsx +141 -136
- package/src/components/Item/Inventory/ItemSlot.tsx +24 -9
- package/src/components/Item/Inventory/itemContainerHelper.ts +44 -0
- package/src/components/Item/SpriteFromAtlas.tsx +10 -0
- package/src/components/SimpleProgressBar.tsx +14 -10
- package/src/components/SkillProgressBar.tsx +74 -20
- package/src/components/SkillsContainer.tsx +235 -0
- package/src/constants/uiColors.ts +7 -0
- package/src/hooks/useOutsideAlerter.ts +25 -0
- package/src/mocks/atlas/items/items.json +3920 -460
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/skills.mocks.ts +116 -0
- package/src/types/eventTypes.ts +4 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Draggable from 'react-draggable';
|
|
2
|
+
import Draggable, { DraggableData } from 'react-draggable';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import { IPosition } from '../types/eventTypes';
|
|
4
5
|
import { RPGUIContainerTypes } from './RPGUIContainer';
|
|
5
6
|
|
|
6
7
|
export interface IDraggableContainerProps {
|
|
@@ -12,7 +13,9 @@ export interface IDraggableContainerProps {
|
|
|
12
13
|
title: string;
|
|
13
14
|
imgSrc?: string;
|
|
14
15
|
imgWidth?: string;
|
|
15
|
-
onCloseButton
|
|
16
|
+
onCloseButton?: () => void;
|
|
17
|
+
cancelDrag?: string;
|
|
18
|
+
onPositionChange?: (position: IPosition) => void;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
|
|
@@ -25,13 +28,25 @@ export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
|
|
|
25
28
|
title,
|
|
26
29
|
imgSrc,
|
|
27
30
|
imgWidth = '20px',
|
|
31
|
+
cancelDrag,
|
|
32
|
+
onPositionChange,
|
|
28
33
|
}) => {
|
|
29
34
|
return (
|
|
30
|
-
<Draggable
|
|
35
|
+
<Draggable
|
|
36
|
+
cancel={`.container-close,${cancelDrag}`}
|
|
37
|
+
onDrag={(_e, data: DraggableData) => {
|
|
38
|
+
if (onPositionChange) {
|
|
39
|
+
onPositionChange({
|
|
40
|
+
x: data.x,
|
|
41
|
+
y: data.y,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
31
46
|
<Container
|
|
32
47
|
width={width}
|
|
33
48
|
height={height || 'auto'}
|
|
34
|
-
className={`rpgui-container ${type} ${className}
|
|
49
|
+
className={`rpgui-container ${type} ${className}`}
|
|
35
50
|
>
|
|
36
51
|
<TitleContainer className="drag-handler">
|
|
37
52
|
<Title>
|
|
@@ -86,7 +101,7 @@ const TitleContainer = styled.div`
|
|
|
86
101
|
height: 100%;
|
|
87
102
|
display: flex;
|
|
88
103
|
flex-wrap: wrap;
|
|
89
|
-
justify-content:
|
|
104
|
+
justify-content: flex-start;
|
|
90
105
|
align-items: center;
|
|
91
106
|
`;
|
|
92
107
|
|
|
Binary file
|
|
@@ -25,6 +25,12 @@ const Container = styled.div<IContainerProps>`
|
|
|
25
25
|
position: absolute;
|
|
26
26
|
top: ${props => props.y || 0}px;
|
|
27
27
|
left: ${props => props.x || 0}px;
|
|
28
|
-
font-size:
|
|
28
|
+
font-size: 0.5rem;
|
|
29
29
|
color: white;
|
|
30
|
+
background-color: black;
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
padding: 0.5rem;
|
|
33
|
+
min-width: 20px;
|
|
34
|
+
|
|
35
|
+
opacity: 0.5;
|
|
30
36
|
`;
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ActionsByItemType,
|
|
3
2
|
IItem,
|
|
4
3
|
IItemContainer,
|
|
5
4
|
IPayloadProps,
|
|
6
5
|
ItemSocketEvents,
|
|
7
|
-
ItemType,
|
|
8
6
|
} from '@rpg-engine/shared';
|
|
9
|
-
import React, { useEffect, useState } from 'react';
|
|
7
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
10
8
|
import styled from 'styled-components';
|
|
9
|
+
import { useOutsideClick } from '../../../hooks/useOutsideAlerter';
|
|
10
|
+
import { IPosition } from '../../../types/eventTypes';
|
|
11
11
|
import { DraggableContainer } from '../../DraggableContainer';
|
|
12
12
|
import { ListMenu } from '../../ListMenu';
|
|
13
13
|
import { RPGUIContainerTypes } from '../../RPGUIContainer';
|
|
14
14
|
import { ItemCard } from '../Cards/ItemCard';
|
|
15
|
+
import { handleContextMenuList } from './itemContainerHelper';
|
|
15
16
|
import { ItemSlot } from './ItemSlot';
|
|
16
17
|
|
|
17
18
|
export interface IItemContainerProps {
|
|
18
19
|
itemContainer: IItemContainer;
|
|
19
|
-
onClose
|
|
20
|
-
onMouseOver
|
|
21
|
-
onActionSelected
|
|
20
|
+
onClose?: () => void;
|
|
21
|
+
onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
|
|
22
|
+
onActionSelected?: (payload: any) => void;
|
|
23
|
+
initialPosition?: { x: number; y: number };
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
interface
|
|
26
|
+
interface IContextItemProps {
|
|
25
27
|
visible: boolean;
|
|
26
28
|
posX: number;
|
|
27
29
|
posY: number;
|
|
@@ -30,127 +32,113 @@ interface contextItemPropx {
|
|
|
30
32
|
contextActions: any;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
interface IHoverDetailProps {
|
|
36
|
+
visible: boolean;
|
|
37
|
+
posX: number;
|
|
38
|
+
posY: number;
|
|
39
|
+
item: IItem | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
34
43
|
itemContainer,
|
|
35
44
|
onClose,
|
|
36
45
|
onMouseOver,
|
|
37
46
|
onActionSelected,
|
|
47
|
+
initialPosition = { x: 0, y: 0 },
|
|
38
48
|
}) => {
|
|
39
|
-
|
|
49
|
+
// we use this draggable position to offset the menu position, after the container is dragged (otherwise, it bugs!)
|
|
50
|
+
const [draggablePosition, setDraggablePosition] = useState<IPosition>(
|
|
51
|
+
initialPosition
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const draggableRef = useRef(null);
|
|
55
|
+
|
|
56
|
+
useOutsideClick(draggableRef, 'item-container');
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
document.addEventListener('clickOutside', event => {
|
|
60
|
+
const e = event as CustomEvent;
|
|
61
|
+
|
|
62
|
+
if (e.detail.id === 'item-container') {
|
|
63
|
+
clearContextMenu();
|
|
64
|
+
clearItemHoverDetail();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
document.removeEventListener('clickOutside', _e => {});
|
|
70
|
+
};
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const { x: initX, y: initY } = initialPosition;
|
|
74
|
+
|
|
75
|
+
const [contextData, setContextData] = useState<IContextItemProps>({
|
|
40
76
|
visible: false,
|
|
41
|
-
posX:
|
|
42
|
-
posY:
|
|
77
|
+
posX: initX,
|
|
78
|
+
posY: initY,
|
|
43
79
|
contextActions: [],
|
|
44
80
|
slotItem: null,
|
|
45
81
|
});
|
|
46
|
-
const [itemHoverDetail] = useState({
|
|
82
|
+
const [itemHoverDetail, setItemHoverDetail] = useState<IHoverDetailProps>({
|
|
47
83
|
visible: false,
|
|
48
|
-
posX:
|
|
49
|
-
posY:
|
|
84
|
+
posX: initX,
|
|
85
|
+
posY: initY,
|
|
50
86
|
item: null,
|
|
51
87
|
});
|
|
52
|
-
let selectedSlotContext: number | null = null;
|
|
53
|
-
|
|
54
|
-
const handleContextMenuList = (itemType: ItemType) => {
|
|
55
|
-
const generateContextList = (actionsByTypeList: any) => {
|
|
56
|
-
let contextMenu = actionsByTypeList.map((action: string) => {
|
|
57
|
-
return { id: action, text: action };
|
|
58
|
-
});
|
|
59
|
-
return contextMenu;
|
|
60
|
-
};
|
|
61
88
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
break;
|
|
71
|
-
case ItemType.Consumable:
|
|
72
|
-
contextActionMenu = generateContextList(ActionsByItemType.Consumable);
|
|
73
|
-
break;
|
|
74
|
-
case ItemType.CraftMaterial:
|
|
75
|
-
contextActionMenu = generateContextList(
|
|
76
|
-
ActionsByItemType.CraftMaterial
|
|
77
|
-
);
|
|
78
|
-
break;
|
|
79
|
-
case ItemType.Other:
|
|
80
|
-
case ItemType.Information:
|
|
81
|
-
case ItemType.Quest:
|
|
82
|
-
case ItemType.Container:
|
|
83
|
-
contextActionMenu = generateContextList(ActionsByItemType.Other);
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
contextActionMenu = generateContextList(ActionsByItemType.Other);
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
return contextActionMenu;
|
|
89
|
+
const clearContextMenu = () => {
|
|
90
|
+
setContextData({
|
|
91
|
+
visible: false,
|
|
92
|
+
posX: 0,
|
|
93
|
+
posY: 0,
|
|
94
|
+
contextActions: [],
|
|
95
|
+
slotItem: null,
|
|
96
|
+
});
|
|
90
97
|
};
|
|
91
98
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
contextActions: contextActionMenu,
|
|
107
|
-
});
|
|
108
|
-
} else {
|
|
109
|
-
// console.log("Empty Slot")
|
|
110
|
-
setContextData({
|
|
111
|
-
...contextData,
|
|
112
|
-
visible: false,
|
|
113
|
-
posX: 0,
|
|
114
|
-
posY: 0,
|
|
115
|
-
slotIndex: null,
|
|
116
|
-
slotItem: null,
|
|
117
|
-
contextActions: [],
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const offClickHandler = (event: any) => {
|
|
124
|
-
console.log(event);
|
|
125
|
-
setContextData({
|
|
126
|
-
...contextData,
|
|
127
|
-
visible: false,
|
|
128
|
-
posX: 0,
|
|
129
|
-
posY: 0,
|
|
130
|
-
slotIndex: null,
|
|
131
|
-
slotItem: null,
|
|
99
|
+
const handleOnMouseHover = (
|
|
100
|
+
event: any,
|
|
101
|
+
slotIndex: number,
|
|
102
|
+
item: IItem | null,
|
|
103
|
+
x: number,
|
|
104
|
+
y: number
|
|
105
|
+
) => {
|
|
106
|
+
if (item) {
|
|
107
|
+
setItemHoverDetail({
|
|
108
|
+
...itemHoverDetail,
|
|
109
|
+
visible: true,
|
|
110
|
+
item: item,
|
|
111
|
+
posX: x - draggablePosition.x,
|
|
112
|
+
posY: y - draggablePosition.y,
|
|
132
113
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
}, [contextData, selectedSlotContext]);
|
|
114
|
+
if (onMouseOver) {
|
|
115
|
+
onMouseOver(event, slotIndex, item);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
clearItemHoverDetail();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
142
121
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
122
|
+
const clearItemHoverDetail = () => {
|
|
123
|
+
setItemHoverDetail({
|
|
124
|
+
...itemHoverDetail,
|
|
125
|
+
visible: false,
|
|
126
|
+
item: null,
|
|
127
|
+
});
|
|
147
128
|
};
|
|
148
129
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
130
|
+
const handleOnItemClick = (item: IItem, posX: number, posY: number) => {
|
|
131
|
+
const contextList = handleContextMenuList(item.type);
|
|
132
|
+
|
|
133
|
+
setContextData({
|
|
134
|
+
...contextData,
|
|
135
|
+
visible: true,
|
|
136
|
+
posX,
|
|
137
|
+
posY,
|
|
138
|
+
slotItem: item,
|
|
139
|
+
contextActions: contextList,
|
|
140
|
+
});
|
|
141
|
+
clearItemHoverDetail();
|
|
154
142
|
};
|
|
155
143
|
|
|
156
144
|
const onSelected = (selectedActionId: ItemSocketEvents | string): void => {
|
|
@@ -158,8 +146,10 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
158
146
|
actionType: selectedActionId,
|
|
159
147
|
item: contextData.slotItem,
|
|
160
148
|
};
|
|
161
|
-
|
|
162
|
-
|
|
149
|
+
if (onActionSelected) {
|
|
150
|
+
onActionSelected(payloadData);
|
|
151
|
+
}
|
|
152
|
+
clearContextMenu();
|
|
163
153
|
};
|
|
164
154
|
|
|
165
155
|
const onRenderSlots = () => {
|
|
@@ -172,7 +162,10 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
172
162
|
slotIndex={i}
|
|
173
163
|
item={itemContainer.slots?.[i] || null}
|
|
174
164
|
onMouseOver={handleOnMouseHover}
|
|
175
|
-
|
|
165
|
+
onClick={handleOnItemClick}
|
|
166
|
+
onCancelContextMenu={() => {
|
|
167
|
+
clearContextMenu();
|
|
168
|
+
}}
|
|
176
169
|
/>
|
|
177
170
|
);
|
|
178
171
|
}
|
|
@@ -180,31 +173,43 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
180
173
|
};
|
|
181
174
|
|
|
182
175
|
return (
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
176
|
+
<div ref={draggableRef}>
|
|
177
|
+
<DraggableContainer
|
|
178
|
+
title={itemContainer.name || 'Container'}
|
|
179
|
+
type={RPGUIContainerTypes.Framed}
|
|
180
|
+
onCloseButton={() => {
|
|
181
|
+
if (onClose) {
|
|
182
|
+
onClose();
|
|
183
|
+
}
|
|
184
|
+
}}
|
|
185
|
+
width="330px"
|
|
186
|
+
cancelDrag=".item-container-body"
|
|
187
|
+
onPositionChange={({ x, y }) => {
|
|
188
|
+
setDraggablePosition({ x, y });
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
<ItemsContainer className="item-container-body">
|
|
192
|
+
{onRenderSlots()}
|
|
193
|
+
</ItemsContainer>
|
|
194
|
+
|
|
195
|
+
{contextData.visible ? (
|
|
196
|
+
<ListMenu
|
|
197
|
+
x={contextData.posX - draggablePosition.x}
|
|
198
|
+
y={contextData.posY - draggablePosition.y}
|
|
199
|
+
options={contextData.contextActions}
|
|
200
|
+
onSelected={onSelected}
|
|
201
|
+
/>
|
|
202
|
+
) : null}
|
|
203
|
+
|
|
204
|
+
{itemHoverDetail.visible ? (
|
|
205
|
+
<ItemCard
|
|
206
|
+
item={itemHoverDetail.item}
|
|
207
|
+
x={itemHoverDetail.posX}
|
|
208
|
+
y={itemHoverDetail.posY}
|
|
209
|
+
/>
|
|
210
|
+
) : null}
|
|
211
|
+
</DraggableContainer>
|
|
212
|
+
</div>
|
|
208
213
|
);
|
|
209
214
|
};
|
|
210
215
|
|
|
@@ -7,17 +7,25 @@ import { SpriteFromAtlas } from '../SpriteFromAtlas';
|
|
|
7
7
|
interface IProps {
|
|
8
8
|
slotIndex: number;
|
|
9
9
|
item: IItem | null;
|
|
10
|
-
onMouseOver: (
|
|
11
|
-
|
|
10
|
+
onMouseOver: (
|
|
11
|
+
event: any,
|
|
12
|
+
slotIndex: number,
|
|
13
|
+
item: IItem | null,
|
|
14
|
+
x: number,
|
|
15
|
+
y: number
|
|
16
|
+
) => void;
|
|
17
|
+
onClick: (item: IItem, posX: number, posY: number) => void;
|
|
18
|
+
onCancelContextMenu: () => void;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
export const ItemSlot: React.FC<IProps> = ({
|
|
15
22
|
slotIndex,
|
|
16
23
|
item,
|
|
17
24
|
onMouseOver,
|
|
18
|
-
|
|
25
|
+
onClick,
|
|
26
|
+
onCancelContextMenu,
|
|
19
27
|
}) => {
|
|
20
|
-
const
|
|
28
|
+
const getLeftPositionValue = (quantity: number) => {
|
|
21
29
|
if (quantity > 0 && quantity < 10) return '2.5rem';
|
|
22
30
|
else if (quantity > 9 && quantity < 100) return '2.0rem';
|
|
23
31
|
else if (quantity > 99) return '1rem';
|
|
@@ -26,11 +34,18 @@ export const ItemSlot: React.FC<IProps> = ({
|
|
|
26
34
|
|
|
27
35
|
return (
|
|
28
36
|
<Container
|
|
29
|
-
onContextMenu={event => {
|
|
30
|
-
onActionContextMenu(event, slotIndex);
|
|
31
|
-
}}
|
|
32
37
|
className="rpgui-icon empty-slot"
|
|
33
|
-
onMouseOver={event =>
|
|
38
|
+
onMouseOver={event =>
|
|
39
|
+
onMouseOver(event, slotIndex, item, event.clientX, event.clientY)
|
|
40
|
+
}
|
|
41
|
+
onClick={e => {
|
|
42
|
+
if (item) {
|
|
43
|
+
console.log(e);
|
|
44
|
+
onClick(item, e.clientX, e.clientY);
|
|
45
|
+
} else {
|
|
46
|
+
onCancelContextMenu();
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
34
49
|
>
|
|
35
50
|
{item && item.texturePath ? (
|
|
36
51
|
<SpriteFromAtlas
|
|
@@ -41,7 +56,7 @@ export const ItemSlot: React.FC<IProps> = ({
|
|
|
41
56
|
/>
|
|
42
57
|
) : null}
|
|
43
58
|
{item && item.isStackable && item?.stackQty ? (
|
|
44
|
-
<ItemQty left={
|
|
59
|
+
<ItemQty left={getLeftPositionValue(item.stackQty)}>
|
|
45
60
|
{' '}
|
|
46
61
|
{item.stackQty}{' '}
|
|
47
62
|
</ItemQty>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ActionsByItemType, ItemType } from '@rpg-engine/shared';
|
|
2
|
+
|
|
3
|
+
interface IContextMenuItem {
|
|
4
|
+
id: string;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const handleContextMenuList = (itemType: ItemType) => {
|
|
9
|
+
const generateContextList = (actionsByTypeList: any) => {
|
|
10
|
+
const contextMenu: IContextMenuItem[] = actionsByTypeList.map(
|
|
11
|
+
(action: string) => {
|
|
12
|
+
return { id: action, text: action };
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
return contextMenu;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let contextActionMenu: IContextMenuItem[] = [];
|
|
19
|
+
switch (itemType) {
|
|
20
|
+
case ItemType.Weapon:
|
|
21
|
+
case ItemType.Armor:
|
|
22
|
+
case ItemType.Accessory:
|
|
23
|
+
case ItemType.Jewelry:
|
|
24
|
+
case ItemType.Tool:
|
|
25
|
+
contextActionMenu = generateContextList(ActionsByItemType.Equipment);
|
|
26
|
+
break;
|
|
27
|
+
case ItemType.Consumable:
|
|
28
|
+
contextActionMenu = generateContextList(ActionsByItemType.Consumable);
|
|
29
|
+
break;
|
|
30
|
+
case ItemType.CraftMaterial:
|
|
31
|
+
contextActionMenu = generateContextList(ActionsByItemType.CraftMaterial);
|
|
32
|
+
break;
|
|
33
|
+
case ItemType.Other:
|
|
34
|
+
case ItemType.Information:
|
|
35
|
+
case ItemType.Quest:
|
|
36
|
+
case ItemType.Container:
|
|
37
|
+
contextActionMenu = generateContextList(ActionsByItemType.Other);
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
contextActionMenu = generateContextList(ActionsByItemType.Other);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return contextActionMenu;
|
|
44
|
+
};
|
|
@@ -9,6 +9,8 @@ interface IProps {
|
|
|
9
9
|
width?: number;
|
|
10
10
|
height?: number;
|
|
11
11
|
scale?: number;
|
|
12
|
+
grayScale?: boolean;
|
|
13
|
+
opacity?: number;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export const SpriteFromAtlas: React.FC<IProps> = ({
|
|
@@ -18,6 +20,8 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
|
|
|
18
20
|
width = GRID_WIDTH,
|
|
19
21
|
height = GRID_HEIGHT,
|
|
20
22
|
scale = 2,
|
|
23
|
+
grayScale = false,
|
|
24
|
+
opacity = 1,
|
|
21
25
|
}) => {
|
|
22
26
|
//! If an item is not showing, remember that you MUST run yarn atlas:copy everytime you add a new item to the atlas (it will sync our public folder atlas with src/atlas).
|
|
23
27
|
//!Due to React's limitations, we cannot import it from the public folder directly!
|
|
@@ -31,6 +35,8 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
|
|
|
31
35
|
atlasIMG={atlasIMG}
|
|
32
36
|
frame={spriteData.frame}
|
|
33
37
|
scale={scale}
|
|
38
|
+
grayScale={grayScale}
|
|
39
|
+
opacity={opacity}
|
|
34
40
|
/>
|
|
35
41
|
</Container>
|
|
36
42
|
);
|
|
@@ -45,6 +51,8 @@ interface IImgSpriteProps {
|
|
|
45
51
|
h: number;
|
|
46
52
|
};
|
|
47
53
|
scale: number;
|
|
54
|
+
grayScale: boolean;
|
|
55
|
+
opacity: number;
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
interface IContainerProps {
|
|
@@ -66,4 +74,6 @@ const ImgSprite = styled.div<IImgSpriteProps>`
|
|
|
66
74
|
position: relative;
|
|
67
75
|
top: 8px;
|
|
68
76
|
left: 8px;
|
|
77
|
+
filter: ${props => (props.grayScale ? 'grayscale(100%)' : 'none')};
|
|
78
|
+
opacity: ${props => props.opacity};
|
|
69
79
|
`;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
export interface ISimpleProgressBarProps {
|
|
5
5
|
value: number;
|
|
6
|
-
height?: string;
|
|
7
6
|
bgColor?: string;
|
|
7
|
+
margin?: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const SimpleProgressBar: React.FC<
|
|
10
|
+
export const SimpleProgressBar: React.FC<ISimpleProgressBarProps> = ({
|
|
11
11
|
value,
|
|
12
|
-
|
|
13
12
|
bgColor = 'red',
|
|
13
|
+
margin = 20,
|
|
14
14
|
}) => {
|
|
15
15
|
return (
|
|
16
|
-
<Container>
|
|
17
|
-
<ProgressBarContainer>
|
|
16
|
+
<Container className="simple-progress-bar">
|
|
17
|
+
<ProgressBarContainer margin={margin}>
|
|
18
18
|
<BackgroundBar>
|
|
19
19
|
<Progress value={value} bgColor={bgColor} />
|
|
20
20
|
</BackgroundBar>
|
|
@@ -34,16 +34,20 @@ const BackgroundBar = styled.span`
|
|
|
34
34
|
background-color: rgba(0, 0, 0, 0.075);
|
|
35
35
|
`;
|
|
36
36
|
|
|
37
|
-
interface
|
|
37
|
+
interface ISimpleProgressBarThemeProps {
|
|
38
38
|
value: number;
|
|
39
39
|
bgColor: string;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const Progress = styled.span`
|
|
43
|
-
background-color: ${(props:
|
|
44
|
-
width: ${(props:
|
|
43
|
+
background-color: ${(props: ISimpleProgressBarThemeProps) => props.bgColor};
|
|
44
|
+
width: ${(props: ISimpleProgressBarThemeProps) => props.value}%;
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
|
+
interface ISimpleProgressBarTheme2Props {
|
|
48
|
+
margin: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
const ProgressBarContainer = styled.div`
|
|
48
52
|
border-radius: 60px;
|
|
49
53
|
border: 1px solid #282424;
|
|
@@ -53,6 +57,6 @@ const ProgressBarContainer = styled.div`
|
|
|
53
57
|
display: block;
|
|
54
58
|
height: 100%;
|
|
55
59
|
}
|
|
56
|
-
|
|
57
60
|
height: 8px;
|
|
61
|
+
margin-left: ${(props: ISimpleProgressBarTheme2Props) => props.margin}px;
|
|
58
62
|
`;
|