mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
further cleanup of repo
This commit is contained in:
parent
4f8dcb0cd0
commit
323eb92f2e
140 changed files with 1 additions and 2430 deletions
6
.Experimental/LuaTTS/LuaTTS.csproj
Normal file
6
.Experimental/LuaTTS/LuaTTS.csproj
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Sprays</RootNamespace>
|
||||
</PropertyGroup>
|
||||
</Project>
|
54
.Experimental/LuaTTS/Main.cs
Normal file
54
.Experimental/LuaTTS/Main.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using ABI_RC.Scripting.ScriptNetwork;
|
||||
using ABI_RC.Systems.ModNetwork;
|
||||
using MelonLoader;
|
||||
using NAK.LuaTTS.Patches;
|
||||
|
||||
namespace NAK.LuaTTS;
|
||||
|
||||
public class LuaTTSMod : MelonMod
|
||||
{
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
ApplyPatches(typeof(LuaScriptFactoryPatches));
|
||||
|
||||
ModNetworkMessage.AddConverter<ScriptID>(ReadScriptID, WriteScriptID);
|
||||
ModNetworkMessage.AddConverter<ScriptInstanceID>(ReadScriptInstanceID, WriteScriptInstanceID);
|
||||
}
|
||||
|
||||
private static ScriptID ReadScriptID(ModNetworkMessage msg)
|
||||
{
|
||||
msg.Read(out byte[] value);
|
||||
ScriptID scriptID = new(value);
|
||||
return scriptID;
|
||||
}
|
||||
|
||||
private static void WriteScriptID(ModNetworkMessage msg, ScriptID scriptID)
|
||||
{
|
||||
msg.Write(scriptID.value);
|
||||
}
|
||||
|
||||
private static ScriptInstanceID ReadScriptInstanceID(ModNetworkMessage msg)
|
||||
{
|
||||
msg.Read(out byte[] value);
|
||||
ScriptInstanceID scriptInstanceID = new(value);
|
||||
return scriptInstanceID;
|
||||
}
|
||||
|
||||
private static void WriteScriptInstanceID(ModNetworkMessage msg, ScriptInstanceID scriptInstanceID)
|
||||
{
|
||||
msg.Write(scriptInstanceID.value);
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
27
.Experimental/LuaTTS/Patches.cs
Normal file
27
.Experimental/LuaTTS/Patches.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using ABI.Scripting.CVRSTL.Client;
|
||||
using ABI.Scripting.CVRSTL.Common;
|
||||
using HarmonyLib;
|
||||
using MoonSharp.Interpreter;
|
||||
using NAK.LuaTTS.Modules;
|
||||
|
||||
namespace NAK.LuaTTS.Patches;
|
||||
|
||||
internal static class LuaScriptFactoryPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(LuaScriptFactory.CVRRequireModule), nameof(LuaScriptFactory.CVRRequireModule.Require))]
|
||||
private static void Postfix_CVRRequireModule_require(
|
||||
string moduleFriendlyName,
|
||||
ref LuaScriptFactory.CVRRequireModule __instance,
|
||||
ref object __result,
|
||||
ref Script ____script,
|
||||
ref CVRLuaContext ____context)
|
||||
{
|
||||
const string TTSModuleID = "TextToSpeech";
|
||||
if (TTSModuleID != moduleFriendlyName)
|
||||
return; // not our module
|
||||
|
||||
__result = TTSLuaModule.RegisterUserData(____script, ____context);
|
||||
__instance.RegisteredModules[TTSModuleID] = __result; // add module to cache
|
||||
}
|
||||
}
|
32
.Experimental/LuaTTS/Properties/AssemblyInfo.cs
Normal file
32
.Experimental/LuaTTS/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using NAK.LuaTTS.Properties;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.LuaTTS))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.LuaTTS))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.LuaTTS.LuaTTSMod),
|
||||
nameof(NAK.LuaTTS),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/LuaTTS"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
[assembly: MelonColor(255, 246, 25, 99)] // red-pink
|
||||
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red
|
||||
[assembly: HarmonyDontPatchAll]
|
||||
|
||||
namespace NAK.LuaTTS.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.1";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
14
.Experimental/LuaTTS/README.md
Normal file
14
.Experimental/LuaTTS/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# LuaTTS
|
||||
|
||||
Provides access to the built-in text-to-speech (TTS) functionality to lua scripts. Allows you to make the local player speak.
|
||||
|
||||
---
|
||||
|
||||
Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI.
|
||||
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
|
||||
|
||||
> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive.
|
||||
|
||||
> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
|
||||
|
||||
> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.
|
120
.Experimental/LuaTTS/TTSLuaModule.cs
Normal file
120
.Experimental/LuaTTS/TTSLuaModule.cs
Normal file
|
@ -0,0 +1,120 @@
|
|||
using ABI_RC.Systems.Communications.Audio.TTS;
|
||||
using ABI.Scripting.CVRSTL.Common;
|
||||
using JetBrains.Annotations;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace NAK.LuaTTS.Modules;
|
||||
|
||||
[PublicAPI] // fak off its used
|
||||
public class TTSLuaModule : BaseScriptedStaticWrapper
|
||||
{
|
||||
public TTSLuaModule(CVRLuaContext context) : base(context)
|
||||
{
|
||||
// yes
|
||||
}
|
||||
|
||||
internal static object RegisterUserData(Script script, CVRLuaContext context)
|
||||
{
|
||||
UserData.RegisterType<TTSLuaModule>(InteropAccessMode.Default, "TextToSpeech");
|
||||
return new TTSLuaModule(context);
|
||||
}
|
||||
|
||||
// Check if TTS is playing
|
||||
public bool IsPlaying()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(IsPlaying), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler.Instance.IsPlaying;
|
||||
}
|
||||
|
||||
// Check if TTS is processing a message
|
||||
public bool IsProcessing()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(IsProcessing), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler.Instance.IsProcessing;
|
||||
}
|
||||
|
||||
// Check if TTS has no modules (only true for proton?)
|
||||
public bool HasAnyModules()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(HasAnyModules), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler._modules.Count > 0;
|
||||
}
|
||||
|
||||
// Get all available TTS modules
|
||||
public string[] GetAvailableModules()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(GetAvailableModules), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler._modules.Keys.ToArray();
|
||||
}
|
||||
|
||||
// Get the current TTS module
|
||||
public string GetCurrentModule()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(GetCurrentModule), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler.Instance.CurrentModuleId;
|
||||
}
|
||||
|
||||
// Set the current TTS module
|
||||
public void SetCurrentModule(string moduleId)
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(SetCurrentModule), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
Comms_TTSHandler.Instance.ChangeModule(moduleId);
|
||||
}
|
||||
|
||||
// Process a message for TTS playback
|
||||
public void ProcessMessage(string message)
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(ProcessMessage), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
Comms_TTSHandler.Instance.ProcessMessage(message);
|
||||
}
|
||||
|
||||
// Cancel any currently playing TTS message
|
||||
public void CancelMessage()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(CancelMessage), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
Comms_TTSHandler.Instance.ProcessMessage(string.Empty); // empty message cancels the current message
|
||||
}
|
||||
|
||||
// Get all available voices for the current module
|
||||
public string[] GetAvailableVoices()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(GetAvailableVoices), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler.Instance.CurrentModule.Voices.Keys.ToArray();
|
||||
}
|
||||
|
||||
// Get the current voice for the module
|
||||
public string GetCurrentVoice()
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(GetCurrentVoice), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
return Comms_TTSHandler.Instance.CurrentModule.CurrentVoice;
|
||||
}
|
||||
|
||||
// Set the current voice for the module
|
||||
public void SetCurrentVoice(string voiceName)
|
||||
{
|
||||
CheckIfCanAccessMethod(nameof(SetCurrentVoice), false,
|
||||
CVRLuaEnvironmentContext.CLIENT, CVRLuaObjectContext.ALL_BUT_EVENTS, CVRLuaOwnerContext.LOCAL);
|
||||
|
||||
Comms_TTSHandler.Instance.ChangeVoice(voiceName);
|
||||
}
|
||||
}
|
23
.Experimental/LuaTTS/format.json
Normal file
23
.Experimental/LuaTTS/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": -1,
|
||||
"name": "LuaTTS",
|
||||
"modversion": "1.0.2",
|
||||
"gameversion": "2024r176",
|
||||
"loaderversion": "0.6.1",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Provides access to the built-in text-to-speech (TTS) functionality to lua scripts. Allows you to make the local player speak.",
|
||||
"searchtags": [
|
||||
"lua",
|
||||
"tts",
|
||||
"texttospeech",
|
||||
"tomato"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r28/LuaTTS.dll",
|
||||
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/LuaTTS/",
|
||||
"changelog": "- Initial release.",
|
||||
"embedcolor": "#f61963"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue