Implement Options panel, some cleanups

This commit is contained in:
Sinai 2021-05-13 23:03:30 +10:00
parent ccd08c3a63
commit 89022db5fc
22 changed files with 315 additions and 150 deletions

View File

@ -64,7 +64,7 @@ The following helper methods are available:
private static HashSet<string> usingDirectives;
private static StringBuilder evaluatorOutput;
public static CSConsolePanel Panel => UIManager.CSharpConsole;
public static CSConsolePanel Panel => UIManager.GetPanel<CSConsolePanel>(UIManager.Panels.CSConsole);
public static InputFieldRef Input => Panel.Input;
public static int LastCaretPosition { get; private set; }

View File

@ -299,6 +299,7 @@ namespace UnityExplorer.UI.CSConsole
// lower the indent level by one as we would not have accounted for this closing symbol
indent--;
// go back from the caret to the start of the line, calculate how much indent we need to adjust.
while (CurrentIndex > 0)
{
CurrentIndex--;

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityExplorer.Core.Config;
using UnityExplorer.UI.CacheObject.Views;
namespace UnityExplorer.UI.CacheObject
{
public class CacheConfigEntry : CacheObjectBase
{
public CacheConfigEntry(IConfigElement configElement)
{
this.RefConfigElement = configElement;
this.NameLabelText = $"<color=cyan>{configElement.Name}</color>" +
$"\r\n<color=grey><i>{configElement.Description}</i></color>";
this.FallbackType = configElement.ElementType;
configElement.OnValueChangedNotify += UpdateValueFromSource;
}
public IConfigElement RefConfigElement;
public override bool ShouldAutoEvaluate => true;
public override bool HasArguments => false;
public override bool CanWrite => true;
public void UpdateValueFromSource()
{
if (RefConfigElement.BoxedValue.Equals(this.Value))
return;
SetValueFromSource(RefConfigElement.BoxedValue);
}
public override void TrySetUserValue(object value)
{
this.Value = value;
RefConfigElement.BoxedValue = value;
}
protected override bool SetCellEvaluateState(CacheObjectCell cell) => false;
}
}

View File

@ -349,7 +349,8 @@ namespace UnityExplorer.UI.CacheObject
cell.ApplyButton.Component.gameObject.SetActive(args.applyActive);
// Inspect button only if last value not null.
cell.InspectButton.Component.gameObject.SetActive(args.inspectActive && !LastValueWasNull);
if (cell.InspectButton != null)
cell.InspectButton.Component.gameObject.SetActive(args.inspectActive && !LastValueWasNull);
// allow IValue for null strings though
cell.SubContentButton.Component.gameObject.SetActive(args.subContentButtonActive && (!LastValueWasNull || State == ValueState.String));

View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
namespace UnityExplorer.UI.CacheObject.Views
{
public class ConfigEntryCell : CacheObjectCell
{
public override GameObject CreateContent(GameObject parent)
{
// Main layout
UIRoot = UIFactory.CreateUIObject(this.GetType().Name, parent, new Vector2(100, 30));
Rect = UIRoot.GetComponent<RectTransform>();
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(UIRoot, false, false, true, true, 4, 4, 4, 4, 4, childAlignment: TextAnchor.UpperLeft);
UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600);
UIRoot.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
// Left label
NameLabel = UIFactory.CreateLabel(UIRoot, "NameLabel", "<notset>", TextAnchor.MiddleLeft);
NameLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
UIFactory.SetLayoutElement(NameLabel.gameObject, minHeight: 25, flexibleWidth: 9999, flexibleHeight: 300);
NameLayout = NameLabel.GetComponent<LayoutElement>();
// horizontal group
var horiGroup = UIFactory.CreateUIObject("RightHoriGroup", UIRoot);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(horiGroup, false, false, true, true, 4, childAlignment: TextAnchor.UpperLeft);
UIFactory.SetLayoutElement(horiGroup, minHeight: 25, minWidth: 200, flexibleWidth: 9999, flexibleHeight: 800);
SubContentButton = UIFactory.CreateButton(horiGroup, "SubContentButton", "▲", subInactiveColor);
UIFactory.SetLayoutElement(SubContentButton.Component.gameObject, minWidth: 25, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
SubContentButton.OnClick += SubContentClicked;
// Type label
TypeLabel = UIFactory.CreateLabel(horiGroup, "TypeLabel", "<notset>", TextAnchor.MiddleLeft);
TypeLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
UIFactory.SetLayoutElement(TypeLabel.gameObject, minHeight: 25, flexibleHeight: 150, minWidth: 60, flexibleWidth: 0);
// Bool and number value interaction
var toggleObj = UIFactory.CreateToggle(horiGroup, "Toggle", out Toggle, out ToggleText);
UIFactory.SetLayoutElement(toggleObj, minWidth: 70, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
ToggleText.color = SignatureHighlighter.KeywordBlue;
Toggle.onValueChanged.AddListener(ToggleClicked);
InputField = UIFactory.CreateInputField(horiGroup, "InputField", "...");
UIFactory.SetLayoutElement(InputField.UIRoot, minWidth: 150, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
// Apply
ApplyButton = UIFactory.CreateButton(horiGroup, "ApplyButton", "Apply", new Color(0.15f, 0.19f, 0.15f));
UIFactory.SetLayoutElement(ApplyButton.Component.gameObject, minWidth: 70, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
ApplyButton.OnClick += ApplyClicked;
// Main value label
ValueLabel = UIFactory.CreateLabel(horiGroup, "ValueLabel", "Value goes here", TextAnchor.MiddleLeft);
ValueLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
UIFactory.SetLayoutElement(ValueLabel.gameObject, minHeight: 25, flexibleHeight: 150, flexibleWidth: 9999);
// Subcontent
SubContentHolder = UIFactory.CreateUIObject("SubContent", UIRoot);
UIFactory.SetLayoutElement(SubContentHolder.gameObject, minHeight: 30, flexibleHeight: 600, minWidth: 100, flexibleWidth: 9999);
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(SubContentHolder, true, true, true, true, 2, childAlignment: TextAnchor.UpperLeft);
//SubContentHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.MinSize;
SubContentHolder.SetActive(false);
// Bottom separator
var separator = UIFactory.CreateUIObject("BottomSeperator", UIRoot);
UIFactory.SetLayoutElement(separator, minHeight: 1, flexibleHeight: 0, flexibleWidth: 9999);
separator.AddComponent<Image>().color = Color.black;
return UIRoot;
}
protected override void ConstructEvaluateHolder(GameObject parent) { }
}
}

View File

@ -78,8 +78,8 @@ namespace UnityExplorer.UI.CacheObject.Views
this.Occupant.OnCellSubContentToggle();
}
private readonly Color subInactiveColor = new Color(0.23f, 0.23f, 0.23f);
private readonly Color subActiveColor = new Color(0.23f, 0.33f, 0.23f);
public readonly Color subInactiveColor = new Color(0.23f, 0.23f, 0.23f);
public readonly Color subActiveColor = new Color(0.23f, 0.33f, 0.23f);
public void RefreshSubcontentButton()
{
@ -113,9 +113,9 @@ namespace UnityExplorer.UI.CacheObject.Views
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(horiRow, false, false, true, true, 5, 2, childAlignment: TextAnchor.UpperLeft);
horiRow.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
// Left member label
// Left name label
NameLabel = UIFactory.CreateLabel(horiRow, "MemberLabel", "<notset>", TextAnchor.MiddleLeft);
NameLabel = UIFactory.CreateLabel(horiRow, "NameLabel", "<notset>", TextAnchor.MiddleLeft);
NameLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
UIFactory.SetLayoutElement(NameLabel.gameObject, minHeight: 25, minWidth: 20, flexibleHeight: 300, flexibleWidth: 0);
NameLayout = NameLabel.GetComponent<LayoutElement>();

View File

@ -13,7 +13,7 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.IValues
{
public class InteractiveDictionary : InteractiveValue, IPoolDataSource<CacheKeyValuePairCell>, ICacheObjectController
public class InteractiveDictionary : InteractiveValue, ICellPoolDataSource<CacheKeyValuePairCell>, ICacheObjectController
{
CacheObjectBase ICacheObjectController.ParentCacheObject => this.CurrentOwner;
object ICacheObjectController.Target => this.CurrentOwner.Value;

View File

@ -13,7 +13,7 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.IValues
{
public class InteractiveList : InteractiveValue, IPoolDataSource<CacheListEntryCell>, ICacheObjectController
public class InteractiveList : InteractiveValue, ICellPoolDataSource<CacheListEntryCell>, ICacheObjectController
{
CacheObjectBase ICacheObjectController.ParentCacheObject => this.CurrentOwner;
object ICacheObjectController.Target => this.CurrentOwner.Value;

View File

@ -18,7 +18,7 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.Inspectors
{
public class ReflectionInspector : InspectorBase, IPoolDataSource<CacheMemberCell>, ICacheObjectController
public class ReflectionInspector : InspectorBase, ICellPoolDataSource<CacheMemberCell>, ICacheObjectController
{
public CacheObjectBase ParentCacheObject { get; set; }
public Type TargetType { get; private set; }
@ -95,7 +95,7 @@ namespace UnityExplorer.UI.Inspectors
autoUpdateToggle.isOn = false;
AutoUpdateWanted = false;
ObjectRef = null;
UnityObjectRef = null;
ComponentRef = null;
TextureRef = null;
CleanupTextureViewer();
@ -193,6 +193,17 @@ namespace UnityExplorer.UI.Inspectors
}
}
public void UpdateClicked()
{
UpdateDisplayedMembers();
if (this.UnityObjectRef)
{
nameInput.Text = UnityObjectRef.name;
instanceIdInput.Text = UnityObjectRef.GetInstanceID().ToString();
}
}
// Filtering
public void SetFilter(string filter) => SetFilter(filter, FlagsFilter);
@ -378,7 +389,7 @@ namespace UnityExplorer.UI.Inspectors
var updateButton = UIFactory.CreateButton(rowObj, "UpdateButton", "Update displayed values", new Color(0.22f, 0.28f, 0.22f));
UIFactory.SetLayoutElement(updateButton.Component.gameObject, minHeight: 25, minWidth: 175, flexibleWidth: 0);
updateButton.OnClick += UpdateDisplayedMembers;
updateButton.OnClick += UpdateClicked;
var toggleObj = UIFactory.CreateToggle(rowObj, "AutoUpdateToggle", out autoUpdateToggle, out Text toggleText);
//GameObject.DestroyImmediate(toggleText);
@ -455,7 +466,7 @@ namespace UnityExplorer.UI.Inspectors
// Unity object helpers
private UnityEngine.Object ObjectRef;
private UnityEngine.Object UnityObjectRef;
private Component ComponentRef;
private Texture2D TextureRef;
private bool TextureViewerWanted;
@ -475,11 +486,11 @@ namespace UnityExplorer.UI.Inspectors
return;
}
ObjectRef = (UnityEngine.Object)Target.TryCast(typeof(UnityEngine.Object));
UnityObjectRef = (UnityEngine.Object)Target.TryCast(typeof(UnityEngine.Object));
unityObjectRow.SetActive(true);
nameInput.Text = ObjectRef.name;
instanceIdInput.Text = ObjectRef.GetInstanceID().ToString();
nameInput.Text = UnityObjectRef.name;
instanceIdInput.Text = UnityObjectRef.GetInstanceID().ToString();
if (typeof(Component).IsAssignableFrom(TargetType))
{
@ -515,7 +526,7 @@ namespace UnityExplorer.UI.Inspectors
{
// disable
TextureViewerWanted = false;
textureViewer.gameObject.SetActive(false);
textureViewer.SetActive(false);
mainContentHolder.SetActive(true);
textureButton.ButtonText.text = "View Texture";
}
@ -529,7 +540,7 @@ namespace UnityExplorer.UI.Inspectors
// enable
TextureViewerWanted = true;
textureViewer.gameObject.SetActive(true);
textureViewer.SetActive(true);
mainContentHolder.gameObject.SetActive(false);
textureButton.ButtonText.text = "Hide Texture";
}

View File

@ -54,7 +54,7 @@ namespace UnityExplorer.UI.Panels
ConfigManager.CSConsoleData.Value = this.ToSaveData();
}
public override string GetSaveData() => ConfigManager.CSConsoleData.Value;
public override string GetSaveDataFromConfigManager() => ConfigManager.CSConsoleData.Value;
// UI Construction

View File

@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityExplorer.Core.Config;
namespace UnityExplorer.UI.Panels
{
@ -13,24 +15,27 @@ namespace UnityExplorer.UI.Panels
public override int MinWidth => 300;
public override int MinHeight => 75;
public override void ConstructPanelContent()
public override string GetSaveDataFromConfigManager()
{
throw new NotImplementedException();
return ConfigManager.ConsoleLogData.Value;
}
public override void DoSaveToConfigElement()
{
throw new NotImplementedException();
}
public override string GetSaveData()
{
throw new NotImplementedException();
ConfigManager.ConsoleLogData.Value = this.ToSaveData();
}
protected internal override void DoSetDefaultPosAndAnchors()
{
throw new NotImplementedException();
mainPanelRect.localPosition = Vector2.zero;
mainPanelRect.pivot = new Vector2(0f, 1f);
mainPanelRect.anchorMin = new Vector2(0.5f, 0.1f);
mainPanelRect.anchorMax = new Vector2(0.9f, 0.25f);
}
public override void ConstructPanelContent()
{
}
}
}

View File

@ -42,7 +42,7 @@ namespace UnityExplorer.UI.Panels
InspectorManager.OnPanelResized(panel.rect.width);
}
public override string GetSaveData() => ConfigManager.InspectorData.Value;
public override string GetSaveDataFromConfigManager() => ConfigManager.InspectorData.Value;
//public override void LoadSaveData()
//{

View File

@ -63,7 +63,7 @@ namespace UnityExplorer.UI.Panels
ObjectSearch.Update();
}
public override string GetSaveData() => ConfigManager.ObjectExplorerData.Value;
public override string GetSaveDataFromConfigManager() => ConfigManager.ObjectExplorerData.Value;
public override void DoSaveToConfigElement()
{

View File

@ -2,35 +2,97 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core.Config;
using UnityExplorer.UI.CacheObject;
using UnityExplorer.UI.CacheObject.Views;
using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.Panels
{
public class OptionsPanel : UIPanel
public class OptionsPanel : UIPanel, ICacheObjectController, ICellPoolDataSource<ConfigEntryCell>
{
public override string Name => "Options";
public override UIManager.Panels PanelType => UIManager.Panels.Options;
public override int MinWidth => 400;
public override int MinWidth => 550;
public override int MinHeight => 200;
public override void ConstructPanelContent()
public override bool ShouldSaveActiveState => false;
public override bool ShowByDefault => false;
// Entry holders
private readonly List<CacheConfigEntry> configEntries = new List<CacheConfigEntry>();
// ICacheObjectController
public CacheObjectBase ParentCacheObject => null;
public object Target => null;
public Type TargetType => null;
public bool CanWrite => true;
// ICellPoolDataSource
public int ItemCount => configEntries.Count;
public OptionsPanel()
{
throw new NotImplementedException();
foreach (var entry in ConfigManager.ConfigElements)
{
var cache = new CacheConfigEntry(entry.Value);
cache.Owner = this;
configEntries.Add(cache);
}
}
public void OnCellBorrowed(ConfigEntryCell cell)
{
}
public void SetCell(ConfigEntryCell cell, int index)
{
CacheObjectControllerHelper.SetCell(cell, index, this.configEntries, null);
}
// Panel save data
public override string GetSaveDataFromConfigManager()
{
return ConfigManager.OptionsPanelData.Value;
}
public override void DoSaveToConfigElement()
{
throw new NotImplementedException();
}
public override string GetSaveData()
{
throw new NotImplementedException();
ConfigManager.OptionsPanelData.Value = this.ToSaveData();
}
protected internal override void DoSetDefaultPosAndAnchors()
{
throw new NotImplementedException();
mainPanelRect.localPosition = Vector2.zero;
mainPanelRect.pivot = new Vector2(0.5f, 1f);
mainPanelRect.anchorMin = new Vector2(0.5f, 0.1f);
mainPanelRect.anchorMax = new Vector2(0.5f, 0.85f);
mainPanelRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 550f);
}
// UI Construction
public override void ConstructPanelContent()
{
// Save button
var saveBtn = UIFactory.CreateButton(this.content, "Save", "Save Options", new Color(0.25f, 0.3f, 0.25f));
UIFactory.SetLayoutElement(saveBtn.Component.gameObject, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 0);
saveBtn.OnClick += ConfigManager.Handler.SaveConfig;
// Config entries
var scrollPool = UIFactory.CreateScrollPool<ConfigEntryCell>(this.content, "ConfigEntries", out GameObject scrollObj,
out GameObject scrollContent);
scrollPool.Initialize(this);
foreach (var config in configEntries)
config.UpdateValueFromSource();
}
}
}

View File

@ -220,7 +220,7 @@ namespace UnityExplorer.UI.Panels
// apply panel save data or revert to default
try
{
ApplySaveData(GetSaveData());
ApplySaveData(GetSaveDataFromConfigManager());
}
catch (Exception ex)
{
@ -252,7 +252,7 @@ namespace UnityExplorer.UI.Panels
DoSaveToConfigElement();
}
public abstract string GetSaveData();
public abstract string GetSaveDataFromConfigManager();
public bool ApplyingSaveData { get; set; }

View File

@ -39,14 +39,7 @@ namespace UnityExplorer.UI
// panels
internal static GameObject PanelHolder { get; private set; }
public static ObjectExplorerPanel Explorer { get; private set; }
public static InspectorPanel Inspector { get; private set; }
public static CSConsolePanel CSharpConsole { get; private set; }
public static OptionsPanel Options { get; private set; }
public static ConsoleLogPanel ConsoleLog { get; private set; }
public static AutoCompleteModal AutoCompleter { get; private set; }
private static readonly Dictionary<Panels, UIPanel> UIPanels = new Dictionary<Panels, UIPanel>();
// assets
internal static Font ConsoleFont { get; private set; }
@ -62,24 +55,6 @@ namespace UnityExplorer.UI
public const int MAX_INPUTFIELD_CHARS = 16000;
public const int MAX_TEXT_VERTS = 65000;
public static UIPanel GetPanel(Panels panel)
{
switch (panel)
{
case Panels.ObjectExplorer:
return Explorer;
case Panels.Inspector:
return Inspector;
case Panels.AutoCompleter:
return AutoCompleter;
case Panels.CSConsole:
return CSharpConsole;
default:
throw new NotImplementedException($"TODO GetPanel: {panel}");
}
}
// main menu toggle
public static bool ShowMenu
{
get => s_showMenu;
@ -95,34 +70,16 @@ namespace UnityExplorer.UI
}
public static bool s_showMenu = true;
public static void Update()
// Panels
public static UIPanel GetPanel(Panels panel)
{
if (!CanvasRoot || Initializing)
return;
return UIPanels[panel];
}
//if (InspectUnderMouse.Inspecting)
//{
// InspectUnderMouse.UpdateInspect();
// return;
//}
if (InputManager.GetKeyDown(ConfigManager.Main_Menu_Toggle.Value))
ShowMenu = !ShowMenu;
if (!ShowMenu)
return;
gcLabel.text = "GC : " + (GC.GetTotalMemory(false) / 1024 / 1024) + "MB";
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Keybind.Value))
CursorUnlocker.Unlock = !CursorUnlocker.Unlock;
if (EventSystem.current != EventSys)
CursorUnlocker.SetEventSystem();
UIPanel.UpdateFocus();
PanelDragger.UpdateInstances();
UIBehaviourModel.UpdateInstances();
public static T GetPanel<T>(Panels panel) where T : UIPanel
{
return (T)UIPanels[panel];
}
public static void TogglePanel(Panels panel)
@ -153,6 +110,38 @@ namespace UnityExplorer.UI
SetPanelActive(panel, value);
}
// Main UI Update loop
public static void Update()
{
if (!CanvasRoot || Initializing)
return;
//if (InspectUnderMouse.Inspecting)
//{
// InspectUnderMouse.UpdateInspect();
// return;
//}
if (InputManager.GetKeyDown(ConfigManager.Main_Menu_Toggle.Value))
ShowMenu = !ShowMenu;
if (!ShowMenu)
return;
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value))
CursorUnlocker.Unlock = !CursorUnlocker.Unlock;
if (EventSystem.current != EventSys)
CursorUnlocker.SetEventSystem();
UIPanel.UpdateFocus();
PanelDragger.UpdateInstances();
UIBehaviourModel.UpdateInstances();
}
// Initialization and UI Construction
internal static void InitUI()
{
LoadBundle();
@ -161,33 +150,28 @@ namespace UnityExplorer.UI
CreateRootCanvas();
// Global UI Pool Holder
PoolHolder = new GameObject("PoolHolder");
PoolHolder.transform.parent = CanvasRoot.transform;
PoolHolder.SetActive(false);
CreateTopNavBar();
// TODO (or probably just do this when showing it for first time)
//InspectUnderMouse.ConstructUI();
AutoCompleter = new AutoCompleteModal();
AutoCompleter.ConstructUI();
UIPanels.Add(Panels.AutoCompleter, new AutoCompleteModal());
UIPanels.Add(Panels.ObjectExplorer, new ObjectExplorerPanel());
UIPanels.Add(Panels.Inspector, new InspectorPanel());
UIPanels.Add(Panels.CSConsole, new CSConsolePanel());
UIPanels.Add(Panels.Options, new OptionsPanel());
UIPanels.Add(Panels.ConsoleLog, new ConsoleLogPanel());
Explorer = new ObjectExplorerPanel();
Explorer.ConstructUI();
foreach (var panel in UIPanels.Values)
panel.ConstructUI();
Inspector = new InspectorPanel();
Inspector.ConstructUI();
CSharpConsole = new CSConsolePanel();
CSharpConsole.ConstructUI();
ConsoleController.Init();
Options = new OptionsPanel();
Options.ConstructUI();
ConsoleLog = new ConsoleLogPanel();
ConsoleLog.ConstructUI();
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
ExplorerCore.Log("UI initialized.");
@ -228,12 +212,6 @@ namespace UnityExplorer.UI
PanelHolder.transform.SetAsFirstSibling();
}
//// temp
//private static float lastTimeSpeed;
//private static bool pausing;
private static Text gcLabel;
private static void CreateTopNavBar()
{
var navbarPanel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
@ -243,7 +221,7 @@ namespace UnityExplorer.UI
NavBarRect.pivot = new Vector2(0.5f, 1f);
NavBarRect.anchorMin = new Vector2(0.5f, 1f);
NavBarRect.anchorMax = new Vector2(0.5f, 1f);
NavBarRect.sizeDelta = new Vector2(900f, 35f);
NavBarRect.sizeDelta = new Vector2(1000f, 35f);
// UnityExplorer title
@ -251,32 +229,6 @@ namespace UnityExplorer.UI
var title = UIFactory.CreateLabel(navbarPanel, "Title", titleTxt, TextAnchor.MiddleLeft, default, true, 18);
UIFactory.SetLayoutElement(title.gameObject, minWidth: 240, flexibleWidth: 0);
// temp debug
gcLabel = UIFactory.CreateLabel(navbarPanel, "GCLabel", "GC: ", TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(gcLabel.gameObject, minWidth: 150, minHeight: 25, flexibleWidth: 0);
// TODO something nicer for this, maybe a 'Tools' dropout below the main navbar with a few helpers like this.
//var btn = UIFactory.CreateButton(navbarPanel, "Button", "pause", new Color(0.2f, 0.2f, 0.2f));
//UIFactory.SetLayoutElement(btn.Button.gameObject, minWidth: 30, flexibleWidth: 0, minHeight: 25);
//btn.OnClick += () =>
//{
// if (!pausing)
// {
// lastTimeSpeed = Time.timeScale;
// Time.timeScale = 0;
// pausing = true;
// btn.ButtonText.text = "resume";
// }
// else
// {
// Time.timeScale = lastTimeSpeed;
// pausing = false;
// btn.ButtonText.text = "pause";
// }
//};
// Navbar
NavbarButtonHolder = UIFactory.CreateUIObject("NavButtonHolder", navbarPanel);

View File

@ -18,7 +18,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
public class AutoCompleteModal : UIPanel
{
public static AutoCompleteModal Instance => UIManager.AutoCompleter;
public static AutoCompleteModal Instance => UIManager.GetPanel<AutoCompleteModal>(UIManager.Panels.AutoCompleter);
public override string Name => "AutoCompleter";
public override UIManager.Panels PanelType => UIManager.Panels.AutoCompleter;
@ -201,6 +201,6 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
// not savable
}
public override string GetSaveData() => null;
public override string GetSaveDataFromConfigManager() => null;
}
}

