@rpg-engine/long-bow 0.1.96 → 0.1.99

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,15 +1,15 @@
1
- import { IEquipmentSet, IItem } from '@rpg-engine/shared';
1
+ import { IEquipmentSet, IItem, ItemContainerType, ItemType } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
- import { SlotContainerType } from '../Item/Inventory/ItemContainerTypes';
4
3
  export interface IEquipmentSetProps {
5
4
  equipmentSet: IEquipmentSet;
6
5
  onClose?: () => void;
7
- onItemClick?: (item: IItem, slotContainerType: SlotContainerType | null) => void;
6
+ onItemClick?: (ItemType: ItemType, item: IItem, itemContainerType: ItemContainerType | null) => void;
8
7
  onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
9
8
  onSelected?: (optionId: string) => void;
10
9
  initialPosition?: {
11
10
  x: number;
12
11
  y: number;
13
12
  };
13
+ ContainerTypes: ItemContainerType | null;
14
14
  }
15
15
  export declare const EquipmentSet: React.FC<IEquipmentSetProps>;
@@ -1,11 +1,11 @@
1
- import { IItem, IItemContainer } from '@rpg-engine/shared';
1
+ import { IItem, IItemContainer, ItemContainerType } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
- import { SlotContainerType } from './ItemContainerTypes';
4
3
  export interface IItemContainerProps {
5
4
  itemContainer: IItemContainer;
6
5
  onClose?: () => void;
7
- onItemClick?: (item: IItem, slotContainerType: SlotContainerType | null) => void;
6
+ onItemClick?: (item: IItem, ItemType: IItem['type'], itemContainerType: ItemContainerType | null) => void;
8
7
  onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
9
8
  onSelected?: (optionId: string, item: IItem) => void;
9
+ ContainerType: ItemContainerType;
10
10
  }
11
11
  export declare const ItemContainer: React.FC<IItemContainerProps>;
@@ -1,4 +1,6 @@
1
1
  export declare enum SlotContainerType {
2
2
  INVENTORY = "Inventory",
3
- EQUIPMENT_SET = "EquipmentSet"
3
+ EQUIPMENT_SET = "EquipmentSet",
4
+ LOOT = "Loot",
5
+ MAP_CONTAINER = "Map-Container"
4
6
  }
@@ -1,16 +1,15 @@
1
- import { IItem, IItemContainer, ItemSlotType } from '@rpg-engine/shared';
1
+ import { IItem, IItemContainer, ItemContainerType, ItemSlotType, ItemType } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
- import { SlotContainerType } from './ItemContainerTypes';
4
3
  interface IProps {
5
4
  slotIndex: number;
6
5
  item: IItem | null;
7
6
  itemContainer?: IItemContainer | null;
8
- slotContainerType: SlotContainerType | null;
7
+ itemContainerType: ItemContainerType | null;
9
8
  slotSpriteMask?: ItemSlotType | null;
10
9
  onSelected: (selectedOption: string, item: IItem) => void;
11
10
  onMouseOver: (event: any, slotIndex: number, item: IItem | null, x: number, y: number) => void;
12
11
  onMouseOut?: () => void;
13
- onClick: (item: IItem, slotContainerType: SlotContainerType | null) => void;
12
+ onClick: (ItemType: ItemType, itemContainerType: ItemContainerType | null, item: IItem) => void;
14
13
  }
15
14
  export declare const ItemSlot: React.FC<IProps>;
16
15
  export {};
@@ -1,12 +1,9 @@
1
- import { ItemType } from '@rpg-engine/shared';
1
+ import { ItemContainerType, ItemType } from '@rpg-engine/shared';
2
2
  import { SlotContainerType } from './ItemContainerTypes';
3
3
  export interface IContextMenuItem {
4
4
  id: string;
5
5
  text: string;
6
6
  }
7
- export declare enum ContainerType {
8
- INVENTORY = "Inventory",
9
- EQUIPMENT_SET = "EquipmentSet"
10
- }
7
+ export declare const handleNewContextMenu: (itemType: ItemType, itemContainerType: ItemContainerType | null) => IContextMenuItem[];
11
8
  export declare const handleContextMenuList: (itemType: ItemType, slotContainerType: SlotContainerType | null) => IContextMenuItem[];
12
9
  export declare const handleEquipmentContextMenuList: (itemType: ItemType) => IContextMenuItem[];
