Skip to content

Commit

Permalink
Merge pull request #425 from wbonbon/master
Browse files Browse the repository at this point in the history
update and bug fix
  • Loading branch information
wbonbon authored Sep 15, 2024
2 parents e645dd9 + b35eb2d commit 0a28d30
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,6 @@ public static string ReplaceText(
text = string.Empty;
}

var placeholders = TimelineManager.Instance.GetPlaceholders();
foreach (var ph in placeholders)
{
text = text.Replace(
ph.Placeholder,
ph.ReplaceString);
}

foreach (var item in GetVariables())
{
var variable = item.Value;
Expand Down Expand Up @@ -611,6 +603,14 @@ public static string ReplaceText(
}
}

var placeholders = TimelineManager.Instance.GetPlaceholders();
foreach (var ph in placeholders)
{
text = text.Replace(
ph.Placeholder,
ph.ReplaceString);
}

return text;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum AlertCategories
Ninja,
Samurai,
Reaper,
Viper,

Bard,
Machinist,
Expand All @@ -29,6 +30,7 @@ public enum AlertCategories
BlackMage,
Summoner,
RedMage,
Pictomancer,
BlueMage,

CrafterAndGatherer,
Expand Down Expand Up @@ -80,6 +82,8 @@ public static class JobIdsExtensions
{ "Dancer", "おどりこ", "Danseur", "Tänzer", "Dancer", "Dancer",},
{ "Reaper", "りーぱー", "Faucheur", "Schnitter", "Reaper", "Reaper",},
{ "Sage", "けんじゃ", "Sage", "Weiser", "Sage", "Sage",},
{ "Viper", "う゛ぁいぱー", "Rôdeur vipèr", "Viper", "Viper", "Viper",},
{ "Pictomancer", "ぴくとまんさー", "Pictomancien", "Piktomant", "Pictomancer", "Pictomancer",},
};

public static readonly AlertCategories[] JobAlertCategories = new AlertCategories[]
Expand Down Expand Up @@ -125,6 +129,8 @@ public static class JobIdsExtensions
AlertCategories.Dancer,
AlertCategories.Reaper,
AlertCategories.Sage,
AlertCategories.Viper,
AlertCategories.Pictomancer,
};

public static string GetPhonetic(
Expand Down Expand Up @@ -157,12 +163,14 @@ public static class AlertCategoriesExtensions
{ "Ninja/Rogue", "忍者・双剣士","Ninja/Rogue","Ninja/Rogue","Ninja/Rogue","忍者", },
{ "Samurai", "侍","Samurai","Samurai","Samurai","武士", },
{ "Reaper", "リーパー", "Faucheur", "Schnitter", "Reaper", "Reaper", },
{ "Viper", "ヴァイパー", "Rôdeur vipèr", "Viper", "Viper", "Viper", },
{ "Bard/Archer", "吟遊詩人・弓術士","Bard/Archer","Bard/Archer","Bard/Archer","诗人", },
{ "Machinist", "機工士","Machinist","Machinist","Machinist","机工", },
{ "Dancer", "踊り子","Dancer","Dancer","Dancer","Dancer", },
{ "Black Mage/Thaumaturge", "黒魔道士・呪術師","Black Mage/Thaumaturge","Black Mage/Thaumaturge","Black Mage/Thaumaturge","黑魔", },
{ "Summoner/Arcanist", "召喚士・巴術士","Summoner/Arcanist","Summoner/Arcanist","Summoner/Arcanist","召唤", },
{ "Red Mage", "赤魔道士","Red Mage","Red Mage","Red Mage","赤魔", },
{ "Pictomancer", "ピクトマンサー","Pictomancien","Piktomant","Pictomancer","Pictomancer", },
{ "Blue Mage", "青魔道士","Blue Mage","Blue Mage","Blue Mage","Blue Mage", },
{ "Crafter/Gatherer", "クラフター・ギャザラー","Crafter/Gatherer","Crafter/Gatherer","Crafter/Gatherer","采集/制造", },
};
Expand Down
9 changes: 9 additions & 0 deletions source/ACT.TTSYukkuri/ACT.TTSYukkuri.Core/Config/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public static Settings Default
private StatusAlertConfig statusAlertSettings = new StatusAlertConfig();
private DiscordSettings discordSettings = new DiscordSettings();