View File

@ -10,7 +10,7 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.Widgets
{
public class ButtonListSource<T> : IPoolDataSource<ButtonCell>
public class ButtonListSource<T> : ICellPoolDataSource<ButtonCell>
{
internal ScrollPool<ButtonCell> ScrollPool;

View File

@ -6,7 +6,7 @@ using UnityEngine;
namespace UnityExplorer.UI.Widgets
{
public interface IPoolDataSource<T> where T : ICell
public interface ICellPoolDataSource<T> where T : ICell
{
int ItemCount { get; }

View File

@ -27,7 +27,7 @@ namespace UnityExplorer.UI.Widgets
this.ScrollRect = scrollRect;
}
public IPoolDataSource<T> DataSource { get; set; }
public ICellPoolDataSource<T> DataSource { get; set; }
public readonly List<T> CellPool = new List<T>();
@ -143,7 +143,7 @@ namespace UnityExplorer.UI.Widgets
//private bool Initialized;
/// <summary>Should be called only once, when the scroll pool is created.</summary>
public void Initialize(IPoolDataSource<T> dataSource, Action onHeightChangedListener = null)
public void Initialize(ICellPoolDataSource<T> dataSource, Action onHeightChangedListener = null)
{
this.DataSource = dataSource;
HeightCache = new DataHeightCache<T>(this);

View File

@ -11,7 +11,7 @@ using UnityExplorer.UI.Widgets;
namespace UnityExplorer.UI.Widgets
{
public class TransformTree : IPoolDataSource<TransformCell>
public class TransformTree : ICellPoolDataSource<TransformCell>
{
public Func<IEnumerable<GameObject>> GetRootEntriesMethod;

View File

@ -216,6 +216,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Core\Config\InternalConfigHandler.cs" />
<Compile Include="UI\CacheObject\CacheConfigEntry.cs" />
<Compile Include="UI\CacheObject\Views\CacheConfigCell.cs" />
<Compile Include="UI\CSConsole\CSAutoCompleter.cs" />
<Compile Include="UI\CSConsole\LexerBuilder.cs" />
<Compile Include="UI\CSConsole\Lexers\CommentLexer.cs" />
@ -319,7 +321,7 @@
<Compile Include="UI\ObjectExplorer\SceneExplorer.cs" />
<Compile Include="UI\Widgets\ScrollPool\DataHeightCache.cs" />
<Compile Include="UI\Widgets\ScrollPool\ICell.cs" />
<Compile Include="UI\Widgets\ScrollPool\IPoolDataSource.cs" />
<Compile Include="UI\Widgets\ScrollPool\ICellPoolDataSource.cs" />
<Compile Include="UI\Widgets\ScrollPool\ScrollPool.cs" />
<Compile Include="UI\Widgets\ScrollPool\UIExtensions.cs" />
<Compile Include="UI\Widgets\InputFieldScroller.cs" />