@rpg-engine/long-bow 0.8.33 → 0.8.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.33",
3
+ "version": "0.8.35",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -11,7 +11,6 @@ import { DraggableContainer } from '../DraggableContainer';
11
11
  import { InternalTabs } from '../InternalTabs/InternalTabs';
12
12
  import { RPGUIContainerTypes } from '../RPGUI/RPGUIContainer';
13
13
  import { InformationCenterBestiarySection } from './sections/bestiary/InformationCenterBestiarySection';
14
- import { InformationCenterFAQSection } from './sections/faq/InformationCenterFaqSection';
15
14
  import { InformationCenterItemsSection } from './sections/items/InformationCenterItemsSection';
16
15
  import { InformationCenterTutorialsSection } from './sections/tutorials/InformationCenterTutorialsSection';
17
16
 
@@ -38,7 +37,6 @@ export const InformationCenter: React.FC<IInformationCenterProps> = ({
38
37
  entitiesAtlasIMG,
39
38
  iconsAtlasIMG,
40
39
  iconsAtlasJSON,
41
- faqItems = [],
42
40
  bestiaryItems = [],
43
41
  videoGuides = [],
44
42
  items = [],
@@ -88,17 +86,6 @@ export const InformationCenter: React.FC<IInformationCenterProps> = ({
88
86
  />
89
87
  ),
90
88
  },
91
- {
92
- id: 'faq',
93
- title: 'FAQ',
94
- content: (
95
- <InformationCenterFAQSection
96
- faqItems={faqItems}
97
- initialSearchQuery={initialSearchQuery}
98
- tabId="faq"
99
- />
100
- ),
101
- },
102
89
  {
103
90
  id: 'tutorials',
104
91
  title: 'Tutorials',
@@ -1,18 +1,23 @@
1
1
  import {
2
+ IInformationCenterItem,
2
3
  IInformationCenterNPC,
3
4
  isMobileOrTablet,
5
+ ItemRarities,
6
+ ItemSubType,
7
+ ItemType,
4
8
  MovementSpeed,
5
9
  RangeTypes,
6
10
  } from '@rpg-engine/shared';
7
- import React, { useState } from 'react';
11
+ import React, { useEffect, useState } from 'react';
8
12
  import styled from 'styled-components';
9
13
  import { uiColors } from '../../../../constants/uiColors';
10
14
  import { Collapsible } from '../../../shared/Collapsible/Collapsible';
11
15
  import { Pagination } from '../../../shared/Pagination/Pagination';
16
+ import { Portal } from '../../../shared/Portal/Portal';
12
17
  import { SearchBar } from '../../../shared/SearchBar/SearchBar';
13
18
  import { SpriteFromAtlas } from '../../../shared/SpriteFromAtlas';
14
-
15
19
  import { BaseInformationDetails } from '../../shared/BaseInformationDetails';
20
+ import { InformationCenterItemDetails } from '../items/InformationCenterItemDetails';
16
21
 
17
22
  interface INPCDetailsProps {
18
23
  npc: IInformationCenterNPC;
@@ -54,6 +59,14 @@ export const InformationCenterNPCDetails: React.FC<INPCDetailsProps> = ({
54
59
  const isMobile = isMobileOrTablet();
55
60
  const [lootSearchQuery, setLootSearchQuery] = useState('');
56
61
  const [currentLootPage, setCurrentLootPage] = useState(1);
62
+ const [
63
+ selectedItem,
64
+ setSelectedItem,
65
+ ] = useState<IInformationCenterItem | null>(null);
66
+
67
+ useEffect(() => {
68
+ setCurrentLootPage(1);
69
+ }, [lootSearchQuery]);
57
70
 
58
71
  const formatText = (text: string | RangeTypes | MovementSpeed): string => {
59
72
  if (typeof text === 'number') {
@@ -101,6 +114,26 @@ export const InformationCenterNPCDetails: React.FC<INPCDetailsProps> = ({
101
114
  currentLootPage * ITEMS_PER_PAGE
102
115
  );
103
116
 
117
+ const handleItemClick = (loot: any) => {
118
+ const item: IInformationCenterItem = {
119
+ key: loot.itemBlueprintKey,
120
+ name: formatItemName(loot.itemBlueprintKey),
121
+ texturePath: loot.itemBlueprintKey,
122
+ textureAtlas: 'items',
123
+ type: ItemType.Weapon,
124
+ subType: ItemSubType.Sword,
125
+ tier: 1,
126
+ rarity: ItemRarities.Common,
127
+ weight: 0,
128
+ maxStackSize: loot.quantityRange ? loot.quantityRange[1] : 1,
129
+ canSell: true,
130
+ description: 'A basic item.',
131
+ basePrice: 100,
132
+ allowedEquipSlotType: [],
133
+ };
134
+ setSelectedItem(item);
135
+ };
136
+
104
137
  return (
105
138
  <BaseInformationDetails
106
139
  name={npc.name}
@@ -153,13 +186,19 @@ export const InformationCenterNPCDetails: React.FC<INPCDetailsProps> = ({
153
186
  <LootSearchContainer>
154
187
  <StyledSearchBar
155
188
  value={lootSearchQuery}
156
- onChange={setLootSearchQuery}
189
+ onChange={(query: string) => {
190
+ setLootSearchQuery(query);
191
+ setCurrentLootPage(1);
192
+ }}
157
193
  placeholder="Search loot..."
158
194
  />
159
195
  </LootSearchContainer>
160
196
  <LootGrid>
161
197
  {paginatedLoots.map((loot, index) => (
162
- <LootItem key={index}>
198
+ <LootItem
199
+ key={`${loot.itemBlueprintKey}-${index}`}
200
+ onClick={() => handleItemClick(loot)}
201
+ >
163
202
  <SpriteFromAtlas
164
203
  atlasJSON={itemsAtlasJSON}
165
204
  atlasIMG={itemsAtlasIMG}
@@ -232,6 +271,18 @@ export const InformationCenterNPCDetails: React.FC<INPCDetailsProps> = ({
232
271
  </SpellsList>
233
272
  </StyledCollapsible>
234
273
  )}
274
+
275
+ {selectedItem && (
276
+ <Portal>
277
+ <InformationCenterItemDetails
278
+ item={selectedItem}
279
+ itemsAtlasJSON={itemsAtlasJSON}
280
+ itemsAtlasIMG={itemsAtlasIMG}
281
+ droppedBy={[npc]}
282
+ onBack={() => setSelectedItem(null)}
283
+ />
284
+ </Portal>
285
+ )}
235
286
  </BaseInformationDetails>
236
287
  );
237
288
  };
@@ -399,6 +450,13 @@ const LootItem = styled.div`
399
450
  padding: 4px;
400
451
  border-radius: 4px;
401
452
  min-width: 0;
453
+ cursor: pointer;
454
+ user-select: none;
455
+ transition: background-color 0.2s ease;
456
+
457
+ &:hover {
458
+ background: rgba(255, 255, 255, 0.1);
459
+ }
402
460
  `;
403
461
 
404
462
  const LootDetails = styled.div`
@@ -406,27 +464,32 @@ const LootDetails = styled.div`
406
464
  display: flex;
407
465
  flex-direction: column;
408
466
  gap: 4px;
467
+ user-select: none;
409
468
  `;
410
469
 
411
470
  const LootName = styled.div`
412
471
  color: ${uiColors.white};
413
472
  font-size: 0.5rem;
473
+ user-select: none;
414
474
  `;
415
475
 
416
476
  const LootInfo = styled.div`
417
477
  display: flex;
418
478
  align-items: center;
419
479
  gap: 8px;
480
+ user-select: none;
420
481
  `;
421
482
 
422
483
  const LootChance = styled.span`
423
484
  color: ${uiColors.yellow};
424
485
  font-size: 0.45rem;
486
+ user-select: none;
425
487
  `;
426
488
 
427
489
  const LootQuantity = styled.span`
428
490
  color: ${uiColors.lightGray};
429
491
  font-size: 0.45rem;
492
+ user-select: none;
430
493
  `;
431
494
 
432
495
  const PaginationContainer = styled.div`
@@ -10,7 +10,7 @@ import itemsAtlasJSON from '../../../mocks/atlas/items/items.json';
10
10
  import itemsAtlasIMG from '../../../mocks/atlas/items/items.png';
11
11
 
12
12
  import { IInformationCenterItem } from '@rpg-engine/shared';
13
- import { mockBestiaryItems, mockFaqItems, mockItems, mockTutorials } from '../../../mocks/informationCenter.mocks';
13
+ import { mockBestiaryItems, mockItems, mockTutorials } from '../../../mocks/informationCenter.mocks';
14
14
 
15
15
 
16
16
  const meta: Meta = {
@@ -32,7 +32,7 @@ const Template: Story = args => (
32
32
  entitiesAtlasIMG={entitiesAtlasIMG}
33
33
  iconsAtlasJSON={iconsAtlasJSON}
34
34
  iconsAtlasIMG={iconsAtlasIMG}
35
- faqItems={mockFaqItems}
35
+ // faqItems={mockFaqItems}
36
36
  bestiaryItems={mockBestiaryItems}
37
37
  videoGuides={mockTutorials}
38
38
  items={mockItems as unknown as IInformationCenterItem[]}