Skip to content

Commit

Permalink
fixed stack recycling
Browse files Browse the repository at this point in the history
  • Loading branch information
obivandamme committed Dec 12, 2015
1 parent d1acaf3 commit 3b3d73b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
Binary file modified GameData/Workshop/Plugins/Workshop.dll
Binary file not shown.
19 changes: 6 additions & 13 deletions Source/Workshop/Workshop/KIS/KISWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public enum InventoryType { Container, Pod, Eva }

private static MethodInfo kis_AddItem;

private static MethodInfo kis_DeleteItem;

private readonly object _obj;

public ModuleKISInventory(object obj)
Expand Down Expand Up @@ -129,11 +127,6 @@ public KIS_Item AddItem(Part partPrefab)
return new KIS_Item(obj);
}

public void DeleteItem(int slot)
{
kis_DeleteItem.Invoke(_obj, new object[] { slot });
}

internal static void Initialize(Assembly kisAssembly)
{
ModuleKISInventory_class = kisAssembly.GetTypes().First(t => t.Name.Equals("ModuleKISInventory"));
Expand All @@ -143,7 +136,6 @@ internal static void Initialize(Assembly kisAssembly)
kis_showGui = ModuleKISInventory_class.GetField("showGui");
kis_items = ModuleKISInventory_class.GetField("items");
kis_AddItem = ModuleKISInventory_class.GetMethod("AddItem", new[] { typeof(Part), typeof(float), typeof(int) });
kis_DeleteItem = ModuleKISInventory_class.GetMethod("DeleteItem");
kis_GetContentVolume = ModuleKISInventory_class.GetMethod("GetContentVolume");
kis_isFull = ModuleKISInventory_class.GetMethod("isFull");
}
Expand Down Expand Up @@ -215,7 +207,7 @@ public static void Initialize(Assembly kisAssembly)

private static MethodInfo kis_DisableIcon;

private static MethodInfo kis_Delete;
private static MethodInfo kis_StackRemove;

private readonly object _obj;

Expand Down Expand Up @@ -266,9 +258,9 @@ public void DisableIcon()
kis_DisableIcon.Invoke(_obj, null);
}

public void Delete()
public void StackRemove(float quantity)
{
kis_Delete.Invoke(_obj, null);
kis_StackRemove.Invoke(_obj, new object[] { quantity });
}

internal static void Initialize(Assembly kisAssembly)
Expand All @@ -280,7 +272,7 @@ internal static void Initialize(Assembly kisAssembly)
kis_SetResource = KIS_Item_class.GetMethod("SetResource");
kis_EnableIcon = KIS_Item_class.GetMethod("EnableIcon");
kis_DisableIcon = KIS_Item_class.GetMethod("DisableIcon");
kis_Delete = KIS_Item_class.GetMethod("Delete");
kis_StackRemove = KIS_Item_class.GetMethod("StackRemove");
}
}

Expand All @@ -305,7 +297,8 @@ public KIS_IconViewer(object obj)
_obj = obj;
}

public KIS_IconViewer(Part p, int resolution) : this(Activator.CreateInstance(KIS_IconViewer_class, new object[] { p, resolution }))
public KIS_IconViewer(Part p, int resolution)
: this(Activator.CreateInstance(KIS_IconViewer_class, new object[] { p, resolution }))
{
}

Expand Down
1 change: 1 addition & 0 deletions Source/Workshop/Workshop/OSEModuleWorkshop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ private void ApplyFilter()

var selectedFilter = _filters[_selectedFilterId];
_activePage = 0;
_selectedPage = 0;
_filteredItems = selectedFilter.Filter(_availableItems, _activePage * 30);
_activeFilterId = _selectedFilterId;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Workshop/Workshop/OseModuleRecycler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private void DrawWindowContents(int windowId)
if (GUI.Button(new Rect(left, top, 50, 50), item.Value.Icon.texture))
{
_queue.Add(new WorkshopItem(item.Value.availablePart));
item.Value.Delete();
item.Value.StackRemove(1);
}
if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition))
{
Expand Down
1 change: 1 addition & 0 deletions Source/Workshop/Workshop/WorkshopItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void EnableIcon(int resultion)

public void DisableIcon()
{
Debug.Log("[OSE] - DisableIcon for " + Part.name);
Icon = null;
}

Expand Down

0 comments on commit 3b3d73b

Please sign in to comment.