Remove unused features: HTTP server, old telemetry, !do/!dot chat commands
- Delete HttpCommandServer.cs (localhost:8085 HTTP listener) - Delete Telemetry.cs (old HTTP POST to mosswart.snakedesert.se/position/) - Remove !do/!dot allegiance chat regex matching from OnChatText - Remove RemoteCommandsEnabled, HttpServerEnabled, TelemetryEnabled settings - Remove corresponding UI checkboxes, /mm command handlers, and wiring - Keep: WebSocket command receive, ClientTelemetry.cs (used by WS streaming) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c53aa4b31b
commit
9e9a94f159
8 changed files with 6 additions and 452 deletions
|
|
@ -1,105 +0,0 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Decal.Adapter;
|
||||
|
||||
namespace MosswartMassacre
|
||||
{
|
||||
public static class HttpCommandServer
|
||||
{
|
||||
private static HttpListener listener;
|
||||
private static CancellationTokenSource cts;
|
||||
private static bool isRunning = false;
|
||||
|
||||
public static bool IsRunning => isRunning;
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
if (isRunning) return;
|
||||
|
||||
try
|
||||
{
|
||||
listener = new HttpListener();
|
||||
listener.Prefixes.Add("http://localhost:8085/");
|
||||
listener.Start();
|
||||
cts = new CancellationTokenSource();
|
||||
Task.Run(() => ListenLoop(cts.Token));
|
||||
|
||||
isRunning = true;
|
||||
PluginCore.WriteToChat("[HTTP] Server started on port 8085.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat("[HTTP] Error starting server: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
if (!isRunning) return;
|
||||
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
listener.Stop();
|
||||
listener.Close();
|
||||
listener = null;
|
||||
isRunning = false;
|
||||
PluginCore.WriteToChat("[HTTP] Server stopped.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat("[HTTP] Error stopping server: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task ListenLoop(CancellationToken token)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
HttpListenerContext context = null;
|
||||
|
||||
try
|
||||
{
|
||||
context = await listener.GetContextAsync();
|
||||
}
|
||||
catch (HttpListenerException)
|
||||
{
|
||||
break; // Listener was stopped
|
||||
}
|
||||
|
||||
if (context == null) continue;
|
||||
|
||||
string requestBody = new System.IO.StreamReader(context.Request.InputStream).ReadToEnd();
|
||||
|
||||
PluginCore.WriteToChat("[HTTP] Received request: " + requestBody);
|
||||
|
||||
// Parse simple format: target=Name&command=/say hello
|
||||
string target = "";
|
||||
string command = "";
|
||||
foreach (var pair in requestBody.Split('&'))
|
||||
{
|
||||
var parts = pair.Split('=');
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
if (parts[0] == "target") target = WebUtility.UrlDecode(parts[1]);
|
||||
else if (parts[0] == "command") command = WebUtility.UrlDecode(parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(target) && !string.IsNullOrWhiteSpace(command))
|
||||
{
|
||||
string tellCmd = $"/a {target} {command}";
|
||||
CoreManager.Current.Actions.InvokeChatParser(tellCmd);
|
||||
}
|
||||
|
||||
byte[] buffer = Encoding.UTF8.GetBytes("Command received.");
|
||||
context.Response.ContentLength64 = buffer.Length;
|
||||
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -313,12 +313,10 @@
|
|||
<Compile Include="QuestManager.cs" />
|
||||
<Compile Include="vTank.cs" />
|
||||
<Compile Include="VtankControl.cs" />
|
||||
<Compile Include="Telemetry.cs" />
|
||||
<Compile Include="Coordinates.cs" />
|
||||
<Compile Include="Geometry.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="PluginSettings.cs" />
|
||||
<Compile Include="HttpCommandServer.cs" />
|
||||
<Compile Include="DelayedCommandManager.cs" />
|
||||
<Compile Include="PluginCore.cs" />
|
||||
<Compile Include="QuestNames.cs" />
|
||||
|
|
|
|||
|
|
@ -111,10 +111,7 @@ namespace MosswartMassacre
|
|||
Views.VVSTabbedMainView.RefreshUpdateStatus();
|
||||
}
|
||||
}
|
||||
public static bool RemoteCommandsEnabled { get; set; } = false;
|
||||
public static bool HttpServerEnabled { get; set; } = false;
|
||||
public static string CharTag { get; set; } = "";
|
||||
public static bool TelemetryEnabled { get; set; } = false;
|
||||
public static bool WebSocketEnabled { get; set; } = false;
|
||||
public bool InventoryLogEnabled { get; set; } = false;
|
||||
public static bool AggressiveChatStreamingEnabled { get; set; } = true;
|
||||
|
|
@ -240,8 +237,6 @@ namespace MosswartMassacre
|
|||
try
|
||||
{
|
||||
PluginSettings.Save();
|
||||
if (TelemetryEnabled)
|
||||
Telemetry.Stop(); // ensure no dangling timer / HttpClient
|
||||
WriteToChat("Mosswart Massacre is shutting down. Bye!");
|
||||
|
||||
|
||||
|
|
@ -367,14 +362,9 @@ namespace MosswartMassacre
|
|||
// Apply the values
|
||||
RareMetaEnabled = PluginSettings.Instance.RareMetaEnabled;
|
||||
WebSocketEnabled = PluginSettings.Instance.WebSocketEnabled;
|
||||
RemoteCommandsEnabled = PluginSettings.Instance.RemoteCommandsEnabled;
|
||||
HttpServerEnabled = PluginSettings.Instance.HttpServerEnabled;
|
||||
TelemetryEnabled = PluginSettings.Instance.TelemetryEnabled;
|
||||
CharTag = PluginSettings.Instance.CharTag;
|
||||
ViewManager.SetRareMetaToggleState(RareMetaEnabled);
|
||||
ViewManager.RefreshSettingsFromConfig(); // Refresh all UI settings after loading
|
||||
if (TelemetryEnabled)
|
||||
Telemetry.Start();
|
||||
if (WebSocketEnabled)
|
||||
WebSocket.Start();
|
||||
|
||||
|
|
@ -575,9 +565,6 @@ namespace MosswartMassacre
|
|||
// 2. Apply the values from settings
|
||||
RareMetaEnabled = PluginSettings.Instance.RareMetaEnabled;
|
||||
WebSocketEnabled = PluginSettings.Instance.WebSocketEnabled;
|
||||
RemoteCommandsEnabled = PluginSettings.Instance.RemoteCommandsEnabled;
|
||||
HttpServerEnabled = PluginSettings.Instance.HttpServerEnabled;
|
||||
TelemetryEnabled = PluginSettings.Instance.TelemetryEnabled;
|
||||
CharTag = PluginSettings.Instance.CharTag;
|
||||
|
||||
// 3. Update UI with current settings
|
||||
|
|
@ -585,24 +572,12 @@ namespace MosswartMassacre
|
|||
ViewManager.RefreshSettingsFromConfig();
|
||||
|
||||
// 4. Restart services if they were enabled (stop first, then start)
|
||||
if (TelemetryEnabled)
|
||||
{
|
||||
Telemetry.Stop(); // Stop existing
|
||||
Telemetry.Start(); // Restart
|
||||
}
|
||||
|
||||
if (WebSocketEnabled)
|
||||
{
|
||||
WebSocket.Stop(); // Stop existing
|
||||
WebSocket.Stop(); // Stop existing
|
||||
WebSocket.Start(); // Restart
|
||||
}
|
||||
|
||||
if (HttpServerEnabled)
|
||||
{
|
||||
HttpCommandServer.Stop(); // Stop existing
|
||||
HttpCommandServer.Start(); // Restart
|
||||
}
|
||||
|
||||
// 5. Initialize Harmony patches (only if not already done)
|
||||
// Note: Harmony patches are global and don't need reinitialization
|
||||
if (!DecalHarmonyClean.IsActive())
|
||||
|
|
@ -1086,31 +1061,6 @@ namespace MosswartMassacre
|
|||
WriteToChat($"[Mosswart Massacre] Reporting to allegiance: {reportMessage}");
|
||||
MyHost.Actions.InvokeChatParser($"/a {reportMessage}");
|
||||
}
|
||||
if (RemoteCommandsEnabled && e.Color == 18)
|
||||
{
|
||||
string characterName = Regex.Escape(CoreManager.Current.CharacterFilter.Name);
|
||||
string pattern = $@"^\[Allegiance\].*Dunking Rares.*say[s]?, \""!do {characterName} (?<command>.+)\""$";
|
||||
string tag = Regex.Escape(PluginCore.CharTag);
|
||||
string patterntag = $@"^\[Allegiance\].*Dunking Rares.*say[s]?, \""!dot {tag} (?<command>.+)\""$";
|
||||
|
||||
|
||||
var match = Regex.Match(e.Text, pattern);
|
||||
var matchtag = Regex.Match(e.Text, patterntag);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
string command = match.Groups["command"].Value;
|
||||
DispatchChatToBoxWithPluginIntercept(command);
|
||||
DelayedCommandManager.AddDelayedCommand($"/a [Remote] Executing: {command}", 2000);
|
||||
}
|
||||
else if (matchtag.Success)
|
||||
{
|
||||
string command = matchtag.Groups["command"].Value;
|
||||
DispatchChatToBoxWithPluginIntercept(command);
|
||||
DelayedCommandManager.AddDelayedCommand($"/a [Remote] Executing: {command}", 2000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1416,33 +1366,6 @@ namespace MosswartMassacre
|
|||
|
||||
switch (subCommand)
|
||||
{
|
||||
case "telemetry":
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (args[1].Equals("enable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
TelemetryEnabled = true;
|
||||
Telemetry.Start();
|
||||
PluginSettings.Instance.TelemetryEnabled = true;
|
||||
WriteToChat("Telemetry streaming ENABLED.");
|
||||
}
|
||||
else if (args[1].Equals("disable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
TelemetryEnabled = false;
|
||||
Telemetry.Stop();
|
||||
PluginSettings.Instance.TelemetryEnabled = false;
|
||||
WriteToChat("Telemetry streaming DISABLED.");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm telemetry <enable|disable>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm telemetry <enable|disable>");
|
||||
}
|
||||
break;
|
||||
case "ws":
|
||||
if (args.Length > 1)
|
||||
{
|
||||
|
|
@ -1475,12 +1398,9 @@ namespace MosswartMassacre
|
|||
WriteToChat("Mosswart Massacre Commands:");
|
||||
WriteToChat("/mm report - Show current stats");
|
||||
WriteToChat("/mm loc - Show current location");
|
||||
WriteToChat("/mm telemetry - Telemetry streaming enable|disable");
|
||||
WriteToChat("/mm ws - Websocket streaming enable|disable");
|
||||
WriteToChat("/mm reset - Reset all counters");
|
||||
WriteToChat("/mm meta - Toggle rare meta state!!");
|
||||
WriteToChat("/mm http - Local http-command server enable|disable");
|
||||
WriteToChat("/mm remotecommand - Listen to allegiance !do/!dot enable|disable");
|
||||
WriteToChat("/mm getmetastate - Gets the current metastate");
|
||||
WriteToChat("/mm setchest <name> - Set chest name for looter");
|
||||
WriteToChat("/mm setkey <name> - Set key name for looter");
|
||||
|
|
@ -1526,58 +1446,6 @@ namespace MosswartMassacre
|
|||
WriteToChat($"Rare meta state is now {(RareMetaEnabled ? "ON" : "OFF")}");
|
||||
ViewManager.SetRareMetaToggleState(RareMetaEnabled); // <-- sync the UI
|
||||
break;
|
||||
case "http":
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (args[1].Equals("enable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
PluginSettings.Instance.HttpServerEnabled = true;
|
||||
HttpServerEnabled = true;
|
||||
HttpCommandServer.Start();
|
||||
}
|
||||
else if (args[1].Equals("disable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
PluginSettings.Instance.HttpServerEnabled = false;
|
||||
HttpServerEnabled = false;
|
||||
HttpCommandServer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm http <enable|disable>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm http <enable|disable>");
|
||||
}
|
||||
break;
|
||||
|
||||
case "remotecommands":
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (args[1].Equals("enable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
PluginSettings.Instance.RemoteCommandsEnabled = true;
|
||||
RemoteCommandsEnabled = true;
|
||||
WriteToChat("Remote command listening is now ENABLED.");
|
||||
}
|
||||
else if (args[1].Equals("disable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
PluginSettings.Instance.RemoteCommandsEnabled = false;
|
||||
RemoteCommandsEnabled = false;
|
||||
WriteToChat("Remote command listening is now DISABLED.");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Invalid remotecommands argument. Use 'enable' or 'disable'.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm remotecommands <enable|disable>");
|
||||
}
|
||||
break;
|
||||
|
||||
case "nextwp":
|
||||
double result = VtankControl.VtAdvanceWaypoint();
|
||||
if (result == 1)
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@ namespace MosswartMassacre
|
|||
private static readonly object _sync = new object();
|
||||
|
||||
// backing fields
|
||||
private bool _remoteCommandsEnabled = false;
|
||||
private bool _rareMetaEnabled = true;
|
||||
private bool _httpServerEnabled = false;
|
||||
private bool _telemetryEnabled = false;
|
||||
private bool _webSocketEnabled = false;
|
||||
private bool _inventorylog = true;
|
||||
private string _charTag = "default";
|
||||
|
|
@ -137,29 +134,12 @@ namespace MosswartMassacre
|
|||
}
|
||||
|
||||
// public properties
|
||||
public bool RemoteCommandsEnabled
|
||||
{
|
||||
get => _remoteCommandsEnabled;
|
||||
set { _remoteCommandsEnabled = value; Save(); }
|
||||
}
|
||||
|
||||
public bool RareMetaEnabled
|
||||
{
|
||||
get => _rareMetaEnabled;
|
||||
set { _rareMetaEnabled = value; Save(); }
|
||||
}
|
||||
|
||||
public bool HttpServerEnabled
|
||||
{
|
||||
get => _httpServerEnabled;
|
||||
set { _httpServerEnabled = value; Save(); }
|
||||
}
|
||||
|
||||
public bool TelemetryEnabled
|
||||
{
|
||||
get => _telemetryEnabled;
|
||||
set { _telemetryEnabled = value; Save(); }
|
||||
}
|
||||
public bool WebSocketEnabled
|
||||
{
|
||||
get => _webSocketEnabled;
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
// Telemetry.cs ───────────────────────────────────────────────────────────────
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Decal.Adapter;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MosswartMassacre
|
||||
{
|
||||
public static class Telemetry
|
||||
{
|
||||
/* ───────────── configuration ───────────── */
|
||||
private const string Endpoint = "https://mosswart.snakedesert.se/position/"; // <- trailing slash!
|
||||
private const string SharedSecret = "your_shared_secret"; // <- keep in sync
|
||||
private const int IntervalSec = 5; // seconds between posts
|
||||
|
||||
/* ───────────── runtime state ───────────── */
|
||||
private static readonly HttpClient _http = new HttpClient();
|
||||
private static string _sessionId;
|
||||
private static CancellationTokenSource _cts;
|
||||
private static bool _enabled;
|
||||
|
||||
/* ───────────── public API ───────────── */
|
||||
public static void Start()
|
||||
{
|
||||
if (_enabled) return;
|
||||
|
||||
_enabled = true;
|
||||
_sessionId = $"{CoreManager.Current.CharacterFilter.Name}-{DateTime.UtcNow:yyyyMMdd-HHmmss}";
|
||||
_cts = new CancellationTokenSource();
|
||||
|
||||
PluginCore.WriteToChat("[Telemetry] HTTP streaming ENABLED");
|
||||
|
||||
_ = Task.Run(() => LoopAsync(_cts.Token)); // fire-and-forget
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
if (!_enabled) return;
|
||||
_cts.Cancel();
|
||||
_enabled = false;
|
||||
PluginCore.WriteToChat("[Telemetry] HTTP streaming DISABLED");
|
||||
}
|
||||
|
||||
/* ───────────── async loop ───────────── */
|
||||
private static async Task LoopAsync(CancellationToken token)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
await SendSnapshotAsync(token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat($"[Telemetry] send failed: {ex.Message}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(IntervalSec), token);
|
||||
}
|
||||
catch (TaskCanceledException) { } // expected on Stop()
|
||||
}
|
||||
}
|
||||
|
||||
/* ───────────── single POST ───────────── */
|
||||
private static async Task SendSnapshotAsync(CancellationToken token)
|
||||
{
|
||||
var coords = Coordinates.Me;
|
||||
|
||||
var payload = new
|
||||
{
|
||||
character_name = CoreManager.Current.CharacterFilter.Name,
|
||||
char_tag = PluginCore.CharTag,
|
||||
session_id = _sessionId,
|
||||
timestamp = DateTime.UtcNow.ToString("o"),
|
||||
|
||||
ew = coords.EW,
|
||||
ns = coords.NS,
|
||||
z = coords.Z,
|
||||
|
||||
kills = PluginCore.totalKills,
|
||||
onlinetime = (DateTime.Now - PluginCore.statsStartTime).ToString(@"dd\.hh\:mm\:ss"),
|
||||
kills_per_hour = PluginCore.killsPerHour.ToString("F0"),
|
||||
deaths = PluginCore.sessionDeaths.ToString(),
|
||||
total_deaths = PluginCore.totalDeaths.ToString(),
|
||||
rares_found = PluginCore.rareCount,
|
||||
prismatic_taper_count = PluginCore.cachedPrismaticCount.ToString(),
|
||||
vt_state = VtankControl.VtGetMetaState(),
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(payload);
|
||||
var req = new HttpRequestMessage(HttpMethod.Post, Endpoint)
|
||||
{
|
||||
Content = new StringContent(json, Encoding.UTF8, "application/json")
|
||||
};
|
||||
req.Headers.Add("X-Plugin-Secret", SharedSecret);
|
||||
|
||||
using var resp = await _http.SendAsync(req, token);
|
||||
|
||||
if (!resp.IsSuccessStatusCode) // stay quiet on success
|
||||
{
|
||||
PluginCore.WriteToChat($"[Telemetry] server replied {resp.StatusCode}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,22 +31,13 @@
|
|||
|
||||
<!-- Meta state setting -->
|
||||
<control progid="DecalControls.Checkbox" name="chkRareMetaEnabled" left="20" top="35" width="300" height="20" text="Auto rare meta state" checked="true"/>
|
||||
|
||||
<!-- Remote commands setting -->
|
||||
<control progid="DecalControls.Checkbox" name="chkRemoteCommandsEnabled" left="20" top="60" width="300" height="20" text="Remote commands (!do/!dot)" checked="false"/>
|
||||
|
||||
<!-- HTTP server setting -->
|
||||
<control progid="DecalControls.Checkbox" name="chkHttpServerEnabled" left="20" top="85" width="300" height="20" text="HTTP server (port 8085)" checked="false"/>
|
||||
|
||||
|
||||
<!-- WebSocket setting -->
|
||||
<control progid="DecalControls.Checkbox" name="chkWebSocketEnabled" left="20" top="110" width="300" height="20" text="WebSocket streaming" checked="false"/>
|
||||
|
||||
<!-- Telemetry setting -->
|
||||
<control progid="DecalControls.Checkbox" name="chkTelemetryEnabled" left="20" top="135" width="300" height="20" text="Telemetry reporting" checked="false"/>
|
||||
|
||||
<control progid="DecalControls.Checkbox" name="chkWebSocketEnabled" left="20" top="60" width="300" height="20" text="WebSocket streaming" checked="false"/>
|
||||
|
||||
<!-- Character tag setting -->
|
||||
<control progid="DecalControls.StaticText" name="lblCharTag" left="20" top="165" width="100" height="16" text="Character Tag:"/>
|
||||
<control progid="DecalControls.Edit" name="txtCharTag" left="125" top="163" width="150" height="20" text="default"/>
|
||||
<control progid="DecalControls.StaticText" name="lblCharTag" left="20" top="90" width="100" height="16" text="Character Tag:"/>
|
||||
<control progid="DecalControls.Edit" name="txtCharTag" left="125" top="88" width="150" height="20" text="default"/>
|
||||
|
||||
<!-- VTank profiles path setting -->
|
||||
<control progid="DecalControls.StaticText" name="lblVTankPath" left="20" top="190" width="100" height="16" text="VTank Profiles:"/>
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@ namespace MosswartMassacre.Views
|
|||
|
||||
#region Settings Tab Controls
|
||||
private HudCheckBox chkRareMetaEnabled;
|
||||
private HudCheckBox chkRemoteCommandsEnabled;
|
||||
private HudCheckBox chkHttpServerEnabled;
|
||||
private HudCheckBox chkWebSocketEnabled;
|
||||
private HudCheckBox chkTelemetryEnabled;
|
||||
private HudTextBox txtCharTag;
|
||||
private HudTextBox txtVTankPath;
|
||||
#endregion
|
||||
|
|
@ -212,24 +209,15 @@ namespace MosswartMassacre.Views
|
|||
{
|
||||
// Settings tab controls
|
||||
chkRareMetaEnabled = GetControl<HudCheckBox>("chkRareMetaEnabled");
|
||||
chkRemoteCommandsEnabled = GetControl<HudCheckBox>("chkRemoteCommandsEnabled");
|
||||
chkHttpServerEnabled = GetControl<HudCheckBox>("chkHttpServerEnabled");
|
||||
chkWebSocketEnabled = GetControl<HudCheckBox>("chkWebSocketEnabled");
|
||||
chkTelemetryEnabled = GetControl<HudCheckBox>("chkTelemetryEnabled");
|
||||
txtCharTag = GetControl<HudTextBox>("txtCharTag");
|
||||
txtVTankPath = GetControl<HudTextBox>("txtVTankPath");
|
||||
|
||||
// Hook up settings events
|
||||
if (chkRareMetaEnabled != null)
|
||||
chkRareMetaEnabled.Change += OnRareMetaSettingChanged;
|
||||
if (chkRemoteCommandsEnabled != null)
|
||||
chkRemoteCommandsEnabled.Change += OnRemoteCommandsSettingChanged;
|
||||
if (chkHttpServerEnabled != null)
|
||||
chkHttpServerEnabled.Change += OnHttpServerSettingChanged;
|
||||
if (chkWebSocketEnabled != null)
|
||||
chkWebSocketEnabled.Change += OnWebSocketSettingChanged;
|
||||
if (chkTelemetryEnabled != null)
|
||||
chkTelemetryEnabled.Change += OnTelemetrySettingChanged;
|
||||
if (txtCharTag != null)
|
||||
txtCharTag.Change += OnCharTagChanged;
|
||||
if (txtVTankPath != null)
|
||||
|
|
@ -368,34 +356,6 @@ namespace MosswartMassacre.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void OnRemoteCommandsSettingChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginSettings.Instance.RemoteCommandsEnabled = chkRemoteCommandsEnabled.Checked;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat($"Error in remote commands setting change: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHttpServerSettingChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginSettings.Instance.HttpServerEnabled = chkHttpServerEnabled.Checked;
|
||||
if (chkHttpServerEnabled.Checked)
|
||||
HttpCommandServer.Start();
|
||||
else
|
||||
HttpCommandServer.Stop();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat($"Error in HTTP server setting change: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnWebSocketSettingChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
|
|
@ -420,22 +380,6 @@ namespace MosswartMassacre.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void OnTelemetrySettingChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginSettings.Instance.TelemetryEnabled = chkTelemetryEnabled.Checked;
|
||||
if (chkTelemetryEnabled.Checked)
|
||||
Telemetry.Start();
|
||||
else
|
||||
Telemetry.Stop();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat($"Error in telemetry setting change: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCharTagChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
|
|
@ -603,14 +547,8 @@ namespace MosswartMassacre.Views
|
|||
{
|
||||
if (chkRareMetaEnabled != null)
|
||||
chkRareMetaEnabled.Checked = PluginSettings.Instance.RareMetaEnabled;
|
||||
if (chkRemoteCommandsEnabled != null)
|
||||
chkRemoteCommandsEnabled.Checked = PluginSettings.Instance.RemoteCommandsEnabled;
|
||||
if (chkHttpServerEnabled != null)
|
||||
chkHttpServerEnabled.Checked = PluginSettings.Instance.HttpServerEnabled;
|
||||
if (chkWebSocketEnabled != null)
|
||||
chkWebSocketEnabled.Checked = PluginSettings.Instance.WebSocketEnabled;
|
||||
if (chkTelemetryEnabled != null)
|
||||
chkTelemetryEnabled.Checked = PluginSettings.Instance.TelemetryEnabled;
|
||||
if (txtCharTag != null)
|
||||
txtCharTag.Text = PluginSettings.Instance.CharTag ?? "default";
|
||||
if (txtVTankPath != null)
|
||||
|
|
@ -1252,14 +1190,8 @@ namespace MosswartMassacre.Views
|
|||
// Settings tab event cleanup
|
||||
if (chkRareMetaEnabled != null)
|
||||
chkRareMetaEnabled.Change -= OnRareMetaSettingChanged;
|
||||
if (chkRemoteCommandsEnabled != null)
|
||||
chkRemoteCommandsEnabled.Change -= OnRemoteCommandsSettingChanged;
|
||||
if (chkHttpServerEnabled != null)
|
||||
chkHttpServerEnabled.Change -= OnHttpServerSettingChanged;
|
||||
if (chkWebSocketEnabled != null)
|
||||
chkWebSocketEnabled.Change -= OnWebSocketSettingChanged;
|
||||
if (chkTelemetryEnabled != null)
|
||||
chkTelemetryEnabled.Change -= OnTelemetrySettingChanged;
|
||||
if (txtCharTag != null)
|
||||
txtCharTag.Change -= OnCharTagChanged;
|
||||
if (txtVTankPath != null)
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue