@rpg-engine/long-bow 0.3.43 → 0.3.44
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/Abstractions/SlotsContainer.d.ts +0 -1
- package/dist/components/Button.d.ts +2 -3
- package/dist/components/Chat/Chat.d.ts +2 -12
- package/dist/components/CheckButton.d.ts +2 -1
- package/dist/components/DraggableContainer.d.ts +0 -1
- package/dist/components/Equipment/EquipmentSet.d.ts +0 -8
- package/dist/components/Input.d.ts +0 -1
- package/dist/components/Item/Inventory/ItemContainer.d.ts +0 -12
- package/dist/components/Item/Inventory/ItemSlot.d.ts +0 -9
- package/dist/components/NPCDialog/NPCDialogText.d.ts +2 -4
- package/dist/components/RangeSlider.d.ts +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/long-bow.cjs.development.js +515 -7465
- 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 +520 -7461
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/equipmentSet.mocks.d.ts +2 -15
- package/dist/mocks/skills.mocks.d.ts +121 -2
- package/package.json +2 -5
- package/src/components/Abstractions/SlotsContainer.tsx +0 -3
- package/src/components/Button.tsx +8 -18
- package/src/components/Chat/Chat.tsx +105 -106
- package/src/components/CheckButton.tsx +1 -1
- package/src/components/DraggableContainer.tsx +1 -4
- package/src/components/Dropdown.tsx +1 -7
- package/src/components/Equipment/EquipmentSet.tsx +0 -46
- package/src/components/Input.tsx +2 -6
- package/src/components/Item/Inventory/ItemContainer.tsx +6 -104
- package/src/components/Item/Inventory/ItemSlot.tsx +34 -234
- package/src/components/NPCDialog/NPCDialog.tsx +28 -4
- package/src/components/NPCDialog/NPCDialogText.tsx +15 -75
- package/src/components/RangeSlider.tsx +14 -37
- package/src/components/SkillsContainer.tsx +1 -1
- package/src/components/TimeWidget/TimeWidget.tsx +0 -1
- package/src/components/TradingMenu/TradingItemRow.tsx +6 -43
- package/src/components/TradingMenu/TradingMenu.tsx +1 -1
- package/src/components/TradingMenu/items.mock.ts +0 -1
- package/src/components/shared/SpriteFromAtlas.tsx +1 -4
- package/src/hooks/useOutsideAlerter.ts +2 -2
- package/src/index.tsx +0 -8
- package/src/mocks/atlas/items/items.json +314 -6086
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +4 -49
- package/src/mocks/itemContainer.mocks.ts +6 -54
- package/src/mocks/skills.mocks.ts +2 -8
- package/src/stories/Chat.stories.tsx +3 -20
- package/src/stories/EquipmentSet.stories.tsx +0 -10
- package/src/stories/ItemContainer.stories.tsx +15 -84
- package/src/stories/RangeSlider.stories.tsx +9 -10
- package/dist/components/CaracterStatus/CaracterStatus.d.ts +0 -9
- package/dist/components/Chatdeprecated/ChatDeprecated.d.ts +0 -13
- package/dist/components/CircularController/CircularController.d.ts +0 -10
- package/dist/components/CraftBook/CraftBook.d.ts +0 -15
- package/dist/components/CraftBook/MockItems.d.ts +0 -2
- package/dist/components/DropdownSelectorContainer.d.ts +0 -13
- package/dist/components/Item/Inventory/ItemQuantitySelector.d.ts +0 -7
- package/dist/components/RadioInput/RadioButton.d.ts +0 -8
- package/dist/components/RadioInput/RadioInput.d.ts +0 -13
- package/dist/components/RadioInput/instruments.d.ts +0 -4
- package/dist/components/Spellbook/QuickSpells.d.ts +0 -10
- package/dist/components/Spellbook/Spell.d.ts +0 -11
- package/dist/components/Spellbook/Spellbook.d.ts +0 -15
- package/dist/components/Spellbook/SpellbookShortcuts.d.ts +0 -10
- package/dist/components/Spellbook/constants.d.ts +0 -3
- package/dist/components/Spellbook/mockSpells.d.ts +0 -2
- package/dist/components/itemSelector/ItemSelector.d.ts +0 -14
- package/dist/constants/uiDevices.d.ts +0 -1
- package/dist/stories/CaracterStatus.stories.d.ts +0 -5
- package/dist/stories/ChatDeprecated.stories.d.ts +0 -5
- package/dist/stories/CircullarController.stories.d.ts +0 -5
- package/dist/stories/CraftBook.stories.d.ts +0 -4
- package/dist/stories/DropdownSelectorContainer.stories.d.ts +0 -5
- package/dist/stories/ItemQuantitySelector.stories.d.ts +0 -5
- package/dist/stories/ItemSelector.stories.d.ts +0 -4
- package/dist/stories/QuickSpells.stories.d.ts +0 -5
- package/dist/stories/RadioInput.stories.d.ts +0 -5
- package/dist/stories/Spellbook.stories.d.ts +0 -5
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/CaracterStatus/CaracterStatus.tsx +0 -86
- package/src/components/CaracterStatus/Character.png +0 -0
- package/src/components/Chatdeprecated/ChatDeprecated.tsx +0 -200
- package/src/components/CircularController/CircularController.tsx +0 -162
- package/src/components/CraftBook/CraftBook.tsx +0 -230
- package/src/components/CraftBook/MockItems.ts +0 -46
- package/src/components/DropdownSelectorContainer.tsx +0 -42
- package/src/components/Item/Inventory/ItemQuantitySelector.tsx +0 -142
- package/src/components/NPCDialog/.DS_Store +0 -0
- package/src/components/NPCDialog/img/.DS_Store +0 -0
- package/src/components/NPCDialog/img/press-button.gif +0 -0
- package/src/components/RadioInput/RadioButton.tsx +0 -98
- package/src/components/RadioInput/RadioInput.tsx +0 -99
- package/src/components/RadioInput/instruments.ts +0 -16
- package/src/components/Spellbook/QuickSpells.tsx +0 -120
- package/src/components/Spellbook/Spell.tsx +0 -201
- package/src/components/Spellbook/Spellbook.tsx +0 -144
- package/src/components/Spellbook/SpellbookShortcuts.tsx +0 -77
- package/src/components/Spellbook/constants.ts +0 -12
- package/src/components/Spellbook/mockSpells.ts +0 -60
- package/src/components/itemSelector/ItemSelector.tsx +0 -136
- package/src/constants/uiDevices.ts +0 -5
- package/src/mocks/.DS_Store +0 -0
- package/src/mocks/atlas/.DS_Store +0 -0
- package/src/stories/CaracterStatus.stories.tsx +0 -29
- package/src/stories/ChatDeprecated.stories.tsx +0 -170
- package/src/stories/CircullarController.stories.tsx +0 -33
- package/src/stories/CraftBook.stories.tsx +0 -40
- package/src/stories/DropdownSelectorContainer.stories.tsx +0 -41
- package/src/stories/ItemQuantitySelector.stories.tsx +0 -26
- package/src/stories/ItemSelector.stories.tsx +0 -77
- package/src/stories/QuickSpells.stories.tsx +0 -38
- package/src/stories/RadioInput.stories.tsx +0 -35
- package/src/stories/Spellbook.stories.tsx +0 -107
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { IItem, IItemContainer, ItemContainerType } from '@rpg-engine/shared';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { SlotsContainer } from '../../Abstractions/SlotsContainer';
|
|
5
|
-
import { ItemQuantitySelector } from './ItemQuantitySelector';
|
|
6
5
|
|
|
7
|
-
import { IPosition } from '../../../types/eventTypes';
|
|
8
6
|
import { ItemSlot } from './ItemSlot';
|
|
9
7
|
|
|
10
8
|
export interface IItemContainerProps {
|
|
@@ -15,28 +13,12 @@ export interface IItemContainerProps {
|
|
|
15
13
|
ItemType: IItem['type'],
|
|
16
14
|
itemContainerType: ItemContainerType | null
|
|
17
15
|
) => void;
|
|
18
|
-
onItemDragStart?: (
|
|
19
|
-
item: IItem,
|
|
20
|
-
slotIndex: number,
|
|
21
|
-
itemContainerType: ItemContainerType | null
|
|
22
|
-
) => void;
|
|
23
|
-
onItemDragEnd?: (quantity?: number) => void;
|
|
24
|
-
onOutsideDrop?: (item: IItem, position: IPosition) => void;
|
|
25
|
-
onItemPlaceDrop?: (
|
|
26
|
-
item: IItem | null,
|
|
27
|
-
slotIndex: number,
|
|
28
|
-
itemContainerType: ItemContainerType | null
|
|
29
|
-
) => void;
|
|
30
|
-
dragScale?: number;
|
|
31
|
-
checkIfItemCanBeMoved: () => boolean;
|
|
32
|
-
checkIfItemShouldDragEnd?: () => boolean;
|
|
33
16
|
onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
|
|
34
17
|
onSelected?: (optionId: string, item: IItem) => void;
|
|
35
18
|
type: ItemContainerType;
|
|
36
19
|
atlasJSON: any;
|
|
37
20
|
atlasIMG: any;
|
|
38
21
|
disableContextMenu?: boolean;
|
|
39
|
-
initialPosition?: { x: number; y: number };
|
|
40
22
|
}
|
|
41
23
|
|
|
42
24
|
export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
@@ -49,21 +31,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
49
31
|
atlasJSON,
|
|
50
32
|
atlasIMG,
|
|
51
33
|
disableContextMenu = false,
|
|
52
|
-
onItemDragEnd,
|
|
53
|
-
onItemDragStart,
|
|
54
|
-
onItemPlaceDrop,
|
|
55
|
-
onOutsideDrop,
|
|
56
|
-
checkIfItemCanBeMoved,
|
|
57
|
-
initialPosition,
|
|
58
|
-
checkIfItemShouldDragEnd,
|
|
59
|
-
dragScale,
|
|
60
34
|
}) => {
|
|
61
|
-
const [quantitySelect, setQuantitySelect] = useState({
|
|
62
|
-
isOpen: false,
|
|
63
|
-
maxQuantity: 1,
|
|
64
|
-
callback: (_quantity: number) => {},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
35
|
const onRenderSlots = () => {
|
|
68
36
|
const slots = [];
|
|
69
37
|
|
|
@@ -84,30 +52,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
84
52
|
onSelected={(optionId: string, item: IItem) => {
|
|
85
53
|
if (onSelected) onSelected(optionId, item);
|
|
86
54
|
}}
|
|
87
|
-
onDragStart={(item, slotIndex, itemContainerType) => {
|
|
88
|
-
if (onItemDragStart)
|
|
89
|
-
onItemDragStart(item, slotIndex, itemContainerType);
|
|
90
|
-
}}
|
|
91
|
-
onDragEnd={quantity => {
|
|
92
|
-
if (onItemDragEnd) onItemDragEnd(quantity);
|
|
93
|
-
}}
|
|
94
|
-
dragScale={dragScale}
|
|
95
|
-
checkIfItemCanBeMoved={checkIfItemCanBeMoved}
|
|
96
|
-
checkIfItemShouldDragEnd={checkIfItemShouldDragEnd}
|
|
97
|
-
openQuantitySelector={(maxQuantity, callback) => {
|
|
98
|
-
setQuantitySelect({
|
|
99
|
-
isOpen: true,
|
|
100
|
-
maxQuantity,
|
|
101
|
-
callback,
|
|
102
|
-
});
|
|
103
|
-
}}
|
|
104
|
-
onPlaceDrop={(item, slotIndex, itemContainerType) => {
|
|
105
|
-
if (onItemPlaceDrop)
|
|
106
|
-
onItemPlaceDrop(item, slotIndex, itemContainerType);
|
|
107
|
-
}}
|
|
108
|
-
onOutsideDrop={(item, position) => {
|
|
109
|
-
if (onOutsideDrop) onOutsideDrop(item, position);
|
|
110
|
-
}}
|
|
111
55
|
atlasIMG={atlasIMG}
|
|
112
56
|
atlasJSON={atlasJSON}
|
|
113
57
|
/>
|
|
@@ -117,40 +61,11 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
117
61
|
};
|
|
118
62
|
|
|
119
63
|
return (
|
|
120
|
-
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
>
|
|
126
|
-
<ItemsContainer className="item-container-body">
|
|
127
|
-
{onRenderSlots()}
|
|
128
|
-
</ItemsContainer>
|
|
129
|
-
</SlotsContainer>
|
|
130
|
-
{quantitySelect.isOpen && (
|
|
131
|
-
<QuantitySelectorContainer>
|
|
132
|
-
<ItemQuantitySelector
|
|
133
|
-
quantity={quantitySelect.maxQuantity}
|
|
134
|
-
onConfirm={quantity => {
|
|
135
|
-
quantitySelect.callback(quantity);
|
|
136
|
-
setQuantitySelect({
|
|
137
|
-
isOpen: false,
|
|
138
|
-
maxQuantity: 1,
|
|
139
|
-
callback: () => {},
|
|
140
|
-
});
|
|
141
|
-
}}
|
|
142
|
-
onClose={() => {
|
|
143
|
-
quantitySelect.callback(-1);
|
|
144
|
-
setQuantitySelect({
|
|
145
|
-
isOpen: false,
|
|
146
|
-
maxQuantity: 1,
|
|
147
|
-
callback: () => {},
|
|
148
|
-
});
|
|
149
|
-
}}
|
|
150
|
-
/>
|
|
151
|
-
</QuantitySelectorContainer>
|
|
152
|
-
)}
|
|
153
|
-
</>
|
|
64
|
+
<SlotsContainer title={itemContainer.name || 'Container'} onClose={onClose}>
|
|
65
|
+
<ItemsContainer className="item-container-body">
|
|
66
|
+
{onRenderSlots()}
|
|
67
|
+
</ItemsContainer>
|
|
68
|
+
</SlotsContainer>
|
|
154
69
|
);
|
|
155
70
|
};
|
|
156
71
|
|
|
@@ -160,16 +75,3 @@ const ItemsContainer = styled.div`
|
|
|
160
75
|
justify-content: center;
|
|
161
76
|
flex-wrap: wrap;
|
|
162
77
|
`;
|
|
163
|
-
|
|
164
|
-
const QuantitySelectorContainer = styled.div`
|
|
165
|
-
position: absolute;
|
|
166
|
-
top: 0;
|
|
167
|
-
left: 0;
|
|
168
|
-
width: 100vw;
|
|
169
|
-
height: 100vh;
|
|
170
|
-
z-index: 100;
|
|
171
|
-
display: flex;
|
|
172
|
-
justify-content: center;
|
|
173
|
-
align-items: center;
|
|
174
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
175
|
-
`;
|
|
@@ -3,18 +3,15 @@ import {
|
|
|
3
3
|
IItem,
|
|
4
4
|
IItemContainer,
|
|
5
5
|
ItemContainerType,
|
|
6
|
-
ItemRarities,
|
|
7
6
|
ItemSlotType,
|
|
8
7
|
ItemType,
|
|
9
8
|
} from '@rpg-engine/shared';
|
|
10
9
|
|
|
11
10
|
import { observer } from 'mobx-react-lite';
|
|
12
|
-
import React, { useEffect,
|
|
13
|
-
import Draggable from 'react-draggable';
|
|
11
|
+
import React, { useEffect, useState } from 'react';
|
|
14
12
|
import styled from 'styled-components';
|
|
15
13
|
import { v4 as uuidv4 } from 'uuid';
|
|
16
14
|
import { uiFonts } from '../../../constants/uiFonts';
|
|
17
|
-
import { IPosition } from '../../../types/eventTypes';
|
|
18
15
|
import { RelativeListMenu } from '../../RelativeListMenu';
|
|
19
16
|
import { Ellipsis } from '../../shared/Ellipsis';
|
|
20
17
|
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
@@ -55,22 +52,6 @@ interface IProps {
|
|
|
55
52
|
itemContainerType: ItemContainerType | null,
|
|
56
53
|
item: IItem
|
|
57
54
|
) => void;
|
|
58
|
-
onDragStart: (
|
|
59
|
-
item: IItem,
|
|
60
|
-
slotIndex: number,
|
|
61
|
-
itemContainerType: ItemContainerType | null
|
|
62
|
-
) => void;
|
|
63
|
-
onDragEnd: (quantity?: number) => void;
|
|
64
|
-
onOutsideDrop?: (item: IItem, position: IPosition) => void;
|
|
65
|
-
dragScale?: number;
|
|
66
|
-
checkIfItemCanBeMoved: () => boolean;
|
|
67
|
-
checkIfItemShouldDragEnd?: () => boolean;
|
|
68
|
-
openQuantitySelector?: (maxQuantity: number, callback: () => void) => void;
|
|
69
|
-
onPlaceDrop: (
|
|
70
|
-
item: IItem | null,
|
|
71
|
-
slotIndex: number,
|
|
72
|
-
itemContainerType: ItemContainerType | null
|
|
73
|
-
) => void;
|
|
74
55
|
atlasJSON: any;
|
|
75
56
|
atlasIMG: any;
|
|
76
57
|
isContextMenuDisabled?: boolean;
|
|
@@ -89,57 +70,39 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
89
70
|
atlasJSON,
|
|
90
71
|
atlasIMG,
|
|
91
72
|
isContextMenuDisabled = false,
|
|
92
|
-
onDragEnd,
|
|
93
|
-
onDragStart,
|
|
94
|
-
onPlaceDrop,
|
|
95
|
-
onOutsideDrop: onDrop,
|
|
96
|
-
checkIfItemCanBeMoved,
|
|
97
|
-
openQuantitySelector,
|
|
98
|
-
checkIfItemShouldDragEnd,
|
|
99
|
-
dragScale,
|
|
100
73
|
}) => {
|
|
101
74
|
const [isTooltipVisible, setTooltipVisible] = useState(false);
|
|
102
75
|
|
|
103
76
|
const [isContextMenuVisible, setIsContextMenuVisible] = useState(false);
|
|
104
77
|
|
|
105
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
106
|
-
const [wasDragged, setWasDragged] = useState(false);
|
|
107
|
-
const [dragPosition, setDragPosition] = useState<IPosition>({ x: 0, y: 0 });
|
|
108
|
-
const [dropPosition, setDropPosition] = useState<IPosition | null>(null);
|
|
109
|
-
const dragContainer = useRef<HTMLDivElement>(null);
|
|
110
|
-
|
|
111
78
|
const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
|
|
112
79
|
[]
|
|
113
80
|
);
|
|
114
81
|
|
|
115
82
|
useEffect(() => {
|
|
116
|
-
setDragPosition({ x: 0, y: 0 });
|
|
117
|
-
setIsFocused(false);
|
|
118
|
-
|
|
119
83
|
if (item) {
|
|
120
84
|
setContextActions(generateContextMenu(item, containerType));
|
|
121
85
|
}
|
|
122
86
|
}, [item]);
|
|
123
87
|
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
if (onDrop && item && dropPosition) {
|
|
126
|
-
onDrop(item, dropPosition);
|
|
127
|
-
}
|
|
128
|
-
}, [dropPosition]);
|
|
129
|
-
|
|
130
88
|
const getStackInfo = (itemId: string, stackQty: number) => {
|
|
89
|
+
// if (itemToRender?.isStackable && itemToRender?.stackQty) {
|
|
90
|
+
|
|
131
91
|
const isFractionalStackQty = stackQty % 1 !== 0;
|
|
132
92
|
const isLargerThan999 = stackQty > 999;
|
|
133
93
|
|
|
134
|
-
let qtyClassName = 'regular';
|
|
135
|
-
if (isLargerThan999) qtyClassName = 'small';
|
|
136
|
-
if (isFractionalStackQty) qtyClassName = 'xsmall';
|
|
137
|
-
|
|
138
94
|
if (stackQty > 1) {
|
|
139
95
|
return (
|
|
140
96
|
<ItemQtyContainer key={`qty-${itemId}`}>
|
|
141
97
|
<Ellipsis maxLines={1} maxWidth="48px">
|
|
142
|
-
<ItemQty
|
|
98
|
+
<ItemQty
|
|
99
|
+
className={
|
|
100
|
+
isFractionalStackQty || isLargerThan999 ? 'small' : 'regular'
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
{' '}
|
|
104
|
+
{stackQty}{' '}
|
|
105
|
+
</ItemQty>
|
|
143
106
|
</Ellipsis>
|
|
144
107
|
</ItemQtyContainer>
|
|
145
108
|
);
|
|
@@ -149,7 +112,6 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
149
112
|
|
|
150
113
|
const renderItem = (itemToRender: IItem | null) => {
|
|
151
114
|
const element = [];
|
|
152
|
-
|
|
153
115
|
if (itemToRender?.texturePath) {
|
|
154
116
|
element.push(
|
|
155
117
|
<ErrorBoundary key={itemToRender._id}>
|
|
@@ -157,14 +119,7 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
157
119
|
key={itemToRender._id}
|
|
158
120
|
atlasIMG={atlasIMG}
|
|
159
121
|
atlasJSON={atlasJSON}
|
|
160
|
-
spriteKey={getItemTextureKeyPath(
|
|
161
|
-
{
|
|
162
|
-
key: itemToRender.texturePath,
|
|
163
|
-
texturePath: itemToRender.texturePath,
|
|
164
|
-
stackQty: itemToRender.stackQty || 1,
|
|
165
|
-
},
|
|
166
|
-
atlasJSON
|
|
167
|
-
)}
|
|
122
|
+
spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
|
|
168
123
|
imgScale={3}
|
|
169
124
|
/>
|
|
170
125
|
</ErrorBoundary>
|
|
@@ -187,21 +142,13 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
187
142
|
itemToRender.allowedEquipSlotType?.includes(slotSpriteMask!)
|
|
188
143
|
) {
|
|
189
144
|
const element = [];
|
|
190
|
-
|
|
191
145
|
element.push(
|
|
192
146
|
<ErrorBoundary key={itemToRender._id}>
|
|
193
147
|
<SpriteFromAtlas
|
|
194
148
|
key={itemToRender._id}
|
|
195
149
|
atlasIMG={atlasIMG}
|
|
196
150
|
atlasJSON={atlasJSON}
|
|
197
|
-
spriteKey={getItemTextureKeyPath(
|
|
198
|
-
{
|
|
199
|
-
key: itemToRender.texturePath,
|
|
200
|
-
texturePath: itemToRender.texturePath,
|
|
201
|
-
stackQty: itemToRender.stackQty || 1,
|
|
202
|
-
},
|
|
203
|
-
atlasJSON
|
|
204
|
-
)}
|
|
151
|
+
spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
|
|
205
152
|
imgScale={3}
|
|
206
153
|
/>
|
|
207
154
|
</ErrorBoundary>
|
|
@@ -242,144 +189,29 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
242
189
|
}
|
|
243
190
|
};
|
|
244
191
|
|
|
245
|
-
const resetItem = () => {
|
|
246
|
-
setTooltipVisible(false);
|
|
247
|
-
setWasDragged(false);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
const onSuccesfulDrag = (quantity?: number) => {
|
|
251
|
-
resetItem();
|
|
252
|
-
|
|
253
|
-
if (quantity === -1) setDragPosition({ x: 0, y: 0 });
|
|
254
|
-
else if (item) {
|
|
255
|
-
onDragEnd(quantity);
|
|
256
|
-
resetItem();
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
192
|
return (
|
|
261
193
|
<Container
|
|
262
|
-
item={item}
|
|
263
194
|
className="rpgui-icon empty-slot"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
195
|
+
onMouseOver={event =>
|
|
196
|
+
onMouseOver(event, slotIndex, item, event.clientX, event.clientY)
|
|
197
|
+
}
|
|
198
|
+
onMouseOut={() => {
|
|
199
|
+
if (onMouseOut) onMouseOut();
|
|
267
200
|
}}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
201
|
+
onMouseEnter={() => setTooltipVisible(true)}
|
|
202
|
+
onMouseLeave={() => setTooltipVisible(false)}
|
|
203
|
+
onClick={() => {
|
|
204
|
+
setTooltipVisible(false);
|
|
205
|
+
|
|
206
|
+
if (item) {
|
|
207
|
+
if (!isContextMenuDisabled) {
|
|
208
|
+
setIsContextMenuVisible(!isContextMenuVisible);
|
|
209
|
+
}
|
|
275
210
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
?.dispatchEvent(simulatedEvent);
|
|
211
|
+
onClick(item.type, containerType, item);
|
|
212
|
+
}
|
|
279
213
|
}}
|
|
280
214
|
>
|
|
281
|
-
<Draggable
|
|
282
|
-
defaultClassName={item ? 'draggable' : 'empty-slot'}
|
|
283
|
-
scale={dragScale}
|
|
284
|
-
onStop={(e, data) => {
|
|
285
|
-
if (wasDragged && item) {
|
|
286
|
-
//@ts-ignore
|
|
287
|
-
const classes: string[] = Array.from(e.target?.classList);
|
|
288
|
-
|
|
289
|
-
const isOutsideDrop =
|
|
290
|
-
classes.some(elm => {
|
|
291
|
-
return elm.includes('rpgui-content');
|
|
292
|
-
}) || classes.length === 0;
|
|
293
|
-
|
|
294
|
-
if (isOutsideDrop) {
|
|
295
|
-
setDropPosition({
|
|
296
|
-
x: data.x,
|
|
297
|
-
y: data.y,
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
setWasDragged(false);
|
|
302
|
-
|
|
303
|
-
const target = dragContainer.current;
|
|
304
|
-
if (!target || !wasDragged) return;
|
|
305
|
-
|
|
306
|
-
const style = window.getComputedStyle(target);
|
|
307
|
-
const matrix = new DOMMatrixReadOnly(style.transform);
|
|
308
|
-
const x = matrix.m41;
|
|
309
|
-
const y = matrix.m42;
|
|
310
|
-
|
|
311
|
-
setDragPosition({ x, y });
|
|
312
|
-
|
|
313
|
-
setTimeout(() => {
|
|
314
|
-
if (checkIfItemCanBeMoved()) {
|
|
315
|
-
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd())
|
|
316
|
-
return;
|
|
317
|
-
|
|
318
|
-
if (
|
|
319
|
-
item.stackQty &&
|
|
320
|
-
item.stackQty !== 1 &&
|
|
321
|
-
openQuantitySelector
|
|
322
|
-
)
|
|
323
|
-
openQuantitySelector(item.stackQty, onSuccesfulDrag);
|
|
324
|
-
else onSuccesfulDrag(item.stackQty);
|
|
325
|
-
} else {
|
|
326
|
-
resetItem();
|
|
327
|
-
setIsFocused(false);
|
|
328
|
-
setDragPosition({ x: 0, y: 0 });
|
|
329
|
-
}
|
|
330
|
-
}, 100);
|
|
331
|
-
} else if (item) {
|
|
332
|
-
if (!isContextMenuDisabled)
|
|
333
|
-
setIsContextMenuVisible(!isContextMenuVisible);
|
|
334
|
-
|
|
335
|
-
onClick(item.type, containerType, item);
|
|
336
|
-
}
|
|
337
|
-
}}
|
|
338
|
-
onStart={() => {
|
|
339
|
-
if (!item) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (onDragStart) {
|
|
344
|
-
onDragStart(item, slotIndex, containerType);
|
|
345
|
-
}
|
|
346
|
-
}}
|
|
347
|
-
onDrag={(_e, data) => {
|
|
348
|
-
if (
|
|
349
|
-
Math.abs(data.x - dragPosition.x) > 5 ||
|
|
350
|
-
Math.abs(data.y - dragPosition.y) > 5
|
|
351
|
-
) {
|
|
352
|
-
setWasDragged(true);
|
|
353
|
-
setIsFocused(true);
|
|
354
|
-
}
|
|
355
|
-
}}
|
|
356
|
-
position={dragPosition}
|
|
357
|
-
cancel=".empty-slot"
|
|
358
|
-
>
|
|
359
|
-
<ItemContainer
|
|
360
|
-
ref={dragContainer}
|
|
361
|
-
isFocused={isFocused}
|
|
362
|
-
onMouseOver={event => {
|
|
363
|
-
onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
|
|
364
|
-
}}
|
|
365
|
-
onMouseOut={() => {
|
|
366
|
-
if (onMouseOut) onMouseOut();
|
|
367
|
-
}}
|
|
368
|
-
onMouseEnter={() => {
|
|
369
|
-
setTooltipVisible(true);
|
|
370
|
-
}}
|
|
371
|
-
onMouseLeave={() => {
|
|
372
|
-
setTooltipVisible(false);
|
|
373
|
-
}}
|
|
374
|
-
>
|
|
375
|
-
{onRenderSlot(item)}
|
|
376
|
-
</ItemContainer>
|
|
377
|
-
</Draggable>
|
|
378
|
-
|
|
379
|
-
{isTooltipVisible && item && !isFocused && (
|
|
380
|
-
<ItemTooltip label={item.name} />
|
|
381
|
-
)}
|
|
382
|
-
|
|
383
215
|
{!isContextMenuDisabled && isContextMenuVisible && contextActions && (
|
|
384
216
|
<RelativeListMenu
|
|
385
217
|
options={contextActions}
|
|
@@ -394,60 +226,31 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
394
226
|
}}
|
|
395
227
|
/>
|
|
396
228
|
)}
|
|
229
|
+
|
|
230
|
+
{isTooltipVisible && item && <ItemTooltip label={item.name} />}
|
|
231
|
+
|
|
232
|
+
{onRenderSlot(item)}
|
|
397
233
|
</Container>
|
|
398
234
|
);
|
|
399
235
|
}
|
|
400
236
|
);
|
|
401
237
|
|
|
402
|
-
const
|
|
403
|
-
switch (item?.rarity) {
|
|
404
|
-
case ItemRarities.Uncommon:
|
|
405
|
-
return 'rgba(13, 193, 13, 0.6)';
|
|
406
|
-
case ItemRarities.Rare:
|
|
407
|
-
return 'rgba(8, 104, 187, 0.6)';
|
|
408
|
-
case ItemRarities.Epic:
|
|
409
|
-
return 'rgba(191, 0, 255, 0.6)';
|
|
410
|
-
case ItemRarities.Legendary:
|
|
411
|
-
return 'rgba(255, 191, 0,0.6)';
|
|
412
|
-
default:
|
|
413
|
-
return 'unset';
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
interface ContainerTypes {
|
|
418
|
-
item: IItem | null;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
const Container = styled.div<ContainerTypes>`
|
|
238
|
+
const Container = styled.div`
|
|
422
239
|
margin: 0.1rem;
|
|
423
240
|
.sprite-from-atlas-img {
|
|
424
241
|
position: relative;
|
|
425
242
|
top: 1.5rem;
|
|
426
243
|
left: 1.5rem;
|
|
427
|
-
border-color: ${({ item }) => rarityColor(item)};
|
|
428
|
-
box-shadow: ${({ item }) => `0 0 5px 2px ${rarityColor(item)}`} inset, ${({
|
|
429
|
-
item,
|
|
430
|
-
}) => `0 0 4px 3px ${rarityColor(item)}`};
|
|
431
|
-
//background-color: ${({ item }) => rarityColor(item)};
|
|
432
244
|
}
|
|
433
245
|
position: relative;
|
|
434
246
|
`;
|
|
435
247
|
|
|
436
|
-
const ItemContainer = styled.div<{ isFocused?: boolean }>`
|
|
437
|
-
width: 100%;
|
|
438
|
-
height: 100%;
|
|
439
|
-
position: relative;
|
|
440
|
-
|
|
441
|
-
${props => props.isFocused && 'z-index: 100; pointer-events: none;'}
|
|
442
|
-
`;
|
|
443
|
-
|
|
444
248
|
const ItemQtyContainer = styled.div`
|
|
445
249
|
position: relative;
|
|
446
250
|
width: 85%;
|
|
447
251
|
height: 16px;
|
|
448
252
|
top: 25px;
|
|
449
253
|
left: 2px;
|
|
450
|
-
pointer-events: none;
|
|
451
254
|
|
|
452
255
|
display: flex;
|
|
453
256
|
justify-content: flex-end;
|
|
@@ -460,7 +263,4 @@ const ItemQty = styled.span`
|
|
|
460
263
|
&.small {
|
|
461
264
|
font-size: ${uiFonts.size.xsmall};
|
|
462
265
|
}
|
|
463
|
-
&.xsmall {
|
|
464
|
-
font-size: ${uiFonts.size.xxsmall};
|
|
465
|
-
}
|
|
466
266
|
`;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { RPGUIContainer, RPGUIContainerTypes } from '../RPGUIContainer';
|
|
4
|
+
import aliceDefaultThumbnail from './img/npcDialog/npcThumbnails/alice.png';
|
|
5
|
+
import pressSpaceGif from './img/space.gif';
|
|
4
6
|
import { NPCDialogText } from './NPCDialogText';
|
|
5
7
|
import {
|
|
6
8
|
IQuestionDialog,
|
|
7
9
|
IQuestionDialogAnswer,
|
|
8
10
|
QuestionDialog,
|
|
9
11
|
} from './QuestionDialog/QuestionDialog';
|
|
10
|
-
import aliceDefaultThumbnail from './img/npcDialog/npcThumbnails/alice.png';
|
|
11
12
|
|
|
12
13
|
export enum NPCDialogType {
|
|
13
14
|
TextOnly = 'TextOnly',
|
|
@@ -33,10 +34,14 @@ export const NPCDialog: React.FC<INPCDialogProps> = ({
|
|
|
33
34
|
questions,
|
|
34
35
|
answers,
|
|
35
36
|
}) => {
|
|
37
|
+
const [showGoNextIndicator, setShowGoNextIndicator] = useState<boolean>(
|
|
38
|
+
false
|
|
39
|
+
);
|
|
40
|
+
|
|
36
41
|
return (
|
|
37
42
|
<RPGUIContainer
|
|
38
43
|
type={RPGUIContainerTypes.FramedGold}
|
|
39
|
-
width={isQuestionDialog ? '600px' : '
|
|
44
|
+
width={isQuestionDialog ? '600px' : '50%'}
|
|
40
45
|
height={'180px'}
|
|
41
46
|
>
|
|
42
47
|
{isQuestionDialog && questions && answers ? (
|
|
@@ -67,7 +72,8 @@ export const NPCDialog: React.FC<INPCDialogProps> = ({
|
|
|
67
72
|
flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}
|
|
68
73
|
>
|
|
69
74
|
<NPCDialogText
|
|
70
|
-
|
|
75
|
+
onStartStep={() => setShowGoNextIndicator(false)}
|
|
76
|
+
onEndStep={() => setShowGoNextIndicator(true)}
|
|
71
77
|
text={text || 'No text provided.'}
|
|
72
78
|
onClose={() => {
|
|
73
79
|
if (onClose) {
|
|
@@ -82,6 +88,12 @@ export const NPCDialog: React.FC<INPCDialogProps> = ({
|
|
|
82
88
|
</ThumbnailContainer>
|
|
83
89
|
)}
|
|
84
90
|
</Container>
|
|
91
|
+
{showGoNextIndicator && (
|
|
92
|
+
<PressSpaceIndicator
|
|
93
|
+
right={type === NPCDialogType.TextOnly ? '1rem' : '10.5rem'}
|
|
94
|
+
src={pressSpaceGif}
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
85
97
|
</>
|
|
86
98
|
)}
|
|
87
99
|
</RPGUIContainer>
|
|
@@ -119,3 +131,15 @@ const NPCThumbnail = styled.img`
|
|
|
119
131
|
height: 128px;
|
|
120
132
|
width: 128px;
|
|
121
133
|
`;
|
|
134
|
+
|
|
135
|
+
interface IPressSpaceIndicatorProps {
|
|
136
|
+
right: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const PressSpaceIndicator = styled.img<IPressSpaceIndicatorProps>`
|
|
140
|
+
position: absolute;
|
|
141
|
+
right: ${({ right }) => right};
|
|
142
|
+
bottom: 1rem;
|
|
143
|
+
height: 20.7px;
|
|
144
|
+
image-rendering: -webkit-optimize-contrast;
|
|
145
|
+
`;
|