private string temporarySwitchSoundDevice;

/// <summary>
/// プラグインのUIのロケール
/// </summary>
Expand Down Expand Up @@ -587,6 +589,13 @@ public DiscordSettings DiscordSettings
/// </summary>
public double GlobalSoundInterval { get; set; } = 0.4d;


public string TemporarySwitchSoundDevice
{
get => this.temporarySwitchSoundDevice;
set => this.SetProperty(ref this.temporarySwitchSoundDevice, value);
}

/// <summary>
/// 設定をロードする
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions source/ACT.TTSYukkuri/ACT.TTSYukkuri.Core/FFXIVWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static void Initialize()
{
if (instance != null)
{
instance.Start(); // instance作成直後はStartに成功しないことがあるのでInitializeを呼び出すたびにStartを試みる
return;
}

Expand Down
80 changes: 80 additions & 0 deletions source/ACT.TTSYukkuri/ACT.TTSYukkuri.Core/PluginCore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -50,6 +51,65 @@ public static void Free()
private Logger AppLogger => AppLog.DefaultLogger;

#endregion Logger
internal enum ERole : uint
{
eConsole = 0,
eMultimedia = 1,
eCommunications = 2,
ERole_enum_count = 3
}
[Guid("F8679F50-850A-41CF-9C72-430F290290C8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPolicyConfig
{
[PreserveSig]
int GetMixFormat();
[PreserveSig]
int GetDeviceFormat();
[PreserveSig]
int ResetDeviceFormat();
[PreserveSig]
int SetDeviceFormat();
[PreserveSig]
int GetProcessingPeriod();
[PreserveSig]
int SetProcessingPeriod();
[PreserveSig]
int GetShareMode();
[PreserveSig]
int SetShareMode();
[PreserveSig]
int GetPropertyValue();
[PreserveSig]
int SetPropertyValue();
[PreserveSig]
int SetDefaultEndpoint(
[In][MarshalAs(UnmanagedType.LPWStr)] string deviceId,
[In][MarshalAs(UnmanagedType.U4)] ERole role);
[PreserveSig]
int SetEndpointVisibility();
}
[ComImport, Guid("870AF99C-171D-4F9E-AF0D-E63DF40C2BC9")]
internal class _CPolicyConfigClient
{
}
public class PolicyConfigClient
{
public static int SetDefaultDevice(string deviceID)
{
IPolicyConfig _policyConfigClient = (new _CPolicyConfigClient() as IPolicyConfig);
try
{
Marshal.ThrowExceptionForHR(_policyConfigClient.SetDefaultEndpoint(deviceID, ERole.eConsole));
Marshal.ThrowExceptionForHR(_policyConfigClient.SetDefaultEndpoint(deviceID, ERole.eMultimedia));
Marshal.ThrowExceptionForHR(_policyConfigClient.SetDefaultEndpoint(deviceID, ERole.eCommunications));
return 0;
}
catch
{
return 1;
}
}
}

#region Replace TTS Method

Expand Down Expand Up @@ -645,6 +705,26 @@ private void SubscribeTextCommands()
},
(string logLine, Match match) =>
{
List<PlayDevice> list = FFXIV.Framework.Common.WavePlayer.EnumerateDevicesByWasapiOut();
string temp_device_name = Settings.Default.TemporarySwitchSoundDevice;
if (!string.IsNullOrEmpty(temp_device_name))
{
string current_device_id = Settings.Default.MainDeviceID;

string deviceid = list.Find(x => x.Name.Contains(temp_device_name)).ID;
if (PolicyConfigClient.SetDefaultDevice(deviceid) == 0)
{
this.AppLogger.Info("Change Default Sound Device to " + temp_device_name + ", success.");

deviceid = list.Find(x => x.ID == current_device_id).ID;
string devicename = list.Find(x => x.ID == current_device_id).Name;
if (PolicyConfigClient.SetDefaultDevice(deviceid) == 0)
{
this.AppLogger.Info("Restore Default Sound Device to " + devicename + ", success.");

}
}
}
SoundPlayerWrapper.Init();
this.AppLogger.Info("Playback stream initialized.");
})
Expand Down

0 comments on commit 0a28d30

Please sign in to comment.