public static void UIStatisticsWindow__OnUpdate_Prefix(UIStatisticsWindow __instance) { if (statWindow == null) { statWindow = __instance; } lastStatTimer = __instance.timeLevel; }
public static void UIProductionStatWindow_ComputeDisplayEntries_Prefix(UIStatisticsWindow __instance) { if (Time.frameCount % 10 != 0) { return; } counter.Clear(); if (__instance.astroFilter == -1) { int factoryCount = __instance.gameData.factoryCount; for (int i = 0; i < factoryCount; i++) { AddPlanetFactoryData(__instance.gameData.factories[i]); } } else if (__instance.astroFilter == 0) { AddPlanetFactoryData(__instance.gameData.localPlanet.factory); } else if (__instance.astroFilter % 100 > 0) { PlanetData planetData = __instance.gameData.galaxy.PlanetById(__instance.astroFilter); AddPlanetFactoryData(planetData.factory); } else if (__instance.astroFilter % 100 == 0) { int starId = __instance.astroFilter / 100; StarData starData = __instance.gameData.galaxy.StarById(starId); for (int j = 0; j < starData.planetCount; j++) { if (starData.planets[j].factory != null) { AddPlanetFactoryData(starData.planets[j].factory); } } } }
public static void UIStatisticsWindow__OnOpen_Postfix(UIStatisticsWindow __instance) { if (statWindow == null) { statWindow = __instance; } if (chxGO != null) { return; } var favoritesLabel = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Statistics Window/product-bg/top/favorite-text"); if (favoritesLabel != null) { favoritesLabel.SetActive(false); } sprOn = Sprite.Create(texOn, new Rect(0, 0, texOn.width, texOn.height), new Vector2(0.5f, 0.5f)); sprOff = Sprite.Create(texOff, new Rect(0, 0, texOff.width, texOff.height), new Vector2(0.5f, 0.5f)); chxGO = new GameObject("displaySec"); RectTransform rect = chxGO.AddComponent <RectTransform>(); rect.SetParent(__instance.productSortBox.transform.parent, false); rect.anchorMax = new Vector2(0, 1); rect.anchorMin = new Vector2(0, 1); rect.sizeDelta = new Vector2(20, 20); rect.pivot = new Vector2(0, 0.5f); rect.anchoredPosition = new Vector2(250, -33); Button _btn = rect.gameObject.AddComponent <Button>(); _btn.onClick.AddListener(() => { displayPerSecond.Value = !displayPerSecond.Value; checkBoxImage.sprite = displayPerSecond.Value ? sprOn : sprOff; }); checkBoxImage = _btn.gameObject.AddComponent <Image>(); checkBoxImage.color = new Color(0.8f, 0.8f, 0.8f, 1); checkBoxImage.sprite = displayPerSecond.Value ? sprOn : sprOff; txtGO = new GameObject("displaySecTxt"); RectTransform rectTxt = txtGO.AddComponent <RectTransform>(); rectTxt.SetParent(chxGO.transform, false); rectTxt.anchorMax = new Vector2(0, 0.5f); rectTxt.anchorMin = new Vector2(0, 0.5f); rectTxt.sizeDelta = new Vector2(100, 20); rectTxt.pivot = new Vector2(0, 0.5f); rectTxt.anchoredPosition = new Vector2(20, 0); Text text = rectTxt.gameObject.AddComponent <Text>(); text.text = "Display /sec"; text.fontStyle = FontStyle.Normal; text.fontSize = 14; text.verticalOverflow = VerticalWrapMode.Overflow; text.horizontalOverflow = HorizontalWrapMode.Wrap; text.color = new Color(0.8f, 0.8f, 0.8f, 1); Font fnt = Resources.Load <Font>("ui/fonts/SAIRASB"); if (fnt != null) { text.font = fnt; } filterGO = new GameObject("filterGo"); RectTransform rectFilter = filterGO.AddComponent <RectTransform>(); rectFilter.SetParent(__instance.productSortBox.transform.parent, false); rectFilter.anchorMax = new Vector2(0, 1); rectFilter.anchorMin = new Vector2(0, 1); rectFilter.sizeDelta = new Vector2(100, 30); rectFilter.pivot = new Vector2(0, 0.5f); rectFilter.anchoredPosition = new Vector2(120, -33); var _image = filterGO.AddComponent <Image>(); _image.transform.SetParent(rectFilter, false); _image.color = new Color(0f, 0f, 0f, 0.5f); GameObject textContainer = new GameObject(); textContainer.name = "Text"; textContainer.transform.SetParent(rectFilter, false); var _text = textContainer.AddComponent <Text>(); _text.supportRichText = false; _text.color = new Color(0.8f, 0.8f, 0.8f, 1); _text.font = fnt; _text.fontSize = 16; _text.alignment = TextAnchor.MiddleLeft; _text.horizontalOverflow = HorizontalWrapMode.Overflow; (_text.transform as RectTransform).sizeDelta = new Vector2(90, 30); (_text.transform as RectTransform).anchoredPosition = new Vector2(5, 0); GameObject placeholderContainer = new GameObject(); placeholderContainer.name = "Placeholder"; placeholderContainer.transform.SetParent(rectFilter, false); var _placeholder = placeholderContainer.AddComponent <Text>(); _placeholder.color = new Color(0.8f, 0.8f, 0.8f, 1); _placeholder.font = fnt; _placeholder.fontSize = 16; _placeholder.fontStyle = FontStyle.Italic; _placeholder.alignment = TextAnchor.MiddleLeft; _placeholder.supportRichText = false; _placeholder.horizontalOverflow = HorizontalWrapMode.Overflow; _placeholder.text = "Filter"; (_placeholder.transform as RectTransform).sizeDelta = new Vector2(90, 30); (_placeholder.transform as RectTransform).anchoredPosition = new Vector2(5, 0); var _inputField = filterGO.AddComponent <InputField>(); _inputField.transform.SetParent(rectFilter, false); _inputField.targetGraphic = _image; _inputField.textComponent = _text; _inputField.placeholder = _placeholder; _inputField.onValueChanged.AddListener((string value) => { filterStr = value; __instance.ComputeDisplayEntries(); }); chxGO.transform.SetParent(__instance.productSortBox.transform.parent, false); txtGO.transform.SetParent(chxGO.transform, false); filterGO.transform.SetParent(__instance.productSortBox.transform.parent, false); }