コード例 #1
0
            public void DrawDebug(Vector3 currentWorldPos, List <Vector3> waypoints = null)
            {
                Vector3 upVec = VectorUtils.GetUpDirection(currentWorldPos) * 10;

                if (BDArmorySettings.DISPLAY_PATHING_GRID)
                {
                    using (var kvp = grid.GetEnumerator())
                        while (kvp.MoveNext())
                        {
                            BDGUIUtils.DrawLineBetweenWorldPositions(kvp.Current.Value.WorldPos, kvp.Current.Value.WorldPos + upVec, 3,
                                                                     kvp.Current.Value.Traversable ? Color.green : Color.red);
                        }
                }
                if (waypoints != null)
                {
                    var previous = currentWorldPos;
                    using (var wp = waypoints.GetEnumerator())
                        while (wp.MoveNext())
                        {
                            var c = VectorUtils.GetWorldSurfacePostion(wp.Current, body);
                            BDGUIUtils.DrawLineBetweenWorldPositions(previous + upVec, c + upVec, 2, Color.cyan);
                            previous = c;
                        }
                }
            }
コード例 #2
0
        public static void DrawPointer(Vector2 Pointer, Vector2 Tail, float width, Color color)
        {
            Camera cam = BDGUIUtils.GetMainCamera();

            if (cam == null)
            {
                return;
            }

            GUI.matrix = Matrix4x4.identity;

            float angle = Vector2.Angle(Vector3.up, Tail - Pointer);

            if (Tail.x < Pointer.x)
            {
                angle = -angle;
            }
            float theta = Mathf.Abs(angle);

            if (theta > 90)
            {
                theta -= 90;
            }
            theta = theta * Mathf.Deg2Rad;             //needs to be in radians for Mathf. trig
            float length     = 60;
            float HalfWidth  = Screen.width / 2;
            float HalfHeight = Screen.height / 2;
            float Cos        = Mathf.Cos(theta);
            float Sin        = Mathf.Sin(theta);

            if (Pointer.y >= HalfHeight)
            {
                if (Pointer.x >= HalfWidth)                 // set up Quads 3-4
                {
                    Pointer.x = (Cos * (0.75f * HalfWidth)) + HalfWidth;
                }
                else
                {
                    Pointer.x = HalfWidth - ((Cos * 0.75f) * HalfWidth);
                }
                Pointer.y = (Sin * (0.75f * HalfHeight)) + HalfHeight;
            }
            else
            {
                if (Pointer.x >= HalfWidth)                 // set up Quads 1-2
                {
                    Pointer.x = (Sin * (0.75f * HalfWidth)) + HalfWidth;
                }
                else
                {
                    Pointer.x = HalfWidth - ((Sin * 0.75f) * HalfWidth);
                }
                Pointer.y = HalfHeight - ((Cos * 0.75f) * HalfHeight);
            }
            Rect upRect = new Rect(Pointer.x - (width / 2), Pointer.y - length, width, length);

            GUIUtility.RotateAroundPivot(-angle + 180, Pointer);
            BDGUIUtils.DrawRectangle(upRect, color);
            GUI.matrix = Matrix4x4.identity;
        }
コード例 #3
0
        public void GUIWindow(int windowID)
        {
            InitializeStyles();

            GUILayout.BeginVertical();
            GUILayout.Space(20);

            GUILayout.BeginHorizontal();

            GUILayout.Label("Weapon Name: ");


            txtName = GUILayout.TextField(txtName);


            if (GUILayout.Button("Save & Close"))
            {
                missile_module.WeaponName = txtName;
                missile_module.shortName  = txtName;
                instance.missile_module.HideUI();
            }

            GUILayout.EndHorizontal();

            scrollPos = GUILayout.BeginScrollView(scrollPos);

            GUILayout.EndScrollView();

            GUILayout.EndVertical();

            GUI.DragWindow();
            BDGUIUtils.RepositionWindow(ref guiWindowRect);
        }
コード例 #4
0
 void OnGUI()
 {
     if (((HighLogic.LoadedSceneIsFlight && BDArmorySetup.GAME_UI_ENABLED && !MapView.MapIsEnabled && BDTISettings.TEAMICONS) || HighLogic.LoadedSceneIsFlight && !BDArmorySetup.GAME_UI_ENABLED && !MapView.MapIsEnabled && BDTISettings.TEAMICONS && BDTISettings.PERSISTANT) && BDTISettings.MISSILES)
     {
         if (distanceFromStart > 100)
         {
             BDGUIUtils.DrawTextureOnWorldPos(transform.position, BDTISetup.Instance.TextureIconRocket, new Vector2(20, 20), 0);
         }
     }
 }
コード例 #5
0
 void OnGUI()
 {
     if (setupComplete)
     {
         for (int i = 0; i < localAnchors.Length; i++)
         {
             BDGUIUtils.DrawTextureOnWorldPos(parentTransform.TransformPoint(localAnchors[i]),
                                              BDArmorySetup.Instance.greenDotTexture, new Vector2(6, 6), 0);
         }
     }
 }
