OSDN Git Service

Pre-PR5 Configurable Designators, Autostart, fix for Entity processing
[automap/automap.git] / Automap / Subsystems / AutomapGUIDialog.cs
index 3fbdac1..9fedd85 100644 (file)
@@ -12,6 +12,8 @@ namespace Automap
                public const string _automapControlPanelKey = "automapControlPanelKey";
                private const string _statusTextKey = @"txtStatus";
                private const string _noteTextKey = @"edtNote";
+               private const string _swAutostart = @"swAutostart";
+               private const string _btnRunKey = @"btnRun";
 
                private ILogger Logger;
 
@@ -25,10 +27,10 @@ namespace Automap
                }
 
                private uint totalShards, voidShards, changesThisTick;
-               private RunState lastState;
+               private CommandType lastState;
 
 
-               public AutomapGUIDialog(ICoreClientAPI capi, AutomapSystem ams) : base(capi)
+               public AutomapGUIDialog(ICoreClientAPI capi, AutomapSystem ams, PersistedConfiguration cfg) : base(capi)
                {
 
                        Logger = capi.Logger;
@@ -37,6 +39,10 @@ namespace Automap
 
                }
 
+               public AutomapGUIDialog(ICoreClientAPI capi) : base(capi)
+               {
+               }
+
                //Event for GUI status display
 
                private void SetupDialog()
@@ -53,6 +59,10 @@ namespace Automap
                        toggleBounds.fixedHeight = 24;
                        toggleBounds.fixedWidth = 64;
 
+                       ElementBounds autostartBounds = toggleBounds.RightCopy(66, 0, 1, 1);
+                       autostartBounds.fixedHeight = 24;
+                       autostartBounds.fixedWidth = 80;
+
                        ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 26, 2, 4);
                        txtStatusBounds.fixedHeight = 16;
                        txtStatusBounds.percentWidth = 1;
@@ -70,19 +80,21 @@ namespace Automap
                                .AddShadedDialogBG(bgBounds)
                                .AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
                                .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText(), textBounds)
-                               .AddToggleButton("Run", CairoFont.ButtonText(), RunToggle, toggleBounds, "btnRun")
+                               .AddToggleButton("Run", CairoFont.ButtonText(), RunToggle, toggleBounds, _btnRunKey)
+                               .AddSwitch(AutostartChange,autostartBounds,_swAutostart)
+                               .AddStaticText("Autostart",CairoFont.WhiteDetailText(),autostartBounds.RightCopy(16))
                                .AddDynamicText("Idle.", CairoFont.WhiteSmallText().WithFontSize(12), EnumTextOrientation.Left, txtStatusBounds, _statusTextKey)
                                .AddTextInput(txtNoteArea, null, CairoFont.WhiteMediumText().WithFontSize(16), _noteTextKey)
                                .AddButton("Note:", CreateNote, btnNoteArea, CairoFont.ButtonText())
                                .Compose();
 
-                       //Controls for ALL Block & Entity Designators (Enable/Disable)
+                       //Controls for ALL Block & Entity Designators (Enable/Disable) <-- block edits while in 'Run' state
                        //_automapSystem.BlockID_Designators
                        //_automapSystem.Entity_Designators
                        //Renderer selection
                        //Message verbosity? Speed?
 
-                       //A Button to add POI - notes manually (when AM running)
+
 
                }
 
@@ -107,12 +119,12 @@ namespace Automap
                        if (toggle)
                        {
                                dashTickHandle = capi.Event.RegisterGameTickListener(UpdateDashDisplay, 6001);
-                               cmd = new CommandData(toggle ? RunState.Run : RunState.Stop, new bool[] { true, true, true, true, true });
+                               cmd = new CommandData(toggle ? CommandType.Run : CommandType.Stop);
                        }
                        else
                        {
                                capi.Event.UnregisterGameTickListener(dashTickHandle);
-                               cmd = new CommandData(toggle ? RunState.Run : RunState.Stop);
+                               cmd = new CommandData(toggle ? CommandType.Run : CommandType.Stop);
                        }
 
                        capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, cmd);
@@ -120,7 +132,7 @@ namespace Automap
 
                private bool CreateNote()
                {
-                       var noteCmd = new CommandData(RunState.Notation);
+                       var noteCmd = new CommandData(CommandType.Notation);
                        var txtNote = this.SingleComposer.GetTextInput(_noteTextKey);
                        if (!String.IsNullOrWhiteSpace(txtNote.GetText()))
                        {
@@ -129,7 +141,12 @@ namespace Automap
 
                                capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, noteCmd);
                        }
-                       return false;//???
+                       return true;//FINDOUT: What does this DO?
+               }
+
+               private void AutostartChange(bool startValue)
+               {
+                       
                }
 
                private void AutomapStatusMsg(string eventName, ref EnumHandling handling, IAttribute data)
@@ -140,6 +157,7 @@ namespace Automap
                        voidShards = realData.VoidChunks;
                        changesThisTick = realData.Delta;
                        lastState = realData.CurrentState;
+
                }
 
                private void UpdateDashDisplay(float delay)
@@ -147,7 +165,14 @@ namespace Automap
                        var statusText = this.SingleComposer.GetDynamicText(_statusTextKey);
                        statusText.SetNewText($"State: {lastState}, Total: {totalShards}, Delta: {changesThisTick} Nulls: {voidShards} ");
 
+                       var btnRun = this.SingleComposer.GetToggleButton(_btnRunKey);
 
+                       if (lastState == CommandType.Run) {
+                       btnRun.SetValue(true);
+                       }
+                       else if (lastState == CommandType.Stop) {
+                       btnRun.SetValue(false);
+                       }
                }