@rpg-engine/long-bow 0.5.2 → 0.5.4

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.
@@ -7,5 +7,6 @@ export interface ITextImageProps {
7
7
  export interface IImageCarouselProps {
8
8
  textImage: ITextImageProps[];
9
9
  isTextFixed: boolean;
10
+ onCloseButton?: () => void;
10
11
  }
11
12
  export declare const ImageCarousel: React.FC<IImageCarouselProps>;
@@ -1,6 +1,8 @@
1
1
  import { ISpell } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
3
  export interface ISpellProps {
4
+ atlasJSON: any;
5
+ atlasIMG: any;
4
6
  charMana: number;
5
7
  charMagicLevel: number;
6
8
  onPointerUp?: (spellKey: string) => void;
@@ -13,6 +13,8 @@ export interface ISpellbookProps {
13
13
  removeShortcut: (index: number) => void;
14
14
  atlasIMG: any;
15
15
  atlasJSON: any;
16
+ iconAtlasIMG?: any;
17
+ iconAtlasJSON?: any;
16
18
  scale?: number;
17
19
  spellCooldowns?: Record<string, number>;
18
20
  }
@@ -12,6 +12,8 @@ interface IProps {
12
12
  imgStyle?: any;
13
13
  imgScale?: number;
14
14
  imgClassname?: string;
15
+ centered?: boolean;
16
+ borderRadius?: string;
15
17
  }
16
18
  export declare const SpriteFromAtlas: React.FC<IProps>;
17
19
  export {};
@@ -117,7 +117,9 @@ var SpriteFromAtlas = function SpriteFromAtlas(_ref) {
117
117
  grayScale = _ref$grayScale === void 0 ? false : _ref$grayScale,
118
118
  _ref$opacity = _ref.opacity,
119
119
  opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
120
- imgClassname = _ref.imgClassname;
120
+ imgClassname = _ref.imgClassname,
121
+ centered = _ref.centered,
122
+ borderRadius = _ref.borderRadius;
121
123
  //! If an item is not showing, remember that you MUST run yarn atlas:copy everytime you add a new item to the atlas (it will sync our public folder atlas with src/atlas).
122
124
  //!Due to React's limitations, we cannot import it from the public folder directly!
123
125
  var spriteData = atlasJSON.frames[spriteKey] || atlasJSON.frames['others/no-image.png'];
@@ -135,7 +137,9 @@ var SpriteFromAtlas = function SpriteFromAtlas(_ref) {
135
137
  scale: imgScale,
136
138
  grayScale: grayScale,
137
139
  opacity: opacity,
138
- style: imgStyle
140
+ style: imgStyle,
141
+ centered: centered,
142
+ borderRadius: borderRadius
139
143
  }));
140
144
  };
