Fixed time reporting, added /mm
This commit is contained in:
parent
360a8365d2
commit
201cf96629
4 changed files with 109 additions and 34 deletions
|
|
@ -13,7 +13,6 @@ namespace MosswartMassacre
|
|||
private static IStaticText lblRareCount;
|
||||
private static IButton btnRestart;
|
||||
private static IButton btnToggleRareMeta;
|
||||
private static bool rareMetaEnabled = true;
|
||||
|
||||
public static void ViewInit()
|
||||
{
|
||||
|
|
@ -67,7 +66,15 @@ namespace MosswartMassacre
|
|||
|
||||
public static void UpdateElapsedTime(TimeSpan elapsed)
|
||||
{
|
||||
lblElapsedTime.Text = $"Elapsed Time: {elapsed:hh\\:mm\\:ss}";
|
||||
int days = elapsed.Days;
|
||||
int hours = elapsed.Hours;
|
||||
int minutes = elapsed.Minutes;
|
||||
int seconds = elapsed.Seconds;
|
||||
|
||||
if (days > 0)
|
||||
lblElapsedTime.Text = $"Time: {days}d {hours:D2}:{minutes:D2}:{seconds:D2}";
|
||||
else
|
||||
lblElapsedTime.Text = $"Time: {hours:D2}:{minutes:D2}:{seconds:D2}";
|
||||
}
|
||||
public static void UpdateRareCount(int rareCount)
|
||||
{
|
||||
|
|
@ -79,10 +86,11 @@ namespace MosswartMassacre
|
|||
}
|
||||
private static void OnToggleRareMetaClick(object sender, EventArgs e)
|
||||
{
|
||||
rareMetaEnabled = !rareMetaEnabled;
|
||||
btnToggleRareMeta.Text = rareMetaEnabled ? "Meta: ON" : "Meta: OFF";
|
||||
PluginCore.rareMetaEnabled = rareMetaEnabled; // Share toggle with PluginCore
|
||||
PluginCore.WriteToChat($"[Debug] rareMetaEnabled is now: {rareMetaEnabled}");
|
||||
PluginCore.ToggleRareMeta();
|
||||
}
|
||||
public static void SetRareMetaToggleState(bool enabled)
|
||||
{
|
||||
btnToggleRareMeta.Text = enabled ? "Meta: ON" : "Meta: OFF";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace MosswartMassacre
|
|||
internal static double killsPerHour = 0;
|
||||
internal static DateTime statsStartTime = DateTime.Now;
|
||||
internal static Timer updateTimer;
|
||||
internal static bool rareMetaEnabled = true;
|
||||
public static bool RareMetaEnabled { get; private set; } = true;
|
||||
private static Queue<string> rareMessageQueue = new Queue<string>();
|
||||
private static DateTime _lastSent = DateTime.MinValue;
|
||||
private static readonly Queue<string> _chatQueue = new Queue<string>();
|
||||
|
|
@ -33,6 +33,7 @@ namespace MosswartMassacre
|
|||
|
||||
// Subscribe to chat message event
|
||||
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
|
||||
CoreManager.Current.CommandLineText += OnChatCommand;
|
||||
|
||||
// Initialize the timer
|
||||
updateTimer = new Timer(1000); // Update every second
|
||||
|
|
@ -56,6 +57,7 @@ namespace MosswartMassacre
|
|||
|
||||
// Unsubscribe from chat message event
|
||||
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
|
||||
CoreManager.Current.CommandLineText -= OnChatCommand;
|
||||
|
||||
// Stop and dispose of the timer
|
||||
if (updateTimer != null)
|
||||
|
|
@ -94,36 +96,36 @@ namespace MosswartMassacre
|
|||
rareCount++;
|
||||
MainView.UpdateRareCount(rareCount);
|
||||
|
||||
if (rareMetaEnabled)
|
||||
if (RareMetaEnabled)
|
||||
{
|
||||
Decal_DispatchOnChatCommand("/vt setmetastate loot_rare");
|
||||
}
|
||||
|
||||
DelayedCommandManager.AddDelayedCommand($"/a {rareText}", 3000);
|
||||
}
|
||||
if (e.Text.EndsWith("!testrare\""))
|
||||
{
|
||||
string simulatedText = $"{CoreManager.Current.CharacterFilter.Name} has discovered the Ancient Pickle!";
|
||||
|
||||
if (IsRareDiscoveryMessage(simulatedText, out string simulatedRareText))
|
||||
{
|
||||
rareCount++;
|
||||
MainView.UpdateRareCount(rareCount);
|
||||
|
||||
if (rareMetaEnabled)
|
||||
{
|
||||
Decal_DispatchOnChatCommand("/vt setmetastate loot_rare");
|
||||
}
|
||||
|
||||
DelayedCommandManager.AddDelayedCommand($"/a {simulatedRareText}", 3000);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("[Test] Simulated rare message didn't match the regex.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// if (e.Text.EndsWith("!testrare\""))
|
||||
// {
|
||||
// string simulatedText = $"{CoreManager.Current.CharacterFilter.Name} has discovered the Ancient Pickle!";
|
||||
//
|
||||
// if (IsRareDiscoveryMessage(simulatedText, out string simulatedRareText))
|
||||
// {
|
||||
// rareCount++;
|
||||
// MainView.UpdateRareCount(rareCount);
|
||||
//
|
||||
// if (RareMetaEnabled)
|
||||
// {
|
||||
// Decal_DispatchOnChatCommand("/vt setmetastate loot_rare");
|
||||
// }
|
||||
//
|
||||
// DelayedCommandManager.AddDelayedCommand($"/a {simulatedRareText}", 3000);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// WriteToChat("[Test] Simulated rare message didn't match the regex.");
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
if (e.Color == 18 && e.Text.EndsWith("!report\""))
|
||||
{
|
||||
TimeSpan elapsed = DateTime.Now - statsStartTime;
|
||||
|
|
@ -137,6 +139,21 @@ namespace MosswartMassacre
|
|||
WriteToChat("Error processing chat message: " + ex.Message);
|
||||
}
|
||||
}
|
||||
private void OnChatCommand(object sender, ChatParserInterceptEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Text.StartsWith("/mm", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
e.Eat = true; // Prevent the message from showing in chat
|
||||
HandleMmCommand(e.Text);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat($"[Error] Failed to process /mm command: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStats(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
|
|
@ -249,6 +266,12 @@ namespace MosswartMassacre
|
|||
MainView.UpdateKillStats(totalKills, killsPer5Min, killsPerHour);
|
||||
MainView.UpdateRareCount(rareCount);
|
||||
}
|
||||
public static void ToggleRareMeta()
|
||||
{
|
||||
RareMetaEnabled = !RareMetaEnabled;
|
||||
MainView.SetRareMetaToggleState(RareMetaEnabled);
|
||||
}
|
||||
|
||||
[DllImport("Decal.dll")]
|
||||
private static extern int DispatchOnChatCommand(ref IntPtr str, [MarshalAs(UnmanagedType.U4)] int target);
|
||||
|
||||
|
|
@ -271,6 +294,50 @@ namespace MosswartMassacre
|
|||
if (!Decal_DispatchOnChatCommand(cmd))
|
||||
CoreManager.Current.Actions.InvokeChatParser(cmd);
|
||||
}
|
||||
private void HandleMmCommand(string text)
|
||||
{
|
||||
// Remove the /mm prefix and trim extra whitespace
|
||||
string[] args = text.Substring(3).Trim().Split(' ');
|
||||
|
||||
if (args.Length == 0 || string.IsNullOrEmpty(args[0]))
|
||||
{
|
||||
WriteToChat("Usage: /mm <command>. Try /mm help");
|
||||
return;
|
||||
}
|
||||
|
||||
string subCommand = args[0].ToLower();
|
||||
|
||||
switch (subCommand)
|
||||
{
|
||||
case "help":
|
||||
WriteToChat("Mosswart Massacre Commands:");
|
||||
WriteToChat("/mm report - Show current stats");
|
||||
WriteToChat("/mm reset - Reset all counters");
|
||||
WriteToChat("/mm meta - Toggle rare meta state");
|
||||
break;
|
||||
|
||||
case "report":
|
||||
TimeSpan elapsed = DateTime.Now - statsStartTime;
|
||||
string reportMessage = $"Total Kills: {totalKills}, Kills per Hour: {killsPerHour:F2}, Elapsed Time: {elapsed:dd\\.hh\\:mm\\:ss}, Rares Found: {rareCount}";
|
||||
WriteToChat(reportMessage);
|
||||
break;
|
||||
|
||||
case "reset":
|
||||
RestartStats();
|
||||
break;
|
||||
|
||||
case "meta":
|
||||
RareMetaEnabled = !RareMetaEnabled;
|
||||
WriteToChat($"Rare meta state is now {(RareMetaEnabled ? "ON" : "OFF")}");
|
||||
MainView.SetRareMetaToggleState(RareMetaEnabled); // <-- sync the UI
|
||||
break;
|
||||
|
||||
default:
|
||||
WriteToChat($"Unknown /mm command: {subCommand}. Try /mm help");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,5 @@ using System.Runtime.InteropServices;
|
|||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<control progid="DecalControls.StaticText" name="lblTotalKills" left="10" top="10" width="250" height="20" text="Total Kills: 0"/>
|
||||
<control progid="DecalControls.StaticText" name="lblKillsPer5Min" left="10" top="30" width="250" height="20" text="Kills per 5 Min: 0"/>
|
||||
<control progid="DecalControls.StaticText" name="lblKillsPerHour" left="10" top="50" width="250" height="20" text="Kills per Hour: 0"/>
|
||||
<control progid="DecalControls.StaticText" name="lblElapsedTime" left="10" top="70" width="250" height="20" text="Elapsed Time: 00:00:00"/>
|
||||
<control progid="DecalControls.StaticText" name="lblElapsedTime" left="10" top="70" width="250" height="20" text="Time: 00:00:00"/>
|
||||
<control progid="DecalControls.StaticText" name="lblRareCount" left="10" top="90" width="250" height="20" text="Rare Count: 0"/>
|
||||
<control progid="DecalControls.PushButton" name="btnRestart" left="10" top="110" width="60" height="20" text="Restart"/>
|
||||
<control progid="DecalControls.PushButton" name="btnToggleRareMeta" left="10" top="135" width="60" height="20" text="Meta Rare: ON"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue