initial messy plugin rewrite commit

This commit is contained in:
alterNERDtive 2020-10-21 01:13:40 +02:00
parent 646658648d
commit c955fe05d6
27 changed files with 1657 additions and 1 deletions

350
.gitignore vendored Normal file
View file

@ -0,0 +1,350 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/

View file

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EliteAttack", "EliteAttack\EliteAttack.csproj", "{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {339E6747-C7BF-43C3-99C6-9249C9849A84}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,88 @@
#nullable enable
using alterNERDtive.util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EliteAttack
{
public class EliteAttack {
private static dynamic? VA { get; set; }
private static VoiceAttackLog Log
=> log ??= new VoiceAttackLog(VA, "EliteAttack");
private static VoiceAttackLog? log;
private static VoiceAttackCommands Commands
=> commands ??= new VoiceAttackCommands(VA, Log);
private static VoiceAttackCommands? commands;
/*================\
| plugin contexts |
\================*/
private static void Context_Startup(dynamic vaProxy)
{
Log.Notice("Starting up …");
VA = vaProxy;
Log.Notice("Finished startup.");
}
/*========================================\
| required VoiceAttack plugin shenanigans |
\========================================*/
static readonly string VERSION = "0.0.1";
public static Guid VA_Id()
=> new Guid("{5B46321D-2935-4550-BEEA-36C2145547B8}");
public static string VA_DisplayName()
=> $"EliteAttack {VERSION}";
public static string VA_DisplayInfo()
=> "EliteAttack: a plugin for doing Elite-y things.";
public static void VA_Init1(dynamic vaProxy)
{
VA = vaProxy;
Log.Notice("Initializing …");
Log.Notice("Init successful.");
}
public static void VA_Invoke1(dynamic vaProxy)
{
string context = vaProxy.Context.ToLower();
Log.Debug($"Running context '{context}' …");
try
{
switch (context)
{
// plugin methods
case "startup":
Context_Startup(vaProxy);
break;
// plugin settings
// NYI
// invalid
default:
Log.Error($"Invalid plugin context '{vaProxy.Context}'.");
break;
}
}
catch (ArgumentNullException e)
{
Log.Error($"Missing parameter '~{e.ParamName}' for context '{context}'");
}
catch (Exception e)
{
Log.Error($"Unhandled exception while executing plugin context '{context}'. ({e.Message})");
}
}
public static void VA_Exit1(dynamic vaProxy) { }
public static void VA_StopCommand() { }
}
}

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EliteAttack</RootNamespace>
<AssemblyName>EliteAttack</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EliteAttack.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VoiceAttack-base\VoiceAttack-base\VoiceAttack-base.csproj">
<Project>{1c05db3f-3449-4664-b363-a379892995e5}</Project>
<Name>VoiceAttack-base</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EliteAttack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EliteAttack")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("77cef35c-c25c-4793-ab2c-0b0c5d9a5bb8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RatAttack-cli")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RatAttack-cli")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d72a35ec-8d39-4b96-bbc5-1b330f4cbeef")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,24 @@
#nullable enable
using System.IO;
using System.IO.Pipes;
namespace RatAttack
{
class RatAttack_cli
{
static void Main(string[] args)
{
RatAttack.Ratsignal ratsignal = new RatAttack.Ratsignal(args[0], args.Length > 1 && args[1].Equals("true"));
using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "RatAttack", PipeDirection.Out))
{
pipeClient.Connect(120); // 120s timeout should really be enough, no? if VA doesnt respond you probably dont want the threads to stick around.
using (StreamWriter writer = new StreamWriter(pipeClient))
{
writer.WriteLine(ratsignal);
}
}
}
}
}

View file

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RatAttack_cli</RootNamespace>
<AssemblyName>RatAttack-cli</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Serialization" />
</ItemGroup>
<ItemGroup>
<Compile Include="RatAttack-cli.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RatAttack\RatAttack.csproj">
<Project>{64cd3ba3-7fd2-4360-b055-6927ce92da68}</Project>
<Name>RatAttack</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

