@rpg-engine/long-bow 0.2.24 → 0.2.25
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/dist/libs/ItemSlotHelper.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +791 -300
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +791 -300
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +22 -3
- package/src/libs/ItemSlotHelper.ts +21 -0
- package/src/mocks/atlas/items/items.json +702 -246
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +19 -14
- package/src/mocks/itemContainer.mocks.ts +226 -3
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { observer } from 'mobx-react-lite';
|
|
10
10
|
import React, { useEffect, useState } from 'react';
|
|
11
11
|
import styled from 'styled-components';
|
|
12
|
+
import { getItemTextureKeyPath } from '../../../libs/ItemSlotHelper';
|
|
12
13
|
import { RelativeListMenu } from '../../RelativeListMenu';
|
|
13
14
|
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
14
15
|
import { ItemTooltip } from '../Cards/ItemTooltip';
|
|
@@ -99,17 +100,35 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
99
100
|
return undefined;
|
|
100
101
|
};
|
|
101
102
|
|
|
103
|
+
// const getItemTextureKeyPath = (itemToRender: IItem) => {
|
|
104
|
+
// const stackQty = itemToRender?.stackQty ?? 0;
|
|
105
|
+
// let itemTexturePath = itemToRender.texturePath;
|
|
106
|
+
|
|
107
|
+
// if (stackQty > 1) {
|
|
108
|
+
// const txtExtension: string = itemToRender.texturePath.split('.')[1];
|
|
109
|
+
// const txtDir: string = itemToRender.texturePath.split('/')[0];
|
|
110
|
+
// const idx = stackQty >= 5 ? '5' : stackQty;
|
|
111
|
+
// const newTexturePath = `${txtDir}/${itemToRender.textureKey}-qty-${idx}.${txtExtension}`;
|
|
112
|
+
// const spriteData = atlasJSON.frames[newTexturePath];
|
|
113
|
+
|
|
114
|
+
// if (spriteData !== undefined) {
|
|
115
|
+
// itemTexturePath = newTexturePath;
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
|
|
119
|
+
// return itemTexturePath;
|
|
120
|
+
// };
|
|
121
|
+
|
|
102
122
|
const renderItem = (itemToRender: IItem | null) => {
|
|
103
123
|
const element = [];
|
|
104
124
|
if (itemToRender?.texturePath) {
|
|
105
|
-
console.table(itemToRender);
|
|
106
125
|
element.push(
|
|
107
126
|
<ErrorBoundary>
|
|
108
127
|
<SpriteFromAtlas
|
|
109
128
|
key={itemToRender._id}
|
|
110
129
|
atlasIMG={atlasIMG}
|
|
111
130
|
atlasJSON={atlasJSON}
|
|
112
|
-
spriteKey={itemToRender
|
|
131
|
+
spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
|
|
113
132
|
imgScale={3}
|
|
114
133
|
/>
|
|
115
134
|
</ErrorBoundary>
|
|
@@ -138,7 +157,7 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
138
157
|
key={itemToRender._id}
|
|
139
158
|
atlasIMG={atlasIMG}
|
|
140
159
|
atlasJSON={atlasJSON}
|
|
141
|
-
spriteKey={itemToRender
|
|
160
|
+
spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
|
|
142
161
|
imgScale={3}
|
|
143
162
|
/>
|
|
144
163
|
</ErrorBoundary>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IItem } from "@rpg-engine/shared";
|
|
2
|
+
|
|
3
|
+
export const getItemTextureKeyPath = (itemToRender: IItem, atlasJSON: any) => {
|
|
4
|
+
const stackQty = itemToRender?.stackQty ?? 0;
|
|
5
|
+
let itemTexturePath = itemToRender.texturePath;
|
|
6
|
+
|
|
7
|
+
if (itemToRender.isStackable && stackQty > 1) {
|
|
8
|
+
const txtExtension: string = itemToRender.texturePath.split('.')[1];
|
|
9
|
+
const txtDir: string = itemToRender.texturePath.split('/')[0];
|
|
10
|
+
const idx = stackQty >= 5 ? '5' : stackQty;
|
|
11
|
+
const newTexturePath = `${txtDir}/${itemToRender.textureKey}-qty-${idx}.${txtExtension}`;
|
|
12
|
+
const spriteData = atlasJSON.frames[newTexturePath];
|
|
13
|
+
|
|
14
|
+
if (spriteData !== undefined) {
|
|
15
|
+
itemTexturePath = newTexturePath;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return itemTexturePath;
|
|
20
|
+
};
|
|
21
|
+
|