@rpg-engine/long-bow 0.7.75 → 0.7.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.75",
3
+ "version": "0.7.76",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -76,6 +76,50 @@ interface IProps {
76
76
  isDepotSystem?: boolean;
77
77
  }
78
78
 
79
+ interface IProps {
80
+ slotIndex: number;
81
+ item: IItem | null;
82
+ itemContainer?: IItemContainer | null;
83
+ itemContainerType?: ItemContainerType | null;
84
+ slotSpriteMask?: ItemSlotType | null;
85
+ onMouseOver?: (
86
+ event: any,
87
+ slotIndex: number,
88
+ item: IItem | null,
89
+ x: number,
90
+ y: number
91
+ ) => void;
92
+ onMouseOut?: () => void;
93
+ onPointerDown: (
94
+ ItemType: ItemType,
95
+ itemContainerType: ItemContainerType | null,
96
+ item: IItem
97
+ ) => void;
98
+ onDragStart?: (
99
+ item: IItem,
100
+ slotIndex: number,
101
+ itemContainerType: ItemContainerType | null
102
+ ) => void;
103
+ onDragEnd?: (quantity?: number) => void;
104
+ onOutsideDrop?: (item: IItem, position: IPosition) => void;
105
+ dragScale?: number;
106
+ checkIfItemCanBeMoved?: () => boolean;
107
+ checkIfItemShouldDragEnd?: () => boolean;
108
+ openQuantitySelector?: (maxQuantity: number, callback: () => void) => void;
109
+ onPlaceDrop?: (
110
+ item: IItem | null,
111
+ slotIndex: number,
112
+ itemContainerType: ItemContainerType | null
113
+ ) => void;
114
+ atlasJSON: any;
115
+ atlasIMG: any;
116
+ isContextMenuDisabled?: boolean;
117
+ isSelectingShortcut?: boolean;
118
+ equipmentSet?: IEquipmentSet | null;
119
+ setItemShortcut?: (item: IItem, shortcutIndex: number) => void;
120
+ isDepotSystem?: boolean;
121
+ }
122
+
79
123
  export const ItemSlot: React.FC<IProps> = observer(
80
124
  ({
81
125
  slotIndex,
@@ -130,28 +174,16 @@ export const ItemSlot: React.FC<IProps> = observer(
130
174
 
131
175
  useEffect(() => {
132
176
  // Reset drag position and focus when item changes
133
-
134
177
  updateDraggingState({
135
178
  position: { x: 0, y: 0 },
136
179
  isFocused: false,
137
180
  });
138
-
139
- // Update context actions when item or depot system changes
140
- if (item && containerType && !isContextMenuDisabled) {
141
- setContextActions(
142
- item,
143
- containerType as ItemContainerType,
144
- isDepotSystem ?? false
145
- );
146
- } else {
147
- clearContextActions();
148
- }
149
181
  }, [
150
- item,
151
182
  containerType,
152
183
  isDepotSystem,
153
184
  setContextActions,
154
185
  clearContextActions,
186
+ isContextMenuDisabled, // Added missing dependency
155
187
  ]);
156
188
 
157
189
  useEffect(() => {
@@ -159,7 +191,7 @@ export const ItemSlot: React.FC<IProps> = observer(
159
191
  if (onDrop && item && dropPosition) {
160
192
  onDrop(item, dropPosition);
161
193
  }
162
- }, [dropPosition]);
194
+ }, [dropPosition, onDrop, item]);
163
195
 
164
196
  const resetItem = () => {
165
197
  clearDraggingState();
@@ -182,6 +214,15 @@ export const ItemSlot: React.FC<IProps> = observer(
182
214
  }
183
215
  };
184
216
 
217
+ const refreshContextActions = () => {
218
+ setContextActions(
219
+ item,
220
+ containerType as ItemContainerType,
221
+ isDepotSystem ?? false,
222
+ isContextMenuDisabled
223
+ );
224
+ };
225
+
185
226
  const onDraggableStop: DraggableEventHandler = (e, data) => {
186
227
  requestAnimationFrame(() => {
187
228
  updateDraggingState({
@@ -338,6 +379,8 @@ export const ItemSlot: React.FC<IProps> = observer(
338
379
  return;
339
380
  }
340
381
 
382
+ refreshContextActions();
383
+
341
384
  if (onDragStart && containerType) {
342
385
  onDragStart(item, slotIndex, containerType);
343
386
  }
@@ -31,7 +31,8 @@ interface IItemSlotDetailsContext {
31
31
  setContextActions: (
32
32
  item: IItem | null,
33
33
  containerType: string | null,
34
- isDepotSystem: boolean
34
+ isDepotSystem: boolean,
35
+ isContextMenuDisabled: boolean
35
36
  ) => void;
36
37
  clearContextActions: () => void;
37
38
  }
@@ -85,14 +86,17 @@ export const ItemSlotDetailsProvider: React.FC<IProps> = ({ children }) => {
85
86
  (
86
87
  item: IItem | null,
87
88
  containerType: string | null,
88
- isDepotSystem: boolean
89
+ isDepotSystem: boolean,
90
+ isContextMenuDisabled: boolean
89
91
  ): void => {
90
- if (item && containerType) {
92
+ console.log('ITEM SLOT: Set context actions for', item?.key);
93
+ if (item && containerType && !isContextMenuDisabled) {
91
94
  const newContextActions = generateContextMenu(
92
95
  item,
93
96
  containerType as ItemContainerType,
94
97
  isDepotSystem
95
98
  );
99
+ console.log('ITEM SLOT: New context actions:', newContextActions);
96
100
  updateDetailsState({ contextActions: newContextActions });
97
101
  } else {
98
102
  updateDetailsState({ contextActions: [] });