Lua utilities for reading spring archives
Ejemplo n.º 1
0
 string ToModName(string path)
 {
     if (path.ToLower().EndsWith(".sdz") || path.ToLower().EndsWith("sd7"))
     {
         return(SpringLua.GetModName(L, path));
     }
     return(path); // is already mod name
 }
Ejemplo n.º 2
0
        public Mod(string name, IDictionary <string, string> allMods)
        {
            Name        = name;
            ArchiveName = allMods[name];
            modsPath    = Path.Combine(ArchiveName, "..");
            springPath  = Path.Combine(modsPath, "..");
            var basePath = Path.Combine(springPath, "base");

            springContentFile = Path.Combine(basePath, "springcontent.sdz");
            L            = SpringLua.GetLuaState(springPath);
            this.allMods = allMods;
            var dependencies = new List <string>();

            dependencies.Add(springContentFile);
            dependencies.AddRange(GetDependencyArchivePaths(ArchiveName));
            DependencyPaths = dependencies.ToArray();
            dependencies.Add(ArchiveName);
            FileMap = LoadArchives(dependencies);
            Lua.lua_close(L);
        }
Ejemplo n.º 3
0
        public ArchiveLister(string springPath)
        {
            Mods = new Dictionary <string, string>();
            Maps = new Dictionary <string, string>();
            var contentFolders = new[] { "mods", "maps", "base" };
            var L = SpringLua.GetLuaState(springPath);

            foreach (var folderPath in contentFolders)
            {
                foreach (var archivePath in Directory.GetFiles(Path.Combine(springPath, folderPath), "*"))
                {
                    if (!IsSpringArchive(archivePath))
                    {
                        continue;
                    }
                    foreach (var fileName in Archive.RawListFiles(archivePath))
                    {
                        if (IsModInfo(fileName))
                        {
                            var modName = SpringLua.ProtectedGetModName(L, archivePath);
                            if (modName != null)
                            {
                                Mods.Remove(modName);
                                Mods[modName] = archivePath;
                            }
                        }
                        else if (IsMap(fileName))
                        {
                            var mapName = Path.GetFileName(fileName);
                            Maps.Remove(mapName);
                            Maps[mapName] = archivePath;
                        }
                    }
                }
            }
            Lua.lua_close(L);
        }