@rpg-engine/long-bow 0.3.34 → 0.3.35

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.
@@ -1,4 +1,4 @@
1
- import React, { Component, useState, useEffect, useRef } from 'react';
1
+ import React, { Component, useState, useEffect, useRef, useMemo, Fragment } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { GRID_WIDTH, GRID_HEIGHT, ItemSubType, ItemContainerType, ItemType, ItemSocketEventsDisplayLabels, ActionsForInventory, ActionsForEquipmentSet, ActionsForLoot, ActionsForMapContainer, getItemTextureKeyPath, ItemSlotType, getSPForLevel, PeriodOfDay } from '@rpg-engine/shared';
4
4
  import dayjs from 'dayjs';
@@ -35425,6 +35425,240 @@ var CloseButton$3 = /*#__PURE__*/styled.div.withConfig({
35425
35425
  componentId: "sc-1g0c67q-2"
35426
35426
  })(["position:absolute;top:2px;right:2px;color:white;z-index:22;font-size:1.1rem;"]);
35427
35427
 
35428
+ var QuickSpells = function QuickSpells(_ref) {
35429
+ var quickSpells = _ref.quickSpells,
35430
+ onSpellCast = _ref.onSpellCast,
35431
+ mana = _ref.mana,
35432
+ _ref$isBlockedCasting = _ref.isBlockedCastingByKeyboard,
35433
+ isBlockedCastingByKeyboard = _ref$isBlockedCasting === void 0 ? false : _ref$isBlockedCasting;
35434
+ useEffect(function () {
35435
+ var handleKeyDown = function handleKeyDown(e) {
35436
+ if (isBlockedCastingByKeyboard) return;
35437
+ var shortcutIndex = Number(e.key) - 1;
35438
+ if (shortcutIndex >= 0 && shortcutIndex <= 3) {
35439
+ var shortcut = quickSpells[shortcutIndex];
35440
+ if (shortcut != null && shortcut.key && mana >= (shortcut == null ? void 0 : shortcut.manaCost)) {
35441
+ onSpellCast(shortcut.key);
35442
+ }
35443
+ }
35444
+ };
35445
+ window.addEventListener('keydown', handleKeyDown);
35446
+ return function () {
35447
+ window.removeEventListener('keydown', handleKeyDown);
35448
+ };
35449
+ }, [quickSpells, isBlockedCastingByKeyboard]);
35450
+ return React.createElement(List, null, Array.from({
35451
+ length: 4
35452
+ }).map(function (_, i) {
35453
+ var _quickSpells$i, _quickSpells$i2, _quickSpells$i3, _quickSpells$i4, _quickSpells$i5;
35454
+ return React.createElement(SpellShortcut, {
35455
+ key: i,
35456
+ onClick: onSpellCast.bind(null, (_quickSpells$i = quickSpells[i]) == null ? void 0 : _quickSpells$i.key),
35457
+ disabled: mana < ((_quickSpells$i2 = quickSpells[i]) == null ? void 0 : _quickSpells$i2.manaCost)
35458
+ }, React.createElement("span", {
35459
+ className: "mana"
35460
+ }, ((_quickSpells$i3 = quickSpells[i]) == null ? void 0 : _quickSpells$i3.key) && ((_quickSpells$i4 = quickSpells[i]) == null ? void 0 : _quickSpells$i4.manaCost)), React.createElement("span", {
35461
+ className: "magicWords"
35462
+ }, (_quickSpells$i5 = quickSpells[i]) == null ? void 0 : _quickSpells$i5.magicWords.split(' ').map(function (word) {
35463
+ return word[0];
35464
+ })), React.createElement("span", {
35465
+ className: "keyboard"
35466
+ }, i + 1));
35467
+ }));
35468
+ };
35469
+ var SpellShortcut = /*#__PURE__*/styled.button.withConfig({
35470
+ displayName: "QuickSpells__SpellShortcut",
35471
+ componentId: "sc-41yq7s-0"
35472
+ })(["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);
35473
+ var List = /*#__PURE__*/styled.p.withConfig({
35474
+ displayName: "QuickSpells__List",
35475
+ componentId: "sc-41yq7s-1"
35476
+ })(["width:100%;display:flex;align-items:center;justify-content:center;gap:0.5rem;box-sizing:border-box;margin:0 !important;"]);
35477
+
35478
+ var Spell = function Spell(_ref) {
35479
+ var spellKey = _ref.spellKey,
35480
+ name = _ref.name,
35481
+ description = _ref.description,
35482
+ magicWords = _ref.magicWords,
35483
+ manaCost = _ref.manaCost,
35484
+ charMana = _ref.charMana,
35485
+ charMagicLevel = _ref.charMagicLevel,
35486
+ onClick = _ref.onClick,
35487
+ isSettingShortcut = _ref.isSettingShortcut,
35488
+ minMagicLevelRequired = _ref.minMagicLevelRequired;
35489
+ var disabled = isSettingShortcut ? charMagicLevel < minMagicLevelRequired : manaCost > charMana || charMagicLevel < minMagicLevelRequired;
35490
+ return React.createElement(Container$i, {
35491
+ disabled: disabled,
35492
+ onClick: onClick == null ? void 0 : onClick.bind(null, spellKey),
35493
+ isSettingShortcut: isSettingShortcut && !disabled,
35494
+ className: "spell"
35495
+ }, disabled && React.createElement(Overlay, null, charMagicLevel < minMagicLevelRequired ? 'Low magic level' : manaCost > charMana && 'No mana'), React.createElement(SpellImage, null, magicWords.split(' ').map(function (word) {
35496
+ return word[0];
35497
+ })), React.createElement(Info, null, React.createElement(Title$5, null, React.createElement("span", null, name), React.createElement("span", {
35498
+ className: "spell"
35499
+ }, "(", magicWords, ")")), React.createElement(Description, null, description)), React.createElement(Divider, null), React.createElement(Cost, null, React.createElement("span", null, "Mana cost:"), React.createElement("span", {
35500
+ className: "mana"
35501
+ }, manaCost)));
35502
+ };
35503
+ var Container$i = /*#__PURE__*/styled.button.withConfig({
35504
+ displayName: "Spell__Container",
35505
+ componentId: "sc-j96fa2-0"
35506
+ })(["display:block;background:none;border:2px solid transparent;border-radius:1rem;width:100%;display:flex;height:5rem;gap:1rem;align-items:center;padding:0 1rem;text-align:left;position:relative;animation:", ";@keyframes border-color-change{0%{border-color:", ";}50%{border-color:transparent;}100%{border-color:", ";}}&:hover,&:focus{background-color:", ";}&:active{background:none;}"], function (_ref2) {
35507
+ var isSettingShortcut = _ref2.isSettingShortcut;
35508
+ return isSettingShortcut ? 'border-color-change 1s infinite' : 'none';
35509
+ }, uiColors.yellow, uiColors.yellow, uiColors.darkGray);
35510
+ var SpellImage = /*#__PURE__*/styled.div.withConfig({
35511
+ displayName: "Spell__SpellImage",
35512
+ componentId: "sc-j96fa2-1"
35513
+ })(["width:4rem;height:4rem;font-size:", ";font-weight:bold;background-color:", ";color:", ";display:flex;justify-content:center;align-items:center;text-transform:uppercase;"], uiFonts.size.xLarge, uiColors.darkGray, uiColors.lightGray);
35514
+ var Info = /*#__PURE__*/styled.span.withConfig({
35515
+ displayName: "Spell__Info",
35516
+ componentId: "sc-j96fa2-2"
35517
+ })(["width:0;flex:1;"]);
35518
+ var Title$5 = /*#__PURE__*/styled.p.withConfig({
35519
+ displayName: "Spell__Title",
35520
+ componentId: "sc-j96fa2-3"
35521
+ })(["display:flex;flex-wrap:wrap;align-items:center;margin-bottom:5px;margin:0;span{font-size:", " !important;font-weight:bold !important;color:", " !important;margin-right:0.5rem;}.spell{font-size:", " !important;font-weight:normal !important;color:", " !important;}"], uiFonts.size.medium, uiColors.yellow, uiFonts.size.small, uiColors.lightGray);
35522
+ var Description = /*#__PURE__*/styled.div.withConfig({
35523
+ displayName: "Spell__Description",
35524
+ componentId: "sc-j96fa2-4"
35525
+ })(["font-size:", " !important;line-height:1.1 !important;"], uiFonts.size.small);
35526
+ var Divider = /*#__PURE__*/styled.div.withConfig({
35527
+ displayName: "Spell__Divider",
35528
+ componentId: "sc-j96fa2-5"
35529
+ })(["width:1px;height:100%;margin:0 1rem;background-color:", ";"], uiColors.lightGray);
35530
+ var Cost = /*#__PURE__*/styled.p.withConfig({
35531
+ displayName: "Spell__Cost",
35532
+ componentId: "sc-j96fa2-6"
35533
+ })(["display:flex;align-items:center;flex-direction:column;gap:0.5rem;div{z-index:1;}.mana{position:relative;font-size:", ";font-weight:bold;z-index:1;&::after{position:absolute;content:'';top:0;left:0;background-color:", ";width:100%;height:100%;border-radius:50%;transform:scale(1.8);filter:blur(10px);z-index:-1;}}"], uiFonts.size.medium, uiColors.blue);
35534
+ var Overlay = /*#__PURE__*/styled.p.withConfig({
35535
+ displayName: "Spell__Overlay",
35536
+ componentId: "sc-j96fa2-7"
35537
+ })(["margin:0 !important;position:absolute;top:0;left:0;width:100%;height:100%;border-radius:1rem;display:flex;justify-content:center;align-items:center;color:", ";font-size:", " !important;font-weight:bold;z-index:10;background-color:rgba(0 0 0 / 0.2);"], uiColors.yellow, uiFonts.size.large);
35538
+
35539
+ var SpellbookShortcuts = function SpellbookShortcuts(_ref) {
35540
+ var setSettingShortcutIndex = _ref.setSettingShortcutIndex,
35541
+ settingShortcutIndex = _ref.settingShortcutIndex,
35542
+ shortcuts = _ref.shortcuts,
35543
+ removeShortcut = _ref.removeShortcut;
35544
+ return React.createElement(List$1, {
35545
+ id: "shortcuts_list"
35546
+ }, "Spells shortcuts:", Array.from({
35547
+ length: 4
35548
+ }).map(function (_, i) {
35549
+ var _shortcuts$i2;
35550
+ return React.createElement(SpellShortcut$1, {
35551
+ key: i,
35552
+ onClick: function onClick() {
35553
+ var _shortcuts$i;
35554
+ removeShortcut(i);
35555
+ if (!((_shortcuts$i = shortcuts[i]) != null && _shortcuts$i.key)) setSettingShortcutIndex(i);
35556
+ },
35557
+ disabled: settingShortcutIndex !== -1 && settingShortcutIndex !== i,
35558
+ isBeingSet: settingShortcutIndex === i
35559
+ }, React.createElement("span", null, (_shortcuts$i2 = shortcuts[i]) == null ? void 0 : _shortcuts$i2.magicWords.split(' ').map(function (word) {
35560
+ return word[0];
35561
+ })));
35562
+ }));
35563
+ };
35564
+ var SpellShortcut$1 = /*#__PURE__*/styled.button.withConfig({
35565
+ displayName: "SpellbookShortcuts__SpellShortcut",
35566
+ componentId: "sc-fr4a0d-0"
35567
+ })(["width:2.6rem;height:2.6rem;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;span{margin-top:4px;}&:hover,&:focus{background-color:", ";}&:active{background-color:", ";}&:disabled{opacity:0.5;}"], uiColors.lightGray, function (_ref2) {
35568
+ var isBeingSet = _ref2.isBeingSet;
35569
+ return isBeingSet ? uiColors.yellow : uiColors.darkGray;
35570
+ }, uiColors.darkGray, uiColors.gray);
35571
+ var List$1 = /*#__PURE__*/styled.p.withConfig({
35572
+ displayName: "SpellbookShortcuts__List",
35573
+ componentId: "sc-fr4a0d-1"
35574
+ })(["width:100%;display:flex;align-items:center;justify-content:flex-end;gap:0.5rem;padding:0.5rem;box-sizing:border-box;margin:0 !important;"]);
35575
+
35576
+ var Spellbook = function Spellbook(_ref) {
35577
+ var onClose = _ref.onClose,
35578
+ onInputFocus = _ref.onInputFocus,
35579
+ onInputBlur = _ref.onInputBlur,
35580
+ spells = _ref.spells,
35581
+ magicLevel = _ref.magicLevel,
35582
+ mana = _ref.mana,
35583
+ onSpellClick = _ref.onSpellClick,
35584
+ setSpellShortcut = _ref.setSpellShortcut,
35585
+ spellShortcuts = _ref.spellShortcuts,
35586
+ removeSpellShortcut = _ref.removeSpellShortcut;
35587
+ var _useState = useState(''),
35588
+ search = _useState[0],
35589
+ setSearch = _useState[1];
35590
+ var _useState2 = useState(-1),
35591
+ settingShortcutIndex = _useState2[0],
35592
+ setSettingShortcutIndex = _useState2[1];
35593
+ useEffect(function () {
35594
+ var handleEscapeClose = function handleEscapeClose(e) {
35595
+ if (e.key === 'Escape') {
35596
+ onClose == null ? void 0 : onClose();
35597
+ }
35598
+ };
35599
+ document.addEventListener('keydown', handleEscapeClose);
35600
+ return function () {
35601
+ document.removeEventListener('keydown', handleEscapeClose);
35602
+ };
35603
+ }, [onClose]);
35604
+ var spellsToDisplay = useMemo(function () {
35605
+ return spells.sort(function (a, b) {
35606
+ if (a.minMagicLevelRequired > b.minMagicLevelRequired) return 1;
35607
+ if (a.minMagicLevelRequired < b.minMagicLevelRequired) return -1;
35608
+ return 0;
35609
+ }).filter(function (spell) {
35610
+ return spell.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) || spell.magicWords.toLocaleLowerCase().includes(search.toLocaleLowerCase());
35611
+ });
35612
+ }, [search, spells]);
35613
+ var setShortcut = function setShortcut(spellKey) {
35614
+ setSpellShortcut == null ? void 0 : setSpellShortcut(spellKey, settingShortcutIndex);
35615
+ setSettingShortcutIndex(-1);
35616
+ };
35617
+ return React.createElement(DraggableContainer, {
35618
+ type: RPGUIContainerTypes.Framed,
35619
+ onCloseButton: onClose,
35620
+ width: "inherit",
35621
+ height: "inherit",
35622
+ cancelDrag: "#spellbook-search, #shortcuts_list, .spell"
35623
+ }, React.createElement(Container$j, null, React.createElement(Title$6, null, "Learned Spells"), React.createElement(SpellbookShortcuts, {
35624
+ setSettingShortcutIndex: setSettingShortcutIndex,
35625
+ settingShortcutIndex: settingShortcutIndex,
35626
+ shortcuts: spellShortcuts,
35627
+ removeShortcut: removeSpellShortcut
35628
+ }), React.createElement(Input, {
35629
+ placeholder: "Search for spell",
35630
+ value: search,
35631
+ onChange: function onChange(e) {
35632
+ return setSearch(e.target.value);
35633
+ },
35634
+ onFocus: onInputFocus,
35635
+ onBlur: onInputBlur,
35636
+ id: "spellbook-search"
35637
+ }), React.createElement(SpellList, null, spellsToDisplay.map(function (spell) {
35638
+ return React.createElement(Fragment, {
35639
+ key: spell.key
35640
+ }, React.createElement(Spell, Object.assign({
35641
+ charMana: mana,
35642
+ charMagicLevel: magicLevel,
35643
+ onClick: settingShortcutIndex !== -1 ? setShortcut : onSpellClick,
35644
+ spellKey: spell.key,
35645
+ isSettingShortcut: settingShortcutIndex !== -1
35646
+ }, spell)));
35647
+ }))));
35648
+ };
35649
+ var Title$6 = /*#__PURE__*/styled.h1.withConfig({
35650
+ displayName: "Spellbook__Title",
35651
+ componentId: "sc-r02nfq-0"
35652
+ })(["font-size:", " !important;margin-bottom:0 !important;"], uiFonts.size.large);
35653
+ var Container$j = /*#__PURE__*/styled.div.withConfig({
35654
+ displayName: "Spellbook__Container",
35655
+ componentId: "sc-r02nfq-1"
35656
+ })(["width:100%;height:100%;color:white;display:flex;flex-direction:column;"]);
35657
+ var SpellList = /*#__PURE__*/styled.div.withConfig({
35658
+ displayName: "Spellbook__SpellList",
35659
+ componentId: "sc-r02nfq-2"
35660
+ })(["width:100%;min-height:0;flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:1.5rem;margin-top:1rem;"]);
35661
+
35428
35662
  var TextArea = function TextArea(_ref) {
35429
35663
  var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
35430
35664
  return React.createElement("textarea", Object.assign({}, props));
@@ -35625,7 +35859,7 @@ var TradingMenu = function TradingMenu(_ref) {
35625
35859
  style: {
35626
35860
  width: '100%'
35627
35861
  }
35628
- }, React.createElement(Title$5, null, Capitalize(type), " Menu"), React.createElement("hr", {
35862
+ }, React.createElement(Title$7, null, Capitalize(type), " Menu"), React.createElement("hr", {
35629
35863
  className: "golden"
35630
35864
  })), React.createElement(TradingComponentScrollWrapper, null, traderItems.map(function (tradeItem, index) {
35631
35865
  var _qtyMap$get;
@@ -35651,7 +35885,7 @@ var TradingMenu = function TradingMenu(_ref) {
35651
35885
  }
35652
35886
  }, "Cancel"))));
35653
35887
  };
35654
- var Title$5 = /*#__PURE__*/styled.h1.withConfig({
35888
+ var Title$7 = /*#__PURE__*/styled.h1.withConfig({
35655
35889
  displayName: "TradingMenu__Title",
35656
35890
  componentId: "sc-1wjsz1l-0"
35657
35891
  })(["z-index:22;font-size:0.6rem;color:yellow !important;"]);
@@ -35685,16 +35919,16 @@ var Truncate = function Truncate(_ref) {
35685
35919
  var _ref$maxLines = _ref.maxLines,
35686
35920
  maxLines = _ref$maxLines === void 0 ? 1 : _ref$maxLines,
35687
35921
  children = _ref.children;
35688
- return React.createElement(Container$i, {
35922
+ return React.createElement(Container$k, {
35689
35923
  maxLines: maxLines
35690
35924
  }, children);
35691
35925
  };
35692
- var Container$i = /*#__PURE__*/styled.div.withConfig({
35926
+ var Container$k = /*#__PURE__*/styled.div.withConfig({
35693
35927
  displayName: "Truncate__Container",
35694
35928
  componentId: "sc-6x00qb-0"
35695
35929
  })(["display:-webkit-box;max-width:100%;max-height:100%;-webkit-line-clamp:", ";-webkit-box-orient:vertical;overflow:hidden;"], function (props) {
35696
35930
  return props.maxLines;
35697
35931
  });
35698
35932
 
35699
- 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, RPGUIContainer, RPGUIContainerTypes, RPGUIRoot, RangeSlider, RangeSliderType, SkillProgressBar, SkillsContainer, SpriteFromAtlas, TextArea, TimeWidget, TradingMenu, Truncate, _RPGUI, useEventListener };
35933
+ 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 };
35700
35934
  //# sourceMappingURL=long-bow.esm.js.map