private void DrawThreatIndicator(Vector3 vesselPos, Vector3 targetPos, Color Teamcolor)
        {
            if (Event.current.type.Equals(EventType.Repaint))
            {
                Vector3 screenPos  = BDGUIUtils.GetMainCamera().WorldToViewportPoint(vesselPos);
                Vector3 screenTPos = BDGUIUtils.GetMainCamera().WorldToViewportPoint(targetPos);
                if (screenTPos.z > 0)
                {
                    float xPos  = (screenPos.x * Screen.width);
                    float yPos  = ((1 - screenPos.y) * Screen.height);
                    float xtPos = (screenTPos.x * Screen.width);
                    float ytPos = ((1 - screenTPos.y) * Screen.height);

                    Vector2 head;
                    Vector2 tail;

                    head.x = xPos;
                    head.y = yPos;
                    tail.x = xtPos;
                    tail.y = ytPos;
                    float angle = Vector2.Angle(Vector3.up, tail - head);
                    if (tail.x < head.x)
                    {
                        angle = -angle;
                    }
                    DrawPointer(tail, (angle - 180), 2, Teamcolor);
                }
            }
        }
        private void DrawOnScreenIcon(Vector3 worldPos, Texture texture, Vector2 size, Color Teamcolor, bool ShowPointer)
        {
            if (Event.current.type.Equals(EventType.Repaint))
            {
                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)
                {
                    IconMat.SetColor("_TintColor", Teamcolor);
                    IconMat.mainTexture = texture;
                    Rect iconRect = new Rect(xPos, yPos, size.x, size.y);
                    Graphics.DrawTexture(iconRect, texture, IconMat);
                }
                else
                {
                    if (BDTISettings.POINTERS)
                    {
                        Vector2 head;
                        Vector2 tail;

                        head.x = xPos;
                        head.y = yPos;
                        tail.x = xtPos;
                        tail.y = ytPos;
                        float angle = Vector2.Angle(Vector3.up, tail - head);
                        if (tail.x < head.x)
                        {
                            angle = -angle;
                        }
                        if (ShowPointer && BDTISettings.POINTERS)
                        {
                            DrawPointer(calculateRadialCoords(head, tail, angle, 0.75f), angle, 4, Teamcolor);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private void SetNewHeight(float windowHeight)
        {
            var previousWindowHeight = BDArmorySetup.WindowRectVesselSpawner.height;

            BDArmorySetup.WindowRectVesselSpawner.height = windowHeight;
            if (BDArmorySettings.STRICT_WINDOW_BOUNDARIES && windowHeight < previousWindowHeight && Mathf.RoundToInt(BDArmorySetup.WindowRectVesselSpawner.y + previousWindowHeight) == Screen.height) // Window shrunk while being at edge of screen.
            {
                BDArmorySetup.WindowRectVesselSpawner.y = Screen.height - BDArmorySetup.WindowRectVesselSpawner.height;
            }
            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSpawner);
        }
        public static void DrawPointer(Vector2 Pointer, float angle, float width, Color color)
        {
            Camera cam = BDGUIUtils.GetMainCamera();

            if (cam == null)
            {
                return;
            }

            GUI.matrix = Matrix4x4.identity;
            float length = 60;

            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;
        }
        private void DrawSettingsWindow(int id)
        {
            GUI.Box(new Rect(0, 0, SettingsWidth, SettingsHeight), "BDA Category Settings");

            if (BDArmorySettings.SHOW_CATEGORIES != (BDArmorySettings.SHOW_CATEGORIES = BDArmorySettings.SHOW_CATEGORIES = GUI.Toggle(
                                                         new Rect(SettingsMargin, SettingsLineHeight * 1.25f, SettingsWidth - (2 * SettingsMargin), SettingsLineHeight),
                                                         BDArmorySettings.SHOW_CATEGORIES,
                                                         "Subcategories"
                                                         )))
            {
                PartCategorizer.Instance.editorPartList.Refresh();
            }
            if (BDArmorySettings.AUTOCATEGORIZE_PARTS != (BDArmorySettings.AUTOCATEGORIZE_PARTS = BDArmorySettings.AUTOCATEGORIZE_PARTS = GUI.Toggle(
                                                              new Rect(SettingsMargin, SettingsLineHeight * 2.25f, SettingsWidth - (2 * SettingsMargin), SettingsLineHeight),
                                                              BDArmorySettings.AUTOCATEGORIZE_PARTS,
                                                              "Autocategorize parts"
                                                              )))
            {
                PartCategorizer.Instance.editorPartList.Refresh();
            }

            BDGUIUtils.RepositionWindow(ref SettingsWindow);
            BDGUIUtils.UseMouseEventInRect(SettingsWindow);
        }
        void WindowRcs(int windowID)
        {
            if (GUI.Button(new Rect(windowRect.width - 18, 2, 16, 16), "X"))
            {
                HideToolbarGUI();
            }

            GUI.Label(new Rect(10, 40, 200, 20), "Frontal", BDArmorySetup.BDGuiSkin.box);
            GUI.Label(new Rect(220, 40, 200, 20), "Lateral", BDArmorySetup.BDGuiSkin.box);
            GUI.Label(new Rect(430, 40, 200, 20), "Ventral", BDArmorySetup.BDGuiSkin.box);

            if (takeSnapshot)
            {
                takeRadarSnapshot();
            }

            // for each view draw the rendering with the higher cross section (normal or 45°):
            if (RadarUtils.rcsFrontal > RadarUtils.rcsFrontal45)
            {
                GUI.DrawTexture(new Rect(10, 70, 200, 200), RadarUtils.GetTextureFrontal, ScaleMode.StretchToFill);
            }
            else
            {
                GUI.DrawTexture(new Rect(10, 70, 200, 200), RadarUtils.GetTextureFrontal45, ScaleMode.StretchToFill);
            }

            if (RadarUtils.rcsLateral > RadarUtils.rcsLateral45)
            {
                GUI.DrawTexture(new Rect(220, 70, 200, 200), RadarUtils.GetTextureLateral, ScaleMode.StretchToFill);
            }
            else
            {
                GUI.DrawTexture(new Rect(220, 70, 200, 200), RadarUtils.GetTextureLateral45, ScaleMode.StretchToFill);
            }

            if (RadarUtils.rcsVentral > RadarUtils.rcsVentral45)
            {
                GUI.DrawTexture(new Rect(430, 70, 200, 200), RadarUtils.GetTextureVentral, ScaleMode.StretchToFill);
            }
            else
            {
                GUI.DrawTexture(new Rect(430, 70, 200, 200), RadarUtils.GetTextureVentral45, ScaleMode.StretchToFill);
            }


            GUI.Label(new Rect(10, 275, 200, 20), string.Format("{0:0.00}", Mathf.Max(RadarUtils.rcsFrontal, RadarUtils.rcsFrontal45)) + " m^2", BDArmorySetup.BDGuiSkin.label);
            GUI.Label(new Rect(220, 275, 200, 20), string.Format("{0:0.00}", Mathf.Max(RadarUtils.rcsLateral, RadarUtils.rcsLateral45)) + " m^2", BDArmorySetup.BDGuiSkin.label);
            GUI.Label(new Rect(430, 275, 200, 20), string.Format("{0:0.00}", Mathf.Max(RadarUtils.rcsVentral, RadarUtils.rcsVentral45)) + " m^2", BDArmorySetup.BDGuiSkin.label);

            GUIStyle style = BDArmorySetup.BDGuiSkin.label;

            style.fontStyle = FontStyle.Bold;
            GUI.Label(new Rect(10, 300, 600, 20), "Base radar cross section for vessel: " + string.Format("{0:0.00} m^2 (without ECM/countermeasures)", RadarUtils.rcsTotal), style);
            GUI.Label(new Rect(10, 320, 600, 20), "Total radar cross section for vessel: " + string.Format("{0:0.00} m^2 (with RCS reduction/stealth/ground clutter)", RadarUtils.rcsTotal * rcsReductionFactor * rcsGCF), style);

            style.fontStyle = FontStyle.Normal;
            GUI.Label(new Rect(10, 380, 600, 20), "** (Range evaluation not accounting for ECM/countermeasures)", style);
            GUI.Label(new Rect(10, 410, 600, 20), text_detection, style);
            GUI.Label(new Rect(10, 430, 600, 20), text_locktrack, style);
            GUI.Label(new Rect(10, 450, 600, 20), text_sonar, style);

            bool bNewValue = GUI.Toggle(new Rect(490, 348, 150, 20), bLandedSplashed, "Splashed/Landed", BDArmorySetup.BDGuiSkin.toggle);

            if (radars == null)
            {
                FillRadarList();
                GUIStyle listStyle = new GUIStyle(BDArmorySetup.BDGuiSkin.button);
                listStyle.fixedHeight = 18; //make list contents slightly smaller
                radarBox = new BDGUIComboBox(new Rect(10, 350, 600, 20), new Rect(10, 350, 250, 20), radarBoxText, radarsGUI, 124, listStyle);
            }

            int selected_index = radarBox.Show();

            if ((selected_index != previous_index) || (bNewValue != bLandedSplashed))
            {
                text_sonar      = "";
                bLandedSplashed = bNewValue;

                // selected radar changed - evaluate craft RCS against this radar
                if (selected_index != -1)
                {
                    var selected_radar = radars[selected_index];

                    // ground clutter factor from radar
                    if (bLandedSplashed)
                    {
                        rcsGCF = selected_radar.radarGroundClutterFactor;
                    }
                    else
                    {
                        rcsGCF = 1.0f;
                    }

                    if (selected_radar.canScan)
                    {
                        for (float distance = selected_radar.radarMaxDistanceDetect; distance >= 0; distance--)
                        {
                            text_detection = $"Detection: undetectable by this radar.";
                            if (selected_radar.radarDetectionCurve.Evaluate(distance) <= (RadarUtils.rcsTotal * rcsReductionFactor * rcsGCF))
                            {
                                text_detection = $"Detection: detected at {distance} km and closer";
                                break;
                            }
                        }
                    }
                    else
                    {
                        text_detection = "Detection: This radar does not have detection capabilities.";
                    }

                    if (selected_radar.canLock)
                    {
                        text_locktrack = $"Lock/Track: untrackable by this radar.";
                        for (float distance = selected_radar.radarMaxDistanceLockTrack; distance >= 0; distance--)
                        {
                            if (selected_radar.radarLockTrackCurve.Evaluate(distance) <= (RadarUtils.rcsTotal * rcsReductionFactor * rcsGCF))
                            {
                                text_locktrack = $"Lock/Track: tracked at {distance} km and closer";
                                break;
                            }
                        }
                    }
                    else
                    {
                        text_locktrack = "Lock/Track: This radar does not have locking/tracking capabilities.";
                    }

                    if (selected_radar.getRWRType(selected_radar.rwrThreatType) == "SONAR")
                    {
                        text_sonar = "SONAR - will only be able to detect/track splashed or submerged vessels!";
                    }
                }
            }
            previous_index = selected_index;

            GUI.DragWindow();
            BDGUIUtils.RepositionWindow(ref windowRect);
        }
        private void WindowRemoteOrchestration(int id)
        {
            GUI.DragWindow(new Rect(0, 0, BDArmorySettings.REMOTE_ORCHESTRATION_WINDOW_WIDTH - _titleHeight / 2 - 2, _titleHeight));
            if (GUI.Button(new Rect(BDArmorySettings.REMOTE_ORCHESTRATION_WINDOW_WIDTH - _titleHeight / 2 - 2, 2, _titleHeight / 2, _titleHeight / 2), "X", BDArmorySetup.BDGuiSkin.button))
            {
                showWindow = false;
            }

            float offset = _titleHeight + _margin;
            float width  = BDArmorySettings.REMOTE_ORCHESTRATION_WINDOW_WIDTH;
            float fifth  = width / 5.0f;

            GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Competition: ");
            GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), competition);
            offset += _titleHeight;
            GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Status: ");
            string statusLine;

            switch (service.status)
            {
            case BDAScoreService.StatusType.Waiting:
                statusLine = status + " " + (30 + service.retryFindStartedAt - Planetarium.GetUniversalTime()).ToString("0") + "s";
                break;

            default:
                statusLine = status;
                break;
            }
            GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), statusLine);
            offset += _titleHeight;
            GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Stage: ");
            GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), stage);
            offset += _titleHeight;
            GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Heat: ");
            GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), heat);
            offset += _titleHeight;
            string buttonText;
            bool   nextButton = false;

            switch (BDAScoreService.Instance.status)
            {
            case BDAScoreService.StatusType.Waiting:
                buttonText = "Stop";
                nextButton = true;
                break;

            case BDAScoreService.StatusType.Stopped:
            case BDAScoreService.StatusType.Cancelled:
                buttonText = "Next Heat";
                break;

            default:
                buttonText = "Cancel";
                break;
            }
            if (GUI.Button(new Rect(_margin, offset, nextButton ? 2 * width / 3 - _margin : width - 2 * _margin, _titleHeight), buttonText, BDArmorySetup.BDGuiSkin.button))
            {
                switch (BDAScoreService.Instance.status)
                {
                case BDAScoreService.StatusType.Stopped:
                case BDAScoreService.StatusType.Cancelled:
                    service.Configure(service.vesselPath, BDArmorySettings.COMPETITION_HASH);
                    break;

                default:
                    service.Cancel();
                    break;
                }
            }
            if (nextButton && GUI.Button(new Rect(2 * width / 3, offset, width / 3 - _margin, _titleHeight), "Next", BDArmorySetup.BDGuiSkin.button))
            {
                BDAScoreService.Instance.retryFindStartedAt = -1;
            }
            offset += _titleHeight + _margin;

            _windowHeight = offset;

            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectRemoteOrchestration); // Prevent it from going off the screen edges.
        }
        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)
            {
                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 (VesselModuleRegistry.ignoredVesselTypes.Contains(v.Current.vesselType))
                        {
                            continue;
                        }

                        if (BDTISettings.MISSILES)
                        {
                            using (var ml = VesselModuleRegistry.GetModules <MissileBase>(v.Current).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, BDTISetup.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 (BDTISettings.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, BDTISetup.Instance.TextureIconDebris, new Vector2(20, 20), 0);
                                }
                            }
                        }
                    }
                int Teamcount = 0;
                using (var teamManagers = BDTISetup.Instance.weaponManagers.GetEnumerator())
                    while (teamManagers.MoveNext())
                    {
                        Teamcount++;
                        using (var wm = teamManagers.Current.Value.GetEnumerator())
                            while (wm.MoveNext())
                            {
                                if (wm.Current == null)
                                {
                                    continue;
                                }
                                Teamcolor = BDTISetup.Instance.ColorAssignments[wm.Current.Team.Name];
                                IconUIStyle.normal.textColor = Teamcolor;
                                if (wm.Current.vessel.isActiveVessel)
                                {
                                    if (BDTISettings.THREATICON)
                                    {
                                        if (wm.Current.currentTarget == null)
                                        {
                                            continue;
                                        }
                                        Vector3 sPos   = FlightGlobals.ActiveVessel.CoM;
                                        Vector3 tPos   = (wm.Current.currentTarget.Vessel.CoM);
                                        Vector3 RelPos = (tPos - sPos);
                                        if (RelPos.magnitude >= 100)
                                        {
                                            DrawThreatIndicator(wm.Current.vessel.CoM, wm.Current.currentTarget.Vessel.CoM, Teamcolor);
                                        }
                                    }
                                }
                                else
                                {
                                    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;
                                    string  selectedWeapon = String.Empty;
                                    string  AIstate        = String.Empty;
                                    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 = BDTISetup.Instance.TextureIconPlane;
                                        }
                                        else if (wm.Current.vessel.vesselType == VesselType.Base || wm.Current.vessel.vesselType == VesselType.Lander)
                                        {
                                            icon = BDTISetup.Instance.TextureIconBase;
                                        }
                                        else if (wm.Current.vessel.vesselType == VesselType.Rover)
                                        {
                                            icon = BDTISetup.Instance.TextureIconRover;
                                        }
                                        else if (wm.Current.vessel.vesselType == VesselType.Probe)
                                        {
                                            icon = BDTISetup.Instance.TextureIconProbe;
                                        }
                                        else if (wm.Current.vessel.vesselType == VesselType.Ship && wm.Current.vessel.Splashed)
                                        {
                                            icon = BDTISetup.Instance.TextureIconShip;
                                            if (wm.Current.vessel.vesselType == VesselType.Ship && wm.Current.vessel.altitude < -10)
                                            {
                                                icon = BDTISetup.Instance.TextureIconSub;
                                            }
                                        }
                                        else if (wm.Current.vessel.vesselType == VesselType.Debris)
                                        {
                                            icon = BDTISetup.Instance.TextureIconDebris;
                                            size = 20;
                                            IconUIStyle.normal.textColor = XKCDColors.Grey;
                                            Teamcolor = XKCDColors.Grey;
                                        }
                                        else
                                        {
                                            icon = BDTISetup.Instance.TextureIconGeneric;
                                        }
                                        DrawOnScreenIcon(wm.Current.vessel.CoM, icon, new Vector2((size * BDTISettings.ICONSCALE), (size * BDTISettings.ICONSCALE)), Teamcolor, true);
                                        if (BDTISettings.THREATICON)
                                        {
                                            if (wm.Current.currentTarget != null)
                                            {
                                                if (!wm.Current.currentTarget.Vessel.isActiveVessel)
                                                {
                                                    DrawThreatIndicator(wm.Current.vessel.CoM, wm.Current.currentTarget.Vessel.CoM, Teamcolor);
                                                }
                                            }
                                        }
                                        if (BDGUIUtils.WorldToGUIPos(wm.Current.vessel.CoM, out guiPos))
                                        {
                                            if (BDTISettings.VESSELNAMES)
                                            {
                                                vName = wm.Current.vessel.vesselName;
                                                Rect nameRect = new Rect((guiPos.x + (24 * BDTISettings.ICONSCALE)), guiPos.y - 4, 100, 32);
                                                GUI.Label(nameRect, vName, IconUIStyle);
                                            }
                                            if (BDTISettings.TEAMNAMES)
                                            {
                                                Rect teamRect = new Rect((guiPos.x + (16 * BDTISettings.ICONSCALE)), (guiPos.y - (19 * BDTISettings.ICONSCALE)), 100, 32);
                                                GUI.Label(teamRect, "Team: " + $"{wm.Current.Team.Name}", IconUIStyle);
                                            }

                                            if (BDTISettings.SCORE)
                                            {
                                                BDArmory.Control.ScoringData scoreData = null;
                                                int Score = 0;

                                                if (BDACompetitionMode.Instance.Scores.ContainsKey(wm.Current.vessel.vesselName))
                                                {
                                                    scoreData = BDACompetitionMode.Instance.Scores[wm.Current.vessel.vesselName];
                                                    Score     = scoreData.Score;
                                                }
                                                if (VesselSpawner.Instance.vesselsSpawningContinuously)
                                                {
                                                    if (VesselSpawner.Instance.continuousSpawningScores.ContainsKey(wm.Current.vessel.vesselName))
                                                    {
                                                        Score += VesselSpawner.Instance.continuousSpawningScores[wm.Current.vessel.vesselName].cumulativeHits;
                                                    }
                                                }

                                                Rect scoreRect = new Rect((guiPos.x + (16 * BDTISettings.ICONSCALE)), (guiPos.y + (14 * BDTISettings.ICONSCALE)), 100, 32);
                                                GUI.Label(scoreRect, "Score: " + Score, IconUIStyle);
                                            }
                                            if (BDTISettings.HEALTHBAR)
                                            {
                                                double hpPercent = 1;
                                                hpPercent = Mathf.Clamp((1 - ((wm.Current.totalHP - wm.Current.vessel.parts.Count) / wm.Current.totalHP)), 0, 1);
                                                if (hpPercent > 0)
                                                {
                                                    Rect barRect    = new Rect((guiPos.x - (32 * BDTISettings.ICONSCALE)), (guiPos.y + (30 * BDTISettings.ICONSCALE)), (64 * BDTISettings.ICONSCALE), 12);
                                                    Rect healthRect = new Rect((guiPos.x - (30 * BDTISettings.ICONSCALE)), (guiPos.y + (32 * BDTISettings.ICONSCALE)), (60 * (float)hpPercent * BDTISettings.ICONSCALE), 8);
                                                    //GUI.Label(healthRect, "Team: " + $"{wm.Current.Team.Name}", IconUIStyle);
                                                    BDGUIUtils.DrawRectangle(barRect, XKCDColors.Grey);
                                                    BDGUIUtils.DrawRectangle(healthRect, Color.HSVToRGB((85f * (float)hpPercent) / 255, 1f, 1f));
                                                }
                                                Rect distRect = new Rect((guiPos.x - 12), (guiPos.y + (45 * BDTISettings.ICONSCALE)), 100, 32);
                                                GUI.Label(distRect, UIdist + UoM, IconUIStyle);
                                            }
                                            else
                                            {
                                                Rect distRect = new Rect((guiPos.x - 12), (guiPos.y + (20 * BDTISettings.ICONSCALE)), 100, 32);
                                                GUI.Label(distRect, UIdist + UoM, IconUIStyle);
                                            }
                                            if (BDTISettings.TELEMETRY)
                                            {
                                                selectedWeapon = "Using: " + wm.Current.selectedWeaponString;
                                                AIstate        = "No AI";
                                                if (wm.Current.AI != null)
                                                {
                                                    AIstate = "Pilot " + wm.Current.AI.currentStatus;
                                                }
                                                Rect telemetryRect = new Rect((guiPos.x + (32 * BDTISettings.ICONSCALE)), guiPos.y + 32, 200, 32);
                                                GUI.Label(telemetryRect, selectedWeapon, IconUIStyle);
                                                Rect telemetryRect2 = new Rect((guiPos.x + (32 * BDTISettings.ICONSCALE)), guiPos.y + 48, 200, 32);
                                                GUI.Label(telemetryRect2, AIstate, IconUIStyle);
                                                if (wm.Current.isFlaring || wm.Current.isChaffing || wm.Current.isECMJamming)
                                                {
                                                    Rect telemetryRect3 = new Rect((guiPos.x + (32 * BDTISettings.ICONSCALE)), guiPos.y + 64, 200, 32);
                                                    GUI.Label(telemetryRect3, "Deploying Counter-Measures", IconUIStyle);
                                                }
                                                Rect SpeedRect = new Rect((guiPos.x - (96 * BDTISettings.ICONSCALE)), guiPos.y + 64, 100, 32);
                                                GUI.Label(SpeedRect, "Speed: " + wm.Current.vessel.speed.ToString("0.0") + "m/s", IconUIStyle);
                                                Rect RAltRect = new Rect((guiPos.x - (96 * BDTISettings.ICONSCALE)), guiPos.y + 80, 100, 32);
                                                GUI.Label(RAltRect, "Alt: " + wm.Current.vessel.altitude.ToString("0.0") + "m", IconUIStyle);
                                                Rect ThrottleRect = new Rect((guiPos.x - (96 * BDTISettings.ICONSCALE)), guiPos.y + 96, 100, 32);
                                                GUI.Label(ThrottleRect, "Throttle: " + Mathf.CeilToInt(wm.Current.vessel.ctrlState.mainThrottle * 100) + "%", IconUIStyle);
                                            }
                                        }
                                    }
                                }
                            }
                    }
            }
        }
