|
123456789101112131415161718192021222324252627282930313233 |
- using System;
- using System.Collections.Generic;
- using System.IO;
-
- namespace NScript.Filmscript
- {
- public class FilmscriptInstaller : Install.IInstallable
- {
- public string Name { get; } = "filmscript.dll";
-
- public void Install()
- {
- List<Gitea.Release> releases = Gitea.ReleaseUtility.GetReleases("NGnius", "filmscript-rs");
-
- GamecraftModdingAPI.Utility.Logging.Log($"Downloading {Name}");
- #if DEBUG
- var r = Gitea.ReleaseUtility.FindRelease(releases, prerelease: true)?? throw new Exception("Failed to find valid release candidate");
- #else
- var r = Gitea.ReleaseUtility.FindRelease(releases)?? throw new Exception("Failed to find valid release candidate");
- #endif
- var a = Gitea.ReleaseUtility.FindAsset(r, Name)?? throw new Exception($"Failed to find valid asset candidate for {Name}");
- var download = Gitea.ReleaseUtility.DownloadAsset(a);
- File.WriteAllBytes(NScript.Install.InstallTools.NativeDllFilepath(Name), download);
- }
-
- public bool IsInstalled()
- {
- // NOTE: Mono will only try to load a native DLL once, so trying to call a non-existent DLL
- // will prevent it from being loaded later, even if it's downloaded between now and then.
- return NScript.Install.InstallTools.NativeDllExists(Name);
- }
- }
- }
|