예제 #1
0
        /// <summary>
        /// Loads all Heads into a non gender-specific list and in two gender-specific lists
        /// </summary>
        internal static void LoadHeads(List <Personaliser.Head> FullList, List <Personaliser.Head>[] GenderList)
        {
            string[] gender = { "Male", "Female" };

            for (int i = 0; i < 2; i++)
            {
                foreach (string folder in Folders.HEADS)
                {
                    foreach (GameDatabase.TextureInfo texInfo in GameDatabase.Instance.databaseTexture.Where(t => t.texture != null && t.name.StartsWith((folder + gender[i] + "/"), StringComparison.Ordinal) && !t.name.EndsWith("NRM")))
                    {
                        string headName = texInfo.name.Substring((folder + gender[i] + "/").Length);
                        if (FullList.Any(t => t.name == headName))
                        {
                            continue;
                        }

                        Texture2D texture = texInfo.texture;
                        texture.wrapMode = TextureWrapMode.Clamp;

                        Personaliser.Head head = new Personaliser.Head
                        {
                            name     = headName,
                            head     = texture,
                            isFemale = (i == 1)
                        };

                        Texture2D normal = GameDatabase.Instance.databaseTexture.FirstOrDefault(t => t.name == (texInfo.name + "NRM"))?.texture;

                        if (normal != null)
                        {
                            normal.wrapMode = TextureWrapMode.Clamp;
                            head.headNRM    = normal;
                        }

                        FullList.Add(head);
                        GenderList[i].Add(head);
                    }
                }
            }
        }
