Decompiled source of DashboardOverhaul v1.4.0
DashboardOverhaul.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; 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 Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("DashboardOverhaul")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A series of enhancements for the in-game Dashboard / 为游戏内仪表盘提供一系列优化")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0+7d401a90dcfb22c545e0fab93030dba507dcbb2d")] [assembly: AssemblyProduct("DashboardOverhaul")] [assembly: AssemblyTitle("DashboardOverhaul")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DashboardOverhaul { public static class ChartHotkeys { private enum Command { None, Rename, Size, Background, Border, ResetBorder } private static readonly List<RaycastResult> s_hits = new List<RaycastResult>(); public static void Update(DashboardView view) { UIDashboard dashboard = view.Dashboard; Command command = ReadCommand(); if (command == Command.None || IsTextEditing() || UIMessageBox.activeCount > 0 || (Object)(object)dashboard.rootPopupMenu != (Object)null || (dashboard.anyChartDragging && Input.GetMouseButton(0)) || view.Tabs.IsDragging) { return; } GameObject val = PointerTarget(); if ((Object)(object)val == (Object)null) { return; } if (view.IsGearTarget(val.transform)) { switch (ReadCommand(page: true)) { case Command.Rename: ProductionNames.CyclePage(dashboard); break; case Command.Background: PageGearMenu.CyclePageStyle(dashboard, (EChartStyleType)2); break; case Command.Border: PageGearMenu.CyclePageStyle(dashboard, (EChartStyleType)3); break; case Command.ResetBorder: PageGearMenu.ResetPageBorder(dashboard); break; case Command.Size: break; } return; } UIChart componentInParent = val.GetComponentInParent<UIChart>(); if (!((Object)(object)componentInParent == (Object)null) && ((ManualBehaviour)componentInParent).active && !((Object)(object)componentInParent.uiDashboard != (Object)(object)dashboard) && componentInParent.chartData != null) { switch (command) { case Command.Rename: ProductionNames.Cycle(componentInParent); break; case Command.Size: SwitchSize(componentInParent); break; case Command.Background: CycleStyle(componentInParent, (EChartStyleType)2); break; case Command.Border: CycleStyle(componentInParent, (EChartStyleType)3); break; case Command.ResetBorder: ResetBorder(componentInParent); break; } } } private static Command ReadCommand(bool page = false) { //IL_002b: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) if (Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) { return Command.None; } if (Input.GetKey((KeyCode)306)) { if (!IsDown(ModConfig.QuickRenameKey.Value)) { return Command.None; } return Command.Rename; } if (Input.GetKey((KeyCode)305)) { return Command.None; } if (!page && IsDown(ModConfig.SwitchSizeKey.Value)) { return Command.Size; } if (IsDown(ModConfig.CycleBackgroundKey.Value)) { return Command.Background; } if (IsDown(ModConfig.CycleBorderKey.Value)) { return Command.Border; } if (!IsDown(ModConfig.ResetBorderKey.Value)) { return Command.None; } return Command.ResetBorder; } private static bool IsDown(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return Input.GetKeyDown(key); } return false; } private static GameObject PointerTarget() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) EventSystem current = EventSystem.current; if ((Object)(object)current == (Object)null) { return null; } current.RaycastAll(new PointerEventData(current) { position = Vector2.op_Implicit(Input.mousePosition) }, s_hits); object result; if (s_hits.Count <= 0) { result = null; } else { RaycastResult val = s_hits[0]; result = ((RaycastResult)(ref val)).gameObject; } s_hits.Clear(); return (GameObject)result; } private static void CycleStyle(UIChart chart, EChartStyleType type) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) int index = ChartStyles.NextIndex(ChartStyles.GetIndex(chart.chartData, type), type); if (ChartStyles.Apply(chart.chartData, type, index)) { ChartStyles.Repaint(chart); } } private static void ResetBorder(UIChart chart) { if (ChartStyles.Apply(chart.chartData, (EChartStyleType)3, 0)) { ChartStyles.Repaint(chart); } } private static bool IsTextEditing() { GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null); if ((Object)(object)val != (Object)null) { return (Object)(object)val.GetComponent<InputField>() != (Object)null; } return false; } private static void SwitchSize(UIChart chart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 Presets[] presetsArray = ChartPresetsDB.GetPresetsArray(chart.statPlanType); for (int i = 1; i < presetsArray.Length; i++) { int num = (chart.chartData.presetIndex + i) % presetsArray.Length; if ((int)presetsArray[num].usage == 1) { chart.OnSizeMenuButtonClick(num); break; } } } } public static class ChartPlacement { [HarmonyPostfix] [HarmonyPatch(typeof(DashboardPage), "AddChartWithAutoPosition")] private static void AddChartWithAutoPosition_Postfix(DashboardPage __instance, ChartData __result, Vector2Int gridBoundMin, Vector2Int gridBoundMax) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (ModConfig.PlaceNewChartsAtBottomRight.Value && __result != null) { Vector2Int? val = FindBottomRightSpot(__instance.chartDatas, __result, gridBoundMin, gridBoundMax); if (val.HasValue && val.Value != __result.pos) { __result.pos = val.Value; } } } private static Vector2Int? FindBottomRightSpot(List<ChartData> charts, ChartData added, Vector2Int min, Vector2Int max) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Vector2Int size = added.size; Vector2Int val = default(Vector2Int); for (int num = ((Vector2Int)(ref max)).y - ((Vector2Int)(ref size)).y; num >= ((Vector2Int)(ref min)).y; num--) { for (int num2 = ((Vector2Int)(ref max)).x - ((Vector2Int)(ref size)).x; num2 >= ((Vector2Int)(ref min)).x; num2--) { ((Vector2Int)(ref val))..ctor(num2, num); if (IsFree(charts, added, val, size)) { return val; } } } return null; } private static bool IsFree(List<ChartData> charts, ChartData added, Vector2Int pos, Vector2Int size) { foreach (ChartData chart in charts) { if (chart != added && ((Vector2Int)(ref pos)).x + ((Vector2Int)(ref size)).x > ((Vector2Int)(ref chart.pos)).x && ((Vector2Int)(ref chart.pos)).x + ((Vector2Int)(ref chart.size)).x > ((Vector2Int)(ref pos)).x && ((Vector2Int)(ref pos)).y + ((Vector2Int)(ref size)).y > ((Vector2Int)(ref chart.pos)).y && ((Vector2Int)(ref chart.pos)).y + ((Vector2Int)(ref chart.size)).y > ((Vector2Int)(ref pos)).y) { return false; } } return true; } } public static class ChartRename { private static InputField _input; private static UIChart _target; public static void Begin(UIChart chart) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chart == (Object)null) { return; } UIDashboard uiDashboard = chart.uiDashboard; if ((Object)(object)uiDashboard == (Object)null || (Object)(object)uiDashboard.chartContentRt == (Object)null) { return; } StatPlan val = ResolveStatPlan(chart); if (val != null) { UIDashboardPatch.View?.Tabs.FinishRename(); Cancel(); InputField obj = EnsureInput(uiDashboard); _target = chart; RectTransform val2 = (RectTransform)((Component)obj).transform; RectTransform obj2 = (((Object)(object)chart.titleText != (Object)null) ? ((Graphic)chart.titleText).rectTransform : chart.rectTrans); Transform parent = ((Transform)val2).parent; RectTransform val3 = (RectTransform)(object)((parent is RectTransform) ? parent : null); Vector3[] array = (Vector3[])(object)new Vector3[4]; obj2.GetWorldCorners(array); float num = 140f; float num2 = 22f; if ((Object)(object)val3 != (Object)null) { Vector3 val4 = ((Transform)val3).InverseTransformPoint(array[1]); Vector3 val5 = ((Transform)val3).InverseTransformPoint(array[2]); Vector3 val6 = ((Transform)val3).InverseTransformPoint(array[0]); num = Mathf.Max(140f, Mathf.Abs(val5.x - val4.x)); num2 = Mathf.Max(20f, Mathf.Abs(val4.y - val6.y)); } Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(0f, 1f); val2.anchorMax = val7; val2.anchorMin = val7; val2.pivot = new Vector2(0f, 1f); val2.sizeDelta = new Vector2(num, num2); ((Transform)val2).position = array[1]; ((Component)obj).gameObject.SetActive(true); obj.text = val.name ?? string.Empty; ((Selectable)obj).Select(); obj.ActivateInputField(); ((Component)obj).transform.SetAsLastSibling(); UIRealtimeTip.Popup(string.Format(Loc.L("重命名统计项,将影响 {0} 个图表", "Renaming this statistic affects {0} charts"), PageOps.ChartCount(chart.charts, val.id)), true, 0); } } public static void CancelIfTargeting(UIChart chart) { if ((Object)(object)_target == (Object)(object)chart) { Hide(); } } public static void Free() { Cancel(); if ((Object)(object)_input != (Object)null) { Object.Destroy((Object)(object)((Component)_input).gameObject); } _input = null; _target = null; } private static StatPlan ResolveStatPlan(UIChart chart) { StatPlanPool val = (((Object)(object)chart != (Object)null && chart.charts != null) ? chart.charts.statPlans : null); if (val == null || val.buffer == null || chart.chartData == null) { return null; } int statPlanId = chart.chartData.statPlanId; if (statPlanId < 0 || statPlanId >= val.buffer.Length) { return null; } return val.buffer[statPlanId]; } private static InputField EnsureInput(UIDashboard dash) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0072: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_input != (Object)null) { return _input; } Font font = (((Object)(object)dash.emptyTip != (Object)null) ? dash.emptyTip.font : null); GameObject val = new GameObject("DO_ChartRenameInput", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)dash.chartContentRt, false); val2.sizeDelta = new Vector2(140f, 22f); ((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.85f); GameObject val3 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); RectTransform val4 = (RectTransform)val3.transform; ((Transform)val4).SetParent((Transform)(object)val2, false); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = new Vector2(6f, 0f); val4.offsetMax = new Vector2(-6f, 0f); Text val5 = val3.AddComponent<Text>(); val5.font = font; val5.fontSize = 14; val5.alignment = (TextAnchor)3; ((Graphic)val5).color = Color.white; val5.supportRichText = false; val5.verticalOverflow = (VerticalWrapMode)1; InputField obj = val.AddComponent<InputField>(); obj.textComponent = val5; obj.lineType = (LineType)0; obj.characterLimit = 64; ((UnityEvent<string>)(object)obj.onEndEdit).AddListener((UnityAction<string>)Commit); val.SetActive(false); _input = obj; return obj; } private static void Commit(string value) { UIChart target = _target; bool num = (Object)(object)_input != (Object)null && _input.wasCanceled; Hide(); if (!num) { StatPlan val = ResolveStatPlan(target); if (val != null) { string text = (value ?? string.Empty).Trim(); val.Rename(ref text); } } } public static void Finish() { if ((Object)(object)_target != (Object)null) { _input.DeactivateInputField(true); } } public static void Cancel() { Hide(); } private static void Hide() { _target = null; DashboardUi.HideInput(_input); } } public static class ChartState { private sealed class ExportState { public int Background; public int Border; public int[] Parameters; } private const int SaveTagSlot = 9; private const int BackgroundSlot = 10; private const int BorderSlot = 11; private const int LayoutSlot = 12; private const int PreviousBorderSlot = 14; private const int LegacyLockSlot = 15; private const int SaveTag = 1146028033; [HarmonyPostfix] [HarmonyPatch(typeof(UIChart), "OnLockButtonClick")] private static void OnLockButtonClick_Postfix(UIChart __instance) { ApplyLockBorder(__instance.chartData, __instance.chartData.locked); ChartStyles.Repaint(__instance); } public static void SetLocked(ChartData data, bool locked) { if (data.locked != locked) { data.locked = locked; ApplyLockBorder(data, locked); } } private static void ApplyLockBorder(ChartData data, bool locked) { int blueBorderIndex = ChartStyles.BlueBorderIndex; if (blueBorderIndex > 0) { if (locked) { data.displayTypeParams[14] = ChartStyles.EncodeBorder(data.borderStyleIndex); data.borderStyleIndex = blueBorderIndex; } else if (data.borderStyleIndex == blueBorderIndex) { data.borderStyleIndex = ChartStyles.DecodeBorder(data.displayTypeParams[14]); } } } public static int ResolveBorder(ChartData data, int index) { if (index != 0 || !data.locked || ChartStyles.BlueBorderIndex <= 0) { return index; } return ChartStyles.BlueBorderIndex; } [HarmonyPrefix] [HarmonyPatch(typeof(UIChart), "OnStyleMenuButtonClick")] private static void OnStyleMenuButtonClick_Prefix(UIChart __instance, ref int styleIndex) { if (styleIndex == -3 && __instance.chartData.locked && ChartStyles.BlueBorderIndex > 0) { styleIndex = ChartStyles.BlueBorderIndex; } } [HarmonyPrefix] [HarmonyPatch(typeof(UIChart), "OnSizeMenuButtonClick")] private static bool OnSizeMenuButtonClick_Prefix(UIChart __instance, int presetIndex) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) ChartData chartData = __instance.chartData; if (chartData.presetIndex == presetIndex) { return false; } UIDashboard uiDashboard = __instance.uiDashboard; CustomCharts charts = __instance.charts; DashboardPage val = charts.dashboardLayout.pages[charts.currentView.pageIndex]; StatPlan val2 = charts.statPlans[chartData.statPlanId]; ChartData next = val.AddChart(val2, ref chartData.pos, presetIndex); Inherit(chartData, next, val2.type); uiDashboard.PutChartIntoPool(__instance); val.RemoveChart(chartData); uiDashboard.DetermineCharts(); return false; } internal static void Inherit(ChartData previous, ChartData next, EStatPlanType type) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) next.genericStyleIndex = previous.genericStyleIndex; next.backgroundStyleIndex = previous.backgroundStyleIndex; next.borderStyleIndex = previous.borderStyleIndex; next.locked = previous.locked; next.InheritedParameter(previous.presetIndex, previous.displayTypeParams, type); next.displayTypeParams[14] = previous.displayTypeParams[14]; } [HarmonyPrefix] [HarmonyPatch(typeof(ChartData), "Export")] private static void Export_Prefix(ChartData __instance, out ExportState __state) { int num = ChartStyles.CustomId(__instance.backgroundStyleIndex); int num2 = ChartStyles.CustomId(__instance.borderStyleIndex); int num3 = __instance.displayTypeParams[0]; StatPlanPool val = GameMain.data?.statistics?.charts?.statPlans; if (!ProductionSpeedLayout.IsCustomLayout(num3) || !(((val != null) ? val[__instance.statPlanId] : null) is AstroItemProductionStatPlan)) { num3 = 0; } __state = null; if (num != 0 || num2 != 0 || num3 != 0) { __state = new ExportState { Background = __instance.backgroundStyleIndex, Border = __instance.borderStyleIndex, Parameters = __instance.displayTypeParams }; int[] array = (int[])__state.Parameters.Clone(); array[9] = 1146028033; array[10] = num; array[11] = num2; array[12] = num3; if (num3 != 0) { array[0] = 0; } __instance.displayTypeParams = array; if (num != 0) { __instance.backgroundStyleIndex = 0; } if (num2 != 0) { __instance.borderStyleIndex = 0; } } } [HarmonyFinalizer] [HarmonyPatch(typeof(ChartData), "Export")] private static void Export_Finalizer(ChartData __instance, ExportState __state) { if (__state != null) { __instance.backgroundStyleIndex = __state.Background; __instance.borderStyleIndex = __state.Border; __instance.displayTypeParams = __state.Parameters; } } [HarmonyPostfix] [HarmonyPatch(typeof(ChartData), "Import")] private static void Import_Postfix(ChartData __instance) { int[] displayTypeParams = __instance.displayTypeParams; if (displayTypeParams[9] == 1146028033) { if (__instance.backgroundStyleIndex == 0) { __instance.backgroundStyleIndex = ChartStyles.FromId(displayTypeParams[10], (EChartStyleType)2); } if (__instance.borderStyleIndex == 0) { __instance.borderStyleIndex = ChartStyles.FromId(displayTypeParams[11], (EChartStyleType)3); } if (displayTypeParams[0] == 0 && ProductionSpeedLayout.IsCustomLayout(displayTypeParams[12])) { displayTypeParams[0] = displayTypeParams[12]; } displayTypeParams[9] = (displayTypeParams[10] = (displayTypeParams[11] = (displayTypeParams[12] = 0))); } if (displayTypeParams[15] != 0) { __instance.locked = true; } displayTypeParams[15] = 0; displayTypeParams[14] = ChartStyles.EncodeBorder(ChartStyles.DecodeBorder(displayTypeParams[14])); __instance.genericStyleIndex = ChartStyles.ValidIndex(__instance.genericStyleIndex, (EChartStyleType)1); __instance.backgroundStyleIndex = ChartStyles.ValidIndex(__instance.backgroundStyleIndex, (EChartStyleType)2); __instance.borderStyleIndex = ChartStyles.ValidIndex(__instance.borderStyleIndex, (EChartStyleType)3); } } public static class ChartStyles { private static readonly (string Name, EChartStyleType Type, Color Color)[] Colors = new(string, EChartStyleType, Color)[6] { ("绿色半透明", (EChartStyleType)2, Color32.op_Implicit(new Color32((byte)74, (byte)174, (byte)147, (byte)72))), ("黄色半透明", (EChartStyleType)2, Color32.op_Implicit(new Color32((byte)229, (byte)184, (byte)100, (byte)72))), ("红色半透明", (EChartStyleType)2, Color32.op_Implicit(new Color32((byte)223, (byte)134, (byte)151, (byte)72))), ("绿色边框", (EChartStyleType)3, Color32.op_Implicit(new Color32((byte)85, (byte)167, (byte)145, byte.MaxValue))), ("黄色边框", (EChartStyleType)3, Color32.op_Implicit(new Color32((byte)213, (byte)169, (byte)91, byte.MaxValue))), ("红色边框", (EChartStyleType)3, Color32.op_Implicit(new Color32((byte)202, (byte)118, (byte)128, byte.MaxValue))) }; private static ChartStyle[] _registered; private static readonly int[] Indices = new int[Colors.Length]; public static int BlueBorderIndex { get; private set; } public static int BlackBackgroundIndex { get; private set; } public static int GreenBackgroundIndex => Indices[0]; public static int YellowBackgroundIndex => Indices[1]; public static int RedBackgroundIndex => Indices[2]; [HarmonyPostfix] [HarmonyPatch(typeof(ChartPresetsDB), "Load")] private static void Load_Postfix() { Initialize(); } public static void Initialize() { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Invalid comparison between Unknown and I4 //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Invalid comparison between Unknown and I4 //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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) ChartStyle[] chartStyles = ChartPresetsDB.GetChartStyles(); if (chartStyles == null || chartStyles == _registered) { return; } BlackBackgroundIndex = FindTemplate(chartStyles, (EChartStyleType)2, "bg"); BlueBorderIndex = FindTemplate(chartStyles, (EChartStyleType)3, "border"); if (BlackBackgroundIndex < 0 || BlueBorderIndex < 0) { for (int i = 0; i < Indices.Length; i++) { Indices[i] = -1; } DashboardOverhaulPlugin.Logger.LogWarning((object)"Chart background/border templates are unavailable; custom colors disabled."); return; } List<ChartStyle> list = new List<ChartStyle>(chartStyles); for (int j = 0; j < Colors.Length; j++) { (string Name, EChartStyleType Type, Color Color) spec = Colors[j]; int num = list.FindIndex((ChartStyle style) => style.name == spec.Name && style.type == spec.Type); if (num >= 0) { Indices[j] = num; continue; } int num2 = (((int)spec.Type == 2) ? BlackBackgroundIndex : BlueBorderIndex); ChartStyle val = new ChartStyle(chartStyles[num2]) { name = spec.Name }; string text = (((int)spec.Type == 2) ? "bg" : "border"); ChartStyleSelector[] selectors = val.selectors; foreach (ChartStyleSelector val2 in selectors) { if (!(val2.name == text)) { continue; } ChartStyleDeclaration[] declarations = val2.declarations; foreach (ChartStyleDeclaration val3 in declarations) { if ((int)val3.type == 20) { val3.value = Compound.op_Implicit(spec.Color); } } } Indices[j] = list.Count; list.Add(val); } ChartPresetsDB.styles = (_registered = list.ToArray()); } private static int FindTemplate(ChartStyle[] styles, EChartStyleType type, string selectorName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 for (int i = 1; i < styles.Length; i++) { if (styles[i].type != type) { continue; } ChartStyleSelector[] selectors = styles[i].selectors; foreach (ChartStyleSelector val in selectors) { if (!(val.name == selectorName)) { continue; } ChartStyleDeclaration[] declarations = val.declarations; for (int k = 0; k < declarations.Length; k++) { if ((int)declarations[k].type == 20) { return i; } } } } return -1; } public static int GetIndex(ChartData data, EChartStyleType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected I4, but got Unknown return (type - 1) switch { 0 => data.genericStyleIndex, 1 => data.backgroundStyleIndex, 2 => data.borderStyleIndex, _ => 0, }; } public static int NextIndex(int current, EChartStyleType type) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) ChartStyle[] chartStyles = ChartPresetsDB.GetChartStyles(); if (current != 0 && ValidIndex(current, type) == 0) { return 0; } for (int i = current + 1; i < chartStyles.Length; i++) { if (chartStyles[i].type == type) { return i; } } return 0; } public static bool Apply(ChartData data, EChartStyleType type, int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected I4, but got Unknown if ((int)type == 3) { index = ChartState.ResolveBorder(data, index); } if (GetIndex(data, type) == index) { return false; } switch (type - 1) { case 0: data.genericStyleIndex = index; break; case 1: data.backgroundStyleIndex = index; break; case 2: data.borderStyleIndex = index; break; } return true; } public static UIChart FindChart(UIDashboard dashboard, ChartData data) { foreach (UIChart item in dashboard.chartPool) { if (((ManualBehaviour)item).inited && item.chartData == data) { return item; } } return null; } public static void Repaint(UIChart chart) { if (!((Object)(object)chart == (Object)null)) { UIChartStylePainter[] stylePainters = chart.stylePainters; for (int i = 0; i < stylePainters.Length; i++) { stylePainters[i].Repaint(); } } } internal static int CustomId(int index) { if (index <= 0) { return 0; } int num = Array.IndexOf(Indices, index); if (num >= 0) { return num + 1; } return 0; } internal static int FromId(int id, EChartStyleType type) { //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) if (id <= 0 || id > Colors.Length || Colors[id - 1].Type != type || Indices[id - 1] <= 0) { return 0; } return Indices[id - 1]; } internal static int EncodeBorder(int index) { int num = CustomId(index); if (num != 0) { return -num; } return index; } internal static int DecodeBorder(int value) { if (value >= 0) { return ValidIndex(value, (EChartStyleType)3); } return FromId(-value, (EChartStyleType)3); } internal static int ValidIndex(int index, EChartStyleType type) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) ChartStyle[] chartStyles = ChartPresetsDB.GetChartStyles(); if (index <= 0 || index >= chartStyles.Length || chartStyles[index].type != type) { return 0; } return index; } } public class ChartTitleRenameTrigger : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public UIChart Owner; public void OnPointerClick(PointerEventData eventData) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Owner == (Object)null) && (int)eventData.button == 0 && eventData.clickCount >= 2) { ChartRename.Begin(Owner); } } } public static class ChartTitleStyle { [HarmonyPostfix] [HarmonyPatch(typeof(UIChart), "TruncateStatPlanNameText", new Type[] { })] private static void TruncateStatPlanNameText_Postfix(UIChart __instance) { Apply(__instance); } public static void Apply(UIChart chart) { Text titleText = chart.titleText; int value = ModConfig.TitleFontSize.Value; int num = ((value > 0) ? value : (chart.presets.uiPrefab.titleText.fontSize + 2)); if (titleText.fontSize != num) { titleText.fontSize = num; } ApplyOverflow(titleText); } private static void ApplyOverflow(Text title) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) title.horizontalOverflow = (HorizontalWrapMode)1; title.verticalOverflow = (VerticalWrapMode)1; if (!ModConfig.TitleSingleLine.Value) { Rect rect = ((Graphic)title).rectTransform.rect; TrimToBox(title, ((Rect)(ref rect)).width); } } private static void TrimToBox(Text title, float available) { string text = title.text ?? string.Empty; if (available <= 1f || text.Length <= 1 || title.preferredWidth <= available) { return; } for (int num = text.Length - 1; num > 0; num--) { title.text = text.Substring(0, num); if (title.preferredWidth <= available) { return; } } title.text = text.Substring(0, 1); } } public class ConfirmHotkey : MonoBehaviour { public UIMessageBox Box; public static void Attach(UIMessageBox box) { if (!((Object)(object)box == (Object)null)) { ConfirmHotkey confirmHotkey = ((Component)box).gameObject.GetComponent<ConfirmHotkey>(); if ((Object)(object)confirmHotkey == (Object)null) { confirmHotkey = ((Component)box).gameObject.AddComponent<ConfirmHotkey>(); } confirmHotkey.Box = box; } } private void Update() { if (!((Object)(object)Box == (Object)null) && !((Object)(object)UIMessageBox.TopMessage() != (Object)(object)Box) && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))) { Box.OnButton2Click(); } } } public static class ConfirmHotkeyPatch { [HarmonyPostfix] [HarmonyPatch(typeof(UIMessageBox), "Show", new Type[] { typeof(string), typeof(string), typeof(string), typeof(string), typeof(int), typeof(Response), typeof(Response) })] private static void Show_Postfix(string title, UIMessageBox __result) { if (!((Object)(object)__result == (Object)null) && !(title != Localization.Translate("确认删除统计项标题"))) { ConfirmHotkey.Attach(__result); } } } public static class UIChartPatch { [HarmonyPostfix] [HarmonyPatch(typeof(UIChart), "SetPopupMenuButtons")] private static void SetPopupMenuButtons_Postfix(UIChart __instance, UIPopupMenu popupMenu) { CustomCharts charts = __instance.charts; if (charts == null || __instance.chartData == null) { return; } DashboardLayout dashboardLayout = charts.dashboardLayout; int pageIndex = charts.currentView.pageIndex; foreach (UIPopupMenuButton childButton in popupMenu.childButtons) { if (childButton.onMenuButtonClick == new Action<int>(__instance.CloseAndRemoveChart)) { childButton.ButtonText = Loc.L("移除此图表", "Remove this chart"); childButton.SetState(true); } } if (PageOps.ActivePageCount(charts) > 1) { UIPopupMenuButton val = popupMenu.AddMenuButton(Loc.L("移动到页面", "Move to page"), -1, true); UIPopupMenu val2 = __instance.CreateAndInitChildPopupMenu(val); for (int i = 1; i < 10; i++) { DashboardPage val3 = dashboardLayout.pages[i]; if (i != pageIndex && val3 != null) { UIPopupMenuButton obj = val2.AddMenuButton(PageOps.PageName(val3, i), -1, false); obj.data = i; obj.onMenuButtonClick = (Action<int>)Delegate.Combine(obj.onMenuButtonClick, (Action<int>)delegate(int slot) { MoveChartToPage(__instance, slot); }); obj.SetState(true); } } val.m_ChildMenu = val2; val.SetState(true); } int num = PageOps.ChartCount(charts, __instance.chartData.statPlanId); UIPopupMenuButton obj2 = popupMenu.AddMenuButton(string.Format(Loc.L("重命名统计项(影响 {0} 个图表)", "Rename statistic (affects {0} charts)"), num), -1, true); obj2.onMenuButtonClick = (Action<int>)Delegate.Combine(obj2.onMenuButtonClick, (Action<int>)delegate { __instance.uiDashboard.CloseChartPopupMenu(); ChartRename.Begin(__instance); }); obj2.SetState(true); UIPopupMenuButton obj3 = popupMenu.AddMenuButton(Loc.L("删除统计项及其全部图表", "Delete statistic and all its charts"), -1, false); obj3.onMenuButtonClick = (Action<int>)Delegate.Combine(obj3.onMenuButtonClick, (Action<int>)delegate { ConfirmDelete(__instance); }); obj3.SetState(true); popupMenu.SetState(true); } private static void MoveChartToPage(UIChart chart, int targetSlot) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) CustomCharts charts = chart.charts; UIDashboard uiDashboard = chart.uiDashboard; if (charts == null || (Object)(object)uiDashboard == (Object)null || chart.chartData == null) { return; } DashboardPage[] pages = charts.dashboardLayout.pages; DashboardPage val = pages[charts.currentView.pageIndex]; DashboardPage val2 = pages[targetSlot]; ChartData chartData = chart.chartData; uiDashboard.CloseChartPopupMenu(); if (val != null && val2 != null) { ChartRename.CancelIfTargeting(chart); if (!PageOps.TryMoveChart(val, val2, chartData, uiDashboard.CalculateMaxMiniGridCount())) { UIRealtimeTip.Popup(Loc.L("目标页面没有足够空位,图表保留在原页。", "No room on the destination page. The chart stays on its original page."), true, 0); return; } uiDashboard.DetermineCharts(); UIDashboardPatch.View?.ShowMoved(val2, chartData); } } private static void ConfirmDelete(UIChart chart) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown if (chart.chartData == null || chart.charts == null) { return; } UIDashboard dash = chart.uiDashboard; CustomCharts charts = chart.charts; int id = chart.chartData.statPlanId; StatPlan stat = charts.statPlans[id]; dash.CloseChartPopupMenu(); ChartRename.CancelIfTargeting(chart); ConfirmHotkey.Attach(UIMessageBox.Show(Loc.L("删除统计项", "Delete statistic"), string.Format(Loc.L("删除统计项“{0}”?\n将移除其全部 {1} 个图表(包括其他页面和监控视图),以及侧栏中的统计项。", "Delete statistic “{0}”?\nThis removes all {1} associated charts, including other pages and watch views, and the sidebar statistic."), stat.displayName, PageOps.ChartCount(charts, id)), Localization.Translate("取消"), Localization.Translate("确定"), 1, (Response)null, (Response)delegate { if (!((Object)(object)dash == (Object)null) && dash.charts == charts && charts.statPlans?.buffer != null && id < charts.statPlans.buffer.Length && charts.statPlans[id] == stat) { ChartRename.Cancel(); dash.ResetChartPool(); charts.RemoveStatPlan(id); dash.DetermineCharts(); dash.statboard.DetermineEntryVisible(); } })); } [HarmonyPrefix] [HarmonyPatch(typeof(UIDashboard), "PutChartIntoPool")] private static void PutChartIntoPool_Prefix(UIChart chart) { ChartRename.CancelIfTargeting(chart); } [HarmonyPostfix] [HarmonyPatch(typeof(StatPlan), "Rename")] private static void Rename_Postfix(StatPlan __instance) { UIDashboard val = UIDashboardPatch.View?.Dashboard; if ((Object)(object)val == (Object)null || val.charts != __instance.charts) { return; } foreach (UIChart item in val.chartPool) { if (((ManualBehaviour)item).inited && item.chartData.statPlanId == __instance.id) { item.SetTipFormatString(); UIDashboardTip titleTip = item.titleTip; if (titleTip != null) { titleTip.RefreshSimpleGeneralTipText(); } } } foreach (UIStatPlanEntry item2 in val.statboard.objectEntryPool) { if (item2.statPlan == __instance) { item2.nameInput.SetTextWithoutNotify(__instance.name ?? ""); } } } [HarmonyPostfix] [HarmonyPatch(typeof(UIDashboard), "TakeChartFromPool")] private static void TakeChartFromPool_Postfix(UIChart __result) { if (!((Object)(object)__result == (Object)null) && !((Object)(object)__result.titleText == (Object)null)) { GameObject gameObject = ((Component)__result.titleText).gameObject; ChartTitleRenameTrigger obj = gameObject.GetComponent<ChartTitleRenameTrigger>() ?? gameObject.AddComponent<ChartTitleRenameTrigger>(); ((Graphic)__result.titleText).raycastTarget = true; obj.Owner = __result; } } } [BepInPlugin("org.fyyy.dashboardoverhaul", "DashboardOverhaul", "1.4.0")] public class DashboardOverhaulPlugin : BaseUnityPlugin { public static readonly ManualLogSource Logger = Logger.CreateLogSource("DashboardOverhaul"); internal static readonly Type[] PatchTypes = new Type[12] { typeof(UIDashboardPatch), typeof(UIChartPatch), typeof(DashboardLayoutPatch), typeof(ChartTitleStyle), typeof(ProductionSpeedLayout), typeof(ConfirmHotkeyPatch), typeof(DashboardKeyPatch), typeof(StatPlanShortcutPatch), typeof(ChartPlacement), typeof(ResourceRateBars), typeof(ChartState), typeof(ChartStyles) }; private Harmony _harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown ModConfig.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("org.fyyy.dashboardoverhaul"); Type[] patchTypes = PatchTypes; foreach (Type type in patchTypes) { _harmony.PatchAll(type); } ChartStyles.Initialize(); Logger.LogInfo((object)"DashboardOverhaul loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public static class DashboardLayoutPatch { [HarmonyPrefix] [HarmonyPatch(typeof(DashboardLayout), "Import")] private static void Import_Prefix(DashboardLayout __instance) { if (__instance.pages != null) { __instance.pages[1] = null; } } [HarmonyPostfix] [HarmonyPatch(typeof(DashboardLayout), "AddPage")] private static void AddPage_Postfix(DashboardLayout __instance, int index) { if (__instance.pages != null && index >= 0 && index < 10 && __instance.pages[index] != null) { __instance.pages[index].name = ""; } } } internal static class DashboardUi { public static Text Text(Transform parent, Font font, string value, TextAnchor alignment = (TextAnchor)4) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(parent, false); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = new Vector2(8f, 0f); val2.offsetMax = new Vector2(-8f, 0f); Text obj = val.AddComponent<Text>(); obj.font = font; obj.fontSize = 14; ((Graphic)obj).color = Color.white; obj.alignment = alignment; obj.supportRichText = false; ((Graphic)obj).raycastTarget = false; obj.text = value; return obj; } public static void StyleButton(Button button, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_007b: Unknown result type (might be due to invalid IL or missing references) ColorBlock colors = ((Selectable)button).colors; ((ColorBlock)(ref colors)).normalColor = color; ((ColorBlock)(ref colors)).highlightedColor = Color.Lerp(color, Color.white, 0.3f); ((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).highlightedColor; ((ColorBlock)(ref colors)).pressedColor = Color.Lerp(color, Color.white, 0.5f); ((ColorBlock)(ref colors)).disabledColor = new Color(color.r, color.g, color.b, 0.08f); ((ColorBlock)(ref colors)).fadeDuration = 0.08f; ((Selectable)button).colors = colors; } public static void Tip(GameObject go, string title, string description) { //IL_0013: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) UIDashboardTip obj = go.GetComponent<UIDashboardTip>() ?? go.AddComponent<UIDashboardTip>(); obj.settings = new Settings { tipType = (TipType)2, tipTitle = (string.IsNullOrEmpty(title) ? "" : "{0}"), tipText = (string.IsNullOrEmpty(description) ? "" : "{0}"), delay = 0.4f, corner = 3, width = 300 }; obj.tipTitleFormatString = title; obj.tipTextFormatString = description; obj.RefreshSimpleGeneralTipText(); } public static void HideInput(InputField input) { if (!((Object)(object)input == (Object)null)) { if ((Object)(object)EventSystem.current != (Object)null && (Object)(object)EventSystem.current.currentSelectedGameObject == (Object)(object)((Component)input).gameObject) { EventSystem.current.SetSelectedGameObject((GameObject)null); } ((Component)input).gameObject.SetActive(false); } } } public class DashboardView { private RectTransform _content; private RectTransform _header; private Vector2 _statboardTopOffset; private Font _font; private RectTransform _emptyPanel; private Text _emptyText; private Button _emptyAdd; private Button _emptyCopy; private Button _gearButton; private Image _gearIcon; private Text _gearFallback; private int _emptyState = -1; private RectTransform _notice; private Text _noticeText; private DashboardPage _movedPage; private ChartData _movedChart; private float _noticeUntil; private const float kHeaderHeight = 44f; private const float kChartLeftMargin = 32f; private const float kBaseLeftMargin = 4f; internal const float kTopOffset = -4f; private const float kStatsPanelButtonWidth = 96f; private const float kGearButtonSize = 28f; private const float kGearButtonGap = 4f; internal const float TabLeft = 36f; internal const float TabRight = 100f; public UIDashboard Dashboard { get; private set; } public PageTabBar Tabs { get; } = new PageTabBar(); public void Build(UIDashboard dashboard) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: 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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) Dashboard = dashboard; _font = (((Object)(object)dashboard.emptyTip != (Object)null) ? dashboard.emptyTip.font : null); if ((Object)(object)_font == (Object)null) { DashboardOverhaulPlugin.Logger.LogWarning((object)"[DashboardOverhaul] emptyTip/font is null; tab labels may be invisible."); } if ((Object)(object)dashboard.emptyTip != (Object)null) { ((Behaviour)dashboard.emptyTip).enabled = false; } _content = (RectTransform)new GameObject("DO_Content", new Type[1] { typeof(RectTransform) }).transform; ((Transform)_content).SetParent((Transform)(object)dashboard.rectTrans, false); ((Transform)_content).SetAsFirstSibling(); _content.anchorMin = Vector2.zero; _content.anchorMax = Vector2.one; _content.offsetMin = new Vector2(32f, 0f); _content.offsetMax = new Vector2(0f, -44f); Color color = default(Color); ((Color)(ref color))..ctor(0.04f, 0.12f, 0.19f, 1f); RectTransform val = (RectTransform)new GameObject("DO_SidebarGutter", new Type[2] { typeof(RectTransform), typeof(Image) }).transform; ((Transform)val).SetParent((Transform)(object)_content, false); val.anchorMin = Vector2.zero; val.anchorMax = new Vector2(0f, 1f); val.pivot = new Vector2(1f, 0.5f); val.anchoredPosition = Vector2.zero; val.sizeDelta = new Vector2(32f, 0f); ((Graphic)((Component)val).GetComponent<Image>()).color = color; Reparent(((Graphic)dashboard.gridRawImage).rectTransform, _content); Reparent(dashboard.chartContentRt, _content); RectTransform val2 = (RectTransform)((Component)dashboard.statboard).transform; _statboardTopOffset = val2.offsetMax; val2.offsetMax = _statboardTopOffset - new Vector2(0f, 44f); _header = (RectTransform)new GameObject("DO_Header", new Type[2] { typeof(RectTransform), typeof(Image) }).transform; ((Transform)_header).SetParent((Transform)(object)dashboard.rectTrans, false); _header.anchorMin = new Vector2(0f, 1f); _header.anchorMax = Vector2.one; _header.pivot = new Vector2(0f, 1f); _header.sizeDelta = new Vector2(0f, 44f); _header.anchoredPosition = Vector2.zero; ((Graphic)((Component)_header).GetComponent<Image>()).color = color; ((Transform)dashboard.tipsParent).SetAsLastSibling(); Tabs.Build(dashboard, _header, _font); BuildStatsPanelButton(); BuildGearButton(); BuildEmptyPanel(); } private static void Reparent(RectTransform child, RectTransform parent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Vector2 anchoredPosition = child.anchoredPosition; ((Transform)child).SetParent((Transform)(object)parent, false); child.anchoredPosition = anchoredPosition; } public void Free() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) Tabs.Free(); if ((Object)(object)_emptyPanel != (Object)null) { Object.Destroy((Object)(object)((Component)_emptyPanel).gameObject); } if ((Object)(object)_notice != (Object)null) { Object.Destroy((Object)(object)((Component)_notice).gameObject); } if ((Object)(object)_header != (Object)null) { Object.Destroy((Object)(object)((Component)_header).gameObject); } if ((Object)(object)_content != (Object)null) { Reparent(((Graphic)Dashboard.gridRawImage).rectTransform, Dashboard.rectTrans); Reparent(Dashboard.chartContentRt, Dashboard.rectTrans); Object.Destroy((Object)(object)((Component)_content).gameObject); } ((RectTransform)((Component)Dashboard.statboard).transform).offsetMax = _statboardTopOffset; Dashboard = null; } public void Close() { Tabs.CancelRename(); ChartRename.Cancel(); if ((Object)(object)_notice != (Object)null) { ((Component)_notice).gameObject.SetActive(false); } _movedPage = null; _movedChart = null; } public void Refresh() { Tabs.Refresh(); UpdateLayout(); } public void UpdateLayout() { Tabs.UpdateLayout(); UpdateGearIcon(); UpdateEmptyPanel(); if ((Object)(object)_notice != (Object)null && ((Component)_notice).gameObject.activeSelf) { int num = Array.IndexOf(Dashboard.charts.dashboardLayout.pages, _movedPage); if (Time.unscaledTime >= _noticeUntil || num < 1 || !_movedPage.chartDatas.Contains(_movedChart)) { ((Component)_notice).gameObject.SetActive(false); } else { _noticeText.text = Loc.L("已移动到:", "Moved to: ") + PageOps.PageName(_movedPage, num); } } } private Button CreateAction(Transform parent, string label, float x, float width, UnityAction action) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DO_Action", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(parent, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0.5f, 0f); val2.anchoredPosition = new Vector2(x, 0f); val2.sizeDelta = new Vector2(width, 30f); Image targetGraphic = val.AddComponent<Image>(); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)targetGraphic; DashboardUi.StyleButton(obj, new Color(0.13f, 0.3f, 0.4f, 0.95f)); DashboardUi.Text((Transform)(object)val2, _font, label, (TextAnchor)4); ((UnityEvent)obj.onClick).AddListener(action); return obj; } private void BuildEmptyPanel() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown GameObject val = new GameObject("DO_EmptyPage", new Type[1] { typeof(RectTransform) }); _emptyPanel = (RectTransform)val.transform; ((Transform)_emptyPanel).SetParent((Transform)(object)Dashboard.chartContentRt, false); _emptyPanel.sizeDelta = new Vector2(460f, 112f); _emptyText = DashboardUi.Text((Transform)(object)_emptyPanel, _font, "", (TextAnchor)1); _emptyAdd = CreateAction((Transform)(object)_emptyPanel, Loc.L("添加图表", "Add charts"), -100f, 184f, new UnityAction(ShowAddChartUi)); _emptyCopy = CreateAction((Transform)(object)_emptyPanel, Loc.L("复制其他页面", "Copy another page"), 100f, 184f, new UnityAction(OpenCopyMenu)); val.SetActive(false); } private void ShowAddChartUi() { if ((Object)(object)Dashboard == (Object)null || Dashboard.charts == null) { return; } if (Dashboard.charts.statPlans.count == 0) { UIGame uiGame = UIRoot.instance.uiGame; if (!((ManualBehaviour)uiGame.statWindow).active) { DashboardKeyPatch.ToggleStatisticsPanel(uiGame); } UIRealtimeTip.Popup(Loc.L("在统计窗口中选择需要监控的统计项", "Choose a statistic to monitor in the statistics window"), true, 0); } else if (!Dashboard.showSidebar) { Dashboard.OnSidebarBtnClick(0); } } private void BuildStatsPanelButton() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown GameObject val = new GameObject("DO_StatsPanelBtn", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)_header, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(1f, 1f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(1f, 1f); val2.anchoredPosition = new Vector2(-4f, -4f); val2.sizeDelta = new Vector2(96f, 28f); Image val4 = val.AddComponent<Image>(); ((Graphic)val4).raycastTarget = true; Button val5 = val.AddComponent<Button>(); ((Selectable)val5).targetGraphic = (Graphic)(object)val4; DashboardUi.StyleButton(val5, new Color(0.13f, 0.3f, 0.4f, 0.95f)); Text obj = DashboardUi.Text((Transform)val2, _font, Loc.L("分析面板", "Statistics"), (TextAnchor)4); obj.alignment = (TextAnchor)4; obj.horizontalOverflow = (HorizontalWrapMode)1; obj.verticalOverflow = (VerticalWrapMode)1; DashboardUi.Tip(val, Loc.L("分析面板", "Statistics panel"), Loc.L("与按 P 相同:打开或关闭统计面板", "Same as pressing P: opens or closes the statistics panel")); ((UnityEvent)val5.onClick).AddListener(new UnityAction(ToggleStatisticsPanel)); } private void BuildGearButton() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0078: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown GameObject val = new GameObject("DO_GearBtn", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)_header, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 1f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = new Vector2(4f, -4f); val2.sizeDelta = new Vector2(28f, 28f); Image val4 = val.AddComponent<Image>(); ((Graphic)val4).raycastTarget = true; Button val5 = val.AddComponent<Button>(); ((Selectable)val5).targetGraphic = (Graphic)(object)val4; DashboardUi.StyleButton(val5, new Color(0.13f, 0.3f, 0.4f, 0.95f)); GameObject val6 = new GameObject("Icon", new Type[1] { typeof(RectTransform) }); RectTransform val7 = (RectTransform)val6.transform; ((Transform)val7).SetParent((Transform)(object)val2, false); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val7.anchorMax = val3; val7.anchorMin = val3; val7.pivot = new Vector2(0.5f, 0.5f); val7.anchoredPosition = Vector2.zero; val7.sizeDelta = new Vector2(18f, 18f); _gearIcon = val6.AddComponent<Image>(); ((Graphic)_gearIcon).raycastTarget = false; _gearIcon.sprite = GearSprite(); _gearFallback = DashboardUi.Text((Transform)(object)val2, _font, Loc.L("样式", "Style"), (TextAnchor)4); if ((Object)(object)_gearIcon.sprite != (Object)null) { ((Component)_gearFallback).gameObject.SetActive(false); } DashboardUi.Tip(val, Loc.L("页面设置", "Page settings"), Loc.L("对当前页所有统计项切换样式或锁定", "Switch the style or lock for every statistic on this page")); ((UnityEvent)val5.onClick).AddListener(new UnityAction(OpenGearMenu)); _gearButton = val5; } private void UpdateGearIcon() { if ((Object)(object)_gearIcon == (Object)null || (Object)(object)_gearIcon.sprite != (Object)null) { return; } Sprite val = GearSprite(); if (!((Object)(object)val == (Object)null)) { _gearIcon.sprite = val; if ((Object)(object)_gearFallback != (Object)null) { ((Component)_gearFallback).gameObject.SetActive(false); } } } private static Sprite GearSprite() { BuiltinConfig builtin = Configs.builtin; Sprite[] array = (((Object)(object)builtin != (Object)null) ? builtin.genericMenuButtonSprites : null); if (array == null || array.Length <= 3) { return null; } return array[3]; } private void OpenGearMenu() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (!((Object)(object)Dashboard == (Object)null) && !((Object)(object)_gearButton == (Object)null)) { PageGearMenu.Open(Dashboard, (RectTransform)((Component)_gearButton).transform); } } public bool IsGearTarget(Transform target) { if ((Object)(object)_gearButton != (Object)null) { if (!((Object)(object)target == (Object)(object)((Component)_gearButton).transform)) { return target.IsChildOf(((Component)_gearButton).transform); } return true; } return false; } private void ToggleStatisticsPanel() { if (!((Object)(object)Dashboard == (Object)null)) { DashboardKeyPatch.ToggleStatisticsPanel(UIRoot.instance.uiGame); } } private void UpdateEmptyPanel() { if ((Object)(object)_emptyPanel == (Object)null || !PageOps.IsValidViewPage(Dashboard.charts)) { return; } CustomCharts charts = Dashboard.charts; DashboardPage val = charts.dashboardLayout.pages[charts.currentView.pageIndex]; bool flag = val.chartDatas.Count == 0; if (((Component)_emptyPanel).gameObject.activeSelf != flag) { ((Component)_emptyPanel).gameObject.SetActive(flag); } if (!flag) { return; } bool flag2 = charts.statPlans.count > 0; bool flag3 = false; DashboardPage[] pages = charts.dashboardLayout.pages; foreach (DashboardPage val2 in pages) { if (val2 != null && val2 != val && val2.chartDatas.Count > 0) { flag3 = true; break; } } int num = (int)((flag2 ? 1u : 0u) | (uint)(flag3 ? 2 : 0)) | (Localization.isZHCN ? 4 : 0); if (num != _emptyState) { _emptyState = num; _emptyText.text = Loc.L("当前页暂无图表\n", "This page has no charts\n") + (flag2 ? Loc.L("打开侧栏,点击统计项旁的添加按钮。", "Open the sidebar and use a statistic's add button.") : Loc.L("先在统计窗口中添加需要监控的统计项。", "Start by adding a statistic from the statistics window.")); ((Component)_emptyAdd).GetComponentInChildren<Text>().text = (flag2 ? Loc.L("添加图表", "Add charts") : Loc.L("打开统计窗口", "Open statistics")); ((Selectable)_emptyCopy).interactable = flag3; DashboardUi.Tip(((Component)_emptyCopy).gameObject, Loc.L("复制其他页面", "Copy another page"), flag3 ? Loc.L("复制布局和显示设置;统计项与原页面共享,重命名会同步生效。", "Copy layout and display settings. Statistics are shared; renaming affects both pages.") : Loc.L("没有其他包含图表的页面", "No other page contains charts")); } } private void OpenCopyMenu() { //IL_0055: 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_006f: Expected O, but got Unknown CustomCharts charts = Dashboard.charts; DashboardPage target = charts.dashboardLayout.pages[charts.currentView.pageIndex]; UIPopupMenu val = Dashboard.OpenChartPopupMenu(new Vector2(0f, 30f), (RectTransform)((Component)_emptyCopy).transform); ((Transform)val.m_RectTrans).SetParent((Transform)(object)Dashboard.chartContentRt, true); for (int i = 1; i < 10; i++) { DashboardPage source = charts.dashboardLayout.pages[i]; if (source == null || source == target || source.chartDatas.Count == 0) { continue; } UIPopupMenuButton obj = val.AddMenuButton($"{PageOps.PageName(source, i)} ({source.chartDatas.Count})", -1, false); obj.onMenuButtonClick = (Action<int>)Delegate.Combine(obj.onMenuButtonClick, (Action<int>)delegate { if (!((Object)(object)Dashboard == (Object)null) && Dashboard.charts == charts && Array.IndexOf(charts.dashboardLayout.pages, target) >= 1) { Dashboard.CloseChartPopupMenu(); if (PageOps.CopyIntoEmptyPage(source, target)) { Dashboard.DetermineCharts(); UpdateEmptyPanel(); UIRealtimeTip.Popup(Loc.L("已复制图表,统计项与原页共享。", "Charts copied. Statistics are shared with the source page."), true, 0); } } }); obj.SetState(true); } val.SetState(true); Dashboard.input_lock = true; } public void ShowMoved(DashboardPage page, ChartData chart) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0074: 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) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown if ((Object)(object)_notice == (Object)null) { GameObject val = new GameObject("DO_MoveNotice", new Type[1] { typeof(RectTransform) }); _notice = (RectTransform)val.transform; ((Transform)_notice).SetParent((Transform)(object)Dashboard.rectTrans, false); RectTransform notice = _notice; RectTransform notice2 = _notice; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0f); notice2.anchorMax = val2; notice.anchorMin = val2; _notice.pivot = new Vector2(0.5f, 0f); _notice.anchoredPosition = new Vector2(0f, 36f); _notice.sizeDelta = new Vector2(440f, 96f); ((Graphic)val.AddComponent<Image>()).color = new Color(0.02f, 0.08f, 0.14f, 0.96f); _noticeText = DashboardUi.Text((Transform)(object)_notice, _font, "", (TextAnchor)1); ((Graphic)_noticeText).rectTransform.offsetMin = new Vector2(8f, 36f); ((Graphic)_noticeText).rectTransform.offsetMax = new Vector2(-8f, -8f); CreateAction((Transform)(object)_notice, Loc.L("前往", "Go to page"), -50f, 90f, (UnityAction)delegate { int num = Array.IndexOf(Dashboard.charts.dashboardLayout.pages, _movedPage); if (num > 0) { Tabs.SwitchTo(num); Dashboard.HighlightChart(_movedChart); } ((Component)_notice).gameObject.SetActive(false); }); CreateAction((Transform)(object)_notice, Loc.L("关闭", "Dismiss"), 50f, 90f, (UnityAction)delegate { ((Component)_notice).gameObject.SetActive(false); }); } _movedPage = page; _movedChart = chart; _noticeUntil = Time.unscaledTime + 10f; ((Component)_notice).gameObject.SetActive(true); ((Transform)_notice).SetAsLastSibling(); UpdateLayout(); } } public static class PageGearMenu { public static void Open(UIDashboard dashboard, RectTransform anchor) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) CustomCharts charts = dashboard.charts; DashboardPage page = CurrentPage(charts); if (page != null && page.chartDatas.Count != 0) { dashboard.CloseChartPopupMenu(); UIDashboard obj = dashboard; Rect rect = anchor.rect; UIPopupMenu val = obj.OpenChartPopupMenu(new Vector2(0f, 0f - ((Rect)(ref rect)).height), anchor); UIPopupMenuButton val2 = val.AddMenuButton(Localization.Translate("切换图表样式"), 3, false); val2.m_ChildMenu = CreateStyleTypesMenu(dashboard, val, val2, page); val2.SetState(true); PageObserveMenu.AddTo(dashboard, val, page); UIPopupMenuButton obj2 = val.AddMenuButton(Loc.L("产量告警", "Production alarm"), -1, true); obj2.onMenuButtonClick = (Action<int>)Delegate.Combine(obj2.onMenuButtonClick, (Action<int>)delegate { dashboard.CloseChartPopupMenu(); ProductionAlarm.Run(dashboard); }); obj2.SetState(true); DashboardUi.Tip(((Component)obj2).gameObject, Loc.L("产量告警", "Production alarm"), Loc.L("按参考速率判定当前页【生产与参考速率】统计项:低于 99% 标红、低于 99.9% 标黄、达标显示黑", "Checks every production + reference statistic of this page against its reference rate: red below 99%, yellow below 99.9%, black when met")); bool allLocked = AllLocked(page); UIPopupMenuButton obj3 = val.AddMenuButton(allLocked ? Loc.L("解锁当前页统计项", "Unlock this page") : Loc.L("锁定当前页统计项", "Lock this page"), -1, true); obj3.onMenuButtonClick = (Action<int>)Delegate.Combine(obj3.onMenuButtonClick, (Action<int>)delegate { dashboard.CloseChartPopupMenu(); SetLocked(dashboard, page, !allLocked); }); obj3.SetState(true); val.SetState(true); dashboard.input_lock = true; } } private static UIPopupMenu CreateStyleTypesMenu(UIDashboard dashboard, UIPopupMenu parent, UIPopupMenuButton parentBtn, DashboardPage page) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) UIPopupMenu val = CreateChildMenu(dashboard, parent, parentBtn); foreach (EChartStyleType item in ChartPresetsDB.GetChartStyleTypeEnumArray()) { if ((int)item != 0 && ((int)item != 1 || HasGenericStyles())) { UIPopupMenuButton val3 = val.AddMenuButton(Localization.Translate("修改样式类型前缀") + ChartStyle.StyleTypeToString(item), -1, false); val3.m_ChildMenu = CreateStylesMenu(dashboard, val, val3, page, item); val3.SetState(true); } } val.SetState(true); return val; } private static UIPopupMenu CreateStylesMenu(UIDashboard dashboard, UIPopupMenu parent, UIPopupMenuButton parentBtn, DashboardPage page, EChartStyleType type) { //IL_0015: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) UIPopupMenu val = CreateChildMenu(dashboard, parent, parentBtn); ChartStyle[] chartStyles = ChartPresetsDB.GetChartStyles(); int num = SharedStyleIndex(page, type); UIPopupMenuButton obj = val.AddMenuButton(Localization.Translate("默认"), (num == 0) ? 1 : (-1), false); obj.onMenuButtonClick = (Action<int>)Delegate.Combine(obj.onMenuButtonClick, (Action<int>)delegate { //IL_0018: Unknown result type (might be due to invalid IL or missing references) dashboard.CloseChartPopupMenu(); ApplyStyle(dashboard, page, type, 0); }); obj.SetState(true); for (int num2 = 1; num2 < chartStyles.Length; num2++) { if (chartStyles[num2].type == type) { int index = num2; UIPopupMenuButton obj2 = val.AddMenuButton(Localization.Translate(chartStyles[num2].name), (num == index) ? 1 : (-1), false); obj2.onMenuButtonClick = (Action<int>)Delegate.Combine(obj2.onMenuButtonClick, (Action<int>)delegate { //IL_002c: Unknown result type (might be due to invalid IL or missing references) dashboard.CloseChartPopupMenu(); ApplyStyle(dashboard, page, type, index); }); obj2.SetState(true); } } val.SetState(true); return val; } private static UIPopupMenu CreateChildMenu(UIDashboard dashboard, UIPopupMenu parent, UIPopupMenuButton parentBtn) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) UIPopupMenu val = Object.Instantiate<UIPopupMenu>(dashboard.menuPrefab, ((Component)parentBtn).transform); RectTransform rectTrans = val.m_RectTrans; Rect rect = parentBtn.m_RectTransform.rect; rectTrans.anchoredPosition = new Vector2(((Rect)(ref rect)).width, (float)parent.Padding.top); ((Component)val).gameObject.SetActive(true); ((Transform)val.m_RectTrans).SetParent((Transform)(object)dashboard.chartContentRt, true); rect = dashboard.chartContentRt.rect; float num = Mathf.RoundToInt(((Rect)(ref rect)).width); float num2 = val.m_RectTrans.anchorMin.x * num + val.m_RectTrans.anchoredPosition.x; Rect rect2 = val.m_RectTrans.rect; ((Rect)(ref rect2)).x = ((Rect)(ref rect2)).x + num2; float num3 = 0f; if (((Rect)(ref rect2)).xMin < 0f) { num3 -= ((Rect)(ref rect2)).xMin; } if (((Rect)(ref rect2)).xMax > num) { num3 -= ((Rect)(ref rect2)).xMax - num; } ((Transform)val.m_RectTrans).SetParent((Transform)(object)parentBtn.m_RectTransform); if (Mathf.Abs(num3) > 0f) { RectTransform rectTrans2 = val.m_RectTrans; rect = val.m_RectTrans.rect; rectTrans2.anchoredPosition = new Vector2(0f - ((Rect)(ref rect)).width, (float)parent.Padding.top); } return val; } private static void ApplyStyle(UIDashboard dashboard, DashboardPage page, EChartStyleType type, int index) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) foreach (ChartData chartData in page.chartDatas) { if (ChartStyles.Apply(chartData, type, index)) { ChartStyles.Repaint(ChartStyles.FindChart(dashboard, chartData)); } } } public static void CyclePageStyle(UIDashboard dashboard, EChartStyleType type) { //IL_0029: 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_0038: Unknown result type (might be due to invalid IL or missing references) DashboardPage val = CurrentPage(dashboard.charts); if (val != null && val.chartDatas.Count != 0) { int index = ChartStyles.NextIndex(ChartStyles.GetIndex(val.chartDatas[0], type), type); ApplyStyle(dashboard, val, type, index); } } public static void ResetPageBorder(UIDashboard dashboard) { DashboardPage val = CurrentPage(dashboard.charts); if (val != null && val.chartDatas.Count != 0) { ApplyStyle(dashboard, val, (EChartStyleType)3, 0); } } private static void SetLocked(UIDashboard dashboard, DashboardPage page, bool locked) { foreach (ChartData chartData in page.chartDatas) { if (chartData.locked != locked) { ChartState.SetLocked(chartData, locked); ChartStyles.Repaint(ChartStyles.FindChart(dashboard, chartData)); } } } private static bool HasGenericStyles() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 ChartStyle[] chartStyles = ChartPresetsDB.GetChartStyles(); for (int i = 1; i < chartStyles.Length; i++) { if ((int)chartStyles[i].type == 1) { return true; } } return false; } private static bool AllLocked(DashboardPage page) { if (page.chartDatas.Count == 0) { return false; } foreach (ChartData chartData in page.chartDatas) { if (!chartData.locked) { return false; } } return true; } private static int SharedStyleIndex(DashboardPage page, EChartStyleType type) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (page.chartDatas.Count == 0) { return 0; } int index = ChartStyles.GetIndex(page.chartDatas[0], type); foreach (ChartData chartData in page.chartDatas) { if (ChartStyles.GetIndex(chartData, type) != index) { return -1; } } return index; } private static DashboardPage CurrentPage(CustomCharts charts) { if (!PageOps.IsValidViewPage(charts)) { return null; } return charts.dashboardLayout.pages[charts.currentView.pageIndex]; } } public static class PageObserveMenu { private sealed class ObserveGroup { public readonly List<UIChart> Charts = new List<UIChart>(); public (EStatPlanType Type, int Preset, int Subject, bool Totals) Key; public string Label; } public static void AddTo(UIDashboard dashboard, UIPopupMenu menu, DashboardPage page) { foreach (ObserveGroup item in Groups(dashboard, page)) { UIChart val = item.Charts[0]; int count = menu.childButtons.Count; val.SetObserveGroupPopupMenuButtons(menu); for (int i = count; i < menu.childButtons.Count; i++) { UIPopupMenuButton val2 = menu.childButtons[i]; val2.ButtonText = val2.ButtonText + " (" + item.Label + ")"; val2.SetState(true); DashboardUi.Tip(((Component)val2).gameObject, val2.ButtonText, string.Format(Loc.L("修改当前页中背景为绿色、属于此组的 {0} 个图表。", "Changes the {0} green charts in this group on the current page."), item.Charts.Count)); Bind(val2, val, item.Charts, dashboard); } } } private static void Bind(UIPopupMenuButton button, UIChart source, List<UIChart> targets, UIDashboard dashboard) { Action<int> onMenuButtonClick = button.onMenuButtonClick; if (onMenuButtonClick == null) { if (!((Object)(object)button.m_ChildMenu != (Object)null)) { return; } { foreach (UIPopupMenuButton childButton in button.m_ChildMenu.childButtons) { Bind(childButton, source, targets, dashboard); } return; } } Action<int>[] handlers = BindTargets(onMenuButtonClick, source, targets); if (handlers == null) { button.onMenuButtonClick = null; ((Selectable)button.m_Button).interactable = false; DashboardUi.Tip(((Component)button).gameObject, button.ButtonText, Loc.L("此扩展选项不支持批量修改,请在单个图表中设置。", "Set this extension option on an individual chart; batch editing is unavailable.")); return; } if (targets.Count > 1) { button.ButtonIcon = null; button.SetState(true); } button.onMenuButtonClick = delegate(int data) { dashboard.CloseChartPopupMenu(); Action<int>[] array = handlers; for (int i = 0; i < array.Length; i++) { array[i](data); } }; } private static Action<int>[] BindTargets(Action<int> handler, UIChart source, List<UIChart> targets) { if (handler.GetInvocationList().Length != 1 || handler.Target != source || handler.Method.DeclaringType?.Assembly != typeof(UIChart).Assembly) { return null; } Action<int>[] array = new Action<int>[targets.Count]; for (int i = 0; i < targets.Count; i++) { if (!handler.Method.DeclaringType.IsInstanceOfType(targets[i])) { return null; } array[i] = (Action<int>)Delegate.CreateDelegate(typeof(Action<int>), targets[i], handler.Method); } return array; } private static List<ObserveGroup> Groups(UIDashboard dashboard, DashboardPage page) { List<ObserveGroup> list = new List<ObserveGroup>(); int greenBackgroundIndex = ChartStyles.GreenBackgroundIndex; if (greenBackgroundIndex < 0) { return list; } foreach (ChartData chartData in page.chartDatas) { if (chartData.backgroundStyleIndex != greenBackgroundIndex) { continue; } UIChart val = ChartStyles.FindChart(dashboard, chartData); if (!((Object)(object)val == (Object)null)) { StatPlan plan = val.charts.statPlans[chartData.statPlanId]; (EStatPlanType Type, int Preset, int Subject, bool Totals) key = GroupKey(plan, chartData); ObserveGroup observeGroup = list.Find(delegate(ObserveGroup candidate) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) (EStatPlanType, int, int, bool) key2 = candidate.Key; (EStatPlanType, int, int, bool) tuple = key; return key2.Item1 == tuple.Item1 && key2.Item2 == tuple.Item2 && key2.Item3 == tuple.Item3 && key2.Item4 == tuple.Item4; }); if (observeGroup == null) { observeGroup = new ObserveGroup { Key = key, Label = GroupLabel(plan, key) }; list.Add(observeGroup); } observeGroup.Charts.Add(val); } } return list; } internal static (EStatPlanType Type, int Preset, int Subject, bool Totals) GroupKey(StatPlan plan, ChartData data) { //IL_006c: 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_006b: Expected I4, but got Unknown int item = 0; bool item2 = false; AstroItemProductionStatPlan val = (AstroItemProductionStatPlan)(object)((plan is AstroItemProductionStatPlan) ? plan : null); if (val == null) { DysonSphereStatPlan val2 = (DysonSphereStatPlan)(object)((plan is DysonSphereStatPlan) ? plan : null); if (val2 == null) { AstroTransportStatPlan val3 = (AstroTransportStatPlan)(object)((plan is AstroTransportStatPlan) ? plan : null); if (val3 == null) { SingleStorageStatPlan val4 = (SingleStorageStatPlan)(object)((plan is SingleStorageStatPlan) ? plan : null); if (val4 != null) { item = (int)val4.storageType; } } else { item = (val3.isInterstellar ? 1 : 0); } } else { item = ((data.displayTypeParams[0] != 0) ? 1 : 0); item2 = val2.timeLevel == 5; } } else { item2 = val.timeLevel == 5; } return (Type: plan.type, Preset: data.presetIndex, Subject: item, Totals: item2); } private static string GroupLabel(StatPlan plan, (EStatPlanType Type, int Preset, int Subject, bool Totals) key) { //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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Invalid comparison between Unknown and I4 //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Invalid comparison between Unknown and I4 string text = StatPlan.GetDefaultName(key.Type, key.Subject) + " " + Localization.Translate(ChartPresetsDB.GetPresetsArray(key.Type)[key.Preset].name); if (!(plan is AstroItemProductionStatPlan)) { if (!(plan is DysonSphereStatPlan)) { SingleStorageStatPlan val = (SingleStorageStatPlan)(object)((plan is SingleStorageStatPlan) ? plan : null); if (val != null) { if ((int)val.storageType == 1) { return text + " · " + Loc.L("仓库", "Storage"); } if ((int)val.storageType == 2) { return text + " · " + Loc.L("储液罐", "Tank"); } } return text; } return text + " · " + ((key.Subject == 0) ? Loc.L("太阳帆", "Sails") : Loc.L("结构点与细胞", "Structure / cells")) + " · " + (key.Totals ? Loc.L("累计", "Total") : Loc.L("速率", "Rate")); } return text + " · " + (key.Totals ? Loc.L("累计", "Total") : Loc.L("速率", "Rate")); } } public static class PageOps { public static int ActivePageCount(CustomCharts charts) { int num = 0; DashboardPage[] pages = charts.dashboardLayout.pages; for (int i = 1; i < 10; i++) { if (pages[i] != null) { num++; } } return num; } public static int FirstFreeSlot(DashboardLayout layout) { DashboardPage[] pages = layout.pages; for (int i = 1; i < 10; i++) { if (pages[i] == null) { return i; } } return -1; } public static int FirstActiveSlot(DashboardLayout layout) { DashboardPage[] array = layout?.pages; if (array == null) { return -1; } for (int i = 1; i < 10; i++) { if (array[i] != null) { return i; } } return -1; } public static bool IsValidViewPage(CustomCharts charts) { DashboardPage[] array = charts?.dashboardLayout?.pages; if (array == null) { return false; } int pageIndex = charts.currentView.pageIndex; if (pageIndex >= 1 && pageIndex < 10) { return array[pageIndex] != null; } return false; } public static string PageName(DashboardPage page, int slot) { if (!string.IsNullOrEmpty(page.name)) { return page.name; } return slot.ToString(); } public static void EnsureViewPage(CustomCharts charts) { if (!IsValidViewPage(charts)) { int num = FirstActiveSlot(charts.dashboardLayout); if (num < 0) { num = 1; charts.dashboardLayout.AddPage(num); } charts.currentView.pageIndex = num; } } public static int AddPage(CustomCharts charts) { DashboardLayout dashboardLayout = charts.dashboardLayout; int num = FirstFreeSlot(dashboardLayout); if (num < 0) { return -1; } List<DashboardPage> list = new List<DashboardPage>(); for (int i = 1; i < 10; i++) { if (dashboardLayout.pages[i] != null) { list.Add(dashboardLayout.pages[i]); } } dashboardLayout.AddPage(num); list.Add(dashboardLayout.pages[num]); ReorderPages(charts, list); return list.Count; } public static bool CanDelete(CustomCharts charts) { return ActivePageCount(charts) > 1; } public static int PickPageAfterDelete(DashboardLayout layout, int deletedIndex) { DashboardPage[] pages = layout.pages; for (int num = deletedIndex - 1; num >= 1; num--) { if (pages[num] != null) { return num; } } for (int i = deletedIndex + 1; i < 10; i++) { if (pages[i] != null) { return i; } } return -1; } public static bool RemovePage(CustomCharts charts, int index) { if (!CanDelete(charts)) { return false; } if (index < 1 || index >= 10) { return false; } DashboardPage[] pages = charts.dashboardLayout.pages; DashboardPage val = pages[index]; if (val == null) { return false; } val.Free(); pages[index] = null; return true; } public static bool ReorderPages(CustomCharts charts, IReadOnlyList<DashboardPage> newOrder) { DashboardPage[] array = charts?.dashboardLayout?.pages; if (array == null || newOrder == null) { return false; } int num = ActivePageCount(charts); if (num == 0) { return false; } if (newOrder.Count != num) { return false; } HashSet<DashboardPage> hashSet = new HashSet<DashboardPage>(); foreach (DashboardPage item in newOrder) { if (item == null) { return false; } hashSet.Add(item); } if (hashSet.Count != num) { return false; } for (int i = 1; i < 10; i++) { if (array[i] != null && !hashSet.Contains(array[i])) { return false; } } int pageIndex = charts.currentView.pageIndex; DashboardPage val = ((pageIndex >= 1 && pageIndex < 10) ? array[pageIndex] : null); for (int j = 0; j < newOrder.Count; j++) { array[j + 1] = newOrder[j]; } for (int k = newOrder.Count + 1; k < 10; k++) { array[k] = null; } int pageIndex2 = 1; if (val != null) { for (int l = 1; l < 10; l++) { if (array[l] == val) { pageIndex2 = l; break; } } } charts.currentView.pageIndex = pageIndex2; return true; } public static void RenamePage(DashboardPage page, string newName) { if (page != null) { page.name = (newName ?? string.Empty).Trim(); } } public static int ChartCount(CustomCharts charts, int statPlanId) { int num = 0; DashboardPage[] pages = charts.dashboardLayout.pages; foreach (DashboardPage val in pages) { if (val == null) { continue; } foreach (ChartData chartData in val.chartDatas) { if (chartData.statPlanId == statPlanId) { num++; } } } if (charts.watchLayout?.chartDatas != null) { foreach (ChartData chartData2 in charts.watchLayout.chartDatas) { if (chartData2.statPlanId == statPlanId) { num++; } } } return num; } public static bool TryMoveChart(DashboardPage source, DashboardPage target, ChartData chart, Vector2Int bounds) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (source == target || !source.chartDatas.Contains(chart)) { return false; } Vector2Int pos = chart.pos; if (!Fits(target, pos, chart.size, bounds)) { bool flag = false; for (int i = 0; i + ((Vector2Int)(ref chart.size)).y <= ((Vector2Int)(ref bounds)).y; i++) { if (flag) { break; } for (int j = 0; j + ((Vector2Int)(ref chart.size)).x <= ((Vector2Int)(ref bounds)).x; j++) { if (Fits(target, new Vector2Int(j, i), chart.size, bounds)) { ((Vector2Int)(ref pos))..ctor(j, i); flag = true; break; } } } if (!flag) { return false; } } int num = -1; foreach (ChartData chartData in target.chartDatas) { num = Math.Max(num, chartData.depth); } source.chartDatas.Remove(chart); chart.pos = pos; chart.depth = num + 1; target.chartDatas.Add(chart); return true; } private static bool Fits(DashboardPage page, Vector2Int pos, Vector2Int size, Vector2Int bounds) { if (((Vector2Int)(ref pos)).x < 0 || ((Vector2Int)(ref pos)).y < 0 || ((Vector2Int)(ref pos)).x + ((Vector2Int)(ref size)).x > ((Vector2Int)(ref boun