コード例 #6
0
 void OnGUI()
 {
     if (drawGUI)
     {
         if (boresightScan)
         {
             BDGUIUtils.DrawTextureOnWorldPos(transform.position + (3500 * transform.up),
                                              BDArmorySetup.Instance.dottedLargeGreenCircle, new Vector2(156, 156), 0);
         }
     }
 }
コード例 #7
0
        void RWRWindow(int windowID)
        {
            GUI.DragWindow(new Rect(0, 0, BDArmorySetup.WindowRectRwr.width - 18, 30));
            if (GUI.Button(new Rect(BDArmorySetup.WindowRectRwr.width - 18, 2, 16, 16), "X", GUI.skin.button))
            {
                DisableRWR();
            }
            GUI.BeginGroup(new Rect(BorderSize / 2, HeaderSize + (BorderSize / 2), RwrDisplayRect.width, RwrDisplayRect.height));
            GUI.DragWindow(RwrDisplayRect);

            GUI.DrawTexture(RwrDisplayRect, VesselRadarData.omniBgTexture, ScaleMode.StretchToFill, false);
            float pingSize = 32 * BDArmorySettings.RWR_WINDOW_SCALE;

            for (int i = 0; i < dataCount; i++)
            {
                Vector2 pingPosition = (Vector2)pingsData[i].position;
                //pingPosition = Vector2.MoveTowards(displayRect.center, pingPosition, displayRect.center.x - (pingSize/2));
                Rect pingRect = new Rect(pingPosition.x - (pingSize / 2), pingPosition.y - (pingSize / 2), pingSize,
                                         pingSize);

                if (!pingsData[i].exists)
                {
                    continue;
                }
                if (pingsData[i].signalStrength == (float)RWRThreatTypes.MissileLock) //Hack! Evil misuse of field signalstrength...
                {
                    GUI.DrawTexture(pingRect, rwrMissileTexture, ScaleMode.StretchToFill, true);
                }
                else
                {
                    GUI.DrawTexture(pingRect, rwrDiamondTexture, ScaleMode.StretchToFill, true);
                    GUI.Label(pingRect, iconLabels[Mathf.RoundToInt(pingsData[i].signalStrength)], rwrIconLabelStyle); //Hack! Evil misuse of field signalstrength...
                }
            }

            List <TargetSignatureData> .Enumerator lw = launchWarnings.GetEnumerator();
            while (lw.MoveNext())
            {
                Vector2 pingPosition = (Vector2)lw.Current.position;
                //pingPosition = Vector2.MoveTowards(displayRect.center, pingPosition, displayRect.center.x - (pingSize/2));

                Rect pingRect = new Rect(pingPosition.x - (pingSize / 2), pingPosition.y - (pingSize / 2), pingSize,
                                         pingSize);
                GUI.DrawTexture(pingRect, rwrMissileTexture, ScaleMode.StretchToFill, true);
            }
            lw.Dispose();
            GUI.EndGroup();
            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectRwr);
        }
コード例 #8
0
        void OnGUI()
        {
            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && BDArmorySetup.GAME_UI_ENABLED &&
                vessel.isActiveVessel && rwrEnabled)
            {
                if (audioSourceRepeatDelay > 0)
                {
                    audioSourceRepeatDelay -= Time.fixedDeltaTime;
                }

                BDArmorySetup.WindowRectRwr = GUI.Window(94353, BDArmorySetup.WindowRectRwr, RWRWindow,
                                                         "Radar Warning Receiver", HighLogic.Skin.window);
                BDGUIUtils.UseMouseEventInRect(BDArmorySetup.WindowRectRwr);
            }
        }
コード例 #9
0
        private static void DrawOnScreenIcon(Vector3 worldPos, Texture texture, Vector2 size, Color Teamcolor)
        {
            if (Event.current.type.Equals(EventType.Repaint))
            {
                Material IconMat;
                bool     offscreen = false;
                Vector3  screenPos = BDGUIUtils.GetMainCamera().WorldToViewportPoint(worldPos);
                if (screenPos.z < 0)
                {
                    offscreen    = true;
                    screenPos.x *= -1;
                    screenPos.y *= -1;
                }
                if (screenPos.x != Mathf.Clamp01(screenPos.x))
                {
                    offscreen = true;
                }
                if (screenPos.y != Mathf.Clamp01(screenPos.y))
                {
                    offscreen = true;
                }
                float xPos  = (screenPos.x * Screen.width) - (0.5f * size.x);
                float yPos  = ((1 - screenPos.y) * Screen.height) - (0.5f * size.y);
                float xtPos = 1 * (Screen.width / 2);
                float ytPos = 1 * (Screen.height / 2);
                if (offscreen && TeamIconSettings.POINTERS)
                {
                    Vector2 pointer;
                    Vector2 tail;

                    pointer.x = xPos;
                    pointer.y = yPos;
                    tail.x    = xtPos;
                    tail.y    = ytPos;

                    DrawPointer(pointer, tail, 4, Teamcolor);
                }
                else
                {
                    IconMat = new Material(Shader.Find("KSP/Particles/Alpha Blended"));
                    IconMat.SetColor("_TintColor", Teamcolor);
                    IconMat.mainTexture = texture;
                    Rect iconRect   = new Rect(xPos, yPos, size.x, size.y);
                    Rect sourceRect = new Rect(0, 0, 40 * TeamIconSettings.ICONSCALE, 40 * TeamIconSettings.ICONSCALE);
                    Graphics.DrawTexture(iconRect, texture, IconMat);
                }
            }
        }
