Implementing python script
parent
e84d5ab6bf
commit
0492ade55b
|
@ -4,8 +4,9 @@ namespace stardew_access
|
||||||
{
|
{
|
||||||
internal class CustomCommands
|
internal class CustomCommands
|
||||||
{
|
{
|
||||||
internal static void Initialize(IModHelper helper)
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
|
IModHelper helper = MainClass.ModHelper;
|
||||||
|
|
||||||
helper.ConsoleCommands.Add("readtile", "Toggle read tile feature.", (string commmand, string[] args) =>
|
helper.ConsoleCommands.Add("readtile", "Toggle read tile feature.", (string commmand, string[] args) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace stardew_access
|
||||||
Footstep
|
Footstep
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Initialize(IModHelper helper)
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ namespace stardew_access
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEffect effect;
|
SoundEffect effect;
|
||||||
string filePath = Path.Combine(helper.DirectoryPath, $"sounds/{soundEffect.Key}.wav");
|
string filePath = Path.Combine(MainClass.ModHelper.DirectoryPath,"sounds" , $"{soundEffect.Key}.wav");
|
||||||
using (FileStream stream = new(filePath, FileMode.Open))
|
using (FileStream stream = new(filePath, FileMode.Open))
|
||||||
{
|
{
|
||||||
effect = SoundEffect.FromStream(stream);
|
effect = SoundEffect.FromStream(stream);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import libspeechd
|
import wrapper
|
||||||
|
|
||||||
speech = libspeechd.Speech
|
speech = wrapper.Speech
|
||||||
|
|
||||||
speech.Initialize(self=speech)
|
speech.Initialize(self=speech)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import libspeechd
|
import wrapper
|
||||||
import time
|
import time
|
||||||
|
|
||||||
speech = libspeechd.Speech
|
speech = wrapper.Speech
|
||||||
|
|
||||||
speech.Initialize(self=speech)
|
speech.Initialize(self=speech)
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,12 @@ namespace stardew_access
|
||||||
public static Radar radarFeature;
|
public static Radar radarFeature;
|
||||||
public static ScreenReader screenReader;
|
public static ScreenReader screenReader;
|
||||||
|
|
||||||
|
private static IModHelper _modHelper;
|
||||||
|
public static IModHelper ModHelper
|
||||||
|
{
|
||||||
|
get{return _modHelper;}
|
||||||
|
}
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Public methods
|
** Public methods
|
||||||
*********/
|
*********/
|
||||||
|
@ -35,6 +41,7 @@ namespace stardew_access
|
||||||
#region Initializations
|
#region Initializations
|
||||||
|
|
||||||
monitor = Monitor; // Inititalize monitor
|
monitor = Monitor; // Inititalize monitor
|
||||||
|
_modHelper = helper;
|
||||||
|
|
||||||
Game1.options.setGamepadMode("force_on");
|
Game1.options.setGamepadMode("force_on");
|
||||||
|
|
||||||
|
@ -45,9 +52,9 @@ namespace stardew_access
|
||||||
screenReader = new ScreenReader();
|
screenReader = new ScreenReader();
|
||||||
screenReader.InitializeScreenReader();
|
screenReader.InitializeScreenReader();
|
||||||
|
|
||||||
CustomSoundEffects.Initialize(helper);
|
CustomSoundEffects.Initialize();
|
||||||
|
|
||||||
CustomCommands.Initialize(helper);
|
CustomCommands.Initialize();
|
||||||
|
|
||||||
radarFeature = new Radar();
|
radarFeature = new Radar();
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,40 @@
|
||||||
using AccessibleOutput;
|
using AccessibleOutput;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using IronPython.Hosting;
|
||||||
|
|
||||||
namespace stardew_access
|
namespace stardew_access
|
||||||
{
|
{
|
||||||
public class ScreenReader
|
public class ScreenReader
|
||||||
{
|
{
|
||||||
public IAccessibleOutput? screenReader = null;
|
public IAccessibleOutput? screenReader = null;
|
||||||
|
public dynamic wrapperInstance = null;
|
||||||
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
||||||
|
|
||||||
/// <summary>Initializes the screen reader.</summary>
|
/// <summary>Initializes the screen reader.</summary>
|
||||||
public void InitializeScreenReader()
|
public void InitializeScreenReader()
|
||||||
{
|
{
|
||||||
|
MainClass.monitor.Log($"here! {RuntimeInformation.OSDescription}", LogLevel.Debug);
|
||||||
|
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
MainClass.monitor.Log($"here!", LogLevel.Debug);
|
||||||
|
//instance of python engine
|
||||||
|
var engine = Python.CreateEngine();
|
||||||
|
//reading code from file
|
||||||
|
var source = engine.CreateScriptSourceFromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LinuxSpeech", "wrapper.py"));
|
||||||
|
var scope = engine.CreateScope();
|
||||||
|
//executing script in scope
|
||||||
|
source.Execute(scope);
|
||||||
|
var wrapper = scope.GetVariable("Speech");
|
||||||
|
//initializing class
|
||||||
|
wrapperInstance = engine.Operations.CreateInstance(wrapper);
|
||||||
|
wrapperInstance.Initialize();
|
||||||
|
|
||||||
|
MainClass.monitor.Log($"here!", LogLevel.Debug);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -55,6 +78,12 @@ namespace stardew_access
|
||||||
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
/// <param name="interrupt">Whether to skip the currently speaking text or not.</param>
|
||||||
public void Say(string text, bool interrupt)
|
public void Say(string text, bool interrupt)
|
||||||
{
|
{
|
||||||
|
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
wrapperInstance.Say(text, interrupt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (screenReader == null)
|
if (screenReader == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -73,7 +102,7 @@ namespace stardew_access
|
||||||
if (prevText != text)
|
if (prevText != text)
|
||||||
{
|
{
|
||||||
prevText = text;
|
prevText = text;
|
||||||
screenReader.Speak(text, interrupt);
|
Say(text, interrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +119,7 @@ namespace stardew_access
|
||||||
if (prevMenuText != text)
|
if (prevMenuText != text)
|
||||||
{
|
{
|
||||||
prevMenuText = text;
|
prevMenuText = text;
|
||||||
screenReader.Speak(text, interrupt);
|
Say(text, interrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +136,7 @@ namespace stardew_access
|
||||||
if (prevChatText != text)
|
if (prevChatText != text)
|
||||||
{
|
{
|
||||||
prevChatText = text;
|
prevChatText = text;
|
||||||
screenReader.Speak(text, interrupt);
|
Say(text, interrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +157,7 @@ namespace stardew_access
|
||||||
if (prevTextTile != query)
|
if (prevTextTile != query)
|
||||||
{
|
{
|
||||||
prevTextTile = query;
|
prevTextTile = query;
|
||||||
screenReader.Speak(text, interrupt);
|
Say(text, interrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
<RootNamespace>stardew_access</RootNamespace>
|
<RootNamespace>stardew_access</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue