Restore UnlockMouse config, adjust config saving

This commit is contained in:
Sinai
2021-03-30 21:23:45 +11:00
parent 40f698122d
commit 3501a28fd1
14 changed files with 114 additions and 94 deletions

View File

@ -49,7 +49,7 @@ namespace UnityExplorer.UI.CacheObject
public override void SetValue()
{
RefConfig.BoxedValue = IValue.Value;
ConfigManager.Handler.SaveConfig();
ConfigManager.Handler.OnAnyConfigChanged();
}
internal GameObject m_leftGroup;
@ -59,7 +59,9 @@ namespace UnityExplorer.UI.CacheObject
{
base.ConstructUI();
var horiGroup = UIFactory.CreateHorizontalGroup(m_mainContent, "ConfigEntryHolder", true, false, true, true, 5, new Vector4(2,2,2,2));
var vertGroup = UIFactory.CreateVerticalGroup(m_mainContent, "ConfigHolder", true, false, true, true, 5, new Vector4(2, 2, 2, 2));
var horiGroup = UIFactory.CreateHorizontalGroup(vertGroup, "ConfigEntryHolder", true, false, true, true);
UIFactory.SetLayoutElement(horiGroup, minHeight: 30, flexibleHeight: 0);
// left group
@ -89,6 +91,12 @@ namespace UnityExplorer.UI.CacheObject
IValue.m_mainContentParent = m_rightGroup;
IValue.m_subContentParent = this.m_subContent;
}
// Config description label
UIFactory.CreateLabel(vertGroup, "Description", $"<i>{RefConfig.Description}</i>", TextAnchor.MiddleLeft, Color.grey);
m_subContent.transform.SetAsLastSibling();
}
}
}

View File

@ -19,13 +19,6 @@ namespace UnityExplorer.UI.Main.Options
{
ConstructUI();
_cachedConfigEntries.AddRange(ConfigManager.ConfigElements.Values
.Where(it => !it.IsInternal)
.Select(it => new CacheConfigEntry(it, m_contentObj)));
foreach (var entry in _cachedConfigEntries)
entry.Enable();
return true;
}
@ -51,14 +44,26 @@ namespace UnityExplorer.UI.Main.Options
var titleLabel = UIFactory.CreateLabel(Content, "Title", "Options", TextAnchor.UpperLeft, default, true, 25);
UIFactory.SetLayoutElement(titleLabel.gameObject, minHeight: 30, flexibleHeight: 0);
// Save button
var btn = UIFactory.CreateButton(Content,
"SaveButton",
"Save Config File",
() => { ConfigManager.Handler.SaveConfig(); },
new Color(0.25f, 0.6f, 0.25f));
UIFactory.SetLayoutElement(btn.gameObject, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 0);
// ~~~~~ Actual options ~~~~~
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);
//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);
_cachedConfigEntries.AddRange(ConfigManager.ConfigElements.Values
.Where(it => !it.IsInternal)
.Select(it => new CacheConfigEntry(it, m_contentObj)));
foreach (var entry in _cachedConfigEntries)
entry.Enable();
}