Beispiel #9
0
        private void WindowVesselSwitcher(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            = _titleHeight;
            float vesselButtonWidth = _windowWidth - 2 * _margin - 3 * _buttonHeight;

            using (var teamManagers = weaponManagers.GetEnumerator())
                while (teamManagers.MoveNext())
                {
                    height += _margin;
                    GUI.Label(new Rect(_margin, height, _windowWidth - 2 * _margin, _buttonHeight), $"{teamManagers.Current.Key}:", BDArmorySetup.BDGuiSkin.label);
                    height += _buttonHeight;

                    using (var wm = teamManagers.Current.Value.GetEnumerator())
                        while (wm.MoveNext())
                        {
                            if (wm.Current == null)
                            {
                                continue;
                            }

                            Rect     buttonRect   = new Rect(_margin, height, vesselButtonWidth, _buttonHeight);
                            GUIStyle vButtonStyle = wm.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;
                            string   status       = UpdateVesselStatus(wm.Current, vButtonStyle);

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

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

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

                            //team toggle
                            Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight * 2, height,
                                                           _buttonHeight, _buttonHeight);
                            if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button))
                            {
                                if (Event.current.button == 1)
                                {
                                    BDTeamSelector.Instance.Open(wm.Current, new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y));
                                }
                                else
                                {
                                    _wmToSwitchTeam  = wm.Current;
                                    _teamSwitchDirty = true;
                                }
                            }

                            height += _buttonHeight + _buttonGap;
                        }
                }

            height       += _margin;
            _windowHeight = height;
            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSwitcher);
        }
        private void TeamSelectorWindow(int id)
        {
            height = margin;
            // Team input field
            newTeamName = GUI.TextField(new Rect(margin, margin, width - buttonGap - 2 * margin - newTeanButtonWidth, buttonHeight), newTeamName, 30);

            // New team button
            Rect newTeamButtonRect = new Rect(width - margin - newTeanButtonWidth, height, newTeanButtonWidth, buttonHeight);

            if (GUI.Button(newTeamButtonRect, Localizer.Format("#LOC_BDArmory_Generic_New"), BDArmorySetup.BDGuiSkin.button))//"New"
            {
                if (!string.IsNullOrEmpty(newTeamName.Trim()))
                {
                    targetWeaponManager.SetTeam(BDTeam.Get(newTeamName.Trim()));
                    open = false;
                }
            }

            height += buttonHeight;

            // Scrollable list of existing teams
            scrollable = (BDArmorySetup.Instance.Teams.Count * (buttonHeight + buttonGap) * 2 > Screen.height);

            if (scrollable)
            {
                scrollPosition = GUI.BeginScrollView(
                    new Rect(margin, height, width - margin * 2 + scrollWidth, Screen.height / 2),
                    scrollPosition,
                    new Rect(margin, height, width - margin * 2, BDArmorySetup.Instance.Teams.Count * (buttonHeight + buttonGap)),
                    false, true);
            }

            using (var teams = BDArmorySetup.Instance.Teams.Values.GetEnumerator())
                while (teams.MoveNext())
                {
                    if (teams.Current == null || !teams.Current.Name.ToLowerInvariant().StartsWith(newTeamName.ToLowerInvariant().Trim()))
                    {
                        continue;
                    }

                    height += buttonGap;
                    Rect     buttonRect  = new Rect(margin, height, width - 2 * margin, buttonHeight);
                    GUIStyle buttonStyle = (teams.Current == targetWeaponManager.Team) ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

                    if (GUI.Button(buttonRect, teams.Current.Name, buttonStyle))
                    {
                        targetWeaponManager.SetTeam(teams.Current);
                        open = false;
                    }

                    height += buttonHeight;
                }

            if (scrollable)
            {
                GUI.EndScrollView();
            }

            // Buttons
            if (Event.current.type == EventType.KeyUp)
            {
                if ((Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) && !string.IsNullOrEmpty(newTeamName.Trim()))
                {
                    targetWeaponManager.SetTeam(BDTeam.Get(newTeamName.Trim()));
                    open = false;
                }
                else if (Event.current.keyCode == KeyCode.Escape)
                {
                    open = false;
                }
            }

            height += margin;
            BDGUIUtils.RepositionWindow(ref window);
            BDGUIUtils.UseMouseEventInRect(window);
        }
