OSDN Git Service

Added Notation feature
authormelchior <melchior@users.osdn.me>
Sun, 16 Feb 2020 23:10:22 +0000 (18:10 -0500)
committermelchior <melchior@users.osdn.me>
Sun, 16 Feb 2020 23:10:22 +0000 (18:10 -0500)
Automap/Data/CommandData.cs
Automap/Data/RunState.cs
Automap/Subsystems/AutomapGUIDialog.cs
Automap/Subsystems/AutomapSystem.cs

index c87c358..88ebe3a 100644 (file)
@@ -21,6 +21,9 @@ namespace Automap
                [ProtoMember(2)]
                private List<DelegateState> DelegatesFlags;
 
+               [ProtoMember(3)]
+               public string Notation { get; set; }
+
                //POI Delegate list {enabled/Disable}, color?
                //Other params...? Tick rate?
                //Choose : Renderer(s)
index 55311b3..f37b28d 100644 (file)
@@ -1,11 +1,15 @@
 using System;
 namespace Automap
 {
+       /// <summary>
+       /// Command Type
+       /// </summary>
        public enum RunState : byte
        {
                Stop = 0x00,
                Run = 0x01,
                Snapshot = 0x02,
+               Notation = 0x03,
        }
 }
 
index 898c6a0..ad8d8b3 100644 (file)
@@ -11,6 +11,7 @@ namespace Automap
        {
                public const string _automapControlPanelKey = "automapControlPanelKey";
                private const string _statusTextKey = @"txtStatus";
+               private const string _noteTextKey = @"edtNote";
 
                private ILogger Logger;
 
@@ -48,7 +49,7 @@ namespace Automap
                bgBounds.BothSizing = ElementSizing.FitToChildren;
                bgBounds.WithChildren(textBounds);
 
-               ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(3, 64, 5, 2);
+               ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(0, 72, 5, 2);
                toggleBounds.fixedHeight = 24;
                toggleBounds.fixedWidth = 64;
 
@@ -56,6 +57,14 @@ namespace Automap
                txtStatusBounds.fixedHeight = 16;
                txtStatusBounds.percentWidth = 1;
 
+               ElementBounds txtNoteArea = textBounds.CopyOffsetedSibling(20, 42, 1, 6);
+               txtNoteArea.fixedHeight = 24;
+               txtNoteArea.percentWidth = 25;
+               
+               ElementBounds btnNoteArea = textBounds.CopyOffsetedSibling(0, 42, 2, 5);
+               btnNoteArea.fixedHeight = 24;
+               btnNoteArea.fixedWidth = 20;
+
 
                this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
                        .AddShadedDialogBG(bgBounds)
@@ -63,6 +72,8 @@ namespace Automap
                        .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText( ), textBounds)
                        .AddToggleButton("Run", CairoFont.ButtonText( ), RunToggle, toggleBounds, "btnRun")
                        .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)
@@ -105,6 +116,18 @@ namespace Automap
                capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, cmd);
                }
 
+               private bool CreateNote( )
+               {
+               var noteCmd = new CommandData(RunState.Notation);
+               var txtNote = this.SingleComposer.GetTextInput(_noteTextKey);
+               if (!String.IsNullOrWhiteSpace(txtNote.GetText( ))) {
+               noteCmd.Notation = txtNote.GetText( );
+               txtNote.SetValue(string.Empty);
+
+               capi.Event.PushEvent(AutomapSystem.AutomapCommandEventKey, noteCmd);
+               }
+               return true;//???
+               }
 
                private void AutomapStatusMsg(string eventName, ref EnumHandling handling, IAttribute data)
                {
index 6f022a2..b4656be 100644 (file)
@@ -495,11 +495,14 @@ namespace Automap
                                jsonWriter.Write("NonAirBlocks : {0},", shard.NonAirBlocks);
                                //TODO: Heightmap
                                //TODO: Rock-ratio
-                               jsonWriter.Write("}],");
-                               //TODO: POIs
+                               jsonWriter.Write("}],");                                
                                }
                        jsonWriter.Write("]);\n\n");
-                       jsonWriter.Flush( );
+
+               //TODO: POIs
+
+
+               jsonWriter.Flush( );
                }
 
                }
@@ -692,6 +695,18 @@ namespace Automap
 
                }
 
+               private void AddNote(string notation)
+               {                       
+               var playerNodePoi = new PointOfInterest( ) {
+                       Location = ClientAPI.World.Player.Entity.LocalPos.AsBlockPos.Copy(),
+                       Notes = notation,
+                       Timestamp = DateTimeOffset.UtcNow,
+               };
+
+               this.POIs.AddReplace(playerNodePoi);
+               }
+
+
 
                private void CommandListener(string eventName, ref EnumHandling handling, IAttribute data)
                {
@@ -716,6 +731,11 @@ namespace Automap
                        //Snapshot starts a second thread/process...
 
                        break;
+
+               case RunState.Notation:
+                       //Add to POI list where player location
+                                       AddNote(cmdData.Notation);
+                       break;
                }
 
                }
@@ -723,12 +743,12 @@ namespace Automap
                if (CurrentState != cmdData.State) {
                CurrentState = cmdData.State;           
                AwakenCartographer(0.0f);
+               }
 
                #if DEBUG
                ClientAPI.TriggerChatMessage($"Automap commanded to: {cmdData.State} ");
                #endif
-               }
-               
+
                }