OSDN Git Service

Fixes for Automatic startup
authormelchior <melchior@users.osdn.me>
Mon, 15 Aug 2022 00:44:02 +0000 (20:44 -0400)
committermelchior <melchior@users.osdn.me>
Mon, 15 Aug 2022 00:44:02 +0000 (20:44 -0400)
Automap/Subsystems/AutomapGUIDialog.cs
Automap/Subsystems/AutomapSystem.cs
Automap/modinfo.json

index d5a22a1..72471f0 100644 (file)
@@ -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;
-
-               }
 
        }
 }
index 249151c..2e35db3 100644 (file)
@@ -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;
-               }
+               }                       
        }
 
 }
index 2c95cb2..22f4de3 100644 (file)
@@ -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"