Esempio n. 1
0
        public void AddElement(SettingsField field)
        {
            elementChildren.Add(field);
            var content = pageObject.transform.Find("Viewport/Content").gameObject;

            field.initializedObject = Instantiate(FindObjectOfType <Core>().uiManager.BuildUiElement(field.name, field.type), content.transform); // instantiate UI element
            var rt = field.initializedObject.GetComponent <RectTransform>();                                                                      //get rect transform

            rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, -height);                                                                    // set elements position
            height    += (int)rt.rect.height;
            field.page = this;
            content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, height);            //set height of conent element
            if (field.type == UiType.Float || field.type == UiType.Int)
            {
                var slider = field.initializedObject.GetComponentInChildren <Slider>();
                slider.maxValue = field.maxValue;
                slider.minValue = field.minValue;
            }
        }
        private void SetupElement(SettingsField setting, MenuPage parent)
        {
            string[] path        = setting.menuPath.Split('/');
            MenuPage currentPage = parent;

            foreach (var page in path)
            {
                bool pageExists = false;
                foreach (var menuPage in allPages)
                {
                    if (string.Equals(page, menuPage.pageName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        pageExists  = true;
                        currentPage = menuPage;
                    }
                }
                if (!pageExists)
                {
                    currentPage = CreatePage(page, currentPage);
                }
            }
            currentPage.AddElement(setting);
            setting.SetupListeners();
        }
Esempio n. 3
0
        /// <summary>
        /// Add all integrated settings to Settings manager (UI) and add listeners to inputs
        /// </summary>
        private void InitializeSettings()
        {
            List <SettingsField> coreSettings = new List <SettingsField>();

            {
                SettingsField setting = new SettingsField("Song save Path", UiType.Text, uiManager.textPrefab, "Settings/Files", config.songSavePath);
                setting.stringCall = delegate(string arg0) { config.songSavePath = arg0; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Plugin save Path", UiType.Text, uiManager.textPrefab, "Settings/Files", config.pluginSavePath);
                setting.stringCall = delegate(string arg0) { config.pluginSavePath = arg0; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("keyboard config Path", UiType.Text, uiManager.textPrefab, "Settings/Files", config.keyboardSavePath);
                setting.stringCall = delegate(string arg0) { config.keyboardSavePath = arg0; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Use Steam Username", UiType.Bool, uiManager.boolPrefab, "Settings/Player", config.useSteamUsername);
                setting.boolCall = delegate(bool arg0) { config.useSteamUsername = arg0; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Local Username", UiType.Text, uiManager.textPrefab, "Settings/Player", config.localUsername);
                setting.stringCall = delegate(string arg0) { config.localUsername = arg0; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Super Sampling", UiType.Float, uiManager.floatPrefab, "Settings/Video", config.superSampling);
                setting.floatCall = delegate(float arg0) { config.superSampling = arg0; };
                setting.maxValue  = 5;
                setting.minValue  = 0.2f;
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Camera Smoothing (desktop)", UiType.Int, uiManager.intPrefab, "Settings/Video", config.cameraSmoothing);
                setting.floatCall = delegate(float arg0) { config.cameraSmoothing = (int)arg0; };
                setting.maxValue  = 10;
                setting.minValue  = 0;
                coreSettings.Add(setting);
            }

            {
                Vector3       initialValue = new Vector3(config.playspacePosition[0], config.playspacePosition[1], config.playspacePosition[2]);
                SettingsField setting      = new SettingsField("Position", UiType.Vector3, uiManager.vector3Prefab, "Settings/Offsets/Playspace", initialValue);
                setting.vectorNCall = delegate(int arg0, float arg1) { config.playspacePosition[arg0] = arg1; };
                coreSettings.Add(setting);
            }

            {
                Vector3       initialValue = new Vector3(config.playspaceRotation[0], config.playspaceRotation[1], config.playspaceRotation[2]);
                SettingsField setting      = new SettingsField("Rotation", UiType.Vector3, uiManager.vector3Prefab, "Settings/Offsets/Playspace", initialValue);
                setting.vectorNCall = delegate(int arg0, float arg1) { config.playspaceRotation[arg0] = arg1; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Reset", UiType.Button, uiManager.buttonPrefab, "Settings/Offsets/Playspace");
                setting.buttonCall = delegate() {
                    config.playspacePosition = new float[] { 0, 0, 0 };
                    config.playspaceRotation = new float[] { 0, 0, 0 };
                    setting.page.elementChildren[0].SetValues(new Vector3(0, 0, 0));
                    setting.page.elementChildren[1].SetValues(new Vector3(0, 0, 0));
                };
                coreSettings.Add(setting);
            }

            {
                Vector3       initialValue = new Vector3(config.controllerPosition[0], config.controllerPosition[1], config.controllerPosition[2]);
                SettingsField setting      = new SettingsField("Position", UiType.Vector3, uiManager.vector3Prefab, "Settings/Offsets/Controller", initialValue);
                setting.vectorNCall = delegate(int arg0, float arg1) { config.controllerPosition[arg0] = arg1; };
                coreSettings.Add(setting);
            }

            {
                Vector3       initialValue = new Vector3(config.controllerRotation[0], config.controllerRotation[1], config.controllerRotation[2]);
                SettingsField setting      = new SettingsField("Rotation", UiType.Vector3, uiManager.vector3Prefab, "Settings/Offsets/Controller", initialValue);
                setting.vectorNCall = delegate(int arg0, float arg1) { config.controllerRotation[arg0] = arg1; };
                coreSettings.Add(setting);
            }

            {
                SettingsField setting = new SettingsField("Reset", UiType.Button, uiManager.buttonPrefab, "Settings/Offsets/Controller");
                setting.buttonCall = delegate() {
                    config.controllerPosition = new float[] { 0, 0, 0 };
                    config.controllerRotation = new float[] { 0, 0, 0 };
                    setting.page.elementChildren[0].SetValues(new Vector3(0, 0, 0));
                    setting.page.elementChildren[1].SetValues(new Vector3(0, 0, 0));
                };
                coreSettings.Add(setting);
            }


            settingsManager.settings.AddRange(coreSettings);
            settingsManager.settingsMenuParent = uiManager.settingsMenu;
            settingsManager.UpdateSettingsUi();
        }