@rpg-engine/long-bow 0.3.38 → 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.
@@ -0,0 +1,10 @@
1
+ import { IRawSpell } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ export declare type CircularControllerProps = {
4
+ onActionClick: () => void;
5
+ onCancelClick: () => void;
6
+ onSpellClick: (spellKey: string) => void;
7
+ mana: number;
8
+ spells: IRawSpell[];
9
+ };
10
+ export declare const CircularController: React.FC<CircularControllerProps>;
@@ -7,3 +7,4 @@ export declare type QuickSpellsProps = {
7
7
  isBlockedCastingByKeyboard?: boolean;
8
8
  };
9
9
  export declare const QuickSpells: React.FC<QuickSpellsProps>;
10
+ export declare const SpellShortcut: import("styled-components").StyledComponent<"button", any, {}, never>;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './components/Character/CharacterSelection';
3
3
  export * from './components/Chat/Chat';
4
4
  export * from './components/Chatdeprecated/ChatDeprecated';
5
5
  export * from './components/CheckButton';
6
+ export * from './components/CircularController/CircularController';
6
7
  export * from './components/CraftBook/CraftBook';
7
8
  export * from './components/DraggableContainer';
8
9
  export * from './components/Dropdown';
@@ -33059,6 +33059,123 @@ var CheckButton = function CheckButton(_ref) {
33059
33059
  }));
33060
33060
  };
33061
33061
 
