@rpg-engine/long-bow 0.8.12 → 0.8.14

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.
@@ -0,0 +1 @@
1
+ export declare const toUppercaseHexColor: (color: string | undefined) => string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.12",
3
+ "version": "0.8.14",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  import { GRID_HEIGHT, GRID_WIDTH } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
- import styled from 'styled-components';
3
+ import styled, { css } from 'styled-components';
4
+ import { toUppercaseHexColor } from '../../utils/colorUtils';
4
5
 
5
6
  interface IProps {
6
7
  atlasJSON: any;
@@ -51,6 +52,11 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
51
52
  return null;
52
53
  }
53
54
 
55
+ const normalizedTintColor = toUppercaseHexColor(tintColor);
56
+ // For white tint, we'll use a very light gray instead
57
+ const effectiveTintColor =
58
+ normalizedTintColor === '#FFFFFF' ? '#EEEEEE' : normalizedTintColor;
59
+
54
60
  return (
55
61
  <Container
56
62
  width={width}
@@ -69,7 +75,7 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
69
75
  style={imgStyle}
70
76
  centered={centered}
71
77
  borderRadius={borderRadius}
72
- tintColor={tintColor}
78
+ tintColor={effectiveTintColor}
73
79
  />
74
80
  </Container>
75
81
  );
@@ -112,23 +118,59 @@ const ImgSprite = styled.div<IImgSpriteProps>`
112
118
  width: ${props => props.frame.w}px;
113
119
  height: ${props => props.frame.h}px;
114
120
  background-image: url(${props => props.atlasIMG});
115
- background-position: -${props => props.frame.x}px -${props => props.frame.y}px;
121
+ background-position: -${props => props.frame.x}px -${props =>
122
+ props.frame.y}px;
116
123
  transform: scale(${props => props.scale});
117
124
  position: relative;
118
125
  top: ${props => (props.centered ? '0' : '8px')};
119
126
  left: ${props => (props.centered ? '0' : '8px')};
120
- filter: ${props => {
121
- const filters = [];
122
- if (props.grayScale) filters.push('grayscale(100%)');
123
- if (props.tintColor)
124
- filters.push(
125
- `brightness(0.8) contrast(1.2) sepia(100%) hue-rotate(${
126
- props.tintColor === '#FFD700' ? '40deg' : '210deg'
127
- }) saturate(400%)`
128
- );
129
- return filters.length ? filters.join(' ') : 'none';
130
- }};
131
127
  opacity: ${props => props.opacity};
132
128
  border-radius: ${props => props.borderRadius || '0'};
133
129
  overflow: hidden;
130
+
131
+ /* Apply grayscale if needed */
132
+ ${props =>
133
+ props.grayScale &&
134
+ css`
135
+ filter: grayscale(100%);
136
+ `}
137
+
138
+ /* Add tint overlay if tintColor is provided */
139
+ ${props =>
140
+ props.tintColor &&
141
+ css`
142
+ &::before {
143
+ content: '';
144
+ position: absolute;
145
+ top: 0;
146
+ left: 0;
147
+ width: ${props.frame.w}px;
148
+ height: ${props.frame.h}px;
149
+ background-color: ${props.tintColor};
150
+ mix-blend-mode: multiply;
151
+ opacity: 0.6;
152
+ pointer-events: none;
153
+ -webkit-mask-image: url(${props.atlasIMG});
154
+ -webkit-mask-position: -${props.frame.x}px -${props.frame.y}px;
155
+ mask-image: url(${props.atlasIMG});
156
+ mask-position: -${props.frame.x}px -${props.frame.y}px;
157
+ }
158
+
159
+ &::after {
160
+ content: '';
161
+ position: absolute;
162
+ top: 0;
163
+ left: 0;
164
+ width: ${props.frame.w}px;
165
+ height: ${props.frame.h}px;
166
+ background-color: ${props.tintColor};
167
+ mix-blend-mode: soft-light;
168
+ opacity: 0.6;
169
+ pointer-events: none;
170
+ -webkit-mask-image: url(${props.atlasIMG});
171
+ -webkit-mask-position: -${props.frame.x}px -${props.frame.y}px;
172
+ mask-image: url(${props.atlasIMG});
173
+ mask-position: -${props.frame.x}px -${props.frame.y}px;
174
+ }
175
+ `}
134
176
  `;
@@ -8,6 +8,44 @@ import {
8
8
  UserAccountTypes,
9
9
  } from '@rpg-engine/shared';
