Skip to content

Commit

Permalink
Merge pull request #1 from anoyetta-academy/develop
Browse files Browse the repository at this point in the history
publish alpha9
  • Loading branch information
anoyetta authored May 23, 2019
2 parents d864c3e + f492a48 commit 06e2488
Show file tree
Hide file tree
Showing 116 changed files with 3,211 additions and 525 deletions.
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
# kagami
# kagami

「カガミ」はスキル回しを見やすく表示するためのツールです。OverlayPlugin の Add-on として動作します。

* 配信のときに視聴者がスキル回しを見せることが出来る
* 自分で録画を確認するときにスキル回しをチェックしやすくなる
* 木人でのスキル回し動画を作成するときにスキル回しを見せやすくなる



**[DOWNLOAD](<https://github.com/anoyetta-academy/kagami/releases>)**



## インストール

1. ダウンロードする

2. ダウンロードしたものを解凍する

3. ダウンロードしたものをOverlayPluginのインストールディレクトリに上書きコピーする

```
OverlayPlugin
├ addons
│ ├ bin
│ ├ kagami.dll
│ └ kagami.Core.dll
└ resources
└ kagami
```



## 使い方

1. OverlayPlugin の設定タブで [New] をクリックする

2. オーバーレイの Name を入力する。例えば、"KAGAMI" とする

3. オーバーレイの Type で kagami を選択する

4. OK をクリックする

5. kagami オーバーレイの設定が表示されたら URL に使用したいスキンの URL を入力する


Binary file added images/kagami_screenshot_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions source/kagami.Core/Common/ThreadWorker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using System;
using System.Threading;

namespace kagami.Helpers.Common
{
public class ThreadWorker
{
private volatile bool isAbort;
private Thread thread;

/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="doWorkAction">
/// 定期的に実行するアクション</param>
/// <param name="interval">
/// インターバル。ミリ秒</param>
public ThreadWorker(
Action doWorkAction,
double interval,
string name = "",
ThreadPriority priority = ThreadPriority.Normal)
{
this.DoWorkAction = doWorkAction;
this.Interval = interval;
this.Name = name;
this.Priority = priority;
}

public Action DoWorkAction { get; set; }

public double Interval { get; set; }

public string Name { get; set; }

public ThreadPriority Priority { get; private set; }

public bool IsRunning { get; private set; }

public static ThreadWorker Run(
Action doWorkAction,
double interval,
string name = "",
ThreadPriority priority = ThreadPriority.Normal)
{
var worker = new ThreadWorker(doWorkAction, interval, name);
worker.Run();
return worker;
}

public bool Abort(
int timeout = 0)
{
var result = false;

this.isAbort = true;

if (timeout == 0)
{
timeout = (int)this.Interval;
}

if (this.thread != null)
{
this.thread.Join(timeout);
if (this.thread.IsAlive)
{
this.thread.Abort();
result = true;
}

this.thread = null;
}

this.IsRunning = false;

Logger.Info($"ThreadWorker - {this.Name} end.{(result ? " aborted" : string.Empty)}");

return result;
}

public void Run()
{
this.isAbort = false;

this.thread = new Thread(this.DoWorkLoop);
this.thread.IsBackground = true;
this.thread.Priority = this.Priority;
this.thread.Start();

this.IsRunning = true;
}

private void DoWorkLoop()
{
Thread.Sleep((int)this.Interval);
Logger.Info($"ThreadWorker - {this.Name} start.");

while (!this.isAbort)
{
try
{
this.DoWorkAction?.Invoke();
}
catch (ThreadAbortException)
{
this.isAbort = true;
Logger.Info($"ThreadWorker - {this.Name} abort.");
break;
}
catch (Exception ex)
{
Logger.Error($"ThreadWorker - {this.Name} error. {ex.ToString()}");
}

if (this.isAbort)
{
break;
}

if (this.Interval > 0)
{
Thread.Sleep((int)this.Interval);
}
}
}
}
}
123 changes: 123 additions & 0 deletions source/kagami.Core/Helpers/FFXIVPluginHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using Advanced_Combat_Tracker;
using kagami.Helpers.Common;

namespace kagami.Helpers
{
public class FFXIVPluginHelper
{
#region Singleton

private static readonly Lazy<FFXIVPluginHelper> LazyInstance = new Lazy<FFXIVPluginHelper>(() => new FFXIVPluginHelper());

public static FFXIVPluginHelper Instance => LazyInstance.Value;

private FFXIVPluginHelper()
{
}

#endregion Singleton

private ThreadWorker attachWorker;

private dynamic ffxivPlugin;
private dynamic ffxivPluginConfig;
private dynamic ffxivPluginLogParse;

public Process FFXIVProcess => this.ffxivPluginConfig?.Process;

public string FFXIVPluginLanguage => (this.ffxivPluginLogParse?.Settings?.LanguageID ?? 0) switch
{
1 => "English",
2 => "French",
3 => "German",
4 => "Japanese",
_ => "English",
};

private static readonly double AttachSubscribeInterval = 3000;

public void Start()
{
this.attachWorker = new ThreadWorker(() =>
{
if (ActGlobals.oFormActMain == null)
{
return;
}

if (this.ffxivPlugin == null)
{
this.ffxivPlugin = (
from x in ActGlobals.oFormActMain.ActPlugins
where
x.pluginFile.Name.ToUpper().Contains("FFXIV_ACT_Plugin".ToUpper()) &&
x.lblPluginStatus.Text.ToUpper().Contains("FFXIV Plugin Started.".ToUpper())
select
x.pluginObj).FirstOrDefault();
}

if (this.ffxivPlugin != null &&
this.ffxivPluginConfig == null)
{
var fi = this.ffxivPlugin.GetType().GetField(
"_Memory",
BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
var memory = fi?.GetValue(this.ffxivPlugin);
if (memory == null)
{
return;
}

fi = memory.GetType().GetField(
"_config",
BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
this.ffxivPluginConfig = fi?.GetValue(memory);

Logger.Info("FFXIV_ACT_Plugin.Config attached.");
}

if (this.ffxivPlugin != null &&
this.ffxivPluginLogParse == null)
{
var fi = this.ffxivPlugin.GetType().GetField(
"_LogParse",
BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);

this.ffxivPluginLogParse = fi?.GetValue(this.ffxivPlugin);

Logger.Info("FFXIV_ACT_Plugin.LogParse attached.");
}

if (this.ffxivPlugin != null &&
this.ffxivPluginConfig != null &&
this.ffxivPluginLogParse != null)
{
Thread.Sleep(TimeSpan.FromMilliseconds(AttachSubscribeInterval));
}
},
AttachSubscribeInterval,
"FFXIV_ACT_Plugin Subscriber",
ThreadPriority.Lowest);

this.attachWorker.Run();
}

public void Stop()
{
if (this.attachWorker != null)
{
this.attachWorker.Abort();
this.attachWorker = null;
}

this.ffxivPlugin = null;
this.ffxivPluginConfig = null;
this.ffxivPluginLogParse = null;
}
}
}
Loading

0 comments on commit 06e2488

Please sign in to comment.