@rpg-engine/long-bow 0.4.2 → 0.4.3
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/long-bow.cjs.development.js +1060 -1065
- 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 +1066 -1071
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +100 -100
- package/src/components/Abstractions/ModalPortal.tsx +22 -22
- package/src/components/Abstractions/SlotsContainer.tsx +62 -62
- package/src/components/Arrow/SelectArrow.tsx +69 -69
- package/src/components/Arrow/img/arrow01-left-clicked.png +0 -0
- package/src/components/Arrow/img/arrow01-left.png +0 -0
- package/src/components/Arrow/img/arrow01-right-clicked.png +0 -0
- package/src/components/Arrow/img/arrow01-right.png +0 -0
- package/src/components/Arrow/img/arrow02-left-clicked.png +0 -0
- package/src/components/Arrow/img/arrow02-left.png +0 -0
- package/src/components/Arrow/img/arrow02-right-clicked.png +0 -0
- package/src/components/Arrow/img/arrow02-right.png +0 -0
- package/src/components/Button.tsx +40 -40
- package/src/components/Character/CharacterSelection.tsx +98 -98
- package/src/components/CharacterStatus/CharacterStatus.tsx +120 -120
- package/src/components/Chat/Chat.tsx +196 -196
- package/src/components/Chatdeprecated/ChatDeprecated.tsx +198 -198
- package/src/components/CheckButton.tsx +65 -65
- package/src/components/CircularController/CircularController.tsx +282 -282
- package/src/components/CraftBook/CraftBook.tsx +286 -286
- package/src/components/CraftBook/CraftingRecipe.tsx +161 -161
- package/src/components/CraftBook/MockItems.ts +101 -101
- package/src/components/DraggableContainer.tsx +181 -180
- package/src/components/DropdownSelectorContainer.tsx +42 -42
- package/src/components/Equipment/EquipmentSet.tsx +199 -199
- package/src/components/HistoryDialog.tsx +104 -104
- package/src/components/Input.tsx +15 -15
- package/src/components/InputRadio.tsx +41 -41
- package/src/components/Item/Cards/ItemInfo.tsx +298 -298
- package/src/components/Item/Cards/ItemInfoDisplay.tsx +135 -135
- package/src/components/Item/Cards/ItemInfoWrapper.tsx +62 -62
- package/src/components/Item/Cards/ItemTooltip.tsx +83 -83
- package/src/components/Item/Cards/MobileItemTooltip.tsx +149 -149
- package/src/components/Item/Inventory/ErrorBoundary.tsx +42 -42
- package/src/components/Item/Inventory/ItemContainer.tsx +231 -231
- package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -6
- package/src/components/Item/Inventory/ItemQuantitySelector.tsx +138 -138
- package/src/components/Item/Inventory/ItemSlot.tsx +580 -580
- package/src/components/Item/Inventory/itemContainerHelper.ts +175 -175
- package/src/components/ListMenu.tsx +63 -63
- package/src/components/Marketplace/Marketplace.tsx +132 -132
- package/src/components/Marketplace/MarketplaceRows.tsx +171 -171
- package/src/components/Marketplace/__mocks__/index.tsx +65 -65
- package/src/components/Multitab/Tab.tsx +66 -66
- package/src/components/Multitab/TabBody.tsx +13 -13
- package/src/components/Multitab/TabsContainer.tsx +97 -97
- package/src/components/NPCDialog/NPCDialog.tsx +121 -121
- package/src/components/NPCDialog/NPCDialogText.tsx +113 -113
- package/src/components/NPCDialog/NPCMultiDialog.tsx +159 -159
- package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -237
- package/src/components/ProgressBar.tsx +92 -95
- package/src/components/PropertySelect/PropertySelect.tsx +106 -106
- package/src/components/QuestInfo/QuestInfo.tsx +233 -233
- package/src/components/QuestList.tsx +135 -135
- package/src/components/RPGUIContainer.tsx +47 -47
- package/src/components/RPGUIForceRenderStart.tsx +45 -45
- package/src/components/RPGUIRoot.tsx +14 -14
- package/src/components/RadioButton.tsx +53 -53
- package/src/components/RadioInput/RadioButton.tsx +96 -96
- package/src/components/RadioInput/RadioInput.tsx +102 -102
- package/src/components/RadioInput/instruments.ts +15 -15
- package/src/components/RangeSlider.tsx +78 -78
- package/src/components/RelativeListMenu.tsx +90 -90
- package/src/components/ScrollList.tsx +79 -79
- package/src/components/Shortcuts/Shortcuts.tsx +193 -193
- package/src/components/Shortcuts/ShortcutsSetter.tsx +139 -139
- package/src/components/Shortcuts/SingleShortcut.ts +82 -82
- package/src/components/Shortcuts/useShortcutCooldown.ts +23 -23
- package/src/components/SimpleProgressBar.tsx +62 -62
- package/src/components/SkillProgressBar.tsx +133 -133
- package/src/components/SkillsContainer.tsx +217 -211
- package/src/components/Spellbook/Spell.tsx +236 -236
- package/src/components/Spellbook/Spellbook.tsx +161 -161
- package/src/components/Spellbook/cards/MobileSpellTooltip.tsx +137 -137
- package/src/components/Spellbook/cards/SpellInfo.tsx +134 -134
- package/src/components/Spellbook/cards/SpellInfoDisplay.tsx +31 -31
- package/src/components/Spellbook/cards/SpellInfoWrapper.tsx +48 -48
- package/src/components/Spellbook/cards/SpellTooltip.tsx +70 -70
- package/src/components/Spellbook/constants.ts +7 -7
- package/src/components/Spellbook/mockSpells.ts +84 -84
- package/src/components/StaticBook/StaticBook.tsx +103 -103
- package/src/components/TextArea.tsx +11 -11
- package/src/components/TimeWidget/DayNightPeriod/DayNightPeriod.tsx +35 -35
- package/src/components/TimeWidget/TimeWidget.tsx +65 -65
- package/src/components/TradingMenu/TradingItemRow.tsx +199 -199
- package/src/components/TradingMenu/TradingMenu.tsx +219 -219
- package/src/components/TradingMenu/items.mock.ts +48 -48
- package/src/components/Truncate.tsx +25 -25
- package/src/components/itemSelector/ItemSelector.tsx +136 -136
- package/src/components/shared/Column.tsx +16 -16
- package/src/components/shared/Ellipsis.tsx +68 -68
- package/src/components/shared/SpriteFromAtlas.tsx +104 -104
- package/src/components/typography/DynamicText.tsx +49 -49
- package/src/constants/uiColors.ts +20 -20
- package/src/constants/uiDevices.ts +3 -3
- package/src/constants/uiFonts.ts +12 -12
- package/src/hooks/useEventListener.ts +21 -21
- package/src/hooks/useOutsideAlerter.ts +25 -25
- package/src/index.tsx +42 -42
- package/src/libs/CastingTypeHelper.ts +7 -7
- package/src/libs/StringHelpers.ts +3 -3
- package/src/libs/itemCounter.ts +21 -21
- package/src/mocks/atlas/entities/entities.json +20215 -20215
- package/src/mocks/atlas/icons/icons.json +735 -735
- package/src/mocks/atlas/items/items.json +12086 -12086
- package/src/mocks/equipmentSet.mocks.ts +391 -391
- package/src/mocks/itemContainer.mocks.ts +605 -605
- package/src/mocks/skills.mocks.ts +128 -128
- package/src/stories/Arrow.stories.tsx +26 -26
- package/src/stories/Button.stories.tsx +36 -36
- package/src/stories/CharacterSelection.stories.tsx +44 -44
- package/src/stories/CharacterStatus.stories.tsx +29 -29
- package/src/stories/Chat.stories.tsx +187 -187
- package/src/stories/ChatDeprecated.stories.tsx +170 -170
- package/src/stories/CheckButton.stories.tsx +48 -48
- package/src/stories/CircullarController.stories.tsx +37 -37
- package/src/stories/CraftBook.stories.tsx +42 -42
- package/src/stories/DayNightPeriod.stories.tsx +27 -27
- package/src/stories/DraggableContainer.stories.tsx +28 -28
- package/src/stories/Dropdown.stories.tsx +46 -46
- package/src/stories/DropdownSelectorContainer.stories.tsx +41 -41
- package/src/stories/EquipmentSet.stories.tsx +65 -65
- package/src/stories/HistoryDialog.stories.tsx +61 -61
- package/src/stories/ItemContainer.stories.tsx +201 -201
- package/src/stories/ItemInfoDisplay.stories.tsx +33 -33
- package/src/stories/ItemQuantitySelector.stories.tsx +26 -26
- package/src/stories/ItemSelector.stories.tsx +77 -77
- package/src/stories/ItemTradingComponent.stories.tsx +35 -35
- package/src/stories/ListMenu.stories.tsx +56 -56
- package/src/stories/Marketplace.stories.tsx +42 -42
- package/src/stories/MarketplaceRows.stories.tsx +28 -28
- package/src/stories/Multitab.stories.tsx +51 -51
- package/src/stories/NPCDialog.stories.tsx +130 -130
- package/src/stories/NPCMultiDialog.stories.tsx +71 -71
- package/src/stories/ProgressBar.stories.tsx +23 -23
- package/src/stories/PropertySelect.stories.tsx +40 -40
- package/src/stories/QuestInfo.stories.tsx +107 -107
- package/src/stories/QuestList.stories.tsx +82 -82
- package/src/stories/RPGUIContainers.stories.tsx +42 -42
- package/src/stories/RadioButton.stories.tsx +49 -49
- package/src/stories/RadioInput.stories.tsx +34 -34
- package/src/stories/RangeSlider.stories.tsx +64 -64
- package/src/stories/ScrollList.stories.tsx +85 -85
- package/src/stories/Shortcuts.stories.tsx +39 -39
- package/src/stories/SimpleProgressBar.stories.tsx +22 -22
- package/src/stories/SkillProgressBar.stories.tsx +34 -34
- package/src/stories/SkillsContainer.stories.tsx +35 -35
- package/src/stories/SpellInfoDisplay.stories.tsx +27 -27
- package/src/stories/Spellbook.stories.tsx +104 -104
- package/src/stories/StaticBook.stories.tsx +32 -32
- package/src/stories/Text.stories.tsx +42 -42
- package/src/stories/TimeWidget.stories.tsx +27 -27
- package/src/stories/TradingMenu.stories.tsx +47 -47
- package/src/types/eventTypes.ts +4 -4
- package/src/types/index.d.ts +2 -2
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import { IShortcut, ISpell } from '@rpg-engine/shared';
|
|
2
|
-
import React, { Fragment, useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { uiFonts } from '../../constants/uiFonts';
|
|
5
|
-
import { DraggableContainer } from '../DraggableContainer';
|
|
6
|
-
import { Input } from '../Input';
|
|
7
|
-
import { RPGUIContainerTypes } from '../RPGUIContainer';
|
|
8
|
-
import { ShortcutsSetter } from '../Shortcuts/ShortcutsSetter';
|
|
9
|
-
import { Spell } from './Spell';
|
|
10
|
-
|
|
11
|
-
export interface ISpellbookProps {
|
|
12
|
-
onClose?: () => void;
|
|
13
|
-
onInputFocus?: () => void;
|
|
14
|
-
onInputBlur?: () => void;
|
|
15
|
-
spells: ISpell[];
|
|
16
|
-
magicLevel: number;
|
|
17
|
-
mana: number;
|
|
18
|
-
onSpellClick: (spellKey: string) => void;
|
|
19
|
-
setSpellShortcut: (key: string, index: number) => void;
|
|
20
|
-
shortcuts: IShortcut[];
|
|
21
|
-
removeShortcut: (index: number) => void;
|
|
22
|
-
atlasIMG: any;
|
|
23
|
-
atlasJSON: any;
|
|
24
|
-
scale?: number;
|
|
25
|
-
spellCooldowns?: Record<string, number>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const Spellbook: React.FC<ISpellbookProps> = ({
|
|
29
|
-
onClose,
|
|
30
|
-
onInputFocus,
|
|
31
|
-
onInputBlur,
|
|
32
|
-
spells,
|
|
33
|
-
magicLevel,
|
|
34
|
-
mana,
|
|
35
|
-
onSpellClick,
|
|
36
|
-
setSpellShortcut,
|
|
37
|
-
shortcuts,
|
|
38
|
-
removeShortcut,
|
|
39
|
-
atlasIMG,
|
|
40
|
-
atlasJSON,
|
|
41
|
-
scale,
|
|
42
|
-
spellCooldowns,
|
|
43
|
-
}) => {
|
|
44
|
-
const [search, setSearch] = useState('');
|
|
45
|
-
const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const handleEscapeClose = (e: KeyboardEvent) => {
|
|
49
|
-
if (e.key === 'Escape') {
|
|
50
|
-
onClose?.();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
document.addEventListener('keydown', handleEscapeClose);
|
|
55
|
-
|
|
56
|
-
return () => {
|
|
57
|
-
document.removeEventListener('keydown', handleEscapeClose);
|
|
58
|
-
};
|
|
59
|
-
}, [onClose]);
|
|
60
|
-
|
|
61
|
-
const spellsToDisplay = useMemo(() => {
|
|
62
|
-
return spells
|
|
63
|
-
.sort((a, b) => {
|
|
64
|
-
if (a.minMagicLevelRequired > b.minMagicLevelRequired) return 1;
|
|
65
|
-
if (a.minMagicLevelRequired < b.minMagicLevelRequired) return -1;
|
|
66
|
-
return 0;
|
|
67
|
-
})
|
|
68
|
-
.filter(
|
|
69
|
-
spell =>
|
|
70
|
-
spell.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) ||
|
|
71
|
-
spell.magicWords
|
|
72
|
-
.toLocaleLowerCase()
|
|
73
|
-
.includes(search.toLocaleLowerCase())
|
|
74
|
-
);
|
|
75
|
-
}, [search, spells]);
|
|
76
|
-
|
|
77
|
-
const setShortcut = (spellKey: string) => {
|
|
78
|
-
setSpellShortcut?.(spellKey, settingShortcutIndex);
|
|
79
|
-
setSettingShortcutIndex(-1);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<DraggableContainer
|
|
84
|
-
type={RPGUIContainerTypes.Framed}
|
|
85
|
-
onCloseButton={onClose}
|
|
86
|
-
width="inherit"
|
|
87
|
-
height="inherit"
|
|
88
|
-
cancelDrag="#spellbook-search, #shortcuts_list, .spell"
|
|
89
|
-
scale={scale}
|
|
90
|
-
>
|
|
91
|
-
<Container>
|
|
92
|
-
<Title>Learned Spells</Title>
|
|
93
|
-
|
|
94
|
-
<ShortcutsSetter
|
|
95
|
-
setSettingShortcutIndex={setSettingShortcutIndex}
|
|
96
|
-
settingShortcutIndex={settingShortcutIndex}
|
|
97
|
-
shortcuts={shortcuts}
|
|
98
|
-
removeShortcut={removeShortcut}
|
|
99
|
-
atlasIMG={atlasIMG}
|
|
100
|
-
atlasJSON={atlasJSON}
|
|
101
|
-
/>
|
|
102
|
-
|
|
103
|
-
<Input
|
|
104
|
-
placeholder="Search for spell"
|
|
105
|
-
value={search}
|
|
106
|
-
onChange={e => setSearch(e.target.value)}
|
|
107
|
-
onFocus={onInputFocus}
|
|
108
|
-
onBlur={onInputBlur}
|
|
109
|
-
id="spellbook-search"
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
<SpellList>
|
|
113
|
-
{spellsToDisplay.map(spell => (
|
|
114
|
-
<Fragment key={spell.key}>
|
|
115
|
-
<Spell
|
|
116
|
-
charMana={mana}
|
|
117
|
-
charMagicLevel={magicLevel}
|
|
118
|
-
onPointerUp={
|
|
119
|
-
settingShortcutIndex !== -1 ? setShortcut : onSpellClick
|
|
120
|
-
}
|
|
121
|
-
spellKey={spell.key}
|
|
122
|
-
isSettingShortcut={settingShortcutIndex !== -1}
|
|
123
|
-
spell={spell}
|
|
124
|
-
activeCooldown={
|
|
125
|
-
spellCooldowns?.[spell.magicWords.replaceAll(' ', '_')]
|
|
126
|
-
}
|
|
127
|
-
{...spell}
|
|
128
|
-
/>
|
|
129
|
-
</Fragment>
|
|
130
|
-
))}
|
|
131
|
-
</SpellList>
|
|
132
|
-
</Container>
|
|
133
|
-
</DraggableContainer>
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const Title = styled.h1`
|
|
138
|
-
font-size: ${uiFonts.size.large} !important;
|
|
139
|
-
margin-bottom: 0 !important;
|
|
140
|
-
|
|
141
|
-
`;
|
|
142
|
-
|
|
143
|
-
const Container = styled.div`
|
|
144
|
-
width: 100%;
|
|
145
|
-
height: 100%;
|
|
146
|
-
color: white;
|
|
147
|
-
display: flex;
|
|
148
|
-
flex-direction: column;
|
|
149
|
-
|
|
150
|
-
`;
|
|
151
|
-
|
|
152
|
-
const SpellList = styled.div`
|
|
153
|
-
width: 100%;
|
|
154
|
-
min-height: 0;
|
|
155
|
-
flex: 1;
|
|
156
|
-
overflow-y: auto;
|
|
157
|
-
display: flex;
|
|
158
|
-
flex-direction: column;
|
|
159
|
-
gap: 1.5rem;
|
|
160
|
-
margin-top: 1rem;
|
|
161
|
-
`;
|
|
1
|
+
import { IShortcut, ISpell } from '@rpg-engine/shared';
|
|
2
|
+
import React, { Fragment, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { uiFonts } from '../../constants/uiFonts';
|
|
5
|
+
import { DraggableContainer } from '../DraggableContainer';
|
|
6
|
+
import { Input } from '../Input';
|
|
7
|
+
import { RPGUIContainerTypes } from '../RPGUIContainer';
|
|
8
|
+
import { ShortcutsSetter } from '../Shortcuts/ShortcutsSetter';
|
|
9
|
+
import { Spell } from './Spell';
|
|
10
|
+
|
|
11
|
+
export interface ISpellbookProps {
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
onInputFocus?: () => void;
|
|
14
|
+
onInputBlur?: () => void;
|
|
15
|
+
spells: ISpell[];
|
|
16
|
+
magicLevel: number;
|
|
17
|
+
mana: number;
|
|
18
|
+
onSpellClick: (spellKey: string) => void;
|
|
19
|
+
setSpellShortcut: (key: string, index: number) => void;
|
|
20
|
+
shortcuts: IShortcut[];
|
|
21
|
+
removeShortcut: (index: number) => void;
|
|
22
|
+
atlasIMG: any;
|
|
23
|
+
atlasJSON: any;
|
|
24
|
+
scale?: number;
|
|
25
|
+
spellCooldowns?: Record<string, number>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Spellbook: React.FC<ISpellbookProps> = ({
|
|
29
|
+
onClose,
|
|
30
|
+
onInputFocus,
|
|
31
|
+
onInputBlur,
|
|
32
|
+
spells,
|
|
33
|
+
magicLevel,
|
|
34
|
+
mana,
|
|
35
|
+
onSpellClick,
|
|
36
|
+
setSpellShortcut,
|
|
37
|
+
shortcuts,
|
|
38
|
+
removeShortcut,
|
|
39
|
+
atlasIMG,
|
|
40
|
+
atlasJSON,
|
|
41
|
+
scale,
|
|
42
|
+
spellCooldowns,
|
|
43
|
+
}) => {
|
|
44
|
+
const [search, setSearch] = useState('');
|
|
45
|
+
const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const handleEscapeClose = (e: KeyboardEvent) => {
|
|
49
|
+
if (e.key === 'Escape') {
|
|
50
|
+
onClose?.();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
document.addEventListener('keydown', handleEscapeClose);
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
document.removeEventListener('keydown', handleEscapeClose);
|
|
58
|
+
};
|
|
59
|
+
}, [onClose]);
|
|
60
|
+
|
|
61
|
+
const spellsToDisplay = useMemo(() => {
|
|
62
|
+
return spells
|
|
63
|
+
.sort((a, b) => {
|
|
64
|
+
if (a.minMagicLevelRequired > b.minMagicLevelRequired) return 1;
|
|
65
|
+
if (a.minMagicLevelRequired < b.minMagicLevelRequired) return -1;
|
|
66
|
+
return 0;
|
|
67
|
+
})
|
|
68
|
+
.filter(
|
|
69
|
+
spell =>
|
|
70
|
+
spell.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) ||
|
|
71
|
+
spell.magicWords
|
|
72
|
+
.toLocaleLowerCase()
|
|
73
|
+
.includes(search.toLocaleLowerCase())
|
|
74
|
+
);
|
|
75
|
+
}, [search, spells]);
|
|
76
|
+
|
|
77
|
+
const setShortcut = (spellKey: string) => {
|
|
78
|
+
setSpellShortcut?.(spellKey, settingShortcutIndex);
|
|
79
|
+
setSettingShortcutIndex(-1);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<DraggableContainer
|
|
84
|
+
type={RPGUIContainerTypes.Framed}
|
|
85
|
+
onCloseButton={onClose}
|
|
86
|
+
width="inherit"
|
|
87
|
+
height="inherit"
|
|
88
|
+
cancelDrag="#spellbook-search, #shortcuts_list, .spell"
|
|
89
|
+
scale={scale}
|
|
90
|
+
>
|
|
91
|
+
<Container>
|
|
92
|
+
<Title>Learned Spells</Title>
|
|
93
|
+
|
|
94
|
+
<ShortcutsSetter
|
|
95
|
+
setSettingShortcutIndex={setSettingShortcutIndex}
|
|
96
|
+
settingShortcutIndex={settingShortcutIndex}
|
|
97
|
+
shortcuts={shortcuts}
|
|
98
|
+
removeShortcut={removeShortcut}
|
|
99
|
+
atlasIMG={atlasIMG}
|
|
100
|
+
atlasJSON={atlasJSON}
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<Input
|
|
104
|
+
placeholder="Search for spell"
|
|
105
|
+
value={search}
|
|
106
|
+
onChange={e => setSearch(e.target.value)}
|
|
107
|
+
onFocus={onInputFocus}
|
|
108
|
+
onBlur={onInputBlur}
|
|
109
|
+
id="spellbook-search"
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<SpellList>
|
|
113
|
+
{spellsToDisplay.map(spell => (
|
|
114
|
+
<Fragment key={spell.key}>
|
|
115
|
+
<Spell
|
|
116
|
+
charMana={mana}
|
|
117
|
+
charMagicLevel={magicLevel}
|
|
118
|
+
onPointerUp={
|
|
119
|
+
settingShortcutIndex !== -1 ? setShortcut : onSpellClick
|
|
120
|
+
}
|
|
121
|
+
spellKey={spell.key}
|
|
122
|
+
isSettingShortcut={settingShortcutIndex !== -1}
|
|
123
|
+
spell={spell}
|
|
124
|
+
activeCooldown={
|
|
125
|
+
spellCooldowns?.[spell.magicWords.replaceAll(' ', '_')]
|
|
126
|
+
}
|
|
127
|
+
{...spell}
|
|
128
|
+
/>
|
|
129
|
+
</Fragment>
|
|
130
|
+
))}
|
|
131
|
+
</SpellList>
|
|
132
|
+
</Container>
|
|
133
|
+
</DraggableContainer>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const Title = styled.h1`
|
|
138
|
+
font-size: ${uiFonts.size.large} !important;
|
|
139
|
+
margin-bottom: 0 !important;
|
|
140
|
+
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
const Container = styled.div`
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 100%;
|
|
146
|
+
color: white;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
const SpellList = styled.div`
|
|
153
|
+
width: 100%;
|
|
154
|
+
min-height: 0;
|
|
155
|
+
flex: 1;
|
|
156
|
+
overflow-y: auto;
|
|
157
|
+
display: flex;
|
|
158
|
+
flex-direction: column;
|
|
159
|
+
gap: 1.5rem;
|
|
160
|
+
margin-top: 1rem;
|
|
161
|
+
`;
|
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import { ISpell } from '@rpg-engine/shared';
|
|
2
|
-
import React, { useRef } from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import ModalPortal from '../../Abstractions/ModalPortal';
|
|
5
|
-
import { SpellInfoDisplay } from './SpellInfoDisplay';
|
|
6
|
-
|
|
7
|
-
interface IListMenuOption {
|
|
8
|
-
id: string;
|
|
9
|
-
text: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface MobileSpellTooltipProps {
|
|
13
|
-
spell: ISpell;
|
|
14
|
-
closeTooltip: () => void;
|
|
15
|
-
scale?: number;
|
|
16
|
-
options?: IListMenuOption[];
|
|
17
|
-
onSelected?: (selectedOptionId: string) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const MobileSpellTooltip: React.FC<MobileSpellTooltipProps> = ({
|
|
21
|
-
spell,
|
|
22
|
-
closeTooltip,
|
|
23
|
-
scale = 1,
|
|
24
|
-
options,
|
|
25
|
-
onSelected,
|
|
26
|
-
}) => {
|
|
27
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
28
|
-
|
|
29
|
-
const handleFadeOut = () => {
|
|
30
|
-
ref.current?.classList.add('fadeOut');
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<ModalPortal>
|
|
35
|
-
<Container
|
|
36
|
-
ref={ref}
|
|
37
|
-
onTouchEnd={() => {
|
|
38
|
-
handleFadeOut();
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
closeTooltip();
|
|
41
|
-
}, 100);
|
|
42
|
-
}}
|
|
43
|
-
scale={scale}
|
|
44
|
-
>
|
|
45
|
-
<SpellInfoDisplay spell={spell} isMobile />
|
|
46
|
-
<OptionsContainer>
|
|
47
|
-
{options?.map(option => (
|
|
48
|
-
<Option
|
|
49
|
-
key={option.id}
|
|
50
|
-
onTouchEnd={() => {
|
|
51
|
-
handleFadeOut();
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
onSelected?.(option.id);
|
|
54
|
-
closeTooltip();
|
|
55
|
-
}, 100);
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{option.text}
|
|
59
|
-
</Option>
|
|
60
|
-
))}
|
|
61
|
-
</OptionsContainer>
|
|
62
|
-
</Container>
|
|
63
|
-
</ModalPortal>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const Container = styled.div<{ scale: number }>`
|
|
68
|
-
position: absolute;
|
|
69
|
-
z-index: 100;
|
|
70
|
-
left: 0;
|
|
71
|
-
top: 0;
|
|
72
|
-
width: 100vw;
|
|
73
|
-
height: 100vh;
|
|
74
|
-
background-color: rgba(0 0 0 / 0.5);
|
|
75
|
-
display: flex;
|
|
76
|
-
justify-content: center;
|
|
77
|
-
align-items: center;
|
|
78
|
-
gap: 0.5rem;
|
|
79
|
-
transition: opacity 0.08s;
|
|
80
|
-
animation: fadeIn 0.1s forwards;
|
|
81
|
-
|
|
82
|
-
@keyframes fadeIn {
|
|
83
|
-
0% {
|
|
84
|
-
opacity: 0;
|
|
85
|
-
}
|
|
86
|
-
100% {
|
|
87
|
-
opacity: 0.92;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@keyframes fadeOut {
|
|
92
|
-
0% {
|
|
93
|
-
opacity: 0.92;
|
|
94
|
-
}
|
|
95
|
-
100% {
|
|
96
|
-
opacity: 0;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&.fadeOut {
|
|
101
|
-
animation: fadeOut 0.1s forwards;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@media (max-width: 580px) {
|
|
105
|
-
flex-direction: column;
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
|
|
109
|
-
const OptionsContainer = styled.div`
|
|
110
|
-
display: flex;
|
|
111
|
-
flex-direction: column;
|
|
112
|
-
gap: 0.5rem;
|
|
113
|
-
flex-wrap: wrap;
|
|
114
|
-
|
|
115
|
-
@media (max-width: 580px) {
|
|
116
|
-
flex-direction: row;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
}
|
|
119
|
-
`;
|
|
120
|
-
|
|
121
|
-
const Option = styled.button`
|
|
122
|
-
padding: 1rem;
|
|
123
|
-
background-color: #333;
|
|
124
|
-
color: white;
|
|
125
|
-
border: none;
|
|
126
|
-
border-radius: 3px;
|
|
127
|
-
width: 8rem;
|
|
128
|
-
transition: background-color 0.1s;
|
|
129
|
-
|
|
130
|
-
&:hover {
|
|
131
|
-
background-color: #555;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@media (max-width: 580px) {
|
|
135
|
-
padding: 1rem 0.5rem;
|
|
136
|
-
}
|
|
137
|
-
`;
|
|
1
|
+
import { ISpell } from '@rpg-engine/shared';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import ModalPortal from '../../Abstractions/ModalPortal';
|
|
5
|
+
import { SpellInfoDisplay } from './SpellInfoDisplay';
|
|
6
|
+
|
|
7
|
+
interface IListMenuOption {
|
|
8
|
+
id: string;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MobileSpellTooltipProps {
|
|
13
|
+
spell: ISpell;
|
|
14
|
+
closeTooltip: () => void;
|
|
15
|
+
scale?: number;
|
|
16
|
+
options?: IListMenuOption[];
|
|
17
|
+
onSelected?: (selectedOptionId: string) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const MobileSpellTooltip: React.FC<MobileSpellTooltipProps> = ({
|
|
21
|
+
spell,
|
|
22
|
+
closeTooltip,
|
|
23
|
+
scale = 1,
|
|
24
|
+
options,
|
|
25
|
+
onSelected,
|
|
26
|
+
}) => {
|
|
27
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
28
|
+
|
|
29
|
+
const handleFadeOut = () => {
|
|
30
|
+
ref.current?.classList.add('fadeOut');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<ModalPortal>
|
|
35
|
+
<Container
|
|
36
|
+
ref={ref}
|
|
37
|
+
onTouchEnd={() => {
|
|
38
|
+
handleFadeOut();
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
closeTooltip();
|
|
41
|
+
}, 100);
|
|
42
|
+
}}
|
|
43
|
+
scale={scale}
|
|
44
|
+
>
|
|
45
|
+
<SpellInfoDisplay spell={spell} isMobile />
|
|
46
|
+
<OptionsContainer>
|
|
47
|
+
{options?.map(option => (
|
|
48
|
+
<Option
|
|
49
|
+
key={option.id}
|
|
50
|
+
onTouchEnd={() => {
|
|
51
|
+
handleFadeOut();
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
onSelected?.(option.id);
|
|
54
|
+
closeTooltip();
|
|
55
|
+
}, 100);
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{option.text}
|
|
59
|
+
</Option>
|
|
60
|
+
))}
|
|
61
|
+
</OptionsContainer>
|
|
62
|
+
</Container>
|
|
63
|
+
</ModalPortal>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const Container = styled.div<{ scale: number }>`
|
|
68
|
+
position: absolute;
|
|
69
|
+
z-index: 100;
|
|
70
|
+
left: 0;
|
|
71
|
+
top: 0;
|
|
72
|
+
width: 100vw;
|
|
73
|
+
height: 100vh;
|
|
74
|
+
background-color: rgba(0 0 0 / 0.5);
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 0.5rem;
|
|
79
|
+
transition: opacity 0.08s;
|
|
80
|
+
animation: fadeIn 0.1s forwards;
|
|
81
|
+
|
|
82
|
+
@keyframes fadeIn {
|
|
83
|
+
0% {
|
|
84
|
+
opacity: 0;
|
|
85
|
+
}
|
|
86
|
+
100% {
|
|
87
|
+
opacity: 0.92;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@keyframes fadeOut {
|
|
92
|
+
0% {
|
|
93
|
+
opacity: 0.92;
|
|
94
|
+
}
|
|
95
|
+
100% {
|
|
96
|
+
opacity: 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&.fadeOut {
|
|
101
|
+
animation: fadeOut 0.1s forwards;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@media (max-width: 580px) {
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
const OptionsContainer = styled.div`
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
gap: 0.5rem;
|
|
113
|
+
flex-wrap: wrap;
|
|
114
|
+
|
|
115
|
+
@media (max-width: 580px) {
|
|
116
|
+
flex-direction: row;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
const Option = styled.button`
|
|
122
|
+
padding: 1rem;
|
|
123
|
+
background-color: #333;
|
|
124
|
+
color: white;
|
|
125
|
+
border: none;
|
|
126
|
+
border-radius: 3px;
|
|
127
|
+
width: 8rem;
|
|
128
|
+
transition: background-color 0.1s;
|
|
129
|
+
|
|
130
|
+
&:hover {
|
|
131
|
+
background-color: #555;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@media (max-width: 580px) {
|
|
135
|
+
padding: 1rem 0.5rem;
|
|
136
|
+
}
|
|
137
|
+
`;
|