static void _OnOpen(UILoadGameWindow __instance, UIButton ___loadButton, List <UIGameSaveEntry> ___entries) { if (!decompressButton) { decompressButton = ___loadButton; decompressButton = (__instance.transform.Find("button-decompress")?.gameObject ?? GameObject.Instantiate(___loadButton.gameObject, ___loadButton.transform.parent)).GetComponent <UIButton>(); decompressButton.gameObject.name = "button-decompress"; decompressButton.transform.Translate(new Vector3(-2.0f, 0, 0)); decompressButton.button.image.color = new Color32(0, 0xf4, 0x92, 0x77); var localizer = decompressButton.transform.Find("button-text")?.GetComponent <Localizer>(); var text = decompressButton.transform.Find("button-text")?.GetComponent <Text>(); if (localizer) { localizer.stringKey = "解压/Decompress".Translate(); localizer.translation = "解压/Decompress".Translate(); } if (text) { text.text = "解压/Decompress".Translate(); } decompressButton.onClick += _ => { if (SaveUtil.DecompressSave(__instance.selected.saveName, out var newfileName)) { __instance.RefreshList(); __instance.selected = ___entries.First(e => e.saveName == newfileName); } }; decompressButton.button.interactable = false; } }
static void OnSelectedChange(UILoadGameWindow __instance, UIButton ___loadButton, Text ___prop3Text) { bool compressedSave = (___prop3Text != null && ___prop3Text.text.Contains("LZ4")) || (___loadButton.button.interactable == false && SaveUtil.IsCompressedSave(__instance.selected?.saveName)); if (decompressButton) { decompressButton.button.interactable = compressedSave; } }
public static void UILoadGameWindow_RefreshList_Postfix(ref UILoadGameWindow __instance) { if (configSortLoadScreen.Value) { //List<UIGameSaveEntry> sorted = __instance.entries.OrderByDescending(e => e.fileDate).ToList(); __instance.entries.Sort(new GameSaveEntryReverseSorter()); int displayIndex = 1; for (int i = 0; i < __instance.entries.Count;) { UIGameSaveEntry entry = __instance.entries[i++]; if (entry.fileInfo.Name.Equals(GameSave.LastExitFullName)) { entry.SetEntry(i, 0, entry.fileInfo); } else if (entry.fileInfo.Name.Equals(GameSave.AutoSave0FullName)) { entry.SetEntry(i, -1, entry.fileInfo); } else if (entry.fileInfo.Name.Equals(GameSave.AutoSave1FullName)) { entry.SetEntry(i, -2, entry.fileInfo); } else if (entry.fileInfo.Name.Equals(GameSave.AutoSave2FullName)) { entry.SetEntry(i, -3, entry.fileInfo); } else if (entry.fileInfo.Name.Equals(GameSave.AutoSave3FullName)) { entry.SetEntry(i, -4, entry.fileInfo); } else { entry.SetEntry(i, displayIndex++, entry.fileInfo); } } __instance.OnSelectedChange(); } }