31
RatAttack/RatAttack.sln Normal file
View file

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30406.217
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatAttack", "RatAttack\RatAttack.csproj", "{64CD3BA3-7FD2-4360-B055-6927CE92DA68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatAttack-cli", "RatAttack-cli\RatAttack-cli.csproj", "{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Release|Any CPU.Build.0 = Release|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {36AF3229-511E-416B-BF53-0CB8DB56C307}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VoiceAttack-plugins")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VoiceAttack-plugins")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("64cd3ba3-7fd2-4360-b055-6927ce92da68")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace RatAttack.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles />
<Settings />
</SettingsFile>

View file

@ -0,0 +1,221 @@
#nullable enable
using System;
using alterNERDtive.util;
namespace RatAttack
{
public class RatAttack
{
private static RatCase[] CaseList { get; } = new RatCase[20];
private static dynamic? VA { get; set; }
private static alterNERDtive.util.PipeServer<Ratsignal> RatsignalPipe
=> ratsignalPipe ??= new alterNERDtive.util.PipeServer<Ratsignal>(Log, "RatAttack",
new alterNERDtive.util.PipeServer<Ratsignal>.SignalHandler(On_Ratsignal));
private static alterNERDtive.util.PipeServer<Ratsignal>? ratsignalPipe;
private static VoiceAttackLog Log
=> log ??= new VoiceAttackLog(VA, "RatAttack");
private static VoiceAttackLog? log;
private static VoiceAttackCommands Commands
=> commands ??= new VoiceAttackCommands(VA, Log);
private static VoiceAttackCommands? commands;
private class RatCase
{
public string Cmdr;
public string System;
public string Platform;
public bool CodeRed;
public int Number;
public RatCase(string cmdr, string system, string platform, bool codeRed, int number)
=> (Cmdr, System, Platform, CodeRed, Number) = (cmdr, system, platform, codeRed, number);
public string ShortInfo
{
get
{
string type = CodeRed ? ", code red" : "";
return ($"#{Number}, {Platform}, {System}{type}");
}
}
public override string ToString()
{
return ShortInfo;
}
}
public class Ratsignal : IPipable
{
public string Signal { get; set; }
public bool Announce { get; set; }
public Ratsignal()
=> (Signal, Announce) = ("", false);
public Ratsignal(string signal, bool announce)
=> (Signal, Announce) = (signal, announce);
public void ParseString(string serialization)
{
try
{
string[] parts = serialization.Split('|');
Signal = parts[0];
Announce = Boolean.Parse(parts[1]);
}
catch (Exception e)
{
throw new ArgumentException($"Invalid serialized RATSIGNAL: '{serialization}'", e);
}
}
public override string ToString()
=> $"{Signal}|{Announce}";
}
private static int ParseRatsignal(string ratsignal)
{
char delimiter = (char)0x02;
string[] parts = ratsignal.Split(delimiter);
try
{
string cmdr = parts[1];
string system = parts[3];
string platform = parts[5];
if (platform.Contains("PS4")) { platform = "PS4"; }
else if (platform.Contains("XB")) { platform = "XB"; }
bool codeRed = parts.Length == 9;
int start = ratsignal.LastIndexOf('#') + 1;
int end = ratsignal.LastIndexOf(") (");
int number = int.Parse(ratsignal.Substring(start, end - start));
CaseList[number] = new RatCase(cmdr, system, platform, codeRed, number);
return number;
}
catch(Exception e)
{
throw new ArgumentException($"Invalid RATSIGNAL format: '{ratsignal}'.", "ratsignal", e);
}
}
private static void On_Ratsignal(Ratsignal ratsignal)
{
try
{
int number = ParseRatsignal(ratsignal.Signal);
Log.Notice($"New rat case: {CaseList[number]}.");
Commands.TriggerEvent("RatAttack.incomingCase", parameters: new dynamic[] { new int[] { number }, new bool[] { ratsignal.Announce } });
}
catch (ArgumentException e)
{
Log.Error(e.Message);
}
catch (Exception e)
{
Log.Error($"Unhandled exception while parsing RATSIGNAL: '{e.Message}'.");
}
}
/*================\
| plugin contexts |
\================*/
private static void Context_GetCaseData(dynamic vaProxy)
{
int cn = vaProxy.GetInt("~caseNumber");
RatCase rc = CaseList[cn];
vaProxy.SetInt("~~caseNumber", rc?.Number);
vaProxy.SetText("~~cmdr", rc?.Cmdr);
vaProxy.SetText("~~system", rc?.System);
vaProxy.SetText("~~platform", rc?.Platform);
vaProxy.SetBoolean("~~codeRed", rc?.CodeRed);
}
private static void Context_Startup(dynamic vaProxy)
{
Log.Notice("Starting up …");
VA = vaProxy;
_ = RatsignalPipe.Run();
Log.Notice("Finished startup.");
}
private static void Context_ParseRatsignal(dynamic vaProxy)
{
Log.Warn("Passing a RATSIGNAL from VoiceAttack (through the clipboard or a file) is DEPRECATED and will no longer be supported in the future.");
On_Ratsignal(new Ratsignal(vaProxy.GetText("~ratsignal"), vaProxy.GetBoolean("~announceRatsignal")));
}
/*========================================\
| required VoiceAttack plugin shenanigans |
\========================================*/
static readonly string VERSION = "0.0.1";
public static Guid VA_Id()
=> new Guid("{F2ADF0AE-4837-4E4A-9C87-8A7E2FA63E5F}");
public static string VA_DisplayName()
=> $"RatAttack {VERSION}";
public static string VA_DisplayInfo()
=> "RatAttack: a plugin to handle FuelRats cases.";
public static void VA_Init1(dynamic vaProxy)
{
VA = vaProxy;
Log.Notice("Initializing …");
Log.Notice("Init successful.");
}
public static void VA_Invoke1(dynamic vaProxy)
{
string context = vaProxy.Context.ToLower();
Log.Debug($"Running context '{context}' …");
try
{
switch (context)
{
// plugin methods
case "getcasedata":
Context_GetCaseData(vaProxy);
break;
case "parseratsignal":
Context_ParseRatsignal(vaProxy);
break;
case "startup":
Context_Startup(vaProxy);
break;
// plugin settings
// NYI
// invalid
default:
Log.Error($"Invalid plugin context '{vaProxy.Context}'.");
break;
}
}
catch (ArgumentNullException e)
{
Log.Error($"Missing parameter '~{e.ParamName}' for context '{context}'");
}
catch (Exception e)
{
Log.Error($"Unhandled exception while executing plugin context '{context}'. ({e.Message})");
}
}
public static void VA_Exit1(dynamic vaProxy)
{
Log.Debug("Starting teardown …");
Log.Debug("Closing RATSIGNAL pipe …");
RatsignalPipe!.Stop();
Log.Debug("Teardown finished.");
}
public static void VA_StopCommand() { }
}
}

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{64CD3BA3-7FD2-4360-B055-6927CE92DA68}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RatAttack</RootNamespace>
<AssemblyName>RatAttack</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Serialization" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="RatAttack.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VoiceAttack-base\VoiceAttack-base\VoiceAttack-base.csproj">
<Project>{1c05db3f-3449-4664-b363-a379892995e5}</Project>
<Name>VoiceAttack-base</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30406.217
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoiceAttack-base", "VoiceAttack-base\VoiceAttack-base.csproj", "{1C05DB3F-3449-4664-B363-A379892995E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1C05DB3F-3449-4664-B363-A379892995E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C05DB3F-3449-4664-B363-A379892995E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C05DB3F-3449-4664-B363-A379892995E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C05DB3F-3449-4664-B363-A379892995E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D5161776-4AF2-4774-A469-88925187456B}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VoiceAttack-base")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VoiceAttack-base")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1c05db3f-3449-4664-b363-a379892995e5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1C05DB3F-3449-4664-B363-A379892995E5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>alterNERDtive</RootNamespace>
<AssemblyName>base</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\tools\VoiceAttack\Apps\alterNERDtive\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="base.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="util.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,210 @@
#nullable enable
using alterNERDtive.util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting.Channels;
using System.Threading.Tasks;
using System.Timers;
namespace alterNERDtive
{
public class BasePlugin
{
private static dynamic? VA { get; set; }
private static readonly Dictionary<Guid, string> Profiles = new Dictionary<Guid, string> {
{ new Guid("{f31b575b-6ce4-44eb-91fc-7459e55013cf}"), "EliteAttack" },
{ new Guid("{87276668-2a6e-4d80-af77-80651daa58b7}"), "RatAttack" },
{ new Guid("{e722b29d-898e-47dd-a843-a409c87e0bd8}"), "SpanshAttack" },
{ new Guid("{05580e6c-442c-46cd-b36f-f5a1f967ec59}"), "StreamAttack" }
};
private static readonly List<string> ActiveProfiles = new List<string>();
private static VoiceAttackLog Log => log ??= new VoiceAttackLog(VA, "alterNERDtive-base");
private static VoiceAttackLog? log;
private static VoiceAttackCommands Commands => commands ??= new VoiceAttackCommands(VA, Log);
private static VoiceAttackCommands? commands;
private static void CheckProfiles(dynamic vaProxy)
{
ActiveProfiles.Clear();
foreach (KeyValuePair<Guid, string> entry in Profiles)
{
if (vaProxy.Profile.Exists(entry.Key))
ActiveProfiles.Add(entry.Value);
}
Log.Debug($"Profiles found: {string.Join<string>(", ", ActiveProfiles)}");
}
/*================\
| plugin contexts |
\================*/
private static void Context_DistanceBetween(dynamic vaProxy)
{
string fromSystem = vaProxy.GetText("~fromSystem");
string toSystem = vaProxy.GetText("~toSystem");
int roundTo = vaProxy.GetInt("~roundTo") ?? 2;
string path = $"{vaProxy.GetText("Python.ScriptPath")}\\explorationtools.exe";
string arguments = $"distancebetween --roundto {roundTo} \"{fromSystem}\" \"{toSystem}\"";
Process p = PythonProxy.SetupPythonScript(path, arguments);
decimal distance = 0; // sadly currently you cant pass decimals to a command by value … so as a string it is.
bool error = false;
string errorMessage = "";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
switch (p.ExitCode)
{
case 0:
distance = Decimal.Parse(output);
break;
case 1:
case 2:
error = true;
Log.Error(output);
errorMessage = output;
break;
default:
error = true;
Log.Error(output);
errorMessage = "Unrecoverable error in plugin.";
break;
}
Log.Info($"{fromSystem} → {toSystem}: {distance}ly");
vaProxy.SetDecimal("~distance", distance);
vaProxy.SetBoolean("~error", error);
vaProxy.SetText("~errorMessage", errorMessage);
vaProxy.SetInt("~exitCode", p.ExitCode);
}
private static void Context_EddiEvent(dynamic vaProxy)
{
string eddiEvent = vaProxy.Command.Name();
string command = eddiEvent.Substring(2, eddiEvent.Length - 4);
Log.Debug($"Running EDDI event '{command}' …");
Commands.RunAll(ActiveProfiles, command, logMissing: false, subcommand: true); // FIXXME: a) triggerAll or something, b) change all profiles to use "((<name>.<event>))" over "<name>.<event>"
}
private static void Context_Log(dynamic vaProxy)
{
string sender = vaProxy.GetText("~sender");
string message = vaProxy.GetText("~message");
string level = vaProxy.GetText("~level");
if (level == null)
{
Log.Log(sender, message);
}
else
{
try
{
Log.Log(sender, message, (LogLevel)Enum.Parse(typeof(LogLevel), level.ToUpper()));
}
catch (ArgumentException)
{
Log.Error($"Invalid log level '${level}'.");
}
}
}
private static void Context_Startup(dynamic vaProxy)
{
Log.Notice("Starting up …");
VA = vaProxy;
CheckProfiles(VA);
Commands.RunAll(ActiveProfiles, "startup", logMissing: false);
Log.Notice("Finished startup.");
}
private static void Context_SetLogLevel(dynamic vaProxy)
{
string level = vaProxy.GetText("~level");
try
{
Log.SetCurrentLogLevel(level);
}
catch (ArgumentException)
{
Log.Error($"Invalid LogLevel '{level}'.");
}
}
/*========================================\
| required VoiceAttack plugin shenanigans |
\========================================*/
static readonly string VERSION = "0.0.1";
public static Guid VA_Id()
=> new Guid("{F7F59CFD-1AE2-4A7E-8F62-C62372418BAC}");
public static string VA_DisplayName()
=> $"alterNERDtive-base {VERSION}";
public static string VA_DisplayInfo()
=> "The alterNERDtive plugin to manage all the alterNERDtive profiles!";
public static void VA_Init1(dynamic vaProxy)
{
VA = vaProxy;
Log.Notice("Initializing …");
Commands.TriggerEvent("alterNERDtive-base.initialized", wait: false);
Log.Notice("Init successful.");
}
public static void VA_Invoke1(dynamic vaProxy)
{
string context = vaProxy.Context.ToLower();
Log.Debug($"Running context '{context}' …");
try
{
switch (context)
{
// plugin methods
case "distancebetween":
Context_DistanceBetween(vaProxy);
break;
case "eddievent":
Context_EddiEvent(vaProxy);
break;
case "log":
Context_Log(vaProxy);
break;
case "startup":
Context_Startup(vaProxy);
break;
// plugin settings
case "setloglevel":
Context_SetLogLevel(vaProxy);
break;
// invalid
default:
Log.Error($"Invalid plugin context '{vaProxy.Context}'.");
break;
}
}
catch (ArgumentNullException e)
{
Log.Error($"Missing parameter '~{e.ParamName}' for context '{context}'");
}
catch (Exception e)
{
Log.Error($"Unhandled exception while executing plugin context '{context}'. ({e.Message})");
}
}
public static void VA_Exit1(dynamic vaProxy) { }
public static void VA_StopCommand() { }
}
}