33062
+ var QuickSpells = function QuickSpells(_ref) {
33063
+ var quickSpells = _ref.quickSpells,
33064
+ onSpellCast = _ref.onSpellCast,
33065
+ mana = _ref.mana,
33066
+ _ref$isBlockedCasting = _ref.isBlockedCastingByKeyboard,
33067
+ isBlockedCastingByKeyboard = _ref$isBlockedCasting === void 0 ? false : _ref$isBlockedCasting;
33068
+ React.useEffect(function () {
33069
+ var handleKeyDown = function handleKeyDown(e) {
33070
+ if (isBlockedCastingByKeyboard) return;
33071
+ var shortcutIndex = Number(e.key) - 1;
33072
+ if (shortcutIndex >= 0 && shortcutIndex <= 3) {
33073
+ var shortcut = quickSpells[shortcutIndex];
33074
+ if (shortcut != null && shortcut.key && mana >= (shortcut == null ? void 0 : shortcut.manaCost)) {
33075
+ onSpellCast(shortcut.key);
33076
+ }
33077
+ }
33078
+ };
33079
+ window.addEventListener('keydown', handleKeyDown);
33080
+ return function () {
33081
+ window.removeEventListener('keydown', handleKeyDown);
33082
+ };
33083
+ }, [quickSpells, isBlockedCastingByKeyboard]);
33084
+ return React__default.createElement(List, null, Array.from({
33085
+ length: 4
33086
+ }).map(function (_, i) {
33087
+ var _quickSpells$i, _quickSpells$i2, _quickSpells$i3, _quickSpells$i4, _quickSpells$i5;
33088
+ return React__default.createElement(SpellShortcut, {
33089
+ key: i,
33090
+ onClick: onSpellCast.bind(null, (_quickSpells$i = quickSpells[i]) == null ? void 0 : _quickSpells$i.key),
33091
+ disabled: mana < ((_quickSpells$i2 = quickSpells[i]) == null ? void 0 : _quickSpells$i2.manaCost)
33092
+ }, React__default.createElement("span", {
33093
+ className: "mana"
33094
+ }, ((_quickSpells$i3 = quickSpells[i]) == null ? void 0 : _quickSpells$i3.key) && ((_quickSpells$i4 = quickSpells[i]) == null ? void 0 : _quickSpells$i4.manaCost)), React__default.createElement("span", {
33095
+ className: "magicWords"
33096
+ }, (_quickSpells$i5 = quickSpells[i]) == null ? void 0 : _quickSpells$i5.magicWords.split(' ').map(function (word) {
33097
+ return word[0];
33098
+ })), React__default.createElement("span", {
33099
+ className: "keyboard"
33100
+ }, i + 1));
33101
+ }));
33102
+ };
33103
+ var SpellShortcut = /*#__PURE__*/styled.button.withConfig({
33104
+ displayName: "QuickSpells__SpellShortcut",
33105
+ componentId: "sc-41yq7s-0"
33106
+ })(["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);
33107
+ var List = /*#__PURE__*/styled.p.withConfig({
33108
+ displayName: "QuickSpells__List",
33109
+ componentId: "sc-41yq7s-1"
33110
+ })(["width:100%;display:flex;align-items:center;justify-content:center;gap:0.5rem;box-sizing:border-box;margin:0 !important;"]);
33111
+
33112
+ var CircularController = function CircularController(_ref) {
33113
+ var onActionClick = _ref.onActionClick,
33114
+ onCancelClick = _ref.onCancelClick,
33115
+ onSpellClick = _ref.onSpellClick,
33116
+ mana = _ref.mana,
33117
+ spells = _ref.spells;
33118
+ var onTouchStart = function onTouchStart(e) {
33119
+ var target = e.target;
33120
+ target == null ? void 0 : target.classList.add('active');
33121
+ };
33122
+ var onTouchEnd = function onTouchEnd(action, e) {
33123
+ var target = e.target;
33124
+ setTimeout(function () {
33125
+ target == null ? void 0 : target.classList.remove('active');
33126
+ }, 100);
33127
+ action();
33128
+ };
33129
+ return React__default.createElement(ButtonsContainer, null, React__default.createElement(SpellsContainer, null, Array.from({
33130
+ length: 4
33131
+ }).map(function (_, i) {
33132
+ var variant = i === 0 ? 'top' : i === 3 ? 'bottom' : '';
33133
+ var spell = spells[i];
33134
+ var onSpellClickBinded = spell ? onSpellClick.bind(null, spell.key) : function () {};
33135
+ return React__default.createElement(StyledShortcut, {
33136
+ key: i,
33137
+ disabled: mana < (spell == null ? void 0 : spell.manaCost),
33138
+ onTouchStart: onTouchStart,
33139
+ onTouchEnd: onTouchEnd.bind(null, onSpellClickBinded),
33140
+ className: variant
33141
+ }, React__default.createElement("span", {
33142
+ className: "mana"
33143
+ }, (spell == null ? void 0 : spell.key) && (spell == null ? void 0 : spell.manaCost)), React__default.createElement("span", {
33144
+ className: "magicWords"
33145
+ }, spell == null ? void 0 : spell.magicWords.split(' ').map(function (word) {
33146
+ return word[0];
33147
+ })));
33148
+ })), React__default.createElement(Button$2, {
33149
+ onTouchStart: onTouchStart,
33150
+ onTouchEnd: onTouchEnd.bind(null, onActionClick)
33151
+ }, React__default.createElement("div", {
33152
+ className: "rpgui-icon sword"
33153
+ })), React__default.createElement(CancelButton, {
33154
+ onTouchStart: onTouchStart,
33155
+ onTouchEnd: onTouchEnd.bind(null, onCancelClick)
33156
+ }, React__default.createElement("span", null, "X")));
33157
+ };
33158
+ var Button$2 = /*#__PURE__*/styled.button.withConfig({
33159
+ displayName: "CircularController__Button",
33160
+ componentId: "sc-1fewf3h-0"
33161
+ })(["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);
33162
+ var CancelButton = /*#__PURE__*/styled(Button$2).withConfig({
33163
+ displayName: "CircularController__CancelButton",
33164
+ componentId: "sc-1fewf3h-1"
33165
+ })(["width:3rem;height:3rem;font-size:0.8rem;span{margin-top:4px;margin-left:2px;pointer-events:none;}"]);
33166
+ var ButtonsContainer = /*#__PURE__*/styled.div.withConfig({
33167
+ displayName: "CircularController__ButtonsContainer",
33168
+ componentId: "sc-1fewf3h-2"
33169
+ })(["display:flex;align-items:center;justify-content:center;gap:0.5rem;"]);
33170
+ var SpellsContainer = /*#__PURE__*/styled.div.withConfig({
33171
+ displayName: "CircularController__SpellsContainer",
33172
+ componentId: "sc-1fewf3h-3"
33173
+ })(["display:flex;align-items:center;justify-content:center;gap:0.4rem;flex-direction:column;.top{transform:translate(93%,25%);}.bottom{transform:translate(93%,-25%);}"]);
33174
+ var StyledShortcut = /*#__PURE__*/styled(SpellShortcut).withConfig({
33175
+ displayName: "CircularController__StyledShortcut",
33176
+ componentId: "sc-1fewf3h-4"
33177
+ })(["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);
33178
+
33062
33179
  function useOutsideClick(ref, id) {
33063
33180
  React.useEffect(function () {
33064
33181
  /**
@@ -35453,56 +35570,6 @@ var CloseButton$3 = /*#__PURE__*/styled.div.withConfig({
35453
35570
  componentId: "sc-1g0c67q-2"
35454
35571
  })(["position:absolute;top:2px;right:2px;color:white;z-index:22;font-size:1.1rem;"]);
35455
35572
 
35456
- var QuickSpells = function QuickSpells(_ref) {
35457
- var quickSpells = _ref.quickSpells,
35458
- onSpellCast = _ref.onSpellCast,
35459
- mana = _ref.mana,
35460
- _ref$isBlockedCasting = _ref.isBlockedCastingByKeyboard,
35461
- isBlockedCastingByKeyboard = _ref$isBlockedCasting === void 0 ? false : _ref$isBlockedCasting;
35462
- React.useEffect(function () {
35463
- var handleKeyDown = function handleKeyDown(e) {
35464
- if (isBlockedCastingByKeyboard) return;
35465
- var shortcutIndex = Number(e.key) - 1;
35466
- if (shortcutIndex >= 0 && shortcutIndex <= 3) {
35467
- var shortcut = quickSpells[shortcutIndex];
35468
- if (shortcut != null && shortcut.key && mana >= (shortcut == null ? void 0 : shortcut.manaCost)) {
35469
- onSpellCast(shortcut.key);
35470
- }
35471
- }
35472
- };
35473
- window.addEventListener('keydown', handleKeyDown);
35474
- return function () {
35475
- window.removeEventListener('keydown', handleKeyDown);
35476
- };
35477
- }, [quickSpells, isBlockedCastingByKeyboard]);
35478
- return React__default.createElement(List, null, Array.from({
35479
- length: 4
35480
- }).map(function (_, i) {
35481
- var _quickSpells$i, _quickSpells$i2, _quickSpells$i3, _quickSpells$i4, _quickSpells$i5;
35482
- return React__default.createElement(SpellShortcut, {
35483
- key: i,
35484
- onClick: onSpellCast.bind(null, (_quickSpells$i = quickSpells[i]) == null ? void 0 : _quickSpells$i.key),
35485
- disabled: mana < ((_quickSpells$i2 = quickSpells[i]) == null ? void 0 : _quickSpells$i2.manaCost)
35486
- }, React__default.createElement("span", {
35487
- className: "mana"
35488
- }, ((_quickSpells$i3 = quickSpells[i]) == null ? void 0 : _quickSpells$i3.key) && ((_quickSpells$i4 = quickSpells[i]) == null ? void 0 : _quickSpells$i4.manaCost)), React__default.createElement("span", {
35489
- className: "magicWords"
35490
- }, (_quickSpells$i5 = quickSpells[i]) == null ? void 0 : _quickSpells$i5.magicWords.split(' ').map(function (word) {
35491
- return word[0];
35492
- })), React__default.createElement("span", {
35493
- className: "keyboard"
35494
- }, i + 1));
35495
- }));
35496
- };
35497
- var SpellShortcut = /*#__PURE__*/styled.button.withConfig({
35498
- displayName: "QuickSpells__SpellShortcut",
35499
- componentId: "sc-41yq7s-0"
35500
- })(["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);
35501
- var List = /*#__PURE__*/styled.p.withConfig({
35502
- displayName: "QuickSpells__List",
35503
- componentId: "sc-41yq7s-1"
35504
- })(["width:100%;display:flex;align-items:center;justify-content:center;gap:0.5rem;box-sizing:border-box;margin:0 !important;"]);
35505
-
35506
35573
  var Spell = function Spell(_ref) {
35507
35574
  var spellKey = _ref.spellKey,
35508
35575
  name = _ref.name,
@@ -35759,6 +35826,19 @@ var TradingItemRow = function TradingItemRow(_ref) {
35759
35826
  onQuantityChange(traderItem, newQuantity);
35760
35827
  }
35761
35828
  };
35829
+ var onLeftOutClick = function onLeftOutClick() {
35830
+ if (selectedQty >= 10) {
35831
+ var newQuantity = selectedQty - 10;
35832
+ onQuantityChange(traderItem, newQuantity);
35833
+ }
35834
+ };
35835
+ var onRightOutClick = function onRightOutClick() {
35836
+ var _traderItem$qty2;
35837
+ if (selectedQty < ((_traderItem$qty2 = traderItem.qty) != null ? _traderItem$qty2 : 999)) {
35838
+ var newQuantity = selectedQty + 10;
35839
+ onQuantityChange(traderItem, newQuantity);
35840
+ }
35841
+ };
35762
35842
  return React__default.createElement(ItemWrapper, null, React__default.createElement(ItemIconContainer, null, React__default.createElement(SpriteContainer$1, null, React__default.createElement(SpriteFromAtlas, {
35763
35843
  atlasIMG: atlasIMG,
35764
35844
  atlasJSON: atlasJSON,
@@ -35772,54 +35852,70 @@ var TradingItemRow = function TradingItemRow(_ref) {
35772
35852
  maxLines: 1,
35773
35853
  maxWidth: "250px"
35774
35854
  }, capitalize(traderItem.name))), React__default.createElement("p", null, "$", traderItem.price))), React__default.createElement(QuantityContainer, null, React__default.createElement(SelectArrow, {
35855
+ size: 32,
35856
+ className: "arrow-selector",
35857
+ direction: "left",
35858
+ onClick: onLeftOutClick,
35859
+ onTouchStart: onLeftOutClick
35860
+ }), React__default.createElement(StyledArrow, {
35775
35861
  size: 32,
35776
35862
  className: "arrow-selector",
35777
35863
  direction: "left",
35778
35864
  onClick: onLeftClick,
35779
35865
  onTouchStart: onLeftClick
35780
- }), React__default.createElement(QuantityDisplay, null, React__default.createElement(TextOverlay$2, null, React__default.createElement(Item$1, null, selectedQty))), React__default.createElement(SelectArrow, {
35866
+ }), React__default.createElement(QuantityDisplay, null, React__default.createElement(TextOverlay$2, null, React__default.createElement(Item$1, null, selectedQty))), React__default.createElement(StyledArrow, {
35781
35867
  size: 32,
35782
35868
  className: "arrow-selector",
35783
35869
  direction: "right",
35784
35870
  onClick: onRightClick,
35785
35871
  onTouchStart: onRightClick
35872
+ }), React__default.createElement(SelectArrow, {
35873
+ size: 32,
35874
+ className: "arrow-selector",
35875
+ direction: "right",
35876
+ onClick: onRightOutClick,
35877
+ onTouchStart: onRightOutClick
35786
35878
  })));
35787
35879
  };
35880
+ var StyledArrow = /*#__PURE__*/styled(SelectArrow).withConfig({
35881
+ displayName: "TradingItemRow__StyledArrow",
35882
+ componentId: "sc-mja0b5-0"
35883
+ })(["margin:40px;"]);
35788
35884
  var ItemWrapper = /*#__PURE__*/styled.div.withConfig({
35789
35885
  displayName: "TradingItemRow__ItemWrapper",
35790
- componentId: "sc-mja0b5-0"
35886
+ componentId: "sc-mja0b5-1"
35791
35887
  })(["width:100%;margin:auto;display:flex;justify-content:space-between;margin-bottom:1rem;&:hover{background-color:", ";}padding:0.5rem;"], uiColors.darkGray);
35792
35888
  var ItemNameContainer = /*#__PURE__*/styled.div.withConfig({
35793
35889
  displayName: "TradingItemRow__ItemNameContainer",
35794
- componentId: "sc-mja0b5-1"
35890
+ componentId: "sc-mja0b5-2"
35795
35891
  })(["flex:60%;"]);
35796
35892
  var ItemIconContainer = /*#__PURE__*/styled.div.withConfig({
35797
35893
  displayName: "TradingItemRow__ItemIconContainer",
35798
- componentId: "sc-mja0b5-2"
35894
+ componentId: "sc-mja0b5-3"
35799
35895
  })(["display:flex;justify-content:flex-start;align-items:center;flex:0 0 58px;"]);
35800
35896
  var SpriteContainer$1 = /*#__PURE__*/styled.div.withConfig({
35801
35897
  displayName: "TradingItemRow__SpriteContainer",
35802
- componentId: "sc-mja0b5-3"
35898
+ componentId: "sc-mja0b5-4"
35803
35899
  })(["position:relative;top:-0.5rem;left:0.5rem;"]);
35804
35900
  var NameValue = /*#__PURE__*/styled.div.withConfig({
35805
35901
  displayName: "TradingItemRow__NameValue",
35806
- componentId: "sc-mja0b5-4"
35902
+ componentId: "sc-mja0b5-5"
35807
35903
  })(["p{font-size:0.75rem;margin:0;}"]);
35808
35904
  var Item$1 = /*#__PURE__*/styled.span.withConfig({
35809
35905
  displayName: "TradingItemRow__Item",
35810
- componentId: "sc-mja0b5-5"
35906
+ componentId: "sc-mja0b5-6"
35811
35907
  })(["color:white;text-align:center;z-index:1;width:100%;"]);
35812
35908
  var TextOverlay$2 = /*#__PURE__*/styled.div.withConfig({
35813
35909
  displayName: "TradingItemRow__TextOverlay",
35814
- componentId: "sc-mja0b5-6"
35910
+ componentId: "sc-mja0b5-7"
35815
35911
  })(["width:100%;position:relative;"]);
35816
35912
  var QuantityContainer = /*#__PURE__*/styled.div.withConfig({
35817
35913
  displayName: "TradingItemRow__QuantityContainer",
35818
- componentId: "sc-mja0b5-7"
35819
- })(["position:relative;display:flex;min-width:100px;width:40%;justify-content:center;align-items:center;flex:20%;"]);
35914
+ componentId: "sc-mja0b5-8"
35915
+ })(["position:relative;display:flex;min-width:100px;width:40%;justify-content:center;align-items:center;flex:40%;"]);
35820
35916
  var QuantityDisplay = /*#__PURE__*/styled.div.withConfig({
35821
35917
  displayName: "TradingItemRow__QuantityDisplay",
35822
- componentId: "sc-mja0b5-8"
35918
+ componentId: "sc-mja0b5-9"
35823
35919
  })(["font-size:", ";"], uiFonts.size.small);
35824
35920
 
35825
35921
  var TradingMenu = function TradingMenu(_ref) {
@@ -35881,7 +35977,7 @@ var TradingMenu = function TradingMenu(_ref) {
35881
35977
  onCloseButton: function onCloseButton() {
35882
35978
  if (onClose) onClose();
35883
35979
  },
35884
- width: "500px",
35980
+ width: "600px",
35885
35981
  cancelDrag: ".equipment-container-body .arrow-selector"
35886
35982
  }, React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
35887
35983
  style: {
@@ -35963,6 +36059,7 @@ exports.CharacterSelection = CharacterSelection;
35963
36059
  exports.Chat = Chat;
35964
36060
  exports.ChatDeprecated = ChatDeprecated;
35965
36061
  exports.CheckButton = CheckButton;
36062
+ exports.CircularController = CircularController;
35966
36063
  exports.CraftBook = CraftBook;
35967
36064
  exports.DraggableContainer = DraggableContainer;
35968
36065
  exports.Dropdown = Dropdown;
@@ -35990,6 +36087,7 @@ exports.RPGUIRoot = RPGUIRoot;
35990
36087
  exports.RangeSlider = RangeSlider;
35991
36088
  exports.SkillProgressBar = SkillProgressBar;
35992
36089
  exports.SkillsContainer = SkillsContainer;
36090
+ exports.SpellShortcut = SpellShortcut;
35993
36091
  exports.Spellbook = Spellbook;
35994
36092
  exports.SpriteFromAtlas = SpriteFromAtlas;
35995
36093
  exports.TextArea = TextArea;