Fix hot reload: restore window position and add character stats timer
InitializeForHotReload was missing window position restore (settings loaded after ViewInit, but position never re-applied) and character stats streaming timer (10-min interval + initial send). Added VVSTabbedMainView.RestorePosition() static wrapper and wired it into the hot reload path after settings load. Added character stats timer initialization as step 10. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
361c2012da
commit
1ffa163501
3 changed files with 41 additions and 1 deletions
|
|
@ -112,6 +112,11 @@ namespace MosswartMassacre
|
||||||
Views.VVSTabbedMainView.RefreshSettingsFromConfig();
|
Views.VVSTabbedMainView.RefreshSettingsFromConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RestoreWindowPosition()
|
||||||
|
{
|
||||||
|
Views.VVSTabbedMainView.RestorePosition();
|
||||||
|
}
|
||||||
|
|
||||||
public static void RefreshUpdateStatus()
|
public static void RefreshUpdateStatus()
|
||||||
{
|
{
|
||||||
Views.VVSTabbedMainView.RefreshUpdateStatus();
|
Views.VVSTabbedMainView.RefreshUpdateStatus();
|
||||||
|
|
@ -503,9 +508,10 @@ namespace MosswartMassacre
|
||||||
WebSocketEnabled = PluginSettings.Instance.WebSocketEnabled;
|
WebSocketEnabled = PluginSettings.Instance.WebSocketEnabled;
|
||||||
CharTag = PluginSettings.Instance.CharTag;
|
CharTag = PluginSettings.Instance.CharTag;
|
||||||
|
|
||||||
// 3. Update UI with current settings
|
// 3. Update UI with current settings and restore window position
|
||||||
ViewManager.SetRareMetaToggleState(RareMetaEnabled);
|
ViewManager.SetRareMetaToggleState(RareMetaEnabled);
|
||||||
ViewManager.RefreshSettingsFromConfig();
|
ViewManager.RefreshSettingsFromConfig();
|
||||||
|
ViewManager.RestoreWindowPosition();
|
||||||
|
|
||||||
// 4. Restart services if they were enabled (stop first, then start)
|
// 4. Restart services if they were enabled (stop first, then start)
|
||||||
if (WebSocketEnabled)
|
if (WebSocketEnabled)
|
||||||
|
|
@ -574,6 +580,34 @@ namespace MosswartMassacre
|
||||||
WriteToChat($"[ERROR] Quest streaming service hot reload failed: {ex.Message}");
|
WriteToChat($"[ERROR] Quest streaming service hot reload failed: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 10. Reinitialize character stats streaming
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (characterStatsTimer == null)
|
||||||
|
{
|
||||||
|
characterStatsTimer = new Timer(Constants.CharacterStatsIntervalMs);
|
||||||
|
characterStatsTimer.Elapsed += OnCharacterStatsUpdate;
|
||||||
|
characterStatsTimer.AutoReset = true;
|
||||||
|
characterStatsTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send initial stats after short delay
|
||||||
|
var initialDelay = new Timer(Constants.LoginDelayMs);
|
||||||
|
initialDelay.AutoReset = false;
|
||||||
|
initialDelay.Elapsed += (s, args) =>
|
||||||
|
{
|
||||||
|
CharacterStats.CollectAndSend();
|
||||||
|
((Timer)s).Dispose();
|
||||||
|
};
|
||||||
|
initialDelay.Start();
|
||||||
|
|
||||||
|
WriteToChat("[OK] Character stats streaming initialized");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
WriteToChat($"[ERROR] Character stats hot reload failed: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
WriteToChat("Hot reload initialization completed!");
|
WriteToChat("Hot reload initialization completed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1047,6 +1047,12 @@ namespace MosswartMassacre.Views
|
||||||
PluginCore.WriteToChat($"Error refreshing settings from config: {ex.Message}");
|
PluginCore.WriteToChat($"Error refreshing settings from config: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RestorePosition()
|
||||||
|
{
|
||||||
|
instance?.RestoreWindowPosition();
|
||||||
|
instance?.KeepWindowInBounds();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Status Update Methods
|
#region Status Update Methods
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue