@rpg-engine/long-bow 0.3.42 → 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 -7464
- 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 -7460
- 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 -105
- 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/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/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/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/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/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,120 +0,0 @@
|
|
|
1
|
-
import { IRawSpell } from '@rpg-engine/shared';
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { uiColors } from '../../constants/uiColors';
|
|
5
|
-
|
|
6
|
-
export type QuickSpellsProps = {
|
|
7
|
-
quickSpells: IRawSpell[];
|
|
8
|
-
onSpellCast: (spellKey: string) => void;
|
|
9
|
-
mana: number;
|
|
10
|
-
isBlockedCastingByKeyboard?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const QuickSpells: React.FC<QuickSpellsProps> = ({
|
|
14
|
-
quickSpells,
|
|
15
|
-
onSpellCast,
|
|
16
|
-
mana,
|
|
17
|
-
isBlockedCastingByKeyboard = false,
|
|
18
|
-
}) => {
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const handleKeyDown = (e: KeyboardEvent) => {
|
|
21
|
-
if (isBlockedCastingByKeyboard) return;
|
|
22
|
-
|
|
23
|
-
const shortcutIndex = Number(e.key) - 1;
|
|
24
|
-
if (shortcutIndex >= 0 && shortcutIndex <= 3) {
|
|
25
|
-
const shortcut = quickSpells[shortcutIndex];
|
|
26
|
-
if (shortcut?.key && mana >= shortcut?.manaCost) {
|
|
27
|
-
onSpellCast(shortcut.key);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
33
|
-
|
|
34
|
-
return () => {
|
|
35
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
36
|
-
};
|
|
37
|
-
}, [quickSpells, isBlockedCastingByKeyboard]);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<List>
|
|
41
|
-
{Array.from({ length: 4 }).map((_, i) => (
|
|
42
|
-
<SpellShortcut
|
|
43
|
-
key={i}
|
|
44
|
-
onClick={onSpellCast.bind(null, quickSpells[i]?.key)}
|
|
45
|
-
disabled={mana < quickSpells[i]?.manaCost}
|
|
46
|
-
>
|
|
47
|
-
<span className="mana">
|
|
48
|
-
{quickSpells[i]?.key && quickSpells[i]?.manaCost}
|
|
49
|
-
</span>
|
|
50
|
-
<span className="magicWords">
|
|
51
|
-
{quickSpells[i]?.magicWords.split(' ').map(word => word[0])}
|
|
52
|
-
</span>
|
|
53
|
-
<span className="keyboard">{i + 1}</span>
|
|
54
|
-
</SpellShortcut>
|
|
55
|
-
))}
|
|
56
|
-
</List>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const SpellShortcut = styled.button`
|
|
61
|
-
width: 3rem;
|
|
62
|
-
height: 3rem;
|
|
63
|
-
background-color: ${uiColors.lightGray};
|
|
64
|
-
border: 2px solid ${uiColors.darkGray};
|
|
65
|
-
border-radius: 50%;
|
|
66
|
-
text-transform: uppercase;
|
|
67
|
-
font-size: 0.7rem;
|
|
68
|
-
font-weight: bold;
|
|
69
|
-
display: flex;
|
|
70
|
-
align-items: center;
|
|
71
|
-
justify-content: center;
|
|
72
|
-
position: relative;
|
|
73
|
-
|
|
74
|
-
span {
|
|
75
|
-
pointer-events: none;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.mana {
|
|
79
|
-
position: absolute;
|
|
80
|
-
top: -5px;
|
|
81
|
-
right: 0;
|
|
82
|
-
font-size: 0.65rem;
|
|
83
|
-
color: ${uiColors.blue};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.magicWords {
|
|
87
|
-
margin-top: 4px;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.keyboard {
|
|
91
|
-
position: absolute;
|
|
92
|
-
bottom: -5px;
|
|
93
|
-
left: 0;
|
|
94
|
-
font-size: 0.65rem;
|
|
95
|
-
color: ${uiColors.yellow};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&:hover,
|
|
99
|
-
&:focus {
|
|
100
|
-
background-color: ${uiColors.darkGray};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
&:active {
|
|
104
|
-
background-color: ${uiColors.gray};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&:disabled {
|
|
108
|
-
opacity: 0.5;
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
const List = styled.p`
|
|
113
|
-
width: 100%;
|
|
114
|
-
display: flex;
|
|
115
|
-
align-items: center;
|
|
116
|
-
justify-content: center;
|
|
117
|
-
gap: 0.5rem;
|
|
118
|
-
box-sizing: border-box;
|
|
119
|
-
margin: 0 !important;
|
|
120
|
-
`;
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { IRawSpell } from '@rpg-engine/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { uiColors } from '../../constants/uiColors';
|
|
5
|
-
import { uiFonts } from '../../constants/uiFonts';
|
|
6
|
-
|
|
7
|
-
interface Props extends IRawSpell {
|
|
8
|
-
charMana: number;
|
|
9
|
-
charMagicLevel: number;
|
|
10
|
-
onClick?: (spellKey: string) => void;
|
|
11
|
-
isSettingShortcut?: boolean;
|
|
12
|
-
spellKey: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const Spell: React.FC<Props> = ({
|
|
16
|
-
spellKey,
|
|
17
|
-
name,
|
|
18
|
-
description,
|
|
19
|
-
magicWords,
|
|
20
|
-
manaCost,
|
|
21
|
-
charMana,
|
|
22
|
-
charMagicLevel,
|
|
23
|
-
onClick,
|
|
24
|
-
isSettingShortcut,
|
|
25
|
-
minMagicLevelRequired,
|
|
26
|
-
}) => {
|
|
27
|
-
const disabled = isSettingShortcut
|
|
28
|
-
? charMagicLevel < minMagicLevelRequired
|
|
29
|
-
: manaCost > charMana || charMagicLevel < minMagicLevelRequired;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Container
|
|
33
|
-
disabled={disabled}
|
|
34
|
-
onClick={onClick?.bind(null, spellKey)}
|
|
35
|
-
isSettingShortcut={isSettingShortcut && !disabled}
|
|
36
|
-
className="spell"
|
|
37
|
-
>
|
|
38
|
-
{disabled && (
|
|
39
|
-
<Overlay>
|
|
40
|
-
{charMagicLevel < minMagicLevelRequired
|
|
41
|
-
? 'Low magic level'
|
|
42
|
-
: manaCost > charMana && 'No mana'}
|
|
43
|
-
</Overlay>
|
|
44
|
-
)}
|
|
45
|
-
<SpellImage>{magicWords.split(' ').map(word => word[0])}</SpellImage>
|
|
46
|
-
<Info>
|
|
47
|
-
<Title>
|
|
48
|
-
<span>{name}</span>
|
|
49
|
-
<span className="spell">({magicWords})</span>
|
|
50
|
-
</Title>
|
|
51
|
-
<Description>{description}</Description>
|
|
52
|
-
</Info>
|
|
53
|
-
|
|
54
|
-
<Divider />
|
|
55
|
-
<Cost>
|
|
56
|
-
<span>Mana cost:</span>
|
|
57
|
-
<span className="mana">{manaCost}</span>
|
|
58
|
-
</Cost>
|
|
59
|
-
</Container>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const Container = styled.button<{ isSettingShortcut?: boolean }>`
|
|
64
|
-
display: block;
|
|
65
|
-
background: none;
|
|
66
|
-
border: 2px solid transparent;
|
|
67
|
-
border-radius: 1rem;
|
|
68
|
-
width: 100%;
|
|
69
|
-
display: flex;
|
|
70
|
-
height: 5rem;
|
|
71
|
-
gap: 1rem;
|
|
72
|
-
align-items: center;
|
|
73
|
-
padding: 0 1rem;
|
|
74
|
-
text-align: left;
|
|
75
|
-
position: relative;
|
|
76
|
-
|
|
77
|
-
animation: ${({ isSettingShortcut }) =>
|
|
78
|
-
isSettingShortcut ? 'border-color-change 1s infinite' : 'none'};
|
|
79
|
-
|
|
80
|
-
@keyframes border-color-change {
|
|
81
|
-
0% {
|
|
82
|
-
border-color: ${uiColors.yellow};
|
|
83
|
-
}
|
|
84
|
-
50% {
|
|
85
|
-
border-color: transparent;
|
|
86
|
-
}
|
|
87
|
-
100% {
|
|
88
|
-
border-color: ${uiColors.yellow};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&:hover,
|
|
93
|
-
&:focus {
|
|
94
|
-
background-color: ${uiColors.darkGray};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
&:active {
|
|
98
|
-
background: none;
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
const SpellImage = styled.div`
|
|
103
|
-
width: 4rem;
|
|
104
|
-
height: 4rem;
|
|
105
|
-
font-size: ${uiFonts.size.xLarge};
|
|
106
|
-
font-weight: bold;
|
|
107
|
-
background-color: ${uiColors.darkGray};
|
|
108
|
-
color: ${uiColors.lightGray};
|
|
109
|
-
display: flex;
|
|
110
|
-
justify-content: center;
|
|
111
|
-
align-items: center;
|
|
112
|
-
text-transform: uppercase;
|
|
113
|
-
`;
|
|
114
|
-
|
|
115
|
-
const Info = styled.span`
|
|
116
|
-
width: 0;
|
|
117
|
-
flex: 1;
|
|
118
|
-
`;
|
|
119
|
-
|
|
120
|
-
const Title = styled.p`
|
|
121
|
-
display: flex;
|
|
122
|
-
flex-wrap: wrap;
|
|
123
|
-
align-items: center;
|
|
124
|
-
margin-bottom: 5px;
|
|
125
|
-
margin: 0;
|
|
126
|
-
|
|
127
|
-
span {
|
|
128
|
-
font-size: ${uiFonts.size.medium} !important;
|
|
129
|
-
font-weight: bold !important;
|
|
130
|
-
color: ${uiColors.yellow} !important;
|
|
131
|
-
margin-right: 0.5rem;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.spell {
|
|
135
|
-
font-size: ${uiFonts.size.small} !important;
|
|
136
|
-
font-weight: normal !important;
|
|
137
|
-
color: ${uiColors.lightGray} !important;
|
|
138
|
-
}
|
|
139
|
-
`;
|
|
140
|
-
|
|
141
|
-
const Description = styled.div`
|
|
142
|
-
font-size: ${uiFonts.size.small} !important;
|
|
143
|
-
line-height: 1.1 !important;
|
|
144
|
-
`;
|
|
145
|
-
|
|
146
|
-
const Divider = styled.div`
|
|
147
|
-
width: 1px;
|
|
148
|
-
height: 100%;
|
|
149
|
-
margin: 0 1rem;
|
|
150
|
-
background-color: ${uiColors.lightGray};
|
|
151
|
-
`;
|
|
152
|
-
|
|
153
|
-
const Cost = styled.p`
|
|
154
|
-
display: flex;
|
|
155
|
-
align-items: center;
|
|
156
|
-
flex-direction: column;
|
|
157
|
-
gap: 0.5rem;
|
|
158
|
-
|
|
159
|
-
div {
|
|
160
|
-
z-index: 1;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.mana {
|
|
164
|
-
position: relative;
|
|
165
|
-
font-size: ${uiFonts.size.medium};
|
|
166
|
-
font-weight: bold;
|
|
167
|
-
z-index: 1;
|
|
168
|
-
|
|
169
|
-
&::after {
|
|
170
|
-
position: absolute;
|
|
171
|
-
content: '';
|
|
172
|
-
top: 0;
|
|
173
|
-
left: 0;
|
|
174
|
-
background-color: ${uiColors.blue};
|
|
175
|
-
width: 100%;
|
|
176
|
-
height: 100%;
|
|
177
|
-
border-radius: 50%;
|
|
178
|
-
transform: scale(1.8);
|
|
179
|
-
filter: blur(10px);
|
|
180
|
-
z-index: -1;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
`;
|
|
184
|
-
|
|
185
|
-
const Overlay = styled.p`
|
|
186
|
-
margin: 0 !important;
|
|
187
|
-
position: absolute;
|
|
188
|
-
top: 0;
|
|
189
|
-
left: 0;
|
|
190
|
-
width: 100%;
|
|
191
|
-
height: 100%;
|
|
192
|
-
border-radius: 1rem;
|
|
193
|
-
display: flex;
|
|
194
|
-
justify-content: center;
|
|
195
|
-
align-items: center;
|
|
196
|
-
color: ${uiColors.yellow};
|
|
197
|
-
font-size: ${uiFonts.size.large} !important;
|
|
198
|
-
font-weight: bold;
|
|
199
|
-
z-index: 10;
|
|
200
|
-
background-color: rgba(0 0 0 / 0.2);
|
|
201
|
-
`;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { IRawSpell } 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 { Spell } from './Spell';
|
|
9
|
-
import { SpellbookShortcuts } from './SpellbookShortcuts';
|
|
10
|
-
|
|
11
|
-
export interface ISpellbookProps {
|
|
12
|
-
onClose?: () => void;
|
|
13
|
-
onInputFocus?: () => void;
|
|
14
|
-
onInputBlur?: () => void;
|
|
15
|
-
spells: IRawSpell[];
|
|
16
|
-
magicLevel: number;
|
|
17
|
-
mana: number;
|
|
18
|
-
onSpellClick: (spellKey: string) => void;
|
|
19
|
-
setSpellShortcut: (key: string, index: number) => void;
|
|
20
|
-
spellShortcuts: IRawSpell[];
|
|
21
|
-
removeSpellShortcut: (index: number) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const Spellbook: React.FC<ISpellbookProps> = ({
|
|
25
|
-
onClose,
|
|
26
|
-
onInputFocus,
|
|
27
|
-
onInputBlur,
|
|
28
|
-
spells,
|
|
29
|
-
magicLevel,
|
|
30
|
-
mana,
|
|
31
|
-
onSpellClick,
|
|
32
|
-
setSpellShortcut,
|
|
33
|
-
spellShortcuts,
|
|
34
|
-
removeSpellShortcut,
|
|
35
|
-
}) => {
|
|
36
|
-
const [search, setSearch] = useState('');
|
|
37
|
-
const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const handleEscapeClose = (e: KeyboardEvent) => {
|
|
41
|
-
if (e.key === 'Escape') {
|
|
42
|
-
onClose?.();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
document.addEventListener('keydown', handleEscapeClose);
|
|
47
|
-
|
|
48
|
-
return () => {
|
|
49
|
-
document.removeEventListener('keydown', handleEscapeClose);
|
|
50
|
-
};
|
|
51
|
-
}, [onClose]);
|
|
52
|
-
|
|
53
|
-
const spellsToDisplay = useMemo(() => {
|
|
54
|
-
return spells
|
|
55
|
-
.sort((a, b) => {
|
|
56
|
-
if (a.minMagicLevelRequired > b.minMagicLevelRequired) return 1;
|
|
57
|
-
if (a.minMagicLevelRequired < b.minMagicLevelRequired) return -1;
|
|
58
|
-
return 0;
|
|
59
|
-
})
|
|
60
|
-
.filter(
|
|
61
|
-
spell =>
|
|
62
|
-
spell.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) ||
|
|
63
|
-
spell.magicWords
|
|
64
|
-
.toLocaleLowerCase()
|
|
65
|
-
.includes(search.toLocaleLowerCase())
|
|
66
|
-
);
|
|
67
|
-
}, [search, spells]);
|
|
68
|
-
|
|
69
|
-
const setShortcut = (spellKey: string) => {
|
|
70
|
-
setSpellShortcut?.(spellKey, settingShortcutIndex);
|
|
71
|
-
setSettingShortcutIndex(-1);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<DraggableContainer
|
|
76
|
-
type={RPGUIContainerTypes.Framed}
|
|
77
|
-
onCloseButton={onClose}
|
|
78
|
-
width="inherit"
|
|
79
|
-
height="inherit"
|
|
80
|
-
cancelDrag="#spellbook-search, #shortcuts_list, .spell"
|
|
81
|
-
>
|
|
82
|
-
<Container>
|
|
83
|
-
<Title>Learned Spells</Title>
|
|
84
|
-
|
|
85
|
-
<SpellbookShortcuts
|
|
86
|
-
setSettingShortcutIndex={setSettingShortcutIndex}
|
|
87
|
-
settingShortcutIndex={settingShortcutIndex}
|
|
88
|
-
shortcuts={spellShortcuts}
|
|
89
|
-
removeShortcut={removeSpellShortcut}
|
|
90
|
-
/>
|
|
91
|
-
|
|
92
|
-
<Input
|
|
93
|
-
placeholder="Search for spell"
|
|
94
|
-
value={search}
|
|
95
|
-
onChange={e => setSearch(e.target.value)}
|
|
96
|
-
onFocus={onInputFocus}
|
|
97
|
-
onBlur={onInputBlur}
|
|
98
|
-
id="spellbook-search"
|
|
99
|
-
/>
|
|
100
|
-
|
|
101
|
-
<SpellList>
|
|
102
|
-
{spellsToDisplay.map(spell => (
|
|
103
|
-
<Fragment key={spell.key}>
|
|
104
|
-
<Spell
|
|
105
|
-
charMana={mana}
|
|
106
|
-
charMagicLevel={magicLevel}
|
|
107
|
-
onClick={
|
|
108
|
-
settingShortcutIndex !== -1 ? setShortcut : onSpellClick
|
|
109
|
-
}
|
|
110
|
-
spellKey={spell.key}
|
|
111
|
-
isSettingShortcut={settingShortcutIndex !== -1}
|
|
112
|
-
{...spell}
|
|
113
|
-
/>
|
|
114
|
-
</Fragment>
|
|
115
|
-
))}
|
|
116
|
-
</SpellList>
|
|
117
|
-
</Container>
|
|
118
|
-
</DraggableContainer>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const Title = styled.h1`
|
|
123
|
-
font-size: ${uiFonts.size.large} !important;
|
|
124
|
-
margin-bottom: 0 !important;
|
|
125
|
-
`;
|
|
126
|
-
|
|
127
|
-
const Container = styled.div`
|
|
128
|
-
width: 100%;
|
|
129
|
-
height: 100%;
|
|
130
|
-
color: white;
|
|
131
|
-
display: flex;
|
|
132
|
-
flex-direction: column;
|
|
133
|
-
`;
|
|
134
|
-
|
|
135
|
-
const SpellList = styled.div`
|
|
136
|
-
width: 100%;
|
|
137
|
-
min-height: 0;
|
|
138
|
-
flex: 1;
|
|
139
|
-
overflow-y: auto;
|
|
140
|
-
display: flex;
|
|
141
|
-
flex-direction: column;
|
|
142
|
-
gap: 1.5rem;
|
|
143
|
-
margin-top: 1rem;
|
|
144
|
-
`;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { IRawSpell } from '@rpg-engine/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { uiColors } from '../../constants/uiColors';
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
setSettingShortcutIndex: (index: number) => void;
|
|
8
|
-
settingShortcutIndex: number;
|
|
9
|
-
shortcuts: IRawSpell[];
|
|
10
|
-
removeShortcut: (index: number) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const SpellbookShortcuts: React.FC<Props> = ({
|
|
14
|
-
setSettingShortcutIndex,
|
|
15
|
-
settingShortcutIndex,
|
|
16
|
-
shortcuts,
|
|
17
|
-
removeShortcut,
|
|
18
|
-
}) => (
|
|
19
|
-
<List id="shortcuts_list">
|
|
20
|
-
Spells shortcuts:
|
|
21
|
-
{Array.from({ length: 4 }).map((_, i) => (
|
|
22
|
-
<SpellShortcut
|
|
23
|
-
key={i}
|
|
24
|
-
onClick={() => {
|
|
25
|
-
removeShortcut(i);
|
|
26
|
-
if (!shortcuts[i]?.key) setSettingShortcutIndex(i);
|
|
27
|
-
}}
|
|
28
|
-
disabled={settingShortcutIndex !== -1 && settingShortcutIndex !== i}
|
|
29
|
-
isBeingSet={settingShortcutIndex === i}
|
|
30
|
-
>
|
|
31
|
-
<span>{shortcuts[i]?.magicWords.split(' ').map(word => word[0])}</span>
|
|
32
|
-
</SpellShortcut>
|
|
33
|
-
))}
|
|
34
|
-
</List>
|
|
35
|
-
);
|
|
36
|
-
const SpellShortcut = styled.button<{ isBeingSet?: boolean }>`
|
|
37
|
-
width: 2.6rem;
|
|
38
|
-
height: 2.6rem;
|
|
39
|
-
background-color: ${uiColors.lightGray};
|
|
40
|
-
border: 2px solid
|
|
41
|
-
${({ isBeingSet }) => (isBeingSet ? uiColors.yellow : uiColors.darkGray)};
|
|
42
|
-
border-radius: 50%;
|
|
43
|
-
text-transform: uppercase;
|
|
44
|
-
font-size: 0.7rem;
|
|
45
|
-
font-weight: bold;
|
|
46
|
-
display: flex;
|
|
47
|
-
align-items: center;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
|
|
50
|
-
span {
|
|
51
|
-
margin-top: 4px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&:hover,
|
|
55
|
-
&:focus {
|
|
56
|
-
background-color: ${uiColors.darkGray};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&:active {
|
|
60
|
-
background-color: ${uiColors.gray};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&:disabled {
|
|
64
|
-
opacity: 0.5;
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
const List = styled.p`
|
|
69
|
-
width: 100%;
|
|
70
|
-
display: flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
justify-content: flex-end;
|
|
73
|
-
gap: 0.5rem;
|
|
74
|
-
padding: 0.5rem;
|
|
75
|
-
box-sizing: border-box;
|
|
76
|
-
margin: 0 !important;
|
|
77
|
-
`;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IRawSpell } from '@rpg-engine/shared';
|
|
2
|
-
|
|
3
|
-
export const SPELL_SHORTCUTS_STORAGE_KEY = 'spellShortcuts';
|
|
4
|
-
|
|
5
|
-
export const defaultSpellShortcut: IRawSpell = {
|
|
6
|
-
key: '',
|
|
7
|
-
manaCost: 0,
|
|
8
|
-
magicWords: '',
|
|
9
|
-
name: '',
|
|
10
|
-
description: '',
|
|
11
|
-
minMagicLevelRequired: 0,
|
|
12
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { IRawSpell } from '@rpg-engine/shared';
|
|
2
|
-
|
|
3
|
-
enum SpellsBlueprint {
|
|
4
|
-
SelfHealingSpell = 'self-healing-spell',
|
|
5
|
-
FoodCreationSpell = 'food-creation-spell',
|
|
6
|
-
ArrowCreationSpell = 'arrow-creation-spell',
|
|
7
|
-
BoltCreationSpell = 'bolt-creation-spell',
|
|
8
|
-
BlankRuneCreationSpell = 'blank-rune-creation-spell',
|
|
9
|
-
SelfHasteSpell = 'self-haste-spell',
|
|
10
|
-
FireRuneCreationSpell = 'fire-rune-creation-spell',
|
|
11
|
-
HealRuneCreationSpell = 'healing-rune-creation-spell',
|
|
12
|
-
PoisonRuneCreationSpell = 'poison-rune-creation-spell',
|
|
13
|
-
DarkRuneCreationSpell = 'dark-rune-creation-spell',
|
|
14
|
-
GreaterHealingSpell = 'greater-healing-spell',
|
|
15
|
-
EnergyBoltCreationSpell = 'energy-bolt-creation-spell',
|
|
16
|
-
FireBoltCreationSpell = 'fire-bolt-creation-spell',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const mockSpells: IRawSpell[] = [
|
|
20
|
-
{
|
|
21
|
-
key: SpellsBlueprint.ArrowCreationSpell,
|
|
22
|
-
name: 'Arrow Creation Spell',
|
|
23
|
-
description: 'A spell that creates arrow in your inventory.',
|
|
24
|
-
magicWords: 'iquar elandi',
|
|
25
|
-
manaCost: 10,
|
|
26
|
-
minMagicLevelRequired: 3,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
key: SpellsBlueprint.BlankRuneCreationSpell,
|
|
30
|
-
name: 'Blank Rune Creation Spell',
|
|
31
|
-
description: 'A spell that creates a blank rune in your inventory.',
|
|
32
|
-
magicWords: 'iquar ansr ki',
|
|
33
|
-
manaCost: 5,
|
|
34
|
-
minMagicLevelRequired: 3,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
key: SpellsBlueprint.BoltCreationSpell,
|
|
38
|
-
name: 'Bolt Creation Spell',
|
|
39
|
-
description: 'A spell that creates bolt in your inventory.',
|
|
40
|
-
magicWords: 'iquar lyn',
|
|
41
|
-
manaCost: 15,
|
|
42
|
-
minMagicLevelRequired: 3,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
key: SpellsBlueprint.SelfHasteSpell,
|
|
46
|
-
name: 'Self Haste Spell',
|
|
47
|
-
description: 'A self haste spell.',
|
|
48
|
-
magicWords: 'talas hiz',
|
|
49
|
-
manaCost: 40,
|
|
50
|
-
minMagicLevelRequired: 5,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
key: SpellsBlueprint.SelfHealingSpell,
|
|
54
|
-
name: 'Self Healing Spell',
|
|
55
|
-
description: 'A self healing spell.',
|
|
56
|
-
magicWords: 'talas faenya',
|
|
57
|
-
manaCost: 10,
|
|
58
|
-
minMagicLevelRequired: 1,
|
|
59
|
-
},
|
|
60
|
-
];
|