141
145
  var Container = /*#__PURE__*/styled.div.withConfig({
@@ -151,7 +155,7 @@ var Container = /*#__PURE__*/styled.div.withConfig({
151
155
  var ImgSprite = /*#__PURE__*/styled.div.withConfig({
152
156
  displayName: "SpriteFromAtlas__ImgSprite",
153
157
  componentId: "sc-1lpani8-1"
154
- })(["width:", "px;height:", "px;background-image:url(", ");background-position:-", "px -", "px;transform:scale(", ");position:relative;top:8px;left:8px;filter:", ";opacity:", ";"], function (props) {
158
+ })(["width:", "px;height:", "px;background-image:url(", ");background-position:-", "px -", "px;transform:scale(", ");position:relative;top:", ";left:", ";filter:", ";opacity:", ";border-radius:", ";"], function (props) {
155
159
  return props.frame.w;
156
160
  }, function (props) {
157
161
  return props.frame.h;
@@ -163,10 +167,16 @@ var ImgSprite = /*#__PURE__*/styled.div.withConfig({
163
167
  return props.frame.y;
164
168
  }, function (props) {
165
169
  return props.scale;
170
+ }, function (props) {
171
+ return props.centered ? '0' : '8px';
172
+ }, function (props) {
173
+ return props.centered ? '0' : '8px';
166
174
  }, function (props) {
167
175
  return props.grayScale ? 'grayscale(100%)' : 'none';
168
176
  }, function (props) {
169
177
  return props.opacity;
178
+ }, function (props) {
179
+ return props.borderRadius ? props.borderRadius : '0';
170
180
  });
171
181
 
172
182
  var frames = {
@@ -12959,6 +12969,11 @@ var CircularController = function CircularController(_ref) {
12959
12969
  var spellCooldown = !payload ? 0 : (_spellCooldowns$paylo = spellCooldowns == null ? void 0 : spellCooldowns[payload.magicWords.replaceAll(' ', '_')]) != null ? _spellCooldowns$paylo : shortcutCooldown;
12960
12970
  var cooldown = spellCooldown > shortcutCooldown ? spellCooldown : shortcutCooldown;
12961
12971
  var isOnCooldown = cooldown > 0 && !!payload;
12972
+ var CONTAINER_STYLE = {
12973
+ width: '32px',
12974
+ height: '32px'
12975
+ };
12976
+ var IMAGE_SCALE = 1.5;
12962
12977
  return React__default.createElement(StyledShortcut, {
12963
12978
  key: i,
12964
12979
  onTouchStart: onTouchStart,
@@ -12971,7 +12986,15 @@ var CircularController = function CircularController(_ref) {
12971
12986
  className: buildClassName('mana', isOnCooldown)
12972
12987
  }, payload && payload.manaCost), React__default.createElement("span", {
12973
12988
  className: "magicWords"
12974
- }, payload == null ? void 0 : payload.magicWords.split(' ').map(function (word) {
12989
+ }, payload != null && payload.texturePath ? React__default.createElement(SpriteFromAtlas, {
12990
+ atlasIMG: payload.atlasIMG,
12991
+ atlasJSON: payload.atlasJSON,
12992
+ spriteKey: payload.texturePath,
12993
+ imgScale: IMAGE_SCALE,
12994
+ containerStyle: CONTAINER_STYLE,
12995
+ centered: true,
12996
+ borderRadius: "50%"
12997
+ }) : payload == null ? void 0 : payload.magicWords.split(' ').map(function (word) {
12975
12998
  return word[0];
12976
12999
  })));
12977
13000
  };
@@ -15143,7 +15166,8 @@ var DialogContainer = /*#__PURE__*/styled.div.withConfig({
15143
15166
  var ImageCarousel = function ImageCarousel(_ref) {
15144
15167
  var _textImageSelected$te, _textImageSelected$te2;
15145
15168
  var textImage = _ref.textImage,
15146
- isTextFixed = _ref.isTextFixed;
15169
+ isTextFixed = _ref.isTextFixed,
15170
+ onCloseButton = _ref.onCloseButton;
15147
15171
  var _useState = React.useState(textImage[0]),
15148
15172
  textImageSelected = _useState[0],
15149
15173
  setTextImageSelected = _useState[1];
@@ -15197,7 +15221,10 @@ var ImageCarousel = function ImageCarousel(_ref) {
15197
15221
  onPointerDown: function onPointerDown() {
15198
15222
  return goToNextImage();
15199
15223
  }
15200
- }))));
15224
+ }))), onCloseButton && React__default.createElement(CloseButton$2, {
15225
+ className: "container-close",
15226
+ onPointerDown: onCloseButton
15227
+ }, "X"));
15201
15228
  };
15202
15229
  var CarouselWrapper = /*#__PURE__*/styled(DraggableContainer).withConfig({
15203
15230
  displayName: "ImageCarousel__CarouselWrapper",
@@ -15225,6 +15252,10 @@ var Description$1 = /*#__PURE__*/styled.div.withConfig({
15225
15252
  }, function (props) {
15226
15253
  return props.isTextFixed ? 'none' : 'rgba(0, 0, 0, 0.6)';
15227
15254
  });
15255
+ var CloseButton$2 = /*#__PURE__*/styled.div.withConfig({
15256
+ displayName: "ImageCarousel__CloseButton",
15257
+ componentId: "sc-jl6f8-4"
15258
+ })(["position:absolute;top:3px;right:0px;color:white;z-index:22;font-size:1.5rem;@media (max-width:950px){font-size:1.7rem;padding:12px;}"]);
15228
15259
 
15229
15260
  var SlotsContainer = function SlotsContainer(_ref) {
15230
15261
  var children = _ref.children,
@@ -15373,7 +15404,7 @@ var ItemQuantitySelector = function ItemQuantitySelector(_ref) {
15373
15404
  return React__default.createElement(StyledContainer, {
15374
15405
  type: exports.RPGUIContainerTypes.Framed,
15375
15406
  width: "25rem"
15376
- }, React__default.createElement(CloseButton$2, {
15407
+ }, React__default.createElement(CloseButton$3, {
15377
15408
  className: "container-close",
15378
15409
  onPointerDown: onClose
15379
15410
  }, "X"), React__default.createElement("h2", null, "Select quantity to move"), React__default.createElement(StyledForm, {
@@ -15431,7 +15462,7 @@ var StyledInput = /*#__PURE__*/styled(Input).withConfig({
15431
15462
  displayName: "ItemQuantitySelector__StyledInput",
15432
15463
  componentId: "sc-yfdtpn-2"
15433
15464
  })(["text-align:center;&::-webkit-outer-spin-button,&::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}&[type='number']{-moz-appearance:textfield;}"]);
15434
- var CloseButton$2 = /*#__PURE__*/styled.div.withConfig({
15465
+ var CloseButton$3 = /*#__PURE__*/styled.div.withConfig({
15435
15466
  displayName: "ItemQuantitySelector__CloseButton",
15436
15467
  componentId: "sc-yfdtpn-3"
15437
15468
  })(["position:absolute;top:3px;right:0px;color:white;z-index:22;font-size:0.8rem;"]);
@@ -15444,19 +15475,19 @@ var ShortcutsSetter = function ShortcutsSetter(_ref) {
15444
15475
  atlasJSON = _ref.atlasJSON,
15445
15476
  atlasIMG = _ref.atlasIMG;
15446
15477
  var getContent = function getContent(index) {
15447
- var _shortcuts$index, _shortcuts$index3;
15478
+ var _shortcuts$index;
15448
15479
  if (((_shortcuts$index = shortcuts[index]) == null ? void 0 : _shortcuts$index.type) === shared.ShortcutType.Item) {
15449
15480
  var _shortcuts$index2;
15450
- var _payload = (_shortcuts$index2 = shortcuts[index]) == null ? void 0 : _shortcuts$index2.payload;
15451
- if (!_payload) return null;
15481
+ var payload = (_shortcuts$index2 = shortcuts[index]) == null ? void 0 : _shortcuts$index2.payload;
15482
+ if (!payload) return null;
15452
15483
  return React__default.createElement(SpriteFromAtlas, {
15453
15484
  atlasIMG: atlasIMG,
15454
15485
  atlasJSON: atlasJSON,
15455
15486
  spriteKey: shared.getItemTextureKeyPath({
15456
- key: _payload.texturePath,
15457
- texturePath: _payload.texturePath,
15458
- stackQty: _payload.stackQty || 1,
15459
- isStackable: _payload.isStackable
15487
+ key: payload.texturePath,
15488
+ texturePath: payload.texturePath,
15489
+ stackQty: payload.stackQty || 1,
15490
+ isStackable: payload.isStackable
15460
15491
  }, atlasJSON),
15461
15492
  width: 32,
15462
15493
  height: 32,
@@ -15466,10 +15497,24 @@ var ShortcutsSetter = function ShortcutsSetter(_ref) {
15466
15497
  }
15467
15498
  });
15468
15499
  }
15469
- var payload = (_shortcuts$index3 = shortcuts[index]) == null ? void 0 : _shortcuts$index3.payload;
15470
- return React__default.createElement("span", null, payload == null ? void 0 : payload.magicWords.split(' ').map(function (word) {
15471
- return word[0];
15472
- }));
15500
+ var IMAGE_SIZE = 32;
15501
+ var IMAGE_SCALE = 1;
15502
+ var shortcut = shortcuts[index];
15503
+ if ((shortcut == null ? void 0 : shortcut.type) === shared.ShortcutType.Spell && shortcut.payload) {
15504
+ var _payload$texturePath;
15505
+ var _payload = shortcut.payload; // TypeScript type assertion
15506
+ return React__default.createElement(SpriteFromAtlas, {
15507
+ atlasIMG: _payload.atlasIMG,
15508
+ atlasJSON: _payload.atlasJSON,
15509
+ spriteKey: (_payload$texturePath = _payload.texturePath) != null ? _payload$texturePath : '',
15510
+ width: IMAGE_SIZE,
15511
+ height: IMAGE_SIZE,
15512
+ imgScale: IMAGE_SCALE,
15513
+ centered: true,
15514
+ borderRadius: "50%"
15515
+ });
15516
+ }
15517
+ return null;
15473
15518
  };
15474
15519
  return React__default.createElement(Container$i, null, React__default.createElement("p", null, "Shortcuts:"), React__default.createElement(List, {
15475
15520
  id: "shortcuts_list"
@@ -16988,7 +17033,7 @@ var Shortcuts = function Shortcuts(_ref) {
16988
17033
  return React__default.createElement(List$1, null, Array.from({
16989
17034
  length: 12
16990
17035
  }).map(function (_, i) {
16991
- var _shortcuts$i, _shortcuts$i3, _spellCooldowns$paylo, _payload$manaCost;
17036
+ var _shortcuts$i, _shortcuts$i3, _spellCooldowns$paylo, _payload$manaCost, _payload$texturePath;
16992
17037
  var buildClassName = function buildClassName(classBase, isOnCooldown) {
16993
17038
  return classBase + " " + (isOnCooldown ? 'onCooldown' : '');
16994
17039
  };
@@ -17037,6 +17082,8 @@ var Shortcuts = function Shortcuts(_ref) {
17037
17082
  var spellCooldown = !payload ? 0 : (_spellCooldowns$paylo = spellCooldowns == null ? void 0 : spellCooldowns[payload.magicWords.replaceAll(' ', '_')]) != null ? _spellCooldowns$paylo : shortcutCooldown;
17038
17083
  var cooldown = spellCooldown > shortcutCooldown ? spellCooldown : shortcutCooldown;
17039
17084
  var isOnCooldown = cooldown > 0 && !!payload;
17085
+ var IMAGE_SCALE = 1.5;
17086
+ var IMAGE_SIZE = 32;
17040
17087
  return React__default.createElement(StyledShortcut$1, {
17041
17088
  key: i,
17042
17089
  onPointerDown: handleShortcutCast.bind(null, i),
@@ -17046,13 +17093,18 @@ var Shortcuts = function Shortcuts(_ref) {
17046
17093
  }
17047
17094
  }, isOnCooldown && React__default.createElement("span", {
17048
17095
  className: "cooldown"
17049
- }, cooldown.toFixed(cooldown < 10 ? 1 : 0)), React__default.createElement("span", {
17096
+ }, cooldown.toFixed(cooldown < 10 ? 1 : 0)), React__default.createElement("span", null, (payload == null ? void 0 : payload.atlasIMG) && React__default.createElement(SpriteFromAtlas, {
17097
+ atlasIMG: payload.atlasIMG,
17098
+ atlasJSON: payload.atlasJSON,
17099
+ spriteKey: (_payload$texturePath = payload.texturePath) != null ? _payload$texturePath : '',
17100
+ width: IMAGE_SIZE,
17101
+ height: IMAGE_SIZE,
17102
+ imgScale: IMAGE_SCALE,
17103
+ centered: true,
17104
+ borderRadius: "50%"
17105
+ })), React__default.createElement("span", {
17050
17106
  className: buildClassName('mana', isOnCooldown)
17051
17107
  }, payload && payload.manaCost), React__default.createElement("span", {
17052
- className: "magicWords"
17053
- }, payload == null ? void 0 : payload.magicWords.split(' ').map(function (word) {
17054
- return word[0];
17055
- })), React__default.createElement("span", {
17056
17108
  className: buildClassName('keyboard', isOnCooldown)
17057
17109
  }, i + 1));
17058
17110
  }));
@@ -17312,7 +17364,7 @@ var SkillsContainer = function SkillsContainer(_ref) {
17312
17364
  cancelDrag: "#skillsDiv",
17313
17365
  scale: scale,
17314
17366
  width: "100%"
17315
- }, onCloseButton && React__default.createElement(CloseButton$3, {
17367
+ }, onCloseButton && React__default.createElement(CloseButton$4, {
17316
17368
  onPointerDown: onCloseButton
17317
17369
  }, "X"), React__default.createElement(SkillsContainerDiv, {
17318
17370
  id: "skillsDiv"
@@ -17348,7 +17400,7 @@ var SkillSplitDiv = /*#__PURE__*/styled.div.withConfig({
17348
17400
  displayName: "SkillsContainer__SkillSplitDiv",
17349
17401
  componentId: "sc-1g0c67q-2"
17350
17402
  })(["width:100%;font-size:11px;hr{margin:0;margin-bottom:1rem;padding:0px;}p{margin-bottom:0px;}"]);
17351
- var CloseButton$3 = /*#__PURE__*/styled.div.withConfig({
17403
+ var CloseButton$4 = /*#__PURE__*/styled.div.withConfig({
17352
17404
  displayName: "SkillsContainer__CloseButton",
17353
17405
  componentId: "sc-1g0c67q-3"
17354
17406
  })(["position:absolute;top:2px;right:2px;color:white;z-index:22;font-size:1.1rem;"]);
@@ -17559,7 +17611,10 @@ var SpellInfoWrapper = function SpellInfoWrapper(_ref) {
17559
17611
  };
17560
17612
 
17561
17613
  var Spell = function Spell(_ref) {
17562
- var spellKey = _ref.spellKey,
17614
+ var _spell$texturePath;
17615
+ var atlasIMG = _ref.atlasIMG,
17616
+ atlasJSON = _ref.atlasJSON,
17617
+ spellKey = _ref.spellKey,
17563
17618
  charMana = _ref.charMana,
17564
17619
  charMagicLevel = _ref.charMagicLevel,
17565
17620
  onPointerUp = _ref.onPointerUp,
@@ -17572,6 +17627,11 @@ var Spell = function Spell(_ref) {
17572
17627
  name = spell.name,
17573
17628
  description = spell.description;
17574
17629
  var disabled = isSettingShortcut ? charMagicLevel < minMagicLevelRequired : manaCost > charMana || charMagicLevel < minMagicLevelRequired;
17630
+ var CONTAINER_STYLE = {
17631
+ width: '32px',
17632
+ height: '32px'
17633
+ };
17634
+ var IMAGE_SCALE = 2;
17575
17635
  return React__default.createElement(SpellInfoWrapper, {
17576
17636
  spell: spell
17577
17637
  }, React__default.createElement(Container$r, {
@@ -17580,8 +17640,13 @@ var Spell = function Spell(_ref) {
17580
17640
  className: "spell"
17581
17641
  }, disabled && React__default.createElement(Overlay, null, charMagicLevel < minMagicLevelRequired ? 'Low magic level' : manaCost > charMana && 'No mana'), React__default.createElement(SpellImage, null, activeCooldown && activeCooldown > 0 ? React__default.createElement("span", {
17582
17642
  className: "cooldown"
17583
- }, activeCooldown.toFixed(activeCooldown > 10 ? 0 : 1)) : null, magicWords.split(' ').map(function (word) {
17584
- return word[0];
17643
+ }, activeCooldown.toFixed(activeCooldown > 10 ? 0 : 1)) : null, React__default.createElement(SpriteFromAtlas, {
17644
+ atlasIMG: atlasIMG,
17645
+ atlasJSON: atlasJSON,
17646
+ spriteKey: (_spell$texturePath = spell.texturePath) != null ? _spell$texturePath : '',
17647
+ imgScale: IMAGE_SCALE,
17648
+ containerStyle: CONTAINER_STYLE,
17649
+ centered: true
17585
17650
  })), React__default.createElement(Info, null, React__default.createElement(Title$a, null, React__default.createElement("span", null, name), React__default.createElement("span", {
17586
17651
  className: "spell"
17587
17652
  }, "(", magicWords, ")")), React__default.createElement(Description$3, null, description)), React__default.createElement(Divider, null), React__default.createElement(Cost, null, React__default.createElement("span", null, "Mana cost:"), React__default.createElement("span", {
@@ -17637,6 +17702,8 @@ var Spellbook = function Spellbook(_ref) {
17637
17702
  removeShortcut = _ref.removeShortcut,
17638
17703
  atlasIMG = _ref.atlasIMG,
17639
17704
  atlasJSON = _ref.atlasJSON,
17705
+ iconAtlasIMG = _ref.iconAtlasIMG,
17706
+ iconAtlasJSON = _ref.iconAtlasJSON,
17640
17707
  scale = _ref.scale,
17641
17708
  spellCooldowns = _ref.spellCooldowns;
17642
17709
  var _useState = React.useState(''),
@@ -17685,6 +17752,8 @@ var Spellbook = function Spellbook(_ref) {
17685
17752
  return React__default.createElement(React.Fragment, {
17686
17753
  key: spell.key
17687
17754
  }, React__default.createElement(Spell, Object.assign({
17755
+ atlasIMG: iconAtlasIMG,
17756
+ atlasJSON: iconAtlasJSON,
17688
17757
  charMana: mana,
17689
17758
  charMagicLevel: magicLevel,
17690
17759
  onPointerUp: settingShortcutIndex !== -1 ? setShortcut : onSpellClick,
@@ -17741,7 +17810,7 @@ var TimeWidget = function TimeWidget(_ref) {
17741
17810
  scale = _ref.scale;
17742
17811
  return React__default.createElement(Draggable, {
17743
17812
  scale: scale
17744
- }, React__default.createElement(WidgetContainer, null, React__default.createElement(CloseButton$4, {
17813
+ }, React__default.createElement(WidgetContainer, null, React__default.createElement(CloseButton$5, {
17745
17814
  onPointerDown: onClose
17746
17815
  }, "X"), React__default.createElement(DayNightContainer, null, React__default.createElement(DayNightPeriod, {
17747
17816
  periodOfDay: periodOfDay
@@ -17755,7 +17824,7 @@ var Time = /*#__PURE__*/styled.div.withConfig({
17755
17824
  displayName: "TimeWidget__Time",
17756
17825
  componentId: "sc-1ja236h-1"
17757
17826
  })(["top:0.75rem;right:0.5rem;position:absolute;font-size:", ";color:white;"], uiFonts.size.small);
17758
- var CloseButton$4 = /*#__PURE__*/styled.p.withConfig({
17827
+ var CloseButton$5 = /*#__PURE__*/styled.p.withConfig({
17759
17828
  displayName: "TimeWidget__CloseButton",
17760
17829
  componentId: "sc-1ja236h-2"
17761
17830
  })(["position:absolute;top:-0.5rem;margin:0;right:-0.2rem;font-size:", " !important;z-index:1;"], uiFonts.size.small);