Adding drop item sound

master
shoaib11120 2022-01-06 21:59:27 +05:30
parent ac8f8c494c
commit e696440ce6
5 changed files with 47 additions and 29 deletions

Binary file not shown.

View File

@ -222,21 +222,19 @@ namespace stardew_access
}); });
#endregion #endregion
#region Custom Sounds #region Custom Drop Item Sound
/*CueDefinition myCueDefinition = new CueDefinition(); CueDefinition sa_drop_item = new CueDefinition();
sa_drop_item.name = "sa_drop_item";
// Adding the name for the cue, which will be sa_drop_item.instanceLimit = 1;
// the name of the audio to play when using sound functions. sa_drop_item.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest;
myCueDefinition.name = "myNewSound"; SoundEffect audio;
// If this sound is played multiple times in quick succession, string filePathCombined = Path.Combine(this.Helper.DirectoryPath, "drop_item.wav");
// only one sound instance will play at a time. using (FileStream stream = new(filePathCombined, FileMode.Open))
myCueDefinition.instanceLimit = 1; {
myCueDefinition.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest; audio = SoundEffect.FromStream(stream);
// Get the audio file and add it to a SoundEffect. }
SoundEffect sound_effect; sa_drop_item.SetSound(audio, Game1.audioEngine.GetCategoryIndex("Sound"), false);
string filePathCombined = Path.Combine(this.Helper.DirectoryPath, "mySound.wav"); Game1.soundBank.AddCue(sa_drop_item);
System.IO.FileStream stream = new System.IO.FileStream(filePathCombined, System.IO.FileMode.Open)
sound_effect = SoundEffect.FromStream(stream);*/
#endregion #endregion
helper.Events.Input.ButtonPressed += this.OnButtonPressed; helper.Events.Input.ButtonPressed += this.OnButtonPressed;

View File

@ -7,7 +7,11 @@ namespace stardew_access.Patches
{ {
internal class GameMenuPatches internal class GameMenuPatches
{ {
internal static string hoveredItemQueryKey = "";
internal static string geodeMenuQueryKey = ""; internal static string geodeMenuQueryKey = "";
internal static string itemGrabMenuQueryKey = "";
internal static string craftingPageQueryKey = "";
internal static string inventoryPageQueryKey = "";
internal static void GeodeMenuPatch(GeodeMenu __instance) internal static void GeodeMenuPatch(GeodeMenu __instance)
{ {
@ -52,6 +56,7 @@ namespace stardew_access.Patches
{ {
geodeMenuQueryKey = toSpeak; geodeMenuQueryKey = toSpeak;
ScreenReader.say(toSpeak, true); ScreenReader.say(toSpeak, true);
Game1.playSound("sa_drop_item");
} }
return; return;
} }
@ -82,7 +87,8 @@ namespace stardew_access.Patches
#endregion #endregion
#region Narrate hovered item #region Narrate hovered item
narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y); if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
geodeMenuQueryKey = "";
#endregion #endregion
} }
catch (Exception e) catch (Exception e)
@ -110,18 +116,34 @@ namespace stardew_access.Patches
#region Narrate buttons in the menu #region Narrate buttons in the menu
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
{ {
ScreenReader.sayWithMenuChecker("Ok Button", true); string toSpeak = "Ok Button";
if(itemGrabMenuQueryKey != toSpeak)
{
itemGrabMenuQueryKey = toSpeak;
ScreenReader.say(toSpeak, true);
}
return; return;
} }
if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y)) if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y))
{ {
ScreenReader.sayWithMenuChecker("Trash Can", true); string toSpeak = "Trash Can";
if (itemGrabMenuQueryKey != toSpeak)
{
itemGrabMenuQueryKey = toSpeak;
ScreenReader.say(toSpeak, true);
}
return; return;
} }
if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y))
{ {
ScreenReader.sayWithMenuChecker("Drop Item", true); string toSpeak = "Drop Item";
if (itemGrabMenuQueryKey != toSpeak)
{
itemGrabMenuQueryKey = toSpeak;
ScreenReader.say(toSpeak, true);
Game1.playSound("sa_drop_item");
}
return; return;
} }
#endregion #endregion
@ -204,7 +226,8 @@ namespace stardew_access.Patches
} }
#region Narrate hovered item #region Narrate hovered item
narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true); if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
inventoryPageQueryKey = "";
#endregion #endregion
} }
catch (Exception e) catch (Exception e)
@ -389,9 +412,9 @@ namespace stardew_access.Patches
toSpeak = "Empty Slot"; toSpeak = "Empty Slot";
} }
if (geodeMenuQueryKey != $"{toSpeak}:{i}") if (hoveredItemQueryKey != $"{toSpeak}:{i}")
{ {
geodeMenuQueryKey = $"{toSpeak}:{i}"; hoveredItemQueryKey = $"{toSpeak}:{i}";
ScreenReader.say(toSpeak, true); ScreenReader.say(toSpeak, true);
} }
return true; return true;

View File

@ -264,6 +264,8 @@ namespace stardew_access.Patches
{ {
GameMenuPatches.geodeMenuQueryKey = ""; GameMenuPatches.geodeMenuQueryKey = "";
} }
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net452</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<RootNamespace>stardew_access</RootNamespace> <RootNamespace>stardew_access</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -12,13 +12,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AccessibleOutput" Version="1.0.0" /> <PackageReference Include="AccessibleOutput" Version="1.0.0" />
<PackageReference Include="AutoHotkey.Interop" Version="1.0.0.1" /> <PackageReference Include="AutoHotkey.Interop" Version="1.0.0.1" />
<PackageReference Include="Lib.Harmony" Version="2.1.1" /> <PackageReference Include="Lib.Harmony" Version="2.2.0" />
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.0" /> <PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project> </Project>