Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for dawntrail and v10 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Dalamud.RichPresence/Dalamud.RichPresence.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Dalamud.RichPresence</AssemblyName>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64;AnyCPU</Platforms>
<LangVersion>9.0</LangVersion>
Expand All @@ -13,7 +13,7 @@
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<PropertyGroup Label="Documentation">
<DocumentationFile/>
<DocumentationFile />
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Label="Build">
Expand All @@ -32,9 +32,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.7"/>
<PackageReference GeneratePathProperty="true" Include="DiscordRichPresence" Version="1.0.175"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference GeneratePathProperty="true" Include="DiscordRichPresence" Version="1.0.175" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -46,10 +46,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.7"/>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0"/>
<PackageReference Include="NCalcSync" Version="2.0.0"/>
<PackageReference Include="XivCommon" Version="4.0.0-alpha.2"/>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="NCalcSync" Version="5.0.0" />
<PackageReference Include="XivCommon" Version="9.0.0" />
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
Expand Down Expand Up @@ -81,7 +80,7 @@
</ItemGroup>

<ItemGroup>
<Content Remove="Resources/loc/*.json"/>
<Content Remove="Resources/loc/*.json" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Dalamud.RichPresence/Interface/RichPresenceConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void DrawRichPresenceConfigWindow()
this.Close();
RichPresencePlugin.DalamudPluginInterface.SavePluginConfig(RichPresenceConfig);
RichPresencePlugin.RichPresenceConfig = this.RichPresenceConfig;
PluginLog.Log("Settings saved.");
RichPresencePlugin.PluginLog.Info("Settings saved.");
}

ImGui.End();
Expand Down
2 changes: 1 addition & 1 deletion Dalamud.RichPresence/Managers/DiscordPresenceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void CreateClient()
RpcClient.Logger = new ConsoleLogger { Level = LogLevel.Warning };

// Subscribe to events
RpcClient.OnPresenceUpdate += (sender, e) => { Console.WriteLine("Received Update! {0}", e.Presence); };
RpcClient.OnPresenceUpdate += (sender, e) => { System.Console.WriteLine("Received Update! {0}", e.Presence); };
}

if (!RpcClient.IsInitialized)
Expand Down
15 changes: 9 additions & 6 deletions Dalamud.RichPresence/Managers/LocalizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Dalamud.Logging;

using Dalamud.RichPresence.Models;
using Dalamud.Game;
using Dalamud.Plugin.Services;