Beispiel #11
0
        private void WindowVesselSwitcher(int id)
        {
            GUI.DragWindow(new Rect(0, 0, _windowWidth - 4 * (_buttonHeight) - _margin, _titleHeight));

            // enablge guard mode for all pilots
            if (GUI.Button(new Rect(_windowWidth - 4 * (_buttonHeight) - _margin, 4, _buttonHeight, _buttonHeight), "G", _guardModeEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button))
            {
                // switch everyon onto different teams
                ToggleGuardModes();
            }

            // enable autopilot for all
            if (GUI.Button(new Rect(_windowWidth - 3 * (_buttonHeight) - _margin, 4, _buttonHeight, _buttonHeight), "P", _autoPilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button))
            {
                // Toggle autopilots for everyone
                ToggleAutopilots();
            }

            // toggle between FFA and putting everyone on the same team
            if (GUI.Button(new Rect(_windowWidth - 2 * (_buttonHeight) - _margin, 4, _buttonHeight, _buttonHeight), "T", _freeForAll ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button))
            {
                // switch everyon onto different teams
                _teamSwitchDirty = true;
                _wmToSwitchTeam  = null;
            }

            // close the window
            if (GUI.Button(new Rect(_windowWidth - _buttonHeight - _margin, 4, _buttonHeight, _buttonHeight), "X",
                           BDArmorySetup.BDGuiSkin.button))
            {
                BDArmorySetup.Instance.showVSGUI = false;
                return;
            }

            float height            = _titleHeight;
            float vesselButtonWidth = _windowWidth - 2 * _margin - 6 * _buttonHeight;

            using (var teamManagers = weaponManagers.GetEnumerator())
                while (teamManagers.MoveNext())
                {
                    height += _margin;


                    using (var wm = teamManagers.Current.Value.GetEnumerator())
                        while (wm.MoveNext())
                        {
                            if (wm.Current == null)
                            {
                                continue;
                            }
                            // team at the start of the line
                            GUI.Label(new Rect(_margin, height, _buttonHeight, _buttonHeight), $"{teamManagers.Current.Key}:", BDArmorySetup.BDGuiSkin.label);
                            Rect     buttonRect   = new Rect(_margin + _buttonHeight, height, vesselButtonWidth, _buttonHeight);
                            GUIStyle vButtonStyle = wm.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

                            // current target
                            string targetName     = "";
                            Vessel targetVessel   = wm.Current.vessel;
                            bool   incomingThreat = false;
                            if (wm.Current.incomingThreatVessel != null)
                            {
                                incomingThreat = true;
                                targetName     = "<<<" + wm.Current.incomingThreatVessel.GetName();
                                targetVessel   = wm.Current.incomingThreatVessel;
                            }
                            else if (wm.Current.currentTarget)
                            {
                                targetName   = ">>>" + wm.Current.currentTarget.Vessel.GetName();
                                targetVessel = wm.Current.currentTarget.Vessel;
                            }

                            string status     = UpdateVesselStatus(wm.Current, vButtonStyle);
                            string vesselName = wm.Current.vessel.GetName();

                            string postStatus = "";
                            if (wm.Current.AI != null && wm.Current.AI.currentStatus != null)
                            {
                                postStatus += " " + wm.Current.AI.currentStatus;
                            }
                            float targetDistance = 5000;
                            if (wm.Current.currentTarget != null)
                            {
                                targetDistance = Vector3.Distance(wm.Current.vessel.GetWorldPos3D(), wm.Current.currentTarget.position);
                            }

                            if (targetName != "")
                            {
                                postStatus += " " + targetName;
                            }

                            if (GUI.Button(buttonRect, status + vesselName + postStatus, vButtonStyle))
                            {
                                ForceSwitchVessel(wm.Current.vessel);
                            }

                            // selects current target
                            if (targetName != "")
                            {
                                Rect targettingButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, height,
                                                                     _buttonHeight, _buttonHeight);
                                GUIStyle targButton = BDArmorySetup.BDGuiSkin.button;
                                if (wm.Current.currentGun != null && wm.Current.currentGun.recentlyFiring)
                                {
                                    if (targetDistance < 500)
                                    {
                                        targButton = redLight;
                                    }
                                    else if (targetDistance < 1000)
                                    {
                                        targButton = yellowLight;
                                    }
                                    else
                                    {
                                        targButton = blueLight;
                                    }
                                }
                                if (GUI.Button(targettingButtonRect, incomingThreat ? "><" : "[]", targButton))
                                {
                                    ForceSwitchVessel(targetVessel);
                                }
                            }

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

                            //AI toggle
                            if (wm.Current.AI != null)
                            {
                                GUIStyle aiStyle = new GUIStyle(wm.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button);
                                if (wm.Current.underFire)
                                {
                                    var distance = Vector3.Distance(wm.Current.vessel.GetWorldPos3D(), wm.Current.incomingThreatPosition);
                                    if (distance < 500)
                                    {
                                        aiStyle.normal.textColor = Color.red;
                                    }
                                    else if (distance < 1000)
                                    {
                                        aiStyle.normal.textColor = Color.yellow;
                                    }
                                    else
                                    {
                                        aiStyle.normal.textColor = Color.blue;
                                    }
                                }
                                Rect aiButtonRect = new Rect(_margin + vesselButtonWidth + 3 * _buttonHeight, height, _buttonHeight,
                                                             _buttonHeight);
                                if (GUI.Button(aiButtonRect, "P", aiStyle))
                                {
                                    wm.Current.AI.TogglePilot();
                                }
                            }

                            //team toggle
                            Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + 4 * _buttonHeight, height,
                                                           _buttonHeight, _buttonHeight);
                            if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button))
                            {
                                if (Event.current.button == 1)
                                {
                                    BDTeamSelector.Instance.Open(wm.Current, new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y));
                                }
                                else
                                {
                                    _wmToSwitchTeam  = wm.Current;
                                    _teamSwitchDirty = true;
                                }
                            }
                            // boom
                            Rect killButtonRect = new Rect(_margin + vesselButtonWidth + 5 * _buttonHeight, height, _buttonHeight, _buttonHeight);
                            if (GUI.Button(killButtonRect, "X", BDArmorySetup.BDGuiSkin.button))
                            {
                                // must use right button
                                if (Event.current.button == 1)
                                {
                                    Misc.Misc.ForceDeadVessel(wm.Current.vessel);
                                }
                            }


                            height += _buttonHeight + _buttonGap;
                        }
                }

            height       += _margin;
            _windowHeight = height;
            BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSwitcher);
        }
        private void TargetingSelectorWindow(int id)
        {
            height = margin;
            GUIStyle labelStyle = BDArmorySetup.BDGuiSkin.label;

            GUI.Label(new Rect(margin, height, width - 2 * margin, buttonHeight), Localizer.Format("#LOC_BDArmory_Selecttargeting"), labelStyle);
            if (GUI.Button(new Rect(width - 18, 2, 16, 16), "X"))
            {
                open = false;
            }
            height += buttonHeight;

            height += buttonGap;
            Rect     CoMRect  = new Rect(margin, height, width - 2 * margin, buttonHeight);
            GUIStyle CoMStyle = targetWeaponManager.targetCoM ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

            if (GUI.Button(CoMRect, Localizer.Format("#LOC_BDArmory_TargetCOM"), CoMStyle))
            {
                targetWeaponManager.targetCoM = !targetWeaponManager.targetCoM;
                if (targetWeaponManager.targetCoM)
                {
                    targetWeaponManager.targetWeapon  = false;
                    targetWeaponManager.targetEngine  = false;
                    targetWeaponManager.targetCommand = false;
                    targetWeaponManager.targetMass    = false;
                }
                if (!targetWeaponManager.targetCoM && (!targetWeaponManager.targetWeapon && !targetWeaponManager.targetEngine && !targetWeaponManager.targetCommand && !targetWeaponManager.targetMass))
                {
                    targetWeaponManager.targetMass = true;
                }
            }
            height += buttonHeight;

            height += buttonGap;
            Rect     MassRect  = new Rect(margin, height, width - 2 * margin, buttonHeight);
            GUIStyle MassStyle = targetWeaponManager.targetMass ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

            if (GUI.Button(MassRect, Localizer.Format("#LOC_BDArmory_Mass"), MassStyle))
            {
                targetWeaponManager.targetMass = !targetWeaponManager.targetMass;
                if (targetWeaponManager.targetMass)
                {
                    targetWeaponManager.targetCoM = false;
                }
                if (!targetWeaponManager.targetCoM && (!targetWeaponManager.targetWeapon && !targetWeaponManager.targetEngine && !targetWeaponManager.targetCommand && !targetWeaponManager.targetMass))
                {
                    targetWeaponManager.targetCoM = true;
                }
            }
            height += buttonHeight;

            height += buttonGap;
            Rect     CommandRect  = new Rect(margin, height, width - 2 * margin, buttonHeight);
            GUIStyle CommandStyle = targetWeaponManager.targetCommand ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

            if (GUI.Button(CommandRect, Localizer.Format("#LOC_BDArmory_Command"), CommandStyle))
            {
                targetWeaponManager.targetCommand = !targetWeaponManager.targetCommand;
                if (targetWeaponManager.targetCommand)
                {
                    targetWeaponManager.targetCoM = false;
                }
            }
            height += buttonHeight;

            height += buttonGap;
            Rect     EngineRect  = new Rect(margin, height, width - 2 * margin, buttonHeight);
            GUIStyle EngineStyle = targetWeaponManager.targetEngine ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

            if (GUI.Button(EngineRect, Localizer.Format("#LOC_BDArmory_Engines"), EngineStyle))
            {
                targetWeaponManager.targetEngine = !targetWeaponManager.targetEngine;
                if (targetWeaponManager.targetEngine)
                {
                    targetWeaponManager.targetCoM = false;
                }
            }
            height += buttonHeight;

            height += buttonGap;
            Rect     weaponRect = new Rect(margin, height, width - 2 * margin, buttonHeight);
            GUIStyle WepStyle   = targetWeaponManager.targetWeapon ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button;

            if (GUI.Button(weaponRect, Localizer.Format("#LOC_BDArmory_Weapons"), WepStyle))
            {
                targetWeaponManager.targetWeapon = !targetWeaponManager.targetWeapon;
                if (targetWeaponManager.targetWeapon)
                {
                    targetWeaponManager.targetCoM = false;
                }
            }
            height += buttonHeight;

            height += margin;
            targetWeaponManager.targetingString = (targetWeaponManager.targetCoM ? Localizer.Format("#LOC_BDArmory_TargetCOM") + "; " : "")
                                                  + (targetWeaponManager.targetMass ? Localizer.Format("#LOC_BDArmory_Mass") + "; " : "")
                                                  + (targetWeaponManager.targetCommand ? Localizer.Format("#LOC_BDArmory_Command") + "; " : "")
                                                  + (targetWeaponManager.targetEngine ? Localizer.Format("#LOC_BDArmory_Engines") + "; " : "")
                                                  + (targetWeaponManager.targetWeapon ? Localizer.Format("#LOC_BDArmory_Weapons") + "; " : "");
            BDGUIUtils.RepositionWindow(ref window);
            BDGUIUtils.UseMouseEventInRect(window);
        }