コード例 #10
0
        void OnGUI()
        {
            if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready || !BDArmorySetup.GAME_UI_ENABLED ||
                !vessel.isActiveVessel || !displayRWR)
            {
                return;
            }
            if (audioSourceRepeatDelay > 0)
            {
                audioSourceRepeatDelay -= Time.fixedDeltaTime;
            }

            if (Event.current.type == EventType.MouseUp && resizingWindow)
            {
                resizingWindow = false;
            }

            BDArmorySetup.WindowRectRwr = GUI.Window(94353, BDArmorySetup.WindowRectRwr, WindowRwr, "Radar Warning Receiver", GUI.skin.window);
            BDGUIUtils.UseMouseEventInRect(RwrDisplayRect);
        }
コード例 #11
0
        protected override void OnGUI()
        {
            base.OnGUI();

            if (!pilotEnabled || !vessel.isActiveVessel)
            {
                return;
            }

            if (!BDArmorySettings.DRAW_DEBUG_LINES)
            {
                return;
            }
            if (command == PilotCommands.Follow)
            {
                BDGUIUtils.DrawLineBetweenWorldPositions(vesselTransform.position, assignedPositionWorld, 2, Color.red);
            }

            BDGUIUtils.DrawLineBetweenWorldPositions(vesselTransform.position, vesselTransform.position + targetDirection * 10f, 2, Color.blue);
            BDGUIUtils.DrawLineBetweenWorldPositions(vesselTransform.position + (0.05f * vesselTransform.right), vesselTransform.position + (0.05f * vesselTransform.right), 2, Color.green);

            pathingMatrix.DrawDebug(vessel.CoM, waypoints);
        }
コード例 #12
0
        private void ListWindow(int id)
        {
            GUI.DragWindow(new Rect(0, 0, _windowWidth - _buttonHeight - 4, _titleHeight));
            if (GUI.Button(new Rect(_windowWidth - _buttonHeight - 4, 4, _buttonHeight, _buttonHeight), "X",
                           BDArmorySetup.BDGuiSkin.button))
            {
                BDArmorySetup.Instance.showVSGUI = false;
                return;
            }
            float height      = 0;
            float vesselLineA = 0;
            float vesselLineB = 0;

            height += _margin + _titleHeight;
            GUI.Label(new Rect(_margin, height, _windowWidth - 2 * _margin, _buttonHeight), "Team A:", BDArmorySetup.BDGuiSkin.label);
            height += _buttonHeight;
            float vesselButtonWidth = _windowWidth - 2 * _margin;

            vesselButtonWidth -= 3 * _buttonHeight;

            List <MissileFire> .Enumerator wma = _wmgrsA.GetEnumerator();
            while (wma.MoveNext())
            {
                if (wma.Current == null)
                {
                    continue;
                }
                float    lineY        = height + vesselLineA * (_buttonHeight + _buttonGap);
                Rect     buttonRect   = new Rect(_margin, lineY, vesselButtonWidth, _buttonHeight);
                GUIStyle vButtonStyle = wma.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

                string status = UpdateVesselStatus(wma.Current, vButtonStyle);

                if (GUI.Button(buttonRect, status + wma.Current.vessel.GetName(), vButtonStyle))
                {
                    ForceSwitchVessel(wma.Current.vessel);
                }

                //guard toggle
                GUIStyle guardStyle      = wma.Current.guardMode ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;
                Rect     guardButtonRect = new Rect(_margin + vesselButtonWidth, lineY, _buttonHeight, _buttonHeight);
                if (GUI.Button(guardButtonRect, "G", guardStyle))
                {
                    wma.Current.ToggleGuardMode();
                }

                //AI toggle
                if (wma.Current.AI != null)
                {
                    GUIStyle aiStyle      = wma.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;
                    Rect     aiButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, lineY, _buttonHeight,
                                                     _buttonHeight);
                    if (GUI.Button(aiButtonRect, "P", aiStyle))
                    {
                        wma.Current.AI.TogglePilot();
                    }
                }

                //team toggle
                Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight + _buttonHeight, lineY,
                                               _buttonHeight, _buttonHeight);
                if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button))
                {
                    _wmToSwitchTeam  = wma.Current;
                    _teamSwitchDirty = true;
                }
                vesselLineA++;
            }
            wma.Dispose();

            height += vesselLineA * (_buttonHeight + _buttonGap);
            height += _margin;
            GUI.Label(new Rect(_margin, height, _windowWidth - 2 * _margin, _buttonHeight), "Team B:", BDArmorySetup.BDGuiSkin.label);
            height += _buttonHeight;

            List <MissileFire> .Enumerator wmb = _wmgrsB.GetEnumerator();
            while (wmb.MoveNext())
            {
                if (wmb.Current == null)
                {
                    continue;
                }
                float lineY = height + vesselLineB * (_buttonHeight + _buttonGap);

                Rect     buttonRect   = new Rect(_margin, lineY, vesselButtonWidth, _buttonHeight);
                GUIStyle vButtonStyle = wmb.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

                string status = UpdateVesselStatus(wmb.Current, vButtonStyle);


                if (GUI.Button(buttonRect, status + wmb.Current.vessel.GetName(), vButtonStyle))
                {
                    ForceSwitchVessel(wmb.Current.vessel);
                }


                //guard toggle
                GUIStyle guardStyle      = wmb.Current.guardMode ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;
                Rect     guardButtonRect = new Rect(_margin + vesselButtonWidth, lineY, _buttonHeight, _buttonHeight);
                if (GUI.Button(guardButtonRect, "G", guardStyle))
                {
                    wmb.Current.ToggleGuardMode();
                }

                //AI toggle
                if (wmb.Current.AI != null)
                {
                    GUIStyle aiStyle      = wmb.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;
                    Rect     aiButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, lineY, _buttonHeight,
                                                     _buttonHeight);
                    if (GUI.Button(aiButtonRect, "P", aiStyle))
                    {
                        wmb.Current.AI.TogglePilot();
                    }
                }

                //team toggle
                Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight + _buttonHeight, lineY,
                                               _buttonHeight, _buttonHeight);
                if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button))
                {
                    _wmToSwitchTeam  = wmb.Current;
                    _teamSwitchDirty = true;
                }
                vesselLineB++;
            }
            height += vesselLineB * (_buttonHeight + _buttonGap);
            height += _margin;

            _windowHeight = height;
            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSwitcher);
        }
