using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("StatsUITweaks")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.14.0")] [module: UnverifiableCode] namespace StatsUITweaks; public class PerformancePanelPatch { private static bool initialized; private static UIButton foldBtn; private static bool folded; private static float scrollHeight = 398f; private static float scrollY = 23.5f; [HarmonyPostfix] [HarmonyPatch(typeof(UIPerformancePanel), "_OnOpen")] public static void Init(UIPerformancePanel __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) if (initialized) { return; } try { GameObject obj = Object.Instantiate(((Component)UIRoot.instance.uiGame.researchQueue.pauseButton).gameObject, ((Component)__instance).transform); ((Object)obj).name = "CustomStats_Fold"; obj.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); obj.transform.localPosition = new Vector3(-550f, 390f, 0f); Transform obj2 = obj.transform.Find("icon"); Image val = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); if ((Object)(object)val != (Object)null) { UIStarmap starmap = UIRoot.instance.uiGame.starmap; Transform obj3 = ((Component)starmap.cursorFunctionButton2).transform.Find("icon"); object sprite; if (obj3 == null) { sprite = null; } else { Image component = ((Component)obj3).GetComponent(); sprite = ((component != null) ? component.sprite : null); } val.sprite = (Sprite)sprite; } foldBtn = obj.GetComponent(); foldBtn.tips.tipTitle = "Fold 折叠饼图"; foldBtn.tips.tipText = "Click to fold/unfold pie chart"; foldBtn.onClick += OnFoldButtonClick; if (foldBtn.transitions != null) { foldBtn.transitions[0].highlightColorOverride = new Color(0.5f, 0.6f, 0.7f, 0.1f); } obj.SetActive(true); scrollHeight = __instance.cpuScrollRect.viewport.sizeDelta.y; scrollY = ((Transform)__instance.cpuScrollRect.viewport).localPosition.y; initialized = true; } catch (Exception ex) { Plugin.Log.LogError((object)"PerformancePanelPatch initial fail!"); Plugin.Log.LogError((object)ex); } Toggle(folded); } public static void OnDestory() { if (initialized) { Toggle(extendScroll: false); UIButton obj = foldBtn; Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null)); initialized = false; } } private static void OnFoldButtonClick(int obj) { folded = !folded; foldBtn.highlighted = folded; Toggle(folded); } private static void Toggle(bool extendScroll) { if (initialized) { UIPerformancePanel performancePanelUI = UIRoot.instance.uiGame.statWindow.performancePanelUI; Adjust(performancePanelUI.cpuScrollRect.viewport, extendScroll); Adjust(performancePanelUI.gpuScrollRect.viewport, extendScroll); Adjust(performancePanelUI.dataScrollRect.viewport, extendScroll); } } private static void Adjust(RectTransform scrollRect, bool extendScroll) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in ((Transform)scrollRect).parent.parent) { ((Component)item).gameObject.SetActive(!extendScroll); } ((Component)((Transform)scrollRect).parent).gameObject.SetActive(true); ((Component)scrollRect).gameObject.SetActive(true); ((Transform)scrollRect).localPosition = new Vector3(((Transform)scrollRect).localPosition.x, extendScroll ? (scrollY + 362f) : scrollY, 0f); scrollRect.sizeDelta = new Vector2(scrollRect.sizeDelta.x, extendScroll ? (scrollHeight + 372f) : scrollHeight); } } [BepInPlugin("starfi5h.plugin.StatsUITweaks", "StatsUITweaks", "1.6.14")] public class Plugin : BaseUnityPlugin { public const string GUID = "starfi5h.plugin.StatsUITweaks"; public const string NAME = "StatsUITweaks"; public const string VERSION = "1.6.14"; public static ManualLogSource Log; private static Harmony harmony; public void Awake() { //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigEntry val = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "OrderByName", true, "Order list by system name.\n以星系名称排序列表"); ConfigEntry val2 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "DropDownCount", 15, "Number of items shown in drop-down list.\n下拉列表显示的个数"); ConfigEntry val3 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "SystemPrefix", "", "Prefix string of star system in the list\n星系名称前缀"); ConfigEntry val4 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "SystemPostfix", "", "Postfix string of star system in the list\n星系名称后缀"); ConfigEntry val5 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "PlanetPrefix", "ㅤ", "Prefix string of planet in the list\n星球名称前缀"); ConfigEntry val6 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "PlanetPostfix", "", "Postfix string of planet in the list\n星球名称后缀"); ConfigEntry val7 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "HotkeyListUp", (KeyCode)280, "Move to previous item in list.\n切换至列表中上一个项目"); ConfigEntry val8 = ((BaseUnityPlugin)this).Config.Bind("AstroBox", "HotkeyListDown", (KeyCode)281, "Move to next item in list.\n切换至列表中下一个项目"); ConfigEntry val9 = ((BaseUnityPlugin)this).Config.Bind("MainWindow", "TimeSliderSlice", 20, "The number of divisions of the time range slider.\n时间范围滑杆的分割数"); ConfigEntry val10 = ((BaseUnityPlugin)this).Config.Bind("MainWindow", "ListWidthOffeset", 70, "Increase width of the list.\n增加列表栏位宽度"); ConfigEntry val11 = ((BaseUnityPlugin)this).Config.Bind("MainWindow", "RateFontSize", 26, "Adjust the font size of production rate. (Vanilla=18)\n生产速率和参考速率的字体大小(原版=18)"); ConfigEntry val12 = ((BaseUnityPlugin)this).Config.Bind("MainWindow", "RefRateTweak", false, "The reference rate (maximum theoretical value) is always applied proliferator settings, regardless the material.\n参考速率(最大理论值)一律套用增产剂设定,无论原料是否已喷涂"); ConfigEntry val13 = ((BaseUnityPlugin)this).Config.Bind("MainWindow", "RefRateMinerLimit", 14400, "Set reference rate max limit for pump and oil extractor\n為抽水機和油井的参考速率設定上限"); ConfigEntry obj = ((BaseUnityPlugin)this).Config.Bind("MainWindow", "ExcludeTrafficPeak", false, "When calculating the height of a histogram, exclude peak values \u200b\u200bfrom input and output.\n计算柱状图高度时, 排除输入和输出的峰值"); ConfigEntry val14 = ((BaseUnityPlugin)this).Config.Bind("Other", "FoldButton", true, "Add a button in perforamnce test panel to fold pie chart.\n在性能面板加入一个折叠饼图的按钮"); ConfigEntry val15 = ((BaseUnityPlugin)this).Config.Bind("Other", "HideLitterNotification", false, "Don't show trash notification (still visable in Z mode)\n隐藏平常模式的垃圾提示(Z模式仍可见)"); ConfigEntry val16 = ((BaseUnityPlugin)this).Config.Bind("Other", "HideSoilNotification", false, "Don't show soil notification\n隐藏沙土数量变动的提示"); ConfigEntry val17 = ((BaseUnityPlugin)this).Config.Bind("Dashboard", "TabSizeSwitch", true, "When hovering on an item, Tab to switch size, Ctrl+Tab to swtich title.\n鼠标悬停在某个统计项上时,Tab键切换尺寸,Ctrl+Tab键切换标题"); Utils.OrderByName = val.Value; Utils.DropDownCount = val2.Value; Utils.HotkeyListUp = val7.Value; Utils.HotkeyListDown = val8.Value; Utils.SystemPrefix = val3.Value; Utils.SystemPostfix = val4.Value; Utils.PlanetPrefix = val5.Value; Utils.PlanetPostfix = val6.Value; StatsWindowPatch.TimeSliderSlice = val9.Value; StatsWindowPatch.ListWidthOffeset = val10.Value; StatsWindowPatch.RateFontSize = val11.Value; StatsWindowPatch.ExcludeTrafficPeak = obj.Value; harmony = new Harmony("starfi5h.plugin.StatsUITweaks"); harmony.PatchAll(typeof(StatsWindowPatch)); if (val14.Value && GameConfig.gameVersion > new Version(0, 10, 32)) { harmony.PatchAll(typeof(PerformancePanelPatch)); harmony.PatchAll(typeof(UIStatisticsPowerDetailPanelPatch)); } harmony.PatchAll(typeof(UIControlPanelPatch)); harmony.PatchAll(typeof(StatsWindowPatch.Entry_Patch)); RefProductSpeedPatch.Init(harmony, val12.Value, val13.Value); harmony.PatchAll(typeof(UIGamePatch)); harmony.PatchAll(typeof(StatPlanPatch)); if (val17.Value) { harmony.PatchAll(typeof(UIChartPatch)); } harmony.PatchAll(typeof(UIChartAstroItemProductionPatch)); HarmonyMethod val18 = new HarmonyMethod(AccessTools.Method(typeof(Plugin), "Block_Prefix", (Type[])null, (Type[])null)); if (val15.Value) { harmony.Patch((MethodBase)AccessTools.Method(typeof(UITrashPanel), "DetermineVisible", (Type[])null, (Type[])null), val18, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (val16.Value) { harmony.Patch((MethodBase)AccessTools.Method(typeof(UIGame), "OnSandCountChanged", (Type[])null, (Type[])null), val18, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo = AccessTools.Method(typeof(UIOptionWindow), "CollectUILayoutHeights", (Type[])null, (Type[])null); if (methodInfo != null) { val18 = new HarmonyMethod(AccessTools.Method(typeof(Plugin), "CollectUILayoutHeights_Postfix", (Type[])null, (Type[])null)); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val18, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static bool Block_Prefix() { return false; } public static void CollectUILayoutHeights_Postfix(UIOptionWindow __instance) { List uiLayoutHeights = __instance.uiLayoutHeights; uiLayoutHeights.Add(500); uiLayoutHeights.Add(600); uiLayoutHeights.Add(700); uiLayoutHeights.Add(800); uiLayoutHeights.Sort(); } } public class RefProductSpeedPatch { private static float minerLimit = 14400f; public static void Init(Harmony harmony, bool forceInc, int limit) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (forceInc || limit >= 0) { MethodInfo methodInfo = AccessTools.Method(typeof(ProductionExtraInfoCalculator), "CalculateFactory", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(UIReferenceSpeedTip), "AddEntryDataWithFactory", (Type[])null, (Type[])null); if (forceInc) { HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(RefProductSpeedPatch), "IncUsed_Transpiler", (Type[])null, (Type[])null)); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } if (limit >= 0) { minerLimit = limit; HarmonyMethod val2 = new HarmonyMethod(AccessTools.Method(typeof(RefProductSpeedPatch), "MinerLimit_Transpiler", (Type[])null, (Type[])null)); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static IEnumerable IncUsed_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown try { return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((Func)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "incUsed"), (string)null) }).Repeat((Action)delegate(CodeMatcher matcher) { matcher.SetAndAdvance(OpCodes.Nop, (object)null).SetAndAdvance(OpCodes.Ldc_I4_1, (object)null); }, (Action)null).InstructionEnumeration(); } catch (Exception ex) { Plugin.Log.LogWarning((object)"RefProductSpeedPatch.IncUsed_Transpiler error!"); Plugin.Log.LogWarning((object)ex); return instructions; } } private static IEnumerable MinerLimit_Transpiler(IEnumerable instructions) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(Math), "Min", new Type[2] { typeof(float), typeof(float) }, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(MinerComponent), "speed"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(VeinData), "oilSpeedMultiplier"); FieldInfo fieldInfo3 = AccessTools.Field(typeof(RefProductSpeedPatch), "minerLimit"); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)fieldInfo2, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R8, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }).Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo3), new CodeInstruction(OpCodes.Call, (object)methodInfo) }); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R8, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }).Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo3), new CodeInstruction(OpCodes.Call, (object)methodInfo) }); return val.InstructionEnumeration(); } catch (Exception ex) { Plugin.Log.LogWarning((object)"RefProductSpeedPatch.MinerLimit_Transpiler error!"); Plugin.Log.LogWarning((object)ex); return instructions; } } } public class StatPlanPatch { [HarmonyFinalizer] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static Exception Get_componentId_Finalizer(SingleProducerStatPlan __instance, Exception __exception) { if (__exception != null) { Plugin.Log.LogWarning((object)"SingleStorageStatPlan.get_componentId throws an error!"); Plugin.Log.LogWarning((object)__exception); __instance.objId = 0; } return null; } [HarmonyFinalizer] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static Exception Get_componentId_Finalizer(SingleStorageStatPlan __instance, Exception __exception) { if (__exception != null) { Plugin.Log.LogWarning((object)"SingleStorageStatPlan.get_componentId throws an error!"); Plugin.Log.LogWarning((object)__exception); __instance.objId = 0; } return null; } } public class StatsWindowPatch { public class Entry_Patch { private struct Data { public long production; public long consumption; } private static float ratio = 1f; private static readonly Dictionary dict = new Dictionary(); private static readonly string[] formatF = new string[11] { "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10" }; public static void OnSliderChange(float value) { if (value < 1f) { timerSlider.value = 1f; return; } ratio = value / timerSlider.maxValue; UIRoot.instance.uiGame.statWindow.ComputeDisplayEntriesDetail(); if (ratio == 1f) { UIRoot.instance.uiGame.statWindow.ValueToTimeBox(); } else { ChangeTimeBoxText(UIRoot.instance.uiGame.statWindow); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsWindow), "ValueToTimeBox")] private static void ChangeTimeBoxText(UIStatisticsWindow __instance) { if (ratio != 1f && __instance.isStatisticsTab) { string text = $" ({100f * ratio:N0}%)"; InputField input = UIRoot.instance.uiGame.statWindow.timeBox.m_Input; switch (__instance.timeLevel) { case 0: input.text = (int)(60f * ratio + 0.5f) + Localization.Translate("空格秒") + text; break; case 1: input.text = (10f * ratio).ToString("F1") + Localization.Translate("空格分钟") + text; break; case 2: input.text = (60f * ratio).ToString("F1") + Localization.Translate("空格分钟") + text; break; case 3: input.text = (10f * ratio).ToString("F1") + Localization.Translate("统计10小时").Replace("10", " ") + text; break; case 4: input.text = (100f * ratio).ToString("F1") + Localization.Translate("统计100小时").Replace("100", " ") + text; break; case 5: input.text = Localization.Translate("统计总计") + text; break; } } } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "ComputeDisplayEntriesDetail")] private static void ClearData() { dict.Clear(); } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "ComputeFirstHalfDetailExceptLast", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int[]), typeof(long[]) })] private static bool ComputeFirstHalfDetail(int endCursor, int lvlen, int cur, int[] detail, long[] targetDetail) { if (ratio == 1f) { return true; } dict.TryGetValue(targetDetail, out var value); int num = (int)((float)lvlen * (1f - ratio) + 0.5f); int num2 = cur + num - 1; for (int i = 0; i < lvlen - num; i++) { if (++num2 > endCursor) { num2 -= lvlen; } long num3 = detail[num2]; value.production += num3; int num4 = (int)((float)(i + 1) / ratio); for (int j = (int)((float)i / ratio); j < num4; j++) { targetDetail[j] += num3; } } dict[targetDetail] = value; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "ComputeFirstHalfDetail", new Type[] { typeof(int), typeof(int), typeof(int), typeof(long[]), typeof(long[]) })] private static bool ComputeFirstHalfDetail(int endCursor, int lvlen, int cur, long[] detail, long[] targetDetail) { if (ratio == 1f) { return true; } dict.TryGetValue(targetDetail, out var value); int num = (int)((float)lvlen * (1f - ratio) + 0.5f); int num2 = cur + num - 1; for (int i = 0; i < lvlen - num; i++) { if (++num2 > endCursor) { num2 -= lvlen; } long num3 = detail[num2]; value.production += num3; int num4 = (int)((float)(i + 1) / ratio); for (int j = (int)((float)i / ratio); j < num4; j++) { targetDetail[j] += num3; } } dict[targetDetail] = value; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "ComputeSecondHalfDetailExceptLast", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int[]), typeof(long[]) })] private static bool ComputeSecondHalfDetail(int endCursor, int lvlen, int cur, int[] detail, long[] targetDetail) { if (ratio == 1f) { return true; } dict.TryGetValue(targetDetail, out var value); int num = (int)((float)lvlen * (1f - ratio) + 0.5f); int num2 = cur + num - 1; for (int i = 0; i < lvlen - num; i++) { if (++num2 > endCursor) { num2 -= lvlen; } long num3 = detail[num2]; value.consumption += num3; int num4 = (int)((float)(i + 1) / ratio); for (int j = (int)((float)i / ratio); j < num4; j++) { targetDetail[lvlen + j] += num3; } } dict[targetDetail] = value; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "ComputeSecondHalfDetail", new Type[] { typeof(int), typeof(int), typeof(int), typeof(long[]), typeof(long[]) })] private static bool ComputeSecondHalfDetail(int endCursor, int lvlen, int cur, long[] detail, long[] targetDetail) { if (ratio == 1f) { return true; } dict.TryGetValue(targetDetail, out var value); int num = (int)((float)lvlen * (1f - ratio) + 0.5f); int num2 = cur + num - 1; for (int i = 0; i < lvlen - num; i++) { if (++num2 > endCursor) { num2 -= lvlen; } long num3 = detail[num2]; value.consumption += num3; int num4 = (int)((float)(i + 1) / ratio); for (int j = (int)((float)i / ratio); j < num4; j++) { targetDetail[lvlen + j] += num3; } } dict[targetDetail] = value; return false; } [HarmonyPostfix] [HarmonyAfter(new string[] { "Bottleneck" })] [HarmonyPriority(100)] [HarmonyPatch(typeof(UIProductEntry), "_OnUpdate")] private static void UIProductEntry_ShowInText(UIProductEntry __instance) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!__instance.productionStatWindow.isProductionTab) { return; } int timeLevel = __instance.productionStatWindow.timeLevel; if (timeLevel < 5) { Text productUnitLabel = __instance.productUnitLabel; string text2 = (__instance.consumeUnitLabel.text = (DisplayPerSecond ? "/ s" : "/ min")); productUnitLabel.text = text2; } if (RateFontSize > 0) { Text productText = __instance.productText; int fontSize = (__instance.consumeText.fontSize = RateFontSize); productText.fontSize = fontSize; Text productRefSpeedText = __instance.productRefSpeedText; fontSize = (__instance.consumeRefSpeedText.fontSize = RateFontSize); productRefSpeedText.fontSize = fontSize; } ((Component)__instance.statGraph).transform.localScale = (Vector3)(ExtendGraph ? new Vector3(2.5f, 1f, 1f) : Vector3.one); ((Component)((Component)__instance.importText).transform.parent).gameObject.SetActive(!ExtendGraph); ((Component)((Component)__instance.exportText).transform.parent).gameObject.SetActive(!ExtendGraph); ((Component)((Component)__instance.importStorageCountText).transform.parent).gameObject.SetActive(!ExtendGraph); ((Component)((Component)__instance.exportStorageCountText).transform.parent).gameObject.SetActive(!ExtendGraph); ((Component)((Component)__instance.storageCountText).transform.parent).gameObject.SetActive(!ExtendGraph); ((Component)((Component)__instance.trashCountText).transform.parent).gameObject.SetActive(!ExtendGraph); double num; double num2; if (ratio == 1f || !dict.TryGetValue(__instance.entryData.productDetail, out var value)) { if (!DisplayPerSecond || timeLevel >= 5) { return; } num = __instance.entryData.production; num2 = __instance.entryData.consumption; if (num < 0.0) { num = 0.0 - num; } if (num2 < 0.0) { num2 = 0.0 - num2; } if (timeLevel < 5) { double num3 = __instance.lvDivisors[timeLevel]; num /= num3; num2 /= num3; if (DisplayPerSecond) { num /= 60.0; num2 /= 60.0; } } __instance.productText.text = ToLevelString(num); __instance.consumeText.text = ToLevelString(num2); return; } num = value.production; num2 = value.consumption; if (timeLevel < 5) { num /= __instance.lvDivisors[timeLevel] * (double)ratio; num2 /= __instance.lvDivisors[timeLevel] * (double)ratio; if (DisplayPerSecond) { num /= 60.0; num2 /= 60.0; } __instance.productSpeedTip.description = ((num >= 1000.0) ? num.ToString("#,##0") : num.ToString("#,##0.#0")); __instance.consumeSpeedTip.description = ((num2 >= 1000.0) ? num2.ToString("#,##0") : num2.ToString("#,##0.#0")); } if (DisplayPerSecond) { __instance.productText.text = ToLevelString(num); __instance.consumeText.text = ToLevelString(num2); } else { __instance.productText.text = __instance.ToLevelString(num, timeLevel); __instance.consumeText.text = __instance.ToLevelString(num2, timeLevel); } } private static string ToLevelString(double value) { if (value == 0.0) { return "0"; } string text = ""; if (value >= 1000000.0) { value /= 1000000.0; text = " M"; } else if (value >= 10000.0) { value /= 1000.0; text = " k"; } int num = 0; if (value >= 1000.0) { num = 3; } else if (value >= 100.0) { num = 2; } else if (value >= 10.0) { num = 1; } num = SignificantDigits - num - 1; if (num < 0) { num = 0; } if (num >= formatF.Length) { num = formatF.Length - 1; } if (num > 0) { double num2 = 0.1; for (int i = 0; i < num; i++) { num2 *= 0.1; } if (value - (double)(int)value < num2) { return value.ToString("F1") + text; } } return value.ToString(formatF[num]) + text; } [HarmonyPostfix] [HarmonyAfter(new string[] { "Bottleneck" })] [HarmonyPriority(100)] [HarmonyPatch(typeof(UIKillEntry), "_OnUpdate")] private static void UIKillEntry_ShowInText(UIKillEntry __instance) { if (ratio == 1f || !dict.TryGetValue(__instance.entryData.detail, out var value)) { return; } int timeLevel = __instance.productionStatWindow.timeLevel; double num = value.production; if (timeLevel < 5) { num /= __instance.lvDivisors[timeLevel] * (double)ratio; if (DisplayPerSecond) { num /= 60.0; } } __instance.killText.text = __instance.ToLevelString(num, timeLevel); } [HarmonyPostfix] [HarmonyPriority(100)] [HarmonyPatch(typeof(UIProductEntry), "RefreshStatGraphHover")] private static void RefreshStatGraphHover_Postfix(UIProductEntry __instance, float statGraphWidth) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if (ratio == 1f || (Object)(object)__instance.mouseHoverStatGraphTip == (Object)null) { return; } Vector3 mousePosition = Input.mousePosition; RectTransform rectTransform = ((Graphic)__instance.statGraph).rectTransform; Vector2 val = default(Vector2); if (!__instance.isPointerEnter || !UIRoot.ScreenPointIntoRect(mousePosition, rectTransform, ref val)) { return; } Rect rect = rectTransform.rect; float num = ((Rect)(ref rect)).width + val.x; rect = rectTransform.rect; ((Vector2)(ref val))..ctor(num, ((Rect)(ref rect)).height * 0.5f + val.y); if (!(val.x > 0f) || !(val.x < statGraphWidth) || !(val.y > 0f) || !(val.y < 100f) || !__instance.productionStatWindow.isProductionTab || !((Component)__instance.mouseHoverStatGraphTip).gameObject.activeSelf) { return; } string tipText = __instance.statGraphTipSetting.tipText; int num2 = tipText.IndexOf('\n', tipText.IndexOf('\n') + 1); if (num2 > 0) { int num3 = (int)(val.x / (float)(__instance.columnWidth + __instance.columnInterval)); int num4 = (int)((statGraphWidth + (float)__instance.columnInterval) / (float)(__instance.columnWidth + __instance.columnInterval)); long num5 = GameMain.gameTick - __instance.levelTick; int num6 = __instance.levelTick * __instance.columnDataCount; long num7 = num5 / num6 * num6 - (num4 - num3 - 1) * num6; if (num7 < 0) { num7 = 0L; } uint num8 = (uint)((float)num7 * (1f / 60f) * ratio); uint num9 = num8 / 3600; uint num10 = num8 / 60 % 60; uint num11 = num8 % 60; __instance.sb3.Clear(); __instance.sb3.Append("00000:00:00"); StringBuilderUtility.WriteUInt(__instance.sb3, 0, 5, num9, 2, ' '); StringBuilderUtility.WriteUInt(__instance.sb3, 6, 2, num10, 2, ' '); StringBuilderUtility.WriteUInt(__instance.sb3, 9, 2, num11, 2, ' '); StringBuilderUtility.TrimStart(__instance.sb3); __instance.sb3.Insert(0, Localization.Translate("起始时间冒号")); float num12 = (float)(__instance.levelTick * __instance.columnDataCount) * ratio; uint num13 = (uint)(num12 * (1f / 60f)); uint num14 = num13 / 3600; uint num15 = num13 / 60 % 60; uint num16 = num13 % 60; uint num17 = (uint)num12 % 60; __instance.sb3.Append("\n").Append(Localization.Translate("时间周期冒号")); if (num14 != 0) { __instance.sb3.Append(num14).Append("h "); } if (num15 != 0) { __instance.sb3.Append(num15).Append("min "); } if (num16 != 0) { __instance.sb3.Append(num16).Append("s "); } if (num17 != 0) { __instance.sb3.Append(num17).Append("t"); } tipText = __instance.sb3.ToString() + tipText.Substring(num2, tipText.Length - num2); __instance.statGraphTipSetting.tipText = tipText; } __instance.mouseHoverStatGraphTip.UpdateText(ref __instance.statGraphTipSetting, (string)null, (string)null); } [HarmonyPrefix] [HarmonyPatch(typeof(UIProductEntry), "ComputePeak")] private static bool ComputePeak(UIProductEntry __instance, int firstColumnDataCount, ref long __result) { if (!ExcludeTrafficPeak) { return true; } long[] productDetail = __instance.entryData.productDetail; long num = 0L; if (__instance.productionStatWindow.isProductionTab || __instance.productionStatWindow.isDysonTab) { long[] trafficDetail = __instance.entryData.trafficDetail; bool flag = !__instance.productionStatWindow.isProductionTab && false; long num2 = 0L; int num3 = (flag ? (trafficDetail.Length - 1) : 0); int num4 = (flag ? (trafficDetail.Length / 2 - 1) : 0); int num6; if (firstColumnDataCount > 0) { int num5 = productDetail.Length - 1; num6 = productDetail.Length - firstColumnDataCount; for (int num7 = num5; num7 >= num6; num7--) { num2 += productDetail[num7]; } if (flag) { num2 += trafficDetail[num3--]; } if (num2 > num) { num = num2; } num2 = 0L; int num8 = productDetail.Length / 2 - 1; num6 = productDetail.Length / 2 - firstColumnDataCount; for (int num9 = num8; num9 >= num6; num9--) { num2 += productDetail[num9]; } if (flag) { num2 += trafficDetail[num4--]; } if (num2 > num) { num = num2; } num2 = 0L; } int num10 = 0; int num11 = productDetail.Length - firstColumnDataCount - 1; num6 = productDetail.Length / 2; for (int num12 = num11; num12 >= num6; num12--) { num2 += productDetail[num12]; num10++; if (num10 == __instance.columnDataCount) { num10 = 0; if (flag) { num2 += trafficDetail[num3--]; } if (num2 > num) { num = num2; } num2 = 0L; } } num2 = 0L; num10 = 0; int num13 = productDetail.Length / 2 - firstColumnDataCount - 1; num6 = 0; for (int num14 = num13; num14 >= num6; num14--) { num2 += productDetail[num14]; num10++; if (num10 == __instance.columnDataCount) { num10 = 0; if (flag) { num2 += trafficDetail[num4--]; } if (num2 > num) { num = num2; } num2 = 0L; } } } else { int num15 = productDetail.Length; if (__instance.extraEntryData != null) { for (int i = 0; i < num15; i++) { long num16 = productDetail[i]; for (int j = 0; j < __instance.extraEntryData.Length; j++) { num16 += __instance.extraEntryData[j].productDetail[i]; } if (num16 > num) { num = num16; } } } else { for (int k = 0; k < num15; k++) { long num17 = productDetail[k]; if (num17 > num) { num = num17; } } } } __result = num; return false; } } public static bool PreserveFilter = true; public static int SignificantDigits = 3; public static int TimeSliderSlice = 20; public static int ListWidthOffeset = 70; public static bool DisplayPerSecond = false; public static int RateFontSize = 26; public static bool ExtendGraph = false; public static bool ExcludeTrafficPeak = false; private static bool initialized; private static bool enable; private static GameObject perSecGo; private static Slider timerSlider; private static InputField filterInput; private static UIButton locateBtn; private static GameObject filterGo; private static GameObject extendGraphGo; private static string nameFilter; private static int rawMaterialFilter; private static int endProductFilter; private static string searchStr = ""; public static void Init(UIStatisticsWindow __instance) { //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) if (initialized) { return; } initialized = true; try { if (ListWidthOffeset > 0) { Reposition(((Component)__instance.productAstroBox).transform, ((Component)__instance.productTimeBox).transform); if (ListWidthOffeset > 40) { ((RectTransform)((Component)__instance.productSortBox).transform).sizeDelta = new Vector2(200f - (float)(ListWidthOffeset - 40), 30f); ((Component)__instance.productSortBox).transform.localPosition = new Vector3(135f - (float)(ListWidthOffeset - 40), ((Component)__instance.productSortBox).transform.localPosition.y); } Reposition(((Component)__instance.powerAstroBox).transform, ((Component)__instance.powerTimeBox).transform); Reposition(((Component)__instance.researchAstroBox).transform, ((Component)__instance.researchTimeBox).transform); Reposition(((Component)__instance.dysonAstroBox).transform, ((Component)__instance.dysonTimeBox).transform); Reposition(((Component)__instance.killAstroBox).transform, ((Component)__instance.killTimeBox).transform); if (ListWidthOffeset > 40) { ((RectTransform)((Component)__instance.killSortBox).transform).sizeDelta = new Vector2(200f - (float)(ListWidthOffeset - 40), 30f); ((Component)__instance.killSortBox).transform.localPosition = new Vector3(135f - (float)(ListWidthOffeset - 40), ((Component)__instance.killSortBox).transform.localPosition.y); } } Utils.EnableRichText(__instance.productAstroBox); Utils.EnableRichText(__instance.powerAstroBox); Utils.EnableRichText(__instance.researchAstroBox); Utils.EnableRichText(__instance.dysonAstroBox); Utils.EnableRichText(__instance.killAstroBox); Slider slider = UIRoot.instance.uiGame.dysonEditor.controlPanel.inspector.layerInfo.slider0; GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Control Panel Window/filter-group/sub-group/search-filter"); UIButton pauseButton = UIRoot.instance.uiGame.researchQueue.pauseButton; GameObject loadSandboxGroup = UIRoot.instance.loadGameWindow.loadSandboxGroup; if (GameConfig.gameVersion > new Version(0, 10, 33)) { perSecGo = Object.Instantiate(loadSandboxGroup, ((Component)__instance.productNameInputField).transform); ((Object)perSecGo).name = "perSecGo"; perSecGo.transform.localPosition = new Vector3(20f, 10f, 0f); perSecGo.SetActive(true); Object.Destroy((Object)(object)perSecGo.GetComponent()); Transform obj = perSecGo.transform.Find("tips"); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } Text component = perSecGo.GetComponent(); component.fontSize = 12; component.text = "Display /s"; Toggle toggle = perSecGo.GetComponentInChildren().toggle; ((UnityEvent)(object)toggle.onValueChanged).AddListener((UnityAction)OnDisplayPerSecondToggleChange); GameObject gameObject = ((Component)toggle).gameObject; gameObject.transform.localScale = new Vector3(0.6f, 0.6f); gameObject.transform.localPosition = new Vector3(-4f, 27f, 0f); extendGraphGo = Object.Instantiate(loadSandboxGroup, ((Component)__instance.productNameInputField).transform); ((Object)extendGraphGo).name = "extendGraphGo"; extendGraphGo.transform.localPosition = new Vector3(145f, 10f, 0f); extendGraphGo.SetActive(true); Object.Destroy((Object)(object)extendGraphGo.GetComponent()); Transform obj2 = extendGraphGo.transform.Find("tips"); if (obj2 != null) { ((Component)obj2).gameObject.SetActive(false); } Text component2 = extendGraphGo.GetComponent(); component2.fontSize = 12; component2.text = "Extend Graph"; Toggle toggle2 = extendGraphGo.GetComponentInChildren().toggle; ((UnityEvent)(object)toggle2.onValueChanged).AddListener((UnityAction)OnExtendGraphToggleChange); GameObject gameObject2 = ((Component)toggle2).gameObject; gameObject2.transform.localScale = new Vector3(0.6f, 0.6f); gameObject2.transform.localPosition = new Vector3(-4f, 27f, 0f); } GameObject obj3 = Object.Instantiate(((Component)slider).gameObject, ((Component)__instance.productTimeBox).transform); ((Object)obj3).name = "CustomStats_Ratio"; obj3.transform.localPosition = new Vector3(3f, 8f, 0f); obj3.transform.localScale = new Vector3(1.6f, 1.3f, 0f); timerSlider = obj3.GetComponent(); timerSlider.minValue = 0f; timerSlider.maxValue = TimeSliderSlice; timerSlider.wholeNumbers = true; timerSlider.value = timerSlider.maxValue; ((UnityEvent)(object)timerSlider.onValueChanged).AddListener((UnityAction)Entry_Patch.OnSliderChange); obj3.SetActive(true); filterGo = Object.Instantiate(val, ((Component)__instance.productAstroBox).transform); ((Object)filterGo).name = "CustomStats_Fliter"; filterGo.transform.localPosition = new Vector3(0f, 20f, 0f); filterInput = filterGo.GetComponentInChildren(); filterInput.text = ""; ((UnityEvent)(object)filterInput.onValueChanged).AddListener((UnityAction)OnInputValueChanged); filterGo.GetComponent().sizeDelta = new Vector2(((RectTransform)((Component)__instance.productAstroBox).transform).sizeDelta.x, 28f); filterGo.SetActive(true); GameObject obj4 = Object.Instantiate(((Component)pauseButton).gameObject, ((Component)__instance.productAstroBox).transform); ((Object)obj4).name = "CustomStats_Navi"; obj4.transform.localScale = new Vector3(0.33f, 0.33f, 0.33f); obj4.transform.localPosition = new Vector3(2f, -6f, 0f); Transform obj5 = obj4.transform.Find("icon"); Image val2 = ((obj5 != null) ? ((Component)obj5).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { UIStarmap starmap = UIRoot.instance.uiGame.starmap; Transform obj6 = ((Component)starmap.cursorFunctionButton3).transform.Find("icon"); object sprite; if (obj6 == null) { sprite = null; } else { Image component3 = ((Component)obj6).GetComponent(); sprite = ((component3 != null) ? component3.sprite : null); } val2.sprite = (Sprite)sprite; } locateBtn = obj4.GetComponent(); locateBtn.tips.tipTitle = "Locate"; locateBtn.tips.tipText = "Left click: Navigate to planet\nRight click: Show planet in starmap"; locateBtn.onClick += OnLocateButtonClick; locateBtn.onRightClick += OnLocateButtonRightClick; obj4.SetActive(true); enable = true; if ((Object)(object)__instance.astroBox != (Object)(object)__instance.productAstroBox) { OnTabButtonClick(__instance); } } catch (Exception ex) { Plugin.Log.LogError((object)"UI component initial fail!"); Plugin.Log.LogError((object)ex); } static void Reposition(Transform astroBoxtTansform, Transform timeBoxTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) ((RectTransform)astroBoxtTansform).sizeDelta = new Vector2(200f + (float)ListWidthOffeset, 30f); timeBoxTransform.localPosition = new Vector3((float)(330 - ListWidthOffeset), timeBoxTransform.localPosition.y); } } public static void OnDestory() { Object.Destroy((Object)(object)perSecGo); Object.Destroy((Object)(object)extendGraphGo); Slider obj = timerSlider; Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null)); InputField obj2 = filterInput; Object.Destroy((Object)(object)((obj2 != null) ? ((Component)obj2).gameObject : null)); UIButton obj3 = locateBtn; Object.Destroy((Object)(object)((obj3 != null) ? ((Component)obj3).gameObject : null)); Object.Destroy((Object)(object)filterGo); initialized = false; } private static void OnDisplayPerSecondToggleChange(bool value) { DisplayPerSecond = value; } private static void OnExtendGraphToggleChange(bool value) { ExtendGraph = value; } [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsWindow), "_OnOpen")] private static void OnOpen_Postfix(UIStatisticsWindow __instance) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Init(__instance); if (PreserveFilter) { __instance.productNameInputField.text = nameFilter; __instance.rawMaterialFilter = rawMaterialFilter; __instance.endProductFilter = endProductFilter; __instance.RefreshFilterTag(); __instance.ComputeDetailNextTick(); } if ((Object)(object)perSecGo != (Object)null) { perSecGo.transform.localPosition = new Vector3(20f, 10f, 0f); } if ((Object)(object)extendGraphGo != (Object)null) { extendGraphGo.transform.localPosition = new Vector3(145f, 10f, 0f); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsWindow), "_OnClose")] private static void OnClose_Postfix(UIStatisticsWindow __instance) { if (PreserveFilter) { nameFilter = __instance.nameFilter; rawMaterialFilter = __instance.rawMaterialFilter; endProductFilter = __instance.endProductFilter; } } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "OnProductAstroBoxItemIndexChanged")] private static bool PreventClearingFilter() { return !PreserveFilter; } [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsWindow), "OnTabButtonClick")] private static void OnTabButtonClick(UIStatisticsWindow __instance) { if (enable) { if ((Object)(object)__instance.timeBox != (Object)null) { ((Component)timerSlider).gameObject.transform.SetParent(((Component)__instance.timeBox).transform); } if ((Object)(object)__instance.astroBox != (Object)null) { filterGo.transform.SetParent(((Component)__instance.astroBox).transform); ((Component)locateBtn).gameObject.transform.SetParent(((Component)__instance.astroBox).transform); } } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsWindow), "_OnUpdate")] private static void OnUpdate(UIStatisticsWindow __instance) { if (__instance.isStatisticsTab) { Utils.DetermineAstroBoxIndex(__instance.astroBox); } } private static void OnLocateButtonClick(int obj) { int astroFilter = UIRoot.instance.uiGame.statWindow.astroFilter; if (astroFilter > 0) { int indicatorAstroId = GameMain.mainPlayer.navigation.indicatorAstroId; GameMain.mainPlayer.navigation.indicatorAstroId = ((indicatorAstroId != astroFilter) ? astroFilter : 0); } } private static void OnLocateButtonRightClick(int obj) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) int astroFilter = UIRoot.instance.uiGame.statWindow.astroFilter; if (astroFilter <= 0) { return; } UIRoot.instance.uiGame.OpenStarmap(); int num = astroFilter / 100 - 1; int num2 = astroFilter % 100 - 1; UIStarmap starmap = UIRoot.instance.uiGame.starmap; if (num < 0 || num >= starmap.starUIs.Length) { return; } if (num2 >= 0) { PlanetData val = GameMain.galaxy.PlanetById(astroFilter); if (val != null) { starmap.focusPlanet = null; starmap.focusStar = starmap.starUIs[num]; starmap.OnCursorFunction2Click(0); starmap.screenCameraController.SetViewTarget(val, (StarData)null, (EnemyDFHiveSystem)null, (Player)null, VectorLF3.zero, (double)val.realRadius * 0.00025 * 6.0, (double)val.realRadius * 0.00025 * 16.0, true, false); } } else { starmap.focusPlanet = null; starmap.focusStar = starmap.starUIs[num]; starmap.OnCursorFunction2Click(0); } } private static void OnInputValueChanged(string value) { searchStr = value; UIRoot.instance.uiGame.statWindow.RefreshAstroBox(); } [HarmonyPrefix] [HarmonyPatch(typeof(UIStatisticsWindow), "ValueToAstroBox")] [HarmonyAfter(new string[] { "Bottleneck" })] private static void FilterList(UIStatisticsWindow __instance, ref int __state) { if (__instance.isStatisticsTab) { int startIndex = 1; int localStarAstroId = 0; if (!__instance.isDysonTab && __instance.gameData.localPlanet != null) { startIndex = 2; } if (__instance.gameData.localStar != null) { localStarAstroId = __instance.gameData.localStar.astroId; } Utils.UpdateAstroBox(__instance.astroBox, startIndex, localStarAstroId, searchStr); __state = __instance.astroBox.itemIndex; } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsWindow), "ValueToAstroBox")] private static void RestoreItemIndex(UIStatisticsWindow __instance, int __state) { if (!__instance.isStatisticsTab || (Object)(object)__instance.astroBox == (Object)null) { return; } try { int count = __instance.astroBox.ItemsData.Count; if (__state != __instance.astroBox.itemIndex && __state >= 0 && __state < count && __instance.astroBox.itemIndex < count && __instance.astroBox.ItemsData[__state] == __instance.astroBox.ItemsData[__instance.astroBox.itemIndex]) { __instance.astroBox.itemIndex = __state; } } catch (Exception) { } if ((Object)(object)locateBtn == (Object)null) { return; } int astroFilter = __instance.astroFilter; if (astroFilter <= 0) { locateBtn.tips.tipTitle = "Locate"; return; } string text = "astroId=" + astroFilter; PlanetData val = GameMain.galaxy.PlanetById(astroFilter); if (val?.factory != null) { text = text + " idx=" + val.factory.index; } locateBtn.tips.tipTitle = text; } } public class UIChartAstroItemProductionPatch { private static double[] lvDivisors = new double[5] { 1.0, 10.0, 60.0, 600.0, 6000.0 }; [HarmonyPostfix] [HarmonyPatch(typeof(UIChartAstroItemProduction), "ShowInText")] public static void ShowInText_Postfix(UIChartAstroItemProduction __instance, int level) { //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) if (((UIChart)__instance).presetIndex == 0) { if (((UIChart)__instance).chartData.displayTypeParams[0] == 5 && level != 5) { float num = default(float); float num2 = default(float); __instance.statPlan.GetItemsCyclicRefSpeed(ref num, ref num2); __instance.consumeText.text = __instance.ToLevelString((double)num, level).TrimStart(Array.Empty()) + "/min"; ((Graphic)__instance.consumeText).color = ((num > 0f) ? __instance.productColor : __instance.zeroColor); } } else if (((UIChart)__instance).presetIndex == 1 && ((UIChart)__instance).chartData.displayTypeParams[0] == 5 && __instance.statPlan.timeLevel != 5) { __instance.displayGo0.SetActive(true); __instance.displayGo1.SetActive(false); long num3 = default(long); long num4 = default(long); __instance.statPlan.CalculateProductionAndConsumption(ref num3, ref num4); double num5 = (double)num3 / lvDivisors[level]; double num6 = (double)num4 / lvDivisors[level]; float num7 = default(float); float num8 = default(float); __instance.statPlan.GetItemsCyclicRefSpeed(ref num7, ref num8); double num9 = num7; double num10 = num8; string text = __instance.ToLevelString(num5, level).TrimStart(Array.Empty()); string text2 = __instance.ToLevelString(num6, level).TrimStart(Array.Empty()); string text3 = __instance.ToLevelString(num9, level).TrimStart(Array.Empty()); string text4 = __instance.ToLevelString(num10, level).TrimStart(Array.Empty()); __instance.productText.text = text + " / " + text3; __instance.consumeText.text = text2 + " / " + text4; __instance.productText.fontSize = 18; __instance.consumeText.fontSize = 18; __instance.productUnitLabel.text = "/ min"; __instance.consumeUnitLabel.text = "/ min"; __instance.productLabel.text = "生产/理论"; __instance.consumeLabel.text = "消耗/理论"; ((Graphic)__instance.productText).rectTransform.anchoredPosition = new Vector2(-26f, 0f); ((Graphic)__instance.consumeText).rectTransform.anchoredPosition = new Vector2(-26f, 0f); ((Graphic)__instance.productText).color = ((num3 > 0) ? __instance.productColor : __instance.zeroColor); ((Graphic)__instance.consumeText).color = ((num4 > 0) ? __instance.consumeColor : __instance.zeroColor); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIChartAstroItemProduction), "CreateLayoutMenu")] public static void CreateLayoutMenu_Postfix(UIChartAstroItemProduction __instance, UIPopupMenu __result) { if ((((UIChart)__instance).presetIndex == 0 || ((UIChart)__instance).presetIndex == 1) && __instance.statPlan.timeLevel != 5 && !((Object)(object)__result == (Object)null)) { string text = ((((UIChart)__instance).presetIndex == 0) ? "生产与理论速度" : "生产消耗与理论"); UIPopupMenuButton obj = __result.AddMenuButton(Localization.Translate(text), (((UIChart)__instance).chartData.displayTypeParams[0] == 5) ? 1 : (-1), false); obj.data = 5; obj.onMenuButtonClick = (Action)Delegate.Combine(obj.onMenuButtonClick, new Action(__instance.OnLayoutMenuButtonClick)); obj.SetState(true); __result.SetState(true); } } } public class UIChartPatch { private static int titleIndex; private static int lastStatPlanId; [HarmonyPostfix] [HarmonyPatch(typeof(UIChart), "_OnUpdate")] public static void OnUpdate_Postfix(UIChart __instance) { if (__instance.mouseInChart && Input.GetKeyDown((KeyCode)9) && !VFInput.alt) { if (VFInput.control) { SwitchTitleName(__instance); } else { SwitchSize(__instance); } } } private static void SwitchTitleName(UIChart __instance) { if (!((Object)(object)__instance.titleTip != (Object)null)) { return; } string[] array = __instance.titleTip.tipTextFormatString.Split(new char[1] { ';' }); if (array.Length != 0) { StatPlan obj = __instance.charts.statPlans[__instance.chartData.statPlanId]; if (lastStatPlanId != __instance.chartData.statPlanId) { titleIndex = 0; lastStatPlanId = __instance.chartData.statPlanId; } titleIndex = (titleIndex + 1) % array.Length; string text = array[titleIndex].Trim(); obj.Rename(ref text); } } private static void SwitchSize(UIChart __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Presets[] presetsArray = ChartPresetsDB.GetPresetsArray(__instance.statPlanType); if (presetsArray != null && presetsArray.Length != 0) { int num = (__instance.chartData.presetIndex + 1) % presetsArray.Length; __instance.OnSizeMenuButtonClick(num); } } } public class UIControlPanelPatch { private static bool initialized; [HarmonyPostfix] [HarmonyPatch(typeof(UIControlPanelFilterPanel), "_OnOpen")] public static void Init(UIControlPanelFilterPanel __instance) { if (!initialized) { initialized = true; Utils.EnableRichText(__instance.astroFilterBox); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIControlPanelFilterPanel), "_OnUpdate")] public static void OnUpdate(UIControlPanelFilterPanel __instance) { Utils.DetermineAstroBoxIndex(__instance.astroFilterBox); } [HarmonyPostfix] [HarmonyPriority(200)] [HarmonyPatch(typeof(UIControlPanelFilterPanel), "ReconstructAstroFilterBox")] private static void FilterList(UIControlPanelFilterPanel __instance) { int localStarAstroId = 0; if (GameMain.localStar != null) { localStarAstroId = GameMain.localStar.astroId; } Utils.UpdateAstroBox(__instance.astroFilterBox, 2, localStarAstroId); } } public class UIGamePatch { [HarmonyTranspiler] [HarmonyPatch(typeof(UIGame), "_OnUpdate")] public static IEnumerable OnUpdate_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown try { return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "ShutControlPanelWindow"), (string)null) }).SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(UIGamePatch), "ShutControlPanelWindow", (Type[])null, (Type[])null)).InstructionEnumeration(); } catch (Exception ex) { Plugin.Log.LogWarning((object)"Transpiler UIGame._OnUpdate error!"); Plugin.Log.LogWarning((object)ex); return instructions; } } private static void ShutControlPanelWindow(UIGame uIGame) { uIGame.TogglePlayerInventory(); } [HarmonyTranspiler] [HarmonyPatch(typeof(UIGame), "On_Shift_P_Switch")] public static IEnumerable On_Shift_P_Switch_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown try { return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "ShutAllFunctionWindow"), (string)null) }).SetAndAdvance(OpCodes.Pop, (object)null).InstructionEnumeration(); } catch (Exception ex) { Plugin.Log.LogWarning((object)"Transpiler UIGame.On_Shift_P_Switch error!"); Plugin.Log.LogWarning((object)ex); return instructions; } } } public class UIStatisticsPowerDetailPanelPatch { private static bool initialized; private static UIButton extendBtn; private static bool extended; private static float scrollHeight = 210f; private static float scrollY = 210f; private static GameObject sepline; [HarmonyPostfix] [HarmonyPatch(typeof(UIStatisticsPowerDetailPanel), "_OnOpen")] public static void Init(UIStatisticsPowerDetailPanel __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) if (initialized) { return; } try { GameObject obj = Object.Instantiate(((Component)UIRoot.instance.uiGame.researchQueue.pauseButton).gameObject, ((Component)__instance).transform); ((Object)obj).name = "CustomStats_Extend"; obj.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); obj.transform.localPosition = new Vector3(420f, -420f, 0f); Transform obj2 = obj.transform.Find("icon"); Image val = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); if ((Object)(object)val != (Object)null) { UIStarmap starmap = UIRoot.instance.uiGame.starmap; Transform obj3 = ((Component)starmap.cursorFunctionButton2).transform.Find("icon"); object sprite; if (obj3 == null) { sprite = null; } else { Image component = ((Component)obj3).GetComponent(); sprite = ((component != null) ? component.sprite : null); } val.sprite = (Sprite)sprite; } extendBtn = obj.GetComponent(); extendBtn.tips.tipTitle = "Extend 扩展耗电设施"; extendBtn.tips.tipText = "Click to extend power consumption detail"; extendBtn.tips.corner = 8; extendBtn.onClick += OnFoldButtonClick; if (extendBtn.transitions != null) { extendBtn.transitions[0].highlightColorOverride = new Color(0.5f, 0.6f, 0.7f, 0.1f); } obj.SetActive(true); RectTransform val2 = (RectTransform)((Component)((Component)__instance.conScrollContentRect).transform.parent.parent).transform; scrollHeight = val2.sizeDelta.y; scrollY = ((Transform)val2).localPosition.y; Transform obj4 = ((Component)__instance).gameObject.transform.Find("table-panel/sep-line-0"); sepline = ((obj4 != null) ? ((Component)obj4).gameObject : null); initialized = true; Plugin.Log.LogDebug((object)"Create UIStatisticsPowerDetailPanel extend button"); } catch (Exception ex) { Plugin.Log.LogError((object)"PerformancePanelPatch initial fail!"); Plugin.Log.LogError((object)ex); } Toggle(extended); } public static void OnDestory() { Toggle(extendScroll: false); UIButton obj = extendBtn; Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null)); initialized = false; } private static void OnFoldButtonClick(int obj) { extended = !extended; extendBtn.highlighted = extended; Toggle(extended); } private static void Toggle(bool extendScroll) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (initialized) { UIStatisticsPowerDetailPanel powerDetailPanel = UIRoot.instance.uiGame.statWindow.powerDetailPanel; ((Component)powerDetailPanel.genScrollContentRect).gameObject.SetActive(!extendScroll); GameObject obj = sepline; if (obj != null) { obj.SetActive(!extendScroll); } RectTransform val = (RectTransform)((Component)((Component)powerDetailPanel.conScrollContentRect).transform.parent.parent).transform; ((Transform)val).localPosition = new Vector3(((Transform)val).localPosition.x, extendScroll ? (scrollY + 50f) : scrollY, 0f); val.sizeDelta = new Vector2(val.sizeDelta.x, extendScroll ? (scrollHeight + 210f) : scrollHeight); } } } public static class Utils { public static bool OrderByName = true; public static int DropDownCount = 15; public static string PlanetPrefix = "ㅤ"; public static string PlanetPostfix = ""; public static string SystemPrefix = ""; public static string SystemPostfix = ""; public static KeyCode HotkeyListUp = (KeyCode)280; public static KeyCode HotkeyListDown = (KeyCode)281; private static readonly Dictionary astroIndex = new Dictionary(); private static readonly List<(string, int)> systemList = new List<(string, int)>(); private static readonly List newItems = new List(); private static readonly List newItemData = new List(); public static void DetermineAstroBoxIndex(UIComboBox astroBox) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) int num = astroBox.itemIndex; if (Input.GetKeyDown(HotkeyListUp)) { if (VFInput.control) { int num2; do { num = ((num > 0) ? (num - 1) : (astroBox.ItemsData.Count - 1)); num2 = astroBox.ItemsData[num]; } while ((num2 % 100 != 0 || num2 <= 0) && num2 != -1 && num != astroBox.itemIndex); astroBox.itemIndex = num; } else { astroBox.itemIndex = ((num > 0) ? (num - 1) : (astroBox.ItemsData.Count - 1)); } } else { if (!Input.GetKeyDown(HotkeyListDown)) { return; } if (VFInput.control) { int num3; do { num = (num + 1) % astroBox.ItemsData.Count; num3 = astroBox.ItemsData[num]; } while ((num3 % 100 != 0 || num3 <= 0) && num3 != -1 && num != astroBox.itemIndex); astroBox.itemIndex = num; } else { astroBox.itemIndex = (num + 1) % astroBox.ItemsData.Count; } } } public static void EnableRichText(UIComboBox uIComboBox) { uIComboBox.m_Text.supportRichText = true; uIComboBox.m_EmptyItemRes.supportRichText = true; ((Component)uIComboBox.m_ListItemRes).GetComponentInChildren().supportRichText = true; foreach (Button itemButton in uIComboBox.ItemButtons) { ((Component)itemButton).GetComponentInChildren().supportRichText = true; } uIComboBox.DropDownCount = DropDownCount; } public static void UpdateAstroBox(UIComboBox astroBox, int startIndex, int localStarAstroId, string searchStr = "") { if (astroBox.Items.Count <= startIndex) { return; } astroIndex.Clear(); systemList.Clear(); newItems.Clear(); newItemData.Clear(); bool flag = false; if (startIndex + 1 < astroBox.Items.Count && astroBox.Items[startIndex] == Localization.Translate("统计当前星系")) { startIndex++; flag = true; } for (int i = startIndex; i < astroBox.Items.Count; i++) { int num = astroBox.ItemsData[i]; if (num % 100 == 0) { if (astroIndex.ContainsKey(num)) { Plugin.Log.LogDebug((object)$"[{num}] => {astroBox.Items[i]}"); systemList[astroIndex[num]] = (astroBox.Items[i], num); } else { astroIndex[num] = systemList.Count; systemList.Add((astroBox.Items[i], astroBox.ItemsData[i])); } } } if (OrderByName) { systemList.Sort(); } bool flag2 = !string.IsNullOrEmpty(searchStr); foreach (var system in systemList) { int num2 = system.Item2 / 100; for (int j = startIndex; j < astroBox.Items.Count; j++) { int num3 = astroBox.ItemsData[j]; if (num3 / 100 != num2) { continue; } string text = astroBox.Items[j]; bool flag3 = true; if (num3 % 100 != 0) { if (!text.StartsWith(PlanetPrefix) || !text.EndsWith(PlanetPostfix)) { text = PlanetPrefix + text + PlanetPostfix; } if (flag2 && text.Length > PlanetPrefix.Length) { int num4 = text.IndexOf(searchStr, PlanetPrefix.Length, StringComparison.OrdinalIgnoreCase); flag3 = num4 >= 0 && num4 < text.Length - PlanetPostfix.Length; } } else { if (!text.StartsWith(SystemPrefix) || !text.EndsWith(SystemPostfix)) { text = SystemPrefix + text + SystemPostfix; } if (flag2 && text.Length > SystemPrefix.Length) { int num5 = text.IndexOf(searchStr, SystemPrefix.Length, StringComparison.OrdinalIgnoreCase); flag3 = num5 >= 0 && num5 < text.Length - SystemPostfix.Length; } } if (flag3) { newItems.Add(text); newItemData.Add(astroBox.ItemsData[j]); } } } astroBox.Items.RemoveRange(startIndex, astroBox.Items.Count - startIndex); astroBox.ItemsData.RemoveRange(startIndex, astroBox.ItemsData.Count - startIndex); if (localStarAstroId != 0 && !flag) { astroBox.Items.Add(Localization.Translate("统计当前星系")); astroBox.ItemsData.Add(localStarAstroId); } astroBox.Items.AddRange(newItems); astroBox.ItemsData.AddRange(newItemData); } }