Skip to content

Commit

Permalink
inchina
Browse files Browse the repository at this point in the history
  • Loading branch information
tssailzz8 committed Nov 2, 2022
1 parent 3a42c6d commit bb6fc2b
Show file tree
Hide file tree
Showing 15 changed files with 1,294 additions and 739 deletions.
51 changes: 30 additions & 21 deletions FetchDependencies/FetchDependencies.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO.Compression;
using System.Net;

namespace FetchDependencies {
public class FetchDependencies {
Expand All @@ -13,24 +14,24 @@ public FetchDependencies() {
}

public async Task GetFfxivPlugin() {
Directory.CreateDirectory(DependenciesDir);
var pluginZipPath = Path.Combine(DependenciesDir, "FFXIV_ACT_Plugin.zip");
var pluginPath = Path.Combine(DependenciesDir, "FFXIV_ACT_Plugin.dll");
Directory.CreateDirectory(DependenciesDir);
var pluginZipPath = Path.Combine(DependenciesDir, "FFXIV_ACT_Plugin.zip");
var pluginPath = Path.Combine(DependenciesDir, "FFXIV_ACT_Plugin.dll");

if (!await NeedsUpdate(pluginPath))
return;
if (!await NeedsUpdate(pluginPath))
return;

if (!File.Exists(pluginZipPath))
await DownloadPlugin(pluginZipPath);
if (!File.Exists(pluginPath))
await DownloadPlugin(pluginPath);

ZipFile.ExtractToDirectory(pluginZipPath, DependenciesDir, overwriteFiles: true);
File.Delete(pluginZipPath);
// ZipFile.ExtractToDirectory(pluginZipPath, DependenciesDir, overwriteFiles: true);
//File.Delete(pluginPath);

var patcher = new Patcher(DependenciesDir);
patcher.MainPlugin();
patcher.LogFilePlugin();
patcher.MemoryPlugin();
}
var patcher = new Patcher(DependenciesDir);
patcher.MainPlugin();
patcher.LogFilePlugin();
patcher.MemoryPlugin();
}

private static async Task<bool> NeedsUpdate(string dllPath) {
if (!File.Exists(dllPath)) return true;
Expand All @@ -50,12 +51,20 @@ private static async Task<bool> NeedsUpdate(string dllPath) {
}

private static async Task DownloadPlugin(string path) {
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(ActUserAgent);
await using var downloadStream = await httpClient.GetStreamAsync("https://advancedcombattracker.com/download.php?id=73");
await using var zipFileStream = new FileStream(path, FileMode.Create);
await downloadStream.CopyToAsync(zipFileStream);
zipFileStream.Close();
}
string url = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://github.com/TundraWork/FFXIV_ACT_Plugin_CN/releases/latest");
req.Method = "HEAD";
req.AllowAutoRedirect = false;
HttpWebResponse myResp = (HttpWebResponse)req.GetResponse();
if (myResp.StatusCode == HttpStatusCode.Redirect)
url = myResp.GetResponseHeader("Location");
var bcd = url.Split(@"/")[7];
var httpClient = new HttpClient();
await using var downloadStream = await httpClient.GetStreamAsync($"https://github.com/TundraWork/FFXIV_ACT_Plugin_CN/releases/download/{bcd}/FFXIV_ACT_Plugin.dll");
await using var zipFileStream = new FileStream(path, FileMode.Create);
await downloadStream.CopyToAsync(zipFileStream);
zipFileStream.Close();

}
}
}
2 changes: 1 addition & 1 deletion FetchDependencies/FetchDependencies.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<LangVersion>11</LangVersion>
<LangVersion>10</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
17 changes: 17 additions & 0 deletions FetchDependencies/FetchDependencies.csproj.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions IINACT/IINACT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ApplicationIcon>[email protected]</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<PgoMode>full</PgoMode>
<Version>0.4.1</Version>
<LangVersion>11</LangVersion>
<LangVersion>10</LangVersion>
</PropertyGroup>


Expand Down
91 changes: 91 additions & 0 deletions IINACT/IINACT.csproj.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>True</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ApplicationIcon>[email protected]</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<PgoMode>full</PgoMode>
<Version>0.4.1</Version>
<LangVersion>11</LangVersion>
</PropertyGroup>


<ItemGroup>
<Content Include="Icon-IINACT-512x512%402x.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.0.0" />
<PackageReference Include="DarkModeUI" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FetchDependencies\FetchDependencies.csproj" />
<ProjectReference Include="..\machina\Machina\Machina.csproj" />
<ProjectReference Include="..\OverlayPlugin.Core\OverlayPlugin.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="FFXIV_ACT_Plugin">
<HintPath>..\external_dependencies\FFXIV_ACT_Plugin.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Common">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Common.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Config">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Config.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Logfile">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Logfile.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Memory">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Memory.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Network">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Network.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Parse">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Parse.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Resource">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Resource.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Machina.FFXIV">
<HintPath>..\external_dependencies\Machina.FFXIV.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>