コード例 #13
0
        void OnGUI()
        {
            if ((HighLogic.LoadedSceneIsFlight && BDArmorySetup.GAME_UI_ENABLED && !MapView.MapIsEnabled && TeamIconSettings.TEAMICONS) || HighLogic.LoadedSceneIsFlight && !BDArmorySetup.GAME_UI_ENABLED && !MapView.MapIsEnabled && TeamIconSettings.TEAMICONS && TeamIconSettings.PERSISTANT)
            {
                Texture icon;
                float   size = 40;

                using (List <Vessel> .Enumerator v = FlightGlobals.Vessels.GetEnumerator())
                    while (v.MoveNext())
                    {
                        if (v.Current == null)
                        {
                            continue;
                        }
                        if (!v.Current.loaded || v.Current.packed || v.Current.isActiveVessel)
                        {
                            continue;
                        }

                        if (TeamIconSettings.MISSILES)
                        {
                            using (List <MissileBase> .Enumerator ml = v.Current.FindPartModulesImplementing <MissileBase>().GetEnumerator())
                                while (ml.MoveNext())
                                {
                                    if (ml.Current == null)
                                    {
                                        continue;
                                    }
                                    if (ml.Current.MissileState != MissileBase.MissileStates.Idle && ml.Current.MissileState != MissileBase.MissileStates.Drop)
                                    {
                                        Vector3 sPos = FlightGlobals.ActiveVessel.vesselTransform.position;
                                        Vector3 tPos = v.Current.vesselTransform.position;
                                        Vector3 Dist = (tPos - sPos);
                                        Vector2 guiPos;
                                        string  UIdist;
                                        string  UoM;
                                        if (Dist.magnitude > 100)
                                        {
                                            if ((Dist.magnitude / 1000) >= 1)
                                            {
                                                UoM    = "km";
                                                UIdist = (Dist.magnitude / 1000).ToString("0.00");
                                            }
                                            else
                                            {
                                                UoM    = "m";
                                                UIdist = Dist.magnitude.ToString("0.0");
                                            }
                                            BDGUIUtils.DrawTextureOnWorldPos(v.Current.CoM, BDATISetup.Instance.TextureIconMissile, new Vector2(20, 20), 0);
                                            if (BDGUIUtils.WorldToGUIPos(ml.Current.vessel.CoM, out guiPos))
                                            {
                                                Rect distRect = new Rect((guiPos.x - 12), (guiPos.y + 10), 100, 32);
                                                GUI.Label(distRect, UIdist + UoM, mIStyle);
                                            }
                                        }
                                    }
                                }
                        }
                        if (TeamIconSettings.DEBRIS)
                        {
                            if (v.Current.vesselType != VesselType.Debris && !v.Current.isActiveVessel)
                            {
                                continue;
                            }
                            if (v.Current.LandedOrSplashed)
                            {
                                continue;
                            }
                            {
                                Vector3 sPos = FlightGlobals.ActiveVessel.vesselTransform.position;
                                Vector3 tPos = v.Current.vesselTransform.position;
                                Vector3 Dist = (tPos - sPos);
                                if (Dist.magnitude > 100)
                                {
                                    BDGUIUtils.DrawTextureOnWorldPos(v.Current.CoM, BDATISetup.Instance.TextureIconDebris, new Vector2(20, 20), 0);
                                }
                            }
                        }
                    }
                int Teamcount = 0;
                using (var teamManagers = weaponManagers.GetEnumerator())
                    while (teamManagers.MoveNext())
                    {
                        Teamcount++;
                        using (var wm = teamManagers.Current.Value.GetEnumerator())
                            while (wm.MoveNext())
                            {
                                if (wm.Current == null)
                                {
                                    continue;
                                }

                                if (wm.Current.vessel.isActiveVessel)
                                {
                                    continue;
                                }

                                Vector3 selfPos      = FlightGlobals.ActiveVessel.CoM;
                                Vector3 targetPos    = (wm.Current.vessel.CoM);
                                Vector3 targetRelPos = (targetPos - selfPos);
                                Vector2 guiPos;
                                float   distance;
                                string  UIdist;
                                string  UoM;
                                string  vName;
                                distance = targetRelPos.magnitude;
                                if (distance >= 100)
                                {
                                    if ((distance / 1000) >= 1)
                                    {
                                        UoM    = "km";
                                        UIdist = (distance / 1000).ToString("0.00");
                                    }
                                    else
                                    {
                                        UoM    = "m";
                                        UIdist = distance.ToString("0.0");
                                    }
                                    if ((wm.Current.vessel.vesselType == VesselType.Ship && !wm.Current.vessel.Splashed) || wm.Current.vessel.vesselType == VesselType.Plane)
                                    {
                                        icon = BDATISetup.Instance.TextureIconPlane;
                                    }
                                    else if (wm.Current.vessel.vesselType == VesselType.Base || wm.Current.vessel.vesselType == VesselType.Lander)
                                    {
                                        icon = BDATISetup.Instance.TextureIconBase;
                                    }
                                    else if (wm.Current.vessel.vesselType == VesselType.Rover)
                                    {
                                        icon = BDATISetup.Instance.TextureIconRover;
                                    }
                                    else if (wm.Current.vessel.vesselType == VesselType.Probe)
                                    {
                                        icon = BDATISetup.Instance.TextureIconProbe;
                                    }
                                    else if (wm.Current.vessel.vesselType == VesselType.Ship && wm.Current.vessel.Splashed)
                                    {
                                        icon = BDATISetup.Instance.TextureIconShip;
                                        if (wm.Current.vessel.vesselType == VesselType.Ship && wm.Current.vessel.altitude < -10)
                                        {
                                            icon = BDATISetup.Instance.TextureIconSub;
                                        }
                                    }
                                    else if (wm.Current.vessel.vesselType == VesselType.Debris)
                                    {
                                        icon = BDATISetup.Instance.TextureIconDebris;
                                        size = 20;
                                    }
                                    else
                                    {
                                        icon = BDATISetup.Instance.TextureIconGeneric;
                                    }
                                    if (Teamcount == 1)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_1_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_1_COLOR);
                                    }
                                    else if (Teamcount == 2)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_2_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_2_COLOR);
                                    }
                                    else if (Teamcount == 3)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_3_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_3_COLOR);
                                    }
                                    else if (Teamcount == 4)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_4_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_4_COLOR);
                                    }
                                    else if (Teamcount == 5)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_5_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_5_COLOR);
                                    }
                                    else if (Teamcount == 6)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_6_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_6_COLOR);
                                    }
                                    else if (Teamcount == 7)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_7_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_7_COLOR);
                                    }
                                    else if (Teamcount == 8)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_8_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_8_COLOR);
                                    }
                                    else if (Teamcount == 9)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_1_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_9_COLOR);
                                    }
                                    else if (Teamcount == 10)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_2_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_10_COLOR);
                                    }
                                    else if (Teamcount == 11)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_3_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_11_COLOR);
                                    }
                                    else if (Teamcount == 12)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_4_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_12_COLOR);
                                    }
                                    else if (Teamcount == 13)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_5_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_13_COLOR);
                                    }
                                    else if (Teamcount == 14)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_6_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_14_COLOR);
                                    }
                                    else if (Teamcount == 15)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_7_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_15_COLOR);
                                    }
                                    else if (Teamcount == 16)
                                    {
                                        IconUIStyle.normal.textColor = Misc.ParseColor255(TeamIconSettings.TEAM_8_COLOR);
                                        Teamcolor = Misc.ParseColor255(TeamIconSettings.TEAM_16_COLOR);
                                    }
                                    else
                                    {
                                        IconUIStyle.normal.textColor = XKCDColors.Grey;
                                        Teamcolor = XKCDColors.Grey;
                                    }
                                    DrawOnScreenIcon(wm.Current.vessel.CoM, icon, new Vector2((size * TeamIconSettings.ICONSCALE), (size * TeamIconSettings.ICONSCALE)), Teamcolor);
                                    if (BDGUIUtils.WorldToGUIPos(wm.Current.vessel.CoM, out guiPos))
                                    {
                                        if (TeamIconSettings.VESSELNAMES)
                                        {
                                            vName = wm.Current.vessel.vesselName;
                                            Rect nameRect = new Rect((guiPos.x + (24 * TeamIconSettings.ICONSCALE)), guiPos.y - 4, 100, 32);
                                            GUI.Label(nameRect, vName, IconUIStyle);
                                        }
                                        Rect distRect = new Rect((guiPos.x - 12), (guiPos.y + (20 * TeamIconSettings.ICONSCALE)), 100, 32);
                                        GUI.Label(distRect, UIdist + UoM, IconUIStyle);
                                        if (TeamIconSettings.TEAMNAMES)
                                        {
                                            Rect teamRect = new Rect((guiPos.x + (11 * TeamIconSettings.ICONSCALE)), (guiPos.y - (19 * TeamIconSettings.ICONSCALE)), 16, 16);
                                            GUI.Label(teamRect, "Team: " + $"{wm.Current.Team.Name}", IconUIStyle);
                                        }
                                    }
                                }
                            }
                    }
            }
        }
