Skip to content

Commit

Permalink
Merge pull request #11 from Joshuarox100/development
Browse files Browse the repository at this point in the history
v1.1.3 Merge
  • Loading branch information
Joshuarox100 authored Feb 4, 2021
2 parents c1f6322 + f75c462 commit b36adbe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Editor/Assets/InventoryPresetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public void OnEnable()
if (remainingToggles.Count > 0)
{
// Set the item to use the first remaining toggle if it has none assigned.
if (item.Item == null)
if (item.Item == null || !allToggles.Contains(item.Item))
{
item.Item = remainingToggles[0];
}
Expand Down Expand Up @@ -593,7 +593,7 @@ public void OnEnable()
if (remainingToggles.Count > 0)
{
// Set the item to use the first remaining toggle if it has none assigned.
if (item.Item == null)
if (item.Item == null || !allToggles.Contains(item.Item))
{
item.Item = remainingToggles[0];
}
Expand Down Expand Up @@ -784,7 +784,7 @@ public void OnEnable()
if (remainingToggles.Count > 0)
{
// Set the item to use the first remaining toggle if it has none assigned.
if (item.Item == null)
if (item.Item == null || !allToggles.Contains(item.Item))
{
item.Item = remainingToggles[0];
}
Expand Down Expand Up @@ -867,7 +867,7 @@ public void OnEnable()
}

// Don't continue if there are no other toggles.
if (totalUsage - 1 == list.list.Count)
if (totalUsage == list.list.Count)
{
return;
}
Expand Down
35 changes: 33 additions & 2 deletions Editor/Scripts/InventoryInventor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ Add expression parameters to the list.
/*
Create Expressions menu for toggles.
*/
bool menuExists = false;
if (menu != null)
{
menuExists = true;
}

switch (CreateMenus(out VRCExpressionsMenu inventory, items.Count))
{
Expand All @@ -575,7 +580,7 @@ Add expression parameters to the list.
}

// Assign the Inventory menu to given menu if possible and provided.
if (menu != null)
if (menuExists && menu != null)
{
bool exists = false;

Expand All @@ -602,6 +607,12 @@ Add expression parameters to the list.
EditorUtility.DisplayDialog("Inventory Inventory", "WARNING: Inventory controls were not added to the provided menu.\n(No space is available.)", "Close");
}
}
else if (menuExists)
{
avatar.expressionsMenu = inventory;
EditorUtility.SetDirty(avatar);
menu = inventory;
}

EditorUtility.DisplayProgressBar("Inventory Inventor", "Finalizing", 1f);

Expand Down Expand Up @@ -1330,10 +1341,16 @@ private void CreateMasterLayer(AnimatorController source, int itemTotal, out Lis
}
break;
}

// Add group settings.
for (int j = 0; j < items[i].EnableGroup.Length; j++)
{
// Catch faulty data
if (items.IndexOf(items[i].EnableGroup[j].Item) == -1)
{
EditorUtility.DisplayDialog("Inventory Inventor", "ERROR: " + items[i].name + "\'s Enable Group has a corrupt member in Slot " + (j + 1) + ". Please reassign the member to the desired Item to fix it. The program will now abort forcefully.", "Close");
Selection.activeObject = preset;
throw new Exception("Inventory Inventor: Corrupt member data found in " + items[i].name + "/Enable Group/Slot " + (j + 1) + ".");
}
// If the group item refers to an actual toggle.
if (items[i].EnableGroup[j].Item != null)
switch (items[i].EnableGroup[j].Reaction)
Expand Down Expand Up @@ -1460,6 +1477,13 @@ private void CreateMasterLayer(AnimatorController source, int itemTotal, out Lis
// Add group settings.
for (int j = 0; j < items[i].DisableGroup.Length; j++)
{
// Catch faulty data
if (items.IndexOf(items[i].DisableGroup[j].Item) == -1)
{
EditorUtility.DisplayDialog("Inventory Inventor", "ERROR: " + items[i].name + "\'s Disable Group has a corrupt member in Slot " + (j + 1) + ". Please reassign the member to the desired Item to fix it. The program will now abort forcefully.", "Close");
Selection.activeObject = preset;
throw new Exception("Inventory Inventor: Corrupt member data found in " + items[i].name + "/Disable Group/Slot " + (j + 1) + ".");
}
// If the group item refers to an actual toggle.
if (items[i].DisableGroup[j].Item != null)
switch (items[i].DisableGroup[j].Reaction)
Expand Down Expand Up @@ -1585,6 +1609,13 @@ private void CreateMasterLayer(AnimatorController source, int itemTotal, out Lis
// Add group settings.
for (int j = 0; j < buttons[i].ButtonGroup.Length; j++)
{
// Catch faulty data
if (items.IndexOf(buttons[i].ButtonGroup[j].Item) == -1)
{
EditorUtility.DisplayDialog("Inventory Inventor", "ERROR: " + items[i].name + " has a corrupt member in Slot " + (j + 1) + ". Please reassign the member to the desired Item to fix it. The program will now abort forcefully.", "Close");
Selection.activeObject = preset;
throw new Exception("Inventory Inventor: Corrupt member data found in " + items[i].name + "/Slot " + (j + 1) + ".");
}
// If the group item refers to an actual toggle.
if (buttons[i].ButtonGroup[j] != null && buttons[i].ButtonGroup[j].Item != null)
switch (buttons[i].ButtonGroup[j].Reaction)
Expand Down
2 changes: 1 addition & 1 deletion Editor/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.2
v1.1.3

0 comments on commit b36adbe

Please sign in to comment.