@rpg-engine/long-bow 0.1.69 → 0.1.72

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 (41) hide show
  1. package/dist/components/Abstractions/SlotsContainer.d.ts +11 -0
  2. package/dist/components/DraggableContainer.d.ts +2 -1
  3. package/dist/components/Equipment/EquipmentSet.d.ts +13 -0
  4. package/dist/components/Item/Inventory/ItemSlot.d.ts +10 -2
  5. package/dist/components/Item/Inventory/itemContainerHelper.d.ts +6 -2
  6. package/dist/components/Multitab/Tab.d.ts +9 -0
  7. package/dist/components/Multitab/TabBody.d.ts +7 -0
  8. package/dist/components/Multitab/TabsContainer.d.ts +17 -0
  9. package/dist/components/{Item → shared}/SpriteFromAtlas.d.ts +4 -1
  10. package/dist/components/shared/SpriteIcon.d.ts +9 -0
  11. package/dist/components/store/UI.store.d.ts +34 -0
  12. package/dist/index.d.ts +3 -1
  13. package/dist/long-bow.cjs.development.js +2137 -449
  14. package/dist/long-bow.cjs.development.js.map +1 -1
  15. package/dist/long-bow.cjs.production.min.js +1 -1
  16. package/dist/long-bow.cjs.production.min.js.map +1 -1
  17. package/dist/long-bow.esm.js +2139 -451
  18. package/dist/long-bow.esm.js.map +1 -1
  19. package/dist/mocks/equipmentSet.mocks.d.ts +3 -0
  20. package/package.json +4 -2
  21. package/src/components/Abstractions/SlotsContainer.tsx +42 -0
  22. package/src/components/DraggableContainer.tsx +63 -36
  23. package/src/components/Equipment/EquipmentSet.tsx +179 -0
  24. package/src/components/Item/Inventory/ItemContainer.tsx +70 -178
  25. package/src/components/Item/Inventory/ItemSlot.tsx +93 -25
  26. package/src/components/Item/Inventory/itemContainerHelper.ts +48 -11
  27. package/src/components/ListMenu.tsx +4 -4
  28. package/src/components/Multitab/Tab.tsx +57 -0
  29. package/src/components/Multitab/TabBody.tsx +13 -0
  30. package/src/components/Multitab/TabsContainer.tsx +99 -0
  31. package/src/components/SkillProgressBar.tsx +2 -2
  32. package/src/components/{Item → shared}/SpriteFromAtlas.tsx +24 -4
  33. package/src/components/shared/SpriteIcon.tsx +67 -0
  34. package/src/components/store/UI.store.ts +192 -0
  35. package/src/index.tsx +3 -1
  36. package/src/mocks/atlas/icons/icons.json +303 -0
  37. package/src/mocks/atlas/icons/icons.png +0 -0
  38. package/src/mocks/atlas/items/items.json +1209 -181
  39. package/src/mocks/atlas/items/items.png +0 -0
  40. package/src/mocks/equipmentSet.mocks.ts +347 -0
  41. package/src/mocks/itemContainer.mocks.ts +33 -33