コード例 #14
0
        void WingmenWindow(int windowID)
        {
            float height = buttonStartY;

            GUI.DragWindow(new Rect(0, 0, BDArmorySetup.WindowRectWingCommander.width - buttonStartY - margin - margin, buttonStartY));

            //close buttton
            float xSize = buttonStartY - margin - margin;

            if (GUI.Button(new Rect(buttonWidth + (2 * buttonGap) - xSize, margin, xSize, xSize), "X",
                           BDArmorySetup.BDGuiSkin.button))
            {
                showGUI = false;
            }

            GUI.Box(
                new Rect(margin - buttonGap, buttonStartY - buttonGap, buttonWidth + (2 * buttonGap),
                         Mathf.Max(wingmen.Count * (buttonHeight + buttonGap), 10)), GUIContent.none, BDArmorySetup.BDGuiSkin.box);
            buttonEndY = buttonStartY;
            for (int i = 0; i < wingmen.Count; i++)
            {
                WingmanButton(i, out buttonEndY);
            }
            buttonEndY = Mathf.Max(buttonEndY, 15f);
            height    += buttonEndY;

            //command buttons
            float commandButtonLine = 0;

            CommandButton(SelectAll, Localizer.Format("#LOC_BDArmory_WingCommander_SelectAll"), ref commandButtonLine, false, false);//"Select All"
            //commandButtonLine += 0.25f;

            commandSelf =
                GUI.Toggle(
                    new Rect(margin, margin + buttonEndY + (commandButtonLine * (buttonHeight + buttonGap)), buttonWidth,
                             buttonHeight), commandSelf, Localizer.Format("#LOC_BDArmory_WingCommander_CommandSelf"), BDArmorySetup.BDGuiSkin.toggle);//"Command Self"
            commandButtonLine++;

            commandButtonLine += 0.10f;

            CommandButton(CommandFollow, Localizer.Format("#LOC_BDArmory_WingCommander_Follow"), ref commandButtonLine, true, false);                  //"Follow"
            CommandButton(CommandFlyTo, Localizer.Format("#LOC_BDArmory_WingCommander_FlyToPos"), ref commandButtonLine, true, waitingForFlytoPos);    //"Fly To Pos"
            CommandButton(CommandAttack, Localizer.Format("#LOC_BDArmory_WingCommander_AttackPos"), ref commandButtonLine, true, waitingForAttackPos); //"Attack Pos"
            CommandButton(OpenAGWindow, Localizer.Format("#LOC_BDArmory_WingCommander_ActionGroup"), ref commandButtonLine, false, showAGWindow);      //"Action Group"
            CommandButton(CommandTakeOff, Localizer.Format("#LOC_BDArmory_WingCommander_TakeOff"), ref commandButtonLine, true, false);                //"Take Off"
            commandButtonLine += 0.5f;
            CommandButton(CommandRelease, Localizer.Format("#LOC_BDArmory_WingCommander_Release"), ref commandButtonLine, true, false);                //"Release"

            commandButtonLine += 0.5f;
            GUI.Label(
                new Rect(margin, buttonEndY + margin + (commandButtonLine * (buttonHeight + buttonGap)), buttonWidth, 20),
                Localizer.Format("#LOC_BDArmory_WingCommander_FormationSettings") + ":", BDArmorySetup.BDGuiSkin.label);//Formation Settings
            commandButtonLine++;
            GUI.Label(
                new Rect(margin, buttonEndY + margin + (commandButtonLine * (buttonHeight + buttonGap)), buttonWidth / 3, 20),
                Localizer.Format("#LOC_BDArmory_WingCommander_Spread") + ": " + spread.ToString("0"), BDArmorySetup.BDGuiSkin.label);//Spread
            spread =
                GUI.HorizontalSlider(
                    new Rect(margin + (buttonWidth / 3),
                             buttonEndY + margin + (commandButtonLine * (buttonHeight + buttonGap)), 2 * buttonWidth / 3, 20),
                    spread, 1f, 200f, BDArmorySetup.BDGuiSkin.horizontalSlider, BDArmorySetup.BDGuiSkin.horizontalSliderThumb);
            commandButtonLine++;
            GUI.Label(
                new Rect(margin, buttonEndY + margin + (commandButtonLine * (buttonHeight + buttonGap)), buttonWidth / 3, 20),
                Localizer.Format("#LOC_BDArmory_WingCommander_Lag") + ": " + lag.ToString("0"), BDArmorySetup.BDGuiSkin.label);//Lag
            lag =
                GUI.HorizontalSlider(
                    new Rect(margin + (buttonWidth / 3),
                             buttonEndY + margin + (commandButtonLine * (buttonHeight + buttonGap)), 2 * buttonWidth / 3, 20), lag,
                    0f, 100f, BDArmorySetup.BDGuiSkin.horizontalSlider, BDArmorySetup.BDGuiSkin.horizontalSliderThumb);
            commandButtonLine++;

            //resize window
            height += ((commandButtonLine - 1) * (buttonHeight + buttonGap));
            BDArmorySetup.WindowRectWingCommander.height = height;
            GUI.DragWindow(BDArmorySetup.WindowRectWingCommander);
            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectWingCommander);
        }
