@rpg-engine/long-bow 0.5.12 → 0.5.13

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.5.12",
3
+ "version": "0.5.13",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@rollup/plugin-image": "^2.1.1",
86
- "@rpg-engine/shared": "^0.8.81",
86
+ "@rpg-engine/shared": "^0.8.74",
87
87
  "dayjs": "^1.11.2",
88
88
  "font-awesome": "^4.7.0",
89
89
  "fs-extra": "^10.1.0",
@@ -13,6 +13,7 @@ import { ItemQuantitySelector } from './ItemQuantitySelector';
13
13
 
14
14
  import { IPosition } from '../../../types/eventTypes';
15
15
  import ModalPortal from '../../Abstractions/ModalPortal';
16
+ import SelectArrow from '../../Arrow/SelectArrow';
16
17
  import { ShortcutsSetter } from '../../Shortcuts/ShortcutsSetter';
17
18
  import { ItemSlot } from './ItemSlot';
18
19
 
@@ -81,12 +82,15 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
81
82
  onPositionChangeEnd,
82
83
  onPositionChangeStart,
83
84
  }) => {
85
+ const MAX_SLOTS_PER_PAGE = 20;
84
86
  const [quantitySelect, setQuantitySelect] = useState({
85
87
  isOpen: false,
86
88
  maxQuantity: 1,
87
- callback: (_quantity: number) => {},
89
+ callback: (_quantity: number) => { },
88
90
  });
89
91
  const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
92
+ const [currentPage, setCurrentPage] = useState(1);
93
+ const totalPages = Math.ceil(itemContainer.slotQty / MAX_SLOTS_PER_PAGE);
90
94
 
91
95
  const handleSetShortcut = (item: IItem, index: number) => {
92
96
  if (item.type === ItemType.Consumable || item.type === ItemType.Tool) {
@@ -96,8 +100,11 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
96
100
 
97
101
  const onRenderSlots = () => {
98
102
  const slots = [];
103
+ const start = (currentPage - 1) * MAX_SLOTS_PER_PAGE;
104
+ const end = start + MAX_SLOTS_PER_PAGE;
99
105
 
100
- for (let i = 0; i < itemContainer.slotQty; i++) {
106
+ for (let i = start; i < end && i < itemContainer.slotQty; i++) {
107
+ console.log(itemContainer)
101
108
  slots.push(
102
109
  <ItemSlot
103
110
  isContextMenuDisabled={disableContextMenu}
@@ -156,6 +163,14 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
156
163
  return slots;
157
164
  };
158
165
 
166
+ const goToNextPage = () => {
167
+ setCurrentPage(current => Math.min(current + 1, totalPages));
168
+ };
169
+
170
+ const goToPreviousPage = () => {
171
+ setCurrentPage(current => Math.max(current - 1, 1));
172
+ };
173
+
159
174
  return (
160
175
  <>
161
176
  <SlotsContainer
@@ -181,6 +196,32 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
181
196
  <ItemsContainer className="item-container-body">
182
197
  {onRenderSlots()}
183
198
  </ItemsContainer>
199
+ {totalPages > 1 && (
200
+ <ArrowContainer>
201
+ {currentPage > 1 && (
202
+ <SelectArrow
203
+ className='arrow .arrow-up'
204
+ direction="left"
205
+ onPointerDown={() => {
206
+ if (currentPage > 1) {
207
+ goToPreviousPage();
208
+ }
209
+ }}
210
+ />
211
+ )}
212
+ {currentPage < totalPages && (
213
+ <SelectArrow
214
+ className='arrow .arrow-down'
215
+ direction="right"
216
+ onPointerDown={() => {
217
+ if (currentPage < totalPages) {
218
+ goToNextPage();
219
+ }
220
+ }}
221
+ />
222
+ )}
223
+ </ArrowContainer>
224
+ )}
184
225
  </SlotsContainer>
185
226
  {quantitySelect.isOpen && (
186
227
  <ModalPortal>
@@ -192,7 +233,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
192
233
  setQuantitySelect({
193
234
  isOpen: false,
194
235
  maxQuantity: 1,
195
- callback: () => {},
236
+ callback: () => { },
196
237
  });
197
238
  }}
198
239
  onClose={() => {
@@ -200,7 +241,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
200
241
  setQuantitySelect({
201
242
  isOpen: false,
202
243
  maxQuantity: 1,
203
- callback: () => {},
244
+ callback: () => { },
204
245
  });
205
246
  }}
206
247
  />
@@ -229,3 +270,17 @@ const QuantitySelectorContainer = styled.div`
229
270
  align-items: center;
230
271
  background-color: rgba(0, 0, 0, 0.5);
231
272
  `;
273
+
274
+ const ArrowContainer = styled.div`
275
+ margin-top: 10px;
276
+ margin-bottom: 30px;
277
+ /* Aplica a margem ao primeiro span (seta para a esquerda) */
278
+ span:first-child {
279
+ margin-left: 20px;
280
+ }
281
+
282
+ /* Aplica a margem ao último span (seta para a direita) */
283
+ span:last-child {
284
+ margin-right: 20px;
285
+ }
286
+ `;
@@ -2,7 +2,6 @@ import {
2
2
  getItemTextureKeyPath,
3
3
  IEquipmentSet,
4
4
  ITradeResponseItem,
5
- UserAccountTypes,
6
5
  } from '@rpg-engine/shared';
7
6
  import capitalize from 'lodash/capitalize';
8
7
  import React from 'react';
@@ -24,7 +23,6 @@ export interface ITradeComponentProps {
24
23
  selectedQty: number;
25
24
  equipmentSet?: IEquipmentSet | null;
26
25
  scale?: number;
27
- isBuy?: boolean;
28
26
  }
29
27
 
30
28
  const outerQty = 10;
@@ -37,7 +35,6 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
37
35
  selectedQty,
38
36
  equipmentSet,
39
37
  scale,
40
- isBuy,
41
38
  }) => {
42
39
  const onLeftClick = (qty = 1) => {
43
40
  onQuantityChange(traderItem, Math.max(0, selectedQty - qty));
@@ -50,40 +47,6 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
50
47
  );
51
48
  };
52
49
 
53
- const renderAccountTypeIndicator = () => {
54
- if (isBuy) {
55
- switch (traderItem?.accountType) {
56
- case UserAccountTypes.PremiumBronze:
57
- return (
58
- <div>
59
- <SmallCircle color="#CD7F32" /> Account
60
- </div>
61
- );
62
- case UserAccountTypes.PremiumSilver:
63
- return (
64
- <div>
65
- <SmallCircle color="#C0C0C0" /> Account
66
- </div>
67
- );
68
- case UserAccountTypes.PremiumGold:
69
- return (
70
- <div>
71
- <SmallCircle color="#FFD700" /> Account
72
- </div>
73
- );
74
- case UserAccountTypes.PremiumUltimate:
75
- return (
76
- <div>
77
- <SmallCircle color="#002E99" /> Account
78
- </div>
79
- );
80
- default:
81
- return null;
82
- }
83
- }
84
- return null;
85
- };
86
-
87
50
  return (
88
51
  <ItemWrapper>
89
52
  <ItemIconContainer>
@@ -118,7 +81,6 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
118
81
  <p>
119
82
  <Ellipsis maxLines={1} maxWidth="250px">
120
83
  {capitalize(traderItem.name)}
121
- {renderAccountTypeIndicator()}
122
84
  </Ellipsis>
123
85
  </p>
124
86
  <p>${traderItem.price}</p>
@@ -159,16 +121,6 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
159
121
  );
160
122
  };
161
123
 
162
- // Styled component for the small circle
163
- const SmallCircle = styled.span<{ color: string }>`
164
- display: inline-block;
165
- margin-left: 8px;
166
- height: 10px;
167
- width: 10px;
168
- background-color: ${({ color }) => color};
169
- border-radius: 50%;
170
- `;
171
-
172
124
  const StyledArrow = styled(SelectArrow)`
173
125
  margin: 40px;
174
126
  `;
@@ -110,7 +110,6 @@ export const TradingMenu: React.FC<ITradingMenu> = ({
110
110
  selectedQty={qtyMap.get(tradeItem.key) ?? 0}
111
111
  equipmentSet={equipmentSet}
112
112
  scale={scale}
113
- isBuy={isBuy()}
114
113
  />
115
114
  </ItemWrapper>
116
115
  ))}
@@ -577,7 +577,7 @@ export const itemContainerMock: IItemContainer = {
577
577
  _id: '629ba0b6fe3f43002f58f23b',
578
578
  name: 'Item Container',
579
579
  owner: '629ba0b6fe3f43002f58f23b',
580
- slotQty: 20,
580
+ slotQty: 60,
581
581
  slots: {
582
582
  0: items[0],
583
583
  1: items[1],
@@ -595,6 +595,7 @@ export const itemContainerMock: IItemContainer = {
595
595
  13: items[13],
596
596
  14: items[14],
597
597
  15: items[15],
598
+ 21: items[15],
598
599
  //remaining slots are considered null by default
599
600
  },
600
601
  allowedItemTypes: [],