public static string[] GetDirectories(string path) { path = path.Replace('\\', '/'); List <string> stringList = new List <string>(); if (Options.Data.cloud && !MonoMain.disableCloud && Steam.IsInitialized()) { string localSavePath = DuckFile.GetLocalSavePath(path); if (localSavePath != null) { int count = Steam.FileGetCount(); for (int file = 0; file < count; ++file) { string name = Steam.FileGetName(file); int num = name.IndexOf(localSavePath); if (num != -1 && name.StartsWith("nq403216_")) { if (localSavePath == "") { num += 12; } string str1 = name.Substring(num + localSavePath.Length, name.Length - (num + localSavePath.Length)); int length = str1.IndexOf('/'); switch (length) { case -1: case 0: continue; default: string str2 = path + str1.Substring(0, length); if (!stringList.Contains(str2)) { stringList.Add(str2); continue; } continue; } } } } } path = path.Trim('/'); if (!MonoMain.cloudOnly && Directory.Exists(path)) { foreach (string path1 in DuckFile.GetDirectoriesNoCloud(path)) { if (!Path.GetFileName(path1).Contains("._")) { string str = path1.Replace('\\', '/'); if (!stringList.Contains(str)) { stringList.Add(str); } } } } return(stringList.ToArray()); }
public static string[] GetDirectories(string path, string filter = "*.*") { path = path.Replace('\\', '/'); path = path.Trim('/'); List <string> stringList = new List <string>(); foreach (string path1 in DuckFile.GetDirectoriesNoCloud(path)) { if (!Path.GetFileName(path1).Contains("._")) { stringList.Add(path1); } } return(stringList.ToArray()); }
private static void ResultFetched(object value0, WorkshopQueryResult result) { if (result == null || result.details == null) { return; } WorkshopItem publishedFile = result.details.publishedFile; if (publishedFile == null) { return; } try { if ((publishedFile.stateFlags & WorkshopItemState.Installed) == WorkshopItemState.None || !Directory.Exists(publishedFile.path)) { return; } foreach (string folder in DuckFile.GetDirectoriesNoCloud(publishedFile.path)) { ModConfiguration modConfiguration = ModLoader.AttemptModLoad(folder); if (modConfiguration != null) { try { modConfiguration.isWorkshop = true; ModLoader.loadableMods.Add(modConfiguration.uniqueID, modConfiguration); } catch (Exception ex) { } } } } catch (Exception ex) { } }
internal static void LoadMods(string dir) { ModLoader.modDirectory = dir; ModLoader.LoadConfig(); Stack <string> modLoadStack = new Stack <string>(); ModLoader.loadableMods = new Dictionary <string, ModConfiguration>(); if (Directory.Exists(ModLoader.modDirectory)) { if (Steam.IsInitialized()) { bool done = false; WorkshopQueryUser queryUser = Steam.CreateQueryUser(Steam.user.id, WorkshopList.Subscribed, WorkshopType.UsableInGame, WorkshopSortOrder.TitleAsc); queryUser.requiredTags.Add("Mod"); queryUser.onlyQueryIDs = true; queryUser.QueryFinished += (WorkshopQueryFinished)(sender => done = true); queryUser.ResultFetched += new WorkshopQueryResultFetched(ModLoader.ResultFetched); queryUser.Request(); while (!done) { Steam.Update(); Thread.Sleep(13); } } List <string> directoriesNoCloud = DuckFile.GetDirectoriesNoCloud(ModLoader.modDirectory); MonoMain.totalLoadyBits += directoriesNoCloud.Count <string>() * 2; foreach (string folder in directoriesNoCloud) { ModConfiguration modConfiguration = ModLoader.AttemptModLoad(folder); MonoMain.loadyBits += 2; if (modConfiguration != null) { if (ModLoader.loadableMods.ContainsKey(modConfiguration.uniqueID)) { if (ModLoader.loadableMods[modConfiguration.uniqueID].disabled && !modConfiguration.disabled) { ModLoader.loadableMods.Remove(modConfiguration.uniqueID); } else { continue; } } ModLoader.loadableMods.Add(modConfiguration.uniqueID, modConfiguration); } } } MonoMain.totalLoadyBits += ModLoader.loadableMods.Count * 2; int num = 0; foreach (ModConfiguration modConfig in ModLoader.loadableMods.Values) { try { ModLoader.currentModLoadString = modConfig.name; MonoMain.loadMessage = "LOADING MOD " + ModLoader.currentModLoadString; ModLoader.GetOrLoad(modConfig, ref modLoadStack, ref ModLoader.loadableMods); MonoMain.loadyBits += 2; ++num; if (num == 10) { num = 0; Thread.Sleep(50); } } catch (Exception ex) { ModLoader._modLoadErrors.Add(Tuple.Create <string, Exception>(modConfig.uniqueID, ex)); MonoMain.loadyBits += 2; } } ModLoader._sortedMods = (IList <Mod>)ModLoader._loadedMods.Values.OrderBy <Mod, Priority>((Func <Mod, Priority>)(mod => mod.priority)).ToList <Mod>(); ModLoader._sortedAccessibleMods = (IList <Mod>)ModLoader._sortedMods.Where <Mod>((Func <Mod, bool>)(mod => !mod.configuration.disabled)).ToList <Mod>(); foreach (Mod mod in ModLoader._sortedMods.Where <Mod>((Func <Mod, bool>)(a => a.configuration.disabled))) { if (mod != null && mod.configuration != null) { ModLoader._loadedMods.Remove(mod.configuration.uniqueID); } } foreach (Mod sortedAccessibleMod in (IEnumerable <Mod>)ModLoader._sortedAccessibleMods) { sortedAccessibleMod.InvokeOnPreInitialize(); } ModLoader.modHash = ModLoader.GetModHash(); foreach (Mod sortedAccessibleMod in (IEnumerable <Mod>)ModLoader._sortedAccessibleMods) { foreach (System.Type type in sortedAccessibleMod.configuration.assembly.GetTypes()) { ModLoader._typesByName[ModLoader.SmallTypeName(type)] = type; } } }