4 using Vintagestory.API.Client;
5 using Vintagestory.API.Common;
9 public class AutomapGUIDialog : GuiDialog
11 public const string _automapControlPanelKey = "automapControlPanelKey";
13 private ILogger Logger;
14 private AutomapSystem _automapSystem;
16 public override string ToggleKeyCombinationCode {
19 return _automapControlPanelKey;
23 public AutomapGUIDialog(ICoreClientAPI capi,AutomapSystem ams) : base(capi)
30 private void SetupDialog( )
32 ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
34 ElementBounds textBounds = ElementBounds.Fixed(0, 40, 500, 300);
36 ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
37 bgBounds.BothSizing = ElementSizing.FitToChildren;
38 bgBounds.WithChildren(textBounds);
40 ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(3, 5, 5, 2);
41 toggleBounds.fixedHeight = 18;
42 toggleBounds.fixedWidth = 50;
44 ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 20, 2, 4);
45 txtStatusBounds.fixedHeight = 16;
46 txtStatusBounds.percentWidth = 1;
49 this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
50 .AddShadedDialogBG(bgBounds)
51 .AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
52 .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText( ), textBounds)
53 .AddToggleButton("Run", CairoFont.ButtonText( ), RunToggle, toggleBounds, "btnRun")
54 .AddStaticText("Idle.", CairoFont.WhiteSmallText( ).WithFontSize(12), txtStatusBounds, "txtStatus")
58 private void OnTitleBarCloseClicked( )
64 /// Toggle Automap from/to RUN state
66 /// <returns>The toggle.</returns>
67 /// <param name="t1">T1.</param>
68 internal void RunToggle(bool toggle)
70 _automapSystem.Enabled = toggle;
71 Logger.VerboseDebug("Dialog Changed; [ Automap Enabled: {0} ]", toggle);
72 var statusText = this.SingleComposer.GetStaticText("txtStatus");
73 statusText.SetValue($"Running: {this._automapSystem.Enabled}, Total: {this._automapSystem.updatedChunksTotal}, Nulls: {this._automapSystem.nullChunkCount} " );