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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }