@rpg-engine/long-bow 0.8.67 → 0.8.69

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.67",
3
+ "version": "0.8.69",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -2,10 +2,13 @@ import { IStoreItem, MetadataType } from '@rpg-engine/shared';
2
2
  import React, { useState } from 'react';
3
3
  import { FaInfoCircle, FaShoppingBag, FaTimes, FaTrash } from 'react-icons/fa';
4
4
  import styled from 'styled-components';
5
+ import characterAtlasJSON from '../../mocks/atlas/entities/entities.json';
6
+ import characterAtlasIMG from '../../mocks/atlas/entities/entities.png';
5
7
  import { CTAButton } from '../shared/CTAButton/CTAButton';
6
8
  import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
7
9
 
8
10
 
11
+
9
12
  interface ICartViewProps {
10
13
  cartItems: {
11
14
  item: IStoreItem;
@@ -31,7 +34,7 @@ const MetadataDisplay: React.FC<{
31
34
  <FaInfoCircle />
32
35
  <span>Skin:</span>
33
36
  </MetadataLabel>
34
- <MetadataValue>{metadata.selectedSkin?.name || 'Custom skin'}</MetadataValue>
37
+ <MetadataValue>{metadata.selectedSkinName || 'Custom skin'}</MetadataValue>
35
38
  </MetadataInfo>
36
39
  );
37
40
  default:
@@ -87,48 +90,55 @@ export const CartView: React.FC<ICartViewProps> = ({
87
90
  {cartItems.length === 0 ? (
88
91
  <EmptyCart>Your cart is empty</EmptyCart>
89
92
  ) : (
90
- cartItems.map(cartItem => (
91
- <CartItemRow key={cartItem.item.key}>
92
- <ItemIconContainer>
93
- <SpriteFromAtlas
94
- atlasJSON={atlasJSON}
95
- atlasIMG={atlasIMG}
96
- spriteKey={cartItem.item.texturePath}
97
- width={32}
98
- height={32}
99
- imgScale={2}
100
- centered
101
- />
102
- </ItemIconContainer>
103
- <ItemDetails>
104
- <ItemName>{cartItem.item.name}</ItemName>
105
- <ItemInfo>
106
- <span>${formatPrice(cartItem.item.price)}</span>
107
- <span>×</span>
108
- <span>{cartItem.quantity}</span>
109
- <span>=</span>
110
- <span>
111
- ${formatPrice(cartItem.item.price * cartItem.quantity)}
112
- </span>
113
- </ItemInfo>
114
-
115
- {cartItem.metadata && cartItem.item.metadataType && (
116
- <MetadataDisplay
117
- type={cartItem.item.metadataType}
118
- metadata={cartItem.metadata}
93
+ cartItems.map(cartItem => {
94
+ console.log('Item metadataType: , texturePath:', cartItem.item.metadataType , cartItem.item.texturePath);
95
+ const getSpriteKey = (textureKey: string) => {
96
+ return textureKey + '/down/standing/0.png';
97
+ };
98
+
99
+ return (
100
+ <CartItemRow key={cartItem.item.key}>
101
+ <ItemIconContainer>
102
+ <SpriteFromAtlas
103
+ atlasJSON={cartItem.item.metadataType === MetadataType.CharacterSkin ? characterAtlasJSON : atlasJSON}
104
+ atlasIMG={cartItem.item.metadataType === MetadataType.CharacterSkin ? characterAtlasIMG : atlasIMG}
105
+ spriteKey={cartItem.item.metadataType === MetadataType.CharacterSkin && cartItem.metadata?.selectedSkinTextureKey ? getSpriteKey(cartItem.metadata.selectedSkinTextureKey) : cartItem.item.texturePath}
106
+ width={32}
107
+ height={32}
108
+ imgScale={2}
109
+ centered
119
110
  />
120
- )}
121
- </ItemDetails>
122
-
123
- <CTAButton
124
- icon={<FaTrash />}
125
- onClick={e => {
126
- e.stopPropagation();
127
- onRemoveFromCart(cartItem.item.key);
128
- }}
129
- />
130
- </CartItemRow>
131
- ))
111
+ </ItemIconContainer>
112
+ <ItemDetails>
113
+ <ItemName>{cartItem.item.name}</ItemName>
114
+ <ItemInfo>
115
+ <span>${formatPrice(cartItem.item.price)}</span>
116
+ <span>×</span>
117
+ <span>{cartItem.quantity}</span>
118
+ <span>=</span>
119
+ <span>
120
+ ${formatPrice(cartItem.item.price * cartItem.quantity)}
121
+ </span>
122
+ </ItemInfo>
123
+
124
+ {cartItem.metadata && cartItem.item.metadataType && (
125
+ <MetadataDisplay
126
+ type={cartItem.item.metadataType}
127
+ metadata={cartItem.metadata}
128
+ />
129
+ )}
130
+ </ItemDetails>
131
+
132
+ <CTAButton
133
+ icon={<FaTrash />}
134
+ onClick={e => {
135
+ e.stopPropagation();
136
+ onRemoveFromCart(cartItem.item.key);
137
+ }}
138
+ />
139
+ </CartItemRow>
140
+ );
141
+ })
132
142
  )}
133
143
  </CartItems>
134
144
 
@@ -1,6 +1,6 @@
1
- import { IItemPack, IStoreItem, IStoreProps, ItemRarities, ItemSubType, ItemType } from '@rpg-engine/shared';
1
+ import { IItemPack, IPurchase, IStoreItem, ItemRarities, ItemSubType, ItemType, UserAccountTypes } from '@rpg-engine/shared';
2
2
  import React, { useMemo, useState } from 'react';
3
- import { FaShoppingCart } from 'react-icons/fa';
3
+ import { FaHistory, FaShoppingCart } from 'react-icons/fa';
4
4
  import styled from 'styled-components';
5
5
  import { uiColors } from '../../constants/uiColors';
6
6
  import { DraggableContainer } from '../DraggableContainer';
@@ -14,12 +14,27 @@ import { StoreItemsSection } from './sections/StoreItemsSection';
14
14
  import { StorePacksSection } from './sections/StorePacksSection';
15
15
  import { StoreItemDetails } from './StoreItemDetails';
16
16
 
17
+ // Define IStoreProps locally as a workaround
18
+ export interface IStoreProps {
19
+ items: IStoreItem[];
20
+ packs?: IItemPack[];
21
+ atlasJSON: any;
22
+ atlasIMG: string;
23
+ onPurchase: (purchase: Partial<IPurchase>) => Promise<boolean>;
24
+ onShowHistory?: () => void; // Add the new optional prop
25
+ userAccountType: UserAccountTypes;
26
+ loading?: boolean;
27
+ error?: string;
28
+ onClose?: () => void;
29
+ }
30
+
17
31
  export const Store: React.FC<IStoreProps> = ({
18
32
  items,
19
33
  packs = [],
20
34
  atlasJSON,
21
35
  atlasIMG,
22
36
  onPurchase,
37
+ onShowHistory, // Destructure the new prop
23
38
  userAccountType,
24
39
  loading = false,
25
40
  error,
@@ -202,6 +217,15 @@ export const Store: React.FC<IStoreProps> = ({
202
217
  ) : (
203
218
  <Container>
204
219
  <TopBar>
220
+ <HistoryButton>
221
+ {onShowHistory && (
222
+ <CTAButton
223
+ icon={<FaHistory />}
224
+ label="History"
225
+ onClick={onShowHistory}
226
+ />
227
+ )}
228
+ </HistoryButton>
205
229
  <CartButton>
206
230
  <CTAButton
207
231
  icon={<FaShoppingCart />}
@@ -267,6 +291,11 @@ const TopBar = styled.div`
267
291
  margin-top: 0.5rem;
268
292
  `;
269
293
 
294
+ const HistoryButton = styled.div`
295
+ min-width: fit-content;
296
+ margin-right: auto;
297
+ `;
298
+
270
299
  const CartButton = styled.div`
271
300
  min-width: fit-content;
272
301
  `;
@@ -78,10 +78,10 @@ export const StoreCharacterSkinRow: React.FC<IStoreCharacterSkinRowProps> = ({
78
78
  if (!hasRequiredAccount) return;
79
79
 
80
80
  // If we have character skins, add the selected skin to the purchase
81
- if (availableCharacters.length > 0) {
82
- const selectedCharacter = availableCharacters[currentIndex];
81
+ if (availableCharacters.length > 0 && currentCharacter) {
83
82
  onAddToCart(item, quantity, {
84
- selectedSkin: selectedCharacter.textureKey
83
+ selectedSkinName: currentCharacter.name,
84
+ selectedSkinTextureKey: currentCharacter.textureKey
85
85
  });
86
86
  } else {
87
87
  onAddToCart(item, quantity);
@@ -238,9 +238,11 @@ export const Default: Story = {
238
238
  items={duplicatedItems}
239
239
  packs={mockPacks}
240
240
  userAccountType={UserAccountTypes.Free}
241
- onPurchase={(purchase: IPurchase) => {
241
+ onPurchase={(purchase: Partial<IPurchase>) => {
242
242
  console.log('Purchase details:', purchase);
243
+ return Promise.resolve(true);
243
244
  }}
245
+ onShowHistory={() => console.log('Show History clicked in story')}
244
246
  onClose={() => console.log('Store closed')}
245
247
  atlasJSON={itemsAtlasJSON}
246
248
  atlasIMG={itemsAtlasIMG}
@@ -1,2 +1,3 @@
1
1
  declare module '*.gif';
2
2
  declare module '*.png';
3
+ declare module '*.json';