@rpg-engine/long-bow 0.2.24 → 0.2.26

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.2.24",
3
+ "version": "0.2.26",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -23,7 +23,6 @@ export class ErrorBoundary extends Component<Props, State> {
23
23
 
24
24
  public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
25
25
  console.error('Uncaught error:', error, errorInfo);
26
- console.log('quelquer cois');
27
26
  }
28
27
 
29
28
  public render() {
@@ -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';
@@ -102,14 +103,13 @@ export const ItemSlot: React.FC<IProps> = observer(
102
103
  const renderItem = (itemToRender: IItem | null) => {
103
104
  const element = [];
104
105
  if (itemToRender?.texturePath) {
105
- console.table(itemToRender);
106
106
  element.push(
107
107
  <ErrorBoundary>
108
108
  <SpriteFromAtlas
109
109
  key={itemToRender._id}
110
110
  atlasIMG={atlasIMG}
111
111
  atlasJSON={atlasJSON}
112
- spriteKey={itemToRender.texturePath}
112
+ spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
113
113
  imgScale={3}
114
114
  />
115
115
  </ErrorBoundary>
@@ -138,7 +138,7 @@ export const ItemSlot: React.FC<IProps> = observer(
138
138
  key={itemToRender._id}
139
139
  atlasIMG={atlasIMG}
140
140
  atlasJSON={atlasJSON}
141
- spriteKey={itemToRender.texturePath}
141
+ spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
142
142
  imgScale={3}
143
143
  />
144
144
  </ErrorBoundary>
@@ -7,7 +7,6 @@ interface IProps {
7
7
  }
8
8
 
9
9
  export const Ellipsis = ({ children, maxLines }: IProps) => {
10
- console.log('Ellipsis Component 2');
11
10
  return (
12
11
  <Container>
13
12
  <div className={`ellipsis-${maxLines}-lines`}>{children}</div>
@@ -0,0 +1,25 @@
1
+ import { IItem } from "@rpg-engine/shared";
2
+
3
+ export const getItemTextureKeyPath = (itemToRender: IItem, atlasJSON: any) => {
4
+
5
+ const stackQty = itemToRender?.stackQty ?? 0;
6
+ const itemTexturePath = itemToRender.texturePath;
7
+
8
+ if (itemToRender && stackQty > 1) {
9
+ const idx = stackQty >= 5 ? '5' : stackQty;
10
+
11
+ const textureBreakPath = itemTexturePath.split('.');
12
+ const txtPrefix: string = textureBreakPath[0];
13
+ const txtExtension: string = textureBreakPath[1];
14
+
15
+ const newTexturePath = `${txtPrefix}-qty-${idx}.${txtExtension}`;
16
+ const spriteData = atlasJSON.frames[newTexturePath];
17
+
18
+ if (spriteData !== undefined) {
19
+ return newTexturePath;
20
+ }
21
+ }
22
+ return itemTexturePath;
23
+
24
+ };
25
+