public override void OnStart(StartState state) { Personaliser personaliser = Personaliser.instance; if (!isInitialised) { if (!personaliser.isAtmSuitEnabled) { Events.First().active = false; hasEvaSuit = true; } isInitialised = true; } if (!personaliser.personaliseEva(part, hasEvaSuit)) { hasEvaSuit = true; } if (Reflections.instance.isVisorReflectionEnabled && Reflections.instance.reflectionType == Reflections.Type.REAL) { reflectionScript = new Reflections.Script(part, 1); reflectionScript.setActive(hasEvaSuit); } }
private static void Load() { log.Print("Started, Version {0}", Assembly.GetExecutingAssembly().GetName().Version); Prefab.Recreate(); Mapper.Recreate(); Replacer.Recreate(); Reflections.Recreate(); Personaliser.Recreate(); foreach (UrlDir.UrlConfig file in GameDatabase.Instance.GetConfigs("TextureReplacer")) { Prefab.Instance.ReadConfig(file.config); Replacer.Instance.ReadConfig(file.config); Reflections.Instance.ReadConfig(file.config); } Prefab.Instance.Load(); Mapper.Instance.Load(); Replacer.Instance.Load(); Reflections.Instance.Load(); Personaliser.Instance.Load(); isLoaded = true; }
public void Update() { Personaliser personaliser = Personaliser.instance; if (!hasEvaSuit && !personaliser.isAtmBreathable()) { personaliser.personaliseEva(part, true); hasEvaSuit = true; if (reflectionScript != null) { reflectionScript.setActive(true); } } }
public void toggleEvaSuit() { Personaliser personaliser = Personaliser.instance; if (personaliser.personaliseEva(part, !hasEvaSuit)) { hasEvaSuit = !hasEvaSuit; if (reflectionScript != null) { reflectionScript.setActive(hasEvaSuit); } } else { ScreenMessages.PostScreenMessage("No breathable atmosphere", 5.0f, ScreenMessageStyle.UPPER_CENTER); } }
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.defaultHead[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.defaultHead[(int)selectedKerbal.gender]; head = personaliser.getKerbalHead(selectedKerbal, kerbalData); suit = personaliser.getKerbalSuit(selectedKerbal, kerbalData); headIndex = personaliser.heads.IndexOf(head); suitIndex = personaliser.suits.IndexOf(suit); } else if (selectedClass != null) { personaliser.classSuits.TryGetValue(selectedClass, out suit); if (suit != null) { suitIndex = personaliser.suits.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.heads.Count != 0; if (GUILayout.Button("<")) { headIndex = headIndex == -1 ? 0 : headIndex; headIndex = (personaliser.heads.Count + headIndex - 1) % personaliser.heads.Count; kerbalData.head = personaliser.heads[headIndex]; } if (GUILayout.Button(">")) { headIndex = (headIndex + 1) % personaliser.heads.Count; kerbalData.head = personaliser.heads[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.suits.Count != 0; if (GUILayout.Button("<")) { suitIndex = suitIndex == -1 ? 0 : suitIndex; suitIndex = (personaliser.suits.Count + suitIndex - 1) % personaliser.suits.Count; if (kerbalData != null) { kerbalData.suit = personaliser.suits[suitIndex]; kerbalData.cabinSuit = null; } else { personaliser.classSuits[selectedClass] = personaliser.suits[suitIndex]; } } if (GUILayout.Button(">")) { suitIndex = (suitIndex + 1) % personaliser.suits.Count; if (kerbalData != null) { kerbalData.suit = personaliser.suits[suitIndex]; kerbalData.cabinSuit = null; } else { personaliser.classSuits[selectedClass] = personaliser.suits[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.classSuits[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.classSuits[selectedClass] = null; } } GUI.color = Color.white; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(10); personaliser.isHelmetRemovalEnabled = GUILayout.Toggle( personaliser.isHelmetRemovalEnabled, "Remove IVA helmets in safe situations"); personaliser.isAtmSuitEnabled = GUILayout.Toggle( personaliser.isAtmSuitEnabled, "Spawn Kerbals in IVA suits when in breathable atmosphere"); 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)); }
public static void Recreate() { Instance = new Personaliser(); }
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 = ClassColour; // 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. Skin defaultSkin = personaliser.DefaultSkin[0]; Suit defaultSuit = personaliser.DefaultSuit; Appearance appearance = null; Skin skin = null; Suit suit = null; int skinIndex = -1; int suitIndex = -1; if (selectedKerbal != null) { if (selectedKerbal.suit == KerbalSuit.Vintage) { defaultSuit = personaliser.VintageSuit; } appearance = personaliser.GetAppearance(selectedKerbal); defaultSkin = personaliser.DefaultSkin[(int)selectedKerbal.gender]; skin = personaliser.GetKerbalSkin(selectedKerbal, appearance); suit = personaliser.GetKerbalSuit(selectedKerbal, appearance); skinIndex = personaliser.Skins.IndexOf(skin); suitIndex = personaliser.Suits.IndexOf(suit); } else if (selectedClass != null) { personaliser.ClassSuits.TryGetValue(selectedClass, out suit); if (suit != null) { suitIndex = personaliser.Suits.IndexOf(suit); } } GUILayout.Space(10); GUILayout.BeginVertical(); if (skin != null) { GUILayout.Box(skin.Head, GUILayout.Width(200), GUILayout.Height(200)); GUILayout.Label(skin.Name); } if (suit != null) { Texture2D suitTex = suit == defaultSuit && selectedKerbal != null && selectedKerbal.veteran ? suit.IvaSuitVeteran : suit.IvaSuit[0]; Texture2D evaSuitTex = suit.EvaSuit[0] ?? defaultSuit.EvaSuit[0]; GUILayout.BeginHorizontal(); GUILayout.Box(suitTex, GUILayout.Width(100), GUILayout.Height(100)); GUILayout.Space(10); GUILayout.Box(evaSuitTex, GUILayout.Width(100), GUILayout.Height(100)); GUILayout.EndHorizontal(); GUILayout.Label(suit.Name); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(120)); bool isKerbalSelected = appearance != null; bool isClassSelected = selectedClass != null; if (isKerbalSelected) { GUILayout.BeginHorizontal(); GUI.enabled = personaliser.Skins.Count != 0; if (GUILayout.Button("<")) { skinIndex = skinIndex == -1 ? 0 : skinIndex; skinIndex = (personaliser.Skins.Count + skinIndex - 1) % personaliser.Skins.Count; appearance.Skin = personaliser.Skins[skinIndex]; } if (GUILayout.Button(">")) { skinIndex = (skinIndex + 1) % personaliser.Skins.Count; appearance.Skin = personaliser.Skins[skinIndex]; } GUI.enabled = true; GUILayout.EndHorizontal(); GUI.color = appearance.Skin == defaultSkin ? SelectedColour : Color.white; if (GUILayout.Button("Default")) { appearance.Skin = defaultSkin; } GUI.color = appearance.Skin == null ? SelectedColour : Color.white; if (GUILayout.Button("Unset/Generic")) { appearance.Skin = null; } GUI.color = Color.white; selectedKerbal.veteran = GUILayout.Toggle(selectedKerbal.veteran, "Veteran"); } if (isKerbalSelected || isClassSelected) { bool isVintage = false; if (isKerbalSelected) { isVintage = selectedKerbal.suit == KerbalSuit.Vintage; GUILayout.Space(100); } GUILayout.BeginHorizontal(); GUI.enabled = personaliser.Suits.Count != 0; if (GUILayout.Button("<")) { suitIndex = suitIndex == -1 ? 0 : suitIndex; suitIndex = (personaliser.Suits.Count + suitIndex - 1) % personaliser.Suits.Count; if (isClassSelected) { personaliser.ClassSuits[selectedClass] = personaliser.Suits[suitIndex]; } else { appearance.Suit = personaliser.Suits[suitIndex]; } } if (GUILayout.Button(">")) { suitIndex = (suitIndex + 1) % personaliser.Suits.Count; if (isClassSelected) { personaliser.ClassSuits[selectedClass] = personaliser.Suits[suitIndex]; } else { appearance.Suit = personaliser.Suits[suitIndex]; } } GUI.enabled = true; GUILayout.EndHorizontal(); bool hasKerbalGenericSuit = isKerbalSelected && appearance.Suit == null; GUI.color = suit == defaultSuit && !hasKerbalGenericSuit ? SelectedColour : Color.white; if (GUILayout.Button("Default")) { if (isClassSelected) { personaliser.ClassSuits[selectedClass] = defaultSuit; } else { appearance.Suit = defaultSuit; } } GUI.color = suit == null || hasKerbalGenericSuit ? SelectedColour : Color.white; if (GUILayout.Button("Unset/Generic")) { if (isClassSelected) { personaliser.ClassSuits[selectedClass] = null; } else { appearance.Suit = null; } } GUI.color = Color.white; if (isKerbalSelected) { isVintage = GUILayout.Toggle(isVintage, "Vintage"); selectedKerbal.suit = isVintage ? KerbalSuit.Vintage : KerbalSuit.Default; // Make sure the right kind of default suit is selected. if (appearance.Suit == personaliser.DefaultSuit || appearance.Suit == personaliser.VintageSuit) { appearance.Suit = defaultSuit; } } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); bool enableReflections = reflections.ReflectionType == Reflections.Type.Real; enableReflections = GUILayout.Toggle(enableReflections, "Enable real-time reflections for visors and parts"); reflections.ReflectionType = enableReflections ? Reflections.Type.Real : Reflections.Type.None; bool hideParachuteBackpack = personaliser.HideParachuteBackpack; hideParachuteBackpack = GUILayout.Toggle(hideParachuteBackpack, "Hide parachute backpack"); personaliser.HideParachuteBackpack = hideParachuteBackpack; GUILayout.EndVertical(); GUI.DragWindow(new Rect(0, 0, Screen.width, 30)); }