Exemplo n.º 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);
        }
        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, pos, Quaternion.identity) as GameObject;
            if (m_KeybindingsWindowObject == null)
            {
                return;
            }

            // populate window
            m_KeybindingsWindow = m_KeybindingsWindowObject.GetComponent <DraggableWindow>();
            if (m_KeybindingsWindow != null)
            {
                m_KeybindingsWindow.SetTitle(Localizer.Format("precisemaneuver_keybindings_caption"));
                m_KeybindingsWindow.setMainCanvasTransform(MainCanvasUtil.MainCanvasRect);
                hotkeys.fillKeymapperWindow(m_KeybindingsWindow);
                m_KeybindingsWindow.OnWindowPointerEnter = setWindow2InputLock;
                m_KeybindingsWindow.OnWindowPointerExit  = 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);
        }