@rpg-engine/long-bow 0.3.39 → 0.3.40
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/CircularController/CircularController.d.ts +10 -0
- package/dist/components/Spellbook/QuickSpells.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +119 -50
- 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 +118 -51
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/CircullarController.stories.d.ts +5 -0
- package/package.json +2 -2
- package/src/components/CircularController/CircularController.tsx +162 -0
- package/src/components/Spellbook/QuickSpells.tsx +5 -1
- package/src/index.tsx +1 -0
- package/src/stories/CircullarController.stories.tsx +33 -0
package/dist/long-bow.esm.js
CHANGED
|
@@ -33054,6 +33054,123 @@ var CheckButton = function CheckButton(_ref) {
|
|
|
33054
33054
|
}));
|
|
33055
33055
|
};
|
|
33056
33056
|
|
|
33057
|
+
var QuickSpells = function QuickSpells(_ref) {
|
|
33058
|
+
var quickSpells = _ref.quickSpells,
|
|
33059
|
+
onSpellCast = _ref.onSpellCast,
|
|
33060
|
+
mana = _ref.mana,
|
|
33061
|
+
_ref$isBlockedCasting = _ref.isBlockedCastingByKeyboard,
|
|
33062
|
+
isBlockedCastingByKeyboard = _ref$isBlockedCasting === void 0 ? false : _ref$isBlockedCasting;
|
|
33063
|
+
useEffect(function () {
|
|
33064
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
33065
|
+
if (isBlockedCastingByKeyboard) return;
|
|
33066
|
+
var shortcutIndex = Number(e.key) - 1;
|
|
33067
|
+
if (shortcutIndex >= 0 && shortcutIndex <= 3) {
|
|
33068
|
+
var shortcut = quickSpells[shortcutIndex];
|
|
33069
|
+
if (shortcut != null && shortcut.key && mana >= (shortcut == null ? void 0 : shortcut.manaCost)) {
|
|
33070
|
+
onSpellCast(shortcut.key);
|
|
33071
|
+
}
|
|
33072
|
+
}
|
|
33073
|
+
};
|
|
33074
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
33075
|
+
return function () {
|
|
33076
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
33077
|
+
};
|
|
33078
|
+
}, [quickSpells, isBlockedCastingByKeyboard]);
|
|
33079
|
+
return React.createElement(List, null, Array.from({
|
|
33080
|
+
length: 4
|
|
33081
|
+
}).map(function (_, i) {
|
|
33082
|
+
var _quickSpells$i, _quickSpells$i2, _quickSpells$i3, _quickSpells$i4, _quickSpells$i5;
|
|
33083
|
+
return React.createElement(SpellShortcut, {
|
|
33084
|
+
key: i,
|
|
33085
|
+
onClick: onSpellCast.bind(null, (_quickSpells$i = quickSpells[i]) == null ? void 0 : _quickSpells$i.key),
|
|
33086
|
+
disabled: mana < ((_quickSpells$i2 = quickSpells[i]) == null ? void 0 : _quickSpells$i2.manaCost)
|
|
33087
|
+
}, React.createElement("span", {
|
|
33088
|
+
className: "mana"
|
|
33089
|
+
}, ((_quickSpells$i3 = quickSpells[i]) == null ? void 0 : _quickSpells$i3.key) && ((_quickSpells$i4 = quickSpells[i]) == null ? void 0 : _quickSpells$i4.manaCost)), React.createElement("span", {
|
|
33090
|
+
className: "magicWords"
|
|
33091
|
+
}, (_quickSpells$i5 = quickSpells[i]) == null ? void 0 : _quickSpells$i5.magicWords.split(' ').map(function (word) {
|
|
33092
|
+
return word[0];
|
|
33093
|
+
})), React.createElement("span", {
|
|
33094
|
+
className: "keyboard"
|
|
33095
|
+
}, i + 1));
|
|
33096
|
+
}));
|
|
33097
|
+
};
|
|
33098
|
+
var SpellShortcut = /*#__PURE__*/styled.button.withConfig({
|
|
33099
|
+
displayName: "QuickSpells__SpellShortcut",
|
|
33100
|
+
componentId: "sc-41yq7s-0"
|
|
33101
|
+
})(["width:3rem;height:3rem;background-color:", ";border:2px solid ", ";border-radius:50%;text-transform:uppercase;font-size:0.7rem;font-weight:bold;display:flex;align-items:center;justify-content:center;position:relative;span{pointer-events:none;}.mana{position:absolute;top:-5px;right:0;font-size:0.65rem;color:", ";}.magicWords{margin-top:4px;}.keyboard{position:absolute;bottom:-5px;left:0;font-size:0.65rem;color:", ";}&:hover,&:focus{background-color:", ";}&:active{background-color:", ";}&:disabled{opacity:0.5;}"], uiColors.lightGray, uiColors.darkGray, uiColors.blue, uiColors.yellow, uiColors.darkGray, uiColors.gray);
|
|
33102
|
+
var List = /*#__PURE__*/styled.p.withConfig({
|
|
33103
|
+
displayName: "QuickSpells__List",
|
|
33104
|
+
componentId: "sc-41yq7s-1"
|
|
33105
|
+
})(["width:100%;display:flex;align-items:center;justify-content:center;gap:0.5rem;box-sizing:border-box;margin:0 !important;"]);
|
|
33106
|
+
|
|
33107
|
+
var CircularController = function CircularController(_ref) {
|
|
33108
|
+
var onActionClick = _ref.onActionClick,
|
|
33109
|
+
onCancelClick = _ref.onCancelClick,
|
|
33110
|
+
onSpellClick = _ref.onSpellClick,
|
|
33111
|
+
mana = _ref.mana,
|
|
33112
|
+
spells = _ref.spells;
|
|
33113
|
+
var onTouchStart = function onTouchStart(e) {
|
|
33114
|
+
var target = e.target;
|
|
33115
|
+
target == null ? void 0 : target.classList.add('active');
|
|
33116
|
+
};
|
|
33117
|
+
var onTouchEnd = function onTouchEnd(action, e) {
|
|
33118
|
+
var target = e.target;
|
|
33119
|
+
setTimeout(function () {
|
|
33120
|
+
target == null ? void 0 : target.classList.remove('active');
|
|
33121
|
+
}, 100);
|
|
33122
|
+
action();
|
|
33123
|
+
};
|
|
33124
|
+
return React.createElement(ButtonsContainer, null, React.createElement(SpellsContainer, null, Array.from({
|
|
33125
|
+
length: 4
|
|
33126
|
+
}).map(function (_, i) {
|
|
33127
|
+
var variant = i === 0 ? 'top' : i === 3 ? 'bottom' : '';
|
|
33128
|
+
var spell = spells[i];
|
|
33129
|
+
var onSpellClickBinded = spell ? onSpellClick.bind(null, spell.key) : function () {};
|
|
33130
|
+
return React.createElement(StyledShortcut, {
|
|
33131
|
+
key: i,
|
|
33132
|
+
disabled: mana < (spell == null ? void 0 : spell.manaCost),
|
|
33133
|
+
onTouchStart: onTouchStart,
|
|
33134
|
+
onTouchEnd: onTouchEnd.bind(null, onSpellClickBinded),
|
|
33135
|
+
className: variant
|
|
33136
|
+
}, React.createElement("span", {
|
|
33137
|
+
className: "mana"
|
|
33138
|
+
}, (spell == null ? void 0 : spell.key) && (spell == null ? void 0 : spell.manaCost)), React.createElement("span", {
|
|
33139
|
+
className: "magicWords"
|
|
33140
|
+
}, spell == null ? void 0 : spell.magicWords.split(' ').map(function (word) {
|
|
33141
|
+
return word[0];
|
|
33142
|
+
})));
|
|
33143
|
+
})), React.createElement(Button$2, {
|
|
33144
|
+
onTouchStart: onTouchStart,
|
|
33145
|
+
onTouchEnd: onTouchEnd.bind(null, onActionClick)
|
|
33146
|
+
}, React.createElement("div", {
|
|
33147
|
+
className: "rpgui-icon sword"
|
|
33148
|
+
})), React.createElement(CancelButton, {
|
|
33149
|
+
onTouchStart: onTouchStart,
|
|
33150
|
+
onTouchEnd: onTouchEnd.bind(null, onCancelClick)
|
|
33151
|
+
}, React.createElement("span", null, "X")));
|
|
33152
|
+
};
|
|
33153
|
+
var Button$2 = /*#__PURE__*/styled.button.withConfig({
|
|
33154
|
+
displayName: "CircularController__Button",
|
|
33155
|
+
componentId: "sc-1fewf3h-0"
|
|
33156
|
+
})(["width:4.3rem;height:4.3rem;background-color:", ";border:2px solid ", ";border-radius:50%;text-transform:uppercase;font-size:0.7rem;font-weight:bold;display:flex;align-items:center;justify-content:center;position:relative;transition:background-color 0.1s;&.active{background-color:", ";}.sword{transform:rotate(-45deg);height:2.5rem;width:1.9rem;pointer-events:none;}"], uiColors.lightGray, uiColors.darkGray, uiColors.gray);
|
|
33157
|
+
var CancelButton = /*#__PURE__*/styled(Button$2).withConfig({
|
|
33158
|
+
displayName: "CircularController__CancelButton",
|
|
33159
|
+
componentId: "sc-1fewf3h-1"
|
|
33160
|
+
})(["width:3rem;height:3rem;font-size:0.8rem;span{margin-top:4px;margin-left:2px;pointer-events:none;}"]);
|
|
33161
|
+
var ButtonsContainer = /*#__PURE__*/styled.div.withConfig({
|
|
33162
|
+
displayName: "CircularController__ButtonsContainer",
|
|
33163
|
+
componentId: "sc-1fewf3h-2"
|
|
33164
|
+
})(["display:flex;align-items:center;justify-content:center;gap:0.5rem;"]);
|
|
33165
|
+
var SpellsContainer = /*#__PURE__*/styled.div.withConfig({
|
|
33166
|
+
displayName: "CircularController__SpellsContainer",
|
|
33167
|
+
componentId: "sc-1fewf3h-3"
|
|
33168
|
+
})(["display:flex;align-items:center;justify-content:center;gap:0.4rem;flex-direction:column;.top{transform:translate(93%,25%);}.bottom{transform:translate(93%,-25%);}"]);
|
|
33169
|
+
var StyledShortcut = /*#__PURE__*/styled(SpellShortcut).withConfig({
|
|
33170
|
+
displayName: "CircularController__StyledShortcut",
|
|
33171
|
+
componentId: "sc-1fewf3h-4"
|
|
33172
|
+
})(["width:2.5rem;height:2.5rem;transition:background-color 0.1s;.mana{font-size:0.5rem;}&:hover,&:focus,&:active{background-color:", ";}&.active{background-color:", ";}"], uiColors.lightGray, uiColors.gray);
|
|
33173
|
+
|
|
33057
33174
|
function useOutsideClick(ref, id) {
|
|
33058
33175
|
useEffect(function () {
|
|
33059
33176
|
/**
|
|
@@ -35451,56 +35568,6 @@ var CloseButton$3 = /*#__PURE__*/styled.div.withConfig({
|
|
|
35451
35568
|
componentId: "sc-1g0c67q-2"
|
|
35452
35569
|
})(["position:absolute;top:2px;right:2px;color:white;z-index:22;font-size:1.1rem;"]);
|
|
35453
35570
|
|
|
35454
|
-
var QuickSpells = function QuickSpells(_ref) {
|
|
35455
|
-
var quickSpells = _ref.quickSpells,
|
|
35456
|
-
onSpellCast = _ref.onSpellCast,
|
|
35457
|
-
mana = _ref.mana,
|
|
35458
|
-
_ref$isBlockedCasting = _ref.isBlockedCastingByKeyboard,
|
|
35459
|
-
isBlockedCastingByKeyboard = _ref$isBlockedCasting === void 0 ? false : _ref$isBlockedCasting;
|
|
35460
|
-
useEffect(function () {
|
|
35461
|
-
var handleKeyDown = function handleKeyDown(e) {
|
|
35462
|
-
if (isBlockedCastingByKeyboard) return;
|
|
35463
|
-
var shortcutIndex = Number(e.key) - 1;
|
|
35464
|
-
if (shortcutIndex >= 0 && shortcutIndex <= 3) {
|
|
35465
|
-
var shortcut = quickSpells[shortcutIndex];
|
|
35466
|
-
if (shortcut != null && shortcut.key && mana >= (shortcut == null ? void 0 : shortcut.manaCost)) {
|
|
35467
|
-
onSpellCast(shortcut.key);
|
|
35468
|
-
}
|
|
35469
|
-
}
|
|
35470
|
-
};
|
|
35471
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
35472
|
-
return function () {
|
|
35473
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
35474
|
-
};
|
|
35475
|
-
}, [quickSpells, isBlockedCastingByKeyboard]);
|
|
35476
|
-
return React.createElement(List, null, Array.from({
|
|
35477
|
-
length: 4
|
|
35478
|
-
}).map(function (_, i) {
|
|
35479
|
-
var _quickSpells$i, _quickSpells$i2, _quickSpells$i3, _quickSpells$i4, _quickSpells$i5;
|
|
35480
|
-
return React.createElement(SpellShortcut, {
|
|
35481
|
-
key: i,
|
|
35482
|
-
onClick: onSpellCast.bind(null, (_quickSpells$i = quickSpells[i]) == null ? void 0 : _quickSpells$i.key),
|
|
35483
|
-
disabled: mana < ((_quickSpells$i2 = quickSpells[i]) == null ? void 0 : _quickSpells$i2.manaCost)
|
|
35484
|
-
}, React.createElement("span", {
|
|
35485
|
-
className: "mana"
|
|
35486
|
-
}, ((_quickSpells$i3 = quickSpells[i]) == null ? void 0 : _quickSpells$i3.key) && ((_quickSpells$i4 = quickSpells[i]) == null ? void 0 : _quickSpells$i4.manaCost)), React.createElement("span", {
|
|
35487
|
-
className: "magicWords"
|
|
35488
|
-
}, (_quickSpells$i5 = quickSpells[i]) == null ? void 0 : _quickSpells$i5.magicWords.split(' ').map(function (word) {
|
|
35489
|
-
return word[0];
|
|
35490
|
-
})), React.createElement("span", {
|
|
35491
|
-
className: "keyboard"
|
|
35492
|
-
}, i + 1));
|
|
35493
|
-
}));
|
|
35494
|
-
};
|
|
35495
|
-
var SpellShortcut = /*#__PURE__*/styled.button.withConfig({
|
|
35496
|
-
displayName: "QuickSpells__SpellShortcut",
|
|
35497
|
-
componentId: "sc-41yq7s-0"
|
|
35498
|
-
})(["width:3rem;height:3rem;background-color:", ";border:2px solid ", ";border-radius:50%;text-transform:uppercase;font-size:0.7rem;font-weight:bold;display:flex;align-items:center;justify-content:center;position:relative;.mana{position:absolute;top:-5px;right:0;font-size:0.65rem;color:", ";}.magicWords{margin-top:4px;}.keyboard{position:absolute;bottom:-5px;left:0;font-size:0.65rem;color:", ";}&:hover,&:focus{background-color:", ";}&:active{background-color:", ";}&:disabled{opacity:0.5;}"], uiColors.lightGray, uiColors.darkGray, uiColors.blue, uiColors.yellow, uiColors.darkGray, uiColors.gray);
|
|
35499
|
-
var List = /*#__PURE__*/styled.p.withConfig({
|
|
35500
|
-
displayName: "QuickSpells__List",
|
|
35501
|
-
componentId: "sc-41yq7s-1"
|
|
35502
|
-
})(["width:100%;display:flex;align-items:center;justify-content:center;gap:0.5rem;box-sizing:border-box;margin:0 !important;"]);
|
|
35503
|
-
|
|
35504
35571
|
var Spell = function Spell(_ref) {
|
|
35505
35572
|
var spellKey = _ref.spellKey,
|
|
35506
35573
|
name = _ref.name,
|
|
@@ -35985,5 +36052,5 @@ var Container$k = /*#__PURE__*/styled.div.withConfig({
|
|
|
35985
36052
|
return props.maxLines;
|
|
35986
36053
|
});
|
|
35987
36054
|
|
|
35988
|
-
export { Button, ButtonTypes, CharacterSelection, Chat, ChatDeprecated, CheckButton, CraftBook, DraggableContainer, Dropdown, DropdownSelectorContainer, DynamicText, EquipmentSet, ErrorBoundary, HistoryDialog, ImgSide, Input, InputRadio, ItemContainer$1 as ItemContainer, ItemSelector, ItemSlot, ListMenu, NPCDialog, NPCDialogType, NPCMultiDialog, ProgressBar, PropertySelect, QuestInfo, QuestList, QuestionDialog, QuickSpells, RPGUIContainer, RPGUIContainerTypes, RPGUIRoot, RangeSlider, RangeSliderType, SkillProgressBar, SkillsContainer, Spellbook, SpriteFromAtlas, TextArea, TimeWidget, TradingMenu, Truncate, _RPGUI, useEventListener };
|
|
36055
|
+
export { Button, ButtonTypes, CharacterSelection, Chat, ChatDeprecated, CheckButton, CircularController, CraftBook, DraggableContainer, Dropdown, DropdownSelectorContainer, DynamicText, EquipmentSet, ErrorBoundary, HistoryDialog, ImgSide, Input, InputRadio, ItemContainer$1 as ItemContainer, ItemSelector, ItemSlot, ListMenu, NPCDialog, NPCDialogType, NPCMultiDialog, ProgressBar, PropertySelect, QuestInfo, QuestList, QuestionDialog, QuickSpells, RPGUIContainer, RPGUIContainerTypes, RPGUIRoot, RangeSlider, RangeSliderType, SkillProgressBar, SkillsContainer, SpellShortcut, Spellbook, SpriteFromAtlas, TextArea, TimeWidget, TradingMenu, Truncate, _RPGUI, useEventListener };
|
|
35989
36056
|
//# sourceMappingURL=long-bow.esm.js.map
|