View file

@ -0,0 +1,218 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Threading;
using System.Threading.Tasks;
namespace alterNERDtive.util
{
public class PythonProxy
{
public static Process SetupPythonScript(string path, string arguments)
{
Process p = new Process();
p.StartInfo.FileName = path;
p.StartInfo.Arguments = arguments;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.RedirectStandardOutput = true;
//p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
return p;
}
}
public enum LogLevel
{
ERROR,
WARN,
NOTICE,
INFO,
DEBUG
}
public class VoiceAttackCommands
{
private readonly dynamic VA;
private readonly VoiceAttackLog Log;
public VoiceAttackCommands(dynamic vaProxy, VoiceAttackLog log) => (VA, Log) = (vaProxy, log);
public void Run(string command, bool logMissing = true, bool wait = false, bool subcommand = false, Action<Guid?>? callback = null, dynamic[]? parameters = null)
{
_ = command ?? throw new ArgumentNullException("command");
if (VA.Command.Exists(command))
{
Log.Debug($"Parsing arguments for command '{command}' …");
string[]? strings = null;
int[]? integers = null;
decimal[]? decimals = null;
bool[]? booleans = null;
DateTime[]? dates = null; // this might not work!
if (parameters != null)
{
foreach (var values in parameters)
{
if (values.GetType() == typeof(string[]))
strings = values as string[];
else if (values.GetType() == typeof(int[]))
integers = values as int[];
else if (values.GetType() == typeof(decimal[]))
decimals = values as decimal[];
else if (values.GetType() == typeof(bool[]))
booleans = values as bool[];
else if (values.GetType() == typeof(DateTime[]))
dates = values as DateTime[];
}
}
Log.Debug($"Running command '{command}' …");
VA.Command.Execute(
CommandPhrase: command,
WaitForReturn: wait,
AsSubcommand: subcommand,
CompletedAction: callback,
PassedText: strings == null ? null : $"\"{String.Join<string>("\";\"", strings)}\"",
PassedIntegers: integers == null ? null : String.Join<int>(";", integers),
PassedDecimals: decimals == null ? null : String.Join<decimal>(";", decimals),
PassedBooleans: booleans == null ? null : String.Join<bool>(";", booleans),
PassedDates: dates == null ? null : String.Join<DateTime>(";", dates)
);
}
else
{
if (logMissing)
Log.Warn($"Tried running missing command '{command}'.");
}
}
public void RunAll(IEnumerable<string> prefixes, string command, bool logMissing = true, bool wait = false, bool subcommand = false, Action<Guid?>? callback = null, dynamic[]? parameters = null)
{
foreach (string prefix in prefixes)
Run($"{prefix}.{command}", logMissing, wait, subcommand, callback, parameters);
}
public void TriggerEvent(string name, bool logMissing = true, bool wait = false, bool subcommand = false, Action<Guid?>? callback = null, dynamic[]? parameters = null)
{
Run($"(({name}))", logMissing, wait, subcommand, callback, parameters);
}
public void TriggerEventAll(IEnumerable<string> prefixes, string name, bool logMissing = true, bool wait = false, bool subcommand = false, Action<Guid?>? callback = null, dynamic[]? parameters = null)
{
foreach (string prefix in prefixes)
Run($"(({prefix}.{name}))", logMissing, wait, subcommand, callback, parameters);
}
}
public class VoiceAttackLog
{
private readonly dynamic VA;
private readonly string ID;
private static readonly string[] LogColour = { "red", "yellow", "green", "blue", "gray" };
public LogLevel? CurrentLogLevel {
get => currentLogLevel ?? LogLevel.NOTICE;
set
{
currentLogLevel = value;
Notice($"Log level set to {value ?? LogLevel.NOTICE}.");
}
}
public void SetCurrentLogLevel(string level)
{
if (level == null)
CurrentLogLevel = null;
else
CurrentLogLevel = (LogLevel)Enum.Parse(typeof(LogLevel), level.ToUpper());
}
private static LogLevel? currentLogLevel;
public VoiceAttackLog(dynamic vaProxy, string id) => (VA, ID) = (vaProxy, id);
public void Log(string message, LogLevel level = LogLevel.INFO)
{
Log(ID, message, level);
}
public void Log(string sender, string message, LogLevel level = LogLevel.INFO)
{
_ = sender ?? throw new ArgumentNullException("sender");
_ = message ?? throw new ArgumentNullException("message");
if (level <= CurrentLogLevel)
VA.WriteToLog($"{level} | {sender}: {message}", LogColour[(int)level]);
}
public void Error(string message) => Log(message, LogLevel.ERROR);
public void Warn(string message) => Log(message, LogLevel.WARN);
public void Notice(string message) => Log(message, LogLevel.NOTICE);
public void Info(string message) => Log(message, LogLevel.INFO);
public void Debug(string message) => Log(message, LogLevel.DEBUG);
}
public interface IPipable
{
public void ParseString(string serialization);
public string ToString();
}
public class PipeServer<Thing> where Thing : IPipable, new()
{
private readonly CancellationTokenSource ThreadTokens = new CancellationTokenSource();
private readonly string PipeName;
private readonly SignalHandler Handler;
private readonly VoiceAttackLog Log;
private bool Running = false;
public PipeServer(VoiceAttackLog log, string name, SignalHandler handler)
=> (Log, PipeName, Handler) = (log, name, handler);
public delegate void SignalHandler(Thing thing);
public PipeServer<Thing> Run()
{
if (!Running)
{
Task.Factory.StartNew(() => { RunPipeServer(ThreadTokens.Token, PipeName); });
Running = true;
}
return this;
}
public PipeServer<Thing> Stop()
{
if (Running)
{
ThreadTokens.Cancel();
Running = false;
}
return this;
}
private void RunPipeServer(CancellationToken token, string name)
{
while (!token.IsCancellationRequested)
{
try
{
using NamedPipeServerStream server = new NamedPipeServerStream(name, PipeDirection.In);
server.WaitForConnection();
using StreamReader reader = new StreamReader(server);
Thing thing = new Thing();
thing.ParseString(reader.ReadToEnd());
Handler(thing);
}
catch (Exception e)
{
Log.Error($"Error reading pipe: {e.Message}");
}
}
}
}
}

