From 0d9636c8bee5022b9b3e21b80636c85f12b8b0fe Mon Sep 17 00:00:00 2001 From: melchior Date: Sun, 16 Feb 2020 18:10:22 -0500 Subject: [PATCH] Added Notation feature --- Automap/Data/CommandData.cs | 3 +++ Automap/Data/RunState.cs | 4 ++++ Automap/Subsystems/AutomapGUIDialog.cs | 25 ++++++++++++++++++++++++- Automap/Subsystems/AutomapSystem.cs | 30 +++++++++++++++++++++++++----- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Automap/Data/CommandData.cs b/Automap/Data/CommandData.cs index c87c358..88ebe3a 100644 --- a/Automap/Data/CommandData.cs +++ b/Automap/Data/CommandData.cs @@ -21,6 +21,9 @@ namespace Automap [ProtoMember(2)] private List DelegatesFlags; + [ProtoMember(3)] + public string Notation { get; set; } + //POI Delegate list {enabled/Disable}, color? //Other params...? Tick rate? //Choose : Renderer(s) diff --git a/Automap/Data/RunState.cs b/Automap/Data/RunState.cs index 55311b3..f37b28d 100644 --- a/Automap/Data/RunState.cs +++ b/Automap/Data/RunState.cs @@ -1,11 +1,15 @@ using System; namespace Automap { + /// + /// Command Type + /// public enum RunState : byte { Stop = 0x00, Run = 0x01, Snapshot = 0x02, + Notation = 0x03, } } diff --git a/Automap/Subsystems/AutomapGUIDialog.cs b/Automap/Subsystems/AutomapGUIDialog.cs index 898c6a0..ad8d8b3 100644 --- a/Automap/Subsystems/AutomapGUIDialog.cs +++ b/Automap/Subsystems/AutomapGUIDialog.cs @@ -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) { diff --git a/Automap/Subsystems/AutomapSystem.cs b/Automap/Subsystems/AutomapSystem.cs index 6f022a2..b4656be 100644 --- a/Automap/Subsystems/AutomapSystem.cs +++ b/Automap/Subsystems/AutomapSystem.cs @@ -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 - } - + } -- 2.11.0