Skip to content

Commit

Permalink
fixed message not showing on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisenhuth committed May 16, 2023
1 parent 09f7733 commit c71df36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions logchamp/logchamp/LogchampPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Threading.Tasks;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.IoC;
using Dalamud.Plugin;
using ImGuiNET;
Expand All @@ -21,6 +23,8 @@ public class LogchampPlugin : IDalamudPlugin
private Configuration.Timeframe configTimeframe;
[PluginService] private static DalamudPluginInterface PluginInterface { get; set; } = null!;
[PluginService] private static CommandManager CommandManager { get; set; } = null!;

private bool cleanedOnStartup;


public LogchampPlugin([RequiredVersion("1.0")] DalamudPluginInterface dalamudPluginInterface, [RequiredVersion("1.0")] ChatGui chatGui, [RequiredVersion("1.0")] CommandManager commandManager)
Expand All @@ -35,14 +39,23 @@ public LogchampPlugin([RequiredVersion("1.0")] DalamudPluginInterface dalamudPlu
dalamudPluginInterface.UiBuilder.Draw += DrawConfiguration;
dalamudPluginInterface.UiBuilder.OpenConfigUi += OpenConfig;

chatGui.ChatMessage += OnChatMessage;

commandManager.AddHandler(commandName, new CommandInfo(CleanupCommand)
{
HelpMessage = "opens the configuration",
ShowInHelp = true
});

Task.Run(() => DeleteLogs(configTimeframe));
}
private void OnChatMessage(XivChatType type, uint senderid, ref SeString sender, ref SeString message, ref bool ishandled)
{
if (type == XivChatType.Notice && !cleanedOnStartup)
{
Task.Run(() => DeleteLogs(configTimeframe));
cleanedOnStartup = true;
}
}

private void CleanupCommand(string command, string args)
{
OpenConfig();
Expand Down Expand Up @@ -85,7 +98,6 @@ private void DrawConfiguration()
return;

ImGui.Begin($"{Name} Configuration", ref drawConfiguration);

ImGui.Text("Delete logs after");
ImGui.SameLine();

Expand Down Expand Up @@ -152,6 +164,7 @@ public void Dispose()
{
PluginInterface.UiBuilder.Draw -= DrawConfiguration;
PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig;
chatGui.ChatMessage -= OnChatMessage;

CommandManager.RemoveHandler(commandName);
}
Expand Down
2 changes: 1 addition & 1 deletion logchamp/logchamp/logchamp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(AppData)\Eisenhuth\DalamudDevPlugins\LogchampPlugin\</OutputPath>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<AssemblyVersion>1.0.1.1</AssemblyVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<PackageProjectUrl>https://github.com/Eisenhuth/dalamud-logchamp</PackageProjectUrl>
Expand Down

0 comments on commit c71df36

Please sign in to comment.