88 lines
3.3 KiB
C#
88 lines
3.3 KiB
C#
using System;
|
|
using MyClasses.MetaViewWrappers;
|
|
|
|
namespace MosswartMassacre
|
|
{
|
|
internal static class MainView
|
|
{
|
|
private static IView View;
|
|
private static IStaticText lblTotalKills;
|
|
private static IStaticText lblKillsPer5Min;
|
|
private static IStaticText lblKillsPerHour;
|
|
private static IStaticText lblElapsedTime;
|
|
private static IStaticText lblRareCount;
|
|
private static IButton btnRestart;
|
|
private static IButton btnToggleRareMeta;
|
|
private static bool rareMetaEnabled = true;
|
|
|
|
public static void ViewInit()
|
|
{
|
|
try
|
|
{
|
|
// Load the view from the embedded XML resource
|
|
View = MyClasses.MetaViewWrappers.ViewSystemSelector.CreateViewResource(
|
|
PluginCore.MyHost, "MosswartMassacre.ViewXML.mainView.xml");
|
|
|
|
// Get references to controls
|
|
lblTotalKills = (IStaticText)View["lblTotalKills"];
|
|
lblKillsPer5Min = (IStaticText)View["lblKillsPer5Min"];
|
|
lblKillsPerHour = (IStaticText)View["lblKillsPerHour"];
|
|
lblElapsedTime = (IStaticText)View["lblElapsedTime"];
|
|
lblRareCount = (IStaticText)View["lblRareCount"];
|
|
btnRestart = (IButton)View["btnRestart"];
|
|
btnRestart.Hit += OnRestartClick;
|
|
btnToggleRareMeta = (IButton)View["btnToggleRareMeta"];
|
|
btnToggleRareMeta.Hit += OnToggleRareMetaClick;
|
|
btnToggleRareMeta.Text = "Meta: ON";
|
|
|
|
PluginCore.WriteToChat("View initialized.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PluginCore.WriteToChat("Error initializing view: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
public static void ViewDestroy()
|
|
{
|
|
try
|
|
{
|
|
View.Dispose();
|
|
PluginCore.WriteToChat("View destroyed.");
|
|
btnRestart.Hit -= OnRestartClick;
|
|
btnToggleRareMeta.Hit -= OnToggleRareMetaClick;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PluginCore.WriteToChat("Error destroying view: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
public static void UpdateKillStats(int totalKills, double killsPer5Min, double killsPerHour)
|
|
{
|
|
lblTotalKills.Text = $"Total Kills: {totalKills}";
|
|
lblKillsPer5Min.Text = $"Kills per 5 Min: {killsPer5Min:F2}";
|
|
lblKillsPerHour.Text = $"Kills per Hour: {killsPerHour:F2}";
|
|
}
|
|
|
|
public static void UpdateElapsedTime(TimeSpan elapsed)
|
|
{
|
|
lblElapsedTime.Text = $"Elapsed Time: {elapsed:hh\\:mm\\:ss}";
|
|
}
|
|
public static void UpdateRareCount(int rareCount)
|
|
{
|
|
lblRareCount.Text = $"Rare Count: {rareCount}";
|
|
}
|
|
private static void OnRestartClick(object sender, EventArgs e)
|
|
{
|
|
PluginCore.RestartStats();
|
|
}
|
|
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}");
|
|
}
|
|
}
|
|
}
|