2020-11-05 17:33:04 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
using UnityExplorer.Config;
|
2020-11-13 23:14:57 +11:00
|
|
|
|
using UnityExplorer.Helpers;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
using UnityExplorer.UI.Shared;
|
2020-11-09 16:43:19 +11:00
|
|
|
|
using UnityExplorer.Unstrip;
|
2020-11-05 17:33:04 +11:00
|
|
|
|
|
2020-11-11 20:16:43 +11:00
|
|
|
|
namespace UnityExplorer.UI.Modules
|
2020-10-23 20:40:44 +11:00
|
|
|
|
{
|
2020-10-28 06:39:26 +11:00
|
|
|
|
public class OptionsPage : MainMenu.Page
|
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
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
private InputField m_keycodeInput;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
private Toggle m_unlockMouseToggle;
|
2020-11-10 20:18:14 +11:00
|
|
|
|
private InputField m_pageLimitInput;
|
|
|
|
|
private InputField m_defaultOutputInput;
|
2021-02-27 17:04:47 +11:00
|
|
|
|
private Toggle m_hideOnStartupToggle;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-10-23 20:40:44 +11:00
|
|
|
|
public override void Init()
|
|
|
|
|
{
|
2020-11-06 20:42:16 +11:00
|
|
|
|
ConstructUI();
|
2020-10-23 20:40:44 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update()
|
|
|
|
|
{
|
2020-11-08 21:04:41 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void OnApply()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(m_keycodeInput.text) && Enum.Parse(typeof(KeyCode), m_keycodeInput.text) is KeyCode keyCode)
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.Instance.Main_Menu_Toggle = keyCode;
|
2020-10-23 20:40:44 +11:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.Instance.Force_Unlock_Mouse = m_unlockMouseToggle.isOn;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(m_pageLimitInput.text) && int.TryParse(m_pageLimitInput.text, out int lim))
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.Instance.Default_Page_Limit = lim;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.Instance.Default_Output_Path = m_defaultOutputInput.text;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.Instance.Hide_On_Startup = m_hideOnStartupToggle.isOn;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.SaveSettings();
|
|
|
|
|
ExplorerConfig.InvokeConfigChanged();
|
2020-10-23 20:40:44 +11:00
|
|
|
|
}
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
|
|
|
|
#region UI CONSTRUCTION
|
|
|
|
|
|
|
|
|
|
internal void ConstructUI()
|
|
|
|
|
{
|
|
|
|
|
GameObject parent = MainMenu.Instance.PageViewport;
|
|
|
|
|
|
2020-11-08 21:04:41 +11:00
|
|
|
|
Content = UIFactory.CreateVerticalGroup(parent, new Color(0.15f, 0.15f, 0.15f));
|
|
|
|
|
var mainGroup = Content.GetComponent<VerticalLayoutGroup>();
|
2020-11-06 20:42:16 +11:00
|
|
|
|
mainGroup.padding.left = 4;
|
|
|
|
|
mainGroup.padding.right = 4;
|
|
|
|
|
mainGroup.padding.top = 4;
|
|
|
|
|
mainGroup.padding.bottom = 4;
|
|
|
|
|
mainGroup.spacing = 5;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
mainGroup.childForceExpandHeight = false;
|
2020-11-06 20:42:16 +11:00
|
|
|
|
mainGroup.childForceExpandWidth = true;
|
|
|
|
|
mainGroup.childControlHeight = true;
|
|
|
|
|
mainGroup.childControlWidth = true;
|
|
|
|
|
|
2020-11-08 21:04:41 +11:00
|
|
|
|
// ~~~~~ Title ~~~~~
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
|
|
|
|
GameObject titleObj = UIFactory.CreateLabel(Content, TextAnchor.UpperLeft);
|
|
|
|
|
Text titleLabel = titleObj.GetComponent<Text>();
|
|
|
|
|
titleLabel.text = "Options";
|
|
|
|
|
titleLabel.fontSize = 20;
|
|
|
|
|
LayoutElement titleLayout = titleObj.AddComponent<LayoutElement>();
|
|
|
|
|
titleLayout.minHeight = 30;
|
|
|
|
|
titleLayout.flexibleHeight = 0;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
|
|
|
|
// ~~~~~ Actual options ~~~~~
|
|
|
|
|
|
|
|
|
|
var optionsGroupObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
|
|
|
|
|
var optionsGroup = optionsGroupObj.GetComponent<VerticalLayoutGroup>();
|
|
|
|
|
optionsGroup.childForceExpandHeight = false;
|
|
|
|
|
optionsGroup.childForceExpandWidth = true;
|
|
|
|
|
optionsGroup.childControlWidth = true;
|
|
|
|
|
optionsGroup.childControlHeight = true;
|
|
|
|
|
optionsGroup.spacing = 5;
|
|
|
|
|
optionsGroup.padding.top = 5;
|
|
|
|
|
optionsGroup.padding.left = 5;
|
|
|
|
|
optionsGroup.padding.right = 5;
|
|
|
|
|
optionsGroup.padding.bottom = 5;
|
|
|
|
|
|
|
|
|
|
ConstructKeycodeOpt(optionsGroupObj);
|
|
|
|
|
ConstructMouseUnlockOpt(optionsGroupObj);
|
|
|
|
|
ConstructPageLimitOpt(optionsGroupObj);
|
|
|
|
|
ConstructOutputPathOpt(optionsGroupObj);
|
2021-02-27 17:04:47 +11:00
|
|
|
|
ConstructHideOnStartupOpt(optionsGroupObj);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
|
|
|
|
var applyBtnObj = UIFactory.CreateButton(Content, new Color(0.2f, 0.2f, 0.2f));
|
|
|
|
|
var applyText = applyBtnObj.GetComponentInChildren<Text>();
|
|
|
|
|
applyText.text = "Apply and Save";
|
|
|
|
|
var applyLayout = applyBtnObj.AddComponent<LayoutElement>();
|
|
|
|
|
applyLayout.minHeight = 30;
|
|
|
|
|
applyLayout.flexibleWidth = 1000;
|
|
|
|
|
var applyBtn = applyBtnObj.GetComponent<Button>();
|
|
|
|
|
var applyColors = applyBtn.colors;
|
|
|
|
|
applyColors.normalColor = new Color(0.3f, 0.7f, 0.3f);
|
|
|
|
|
applyBtn.colors = applyColors;
|
2020-11-13 23:14:57 +11:00
|
|
|
|
|
2020-11-08 21:04:41 +11:00
|
|
|
|
applyBtn.onClick.AddListener(OnApply);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-27 17:04:47 +11:00
|
|
|
|
private void ConstructHideOnStartupOpt(GameObject optionsGroupObj)
|
2020-11-08 21:04:41 +11:00
|
|
|
|
{
|
2021-02-27 17:04:47 +11:00
|
|
|
|
var rowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0));
|
|
|
|
|
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
rowGroup.childControlWidth = true;
|
|
|
|
|
rowGroup.childForceExpandWidth = false;
|
|
|
|
|
rowGroup.childControlHeight = true;
|
|
|
|
|
rowGroup.childForceExpandHeight = true;
|
|
|
|
|
var groupLayout = rowObj.AddComponent<LayoutElement>();
|
|
|
|
|
groupLayout.minHeight = 25;
|
|
|
|
|
groupLayout.flexibleHeight = 0;
|
|
|
|
|
groupLayout.minWidth = 200;
|
|
|
|
|
groupLayout.flexibleWidth = 1000;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-02-27 17:04:47 +11:00
|
|
|
|
var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
|
|
|
|
var labelText = labelObj.GetComponent<Text>();
|
|
|
|
|
labelText.text = "Hide UI on startup:";
|
|
|
|
|
var labelLayout = labelObj.AddComponent<LayoutElement>();
|
|
|
|
|
labelLayout.minWidth = 150;
|
|
|
|
|
labelLayout.minHeight = 25;
|
|
|
|
|
|
|
|
|
|
UIFactory.CreateToggle(rowObj, out m_hideOnStartupToggle, out Text toggleText);
|
2021-03-11 17:57:58 +11:00
|
|
|
|
m_hideOnStartupToggle.isOn = ExplorerConfig.Instance.Hide_On_Startup;
|
2021-02-27 17:04:47 +11:00
|
|
|
|
toggleText.text = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void ConstructKeycodeOpt(GameObject parent)
|
|
|
|
|
{
|
2020-11-08 21:04:41 +11:00
|
|
|
|
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
|
|
|
|
|
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
rowGroup.childControlWidth = true;
|
|
|
|
|
rowGroup.childForceExpandWidth = false;
|
|
|
|
|
rowGroup.childControlHeight = true;
|
|
|
|
|
rowGroup.childForceExpandHeight = true;
|
|
|
|
|
var groupLayout = rowObj.AddComponent<LayoutElement>();
|
|
|
|
|
groupLayout.minHeight = 25;
|
|
|
|
|
groupLayout.flexibleHeight = 0;
|
|
|
|
|
groupLayout.minWidth = 200;
|
|
|
|
|
groupLayout.flexibleWidth = 1000;
|
|
|
|
|
|
|
|
|
|
var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
|
|
|
|
var labelText = labelObj.GetComponent<Text>();
|
|
|
|
|
labelText.text = "Main Menu Toggle:";
|
|
|
|
|
var labelLayout = labelObj.AddComponent<LayoutElement>();
|
|
|
|
|
labelLayout.minWidth = 150;
|
|
|
|
|
labelLayout.minHeight = 25;
|
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
var keycodeInputObj = UIFactory.CreateInputField(rowObj);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
m_keycodeInput = keycodeInputObj.GetComponent<InputField>();
|
2021-03-11 17:57:58 +11:00
|
|
|
|
m_keycodeInput.text = ExplorerConfig.Instance.Main_Menu_Toggle.ToString();
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
m_keycodeInput.placeholder.gameObject.GetComponent<Text>().text = "KeyCode, eg. F7";
|
2020-11-08 21:04:41 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void ConstructMouseUnlockOpt(GameObject parent)
|
|
|
|
|
{
|
|
|
|
|
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
|
|
|
|
|
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
rowGroup.childControlWidth = true;
|
|
|
|
|
rowGroup.childForceExpandWidth = false;
|
|
|
|
|
rowGroup.childControlHeight = true;
|
|
|
|
|
rowGroup.childForceExpandHeight = true;
|
|
|
|
|
var groupLayout = rowObj.AddComponent<LayoutElement>();
|
|
|
|
|
groupLayout.minHeight = 25;
|
|
|
|
|
groupLayout.flexibleHeight = 0;
|
|
|
|
|
groupLayout.minWidth = 200;
|
|
|
|
|
groupLayout.flexibleWidth = 1000;
|
|
|
|
|
|
|
|
|
|
var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
|
|
|
|
var labelText = labelObj.GetComponent<Text>();
|
|
|
|
|
labelText.text = "Force Unlock Mouse:";
|
|
|
|
|
var labelLayout = labelObj.AddComponent<LayoutElement>();
|
|
|
|
|
labelLayout.minWidth = 150;
|
|
|
|
|
labelLayout.minHeight = 25;
|
|
|
|
|
|
2020-11-09 16:43:19 +11:00
|
|
|
|
UIFactory.CreateToggle(rowObj, out m_unlockMouseToggle, out Text toggleText);
|
2021-03-11 17:57:58 +11:00
|
|
|
|
m_unlockMouseToggle.isOn = ExplorerConfig.Instance.Force_Unlock_Mouse;
|
2020-11-08 21:04:41 +11:00
|
|
|
|
toggleText.text = "";
|
2020-11-06 20:42:16 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 21:04:41 +11:00
|
|
|
|
internal void ConstructPageLimitOpt(GameObject parent)
|
|
|
|
|
{
|
|
|
|
|
//public int Default_Page_Limit = 20;
|
|
|
|
|
|
|
|
|
|
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
|
|
|
|
|
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
rowGroup.childControlWidth = true;
|
|
|
|
|
rowGroup.childForceExpandWidth = false;
|
|
|
|
|
rowGroup.childControlHeight = true;
|
|
|
|
|
rowGroup.childForceExpandHeight = true;
|
|
|
|
|
var groupLayout = rowObj.AddComponent<LayoutElement>();
|
|
|
|
|
groupLayout.minHeight = 25;
|
|
|
|
|
groupLayout.flexibleHeight = 0;
|
|
|
|
|
groupLayout.minWidth = 200;
|
|
|
|
|
groupLayout.flexibleWidth = 1000;
|
|
|
|
|
|
|
|
|
|
var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
|
|
|
|
var labelText = labelObj.GetComponent<Text>();
|
|
|
|
|
labelText.text = "Default Page Limit:";
|
|
|
|
|
var labelLayout = labelObj.AddComponent<LayoutElement>();
|
|
|
|
|
labelLayout.minWidth = 150;
|
|
|
|
|
labelLayout.minHeight = 25;
|
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
var inputObj = UIFactory.CreateInputField(rowObj);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
m_pageLimitInput = inputObj.GetComponent<InputField>();
|
2021-03-11 17:57:58 +11:00
|
|
|
|
m_pageLimitInput.text = ExplorerConfig.Instance.Default_Page_Limit.ToString();
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
m_pageLimitInput.placeholder.gameObject.GetComponent<Text>().text = "Integer, eg. 20";
|
2020-11-08 21:04:41 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void ConstructOutputPathOpt(GameObject parent)
|
|
|
|
|
{
|
|
|
|
|
//public string Default_Output_Path = ExplorerCore.EXPLORER_FOLDER;
|
|
|
|
|
|
|
|
|
|
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
|
|
|
|
|
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
rowGroup.childControlWidth = true;
|
|
|
|
|
rowGroup.childForceExpandWidth = false;
|
|
|
|
|
rowGroup.childControlHeight = true;
|
|
|
|
|
rowGroup.childForceExpandHeight = true;
|
|
|
|
|
var groupLayout = rowObj.AddComponent<LayoutElement>();
|
|
|
|
|
groupLayout.minHeight = 25;
|
|
|
|
|
groupLayout.flexibleHeight = 0;
|
|
|
|
|
groupLayout.minWidth = 200;
|
|
|
|
|
groupLayout.flexibleWidth = 1000;
|
|
|
|
|
|
|
|
|
|
var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
|
|
|
|
var labelText = labelObj.GetComponent<Text>();
|
|
|
|
|
labelText.text = "Default Output Path:";
|
|
|
|
|
var labelLayout = labelObj.AddComponent<LayoutElement>();
|
|
|
|
|
labelLayout.minWidth = 150;
|
|
|
|
|
labelLayout.minHeight = 25;
|
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
var inputObj = UIFactory.CreateInputField(rowObj);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
m_defaultOutputInput = inputObj.GetComponent<InputField>();
|
2021-03-11 17:57:58 +11:00
|
|
|
|
m_defaultOutputInput.text = ExplorerConfig.Instance.Default_Output_Path.ToString();
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
m_defaultOutputInput.placeholder.gameObject.GetComponent<Text>().text = @"Directory, eg. Mods\UnityExplorer";
|
2020-11-08 21:04:41 +11:00
|
|
|
|
}
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
2020-11-08 21:04:41 +11:00
|
|
|
|
#endregion
|
2020-10-23 20:40:44 +11:00
|
|
|
|
}
|
|
|
|
|
}
|