Exemplo n.º 1
0
        private void OnModGroupLoaded(ModGroup newModGroup)
        {
            try {
                Log("==================== Mod Group (Re-)loaded ====================");
                Log($"LoadActiveModConfig: Loaded '{modGroupLoader.FullFilePath}', "
                    + $"new mod: {newModGroup.pathToCurrentMod}, "
                    + $"last mod: {modGroup.pathToCurrentMod}");

                string oldMod = modGroup.pathToCurrentMod;
                modGroup = newModGroup;

                if (CheckBasePath())
                {
                    if (modGroup.isGroupActive)
                    {
                        if (initialLoad || modGroup.pathToCurrentMod != oldMod)
                        {
                            initialLoad = false;
                            ModChanged();
                        }
                        else
                        {
                            LogWarning("Current Mod was not changed!");
                        }
                    }
                    else
                    {
                        Log("Mod is not active: Restoring Default");
                        arenaMod = arenaOrig;
                        arenaModLoader.ModChanged = true;
                    }
                }
                else
                {
                    WriteErrorToFile("ActiveModConfig", $"pathToCurrentMod '{newModGroup.FullBasePath}' does not seem to exist!");
                }
            } catch (Exception exc) {
                Debug.LogException(exc);
            }
        }
Exemplo n.º 2
0
        public List <Mod> LoadMods(PathBase pathBase, ModGroup modGroup)
        {
            StringBuilder sb   = new StringBuilder();
            List <Mod>    mods = new List <Mod>();

            foreach (string path in modGroup.PathsForMods)
            {
                string fullPath = path;
                if (!Path.IsPathRooted(path))
                {
                    fullPath = GetFullPath(pathBase, fullPath);
                    sb.AppendLine($"Trying path '{path}' (=> '{fullPath}')");
                }
                else
                {
                    sb.AppendLine($"Trying path '{path}' (rooted)");
                }

                DirectoryInfo dirInfo  = new DirectoryInfo(fullPath);
                FileInfo[]    modFiles = dirInfo.GetFiles("Mod.json", SearchOption.AllDirectories);
                foreach (FileInfo modFile in modFiles)
                {
                    Mod mod = LoadFile <Mod>(modFile.FullName);
                    if (mod.groupKey.Equals(modGroup.groupKey))
                    {
                        mod.PathToMod = modFile.Directory.FullName;
                        mods.Add(mod);
                        sb.AppendLine($"Added mod '{mod.modName}' at '{modFile.FullName}'");
                    }
                    else
                    {
                        sb.AppendLine(
                            $"Skipping mod '{mod.modName}', has '{mod.groupKey}', needs: '{modGroup.groupKey}'");
                    }
                }
            }
            Log($"Searched for mods. Results:{System.Environment.NewLine}{sb}");

            return(mods);
        }
Exemplo n.º 3
0
 public void GetFrom(ModGroup group)
 {
     modName  = group.pathToCurrentMod;
     groupKey = group.groupKey;
 }