@@ -457,13 +457,6 @@ var Dropdown = function Dropdown(_ref) {
457
457
  }));
458
458
  };
459
459
 
460
- var SlotContainerType;
461
-
462
- (function (SlotContainerType) {
463
- SlotContainerType["INVENTORY"] = "Inventory";
464
- SlotContainerType["EQUIPMENT_SET"] = "EquipmentSet";
465
- })(SlotContainerType || (SlotContainerType = {}));
466
-
467
460
  var frames = {
468
461
  "helmets/brass-helmet.png": {
469
462
  frame: {
@@ -5810,13 +5803,14 @@ var Container$5 = /*#__PURE__*/styled.div.withConfig({
5810
5803
  componentId: "sc-11d9r7x-0"
5811
5804
  })(["z-index:2;position:absolute;top:1rem;left:4rem;font-size:0.5rem;color:white;background-color:black;border-radius:5px;padding:0.5rem;min-width:20px;width:100%;text-align:center;opacity:0.75;"]);
5812
5805
 
5813
- var ContainerType;
5814
-
5815
- (function (ContainerType) {
5816
- ContainerType["INVENTORY"] = "Inventory";
5817
- ContainerType["EQUIPMENT_SET"] = "EquipmentSet";
5818
- })(ContainerType || (ContainerType = {})); // TODO: Refactor this file
5806
+ var SlotContainerType;
5819
5807
 
5808
+ (function (SlotContainerType) {
5809
+ SlotContainerType["INVENTORY"] = "Inventory";
5810
+ SlotContainerType["EQUIPMENT_SET"] = "EquipmentSet";
5811
+ SlotContainerType["LOOT"] = "Loot";
5812
+ SlotContainerType["MAP_CONTAINER"] = "Map-Container";
5813
+ })(SlotContainerType || (SlotContainerType = {}));
5820
5814
 
5821
5815
  var generateContextList = function generateContextList(actionsByTypeList) {
5822
5816
  var contextMenu = actionsByTypeList.map(function (action) {
@@ -5828,41 +5822,101 @@ var generateContextList = function generateContextList(actionsByTypeList) {
5828
5822
  return contextMenu;
5829
5823
  };
5830
5824
 
5831
- var handleContextMenuList = function handleContextMenuList(itemType, slotContainerType) {
5825
+ var handleNewContextMenu = function handleNewContextMenu(itemType, itemContainerType) {
5832
5826
  var contextActionMenu = [];
5833
5827
 
5834
- switch (itemType) {
5835
- case shared.ItemType.Weapon:
5836
- case shared.ItemType.Armor:
5837
- case shared.ItemType.Accessory:
5838
- case shared.ItemType.Jewelry:
5839
- case shared.ItemType.Tool:
5840
- if (slotContainerType === SlotContainerType.EQUIPMENT_SET) {
5841
- contextActionMenu = generateContextList(shared.ActionsByItemType.EquipmentSetItems);
5842
- } else {
5843
- contextActionMenu = generateContextList(shared.ActionsByItemType.Equipment);
5844
- }
5828
+ if (itemContainerType === shared.ItemContainerType.Inventory) {
5829
+ switch (itemType) {
5830
+ case shared.ItemType.Weapon:
5831
+ case shared.ItemType.Armor:
5832
+ case shared.ItemType.Accessory:
5833
+ case shared.ItemType.Jewelry:
5834
+ case shared.ItemType.Container:
5835
+ contextActionMenu = generateContextList(shared.ActionsForInventory.Equipment);
5836
+ break;
5837
+
5838
+ case shared.ItemType.Consumable:
5839
+ contextActionMenu = generateContextList(shared.ActionsForInventory.Consumable);
5840
+ break;
5841
+
5842
+ case shared.ItemType.CraftMaterial:
5843
+ contextActionMenu = generateContextList(shared.ActionsForInventory.CraftMaterial);
5844
+ break;
5845
+
5846
+ case shared.ItemType.Tool:
5847
+ contextActionMenu = generateContextList(shared.ActionsForInventory.Tool);
5848
+ break;
5849
+
5850
+ case shared.ItemType.Other:
5851
+ contextActionMenu = generateContextList(shared.ActionsForInventory.Other);
5852
+ break;
5853
+ }
5854
+ }
5845
5855
 
5846
- break;
5856
+ if (itemContainerType === shared.ItemContainerType.Equipment) {
5857
+ switch (itemType) {
5858
+ case shared.ItemType.Weapon:
5859
+ case shared.ItemType.Armor:
5860
+ case shared.ItemType.Accessory:
5861
+ case shared.ItemType.Jewelry:
5862
+ case shared.ItemType.Container:
5863
+ contextActionMenu = generateContextList(shared.ActionsForEquipmentSet.Equipment);
5864
+ break;
5865
+ }
5866
+ }
5867
+
5868
+ if (itemContainerType === shared.ItemContainerType.Loot) {
5869
+ switch (itemType) {
5870
+ case shared.ItemType.Weapon:
5871
+ case shared.ItemType.Armor:
5872
+ case shared.ItemType.Accessory:
5873
+ case shared.ItemType.Jewelry:
5874
+ contextActionMenu = generateContextList(shared.ActionsForLoot.Equipment);
5875
+ break;
5876
+
5877
+ case shared.ItemType.Consumable:
5878
+ contextActionMenu = generateContextList(shared.ActionsForLoot.Consumable);
5879
+ break;
5880
+
5881
+ case shared.ItemType.CraftMaterial:
5882
+ contextActionMenu = generateContextList(shared.ActionsForLoot.CraftMaterial);
5883
+ break;
5884
+
5885
+ case shared.ItemType.Tool:
5886
+ contextActionMenu = generateContextList(shared.ActionsForLoot.Tool);
5887
+ break;
5888
+
5889
+ case shared.ItemType.Other:
5890
+ contextActionMenu = generateContextList(shared.ActionsForLoot.Other);
5891
+ break;
5892
+ }
5893
+ }
5847
5894
 
5848
- case shared.ItemType.Consumable:
5849
- contextActionMenu = generateContextList(shared.ActionsByItemType.Consumable);
5850
- break;
5895
+ if (itemContainerType === shared.ItemContainerType.MapContainer) {
5896
+ switch (itemType) {
5897
+ case shared.ItemType.Weapon:
5898
+ case shared.ItemType.Armor:
5899
+ case shared.ItemType.Accessory:
5900
+ case shared.ItemType.Jewelry:
5901
+ contextActionMenu = generateContextList(shared.ActionsForMapContainer.Equipment);
5902
+ break;
5851
5903
 
5852
- case shared.ItemType.CraftMaterial:
5853
- contextActionMenu = generateContextList(shared.ActionsByItemType.CraftMaterial);
5854
- break;
5904
+ case shared.ItemType.Consumable:
5905
+ contextActionMenu = generateContextList(shared.ActionsForMapContainer.Consumable);
5906
+ break;
5855
5907
 
5856
- case shared.ItemType.Other:
5857
- case shared.ItemType.Information:
5858
- case shared.ItemType.Quest:
5859
- case shared.ItemType.Container:
5860
- contextActionMenu = generateContextList(shared.ActionsByItemType.Other);
5861
- break;
5908
+ case shared.ItemType.CraftMaterial:
5909
+ contextActionMenu = generateContextList(shared.ActionsForMapContainer.CraftMaterial);
5910
+ break;
5911
+
5912
+ case shared.ItemType.Tool:
5913
+ contextActionMenu = generateContextList(shared.ActionsForMapContainer.Tool);
5914
+ break;
5862
5915
 
5863
- default:
5864
- contextActionMenu = generateContextList(shared.ActionsByItemType.Other);
5865
- break;
5916
+ case shared.ItemType.Other:
5917
+ contextActionMenu = generateContextList(shared.ActionsForMapContainer.Other);
5918
+ break;
5919
+ }
5866
5920
  }
5867
5921
 
5868
5922
  return contextActionMenu;
@@ -5883,7 +5937,7 @@ var EquipmentSlotSpriteByType = {
5883
5937
  var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
5884
5938
  var slotIndex = _ref.slotIndex,
5885
5939
  item = _ref.item,
5886
- slotContainerType = _ref.slotContainerType,
5940
+ containerType = _ref.itemContainerType,
5887
5941
  slotSpriteMask = _ref.slotSpriteMask,
5888
5942
  _onMouseOver = _ref.onMouseOver,
5889
5943
  _onMouseOut = _ref.onMouseOut,
@@ -5904,7 +5958,7 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
5904
5958
 
5905
5959
  React.useEffect(function () {
5906
5960
  if (item) {
5907
- setContextActions(handleContextMenuList(item.type, slotContainerType));
5961
+ setContextActions(handleNewContextMenu(item.type, containerType));
5908
5962
  }
5909
5963
  }, [item]);
5910
5964
 
@@ -5960,8 +6014,16 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
5960
6014
  };
5961
6015
 
5962
6016
  var onRenderSlot = function onRenderSlot(itemToRender) {
5963
- if (slotContainerType === SlotContainerType.EQUIPMENT_SET) return renderEquipment(itemToRender);
5964
- return renderItem(itemToRender);
6017
+ switch (containerType) {
6018
+ case shared.ItemContainerType.Equipment:
6019
+ return renderEquipment(itemToRender);
6020
+
6021
+ case shared.ItemContainerType.Inventory:
6022
+ return renderItem(itemToRender);
6023
+
6024
+ default:
6025
+ return renderItem(itemToRender);
6026
+ }
5965
6027
  };
5966
6028
 
5967
6029
  return React__default.createElement(Container$6, {
@@ -5984,7 +6046,7 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
5984
6046
  if (item) {
5985
6047
  setIsContextMenuVisible(!isContextMenuVisible);
5986
6048
 
5987
- _onClick(item, slotContainerType);
6049
+ _onClick(item.type, containerType, item);
5988
6050
  }
5989
6051
  }
5990
6052
  }, isContextMenuVisible && contextActions && React__default.createElement(RelativeListMenu, {
@@ -6046,13 +6108,13 @@ var EquipmentSet = function EquipmentSet(_ref) {
6046
6108
  slotIndex: i,
6047
6109
  item: item,
6048
6110
  itemContainer: itemContainer,
6049
- slotContainerType: SlotContainerType.EQUIPMENT_SET,
6111
+ itemContainerType: shared.ItemContainerType.Equipment,
6050
6112
  slotSpriteMask: slotMaksRange[i],
6051
6113
  onMouseOver: function onMouseOver(event, slotIndex, item) {
6052
6114
  if (_onMouseOver) _onMouseOver(event, slotIndex, item);
6053
6115
  },
6054
- onClick: function onClick(item, slotContainerType) {
6055
- if (onItemClick) onItemClick(item, slotContainerType);
6116
+ onClick: function onClick(itemType, ContainerType) {
6117
+ if (onItemClick) onItemClick(itemType, item, ContainerType);
6056
6118
  },
6057
6119
  onSelected: function onSelected(optionId) {
6058
6120
  if (_onSelected) _onSelected(optionId);
@@ -6118,7 +6180,8 @@ var ItemContainer = function ItemContainer(_ref) {
6118
6180
  onClose = _ref.onClose,
6119
6181
  _onMouseOver = _ref.onMouseOver,
6120
6182
  _onSelected = _ref.onSelected,
6121
- onItemClick = _ref.onItemClick;
6183
+ onItemClick = _ref.onItemClick,
6184
+ ContainerType = _ref.ContainerType;
6122
6185
 
6123
6186
  var onRenderSlots = function onRenderSlots() {
6124
6187
  var slots = [];
@@ -6130,12 +6193,12 @@ var ItemContainer = function ItemContainer(_ref) {
6130
6193
  key: i,
6131
6194
  slotIndex: i,
6132
6195
  item: ((_itemContainer$slots = itemContainer.slots) == null ? void 0 : _itemContainer$slots[i]) || null,
6133
- slotContainerType: SlotContainerType.INVENTORY,
6196
+ itemContainerType: ContainerType,
6134
6197
  onMouseOver: function onMouseOver(event, slotIndex, item) {
6135
6198
  if (_onMouseOver) _onMouseOver(event, slotIndex, item);
6136
6199
  },
6137
- onClick: function onClick(item, slotContainerType) {
6138
- if (onItemClick) onItemClick(item, slotContainerType);
6200
+ onClick: function onClick(ItemType, ContainerType, item) {
6201
+ if (onItemClick) onItemClick(item, ItemType, ContainerType);
6139
6202
  },
6140
6203
  onSelected: function onSelected(optionId, item) {
6141
6204
  if (_onSelected) _onSelected(optionId, item);