Organized code

This commit is contained in:
Mohammad Shoaib Khan
2023-02-20 13:34:03 +05:30
parent 80637af471
commit 2d061e220b
4 changed files with 81 additions and 169 deletions

View File

@@ -129,37 +129,40 @@ namespace stardew_access.Patches
}
else
{
for (int i = 0; i < __instance.inventory.inventory.Count; i++)
{
if (!__instance.inventory.inventory[i].containsPoint(x, y))
continue;
if (__instance.inventory.actualInventory[i] == null)
toSpeak = "Empty slot";
else
{
toSpeak = $"{__instance.inventory.actualInventory[i].Stack} {__instance.inventory.actualInventory[i].DisplayName}";
if (!__instance.inventory.highlightMethod(__instance.inventory.actualInventory[i]))
{
toSpeak = $"{toSpeak} not usable here";
}
if (prevSlotIndex != i)
{
prevSlotIndex = i;
Game1.playSound("invalid-selection");
}
}
if (forgeMenuQuery != $"{toSpeak}:{i}")
{
forgeMenuQuery = $"{toSpeak}:{i}";
MainClass.ScreenReader.Say(toSpeak, true);
}
if (InventoryUtils.narrateHoveredSlot(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
return;
}
// for (int i = 0; i < __instance.inventory.inventory.Count; i++)
// {
// if (!__instance.inventory.inventory[i].containsPoint(x, y))
// continue;
//
// if (__instance.inventory.actualInventory[i] == null)
// toSpeak = "Empty slot";
// else
// {
// toSpeak = $"{__instance.inventory.actualInventory[i].Stack} {__instance.inventory.actualInventory[i].DisplayName}";
//
// if (!__instance.inventory.highlightMethod(__instance.inventory.actualInventory[i]))
// {
// toSpeak = $"{toSpeak} not usable here";
// }
//
// if (prevSlotIndex != i)
// {
// prevSlotIndex = i;
// Game1.playSound("invalid-selection");
// }
// }
//
// if (forgeMenuQuery != $"{toSpeak}:{i}")
// {
// forgeMenuQuery = $"{toSpeak}:{i}";
// MainClass.ScreenReader.Say(toSpeak, true);
// }
//
// return;
// }
}
@@ -300,40 +303,9 @@ namespace stardew_access.Patches
if (Game1.player.pantsItem.Value != null)
toSpeak = $"{toSpeak}: {Game1.player.pantsItem.Value.DisplayName}";
}
else
{
for (int i = 0; i < __instance.inventory.inventory.Count; i++)
{
if (!__instance.inventory.inventory[i].containsPoint(x, y))
continue;
if (__instance.inventory.actualInventory[i] == null)
toSpeak = "Empty slot";
else
{
toSpeak = $"{__instance.inventory.actualInventory[i].Stack} {__instance.inventory.actualInventory[i].DisplayName}";
if (!__instance.inventory.highlightMethod(__instance.inventory.actualInventory[i]))
{
toSpeak = $"{toSpeak} not usable here";
}
if (prevSlotIndex != i)
{
prevSlotIndex = i;
Game1.playSound("invalid-selection");
}
}
if (tailoringMenuQuery != $"{toSpeak}:{i}")
{
tailoringMenuQuery = $"{toSpeak}:{i}";
MainClass.ScreenReader.Say(toSpeak, true);
}
return;
}
}
if (InventoryUtils.narrateHoveredSlot(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
return;
if (tailoringMenuQuery != toSpeak)