Exemple #1
0
        private void Open()
        {
            // fade menu in if already open
            if (m_ToolbarMenu != null && m_ToolbarMenu.IsFadingOut)
            {
                m_ToolbarMenu.fadeIn();
                return;
            }

            if (m_MenuPrefab == null || m_MenuObject != null)
            {
                return;
            }

            m_MenuObject = Instantiate(m_MenuPrefab, GetAnchor(), Quaternion.identity) as GameObject;
            if (m_MenuObject == null)
            {
                return;
            }

            m_MenuObject.transform.SetParent(MainCanvasUtil.MainCanvas.transform);
            m_ToolbarMenu = m_MenuObject.GetComponent <ToolbarMenu> ();
            if (m_ToolbarMenu != null)
            {
                m_ToolbarMenu.SetMenuControl(this);
                if (!NodeTools.patchedConicsUnlocked)
                {
                    m_ToolbarMenu.DisableMainWindow();
                }
            }
            GUIComponentManager.processStyle(m_MenuObject);
            GUIComponentManager.processLocalization(m_MenuObject);
            GUIComponentManager.replaceLabelsWithTMPro(m_MenuObject);
        }
        public void ReplaceInputFieldWithTMPro(InputField field, UnityAction <string> onSubmit = null, UnityAction <string> onChange = null)
        {
            var     text        = GUIComponentManager.ReplaceTextWithTMPro(field.textComponent);
            Graphic placeholder = field.placeholder;

            if (placeholder is Text)
            {
                placeholder = GUIComponentManager.ReplaceTextWithTMPro(placeholder as Text);
            }
            var contentType  = field.contentType;
            var lineType     = field.lineType;
            var charLimit    = field.characterLimit;
            var interactable = field.interactable;

            var go = field.gameObject;

            UnityEngine.Object.DestroyImmediate(field);
            inputField = go.AddOrGetComponent <TMPro.TMP_InputField> ();

            inputField.textComponent = text;
            inputField.textViewport  = text.transform as RectTransform;
            inputField.placeholder   = placeholder;
            if (onSubmit != null)
            {
                inputField.onEndEdit.AddListener(onSubmit);
            }
            if (onChange != null)
            {
                inputField.onValueChanged.AddListener(onChange);
            }
            inputField.contentType    = (TMPro.TMP_InputField.ContentType)contentType;
            inputField.lineType       = (TMPro.TMP_InputField.LineType)lineType;
            inputField.characterLimit = charLimit;
            inputField.interactable   = interactable;
        }
Exemple #3
0
        private void OpenMainWindow()
        {
            // fade in if already open
            if (m_MainWindow != null)
            {
                m_MainWindow.MoveToBackground(config.IsInBackground);
                if (m_MainWindow.IsFadingOut)
                {
                    m_MainWindow.FadeIn();
                }
                if (config.ModulesChanged)
                {
                    mainWindow.UpdateMainWindow(m_MainWindow);
                }
                return;
            }

            if (m_WindowPrefab == null || m_MainWindowObject != null)
            {
                return;
            }

            // create object
            Vector3 pos = new Vector3(config.MainWindowPos.x, config.MainWindowPos.y, MainCanvasUtil.MainCanvasRect.position.z);

            m_MainWindowObject = Instantiate(m_WindowPrefab);
            if (m_MainWindowObject == null)
            {
                return;
            }

            m_MainWindow = m_MainWindowObject.GetComponent <UI.DraggableWindow> ();
            if (m_MainWindow != null)
            {
                m_MainWindow.SetTitle(Localizer.Format("precisemaneuver_caption"));
                m_MainWindow.SetMainCanvasTransform(MainCanvasUtil.MainCanvasRect);
                mainWindow.ClearMainWindow();
                mainWindow.UpdateMainWindow(m_MainWindow);
                // should be done before moving to background
                GUIComponentManager.ReplaceLabelsWithTMPro(m_MainWindowObject);
                m_MainWindow.MoveToBackground(config.IsInBackground);
                m_MainWindow.setWindowInputLock   = SetWindow1InputLock;
                m_MainWindow.resetWindowInputLock = ResetWindow1InputLock;
            }

            GUIComponentManager.ProcessStyle(m_MainWindowObject);

            // set object as a child of the main canvas
            m_MainWindowObject.transform.SetParent(MainCanvasUtil.MainCanvas.transform);
            m_MainWindowObject.transform.position = pos;

            // do the scaling after the parent has been set
            ScaleMainWindow();
            config.ListenToScaleChange(ScaleMainWindow);
        }
        private void openMainWindow()
        {
            // fade in if already open
            if (m_MainWindow != null)
            {
                m_MainWindow.MoveToBackground(config.isInBackground);
                if (m_MainWindow.IsFadingOut)
                {
                    m_MainWindow.fadeIn();
                }
                if (config.modulesChanged)
                {
                    mainWindow.updateMainWindow(m_MainWindow);
                }
                return;
            }

            if (m_WindowPrefab == null || m_MainWindowObject != null)
            {
                return;
            }

            // create object
            Vector3 pos = new Vector3(config.mainWindowPos.x, config.mainWindowPos.y, MainCanvasUtil.MainCanvasRect.position.z);

            m_MainWindowObject = Instantiate(m_WindowPrefab, pos, Quaternion.identity) as GameObject;
            if (m_MainWindowObject == null)
            {
                return;
            }

            m_MainWindow = m_MainWindowObject.GetComponent <DraggableWindow> ();
            if (m_MainWindow != null)
            {
                m_MainWindow.SetTitle(Localizer.Format("precisemaneuver_caption"));
                m_MainWindow.setMainCanvasTransform(MainCanvasUtil.MainCanvasRect);
                mainWindow.clearMainWindow();
                mainWindow.updateMainWindow(m_MainWindow);
                m_MainWindow.MoveToBackground(config.isInBackground);
                m_MainWindow.OnWindowPointerEnter = setWindow1InputLock;
                m_MainWindow.OnWindowPointerExit  = resetWindow1InputLock;
            }
            scaleMainWindow();
            config.listenToScaleChange(scaleMainWindow);

            GUIComponentManager.processStyle(m_MainWindowObject);
            GUIComponentManager.replaceLabelsWithTMPro(m_MainWindowObject);

            // set object as a child of the main canvas
            m_MainWindowObject.transform.SetParent(MainCanvasUtil.MainCanvas.transform);
        }
        private void CreateOrbitInfoControls(GameObject panel)
        {
            if (OrbitInfoPrefab == null)
            {
                return;
            }
            var orbitinfoObj = UnityEngine.Object.Instantiate(OrbitInfoPrefab);

            GUIComponentManager.ProcessStyle(orbitinfoObj);
            GUIComponentManager.ProcessLocalization(orbitinfoObj);
            GUIComponentManager.ProcessTooltips(orbitinfoObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(orbitinfoObj);
            var orbitinfocontrol = orbitinfoObj.GetComponent <UI.OrbitInfoControl>();

            orbitinfocontrol.SetControl(new OrbitInfoControlInterface(this));
            orbitinfoObj.transform.SetParent(panel.transform, false);
        }
Exemple #6
0
        private void OpenKeybindingsWindow()
        {
            // fade in if already open
            if (m_KeybindingsWindow != null)
            {
                if (m_KeybindingsWindow.IsFadingOut)
                {
                    m_KeybindingsWindow.FadeIn();
                }
                return;
            }

            if (m_WindowPrefab == null || m_KeybindingsWindowObject != null)
            {
                return;
            }

            // create window object
            Vector3 pos = new Vector3(config.KeymapperWindowPos.x, config.KeymapperWindowPos.y, MainCanvasUtil.MainCanvasRect.position.z);

            m_KeybindingsWindowObject = Instantiate(m_WindowPrefab);
            if (m_KeybindingsWindowObject == null)
            {
                return;
            }

            // populate window
            m_KeybindingsWindow = m_KeybindingsWindowObject.GetComponent <UI.DraggableWindow> ();
            if (m_KeybindingsWindow != null)
            {
                m_KeybindingsWindow.SetTitle(Localizer.Format("precisemaneuver_keybindings_caption"));
                m_KeybindingsWindow.SetMainCanvasTransform(MainCanvasUtil.MainCanvasRect);
                hotkeys.FillKeymapperWindow(m_KeybindingsWindow);
                m_KeybindingsWindow.setWindowInputLock   = SetWindow2InputLock;
                m_KeybindingsWindow.resetWindowInputLock = ResetWindow2InputLock;
            }

            GUIComponentManager.ProcessStyle(m_KeybindingsWindowObject);
            GUIComponentManager.ProcessLocalization(m_KeybindingsWindowObject);
            GUIComponentManager.ReplaceLabelsWithTMPro(m_KeybindingsWindowObject);

            // set object as a child of the main canvas
            m_KeybindingsWindowObject.transform.SetParent(MainCanvasUtil.MainCanvas.transform);
            m_KeybindingsWindowObject.transform.position = pos;
        }
        private void CreateUtAxisControls(GameObject panel)
        {
            if (UTPrefab == null || AxisPrefab == null)
            {
                return;
            }

            var utObj = UnityEngine.Object.Instantiate(UTPrefab);

            GUIComponentManager.ProcessStyle(utObj);
            GUIComponentManager.ProcessLocalization(utObj);
            GUIComponentManager.ProcessTooltips(utObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(utObj);
            var utcontrol = utObj.GetComponent <UI.UTControl>();

            utcontrol.SetControl(new UTControlInterface(this));
            utObj.transform.SetParent(panel.transform, false);

            var progradeObj = UnityEngine.Object.Instantiate(AxisPrefab);

            GUIComponentManager.ProcessStyle(progradeObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(progradeObj);
            var progradeAxis = progradeObj.GetComponent <UI.AxisControl>();

            progradeAxis.SetControl(new AxisControlInterface(this, AxisControlInterface.Axis.prograde));
            progradeObj.transform.SetParent(panel.transform, false);

            var normalObj = UnityEngine.Object.Instantiate(AxisPrefab);

            GUIComponentManager.ProcessStyle(normalObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(normalObj);
            var normalAxis = normalObj.GetComponent <UI.AxisControl>();

            normalAxis.SetControl(new AxisControlInterface(this, AxisControlInterface.Axis.normal));
            normalObj.transform.SetParent(panel.transform, false);

            var radialObj = UnityEngine.Object.Instantiate(AxisPrefab);

            GUIComponentManager.ProcessStyle(radialObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(radialObj);
            var radialAxis = radialObj.GetComponent <UI.AxisControl>();

            radialAxis.SetControl(new AxisControlInterface(this, AxisControlInterface.Axis.radial));
            radialObj.transform.SetParent(panel.transform, false);
        }
        private void CreatePagerControls(GameObject panel)
        {
            if (PagerPrefab == null)
            {
                return;
            }

            var pagerObj = UnityEngine.Object.Instantiate(PagerPrefab);

            GUIComponentManager.ProcessStyle(pagerObj);
            GUIComponentManager.ProcessLocalization(pagerObj);
            GUIComponentManager.ProcessTooltips(pagerObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(pagerObj);
            var pagercontrol = pagerObj.GetComponent <UI.PagerControl>();

            pagercontrol.SetControl(new PagerControlInterface(this));
            pagerObj.transform.SetParent(panel.transform, false);
        }
        private void CreateGizmoControls(GameObject panel)
        {
            if (GizmoPrefab == null)
            {
                return;
            }

            var gizmoObj = UnityEngine.Object.Instantiate(GizmoPrefab);

            GUIComponentManager.ProcessStyle(gizmoObj);
            GUIComponentManager.ProcessLocalization(gizmoObj);
            GUIComponentManager.ProcessTooltips(gizmoObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(gizmoObj);
            var gizmocontrol = gizmoObj.GetComponent <UI.GizmoControl>();

            gizmocontrol.SetControl(new GizmoControlInterface(this));
            gizmoObj.transform.SetParent(panel.transform, false);
        }
        private void CreateTimeAlarmControls(GameObject panel)
        {
            if (TimeAlarmPrefab == null)
            {
                return;
            }

            var timeAlarmObj = UnityEngine.Object.Instantiate(TimeAlarmPrefab);

            GUIComponentManager.ProcessStyle(timeAlarmObj);
            GUIComponentManager.ProcessLocalization(timeAlarmObj);
            GUIComponentManager.ProcessTooltips(timeAlarmObj);
            GUIComponentManager.ReplaceLabelsWithTMPro(timeAlarmObj);
            var timealarmcontrol = timeAlarmObj.GetComponent <UI.TimeAlarmControl>();

            timealarmcontrol.SetControl(new TimeAlarmControlInterface(this));
            GUIComponentManager.ReplaceLabelsWithTMPro(timeAlarmObj);
            timeAlarmObj.transform.SetParent(panel.transform, false);
        }
        public UnityAction <string> ReplaceTextComponentWithTMPro(Text text)
        {
            var ugui = GUIComponentManager.ReplaceTextWithTMPro(text);

            return(ugui.SetText);
        }
            public UnityEngine.Events.UnityAction <string> replaceTextComponentWithTMPro(Text text)
            {
                var ugui = GUIComponentManager.replaceTextWithTMPro(text);

                return(ugui.SetText);
            }