using System;
using Vintagestory.API.Client;
using Vintagestory.API.Common;
namespace Automap
{
public class AutomapGUIDialog : GuiDialog
{
public const string _automapControlPanelKey = "automapControlPanelKey";
private ILogger Logger;
private AutomapSystem _automapSystem;
public override string ToggleKeyCombinationCode {
get
{
return _automapControlPanelKey;
}
}
public AutomapGUIDialog(ICoreClientAPI capi,AutomapSystem ams) : base(capi)
{
_automapSystem = ams;
Logger = capi.Logger;
SetupDialog( );
}
//Event for GUI status display
private void SetupDialog( )
{
ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
ElementBounds textBounds = ElementBounds.Fixed(0, 40, 500, 300);
ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
bgBounds.BothSizing = ElementSizing.FitToChildren;
bgBounds.WithChildren(textBounds);
ElementBounds toggleBounds = textBounds.CopyOffsetedSibling(3, 26, 5, 2);
toggleBounds.fixedHeight = 24;
toggleBounds.fixedWidth = 64;
ElementBounds txtStatusBounds = textBounds.CopyOffsetedSibling(0, 20, 2, 4);
txtStatusBounds.fixedHeight = 16;
txtStatusBounds.percentWidth = 1;
this.SingleComposer = capi.Gui.CreateCompo("automapControlPanel", dialogBounds)
.AddShadedDialogBG(bgBounds)
.AddDialogTitleBar("Automap Controls", OnTitleBarCloseClicked)
.AddStaticText("Configure Automap settings:", CairoFont.WhiteDetailText( ), textBounds)
.AddToggleButton("Run", CairoFont.ButtonText( ), RunToggle, toggleBounds, "btnRun")
.AddStaticText("Idle.", CairoFont.WhiteSmallText( ).WithFontSize(12), txtStatusBounds, "txtStatus")
.Compose( );
//Controls for ALL Block & Entity Designators (Enable/Disable)
//_automapSystem.BlockID_Designators
//_automapSystem.Entity_Designators
//Renderer selection
//Message verbosity? Speed?
//A Button to add POI - notes manually (when AM running)
}
private void OnTitleBarCloseClicked( )
{
TryClose( );
}
///
/// Toggle Automap from/to RUN state
///
/// The toggle.
/// T1.
internal void RunToggle(bool toggle)
{
_automapSystem.Enabled = toggle;
Logger.VerboseDebug("Dialog Changed; [ Automap Enabled: {0} ]", toggle);
var statusText = this.SingleComposer.GetStaticText("txtStatus");
statusText.SetValue($"Running: {this._automapSystem.Enabled}, Total: {this._automapSystem.updatedChunksTotal}, Nulls: {this._automapSystem.nullChunkCount} " );
}
}
}