private static void BeginSelectingMod() { var isInitialized = false; GUILayout.BeginVertical(UiStyle.Style[0]); for (var i = 0; i < Ui.Functions.Count; i++) { if (i == 0) { GUILayout.BeginHorizontal(); } if (i == 0 || i == 3) { GUILayout.BeginVertical(); } if (!isInitialized) { if (GUILayout.Button("I'm not a cheater!", UiStyle.Style[5])) { Main.SelectedMod = 0; Progress.CurrentState = Progress.States.EndSelectingMod; } isInitialized = true; } var isToggleAble = Directory.Exists(PathMgr.Raw(((Mods[])Enum.GetValues(typeof(Mods)))[i + 1].ToString().ToLower().Replace("_", "-"))); if (GUILayout.Button(Ui.Functions[i], UiStyle.Style[isToggleAble ? 5 : 6])) { if (!isToggleAble) { break; } Main.SelectedMod = ((Mods[])Enum.GetValues(typeof(Mods)))[i + 1]; Progress.CurrentState = Progress.States.EndSelectingMod; } if (i == 2 || i == 6) { GUILayout.EndVertical(); } if (i == 6) { GUILayout.EndVertical(); } } GUILayout.EndVertical(); GUILayout.BeginHorizontal(UiStyle.Style[0]); if (GUILayout.Button("Replace Skin", UiStyle.Style[Main.ReplaceSkin ? 7 : 8])) { Main.ReplaceSkin = !Main.ReplaceSkin; File.WriteAllText(PathMgr.WorkingDirectory("prefs"), Main.ReplaceSkin ? "1" : "0"); } GUILayout.EndHorizontal(); }
public static byte[] Initialize(TextAsset textAsset, string fileName) { if (Main.SelectedMod == 0) { return(textAsset.bytes); } if (_keys == null) { _keys = new List <string>(); } AddKey("aircraft_template"); AddKey("enemy_data_skill"); AddKey("enemy_data_statistics"); if (Main.ReplaceSkin) { AddKey("ship_data_statistics"); } if (Main.SelectedMod.ToString().ToLower().Contains("damage")) { AddKey("weapon_property"); } foreach (var key in _keys) { if (!fileName.Contains(key)) { continue; } foreach (var filePath in Directory.GetFiles(PathMgr.Raw(Main.SelectedMod.ToString().ToLower().Replace("_", "-")), "*.*", SearchOption.AllDirectories)) { if (!filePath.Contains(key)) { continue; } var bytes = File.ReadAllBytes(filePath); return(bytes); } } return(textAsset.bytes); }
public static IEnumerator Initialize(Action callback, string version) { if (!Directory.Exists(PathMgr.WorkingDirectory())) { Directory.CreateDirectory(PathMgr.WorkingDirectory()); } Ui.Initialize(); yield return(InitializePackage("raw", version)); if (!File.Exists(PathMgr.WorkingDirectory("prefs"))) { File.WriteAllText(PathMgr.WorkingDirectory("prefs"), "0"); } ReplaceSkin = File.ReadAllText(PathMgr.WorkingDirectory("prefs")) != "0"; Progress.CurrentState = Progress.States.BeginSelectingMod; yield return(new WaitUntil(() => Progress.CurrentState == Progress.States.EndSelectingMod)); callback(); }
private static IEnumerator InitializePackage(string fileName, string version) { Progress.CurrentState = Progress.States.BeginInitializingPackage; var localPackagePath = PathMgr.WorkingDirectory(fileName + ".zip"); var webPackagePath = PathMgr.Web(version, LocalizationVersion(), fileName + ".zip"); var isCached = false; yield return(HttpClient.GetHeader(webPackagePath, "Content-Length", (isErr, err, length) => { if (!isErr && File.Exists(localPackagePath) && new FileInfo(localPackagePath).Length.ToString() == length) { isCached = true; } })); if (!isCached) { yield return(HttpClient.GetBytes(webPackagePath, (isErr, err, bytes) => { if (!isErr) { File.WriteAllBytes(localPackagePath, bytes); } })); } if (Directory.Exists(PathMgr.WorkingDirectory(fileName))) { Rmdir(PathMgr.WorkingDirectory(fileName)); } var fastZip = new FastZip(); fastZip.ExtractZip(localPackagePath, PathMgr.WorkingDirectory(), null); Progress.CurrentState = Progress.States.EndInitializingPackage; }