public static void Postfix(HatsTab __instance) { for (int i = 0; i < __instance.ColorChips.Count; i++) { var hat = __instance.ColorChips[i]; hat.transform.localScale *= 0.7f; } }
public static void Postfix(HatsTab __instance) { // Manually hide all custom TMPro.TMP_Text objects that are outside the ScrollRect foreach (TMPro.TMP_Text customText in hatsTabCustomTexts) { if (customText != null && customText.transform != null && customText.gameObject != null) { bool active = customText.transform.position.y <= inventoryTop && customText.transform.position.y >= inventoryBot; float epsilon = Mathf.Min(Mathf.Abs(customText.transform.position.y - inventoryTop), Mathf.Abs(customText.transform.position.y - inventoryBot)); if (active != customText.gameObject.active && epsilon > 0.1f) { customText.gameObject.SetActive(active); } } } }
public static float createHatPackage(List <System.Tuple <HatData, HatExtension> > hats, string packageName, float YStart, HatsTab __instance) { float offset = YStart; if (textTemplate != null) { TMPro.TMP_Text title = UnityEngine.Object.Instantiate <TMPro.TMP_Text>(textTemplate, __instance.scroller.Inner); title.transform.parent = __instance.scroller.Inner; title.transform.localPosition = new Vector3(headerX, YStart, inventoryZ); title.alignment = TMPro.TextAlignmentOptions.Center; title.fontSize *= 1.25f; title.fontWeight = TMPro.FontWeight.Thin; title.enableAutoSizing = false; title.autoSizeTextContainer = true; title.text = ModTranslation.getString(packageName); offset -= headerSize * __instance.YOffset; hatsTabCustomTexts.Add(title); } var numHats = hats.Count; for (int i = 0; i < hats.Count; i++) { HatData hat = hats[i].Item1; HatExtension ext = hats[i].Item2; float xpos = __instance.XRange.Lerp((i % __instance.NumPerRow) / (__instance.NumPerRow - 1f)); float ypos = offset - (i / __instance.NumPerRow) * __instance.YOffset; ColorChip colorChip = UnityEngine.Object.Instantiate <ColorChip>(__instance.ColorTabPrefab, __instance.scroller.Inner); int color = __instance.HasLocalPlayer() ? PlayerControl.LocalPlayer.Data.DefaultOutfit.ColorId : SaveManager.BodyColor; colorChip.transform.localPosition = new Vector3(xpos, ypos, inventoryZ); if (ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard) { colorChip.Button.OnMouseOver.AddListener((UnityEngine.Events.UnityAction)(() => __instance.SelectHat(hat))); colorChip.Button.OnMouseOut.AddListener((UnityEngine.Events.UnityAction)(() => __instance.SelectHat(DestroyableSingleton <HatManager> .Instance.GetHatById(SaveManager.LastHat)))); colorChip.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() => __instance.ClickEquip())); } else { colorChip.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() => __instance.SelectHat(hat))); } colorChip.Inner.SetHat(hat, color); colorChip.Inner.transform.localPosition = hat.ChipOffset; colorChip.Tag = hat; colorChip.Button.ClickMask = __instance.scroller.Hitbox; __instance.ColorChips.Add(colorChip); } return(offset - ((numHats - 1) / __instance.NumPerRow) * __instance.YOffset - headerSize); }
public static bool Prefix(HatsTab __instance) { calcItemBounds(__instance); HatData[] unlockedHats = DestroyableSingleton <HatManager> .Instance.GetUnlockedHats(); Dictionary <string, List <System.Tuple <HatData, HatExtension> > > packages = new Dictionary <string, List <System.Tuple <HatData, HatExtension> > >(); Helpers.destroyList(hatsTabCustomTexts); Helpers.destroyList(__instance.ColorChips); hatsTabCustomTexts.Clear(); __instance.ColorChips.Clear(); textTemplate = PlayerCustomizationMenu.Instance.itemName; foreach (HatData hatData in unlockedHats) { HatExtension ext = hatData.getHatExtension(); if (ext != null) { if (!packages.ContainsKey(ext.package)) { packages[ext.package] = new List <System.Tuple <HatData, HatExtension> >(); } packages[ext.package].Add(new System.Tuple <HatData, HatExtension>(hatData, ext)); } else { if (!packages.ContainsKey(innerslothPackageName)) { packages[innerslothPackageName] = new List <System.Tuple <HatData, HatExtension> >(); } packages[innerslothPackageName].Add(new System.Tuple <HatData, HatExtension>(hatData, null)); } } float YOffset = __instance.YStart; var orderedKeys = packages.Keys.OrderBy((string x) => { if (x == innerslothPackageName) { return(100003); } if (x == "developerHats") { return(10000); } if (x.Contains("gmEdition")) { return(10002); } if (x.Contains("shiune")) { return(10001); } if (x.Contains("01haomingHat")) { return(0); } if (x.Contains("02haomingHat")) { return(1); } return(500); }); foreach (string key in orderedKeys) { List <System.Tuple <HatData, HatExtension> > value = packages[key]; YOffset = createHatPackage(value, key, YOffset, __instance); } __instance.scroller.ContentYBounds.max = -(YOffset + 3.0f + headerSize); return(false); }
public static void calcItemBounds(HatsTab __instance) { inventoryTop = __instance.scroller.Inner.position.y - 0.5f; inventoryBot = __instance.scroller.Inner.position.y - 4.5f; }
public static void Postfix(HatsTab __instance) { var allHats = DestroyableSingleton <HatManager> .Instance.GetUnlockedHats(); var hatGroups = new SortedList <string, List <HatBehaviour> >( new PaddedComparer <string>("Vanilla", "") ); foreach (var hat in allHats) { if (!hatGroups.ContainsKey(hat.StoreName)) { hatGroups[hat.StoreName] = new List <HatBehaviour>(); } hatGroups[hat.StoreName].Add(hat); } foreach (ColorChip instanceColorChip in __instance.ColorChips) { instanceColorChip.gameObject.Destroy(); } __instance.ColorChips.Clear(); var groupNameText = __instance.transform.parent.parent.GetComponentInChildren <GameSettingMenu>(true).GetComponentInChildren <TextMeshPro>(true); int hatIdx = 0; foreach ((string groupName, List <HatBehaviour> hats) in hatGroups) { var text = Object.Instantiate(groupNameText.gameObject); text.transform.localScale = Vector3.one; text.transform.parent = __instance.scroller.Inner; var tmp = text.GetComponent <TextMeshPro>(); tmp.text = groupName; tmp.alignment = TextAlignmentOptions.Center; tmp.fontSize = 3f; tmp.fontSizeMax = 3f; tmp.fontSizeMin = 0f; hatIdx = (hatIdx + 3) / 4 * 4; float xLerp = __instance.XRange.Lerp(0.5f); float yLerp = __instance.YStart - (hatIdx / __instance.NumPerRow) * __instance.YOffset; text.transform.localPosition = new Vector3(xLerp, yLerp, -1f); hatIdx += 4; foreach (var hat in hats.OrderBy(HatManager.Instance.GetIdFromHat)) { float num = __instance.XRange.Lerp(hatIdx % __instance.NumPerRow / (__instance.NumPerRow - 1f)); float num2 = __instance.YStart - hatIdx / __instance.NumPerRow * __instance.YOffset; ColorChip colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner); colorChip.transform.localPosition = new Vector3(num, num2, -1f); colorChip.Button.OnClick.AddListener((Action)(() => __instance.SelectHat(hat))); colorChip.Inner.SetHat(hat, PlayerControl.LocalPlayer.Data.ColorId); colorChip.Inner.transform.localPosition = hat.ChipOffset + new Vector2(0f, -0.3f); colorChip.Tag = hat; __instance.ColorChips.Add(colorChip); hatIdx += 1; } } __instance.scroller.YBounds.max = -(__instance.YStart - (hatIdx + 1) / __instance.NumPerRow * __instance.YOffset) - 3f; }
public static bool Prefix(HatsTab __instance) { PlayerControl.SetPlayerMaterialColors(PlayerControl.LocalPlayer.Data.ColorId, __instance.DemoImage); __instance.HatImage.SetHat(SaveManager.LastHat, PlayerControl.LocalPlayer.Data.ColorId); PlayerControl.SetSkinImage(SaveManager.LastSkin, __instance.SkinImage); PlayerControl.SetPetImage(SaveManager.LastPet, PlayerControl.LocalPlayer.Data.ColorId, __instance.PetImage); HatBehaviour[] unlockedHats = DestroyableSingleton <HatManager> .Instance.GetUnlockedHats(); Dictionary <string, List <System.Tuple <HatBehaviour, HatExtension> > > packages = new Dictionary <string, List <System.Tuple <HatBehaviour, HatExtension> > >(); hatsTabCustomTexts = new List <TMPro.TMP_Text>(); foreach (HatBehaviour hatBehaviour in unlockedHats) { HatExtension ext = hatBehaviour.getHatExtension(); if (ext != null) { if (!packages.ContainsKey(ext.package)) { packages[ext.package] = new List <System.Tuple <HatBehaviour, HatExtension> >(); } packages[ext.package].Add(new System.Tuple <HatBehaviour, HatExtension>(hatBehaviour, ext)); } else { if (!packages.ContainsKey(innerslothPackageName)) { packages[innerslothPackageName] = new List <System.Tuple <HatBehaviour, HatExtension> >(); } packages[innerslothPackageName].Add(new System.Tuple <HatBehaviour, HatExtension>(hatBehaviour, null)); } } float YOffset = __instance.YStart; var hatButton = GameObject.Find("HatButton"); if (hatButton != null && hatButton.transform.FindChild("ButtonText_TMP") != null) { textTemplate = hatButton.transform.FindChild("ButtonText_TMP").GetComponent <TMPro.TMP_Text>(); } var orderedKeys = packages.Keys.OrderBy((string x) => { if (x == innerslothPackageName) { return(1000); } if (x == "Developer Hats") { return(0); } return(500); }); foreach (string key in orderedKeys) { List <System.Tuple <HatBehaviour, HatExtension> > value = packages[key]; YOffset = createHatPackage(value, key, YOffset, __instance); } // __instance.scroller.YBounds.max = -(__instance.YStart - (float)(unlockedHats.Length / this.NumPerRow) * this.YOffset) - 3f; // __instance.scroller.YBounds.max = YOffset * -0.875f; // probably needs to fix up the entire messed math to solve this correctly __instance.scroller.YBounds.max = -(YOffset + 4.1f); return(false); }
public static float createHatPackage(List <System.Tuple <HatBehaviour, HatExtension> > hats, string packageName, float YStart, HatsTab __instance) { bool isDefaultPackage = innerslothPackageName == packageName; float offset = YStart; if (textTemplate != null) { TMPro.TMP_Text title = UnityEngine.Object.Instantiate <TMPro.TMP_Text>(textTemplate, __instance.scroller.Inner); title.transform.localPosition = new Vector3(2.25f, YStart, -1f); title.transform.localScale = Vector3.one * 1.5f; // title.currentFontSize title.fontSize *= 0.5f; title.enableAutoSizing = false; __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => { title.SetText(packageName); }))); offset -= 0.8f * __instance.YOffset; hatsTabCustomTexts.Add(title); } for (int i = 0; i < hats.Count; i++) { HatBehaviour hat = hats[i].Item1; HatExtension ext = hats[i].Item2; float xpos = __instance.XRange.Lerp((i % __instance.NumPerRow) / (__instance.NumPerRow - 1f)); float ypos = offset - (i / __instance.NumPerRow) * (isDefaultPackage ? 1f : 1.5f) * __instance.YOffset; ColorChip colorChip = UnityEngine.Object.Instantiate <ColorChip>(__instance.ColorTabPrefab, __instance.scroller.Inner); if (ext != null) { Transform background = colorChip.transform.FindChild("Background"); Transform foreground = colorChip.transform.FindChild("ForeGround"); if (background != null) { background.localScale = new Vector3(1, 1.5f, 1); background.localPosition = Vector3.down * 0.243f; } if (foreground != null) { foreground.localPosition = Vector3.down * 0.243f; } if (textTemplate != null) { TMPro.TMP_Text description = UnityEngine.Object.Instantiate <TMPro.TMP_Text>(textTemplate, colorChip.transform); description.transform.localPosition = new Vector3(0f, -0.75f, -1f); description.transform.localScale = Vector3.one * 0.7f; __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => { description.SetText($"{hat.name}\nby {ext.author}"); }))); hatsTabCustomTexts.Add(description); } if (!ext.isUnlocked()) // Hat is locked { UnityEngine.Object.Destroy(colorChip.Button); var overlay = UnityEngine.Object.Instantiate(colorChip.InUseForeground, colorChip.transform); overlay.SetActive(true); } } colorChip.transform.localPosition = new Vector3(xpos, ypos, -1f); colorChip.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() => { __instance.SelectHat(hat); })); colorChip.Inner.SetHat(hat, PlayerControl.LocalPlayer.Data.ColorId); colorChip.Inner.transform.localPosition = hat.ChipOffset; colorChip.Tag = hat; __instance.ColorChips.Add(colorChip); } return(offset - ((hats.Count - 1) / __instance.NumPerRow) * (isDefaultPackage ? 1f : 1.5f) * __instance.YOffset - 0.85f); }
public static bool Prefix(HatsTab __instance) { // Colors and hats are always disabled if mod is active. That is the reason for the mod. return(!MarkModeMain.ModActive.GetValue()); }