public static string getVersionURL(string modname)
 {
     if (ModManager.modInstalled(modname))
     {
         Classes.Mod m = ModManager.getMod(modname);
         if (m.hasUpdateURL)
         {
             return(m.updateURL);
         }
     }
     return("");
 }
Ejemplo n.º 2
0
 public static void regsiterMod(string modName, Version modVersion, string modFolder, string modUpdateURL)
 {
     Classes.Mod m = new Classes.Mod(modName, modVersion, modFolder, modUpdateURL);
     ModList.Add(modName, m);
 }
Ejemplo n.º 3
0
 public static void regsiterMod(string modName, Version modVersion)
 {
     Classes.Mod m = new Classes.Mod(modName, modVersion);
     ModList.Add(modName, m);
 }
Ejemplo n.º 4
0
        public InstallModernMod(string _modFilePath)
        {
            InitializeComponent();
            ModFilePath = _modFilePath;
            try
            {
                if (File.Exists("temp"))
                {
                    File.Delete("temp");
                }
                using (var zipfile = ZipFile.Open(_modFilePath, ZipArchiveMode.Read))
                {
                    zipfile.Entries.Where(f => f.Name == "mcmod.info").First().ExtractToFile("temp");
                }
                Classes.Mod temp = Classes.Utilities.GetModFromJson(File.ReadAllText("temp"));
                foreach (PropertyInfo propertyInfo in temp.GetType().GetProperties().Where(a => a.PropertyType == typeof(string)))
                {
                    try
                    {
                        if (propertyInfo.GetValue(temp).ToString() == string.Empty)
                        {
                            propertyInfo.SetValue(temp, null);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                try
                {
                    if (temp.logoFile != null)
                    {
                        System.Drawing.Image image = null;
                        using (var zipfile = ZipFile.Open(_modFilePath, ZipArchiveMode.Read))
                        {
                            image = System.Drawing.Image.FromStream(zipfile.Entries.Where(f => f.Name.Contains(System.IO.Path.GetFileName(temp.logoFile))).First().Open());
                        }
                        MemoryStream ms = new MemoryStream();
                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        BitmapImage bImg = new BitmapImage();
                        bImg.BeginInit();
                        bImg.StreamSource = new MemoryStream(ms.ToArray());
                        bImg.EndInit();
                        bImg.Freeze();
                        Dispatcher.Invoke(() => temp.logo = bImg);
                    }
                    else
                    {
                        Dispatcher.Invoke(() => temp.logo = new BitmapImage(new Uri("/Assets/default.png", UriKind.Relative)));
                    }
                }
                catch (Exception)
                {
                }
                this.DataContext = temp;
            }
            catch
            {
            }
        }