@rpg-engine/long-bow 0.5.2 → 0.5.3
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/components/Spellbook/Spell.d.ts +2 -0
- package/dist/components/Spellbook/Spellbook.d.ts +2 -0
- package/dist/components/shared/SpriteFromAtlas.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +85 -24
- 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 +85 -24
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/shortcut.mocks.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/CircularController/CircularController.tsx +16 -1
- package/src/components/Shortcuts/Shortcuts.tsx +17 -3
- package/src/components/Shortcuts/ShortcutsSetter.tsx +21 -2
- package/src/components/Spellbook/Spell.tsx +16 -1
- package/src/components/Spellbook/Spellbook.tsx +6 -0
- package/src/components/Spellbook/mockSpells.ts +27 -13
- package/src/components/shared/SpriteFromAtlas.tsx +11 -2
- package/src/mocks/shortcut.mocks.ts +2 -0
- package/src/stories/Spellbook.stories.tsx +11 -5
|
@@ -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:
|
|
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
|
|
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
|
};
|
|
@@ -15444,19 +15467,19 @@ var ShortcutsSetter = function ShortcutsSetter(_ref) {
|
|
|
15444
15467
|
atlasJSON = _ref.atlasJSON,
|
|
15445
15468
|
atlasIMG = _ref.atlasIMG;
|
|
15446
15469
|
var getContent = function getContent(index) {
|
|
15447
|
-
var _shortcuts$index
|
|
15470
|
+
var _shortcuts$index;
|
|
15448
15471
|
if (((_shortcuts$index = shortcuts[index]) == null ? void 0 : _shortcuts$index.type) === shared.ShortcutType.Item) {
|
|
15449
15472
|
var _shortcuts$index2;
|
|
15450
|
-
var
|
|
15451
|
-
if (!
|
|
15473
|
+
var payload = (_shortcuts$index2 = shortcuts[index]) == null ? void 0 : _shortcuts$index2.payload;
|
|
15474
|
+
if (!payload) return null;
|
|
15452
15475
|
return React__default.createElement(SpriteFromAtlas, {
|
|
15453
15476
|
atlasIMG: atlasIMG,
|
|
15454
15477
|
atlasJSON: atlasJSON,
|
|
15455
15478
|
spriteKey: shared.getItemTextureKeyPath({
|
|
15456
|
-
key:
|
|
15457
|
-
texturePath:
|
|
15458
|
-
stackQty:
|
|
15459
|
-
isStackable:
|
|
15479
|
+
key: payload.texturePath,
|
|
15480
|
+
texturePath: payload.texturePath,
|
|
15481
|
+
stackQty: payload.stackQty || 1,
|
|
15482
|
+
isStackable: payload.isStackable
|
|
15460
15483
|
}, atlasJSON),
|
|
15461
15484
|
width: 32,
|
|
15462
15485
|
height: 32,
|
|
@@ -15466,10 +15489,24 @@ var ShortcutsSetter = function ShortcutsSetter(_ref) {
|
|
|
15466
15489
|
}
|
|
15467
15490
|
});
|
|
15468
15491
|
}
|
|
15469
|
-
var
|
|
15470
|
-
|
|
15471
|
-
|
|
15472
|
-
|
|
15492
|
+
var IMAGE_SIZE = 32;
|
|
15493
|
+
var IMAGE_SCALE = 1;
|
|
15494
|
+
var shortcut = shortcuts[index];
|
|
15495
|
+
if ((shortcut == null ? void 0 : shortcut.type) === shared.ShortcutType.Spell && shortcut.payload) {
|
|
15496
|
+
var _payload$texturePath;
|
|
15497
|
+
var _payload = shortcut.payload; // TypeScript type assertion
|
|
15498
|
+
return React__default.createElement(SpriteFromAtlas, {
|
|
15499
|
+
atlasIMG: _payload.atlasIMG,
|
|
15500
|
+
atlasJSON: _payload.atlasJSON,
|
|
15501
|
+
spriteKey: (_payload$texturePath = _payload.texturePath) != null ? _payload$texturePath : '',
|
|
15502
|
+
width: IMAGE_SIZE,
|
|
15503
|
+
height: IMAGE_SIZE,
|
|
15504
|
+
imgScale: IMAGE_SCALE,
|
|
15505
|
+
centered: true,
|
|
15506
|
+
borderRadius: "50%"
|
|
15507
|
+
});
|
|
15508
|
+
}
|
|
15509
|
+
return null;
|
|
15473
15510
|
};
|
|
15474
15511
|
return React__default.createElement(Container$i, null, React__default.createElement("p", null, "Shortcuts:"), React__default.createElement(List, {
|
|
15475
15512
|
id: "shortcuts_list"
|
|
@@ -16988,7 +17025,7 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
16988
17025
|
return React__default.createElement(List$1, null, Array.from({
|
|
16989
17026
|
length: 12
|
|
16990
17027
|
}).map(function (_, i) {
|
|
16991
|
-
var _shortcuts$i, _shortcuts$i3, _spellCooldowns$paylo, _payload$manaCost;
|
|
17028
|
+
var _shortcuts$i, _shortcuts$i3, _spellCooldowns$paylo, _payload$manaCost, _payload$texturePath;
|
|
16992
17029
|
var buildClassName = function buildClassName(classBase, isOnCooldown) {
|
|
16993
17030
|
return classBase + " " + (isOnCooldown ? 'onCooldown' : '');
|
|
16994
17031
|
};
|
|
@@ -17037,6 +17074,8 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
17037
17074
|
var spellCooldown = !payload ? 0 : (_spellCooldowns$paylo = spellCooldowns == null ? void 0 : spellCooldowns[payload.magicWords.replaceAll(' ', '_')]) != null ? _spellCooldowns$paylo : shortcutCooldown;
|
|
17038
17075
|
var cooldown = spellCooldown > shortcutCooldown ? spellCooldown : shortcutCooldown;
|
|
17039
17076
|
var isOnCooldown = cooldown > 0 && !!payload;
|
|
17077
|
+
var IMAGE_SCALE = 1.5;
|
|
17078
|
+
var IMAGE_SIZE = 32;
|
|
17040
17079
|
return React__default.createElement(StyledShortcut$1, {
|
|
17041
17080
|
key: i,
|
|
17042
17081
|
onPointerDown: handleShortcutCast.bind(null, i),
|
|
@@ -17046,13 +17085,18 @@ var Shortcuts = function Shortcuts(_ref) {
|
|
|
17046
17085
|
}
|
|
17047
17086
|
}, isOnCooldown && React__default.createElement("span", {
|
|
17048
17087
|
className: "cooldown"
|
|
17049
|
-
}, cooldown.toFixed(cooldown < 10 ? 1 : 0)), React__default.createElement("span", {
|
|
17088
|
+
}, cooldown.toFixed(cooldown < 10 ? 1 : 0)), React__default.createElement("span", null, (payload == null ? void 0 : payload.atlasIMG) && React__default.createElement(SpriteFromAtlas, {
|
|
17089
|
+
atlasIMG: payload.atlasIMG,
|
|
17090
|
+
atlasJSON: payload.atlasJSON,
|
|
17091
|
+
spriteKey: (_payload$texturePath = payload.texturePath) != null ? _payload$texturePath : '',
|
|
17092
|
+
width: IMAGE_SIZE,
|
|
17093
|
+
height: IMAGE_SIZE,
|
|
17094
|
+
imgScale: IMAGE_SCALE,
|
|
17095
|
+
centered: true,
|
|
17096
|
+
borderRadius: "50%"
|
|
17097
|
+
})), React__default.createElement("span", {
|
|
17050
17098
|
className: buildClassName('mana', isOnCooldown)
|
|
17051
17099
|
}, 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
17100
|
className: buildClassName('keyboard', isOnCooldown)
|
|
17057
17101
|
}, i + 1));
|
|
17058
17102
|
}));
|
|
@@ -17559,7 +17603,10 @@ var SpellInfoWrapper = function SpellInfoWrapper(_ref) {
|
|
|
17559
17603
|
};
|
|
17560
17604
|
|
|
17561
17605
|
var Spell = function Spell(_ref) {
|
|
17562
|
-
var
|
|
17606
|
+
var _spell$texturePath;
|
|
17607
|
+
var atlasIMG = _ref.atlasIMG,
|
|
17608
|
+
atlasJSON = _ref.atlasJSON,
|
|
17609
|
+
spellKey = _ref.spellKey,
|
|
17563
17610
|
charMana = _ref.charMana,
|
|
17564
17611
|
charMagicLevel = _ref.charMagicLevel,
|
|
17565
17612
|
onPointerUp = _ref.onPointerUp,
|
|
@@ -17572,6 +17619,11 @@ var Spell = function Spell(_ref) {
|
|
|
17572
17619
|
name = spell.name,
|
|
17573
17620
|
description = spell.description;
|
|
17574
17621
|
var disabled = isSettingShortcut ? charMagicLevel < minMagicLevelRequired : manaCost > charMana || charMagicLevel < minMagicLevelRequired;
|
|
17622
|
+
var CONTAINER_STYLE = {
|
|
17623
|
+
width: '32px',
|
|
17624
|
+
height: '32px'
|
|
17625
|
+
};
|
|
17626
|
+
var IMAGE_SCALE = 2;
|
|
17575
17627
|
return React__default.createElement(SpellInfoWrapper, {
|
|
17576
17628
|
spell: spell
|
|
17577
17629
|
}, React__default.createElement(Container$r, {
|
|
@@ -17580,8 +17632,13 @@ var Spell = function Spell(_ref) {
|
|
|
17580
17632
|
className: "spell"
|
|
17581
17633
|
}, 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
17634
|
className: "cooldown"
|
|
17583
|
-
}, activeCooldown.toFixed(activeCooldown > 10 ? 0 : 1)) : null,
|
|
17584
|
-
|
|
17635
|
+
}, activeCooldown.toFixed(activeCooldown > 10 ? 0 : 1)) : null, React__default.createElement(SpriteFromAtlas, {
|
|
17636
|
+
atlasIMG: atlasIMG,
|
|
17637
|
+
atlasJSON: atlasJSON,
|
|
17638
|
+
spriteKey: (_spell$texturePath = spell.texturePath) != null ? _spell$texturePath : '',
|
|
17639
|
+
imgScale: IMAGE_SCALE,
|
|
17640
|
+
containerStyle: CONTAINER_STYLE,
|
|
17641
|
+
centered: true
|
|
17585
17642
|
})), React__default.createElement(Info, null, React__default.createElement(Title$a, null, React__default.createElement("span", null, name), React__default.createElement("span", {
|
|
17586
17643
|
className: "spell"
|
|
17587
17644
|
}, "(", 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 +17694,8 @@ var Spellbook = function Spellbook(_ref) {
|
|
|
17637
17694
|
removeShortcut = _ref.removeShortcut,
|
|
17638
17695
|
atlasIMG = _ref.atlasIMG,
|
|
17639
17696
|
atlasJSON = _ref.atlasJSON,
|
|
17697
|
+
iconAtlasIMG = _ref.iconAtlasIMG,
|
|
17698
|
+
iconAtlasJSON = _ref.iconAtlasJSON,
|
|
17640
17699
|
scale = _ref.scale,
|
|
17641
17700
|
spellCooldowns = _ref.spellCooldowns;
|
|
17642
17701
|
var _useState = React.useState(''),
|
|
@@ -17685,6 +17744,8 @@ var Spellbook = function Spellbook(_ref) {
|
|
|
17685
17744
|
return React__default.createElement(React.Fragment, {
|
|
17686
17745
|
key: spell.key
|
|
17687
17746
|
}, React__default.createElement(Spell, Object.assign({
|
|
17747
|
+
atlasIMG: iconAtlasIMG,
|
|
17748
|
+
atlasJSON: iconAtlasJSON,
|
|
17688
17749
|
charMana: mana,
|
|
17689
17750
|
charMagicLevel: magicLevel,
|
|
17690
17751
|
onPointerUp: settingShortcutIndex !== -1 ? setShortcut : onSpellClick,
|