OSDN Git Service

W.I.P. IV: More reliable entity / block scanning (full depth chunk scan), rock stats...
[automap/automap.git] / Automap / Subsystems / AutomapGUIDialog.cs
1 using System;
2
3
4 using Vintagestory.API.Client;
5 using Vintagestory.API.Common;
6
7 namespace Automap
8 {
9         public class AutomapGUIDialog : GuiDialog
10         {
11                 public const string _automapControlPanelKey = "automapControlPanelKey";
12
13                 private ILogger Logger;
14                 private AutomapSystem _automapSystem;
15
16                 public override string ToggleKeyCombinationCode {
17                         get
18                         {
19                                 return _automapControlPanelKey;
20                         }
21                 }
22
23                 public AutomapGUIDialog(ICoreClientAPI capi,AutomapSystem ams) : base(capi)
24         {
25                 _automapSystem = ams;
26                 Logger = capi.Logger;
27                 SetupDialog( );
28                 }
29
30                 //Event for GUI status display
31
32                 private void SetupDialog( )
33                 {
34                 ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
35                                         
36                 ElementBounds textBounds = ElementBounds.Fixed(0, 40, 500, 300);
37                 
38                 ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
39                 bgBounds.BothSizing = ElementSizing.FitToChildren;
40                 bgBounds.WithChildren(textBounds);
41
42                 ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(3, 26, 5, 2);
43                 toggleBounds.fixedHeight = 24;
44                 toggleBounds.fixedWidth = 64;
45
46                 ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 20, 2, 4);
47                 txtStatusBounds.fixedHeight = 16;
48                 txtStatusBounds.percentWidth = 1;
49
50
51                 this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
52                         .AddShadedDialogBG(bgBounds)
53                         .AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
54                         .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText( ), textBounds)
55                         .AddToggleButton("Run", CairoFont.ButtonText( ), RunToggle, toggleBounds, "btnRun")
56                         .AddStaticText("Idle.", CairoFont.WhiteSmallText( ).WithFontSize(12), txtStatusBounds, "txtStatus")
57                         .Compose( );
58
59                         //Controls for ALL Block & Entity Designators (Enable/Disable)
60                         //_automapSystem.BlockID_Designators
61                         //_automapSystem.Entity_Designators
62                         //Renderer selection
63                         //Message verbosity? Speed?
64
65                         //A Button to add POI - notes manually (when AM running)
66
67                 }
68
69                 private void OnTitleBarCloseClicked( )
70                 {
71                 TryClose( );
72                 }
73
74                 /// <summary>
75                 /// Toggle Automap from/to RUN state
76                 /// </summary>
77                 /// <returns>The toggle.</returns>
78                 /// <param name="t1">T1.</param>
79                 internal void RunToggle(bool toggle)
80                 {
81                 _automapSystem.Enabled = toggle;
82                 Logger.VerboseDebug("Dialog Changed; [ Automap Enabled: {0} ]", toggle);
83                 var statusText = this.SingleComposer.GetStaticText("txtStatus");
84                 statusText.SetValue($"Running: {this._automapSystem.Enabled}, Total: {this._automapSystem.updatedChunksTotal}, Nulls: {this._automapSystem.nullChunkCount} " );
85
86                 }
87         }
88 }
89