@@ -0,0 +1,192 @@
1
+ import {
2
+ IItem,
3
+ IPayloadProps,
4
+ ItemSocketEvents,
5
+ ItemSocketEventsDisplayLabels,
6
+ ItemType,
7
+ } from '@rpg-engine/shared';
8
+ import { makeAutoObservable, toJS } from 'mobx';
9
+ import {
10
+ handleContextMenuList,
11
+ handleEquipmentContextMenuList,
12
+ IContextMenuItem,
13
+ } from '../Item/Inventory/itemContainerHelper';
14
+ import { SlotContainerType } from '../Item/Inventory/ItemSlot';
15
+
16
+ interface IContextMenu {
17
+ visible: boolean;
18
+ posX: number;
19
+ posY: number;
20
+ slotItem: IItem | null;
21
+ slotIndex?: number | null;
22
+ contextActions: IContextMenuItem[];
23
+ }
24
+
25
+ interface IHoverDetail {
26
+ visible: boolean;
27
+ posX: number;
28
+ posY: number;
29
+ item: IItem | null;
30
+ }
31
+
32
+ interface ISetContextMenu extends Omit<IContextMenu, 'contextActions'> {}
33
+
34
+ const initialState = {
35
+ visible: false,
36
+ posX: 0,
37
+ posY: 0,
38
+ contextActions: [],
39
+ slotItem: null,
40
+ };
41
+
42
+ const initialHoverState = {
43
+ visible: false,
44
+ posX: 0,
45
+ posY: 0,
46
+ item: null,
47
+ };
48
+ class UIStore {
49
+ public contextMenu: IContextMenu | null = initialState;
50
+
51
+ public onHoverDetail: IHoverDetail | null = initialHoverState;
52
+
53
+ constructor() {
54
+ makeAutoObservable(this);
55
+ }
56
+
57
+ public setContextMenu(contextMenu: ISetContextMenu, itemType: ItemType) {
58
+ const contextActions = handleContextMenuList(itemType);
59
+
60
+ this.contextMenu = {
61
+ ...contextMenu,
62
+ contextActions,
63
+ };
64
+
65
+ console.log(toJS(this.contextMenu));
66
+ }
67
+
68
+ public setEquipContextMenu(
69
+ contextMenu: ISetContextMenu,
70
+ itemType: ItemType,
71
+ isItemContainer: boolean | undefined
72
+ ) {
73
+ const contextActions = handleEquipmentContextMenuList(itemType);
74
+ if (isItemContainer)
75
+ contextActions.push({
76
+ id: ItemSocketEvents.ContainerOpen,
77
+ text: ItemSocketEventsDisplayLabels[ItemSocketEvents.ContainerOpen],
78
+ });
79
+ this.contextMenu = {
80
+ ...contextMenu,
81
+ contextActions,
82
+ };
83
+
84
+ console.log(toJS(this.contextMenu));
85
+ }
86
+
87
+ public clearContextMenu() {
88
+ this.contextMenu = initialState;
89
+ }
90
+
91
+ public setItemHoverDetail(hoverDetail: IHoverDetail) {
92
+ if (hoverDetail?.item === null) this.clearItemHoverDetail();
93
+
94
+ this.onHoverDetail = {
95
+ ...hoverDetail,
96
+ };
97
+ }
98
+
99
+ public clearItemHoverDetail() {
100
+ this.onHoverDetail = initialHoverState;
101
+ }
102
+
103
+ public handleOnItemClick = (
104
+ item: IItem,
105
+ posX: number,
106
+ posY: number,
107
+ slotContainerType: SlotContainerType | null
108
+ ): void => {
109
+ if (
110
+ !item ||
111
+ JSON.stringify(this.contextMenu?.slotItem) === JSON.stringify(item)
112
+ ) {
113
+ this.clearContextMenu();
114
+ this.clearItemHoverDetail();
115
+ return;
116
+ }
117
+ switch (slotContainerType) {
118
+ case SlotContainerType.EQUIPMENT_SET:
119
+ this.setEquipContextMenu(
120
+ {
121
+ visible: true,
122
+ posX,
123
+ posY,
124
+ slotItem: item,
125
+ },
126
+ item.type,
127
+ item.isItemContainer
128
+ );
129
+ break;
130
+ case SlotContainerType.INVENTORY:
131
+ this.setContextMenu(
132
+ {
133
+ visible: true,
134
+ posX,
135
+ posY,
136
+ slotItem: item,
137
+ },
138
+ item.type
139
+ );
140
+ break;
141
+ default:
142
+ this.setContextMenu(
143
+ {
144
+ visible: true,
145
+ posX,
146
+ posY,
147
+ slotItem: item,
148
+ },
149
+ item.type
150
+ );
151
+ }
152
+
153
+ this.clearItemHoverDetail();
154
+ };
155
+
156
+ public handleOnMouseHover = (
157
+ event: any,
158
+ slotIndex: number,
159
+ item: IItem | null,
160
+ posX: number,
161
+ posY: number,
162
+ onMouseOver: any
163
+ ): void => {
164
+ if (item) {
165
+ this.setItemHoverDetail({
166
+ visible: true,
167
+ posX,
168
+ posY,
169
+ item: item,
170
+ });
171
+ }
172
+ if (onMouseOver) {
173
+ onMouseOver(event, slotIndex, item);
174
+ }
175
+ };
176
+
177
+ public onSelected(
178
+ selectedActionId: ItemSocketEvents | string,
179
+ onActionSelected: any
180
+ ) {
181
+ let payloadData: IPayloadProps = {
182
+ actionType: selectedActionId,
183
+ item: this.contextMenu?.slotItem!,
184
+ };
185
+ if (onActionSelected) {
186
+ onActionSelected(payloadData);
187
+ }
188
+ this.clearContextMenu!();
189
+ }
190
+ }
191
+
192
+ export const uiStore = new UIStore();
package/src/index.tsx CHANGED
@@ -3,10 +3,10 @@ export * from './components/Chat/Chat';
3
3
  export * from './components/CheckButton';