10
10
 
11
+ const createBagItem = (id: string, tintColor: string): IItem => ({
12
+ _id: id,
13
+ hasUseWith: false,
14
+ type: ItemType.Container,
15
+ subType: ItemSubType.Other,
16
+ textureAtlas: 'items',
17
+ allowedEquipSlotType: [ItemSlotType.Inventory],
18
+ isEquipable: false,
19
+ isStackable: true,
20
+ maxStackSize: 100,
21
+ isUsable: false,
22
+ isStorable: true,
23
+ isTwoHanded: false,
24
+ layer: 1,
25
+ isItemContainer: true,
26
+ isSolid: false,
27
+ key: 'bag',
28
+ texturePath: 'containers/bag.png',
29
+ textureKey: 'bag',
30
+ name: 'Bag',
31
+ generateContainerSlots: 10,
32
+ description:
33
+ 'You see a bag. It has made using leather and it has 10 total slots.',
34
+ attack: 7,
35
+ defense: 3,
36
+ weight: 13,
37
+ tiledId: 67,
38
+ x: 320,
39
+ y: 144,
40
+ scene: 'MainScene',
41
+ fullDescription:
42
+ 'You see a bag. It has made using leather and it has 10 total slots.',
43
+ createdAt: '2022-06-04T03:18:09.335Z',
44
+ updatedAt: '2022-06-04T18:16:49.056Z',
45
+ rarity: ItemRarities.Common,
46
+ tintColor,
47
+ });
48
+
11
49
  export const items: IItem[] = [
12
50
  {
13
51
  _id: '629acef1c7c8e8002ff60736',
@@ -286,44 +324,14 @@ export const items: IItem[] = [
286
324
  updatedAt: '2022-06-04T18:16:49.056Z',
287
325
  rarity: ItemRarities.Common,
288
326
  },
289
- {
290
- _id: '392acek4j7c8e8002ff60404',
291
- hasUseWith: false,
292
- type: ItemType.Container,
293
- subType: ItemSubType.Other,
294
- textureAtlas: 'items',
295
- allowedEquipSlotType: [ItemSlotType.Inventory],
296
- isEquipable: false,
297
- isStackable: true,
298
- maxStackSize: 100,
299
-
300
- isUsable: false,
301
- isStorable: true,
302
- isTwoHanded: false,
303
- layer: 1,
304
- isItemContainer: true,
305
- isSolid: false,
306
- key: 'bag',
307
- texturePath: 'containers/bag.png',
308
- textureKey: 'bag',
309
- name: 'Bag',
310
- generateContainerSlots: 10,
311
- description:
312
- 'You see a bag. It has made using leather and it has 10 total slots.',
313
- attack: 7,
314
- defense: 3,
315
- weight: 13,
316
- tiledId: 67,
317
- x: 320,
318
- y: 144,
319
- scene: 'MainScene',
320
- fullDescription:
321
- 'You see a bag. It has made using leather and it has 10 total slots.',
322
- createdAt: '2022-06-04T03:18:09.335Z',
323
- updatedAt: '2022-06-04T18:16:49.056Z',
324
- rarity: ItemRarities.Common,
325
- tintColor: '#FFD700',
326
- },
327
+ createBagItem('392acek4j7c8e8002ff60404', '#FF0000'), // red
328
+ createBagItem('392acek4j7c8e8002ff60405', '#0000FF'), // blue
329
+ createBagItem('392acek4j7c8e8002ff60406', '#00FF00'), // green
330
+ createBagItem('392acek4j7c8e8002ff60407', '#FFFF00'), // yellow
331
+ createBagItem('392acek4j7c8e8002ff60408', '#800080'), // purple
332
+ createBagItem('392acek4j7c8e8002ff60409', '#FFA500'), // orange
333
+ createBagItem('392acek4j7c8e8002ff60410', '#00FFFF'), // cyan
334
+ createBagItem('392acek4j7c8e8002ff60411', '#FFFFFF'), // white
327
335
  {
328
336
  _id: '392acek4j7c8e80d2fs60404',
329
337
  hasUseWith: false,
@@ -0,0 +1,11 @@
1
+ export const toUppercaseHexColor = (
2
+ color: string | undefined
3
+ ): string | undefined => {
4
+ if (!color) return undefined;
5
+
6
+ // Check if it's a valid hex color
7
+ const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
8
+ if (!hexRegex.test(color)) return color;
9
+
10
+ return color.toUpperCase();
11
+ };