コード例 #15
0
        void OnGUI()
        {
            if (!HighLogic.LoadedSceneIsFlight || !vessel || !vessel.isActiveVessel || vessel.packed)
            {
                return;
            }
            if (!BDArmorySetup.GAME_UI_ENABLED)
            {
                return;
            }
            if (showGUI)
            {
                if (!rectInit)
                {
                    // this Rect initialization ensures any save issues with height or width of the window are resolved
                    BDArmorySetup.WindowRectWingCommander = new Rect(BDArmorySetup.WindowRectWingCommander.x, BDArmorySetup.WindowRectWingCommander.y, windowWidth, windowHeight);
                    buttonWidth                          = BDArmorySetup.WindowRectWingCommander.width - (2 * margin);
                    buttonEndY                           = buttonStartY;
                    wingmanButtonStyle                   = new GUIStyle(BDArmorySetup.BDGuiSkin.button);
                    wingmanButtonStyle.alignment         = TextAnchor.MiddleLeft;
                    wingmanButtonStyle.wordWrap          = false;
                    wingmanButtonStyle.fontSize          = 11;
                    wingmanButtonSelectedStyle           = new GUIStyle(BDArmorySetup.BDGuiSkin.box);
                    wingmanButtonSelectedStyle.alignment = TextAnchor.MiddleLeft;
                    wingmanButtonSelectedStyle.wordWrap  = false;
                    wingmanButtonSelectedStyle.fontSize  = 11;
                    rectInit = true;
                }
                // this Rect initialization ensures any save issues with height or width of the window are resolved
                //BDArmorySetup.WindowRectWingCommander = new Rect(BDArmorySetup.WindowRectWingCommander.x, BDArmorySetup.WindowRectWingCommander.y, windowWidth, windowHeight);
                BDArmorySetup.WindowRectWingCommander = GUI.Window(1293293, BDArmorySetup.WindowRectWingCommander, WingmenWindow, Localizer.Format("#LOC_BDArmory_WingCommander_Title"),//"WingCommander"
                                                                   BDArmorySetup.BDGuiSkin.window);

                if (showAGWindow)
                {
                    AGWindow();
                }
            }

            //command position diamonds
            float diamondSize = 24;

            List <GPSTargetInfo> .Enumerator comPos = commandedPositions.GetEnumerator();
            while (comPos.MoveNext())
            {
                BDGUIUtils.DrawTextureOnWorldPos(comPos.Current.worldPos, BDArmorySetup.Instance.greenDiamondTexture,
                                                 new Vector2(diamondSize, diamondSize), 0);
                Vector2 labelPos;
                if (!BDGUIUtils.WorldToGUIPos(comPos.Current.worldPos, out labelPos))
                {
                    continue;
                }
                labelPos.x += diamondSize / 2;
                labelPos.y -= 10;
                GUI.Label(new Rect(labelPos.x, labelPos.y, 300, 20), comPos.Current.name);
            }
            comPos.Dispose();

            if (!drawMouseDiamond)
            {
                return;
            }
            Vector2 mouseDiamondPos  = Input.mousePosition;
            Rect    mouseDiamondRect = new Rect(mouseDiamondPos.x - (diamondSize / 2),
                                                Screen.height - mouseDiamondPos.y - (diamondSize / 2), diamondSize, diamondSize);

            GUI.DrawTexture(mouseDiamondRect, BDArmorySetup.Instance.greenDiamondTexture,
                            ScaleMode.StretchToFill, true);
        }
