2020-11-05 17:33:04 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using UnityExplorer.Core.Config;
|
2021-03-30 19:50:04 +11:00
|
|
|
|
using UnityExplorer.UI.CacheObject;
|
|
|
|
|
using UnityExplorer.UI.Utility;
|
2020-11-05 17:33:04 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
namespace UnityExplorer.UI.Main.Options
|
2020-10-23 20:40:44 +11:00
|
|
|
|
{
|
2021-03-18 17:17:29 +11:00
|
|
|
|
public class OptionsPage : BaseMenuPage
|
2020-10-23 20:40:44 +11:00
|
|
|
|
{
|
2020-11-06 20:42:16 +11:00
|
|
|
|
public override string Name => "Options";
|
2020-10-23 20:40:44 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
internal static readonly List<CacheConfigEntry> _cachedConfigEntries = new List<CacheConfigEntry>();
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-18 18:38:51 +11:00
|
|
|
|
public override bool Init()
|
2020-10-23 20:40:44 +11:00
|
|
|
|
{
|
2020-11-06 20:42:16 +11:00
|
|
|
|
ConstructUI();
|
2021-03-18 18:38:51 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
_cachedConfigEntries.AddRange(ConfigManager.ConfigElements.Values
|
|
|
|
|
.Where(it => !it.IsInternal)
|
|
|
|
|
.Select(it => new CacheConfigEntry(it, m_contentObj)));
|
|
|
|
|
|
|
|
|
|
foreach (var entry in _cachedConfigEntries)
|
|
|
|
|
entry.Enable();
|
|
|
|
|
|
2021-03-18 18:38:51 +11:00
|
|
|
|
return true;
|
2020-10-23 20:40:44 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update()
|
|
|
|
|
{
|
2021-03-30 19:50:04 +11:00
|
|
|
|
// Not needed
|
2020-10-23 20:40:44 +11:00
|
|
|
|
}
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
|
|
|
|
#region UI CONSTRUCTION
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
internal GameObject m_contentObj;
|
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
internal void ConstructUI()
|
|
|
|
|
{
|
|
|
|
|
GameObject parent = MainMenu.Instance.PageViewport;
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
Content = UIFactory.CreateVerticalGroup(parent, "OptionsPage", true, true, true, true, 5, new Vector4(4,4,4,4),
|
|
|
|
|
new Color(0.15f, 0.15f, 0.15f));
|
|
|
|
|
UIFactory.SetLayoutElement(Content, minHeight: 340, flexibleHeight: 9999);
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
2020-11-08 21:04:41 +11:00
|
|
|
|
// ~~~~~ Title ~~~~~
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
var titleLabel = UIFactory.CreateLabel(Content, "Title", "Options", TextAnchor.UpperLeft, default, true, 25);
|
|
|
|
|
UIFactory.SetLayoutElement(titleLabel.gameObject, minHeight: 30, flexibleHeight: 0);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
|
|
|
|
// ~~~~~ Actual options ~~~~~
|
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
UIFactory.CreateScrollView(Content, "ConfigList", out m_contentObj, out _, new Color(0.05f, 0.05f, 0.05f));
|
|
|
|
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(m_contentObj, forceHeight: true, spacing: 3, padLeft: 3, padRight: 3);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
//m_contentObj = UIFactory.CreateVerticalGroup(Content, "OptionsGroup", true, false, true, false, 5, new Vector4(5,5,5,5),
|
|
|
|
|
// new Color(0.1f, 0.1f, 0.1f));
|
|
|
|
|
//UIFactory.SetLayoutElement(m_contentObj, minHeight: 340, flexibleHeight: 9999);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
2021-03-30 19:50:04 +11:00
|
|
|
|
#endregion
|
2020-10-23 20:40:44 +11:00
|
|
|
|
}
|
|
|
|
|
}
|