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
20 return _automapControlPanelKey;
24 public AutomapGUIDialog(ICoreClientAPI capi, AutomapSystem ams) : base(capi)
31 private void SetupDialog()
33 ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
35 ElementBounds textBounds = ElementBounds.Fixed(0, 40, 500, 300);
37 ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
38 bgBounds.BothSizing = ElementSizing.FitToChildren;
39 bgBounds.WithChildren(textBounds);
41 ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(3, 5, 5, 2);
42 toggleBounds.fixedHeight = 18;
43 toggleBounds.fixedWidth = 50;
45 ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 20, 2, 4);
46 txtStatusBounds.fixedHeight = 16;
47 txtStatusBounds.percentWidth = 1;
50 this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
51 .AddShadedDialogBG(bgBounds)
52 .AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
53 .AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText(), textBounds)
54 .AddToggleButton("Run", CairoFont.ButtonText(), RunToggle, toggleBounds, "btnRun")
55 .AddStaticText("Idle.", CairoFont.WhiteSmallText().WithFontSize(12), txtStatusBounds, "txtStatus")
59 private void OnTitleBarCloseClicked()
65 /// Toggle Automap from/to RUN state
67 /// <returns>The toggle.</returns>
68 /// <param name="t1">T1.</param>
69 internal void RunToggle(bool toggle)
71 _automapSystem.Enabled = toggle;
72 Logger.VerboseDebug("Dialog Changed; [ Automap Enabled: {0} ]", toggle);
73 var statusText = this.SingleComposer.GetStaticText("txtStatus");
74 statusText.SetValue($"Running: {this._automapSystem.Enabled}, Total: {this._automapSystem.updatedChunksTotal}, Nulls: {this._automapSystem.nullChunkCount} ");