@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { RPGUIRoot } from '../../src';
|
|
4
|
+
import {
|
|
5
|
+
IInputProps,
|
|
6
|
+
Input as InputComponent,
|
|
7
|
+
} from '../../src/components/Input';
|
|
8
|
+
import {
|
|
9
|
+
ITextArea,
|
|
10
|
+
TextArea as TextAreaComponent,
|
|
11
|
+
} from '../../src/components/TextArea';
|
|
12
|
+
|
|
13
|
+
const meta: Meta = {
|
|
14
|
+
title: 'Text',
|
|
15
|
+
component: InputComponent,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
const InputTemplate: Story<IInputProps> = args => (
|
|
21
|
+
<RPGUIRoot>
|
|
22
|
+
<InputComponent {...args} />
|
|
23
|
+
</RPGUIRoot>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const Input = InputTemplate.bind({});
|
|
27
|
+
|
|
28
|
+
Input.args = {
|
|
29
|
+
placeholder: 'Test placeholder',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const TextAreaTemplate: Story<ITextArea> = args => (
|
|
33
|
+
<RPGUIRoot>
|
|
34
|
+
<TextAreaComponent {...args} />
|
|
35
|
+
</RPGUIRoot>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const TextArea = TextAreaTemplate.bind({});
|
|
39
|
+
|
|
40
|
+
TextArea.args = {
|
|
41
|
+
placeholder: 'Test placeholder',
|
|
42
|
+
};
|
package/src/types/eventTypes.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface IPosition {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
}
|
|
1
|
+
export interface IPosition {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare module '*.gif';
|
|
2
|
-
declare module '*.png';
|
|
1
|
+
declare module '*.gif';
|
|
2
|
+
declare module '*.png';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { IItem, ItemSocketEvents, ItemType } from '@rpg-engine/shared';
|
|
2
|
-
import { IPosition } from '../../types/eventTypes';
|
|
3
|
-
import { IContextMenuItem } from '../Item/Inventory/itemContainerHelper';
|
|
4
|
-
import { SlotContainerType } from '../Item/Inventory/ItemSlot';
|
|
5
|
-
interface IContextMenu {
|
|
6
|
-
visible: boolean;
|
|
7
|
-
posX: number;
|
|
8
|
-
posY: number;
|
|
9
|
-
slotItem: IItem | null;
|
|
10
|
-
slotIndex?: number | null;
|
|
11
|
-
contextActions: IContextMenuItem[];
|
|
12
|
-
}
|
|
13
|
-
interface IHoverDetail {
|
|
14
|
-
visible: boolean;
|
|
15
|
-
posX: number;
|
|
16
|
-
posY: number;
|
|
17
|
-
item: IItem | null;
|
|
18
|
-
}
|
|
19
|
-
interface ISetContextMenu extends Omit<IContextMenu, 'contextActions'> {
|
|
20
|
-
}
|
|
21
|
-
declare class UIStore {
|
|
22
|
-
contextMenu: IContextMenu | null;
|
|
23
|
-
onHoverDetail: IHoverDetail | null;
|
|
24
|
-
draggablePosition: IPosition;
|
|
25
|
-
constructor();
|
|
26
|
-
setContextMenu(contextMenu: ISetContextMenu, itemType: ItemType): void;
|
|
27
|
-
setEquipContextMenu(contextMenu: ISetContextMenu, itemType: ItemType, isItemContainer: boolean | undefined): void;
|
|
28
|
-
clearContextMenu(): void;
|
|
29
|
-
setItemHoverDetail(hoverDetail: IHoverDetail): void;
|
|
30
|
-
clearItemHoverDetail(): void;
|
|
31
|
-
handleOnItemClick: (item: IItem, posX: number, posY: number, slotContainerType: SlotContainerType | null) => void;
|
|
32
|
-
handleOnMouseHover: (event: any, slotIndex: number, item: IItem | null, posX: number, posY: number, onMouseOver: any) => void;
|
|
33
|
-
onSelected(selectedActionId: ItemSocketEvents | string, onActionSelected: any): void;
|
|
34
|
-
setDraggablePosition(currentPosition: IPosition): void;
|
|
35
|
-
private getOffsets;
|
|
36
|
-
}
|
|
37
|
-
export declare const uiStore: UIStore;
|
|
38
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { IItem } from '@rpg-engine/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
item: IItem | null;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const ItemCard: React.FC<IProps> = ({ item, x, y }) => {
|
|
12
|
-
return (
|
|
13
|
-
<Container x={x} y={y}>
|
|
14
|
-
{item?.name}
|
|
15
|
-
</Container>
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
interface IContainerProps {
|
|
20
|
-
x?: number;
|
|
21
|
-
y?: number;
|
|
22
|
-
fontSize?: number;
|
|
23
|
-
}
|
|
24
|
-
const Container = styled.div<IContainerProps>`
|
|
25
|
-
position: absolute;
|
|
26
|
-
top: ${props => props.y || 0}px;
|
|
27
|
-
left: ${props => props.x || 0}px;
|
|
28
|
-
font-size: 0.5rem;
|
|
29
|
-
color: white;
|
|
30
|
-
background-color: black;
|
|
31
|
-
border-radius: 5px;
|
|
32
|
-
padding: 0.5rem;
|
|
33
|
-
min-width: 20px;
|
|
34
|
-
|
|
35
|
-
opacity: 0.5;
|
|
36
|
-
`;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import iconsAtlasJSON from '../../mocks/atlas/icons/icons.json';
|
|
4
|
-
import iconsAtlasIMG from '../../mocks/atlas/icons/icons.png';
|
|
5
|
-
import { SpriteFromAtlas } from './SpriteFromAtlas';
|
|
6
|
-
|
|
7
|
-
interface IProps {
|
|
8
|
-
onClick?: () => void;
|
|
9
|
-
spriteKey: string;
|
|
10
|
-
baseSpriteKey?: string;
|
|
11
|
-
imgStyle?: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const SpriteIcon: React.FC<IProps> = ({
|
|
15
|
-
onClick,
|
|
16
|
-
spriteKey,
|
|
17
|
-
baseSpriteKey,
|
|
18
|
-
imgStyle,
|
|
19
|
-
}) => {
|
|
20
|
-
return (
|
|
21
|
-
<Container>
|
|
22
|
-
{baseSpriteKey && (
|
|
23
|
-
<Slot>
|
|
24
|
-
<SpriteFromAtlas
|
|
25
|
-
onClick={onClick}
|
|
26
|
-
atlasJSON={iconsAtlasJSON}
|
|
27
|
-
atlasIMG={iconsAtlasIMG}
|
|
28
|
-
spriteKey={baseSpriteKey}
|
|
29
|
-
width={32}
|
|
30
|
-
height={32}
|
|
31
|
-
containerStyle={{
|
|
32
|
-
zIndex: -1,
|
|
33
|
-
}}
|
|
34
|
-
/>
|
|
35
|
-
</Slot>
|
|
36
|
-
)}
|
|
37
|
-
<Slot>
|
|
38
|
-
<SpriteFromAtlas
|
|
39
|
-
onClick={onClick}
|
|
40
|
-
atlasJSON={iconsAtlasJSON}
|
|
41
|
-
atlasIMG={iconsAtlasIMG}
|
|
42
|
-
spriteKey={spriteKey}
|
|
43
|
-
width={28}
|
|
44
|
-
height={28}
|
|
45
|
-
containerStyle={{
|
|
46
|
-
zIndex: 0,
|
|
47
|
-
}}
|
|
48
|
-
imgScale={baseSpriteKey ? 1.5 : 2}
|
|
49
|
-
imgStyle={imgStyle}
|
|
50
|
-
/>
|
|
51
|
-
</Slot>
|
|
52
|
-
</Container>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const Container = styled.div`
|
|
57
|
-
position: relative;
|
|
58
|
-
width: 32px;
|
|
59
|
-
height: 32px;
|
|
60
|
-
display: flex;
|
|
61
|
-
justify-content: center;
|
|
62
|
-
align-items: center;
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
const Slot = styled.div`
|
|
66
|
-
position: absolute;
|
|
67
|
-
`;
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IItem,
|
|
3
|
-
IPayloadProps,
|
|
4
|
-
ItemSocketEvents,
|
|
5
|
-
ItemSocketEventsDisplayLabels,
|
|
6
|
-
ItemType,
|
|
7
|
-
} from '@rpg-engine/shared';
|
|
8
|
-
import { makeAutoObservable, toJS } from 'mobx';
|
|
9
|
-
import { IPosition } from '../../types/eventTypes';
|
|
10
|
-
import {
|
|
11
|
-
handleContextMenuList,
|
|
12
|
-
handleEquipmentContextMenuList,
|
|
13
|
-
IContextMenuItem,
|
|
14
|
-
} from '../Item/Inventory/itemContainerHelper';
|
|
15
|
-
import { SlotContainerType } from '../Item/Inventory/ItemSlot';
|
|
16
|
-
|
|
17
|
-
interface IContextMenu {
|
|
18
|
-
visible: boolean;
|
|
19
|
-
posX: number;
|
|
20
|
-
posY: number;
|
|
21
|
-
slotItem: IItem | null;
|
|
22
|
-
slotIndex?: number | null;
|
|
23
|
-
contextActions: IContextMenuItem[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface IHoverDetail {
|
|
27
|
-
visible: boolean;
|
|
28
|
-
posX: number;
|
|
29
|
-
posY: number;
|
|
30
|
-
item: IItem | null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface ISetContextMenu extends Omit<IContextMenu, 'contextActions'> {}
|
|
34
|
-
|
|
35
|
-
const initialState = {
|
|
36
|
-
visible: false,
|
|
37
|
-
posX: 0,
|
|
38
|
-
posY: 0,
|
|
39
|
-
contextActions: [],
|
|
40
|
-
slotItem: null,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const initialHoverState = {
|
|
44
|
-
visible: false,
|
|
45
|
-
posX: 0,
|
|
46
|
-
posY: 0,
|
|
47
|
-
item: null,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const initialPosition = {
|
|
51
|
-
x: 0,
|
|
52
|
-
y: 0
|
|
53
|
-
}
|
|
54
|
-
class UIStore {
|
|
55
|
-
public contextMenu: IContextMenu | null = initialState;
|
|
56
|
-
public onHoverDetail: IHoverDetail | null = initialHoverState;
|
|
57
|
-
|
|
58
|
-
public draggablePosition: IPosition = initialPosition;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
constructor() {
|
|
62
|
-
makeAutoObservable(this);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public setContextMenu(contextMenu: ISetContextMenu, itemType: ItemType) {
|
|
66
|
-
const contextActions = handleContextMenuList(itemType);
|
|
67
|
-
|
|
68
|
-
this.contextMenu = {
|
|
69
|
-
...contextMenu,
|
|
70
|
-
contextActions,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
console.log(toJS(this.contextMenu));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public setEquipContextMenu(
|
|
77
|
-
contextMenu: ISetContextMenu,
|
|
78
|
-
itemType: ItemType,
|
|
79
|
-
isItemContainer: boolean | undefined
|
|
80
|
-
) {
|
|
81
|
-
const contextActions = handleEquipmentContextMenuList(itemType);
|
|
82
|
-
if (isItemContainer)
|
|
83
|
-
contextActions.push({
|
|
84
|
-
id: ItemSocketEvents.ContainerOpen,
|
|
85
|
-
text: ItemSocketEventsDisplayLabels[ItemSocketEvents.ContainerOpen],
|
|
86
|
-
});
|
|
87
|
-
this.contextMenu = {
|
|
88
|
-
...contextMenu,
|
|
89
|
-
contextActions,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
console.log(toJS(this.contextMenu));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public clearContextMenu() {
|
|
96
|
-
this.contextMenu = initialState;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public setItemHoverDetail(hoverDetail: IHoverDetail) {
|
|
100
|
-
if (hoverDetail?.item === null) this.clearItemHoverDetail();
|
|
101
|
-
|
|
102
|
-
this.onHoverDetail = {
|
|
103
|
-
...hoverDetail,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public clearItemHoverDetail() {
|
|
108
|
-
this.onHoverDetail = initialHoverState;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public handleOnItemClick = (
|
|
112
|
-
item: IItem,
|
|
113
|
-
posX: number,
|
|
114
|
-
posY: number,
|
|
115
|
-
slotContainerType: SlotContainerType | null
|
|
116
|
-
): void => {
|
|
117
|
-
if (
|
|
118
|
-
!item ||
|
|
119
|
-
JSON.stringify(this.contextMenu?.slotItem) === JSON.stringify(item)
|
|
120
|
-
) {
|
|
121
|
-
this.clearContextMenu();
|
|
122
|
-
this.clearItemHoverDetail();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this.setDraggablePosition(this.getOffsets())
|
|
127
|
-
|
|
128
|
-
switch (slotContainerType) {
|
|
129
|
-
case SlotContainerType.EQUIPMENT_SET:
|
|
130
|
-
this.setEquipContextMenu(
|
|
131
|
-
{
|
|
132
|
-
visible: true,
|
|
133
|
-
posX,
|
|
134
|
-
posY,
|
|
135
|
-
slotItem: item,
|
|
136
|
-
},
|
|
137
|
-
item.type,
|
|
138
|
-
item.isItemContainer
|
|
139
|
-
);
|
|
140
|
-
break;
|
|
141
|
-
case SlotContainerType.INVENTORY:
|
|
142
|
-
this.setContextMenu(
|
|
143
|
-
{
|
|
144
|
-
visible: true,
|
|
145
|
-
posX,
|
|
146
|
-
posY,
|
|
147
|
-
slotItem: item,
|
|
148
|
-
},
|
|
149
|
-
item.type
|
|
150
|
-
);
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
this.setContextMenu(
|
|
154
|
-
{
|
|
155
|
-
visible: true,
|
|
156
|
-
posX,
|
|
157
|
-
posY,
|
|
158
|
-
slotItem: item,
|
|
159
|
-
},
|
|
160
|
-
item.type
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
this.clearItemHoverDetail();
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
public handleOnMouseHover = (
|
|
168
|
-
event: any,
|
|
169
|
-
slotIndex: number,
|
|
170
|
-
item: IItem | null,
|
|
171
|
-
posX: number,
|
|
172
|
-
posY: number,
|
|
173
|
-
onMouseOver: any
|
|
174
|
-
): void => {
|
|
175
|
-
if (item) {
|
|
176
|
-
this.setDraggablePosition(this.getOffsets())
|
|
177
|
-
this.setItemHoverDetail({
|
|
178
|
-
visible: true,
|
|
179
|
-
posX: posX,
|
|
180
|
-
posY: posY,
|
|
181
|
-
item: item,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if (onMouseOver) {
|
|
185
|
-
onMouseOver(event, slotIndex, item);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
public onSelected(
|
|
190
|
-
selectedActionId: ItemSocketEvents | string,
|
|
191
|
-
onActionSelected: any
|
|
192
|
-
) {
|
|
193
|
-
let payloadData: IPayloadProps = {
|
|
194
|
-
actionType: selectedActionId,
|
|
195
|
-
item: this.contextMenu?.slotItem!,
|
|
196
|
-
};
|
|
197
|
-
if (onActionSelected) {
|
|
198
|
-
onActionSelected(payloadData);
|
|
199
|
-
}
|
|
200
|
-
this.clearContextMenu!();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public setDraggablePosition(currentPosition: IPosition){
|
|
204
|
-
this.draggablePosition = { ...currentPosition }
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private getOffsets = () => {
|
|
208
|
-
const p = { x: 0, y: 0};
|
|
209
|
-
// const body = document.getElementsByTagName('body')
|
|
210
|
-
let body = document.querySelector('body') as any | null;
|
|
211
|
-
|
|
212
|
-
if( body != null){
|
|
213
|
-
p.x = body.offsetLeft;
|
|
214
|
-
p.y = body.offsetTop;
|
|
215
|
-
while(body!.offsetParent){
|
|
216
|
-
console.log(`offsetParent: ${body!.offsetParent}`)
|
|
217
|
-
p.x = p.x + body!.offsetLeft
|
|
218
|
-
p.y = p.y + body!.offsetTop;
|
|
219
|
-
if (body == document.getElementsByTagName("body")[0]) {
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
body = body!.offsetParent;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return p;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export const uiStore = new UIStore();
|