Beispiel #13
0
        private void AmmoSelectorWindow(int id)
        {
            float    line        = 0.5f;
            string   labelString = GUIstring.ToString() + countString.ToString();
            GUIStyle labelStyle  = BDArmorySetup.BDGuiSkin.label;

            GUI.Label(new Rect(margin, 0.5f * buttonHeight, width - 2 * margin, buttonHeight), Localizer.Format("#LOC_BDArmory_Ammo_Setup"), labelStyle);
            if (GUI.Button(new Rect(width - 18, 2, 16, 16), "X"))
            {
                open = false;
            }
            line++;
            GUI.Label(new Rect(margin, line * buttonHeight, width - 2 * margin, buttonHeight), Localizer.Format("#LOC_BDArmory_Ammo_Belt"), labelStyle);
            line += 1.2f;
            GUI.Label(new Rect(margin, line * buttonHeight, width - 2 * margin, buttonHeight * labelLines), labelString, labelStyle);
            line++;

            labelLines = Mathf.CeilToInt((GUIstring.Length / 50));
            float ammolines = 0.1f;

            for (int i = 0; i < AList.Count; i++)
            {
                string ammoname = AList[i];
                if (GUI.Button(new Rect(margin * 2, (line + labelLines + ammolines) * buttonHeight, (width - 4 * margin), buttonHeight), ammoname, BDArmorySetup.BDGuiSkin.button))
                {
                    beltString += ammoname;
                    beltString += "; ";
                    if (lastGUIstring != ammoname)
                    {
                        GUIstring    += countString.ToString();
                        GUIstring    += ammoname;
                        lastGUIstring = ammoname;
                        roundCounter  = 1;
                        countString   = "; ";
                    }
                    else
                    {
                        roundCounter++;
                        countString = " X" + roundCounter + "; ";
                    }
                }
                ammolines++;
                if (ammoDesc[i] != null)
                {
                    GUI.Label(new Rect(margin * 4, (line + labelLines + ammolines) * buttonHeight, (width - 8 * margin), buttonHeight), ammoDesc[i], labelStyle);
                    ammolines += 1.1f;
                }
            }
            if (GUI.Button(new Rect(margin * 5, (line + labelLines + ammolines) * buttonHeight, (width - (10 * margin)) / 2, buttonHeight), Localizer.Format("#LOC_BDArmory_reset")))
            {
                beltString  = String.Empty;
                GUIstring   = String.Empty;
                countString = String.Empty;
                labelLines  = 1;
            }
            if (GUI.Button(new Rect(((margin * 5) + ((width - (10 * margin)) / 2)), (line + labelLines + ammolines) * buttonHeight, (width - (10 * margin)) / 2, buttonHeight), Localizer.Format("#LOC_BDArmory_save")))
            {
                save = true;
                open = false;
            }
            line             += 1.5f;
            height            = Mathf.Lerp(height, (line + labelLines + ammolines) * buttonHeight, 0.15f);
            windowRect.height = height;
            GUI.DragWindow();
            BDGUIUtils.RepositionWindow(ref windowRect);
        }
        private void WindowVesselSwitcher(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);
        }