@rpg-engine/long-bow 0.3.57 → 0.3.59

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 (157) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/CircularController/CircularController.d.ts +7 -4
  4. package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -1
  5. package/dist/components/Item/Inventory/ItemSlot.d.ts +1 -0
  6. package/dist/components/Shortcuts/Shortcuts.d.ts +12 -0
  7. package/dist/components/Shortcuts/ShortcutsSetter.d.ts +12 -0
  8. package/dist/components/Shortcuts/SingleShortcut.d.ts +1 -0
  9. package/dist/components/Spellbook/Spellbook.d.ts +5 -3
  10. package/dist/components/Spellbook/constants.d.ts +3 -3
  11. package/dist/index.d.ts +1 -1
  12. package/dist/long-bow.cjs.development.js +1168 -1025
  13. package/dist/long-bow.cjs.development.js.map +1 -1
  14. package/dist/long-bow.cjs.production.min.js +1 -1
  15. package/dist/long-bow.cjs.production.min.js.map +1 -1
  16. package/dist/long-bow.esm.js +831 -687
  17. package/dist/long-bow.esm.js.map +1 -1
  18. package/dist/stories/{QuickSpells.stories.d.ts → Shortcuts.stories.d.ts} +2 -2
  19. package/package.json +100 -100
  20. package/src/components/Abstractions/SlotsContainer.tsx +45 -45
  21. package/src/components/Arrow/SelectArrow.tsx +69 -69
  22. package/src/components/Arrow/img/arrow01-left-clicked.png +0 -0
  23. package/src/components/Arrow/img/arrow01-left.png +0 -0
  24. package/src/components/Arrow/img/arrow01-right-clicked.png +0 -0
  25. package/src/components/Arrow/img/arrow01-right.png +0 -0
  26. package/src/components/Arrow/img/arrow02-left-clicked.png +0 -0
  27. package/src/components/Arrow/img/arrow02-left.png +0 -0
  28. package/src/components/Arrow/img/arrow02-right-clicked.png +0 -0
  29. package/src/components/Arrow/img/arrow02-right.png +0 -0
  30. package/src/components/Button.tsx +40 -40
  31. package/src/components/Character/CharacterSelection.tsx +96 -96
  32. package/src/components/CharacterStatus/CharacterStatus.tsx +120 -120
  33. package/src/components/Chat/Chat.tsx +195 -195
  34. package/src/components/Chatdeprecated/ChatDeprecated.tsx +198 -198
  35. package/src/components/CheckButton.tsx +65 -65
  36. package/src/components/CircularController/CircularController.tsx +245 -162
  37. package/src/components/CraftBook/CraftBook.tsx +224 -224
  38. package/src/components/CraftBook/MockItems.ts +46 -46
  39. package/src/components/DraggableContainer.tsx +153 -153
  40. package/src/components/Dropdown.tsx +90 -90
  41. package/src/components/DropdownSelectorContainer.tsx +42 -42
  42. package/src/components/Equipment/EquipmentSet.tsx +190 -190
  43. package/src/components/HistoryDialog.tsx +104 -104
  44. package/src/components/Input.tsx +15 -15
  45. package/src/components/Item/Cards/ItemTooltip.tsx +33 -33
  46. package/src/components/Item/Inventory/ErrorBoundary.tsx +42 -42
  47. package/src/components/Item/Inventory/ItemContainer.tsx +210 -175
  48. package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -6
  49. package/src/components/Item/Inventory/ItemQuantitySelector.tsx +138 -138
  50. package/src/components/Item/Inventory/ItemSlot.tsx +501 -467
  51. package/src/components/Item/Inventory/itemContainerHelper.ts +156 -156
  52. package/src/components/ListMenu.tsx +63 -63
  53. package/src/components/Multitab/Tab.tsx +66 -66
  54. package/src/components/Multitab/TabBody.tsx +13 -13
  55. package/src/components/Multitab/TabsContainer.tsx +97 -97
  56. package/src/components/NPCDialog/NPCDialog.tsx +121 -121
  57. package/src/components/NPCDialog/NPCDialogText.tsx +113 -113
  58. package/src/components/NPCDialog/NPCMultiDialog.tsx +159 -159
  59. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -237
  60. package/src/components/ProgressBar.tsx +92 -92
  61. package/src/components/PropertySelect/PropertySelect.tsx +106 -106
  62. package/src/components/QuestInfo/QuestInfo.tsx +230 -230
  63. package/src/components/QuestList.tsx +129 -129
  64. package/src/components/RPGUIContainer.tsx +47 -47
  65. package/src/components/RPGUIForceRenderStart.tsx +45 -45
  66. package/src/components/RPGUIRoot.tsx +14 -14
  67. package/src/components/RadioButton.tsx +53 -53
  68. package/src/components/RadioInput/RadioButton.tsx +96 -96
  69. package/src/components/RadioInput/RadioInput.tsx +102 -102
  70. package/src/components/RadioInput/instruments.ts +15 -15
  71. package/src/components/RangeSlider.tsx +78 -78
  72. package/src/components/RelativeListMenu.tsx +83 -83
  73. package/src/components/ScrollList.tsx +79 -79
  74. package/src/components/Shortcuts/Shortcuts.tsx +129 -0
  75. package/src/components/Shortcuts/ShortcutsSetter.tsx +132 -0
  76. package/src/components/Shortcuts/SingleShortcut.ts +61 -0
  77. package/src/components/SimpleProgressBar.tsx +62 -62
  78. package/src/components/SkillProgressBar.tsx +133 -133
  79. package/src/components/SkillsContainer.tsx +198 -198
  80. package/src/components/Spellbook/Spell.tsx +201 -201
  81. package/src/components/Spellbook/Spellbook.tsx +150 -144
  82. package/src/components/Spellbook/constants.ts +8 -12
  83. package/src/components/Spellbook/mockSpells.ts +60 -60
  84. package/src/components/StaticBook/StaticBook.tsx +103 -103
  85. package/src/components/TextArea.tsx +11 -11
  86. package/src/components/TimeWidget/DayNightPeriod/DayNightPeriod.tsx +35 -35
  87. package/src/components/TimeWidget/TimeWidget.tsx +63 -63
  88. package/src/components/TradingMenu/TradingItemRow.tsx +193 -193
  89. package/src/components/TradingMenu/TradingMenu.tsx +203 -203
  90. package/src/components/TradingMenu/items.mock.ts +96 -96
  91. package/src/components/Truncate.tsx +25 -25
  92. package/src/components/itemSelector/ItemSelector.tsx +136 -136
  93. package/src/components/shared/Column.tsx +16 -16
  94. package/src/components/shared/Ellipsis.tsx +65 -65
  95. package/src/components/shared/SpriteFromAtlas.tsx +102 -102
  96. package/src/components/typography/DynamicText.tsx +49 -49
  97. package/src/constants/uiColors.ts +20 -20
  98. package/src/constants/uiDevices.ts +3 -3
  99. package/src/constants/uiFonts.ts +12 -12
  100. package/src/hooks/useEventListener.ts +21 -21
  101. package/src/hooks/useOutsideAlerter.ts +25 -25
  102. package/src/index.tsx +40 -40
  103. package/src/libs/StringHelpers.ts +3 -3
  104. package/src/mocks/atlas/entities/entities.json +20215 -20215
  105. package/src/mocks/atlas/icons/icons.json +735 -735
  106. package/src/mocks/atlas/items/items.json +12086 -12086
  107. package/src/mocks/equipmentSet.mocks.ts +393 -393
  108. package/src/mocks/itemContainer.mocks.ts +562 -560
  109. package/src/mocks/skills.mocks.ts +128 -128
  110. package/src/stories/Arrow.stories.tsx +26 -26
  111. package/src/stories/Button.stories.tsx +36 -36
  112. package/src/stories/CharacterSelection.stories.tsx +45 -45
  113. package/src/stories/CharacterStatus.stories.tsx +29 -29
  114. package/src/stories/Chat.stories.tsx +187 -187
  115. package/src/stories/ChatDeprecated.stories.tsx +170 -170
  116. package/src/stories/CheckButton.stories.tsx +48 -48
  117. package/src/stories/CircullarController.stories.tsx +37 -33
  118. package/src/stories/CraftBook.stories.tsx +40 -40
  119. package/src/stories/DayNightPeriod.stories.tsx +27 -27
  120. package/src/stories/DraggableContainer.stories.tsx +28 -28
  121. package/src/stories/Dropdown.stories.tsx +46 -46
  122. package/src/stories/DropdownSelectorContainer.stories.tsx +41 -41
  123. package/src/stories/EquipmentSet.stories.tsx +65 -65
  124. package/src/stories/HistoryDialog.stories.tsx +61 -61
  125. package/src/stories/ItemContainer.stories.tsx +198 -124
  126. package/src/stories/ItemQuantitySelector.stories.tsx +26 -26
  127. package/src/stories/ItemSelector.stories.tsx +77 -77
  128. package/src/stories/ItemTradingComponent.stories.tsx +35 -35
  129. package/src/stories/ListMenu.stories.tsx +56 -56
  130. package/src/stories/Multitab.stories.tsx +51 -51
  131. package/src/stories/NPCDialog.stories.tsx +130 -130
  132. package/src/stories/NPCMultiDialog.stories.tsx +71 -71
  133. package/src/stories/ProgressBar.stories.tsx +23 -23
  134. package/src/stories/PropertySelect.stories.tsx +40 -40
  135. package/src/stories/QuestInfo.stories.tsx +107 -107
  136. package/src/stories/QuestList.stories.tsx +82 -82
  137. package/src/stories/RPGUIContainers.stories.tsx +42 -42
  138. package/src/stories/RadioButton.stories.tsx +49 -49
  139. package/src/stories/RadioInput.stories.tsx +34 -34
  140. package/src/stories/RangeSlider.stories.tsx +64 -64
  141. package/src/stories/ScrollList.stories.tsx +85 -85
  142. package/src/stories/Shortcuts.stories.tsx +39 -0
  143. package/src/stories/SimpleProgressBar.stories.tsx +22 -22
  144. package/src/stories/SkillProgressBar.stories.tsx +34 -34
  145. package/src/stories/SkillsContainer.stories.tsx +35 -35
  146. package/src/stories/Spellbook.stories.tsx +104 -107
  147. package/src/stories/StaticBook.stories.tsx +32 -32
  148. package/src/stories/Text.stories.tsx +42 -42
  149. package/src/stories/TimeWidget.stories.tsx +27 -27
  150. package/src/stories/TradingMenu.stories.tsx +45 -45
  151. package/src/types/eventTypes.ts +4 -4
  152. package/src/types/index.d.ts +2 -2
  153. package/dist/components/Spellbook/QuickSpells.d.ts +0 -10
  154. package/dist/components/Spellbook/SpellbookShortcuts.d.ts +0 -10
  155. package/src/components/Spellbook/QuickSpells.tsx +0 -120
  156. package/src/components/Spellbook/SpellbookShortcuts.tsx +0 -77
  157. package/src/stories/QuickSpells.stories.tsx +0 -38
@@ -1,162 +1,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
- `;
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
+ `;