예제 #2
0
        /// ////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// The method that populate the GUI window
        /// </summary>
        /// <param name="id"></param>
        /// ////////////////////////////////////////////////////////////////////////////////////////
        private void windowHandler(int id)
        {
            Reflections  reflections  = Reflections.instance;
            Personaliser personaliser = Personaliser.instance;

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(200));

            // Roster area.
            rosterScroll = GUILayout.BeginScrollView(rosterScroll);
            GUILayout.BeginVertical();

            foreach (ProtoCrewMember kerbal in HighLogic.CurrentGame.CrewRoster.Crew)
            {
                switch (kerbal.rosterStatus)
                {
                case ProtoCrewMember.RosterStatus.Assigned:
                    GUI.contentColor = Color.cyan;
                    break;

                case ProtoCrewMember.RosterStatus.Dead:
                    continue;

                case ProtoCrewMember.RosterStatus.Missing:
                    GUI.contentColor = Color.yellow;
                    break;

                default:
                    GUI.contentColor = Color.white;
                    break;
                }

                if (GUILayout.Button(kerbal.name))
                {
                    selectedKerbal = kerbal;
                    selectedClass  = null;
                }
            }

            foreach (ProtoCrewMember kerbal in HighLogic.CurrentGame.CrewRoster.Unowned)
            {
                switch (kerbal.rosterStatus)
                {
                case ProtoCrewMember.RosterStatus.Dead:
                    GUI.contentColor = Color.cyan;
                    break;

                default:
                    continue;
                }

                if (GUILayout.Button(kerbal.name))
                {
                    selectedKerbal = kerbal;
                    selectedClass  = null;
                }
            }

            GUI.contentColor = Color.white;
            GUI.color        = CLASS_COLOUR;

            // Class suits.
            foreach (string clazz in classes)
            {
                if (GUILayout.Button(clazz))
                {
                    selectedKerbal = null;
                    selectedClass  = clazz;
                }
            }

            GUI.color = Color.white;

            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            if (GUILayout.Button("Reset to Defaults"))
            {
                personaliser.resetKerbals();
            }

            GUILayout.EndVertical();

            // Textures.
            Personaliser.Head       defaultHead = personaliser.defaulMaleAndFemaleHeads[0];
            Personaliser.Suit       defaultSuit = personaliser.defaultSuit;
            Personaliser.KerbalData kerbalData  = null;
            Personaliser.Head       head        = null;
            Personaliser.Suit       suit        = null;
            int headIndex = -1;
            int suitIndex = -1;

            if (selectedKerbal != null)
            {
                kerbalData  = personaliser.getKerbalData(selectedKerbal);
                defaultHead = personaliser.defaulMaleAndFemaleHeads[(int)selectedKerbal.gender];

                head = personaliser.getKerbalHead(selectedKerbal, kerbalData);
                suit = personaliser.getKerbalSuit(selectedKerbal, kerbalData);

                headIndex = personaliser.KerbalHeadsDB_full.IndexOf(head);
                suitIndex = personaliser.KerbalSuitsDB_full.IndexOf(suit);
            }
            else if (selectedClass != null)
            {
                personaliser.classSuitsDB.TryGetValue(selectedClass, out suit);

                if (suit != null)
                {
                    suitIndex = personaliser.KerbalSuitsDB_full.IndexOf(suit);
                }
            }

            GUILayout.Space(10);
            GUILayout.BeginVertical();

            if (head != null)
            {
                GUILayout.Box(head.head, GUILayout.Width(200), GUILayout.Height(200));

                GUILayout.Label(head.name);
            }

            if (suit != null)
            {
                Texture2D suitTex = suit == defaultSuit && kerbalData != null && kerbalData.isVeteran ?
                                    defaultSuit.suitVeteran : (suit.suit ?? defaultSuit.suit);
                Texture2D helmetTex    = suit.helmet ?? defaultSuit.helmet;
                Texture2D evaSuitTex   = suit.evaSuit ?? defaultSuit.evaSuit;
                Texture2D evaHelmetTex = suit.evaHelmet ?? defaultSuit.evaHelmet;

                GUILayout.BeginHorizontal();
                GUILayout.Box(suitTex, GUILayout.Width(100), GUILayout.Height(100));
                GUILayout.Space(10);
                GUILayout.Box(helmetTex, GUILayout.Width(100), GUILayout.Height(100));
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                GUILayout.BeginHorizontal();
                GUILayout.Box(evaSuitTex, GUILayout.Width(100), GUILayout.Height(100));
                GUILayout.Space(10);
                GUILayout.Box(evaHelmetTex, GUILayout.Width(100), GUILayout.Height(100));
                GUILayout.EndHorizontal();

                GUILayout.Label(suit.name);
            }

            GUILayout.EndVertical();
            GUILayout.BeginVertical(GUILayout.Width(120));

            if (kerbalData != null)
            {
                GUILayout.BeginHorizontal();
                GUI.enabled = personaliser.KerbalHeadsDB_full.Count != 0;

                if (GUILayout.Button("<"))
                {
                    headIndex = headIndex == -1 ? 0 : headIndex;
                    headIndex = (personaliser.KerbalHeadsDB_full.Count + headIndex - 1) % personaliser.KerbalHeadsDB_full.Count;

                    kerbalData.head = personaliser.KerbalHeadsDB_full[headIndex];
                }
                if (GUILayout.Button(">"))
                {
                    headIndex = (headIndex + 1) % personaliser.KerbalHeadsDB_full.Count;

                    kerbalData.head = personaliser.KerbalHeadsDB_full[headIndex];
                }

                GUI.enabled = true;
                GUILayout.EndHorizontal();

                GUI.color = kerbalData.head == defaultHead ? SELECTED_COLOUR : Color.white;
                if (GUILayout.Button("Default"))
                {
                    kerbalData.head = defaultHead;
                }

                GUI.color = kerbalData.head == null ? SELECTED_COLOUR : Color.white;
                if (GUILayout.Button("Unset/Generic"))
                {
                    kerbalData.head = null;
                }

                GUI.color = Color.white;
            }

            if (kerbalData != null || selectedClass != null)
            {
                GUILayout.Space(130);

                GUILayout.BeginHorizontal();
                GUI.enabled = personaliser.KerbalSuitsDB_full.Count != 0;

                if (GUILayout.Button("<"))
                {
                    suitIndex = suitIndex == -1 ? 0 : suitIndex;
                    suitIndex = (personaliser.KerbalSuitsDB_full.Count + suitIndex - 1) % personaliser.KerbalSuitsDB_full.Count;

                    if (kerbalData != null)
                    {
                        kerbalData.suit      = personaliser.KerbalSuitsDB_full[suitIndex];
                        kerbalData.cabinSuit = null;
                    }
                    else
                    {
                        personaliser.classSuitsDB[selectedClass] = personaliser.KerbalSuitsDB_full[suitIndex];
                    }
                }
                if (GUILayout.Button(">"))
                {
                    suitIndex = (suitIndex + 1) % personaliser.KerbalSuitsDB_full.Count;

                    if (kerbalData != null)
                    {
                        kerbalData.suit      = personaliser.KerbalSuitsDB_full[suitIndex];
                        kerbalData.cabinSuit = null;
                    }
                    else
                    {
                        personaliser.classSuitsDB[selectedClass] = personaliser.KerbalSuitsDB_full[suitIndex];
                    }
                }

                GUI.enabled = true;
                GUILayout.EndHorizontal();

                GUI.color = suit == defaultSuit && (kerbalData == null || kerbalData.suit != null) ?
                            SELECTED_COLOUR : Color.white;

                if (GUILayout.Button("Default"))
                {
                    if (kerbalData != null)
                    {
                        kerbalData.suit      = defaultSuit;
                        kerbalData.cabinSuit = null;
                    }
                    else
                    {
                        personaliser.classSuitsDB[selectedClass] = defaultSuit;
                    }
                }

                GUI.color = suit == null || (kerbalData != null && kerbalData.suit == null) ? SELECTED_COLOUR : Color.white;
                if (GUILayout.Button("Unset/Generic"))
                {
                    if (kerbalData != null)
                    {
                        kerbalData.suit      = null;
                        kerbalData.cabinSuit = null;
                    }
                    else
                    {
                        personaliser.classSuitsDB[selectedClass] = null;
                    }
                }

                GUI.color = Color.white;
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.Space(10);

            personaliser.isHelmetRemovalEnabled = GUILayout.Toggle(
                personaliser.isHelmetRemovalEnabled, "Remove helmets in safe situations");

            personaliser.isAtmSuitEnabled = GUILayout.Toggle(
                personaliser.isAtmSuitEnabled, "Spawn Kerbals in IVA suits when in breathable atmosphere");

            personaliser.isNewSuitStateEnabled = GUILayout.Toggle(
                personaliser.isNewSuitStateEnabled, "Kerbals use another EVA suit when on the ground and with no air");

            Reflections.Type reflectionType = reflections.reflectionType;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Reflections", GUILayout.Width(120));
            reflectionType = (Reflections.Type)GUILayout.SelectionGrid((int)reflectionType, REFLECTION_TYPES, 3);
            GUILayout.EndHorizontal();

            if (reflectionType != reflections.reflectionType)
            {
                reflections.setReflectionType(reflectionType);
            }

            GUILayout.EndVertical();
            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
        }