예제 #1
0
        public override void DrawGUI(object sender)
        {
            if (this.core == null)
            {
                return;
            }

            GUI.skin = this.core.Skin;

            Rect _Pos = this.WindowPos;

            _Pos = ClickThruBlocker.GUILayoutWindow(
                this.core.WindowID,
                _Pos,
                VOID_Tools.GetWindowHandler(this.ModuleWindow),
                this.Name,
                GUILayout.Width(this.defWidth),
                GUILayout.Height(this.defHeight)
                );

            bool cursorInWindow = _Pos.Contains(Mouse.screenPos);

            if (cursorInWindow)
            {
                this.setUILock();
            }
            else
            {
                this.removeUILock();
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                _Pos = WindowTools.ClampRectToEditorPad(_Pos);
            }
            else
            {
                _Pos = WindowTools.ClampRectToScreen(_Pos);
            }

            if (_Pos != this.WindowPos)
            {
                this.WindowPos        = _Pos;
                this.core.configDirty = true;
            }
        }
예제 #2
0
        public void OnGUI()
        {
            // Only runs once, if the Toolbar is available.
            if (ToolbarManager.ToolbarAvailable && ARConfiguration.UseToolbarIfAvailable)
            {
                if (this.toolbarButton == null)
                {
                    this.LogDebug("Toolbar available; initializing toolbar button.");

                    if (this.appLauncherButton != null)
                    {
                        ApplicationLauncher.Instance.RemoveModApplication(this.appLauncherButton);
                        this.appLauncherButton = null;
                    }

                    this.toolbarButton             = ToolbarManager.Instance.add("AntennaRange", "ARConfiguration");
                    this.toolbarButton.Visibility  = new GameScenesVisibility(GameScenes.SPACECENTER);
                    this.toolbarButton.Text        = "AR";
                    this.toolbarButton.TexturePath = "AntennaRange/Textures/toolbarIcon";
                    this.toolbarButton.TextColor   = (Color)XKCDColors.Amethyst;
                    this.toolbarButton.OnClick    += delegate(ClickEvent e)
                    {
                        this.toggleConfigWindow();
                    };
                }
            }
            else if (this.appLauncherButton == null && ApplicationLauncher.Ready)
            {
                if (this.toolbarButton != null)
                {
                    this.toolbarButton.Destroy();
                    this.toolbarButton = null;
                }

                this.LogDebug("Toolbar available; initializing AppLauncher button.");

                this.appLauncherButton = ApplicationLauncher.Instance.AddModApplication(
                    this.toggleConfigWindow,
                    this.toggleConfigWindow,
                    ApplicationLauncher.AppScenes.SPACECENTER,
                    GameDatabase.Instance.GetTexture(
                        "AntennaRange/Textures/appLauncherIcon",
                        false
                        )
                    );
            }

            if (this.showConfigWindow)
            {
                Rect configPos = GUILayout.Window(354163056,
                                                  this.configWindowPos,
                                                  this.ConfigWindow,
                                                  string.Format("AntennaRange {0}.{1}", this.runningVersion.Major, this.runningVersion.Minor),
                                                  GUILayout.ExpandHeight(true),
                                                  GUILayout.ExpandWidth(true)
                                                  );

                configPos = WindowTools.ClampRectToScreen(configPos, 20);

                if (configPos != this.configWindowPos)
                {
                    this.configWindowPos = configPos;
                    this.SaveConfigValue(WINDOW_POS_KEY, this.configWindowPos);
                }
            }
        }