@rpg-engine/long-bow 0.3.53 → 0.3.55

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.
Files changed (163) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/Arrow/SelectArrow.d.ts +1 -1
  4. package/dist/components/Button.d.ts +2 -2
  5. package/dist/components/CircularController/CircularController.d.ts +4 -7
  6. package/dist/components/Item/Inventory/ItemContainer.d.ts +1 -4
  7. package/dist/components/Item/Inventory/ItemSlot.d.ts +1 -2
  8. package/dist/components/Multitab/Tab.d.ts +1 -1
  9. package/dist/components/QuestInfo/QuestInfo.d.ts +1 -1
  10. package/dist/components/Spellbook/QuickSpells.d.ts +10 -0
  11. package/dist/components/Spellbook/Spell.d.ts +1 -1
  12. package/dist/components/Spellbook/Spellbook.d.ts +3 -5
  13. package/dist/components/Spellbook/SpellbookShortcuts.d.ts +10 -0
  14. package/dist/components/Spellbook/constants.d.ts +3 -3
  15. package/dist/components/shared/SpriteFromAtlas.d.ts +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/long-bow.cjs.development.js +734 -914
  18. package/dist/long-bow.cjs.development.js.map +1 -1
  19. package/dist/long-bow.cjs.production.min.js +1 -1
  20. package/dist/long-bow.cjs.production.min.js.map +1 -1
  21. package/dist/long-bow.esm.js +736 -917
  22. package/dist/long-bow.esm.js.map +1 -1
  23. package/dist/stories/{Shortcuts.stories.d.ts → QuickSpells.stories.d.ts} +2 -2
  24. package/package.json +100 -100
  25. package/src/components/Abstractions/SlotsContainer.tsx +45 -45
  26. package/src/components/Arrow/SelectArrow.tsx +69 -65
  27. package/src/components/Arrow/img/arrow01-left-clicked.png +0 -0
  28. package/src/components/Arrow/img/arrow01-left.png +0 -0
  29. package/src/components/Arrow/img/arrow01-right-clicked.png +0 -0
  30. package/src/components/Arrow/img/arrow01-right.png +0 -0
  31. package/src/components/Arrow/img/arrow02-left-clicked.png +0 -0
  32. package/src/components/Arrow/img/arrow02-left.png +0 -0
  33. package/src/components/Arrow/img/arrow02-right-clicked.png +0 -0
  34. package/src/components/Arrow/img/arrow02-right.png +0 -0
  35. package/src/components/Button.tsx +40 -41
  36. package/src/components/Character/CharacterSelection.tsx +96 -96
  37. package/src/components/CharacterStatus/CharacterStatus.tsx +120 -120
  38. package/src/components/Chat/Chat.tsx +195 -195
  39. package/src/components/Chatdeprecated/ChatDeprecated.tsx +198 -200
  40. package/src/components/CheckButton.tsx +65 -65
  41. package/src/components/CircularController/CircularController.tsx +162 -245
  42. package/src/components/CraftBook/CraftBook.tsx +224 -235
  43. package/src/components/CraftBook/MockItems.ts +46 -46
  44. package/src/components/DraggableContainer.tsx +153 -154
  45. package/src/components/Dropdown.tsx +90 -96
  46. package/src/components/DropdownSelectorContainer.tsx +42 -42
  47. package/src/components/Equipment/EquipmentSet.tsx +190 -190
  48. package/src/components/HistoryDialog.tsx +104 -104
  49. package/src/components/Input.tsx +15 -15
  50. package/src/components/Item/Cards/ItemTooltip.tsx +33 -33
  51. package/src/components/Item/Inventory/ErrorBoundary.tsx +42 -42
  52. package/src/components/Item/Inventory/ItemContainer.tsx +175 -210
  53. package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -6
  54. package/src/components/Item/Inventory/ItemQuantitySelector.tsx +138 -142
  55. package/src/components/Item/Inventory/ItemSlot.tsx +467 -502
  56. package/src/components/Item/Inventory/itemContainerHelper.ts +156 -156
  57. package/src/components/ListMenu.tsx +63 -63
  58. package/src/components/Multitab/Tab.tsx +66 -57
  59. package/src/components/Multitab/TabBody.tsx +13 -13
  60. package/src/components/Multitab/TabsContainer.tsx +97 -97
  61. package/src/components/NPCDialog/NPCDialog.tsx +121 -121
  62. package/src/components/NPCDialog/NPCDialogText.tsx +113 -113
  63. package/src/components/NPCDialog/NPCMultiDialog.tsx +159 -159
  64. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -237
  65. package/src/components/ProgressBar.tsx +92 -92
  66. package/src/components/PropertySelect/PropertySelect.tsx +106 -114
  67. package/src/components/QuestInfo/QuestInfo.tsx +230 -232
  68. package/src/components/QuestList.tsx +129 -129
  69. package/src/components/RPGUIContainer.tsx +47 -47
  70. package/src/components/RPGUIForceRenderStart.tsx +45 -45
  71. package/src/components/RPGUIRoot.tsx +14 -14
  72. package/src/components/RadioButton.tsx +53 -53
  73. package/src/components/RadioInput/RadioButton.tsx +96 -98
  74. package/src/components/RadioInput/RadioInput.tsx +102 -99
  75. package/src/components/RadioInput/instruments.ts +15 -15
  76. package/src/components/RangeSlider.tsx +78 -78
  77. package/src/components/RelativeListMenu.tsx +83 -83
  78. package/src/components/ScrollList.tsx +79 -79
  79. package/src/components/SimpleProgressBar.tsx +62 -62
  80. package/src/components/SkillProgressBar.tsx +133 -133
  81. package/src/components/SkillsContainer.tsx +198 -200
  82. package/src/components/Spellbook/QuickSpells.tsx +120 -0
  83. package/src/components/Spellbook/Spell.tsx +201 -201
  84. package/src/components/Spellbook/Spellbook.tsx +144 -150
  85. package/src/components/Spellbook/SpellbookShortcuts.tsx +77 -0
  86. package/src/components/Spellbook/constants.ts +12 -8
  87. package/src/components/Spellbook/mockSpells.ts +60 -60
  88. package/src/components/StaticBook/StaticBook.tsx +103 -105
  89. package/src/components/TextArea.tsx +11 -11
  90. package/src/components/TimeWidget/DayNightPeriod/DayNightPeriod.tsx +35 -35
  91. package/src/components/TimeWidget/TimeWidget.tsx +63 -63
  92. package/src/components/TradingMenu/TradingItemRow.tsx +193 -197
  93. package/src/components/TradingMenu/TradingMenu.tsx +203 -203
  94. package/src/components/TradingMenu/items.mock.ts +96 -96
  95. package/src/components/Truncate.tsx +25 -25
  96. package/src/components/itemSelector/ItemSelector.tsx +136 -136
  97. package/src/components/shared/Column.tsx +16 -16
  98. package/src/components/shared/Ellipsis.tsx +65 -65
  99. package/src/components/shared/SpriteFromAtlas.tsx +102 -102
  100. package/src/components/typography/DynamicText.tsx +49 -49
  101. package/src/constants/uiColors.ts +20 -20
  102. package/src/constants/uiDevices.ts +3 -3
  103. package/src/constants/uiFonts.ts +12 -12
  104. package/src/hooks/useEventListener.ts +21 -21
  105. package/src/hooks/useOutsideAlerter.ts +25 -25
  106. package/src/index.tsx +40 -40
  107. package/src/libs/StringHelpers.ts +3 -3
  108. package/src/mocks/atlas/entities/entities.json +20215 -20215
  109. package/src/mocks/atlas/icons/icons.json +735 -735
  110. package/src/mocks/atlas/items/items.json +12086 -12086
  111. package/src/mocks/equipmentSet.mocks.ts +393 -393
  112. package/src/mocks/itemContainer.mocks.ts +560 -562
  113. package/src/mocks/skills.mocks.ts +128 -128
  114. package/src/stories/Arrow.stories.tsx +26 -26
  115. package/src/stories/Button.stories.tsx +36 -36
  116. package/src/stories/CharacterSelection.stories.tsx +45 -45
  117. package/src/stories/CharacterStatus.stories.tsx +29 -29
  118. package/src/stories/Chat.stories.tsx +187 -187
  119. package/src/stories/ChatDeprecated.stories.tsx +170 -170
  120. package/src/stories/CheckButton.stories.tsx +48 -48
  121. package/src/stories/CircullarController.stories.tsx +33 -37
  122. package/src/stories/CraftBook.stories.tsx +40 -40
  123. package/src/stories/DayNightPeriod.stories.tsx +27 -27
  124. package/src/stories/DraggableContainer.stories.tsx +28 -28
  125. package/src/stories/Dropdown.stories.tsx +46 -46
  126. package/src/stories/DropdownSelectorContainer.stories.tsx +41 -41
  127. package/src/stories/EquipmentSet.stories.tsx +65 -65
  128. package/src/stories/HistoryDialog.stories.tsx +61 -61
  129. package/src/stories/ItemContainer.stories.tsx +124 -198
  130. package/src/stories/ItemQuantitySelector.stories.tsx +26 -26
  131. package/src/stories/ItemSelector.stories.tsx +77 -77
  132. package/src/stories/ItemTradingComponent.stories.tsx +35 -35
  133. package/src/stories/ListMenu.stories.tsx +56 -56
  134. package/src/stories/Multitab.stories.tsx +51 -51
  135. package/src/stories/NPCDialog.stories.tsx +130 -130
  136. package/src/stories/NPCMultiDialog.stories.tsx +71 -71
  137. package/src/stories/ProgressBar.stories.tsx +23 -23
  138. package/src/stories/PropertySelect.stories.tsx +40 -40
  139. package/src/stories/QuestInfo.stories.tsx +110 -107
  140. package/src/stories/QuestList.stories.tsx +82 -82
  141. package/src/stories/QuickSpells.stories.tsx +38 -0
  142. package/src/stories/RPGUIContainers.stories.tsx +42 -42
  143. package/src/stories/RadioButton.stories.tsx +49 -49
  144. package/src/stories/RadioInput.stories.tsx +34 -34
  145. package/src/stories/RangeSlider.stories.tsx +64 -64
  146. package/src/stories/ScrollList.stories.tsx +85 -85
  147. package/src/stories/SimpleProgressBar.stories.tsx +22 -22
  148. package/src/stories/SkillProgressBar.stories.tsx +34 -34
  149. package/src/stories/SkillsContainer.stories.tsx +35 -35
  150. package/src/stories/Spellbook.stories.tsx +107 -104
  151. package/src/stories/StaticBook.stories.tsx +32 -32
  152. package/src/stories/Text.stories.tsx +42 -42
  153. package/src/stories/TimeWidget.stories.tsx +27 -27
  154. package/src/stories/TradingMenu.stories.tsx +45 -45
  155. package/src/types/eventTypes.ts +4 -4
  156. package/src/types/index.d.ts +2 -2
  157. package/dist/components/Shortcuts/Shortcuts.d.ts +0 -12
  158. package/dist/components/Shortcuts/ShortcutsSetter.d.ts +0 -12
  159. package/dist/components/Shortcuts/SingleShortcut.d.ts +0 -1
  160. package/src/components/Shortcuts/Shortcuts.tsx +0 -129
  161. package/src/components/Shortcuts/ShortcutsSetter.tsx +0 -132
  162. package/src/components/Shortcuts/SingleShortcut.ts +0 -61
  163. package/src/stories/Shortcuts.stories.tsx +0 -39