namespace Dalamud.RichPresence.Managers
{
Expand All @@ -18,6 +20,7 @@ internal class LocalizationManager : IDisposable
private Dictionary<string, LocalizationEntry> pluginLocalizationDictionary;
private Dictionary<string, LocalizationEntry> defaultLocalizationDictionary;


private const string PREFIX = "dalamud_richpresence_";
private const string DEFAULT_DICT_LANGCODE = "en";

Expand Down Expand Up @@ -63,24 +66,24 @@ public void Dispose()

private void ReadClientLanguageLocFile(string langCode)
{
PluginLog.LogDebug("Loading client localization file...");
RichPresencePlugin.PluginLog.Debug("Loading client localization file...");
clientLocalizationDictonary = this.ReadFileWithLangCode(langCode);
clientCultureInfo = new CultureInfo(langCode);
PluginLog.LogDebug("Client localization file loaded.");
RichPresencePlugin.PluginLog.Debug("Client localization file loaded.");
}

private void ReadPluginLanguageLocFile(string langCode)
{
PluginLog.LogDebug("Loading plugin localization file...");
RichPresencePlugin.PluginLog.Debug("Loading plugin localization file...");
pluginLocalizationDictionary = ReadFileWithLangCode(langCode);
PluginLog.LogDebug("Plugin localization file loaded.");
RichPresencePlugin.PluginLog.Debug("Plugin localization file loaded.");
}

private Dictionary<string, LocalizationEntry> ReadFileWithLangCode(string langCode)
{
try
{
PluginLog.LogDebug($"Reading localization file with language code {langCode}...");
RichPresencePlugin.PluginLog.Debug($"Reading localization file with language code {langCode}...");
return JsonConvert.DeserializeObject<Dictionary<string, LocalizationEntry>>(
File.ReadAllText(Path.Combine(
RichPresencePlugin.DalamudPluginInterface.AssemblyLocation.DirectoryName,
Expand All @@ -92,7 +95,7 @@ private Dictionary<string, LocalizationEntry> ReadFileWithLangCode(string langCo
}
catch (Exception ex)
{
PluginLog.LogError(ex, $"File with language code {langCode} not loaded, using fallbacks...");
RichPresencePlugin.PluginLog.Debug(ex, $"File with language code {langCode} not loaded, using fallbacks...");
return JsonConvert.DeserializeObject<Dictionary<string, LocalizationEntry>>(
File.ReadAllText(Path.Combine(
RichPresencePlugin.DalamudPluginInterface.AssemblyLocation.DirectoryName,
Expand Down
36 changes: 22 additions & 14 deletions Dalamud.RichPresence/RichPresencePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,33 @@
using Dalamud.RichPresence.Managers;
using Dalamud.RichPresence.Models;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;

namespace Dalamud.RichPresence
{
internal class RichPresencePlugin : IDalamudPlugin, IDisposable
{
[PluginService]
internal static DalamudPluginInterface DalamudPluginInterface { get; private set; }
internal static IDalamudPluginInterface DalamudPluginInterface { get; private set; }

[PluginService]
internal static IClientState ClientState { get; private set; }

[PluginService]
internal static ClientState ClientState { get; private set; }
internal static ICommandManager CommandManager { get; private set; }

[PluginService]
internal static CommandManager CommandManager { get; private set; }
internal static IDataManager DataManager { get; private set; }

[PluginService]
internal static DataManager DataManager { get; private set; }
internal static IFramework Framework { get; private set; }

[PluginService]
internal static Framework Framework { get; private set; }
internal static IPartyList PartyList { get; private set; }

[PluginService]
internal static PartyList PartyList { get; private set; }
internal static IPluginLog PluginLog { get; private set; }

internal static LocalizationManager LocalizationManager { get; private set; }
internal static DiscordPresenceManager DiscordPresenceManager { get; private set; }
Expand Down Expand Up @@ -78,6 +83,7 @@ public RichPresencePlugin()
DalamudPluginInterface.UiBuilder.Draw += RichPresenceConfigWindow.DrawRichPresenceConfigWindow;
DalamudPluginInterface.UiBuilder.OpenConfigUi += RichPresenceConfigWindow.Open;


Framework.Update += UpdateRichPresence;

ClientState.Login += State_Login;
Expand All @@ -90,6 +96,11 @@ public RichPresencePlugin()
Territories = DataManager.GetExcelSheet<TerritoryType>().ToList();
}

private void State_Login()
{
UpdateStartTime();
}

public string Name => "Discord Rich Presence";

public void Dispose()
Expand Down Expand Up @@ -134,17 +145,14 @@ private void UpdateStartTime()
}
}

private void State_Login(object sender, System.EventArgs e)
{
UpdateStartTime();
}


private void State_TerritoryChanged(object sender, ushort e)
private void State_TerritoryChanged(ushort arg)
{
UpdateStartTime();
}

private void State_Logout(object sender, System.EventArgs e)
private void State_Logout()
{
SetDefaultPresence();
UpdateStartTime();
Expand All @@ -171,7 +179,7 @@ private void RegisterCommand()
);
}

private unsafe void UpdateRichPresence(Framework framework)
private unsafe void UpdateRichPresence(IFramework framework)
{
try
{
Expand Down Expand Up @@ -401,7 +409,7 @@ private unsafe void UpdateRichPresence(Framework framework)
}
catch (Exception ex)
{
PluginLog.LogError(ex, "Could not run OnUpdate.");
PluginLog.Error(ex, "Could not run OnUpdate.");
}
}

Expand Down
Loading