Exemplo n.º 1
0
        public static void CreateManifest(Mod mod)
        {
            try
            {
                ModsManifest mm = new ModsManifest
                {
                    modID       = mod.ID,
                    version     = mod.Version,
                    description = "",
                    sign        = FileHash(mod.fileName),
                    sid_sign    = ChecksumCalculator(ModLoader.steamID + mod.ID),
                    type        = 0
                };

                string path = ModLoader.GetMetadataFolder($"{mod.ID}.json");

                if (File.Exists(path))
                {
                    ModConsole.Error("Metadata file already exists, to update use update command");
                    return;
                }

                File.WriteAllText(path, Newtonsoft.Json.JsonConvert.SerializeObject(mm, Newtonsoft.Json.Formatting.Indented));

                ModConsole.Print("<color=green>Raw metadata file created successfully</color>");
            }
            catch (Exception e)
            {
                ModConsole.Error(e.Message);
                System.Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
        public static void CreateManifest(Mod mod)
        {
            string steamID;

            if (ModLoader.CheckSteam())
            {
                steamID = Steamworks.SteamUser.GetSteamID().ToString();
            }

            try
            {
                ModsManifest mm = new ModsManifest
                {
                    modID       = mod.ID,
                    version     = mod.Version,
                    description = "<i>No description provided...</i>",
                    sign        = AzjatyckaMatematyka(mod.fileName),
                    type        = 0
                };
                string path = ModLoader.GetMetadataFolder(string.Format("{0}.json", mod.ID));
                if (File.Exists(path))
                {
                    ModConsole.Error("Metadata file already exists");
                    return;
                }
                string serializedData = JsonConvert.SerializeObject(mm, Formatting.Indented);
                File.WriteAllText(path, serializedData);
                ModConsole.Print("<color=green>Raw metadata file created successfully</color>");
            }
            catch (Exception e)
            {
                ModConsole.Error(e.Message);
            }
        }
Exemplo n.º 3
0
        public static void UpdateManifest(Mod mod)
        {
            if (!File.Exists(ModLoader.GetMetadataFolder(string.Format("{0}.json", mod.ID))))
            {
                ModConsole.Error("Metadata file doesn't exists, to create use create command");
                return;
            }
            if (mod.RemMetadata == null)
            {
                ModConsole.Error(string.Format("Your metadata file doesn't seem to be public, you need to upload first before you can update file.{0}If you want to just recreate metadata, delete old file and use create command", Environment.NewLine));
                return;
            }
            string steamID;

            if (ModLoader.CheckSteam())
            {
                steamID = Steamworks.SteamUser.GetSteamID().ToString();
                if (mod.RemMetadata.sid_sign != ModLoader.MurzynskaMatematyka(steamID + mod.ID))
                {
                    ModConsole.Error("This mod doesn't belong to you, can't continue");
                    return;
                }
                try
                {
                    ModsManifest umm = mod.metadata;
                    Version      v1  = new Version(mod.Version);
                    Version      v2  = new Version(mod.metadata.version);
                    switch (v1.CompareTo(v2))
                    {
                    case 0:
                        ModConsole.Error(string.Format("Mod version {0} is same as current metadata version {1}, nothing to update.", mod.Version, mod.metadata.version));
                        break;

                    case 1:
                        umm.version = mod.Version;
                        umm.sign    = AzjatyckaMatematyka(mod.fileName);
                        string msad           = ModLoader.GetMetadataFolder(string.Format("{0}.json", mod.ID));
                        string serializedData = JsonConvert.SerializeObject(umm, Formatting.Indented);
                        File.WriteAllText(msad, serializedData);
                        ModConsole.Print("<color=green>Metadata file updated successfully, you can upload it now!</color>");
                        break;

                    case -1:
                        ModConsole.Error(string.Format("Mod version {0} is <b>earlier</b> than current metadata version {1}, cannot update.", mod.Version, mod.metadata.version));
                        break;
                    }
                }
                catch (Exception e)
                {
                    ModConsole.Error(e.Message);
                    UnityEngine.Debug.Log(e);
                }
            }
            else
            {
                ModConsole.Error("No valid steam detected");
            }
        }
Exemplo n.º 4
0
        public static void CreateManifest(Mod mod)
        {
            string steamID;

            if (ModLoader.CheckSteam())
            {
                try
                {
                    new Version(mod.Version);
                }
                catch
                {
                    ModConsole.Error(string.Format("Invalid version: {0}{1}Please use proper version format: (0.0 or 0.0.0 or 0.0.0.0)", mod.Version, Environment.NewLine));
                    return;
                }
                steamID = Steamworks.SteamUser.GetSteamID().ToString();
                try
                {
                    ModsManifest mm = new ModsManifest
                    {
                        modID       = mod.ID,
                        version     = mod.Version,
                        description = "<i>No description provided...</i>",
                        sign        = AzjatyckaMatematyka(mod.fileName),
                        sid_sign    = ModLoader.MurzynskaMatematyka(steamID + mod.ID),
                        type        = 0
                    };
                    string path = ModLoader.GetMetadataFolder(string.Format("{0}.json", mod.ID));
                    if (File.Exists(path))
                    {
                        ModConsole.Error("Metadata file already exists, to update use update command");
                        return;
                    }
                    string serializedData = JsonConvert.SerializeObject(mm, Formatting.Indented);
                    File.WriteAllText(path, serializedData);
                    ModConsole.Print("<color=green>Raw metadata file created successfully</color>");
                }
                catch (Exception e)
                {
                    ModConsole.Error(e.Message);
                    System.Console.WriteLine(e);
                }
            }
            else
            {
                ModConsole.Error("No valid steam detected");
            }
        }
Exemplo n.º 5
0
        public static void UpdateManifest(Mod mod)
        {
            if (!File.Exists(ModLoader.GetMetadataFolder(string.Format("{0}.json", mod.ID))))
            {
                ModConsole.Error("Metadata file doesn't exists, to create use create command");
            }
            else if (mod.RemMetadata == null)
            {
                ModConsole.Error(string.Format("Your metadata file doesn't seem to be public, you need to upload first before you can update file.{0}If you want to just recreate metadata, delete old file and use create command", Environment.NewLine));
            }
            else if (mod.RemMetadata.sid_sign != ChecksumCalculator(ModLoader.steamID + mod.ID))
            {
                ModConsole.Error("This mod doesn't belong to you, can't continue");
            }
            else
            {
                try
                {
                    ModsManifest metadata = mod.metadata;

                    switch (new Version(mod.Version).CompareTo(new Version(mod.metadata.version)))
                    {
                    case 0:
                        ModConsole.Error(string.Format("Mod version {0} is same as current metadata version {1}, nothing to update.", mod.Version, mod.metadata.version));
                        break;

                    case 1:
                        metadata.version = mod.Version;
                        metadata.sign    = FileHash(mod.fileName);

                        File.WriteAllText(ModLoader.GetMetadataFolder(string.Format("{0}.json", mod.ID)), Newtonsoft.Json.JsonConvert.SerializeObject(metadata, Newtonsoft.Json.Formatting.Indented));

                        ModConsole.Print("<color=green>Metadata file updated successfully, you can upload it now!</color>");
                        break;

                    case -1:
                        ModConsole.Error(string.Format("Mod version {0} is <b>earlier</b> than current metadata version {1}, cannot update.", mod.Version, mod.metadata.version));
                        break;
                    }
                }
                catch (Exception e)
                {
                    ModConsole.Error(e.Message);
                    System.Console.WriteLine(e);
                }
            }
        }