@@ -1,245 +1,162 @@
1
- import {
2
- getItemTextureKeyPath,
3
- IItem,
4
- IItemContainer,
5
- IRawSpell,
6
- IShortcut,
7
- ShortcutType,
8
- } from '@rpg-engine/shared';
9
- import React from 'react';
10
- import styled from 'styled-components';
11
- import { uiColors } from '../../constants/uiColors';
12
- import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
13
- import { SingleShortcut } from '../Shortcuts/SingleShortcut';
14
-
15
- export type CircularControllerProps = {
16
- onActionClick: () => void;
17
- onCancelClick: () => void;
18
- onShortcutClick: (index: number) => void;
19
- mana: number;
20
- shortcuts: IShortcut[];
21
- inventory?: IItemContainer | null;
22
- atlasIMG: any;
23
- atlasJSON: any;
24
- };
25
-
26
- export const CircularController: React.FC<CircularControllerProps> = ({
27
- onActionClick,
28
- onCancelClick,
29
- onShortcutClick,
30
- mana,
31
- shortcuts,
32
- inventory,
33
- atlasIMG,
34
- atlasJSON,
35
- }) => {
36
- const onTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => {
37
- const target = e.target as HTMLButtonElement;
38
- target?.classList.add('active');
39
- };
40
-
41
- const onTouchEnd = (
42
- action: () => void,
43
- e: React.TouchEvent<HTMLButtonElement>
44
- ) => {
45
- const target = e.target as HTMLButtonElement;
46
- setTimeout(() => {
47
- target?.classList.remove('active');
48
- }, 100);
49
- action();
50
- };
51
-
52
- const renderShortcut = (i: number) => {
53
- let variant = '';
54
-
55
- if (i === 0) variant = 'top';
56
- else if (i >= 3) variant = `bottom-${i - 3}`;
57
-
58
- const onShortcutClickBinded =
59
- shortcuts[i]?.type !== ShortcutType.None
60
- ? onShortcutClick.bind(null, i)
61
- : () => {};
62
-
63
- if (shortcuts[i]?.type === ShortcutType.Item) {
64
- const payload = shortcuts[i]?.payload as IItem | undefined;
65
-
66
- let itemsFromEquipment: (IItem | undefined | null)[] = [];
67
-
68
- if (inventory) {
69
- Object.keys(inventory.slots).forEach(i => {
70
- const index = parseInt(i);
71
-
72
- if (inventory.slots[index]?.key === payload?.key) {
73
- itemsFromEquipment.push(inventory.slots[index]);
74
- }
75
- });
76
- }
77
-
78
- const totalQty = itemsFromEquipment.reduce(
79
- (acc, item) => acc + (item?.stackQty || 1),
80
- 0
81
- );
82
-
83
- return (
84
- <StyledShortcut
85
- key={i}
86
- onTouchStart={onTouchStart}
87
- onTouchEnd={onTouchEnd.bind(null, onShortcutClickBinded)}
88
- disabled={false}
89
- className={variant}
90
- >
91
- {payload && (
92
- <SpriteFromAtlas
93
- atlasIMG={atlasIMG}
94
- atlasJSON={atlasJSON}
95
- spriteKey={getItemTextureKeyPath(
96
- {
97
- key: payload.texturePath,
98
- texturePath: payload.texturePath,
99
- stackQty: payload.stackQty || 1,
100
- },
101
- atlasJSON
102
- )}
103
- width={32}
104
- height={32}
105
- imgScale={1.4}
106
- imgStyle={{ left: '4px' }}
107
- />
108
- )}
109
- <span className="qty">{totalQty}</span>
110
- </StyledShortcut>
111
- );
112
- }
113
-
114
- const payload = shortcuts[i]?.payload as IRawSpell | undefined;
115
-
116
- return (
117
- <StyledShortcut
118
- key={i}
119
- onTouchStart={onTouchStart}
120
- onTouchEnd={onTouchEnd.bind(null, onShortcutClickBinded)}
121
- disabled={mana < (payload?.manaCost ?? 0)}
122
- className={variant}
123
- >
124
- <span className="mana">{payload && payload.manaCost}</span>
125
- <span className="magicWords">
126
- {payload?.magicWords.split(' ').map(word => word[0])}
127
- </span>
128
- </StyledShortcut>
129
- );
130
- };
131
-
132
- return (
133
- <ButtonsContainer>
134
- <ShortcutsContainer>
135
- {Array.from({ length: 6 }).map((_, i) => renderShortcut(i))}
136
- </ShortcutsContainer>
137
- <Button
138
- onTouchStart={onTouchStart}
139
- onTouchEnd={onTouchEnd.bind(null, onActionClick)}
140
- >
141
- <div className="rpgui-icon sword" />
142
- </Button>
143
-
144
- <CancelButton
145
- onTouchStart={onTouchStart}
146
- onTouchEnd={onTouchEnd.bind(null, onCancelClick)}
147
- >
148
- <span>X</span>
149
- </CancelButton>
150
- </ButtonsContainer>
151
- );
152
- };
153
-
154
- const Button = styled.button`
155
- width: 4.3rem;
156
- height: 4.3rem;
157
- background-color: ${uiColors.lightGray};
158
- border: 2px solid ${uiColors.darkGray};
159
- border-radius: 50%;
160
- text-transform: uppercase;
161
- font-size: 0.7rem;
162
- font-weight: bold;
163
- display: flex;
164
- align-items: center;
165
- justify-content: center;
166
- position: relative;
167
- transition: background-color 0.1s;
168
- margin-top: -3rem;
169
-
170
- &.active {
171
- background-color: ${uiColors.gray};
172
- }
173
-
174
- .sword {
175
- transform: rotate(-45deg);
176
- height: 2.5rem;
177
- width: 1.9rem;
178
- pointer-events: none;
179
- }
180
- `;
181
-
182
- const CancelButton = styled(Button)`
183
- width: 3rem;
184
- height: 3rem;
185
- font-size: 0.8rem;
186
-
187
- span {
188
- margin-top: 4px;
189
- margin-left: 2px;
190
- pointer-events: none;
191
- }
192
- `;
193
-
194
- const ButtonsContainer = styled.div`
195
- display: flex;
196
- align-items: center;
197
- justify-content: center;
198
- gap: 0.5rem;
199
- `;
200
-
201
- const ShortcutsContainer = styled.div`
202
- display: flex;
203
- align-items: center;
204
- justify-content: center;
205
- gap: 0.5rem;
206
- flex-direction: column;
207
- margin-top: 3rem;
208
-
209
- .top {
210
- transform: translate(93%, 25%);
211
- }
212
-
213
- .bottom-0 {
214
- transform: translate(93%, -25%);
215
- }
216
-
217
- .bottom-1 {
218
- transform: translate(-120%, calc(-5.5rem));
219
- }
220
-
221
- .bottom-2 {
222
- transform: translate(-30%, calc(-5.5rem - 25%));
223
- }
224
- `;
225
-
226
- const StyledShortcut = styled(SingleShortcut)`
227
- width: 2.5rem;
228
- height: 2.5rem;
229
- transition: background-color 0.1s;
230
-
231
- .mana,
232
- .qty {
233
- font-size: 0.5rem;
234
- }
235
-
236
- &:hover,
237
- &:focus,
238
- &:active {
239
- background-color: ${uiColors.lightGray};
240
- }
241
-
242
- &.active {
243
- background-color: ${uiColors.gray};
244
- }
245
- `;
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 { SpellShortcut } from '../Spellbook/QuickSpells';
6
+
7
+ export type CircularControllerProps = {
8
+ onActionPointerDown: () => void;
9
+ onCancelClick: () => void;
10
+ onSpellClick: (spellKey: string) => void;
11
+ mana: number;
12
+ spells: IRawSpell[];
13
+ };
14
+
15
+ export const CircularController: React.FC<CircularControllerProps> = ({
16
+ onActionPointerDown,
17
+ onCancelClick,
18
+ onSpellClick,
19
+ mana,
20
+ spells,
21
+ }) => {
22
+ const onTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => {
23
+ const target = e.target as HTMLButtonElement;
24
+ target?.classList.add('active');
25
+ };
26
+
27
+ const onTouchEnd = (
28
+ action: () => void,
29
+ e: React.TouchEvent<HTMLButtonElement>
30
+ ) => {
31
+ const target = e.target as HTMLButtonElement;
32
+ setTimeout(() => {
33
+ target?.classList.remove('active');
34
+ }, 100);
35
+ action();
36
+ };
37
+
38
+ return (
39
+ <ButtonsContainer>
40
+ <SpellsContainer>
41
+ {Array.from({ length: 4 }).map((_, i) => {
42
+ const variant = i === 0 ? 'top' : i === 3 ? 'bottom' : '';
43
+ const spell = spells[i];
44
+
45
+ const onSpellClickBinded = spell
46
+ ? onSpellClick.bind(null, spell.key)
47
+ : () => {};
48
+
49
+ return (
50
+ <StyledShortcut
51
+ key={i}
52
+ disabled={mana < spell?.manaCost}
53
+ onTouchStart={onTouchStart}
54
+ onTouchEnd={onTouchEnd.bind(null, onSpellClickBinded)}
55
+ className={variant}
56
+ >
57
+ <span className="mana">{spell?.key && spell?.manaCost}</span>
58
+ <span className="magicWords">
59
+ {spell?.magicWords.split(' ').map(word => word[0])}
60
+ </span>
61
+ </StyledShortcut>
62
+ );
63
+ })}
64
+ </SpellsContainer>
65
+ <Button
66
+ onTouchStart={onTouchStart}
67
+ onTouchEnd={onTouchEnd.bind(null, onActionPointerDown)}
68
+ >
69
+ <div className="rpgui-icon sword" />
70
+ </Button>
71
+
72
+ <CancelButton
73
+ onTouchStart={onTouchStart}
74
+ onTouchEnd={onTouchEnd.bind(null, onCancelClick)}
75
+ >
76
+ <span>X</span>
77
+ </CancelButton>
78
+ </ButtonsContainer>
79
+ );
80
+ };
81
+
82
+ const Button = styled.button`
83
+ width: 4.3rem;
84
+ height: 4.3rem;
85
+ background-color: ${uiColors.lightGray};
86
+ border: 2px solid ${uiColors.darkGray};
87
+ border-radius: 50%;
88
+ text-transform: uppercase;
89
+ font-size: 0.7rem;
90
+ font-weight: bold;
91
+ display: flex;
92
+ align-items: center;
93
+ justify-content: center;
94
+ position: relative;
95
+ transition: background-color 0.1s;
96
+
97
+ &.active {
98
+ background-color: ${uiColors.gray};
99
+ }
100
+
101
+ .sword {
102
+ transform: rotate(-45deg);
103
+ height: 2.5rem;
104
+ width: 1.9rem;
105
+ pointer-events: none;
106
+ }
107
+ `;
108
+
109
+ const CancelButton = styled(Button)`
110
+ width: 3rem;
111
+ height: 3rem;
112
+ font-size: 0.8rem;
113
+
114
+ span {
115
+ margin-top: 4px;
116
+ margin-left: 2px;
117
+ pointer-events: none;
118
+ }
119
+ `;
120
+
121
+ const ButtonsContainer = styled.div`
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: center;
125
+ gap: 0.5rem;
126
+ `;
127
+
128
+ const SpellsContainer = styled.div`
129
+ display: flex;
130
+ align-items: center;
131
+ justify-content: center;
132
+ gap: 0.4rem;
133
+ flex-direction: column;
134
+
135
+ .top {
136
+ transform: translate(93%, 25%);
137
+ }
138
+
139
+ .bottom {
140
+ transform: translate(93%, -25%);
141
+ }
142
+ `;
143
+
144
+ const StyledShortcut = styled(SpellShortcut)`
145
+ width: 2.5rem;
146
+ height: 2.5rem;
147
+ transition: background-color 0.1s;
148
+
149
+ .mana {
150
+ font-size: 0.5rem;
151
+ }
152
+
153
+ &:hover,
154
+ &:focus,
155
+ &:active {
156
+ background-color: ${uiColors.lightGray};
157
+ }
158
+
159
+ &.active {
160
+ background-color: ${uiColors.gray};
161
+ }
162
+ `;