Exemplo n.º 1
0
        public ModPreferences(string modName, string basePath)
        {
            this.modName  = modName;
            this.basePath = basePath;

            string manifestPath = Path.Combine(this.basePath, manifestFileName);

            hasManifest = File.Exists(manifestPath);
            hasGit      = Directory.Exists(Path.Combine(this.basePath, ".git"));

            if (!hasManifest || hasGit)
            {
                updateType = UpdateType.Disabled;
            }
            else
            {
                manifest = Json.ParseFile <ModManifest>(manifestPath);

                string modPrefPath = Path.Combine(basePath, prefFileName);
                if (!File.Exists(modPrefPath))
                {
                    updateType = manifest.defaultUpdateType;
                    Save();
                }
                else
                {
                    Json.ParseFileInto(modPrefPath, this);
                }
            }
        }
Exemplo n.º 2
0
        public virtual async Task <bool> PrepareNewInstallation(string manifestUri, string installPath = null)
        {
            Log("Downloading modmanifest.json...");
            string json = await DownloadStringAsync(manifestUri);

            Log("Downloaded modmanifest.json");

            manifest = Json.Parse <ModManifest>(json);
            modName  = string.IsNullOrWhiteSpace(installPath) ? manifest.defaultInstallDir : installPath;
            basePath = GetModAbsolutePath(modName).NormalizedDirPath();

            if (Directory.Exists(basePath) && Directory.GetFileSystemEntries(basePath).Any())
            {
                Log("Install directory is not empty. Aborting mod installation...");
                return(false);
            }

            Directory.CreateDirectory(basePath);
            File.WriteAllText(Path.Combine(basePath, ModPreferences.manifestFileName), json);

            var pref = new ModPreferences(modName, basePath);

            localVersion = pref.localVersion;
            updateType   = pref.updateType;

            return(true);
        }
Exemplo n.º 3
0
 public AbstractModUpdateInfo(ModManifest manifest, string modName, string basePath, UpdateType updateType, string localVersion)
 {
     this.manifest     = manifest;
     this.updateType   = updateType;
     this.modName      = modName;
     this.basePath     = basePath.NormalizedDirPath();
     this.localVersion = localVersion;
 }
Exemplo n.º 4
0
 public FtdModUpdateInfo(ModManifest modManifest, ModPreferences modPreferences) : base(
         modManifest,
         modPreferences.modName,
         modPreferences.basePath,
         modPreferences.updateType,
         modPreferences.localVersion
         )
 {
 }
Exemplo n.º 5
0
        public AbstractModUpdateInfo(string basePath)
        {
            this.basePath = basePath.NormalizedDirPath();
            manifest      = Json.ParseFile <ModManifest>(Path.Combine(this.basePath, ModPreferences.manifestFileName));
            modName       = new DirectoryInfo(basePath).Name;

            var pref = new ModPreferences(modName, this.basePath);

            localVersion = pref.localVersion;
            updateType   = pref.updateType;
        }