コード例 #16
0
        internal void WindowRwr(int windowID)
        {
            GUI.DragWindow(new Rect(0, 0, BDArmorySetup.WindowRectRwr.width - 18, 30));
            if (GUI.Button(new Rect(BDArmorySetup.WindowRectRwr.width - 18, 2, 16, 16), "X", GUI.skin.button))
            {
                displayRWR = false;
                BDArmorySetup.SaveConfig();
            }
            GUI.BeginGroup(new Rect(BorderSize / 2, HeaderSize + (BorderSize / 2), RwrDisplayRect.width, RwrDisplayRect.height));
            //GUI.DragWindow(RwrDisplayRect);

            GUI.DrawTexture(RwrDisplayRect, VesselRadarData.omniBgTexture, ScaleMode.StretchToFill, false);
            float pingSize = 32 * BDArmorySettings.RWR_WINDOW_SCALE;

            for (int i = 0; i < dataCount; i++)
            {
                Vector2 pingPosition = (Vector2)pingsData[i].position;
                //pingPosition = Vector2.MoveTowards(displayRect.center, pingPosition, displayRect.center.x - (pingSize/2));
                Rect pingRect = new Rect(pingPosition.x - (pingSize / 2), pingPosition.y - (pingSize / 2), pingSize,
                                         pingSize);

                if (!pingsData[i].exists)
                {
                    continue;
                }
                if (pingsData[i].signalStrength == (float)RWRThreatTypes.MissileLock) //Hack! Evil misuse of field signalstrength...
                {
                    GUI.DrawTexture(pingRect, rwrMissileTexture, ScaleMode.StretchToFill, true);
                }
                else
                {
                    GUI.DrawTexture(pingRect, rwrDiamondTexture, ScaleMode.StretchToFill, true);
                    GUI.Label(pingRect, iconLabels[Mathf.RoundToInt(pingsData[i].signalStrength)], rwrIconLabelStyle); //Hack! Evil misuse of field signalstrength...
                }
            }

            List <TargetSignatureData> .Enumerator lw = launchWarnings.GetEnumerator();
            while (lw.MoveNext())
            {
                Vector2 pingPosition = (Vector2)lw.Current.position;
                //pingPosition = Vector2.MoveTowards(displayRect.center, pingPosition, displayRect.center.x - (pingSize/2));

                Rect pingRect = new Rect(pingPosition.x - (pingSize / 2), pingPosition.y - (pingSize / 2), pingSize,
                                         pingSize);
                GUI.DrawTexture(pingRect, rwrMissileTexture, ScaleMode.StretchToFill, true);
            }
            lw.Dispose();
            GUI.EndGroup();

            // Resizing code block.
            RWRresizeRect =
                new Rect(BDArmorySetup.WindowRectRwr.width - 18, BDArmorySetup.WindowRectRwr.height - 18, 16, 16);
            GUI.DrawTexture(RWRresizeRect, Misc.Misc.resizeTexture, ScaleMode.StretchToFill, true);
            if (Event.current.type == EventType.MouseDown && RWRresizeRect.Contains(Event.current.mousePosition))
            {
                resizingWindow = true;
            }

            if (Event.current.type == EventType.Repaint && resizingWindow)
            {
                if (Mouse.delta.x != 0 || Mouse.delta.y != 0)
                {
                    float diff = Mouse.delta.x + Mouse.delta.y;
                    UpdateRWRScale(diff);
                    BDArmorySetup.ResizeRwrWindow(BDArmorySettings.RWR_WINDOW_SCALE);
                }
            }
            // End Resizing code.

            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectRwr);
        }