</Project>
52 changes: 40 additions & 12 deletions NotACT/FormActMain.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Globalization;
using System.Speech.Synthesis;
using System.Text.RegularExpressions;
using System.Threading;

Expand Down Expand Up @@ -40,18 +42,32 @@ public partial class FormActMain : Form {
public event LogFileChangedDelegate LogFileChanged;
public event CombatActionDelegate AfterCombatAction;
public delegate DateTime DateTimeLogParser(string logLine);

public FormActMain() {
public InstalledVoice Voice;
public FormActMain() {
InitializeComponent();
AppDataFolder = new DirectoryInfo(Path.Combine(LogFilePath, "Data"));
ActGlobals.ActLocalization.Init();
ActGlobals.ActLocalization.AddPrebuild();
Resources.NotActMainFormatter.SetupEnvironment();
LastKnownTime = DateTime.Now;
StartAfterCombatActionThread();
}

public void WriteExceptionLog(Exception ex, string MoreInfo) {
getVoice();
}
public void getVoice()
{

using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
foreach (var voice in synth.GetInstalledVoices())
{
if (voice.VoiceInfo.Culture.Name.Contains("zh"))
{
Voice = voice;
}
}
}
}
public void WriteExceptionLog(Exception ex, string MoreInfo) {
var value = $"***** {DateTime.Now.ToString("s")} - {MoreInfo}\n{ex}\n{Environment.StackTrace}\n*****";
Trace.WriteLine(value);
}
Expand All @@ -75,10 +91,14 @@ public void ParseRawLogLine(string logLine) {


public void TTS(string message, string binary = "/usr/bin/say", string args = "") {
lock (_ttsLock) {
if (new FileInfo(binary).Exists) {
try {
var ttsProcess = new Process {
lock (_ttsLock)
{
if (new FileInfo(binary).Exists)
{
try
{
var ttsProcess = new Process
{
StartInfo = {
FileName = binary,
CreateNoWindow = true,
Expand All @@ -89,13 +109,21 @@ public void TTS(string message, string binary = "/usr/bin/say", string args = ""
ttsProcess.Start();
Thread.Sleep(500 * message.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length);
}
catch (Exception ex) {
catch (Exception ex)
{
WriteExceptionLog(ex, $"TTS failed to play back {message}");
}
} else {
Trace.WriteLine($"TTS binary {binary} not found");
}
else
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.Rate = 0;
synth.Volume = 100;
synth.SelectVoice(Voice.VoiceInfo.Name);
synth.SpeakAsync(message);
}
}

}

public Regex ZoneChangeRegex { get; set; }
Expand Down
6 changes: 5 additions & 1 deletion NotACT/NotACT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Version>6.9</Version>
<LangVersion>11</LangVersion>
<LangVersion>10</LangVersion>
</PropertyGroup>

<ItemGroup>
<Folder Include="Datatypes\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Speech" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="FFXIV_ACT_Plugin">
<HintPath>..\external_dependencies\FFXIV_ACT_Plugin.dll</HintPath>
Expand Down
30 changes: 30 additions & 0 deletions NotACT/NotACT.csproj.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Advanced Combat Tracker</AssemblyName>
<RootNamespace>Advanced_Combat_Tracker</RootNamespace>
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Version>6.9</Version>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<Folder Include="Datatypes\" />
</ItemGroup>

<ItemGroup>
<Reference Include="FFXIV_ACT_Plugin">
<HintPath>..\external_dependencies\FFXIV_ACT_Plugin.dll</HintPath>
</Reference>
<Reference Include="FFXIV_ACT_Plugin.Logfile">
<HintPath>..\external_dependencies\SDK\FFXIV_ACT_Plugin.Logfile.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion OverlayPlugin.Common/OverlayPlugin.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<LangVersion>11</LangVersion>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
22 changes: 22 additions & 0 deletions OverlayPlugin.Common/OverlayPlugin.Common.csproj.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>RainbowMage.OverlayPlugin</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<LangVersion>11</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NotACT\NotACT.csproj" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions OverlayPlugin.Core/Integration/FFXIVCustomLogLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public FFXIVCustomLogLines(TinyIoCContainer container) {
}
}
if (registry.ContainsKey(registeredCustomLogLineID)) {
var entry = registry[registeredCustomLogLineID];
var Source = entry.Source.Replace("\r", "\\r").Replace("\n", "\\n");
var Name = entry.Name.Replace("\r", "\\r").Replace("\n", "\\n");
repository.WriteLogLineImpl(registeredCustomLogLineID, DateTime.Now, $"{registeredCustomLogLineID}|{Source}|{Name}|{entry.Version}");
//var entry = registry[registeredCustomLogLineID];
//var Source = entry.Source.Replace("\r", "\\r").Replace("\n", "\\n");
//var Name = entry.Name.Replace("\r", "\\r").Replace("\n", "\\n");
//repository.WriteLogLineImpl(registeredCustomLogLineID, DateTime.Now, $"{registeredCustomLogLineID}|{Source}|{Name}|{entry.Version}");
}
}
catch (Exception ex) {
Expand Down
Loading

0 comments on commit bb6fc2b

Please sign in to comment.