4
4
  export * from './components/DraggableContainer';
5
5
  export * from './components/Dropdown';
6
+ export * from './components/Equipment/EquipmentSet';
6
7
  export * from './components/Input';
7
8
  export * from './components/Item/Inventory/ItemContainer';
8
9
  export * from './components/Item/Inventory/ItemSlot';
9
- export * from './components/Item/SpriteFromAtlas';
10
10
  export * from './components/ListMenu';
11
11
  export * from './components/NPCDialog/NPCDialog';
12
12
  export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
@@ -15,6 +15,8 @@ export * from './components/RadioButton';
15
15
  export * from './components/RangeSlider';
16
16
  export * from './components/RPGUIContainer';
17
17
  export * from './components/RPGUIRoot';
18
+ export * from './components/shared/SpriteFromAtlas';
19
+ export * from './components/shared/SpriteIcon';
18
20
  export * from './components/SkillProgressBar';
19
21
  export * from './components/TextArea';
20
22
  export * from './components/Truncate';
@@ -0,0 +1,303 @@
1
+ {
2
+ "frames": {
3
+ "metamask-large.png": {
4
+ "frame": {
5
+ "x": 0,
6
+ "y": 0,
7
+ "w": 33,
8
+ "h": 30
9
+ },
10
+ "rotated": false,
11
+ "trimmed": false,
12
+ "spriteSourceSize": {
13
+ "x": 0,
14
+ "y": 0,
15
+ "w": 33,
16
+ "h": 30
17
+ },
18
+ "sourceSize": {
19
+ "w": 33,
20
+ "h": 30
21
+ },
22
+ "pivot": {
23
+ "x": 0.5,
24
+ "y": 0.5
25
+ }
26
+ },
27
+ "chat-large.png": {
28
+ "frame": {
29
+ "x": 0,
30
+ "y": 30,
31
+ "w": 31,
32
+ "h": 29
33
+ },
34
+ "rotated": false,
35
+ "trimmed": true,
36
+ "spriteSourceSize": {
37
+ "x": 1,
38
+ "y": 3,
39
+ "w": 31,
40
+ "h": 29
41
+ },
42
+ "sourceSize": {
43
+ "w": 32,
44
+ "h": 32
45
+ },
46
+ "pivot": {
47
+ "x": 0.5,
48
+ "y": 0.5
49
+ }
50
+ },
51
+ "equipment.png": {
52
+ "frame": {
53
+ "x": 33,
54
+ "y": 0,
55
+ "w": 17,
56
+ "h": 16
57
+ },
58
+ "rotated": false,
59
+ "trimmed": false,
60
+ "spriteSourceSize": {
61
+ "x": 0,
62
+ "y": 0,
63
+ "w": 17,
64
+ "h": 16
65
+ },
66
+ "sourceSize": {
67
+ "w": 17,
68
+ "h": 16
69
+ },
70
+ "pivot": {
71
+ "x": 0.5,
72
+ "y": 0.5
73
+ }
74
+ },
75
+ "inventory.png": {
76
+ "frame": {
77
+ "x": 33,
78
+ "y": 16,
79
+ "w": 17,
80
+ "h": 16
81
+ },
82
+ "rotated": false,
83
+ "trimmed": false,
84
+ "spriteSourceSize": {
85
+ "x": 0,
86
+ "y": 0,
87
+ "w": 17,
88
+ "h": 16
89
+ },
90
+ "sourceSize": {
91
+ "w": 17,
92
+ "h": 16
93
+ },
94
+ "pivot": {
95
+ "x": 0.5,
96
+ "y": 0.5
97
+ }
98
+ },
99
+ "icon-base-blue.png": {
100
+ "frame": {
101
+ "x": 31,
102
+ "y": 32,
103
+ "w": 16,
104
+ "h": 16
105
+ },
106
+ "rotated": false,
107
+ "trimmed": false,
108
+ "spriteSourceSize": {
109
+ "x": 0,
110
+ "y": 0,
111
+ "w": 16,
112
+ "h": 16
113
+ },
114
+ "sourceSize": {
115
+ "w": 16,
116
+ "h": 16
117
+ },
118
+ "pivot": {
119
+ "x": 0.5,
120
+ "y": 0.5
121
+ }
122
+ },
123
+ "icon-base-brown.png": {
124
+ "frame": {
125
+ "x": 50,
126
+ "y": 0,
127
+ "w": 16,
128
+ "h": 16
129
+ },
130
+ "rotated": false,
131
+ "trimmed": false,
132
+ "spriteSourceSize": {
133
+ "x": 0,
134
+ "y": 0,
135
+ "w": 16,
136
+ "h": 16
137
+ },
138
+ "sourceSize": {
139
+ "w": 16,
140
+ "h": 16
141
+ },
142
+ "pivot": {
143
+ "x": 0.5,
144
+ "y": 0.5
145
+ }
146
+ },
147
+ "chat-small.png": {
148
+ "frame": {
149
+ "x": 50,
150
+ "y": 16,
151
+ "w": 16,
152
+ "h": 16
153
+ },
154
+ "rotated": false,
155
+ "trimmed": true,
156
+ "spriteSourceSize": {
157
+ "x": 1,
158
+ "y": 0,
159
+ "w": 16,
160
+ "h": 16
161
+ },
162
+ "sourceSize": {
163
+ "w": 17,
164
+ "h": 16
165
+ },
166
+ "pivot": {
167
+ "x": 0.5,
168
+ "y": 0.5
169
+ }
170
+ },
171
+ "icon-base-gold.png": {
172
+ "frame": {
173
+ "x": 47,
174
+ "y": 32,
175
+ "w": 16,
176
+ "h": 16
177
+ },
178
+ "rotated": false,
179
+ "trimmed": false,
180
+ "spriteSourceSize": {
181
+ "x": 0,
182
+ "y": 0,
183
+ "w": 16,
184
+ "h": 16
185
+ },
186
+ "sourceSize": {
187
+ "w": 16,
188
+ "h": 16
189
+ },
190
+ "pivot": {
191
+ "x": 0.5,
192
+ "y": 0.5
193
+ }
194
+ },
195
+ "equipment-raw.png": {
196
+ "frame": {
197
+ "x": 0,
198
+ "y": 59,
199
+ "w": 15,
200
+ "h": 13
201
+ },
202
+ "rotated": false,
203
+ "trimmed": true,
204
+ "spriteSourceSize": {
205
+ "x": 0,
206
+ "y": 0,
207
+ "w": 15,
208
+ "h": 13
209
+ },
210
+ "sourceSize": {
211
+ "w": 16,
212
+ "h": 13
213
+ },
214
+ "pivot": {
215
+ "x": 0.5,
216
+ "y": 0.5
217
+ }
218
+ },
219
+ "metamask-small.png": {
220
+ "frame": {
221
+ "x": 31,
222
+ "y": 48,
223
+ "w": 15,
224
+ "h": 15
225
+ },
226
+ "rotated": false,
227
+ "trimmed": true,
228
+ "spriteSourceSize": {
229
+ "x": 1,
230
+ "y": 0,
231
+ "w": 15,
232
+ "h": 15
233
+ },
234
+ "sourceSize": {
235
+ "w": 16,
236
+ "h": 16
237
+ },
238
+ "pivot": {
239
+ "x": 0.5,
240
+ "y": 0.5
241
+ }
242
+ },
243
+ "settings.png": {
244
+ "frame": {
245
+ "x": 46,
246
+ "y": 48,
247
+ "w": 14,
248
+ "h": 14
249
+ },
250
+ "rotated": false,
251
+ "trimmed": true,
252
+ "spriteSourceSize": {
253
+ "x": 1,
254
+ "y": 1,
255
+ "w": 14,
256
+ "h": 14
257
+ },
258
+ "sourceSize": {
259
+ "w": 16,
260
+ "h": 16
261
+ },
262
+ "pivot": {
263
+ "x": 0.5,
264
+ "y": 0.5
265
+ }
266
+ },
267
+ "inventory-raw.png": {
268
+ "frame": {
269
+ "x": 15,
270
+ "y": 59,
271
+ "w": 13,
272
+ "h": 13
273
+ },
274
+ "rotated": false,
275
+ "trimmed": true,
276
+ "spriteSourceSize": {
277
+ "x": 1,
278
+ "y": 2,
279
+ "w": 13,
280
+ "h": 13
281
+ },
282
+ "sourceSize": {
283
+ "w": 16,
284
+ "h": 16
285
+ },
286
+ "pivot": {
287
+ "x": 0.5,
288
+ "y": 0.5
289
+ }
290
+ }
291
+ },
292
+ "meta": {
293
+ "app": "http://free-tex-packer.com",
294
+ "version": "0.6.7",
295
+ "image": "icons.png",
296
+ "format": "RGBA8888",
297
+ "size": {
298
+ "w": 66,
299
+ "h": 72
300
+ },
301
+ "scale": 1
302
+ }
303
+ }
Binary file