コード例 #17
0
        void OnGUI()
        {
            if (!HighLogic.LoadedSceneIsFlight || !vessel || !vessel.isActiveVessel || vessel.packed)
            {
                return;
            }
            if (!BDArmorySetup.GAME_UI_ENABLED)
            {
                return;
            }
            if (showGUI)
            {
                if (!rectInit)
                {
                    guiWindowRect                        = new Rect(45, 75, 240, 800);
                    buttonWidth                          = guiWindowRect.width - (2 * margin);
                    buttonEndY                           = buttonStartY;
                    wingmanButtonStyle                   = new GUIStyle(HighLogic.Skin.button);
                    wingmanButtonStyle.alignment         = TextAnchor.MiddleLeft;
                    wingmanButtonStyle.wordWrap          = false;
                    wingmanButtonStyle.fontSize          = 11;
                    wingmanButtonSelectedStyle           = new GUIStyle(HighLogic.Skin.box);
                    wingmanButtonSelectedStyle.alignment = TextAnchor.MiddleLeft;
                    wingmanButtonSelectedStyle.wordWrap  = false;
                    wingmanButtonSelectedStyle.fontSize  = 11;
                    rectInit = true;
                }
                guiWindowRect = GUI.Window(1293293, guiWindowRect, WingmenWindow, "WingCommander",
                                           HighLogic.Skin.window);

                if (showAGWindow)
                {
                    AGWindow();
                }
            }

            //command position diamonds
            float diamondSize = 24;

            List <GPSTargetInfo> .Enumerator comPos = commandedPositions.GetEnumerator();
            while (comPos.MoveNext())
            {
                BDGUIUtils.DrawTextureOnWorldPos(comPos.Current.worldPos, BDArmorySetup.Instance.greenDiamondTexture,
                                                 new Vector2(diamondSize, diamondSize), 0);
                Vector2 labelPos;
                if (!BDGUIUtils.WorldToGUIPos(comPos.Current.worldPos, out labelPos))
                {
                    continue;
                }
                labelPos.x += diamondSize / 2;
                labelPos.y -= 10;
                GUI.Label(new Rect(labelPos.x, labelPos.y, 300, 20), comPos.Current.name);
            }
            comPos.Dispose();

            if (!drawMouseDiamond)
            {
                return;
            }
            Vector2 mouseDiamondPos  = Input.mousePosition;
            Rect    mouseDiamondRect = new Rect(mouseDiamondPos.x - (diamondSize / 2),
                                                Screen.height - mouseDiamondPos.y - (diamondSize / 2), diamondSize, diamondSize);

            GUI.DrawTexture(mouseDiamondRect, BDArmorySetup.Instance.greenDiamondTexture,
                            ScaleMode.StretchToFill, true);
        }