43
VoiceAttack-plugins.sln Normal file
View file

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoiceAttack-base", "VoiceAttack-base\VoiceAttack-base\VoiceAttack-base.csproj", "{1C05DB3F-3449-4664-B363-A379892995E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatAttack", "RatAttack\RatAttack\RatAttack.csproj", "{64CD3BA3-7FD2-4360-B055-6927CE92DA68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatAttack-cli", "RatAttack\RatAttack-cli\RatAttack-cli.csproj", "{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EliteAttack", "EliteAttack\EliteAttack\EliteAttack.csproj", "{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1C05DB3F-3449-4664-B363-A379892995E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C05DB3F-3449-4664-B363-A379892995E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C05DB3F-3449-4664-B363-A379892995E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C05DB3F-3449-4664-B363-A379892995E5}.Release|Any CPU.Build.0 = Release|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64CD3BA3-7FD2-4360-B055-6927CE92DA68}.Release|Any CPU.Build.0 = Release|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D72A35EC-8D39-4B96-BBC5-1B330F4CBEEF}.Release|Any CPU.Build.0 = Release|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77CEF35C-C25C-4793-AB2C-0B0C5D9A5BB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {339E6747-C7BF-43C3-99C6-9249C9849A84}
EndGlobalSection
EndGlobal

View file

@ -1,4 +1,4 @@
# EliteDangerous #
# EliteAttack #
This is my personal VoiceAttack profile for Elite: Dangerous. It started out
ages ago as a modification of [MalicVRs public

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.