From 71f44a94cf2ad64387400c832e52fb8ba0d838a7 Mon Sep 17 00:00:00 2001 From: melchior Date: Sun, 14 Aug 2022 20:44:02 -0400 Subject: [PATCH] Fixes for Automatic startup --- Automap/Subsystems/AutomapGUIDialog.cs | 22 +++++++--------------- Automap/Subsystems/AutomapSystem.cs | 14 +++++--------- Automap/modinfo.json | 2 +- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/Automap/Subsystems/AutomapGUIDialog.cs b/Automap/Subsystems/AutomapGUIDialog.cs index d5a22a1..72471f0 100644 --- a/Automap/Subsystems/AutomapGUIDialog.cs +++ b/Automap/Subsystems/AutomapGUIDialog.cs @@ -14,6 +14,7 @@ namespace Automap private const string _noteTextKey = @"edtNote"; private const string _swAutostart = @"swAutostart"; private const string _btnRunKey = @"btnRun"; + private const string _btnSnapKey = @"btnSnap"; private ILogger Logger; private PersistedConfiguration configuration; @@ -32,11 +33,10 @@ namespace Automap public AutomapGUIDialog(ICoreClientAPI capi, AutomapSystem ams, PersistedConfiguration cfg) : base(capi) { - + configuration = cfg; Logger = capi.Logger; SetupDialog(); capi.Event.RegisterEventBusListener(AutomapStatusMsg, 1.0D, AutomapSystem.AutomapStatusEventKey); - configuration = cfg; } public AutomapGUIDialog(ICoreClientAPI capi) : base(capi) @@ -90,7 +90,7 @@ namespace Automap .AddDynamicText("Idle.", CairoFont.WhiteSmallText().WithFontSize(12), EnumTextOrientation.Left, txtStatusBounds, _statusTextKey) .AddTextInput(txtNoteArea, null, CairoFont.WhiteMediumText().WithFontSize(16), _noteTextKey) .AddButton("Note:", CreateNote, btnNoteArea, CairoFont.ButtonText()) - .AddButton("Snapshot!", TriggerSnapshot, btnSnapshotArea, CairoFont.ButtonText( )) + .AddButton("Snapshot!", TriggerSnapshot, btnSnapshotArea, CairoFont.ButtonText( ), key: _btnSnapKey) .Compose(); //Controls for ALL Block & Entity Designators (Enable/Disable) <-- block edits while in 'Run' state @@ -98,8 +98,8 @@ namespace Automap //_automapSystem.Entity_Designators //Renderer selection //Message verbosity? Speed? - - + var swAutostart = this.SingleComposer.GetSwitch(_swAutostart); + swAutostart.On = this.configuration.Autostart; } @@ -186,25 +186,17 @@ namespace Automap statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Delta: ±{changesThisTick} Nulls: {voidShards} "); if (!btnRun.On) btnRun.SetValue(true); - - LockGUIElements(true); + } else if (lastState == CommandType.Stop && btnRun.Enabled) { statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Nulls: {voidShards} "); if (btnRun.On) btnRun.SetValue(false); - - LockGUIElements(true); + } } - private void LockGUIElements(bool state) - { - var swAutostart = this.SingleComposer.GetSwitch(_swAutostart); - swAutostart.Enabled = state; - - } } } diff --git a/Automap/Subsystems/AutomapSystem.cs b/Automap/Subsystems/AutomapSystem.cs index 249151c..2e35db3 100644 --- a/Automap/Subsystems/AutomapSystem.cs +++ b/Automap/Subsystems/AutomapSystem.cs @@ -81,14 +81,6 @@ namespace Automap //Listen on bus for commands ClientAPI.Event.RegisterEventBusListener(CommandListener, 1.0, AutomapSystem.AutomapCommandEventKey); - - - if (configuration.Autostart) - { - CurrentState = CommandType.Run; - Logger.Notification("Autostart is Enabled."); - } - } @@ -124,6 +116,10 @@ namespace Automap }; ClientAPI.Event.RegisterGameTickListener(ThreadDecider, 6000); + + if (configuration.Autostart) { + CurrentState = CommandType.Run; + } } private void ChunkAChanging(Vec3i chunkCoord, IWorldChunk chunk, EnumChunkDirtyReason reason) @@ -886,7 +882,7 @@ namespace Automap } return null; - } + } } } diff --git a/Automap/modinfo.json b/Automap/modinfo.json index 2c95cb2..22f4de3 100644 --- a/Automap/modinfo.json +++ b/Automap/modinfo.json @@ -4,7 +4,7 @@ "description" : "Automap; Generates a static HTML5 map dynamically, with P.O.I. Tracking & more.", "authors": ["Melchior","VeryGoodDog"], "contributors":["VeryGoodDog", "Drakker"], - "version": "0.1.8", + "version": "0.1.8-pre.1", "side":"Client", "dependencies": { "game": "1.16.5" -- 2.11.0