Ejemplo n.º 1
0
 public static void DownloadXNBLoader(string url, MainWindow mf)
 {
     //todo download and put into mods folder http://community.playstarbound.com/resources/xnb-loader.4506/download?version=20562
     using (WebClient WC = new WebClient())
     {
         if (System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "xl.zip")))
         {
             System.IO.File.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "xl.zip"));
         }
         WC.Headers.Add("user-agent", "SDVMM/Version: 1.0");
         WC.DownloadFile(url, Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "xl.zip"));
         if (System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked")))
         {
             Directory.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"), true);
         }
         if (!System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked")))
         {
             System.IO.Directory.CreateDirectory(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"));
         }
         zipHandling.extractZip(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "xl.zip"), Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"));
         ModManager mm = new ModManager(MainWindow.SDVMMSettings, mf);
         mm.addMod(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked", "XnbLoader", "XnbLoader.dll"), false, "");
         mm.addMod(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked", "!EntoaroxFramework", "EntoaroxFramework.dll"), false, "");
     }
 }
Ejemplo n.º 2
0
        internal static Translations LoadTranslations(string key, Translations obj)
        {
            try
            {
                string path = Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Translations", $"{key}.json");
                if (!File.Exists(path))
                {
                    return(obj);
                }

                string text = File.ReadAllText(path);
                JsonConvert.PopulateObject(text, obj);
                return(obj);
            }
            catch (Exception ex)
            {
                if (!dMode)
                {
                    MessageBox.Show("Couldn`t load the Translation. Defaulting to English", "Translation Error");
                }
                if (dMode)
                {
                    MessageBox.Show(ex.ToString());
                }
                string path = Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Translations", "en.json");
                if (!File.Exists(path))
                {
                    return(obj);
                }

                string text = File.ReadAllText(path);
                JsonConvert.PopulateObject(text, obj);
                return(obj);
            }
        }
Ejemplo n.º 3
0
        public Setting(SDVMMSettings Settings)
        {
            this.settings = Settings;
            InitializeComponent();
            lang = settings.Language;
            GeneralSettings.Text      = MainWindow.Translation.SettingsCategoryName1;
            ModSettings.Text          = MainWindow.Translation.SettingsCategoryName2;
            SteamSettings.Text        = MainWindow.Translation.SettingsCategoryName3;
            SteamFolder.Text          = MainWindow.Translation.SettingsSteamFolder;
            GameFolder.Text           = MainWindow.Translation.SettingsGameFolder;
            IsGOG.Text                = MainWindow.Translation.isGOG;
            Save.Text                 = MainWindow.Translation.SaveSettings;
            isGogBtn.Text             = MainWindow.Translation.GOGChangeBtn;
            IsGOGBox.Text             = settings.GoGVersion.ToString();
            overwriteButton.Text      = MainWindow.Translation.overWriteGameFiles;
            SetVDF.Text               = MainWindow.Translation.SettingsSetLaunchOptions;
            LanguageLabel.Text        = MainWindow.Translation.Language;
            LanguageBox.DropDownStyle = ComboBoxStyle.DropDownList;
            if (MainWindow.SDVMMSettings.overWrite == true)
            {
                overwriteButton.Checked = true;
            }

            SteamFolderBox.Text = settings.SteamFolder;
            GameFolderBox.Text  = settings.GameFolder;
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                SetVDF.Hide();
            }

            var x = Directory.GetFiles(System.IO.Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Translations"), "*.json", SearchOption.TopDirectoryOnly).ToList();

            foreach (String y in x)
            {
                LanguageBox.Items.Add(System.IO.Path.GetFileNameWithoutExtension(y));
            }

            if (lang != null)
            {
                LanguageBox.SelectedIndex = LanguageBox.FindStringExact(lang);
            }
            else
            {
                LanguageBox.SelectedIndex = LanguageBox.FindStringExact("en");
            }

            if (settings.overWrite == true)
            {
                overwriteButton.CheckState = CheckState.Checked;
            }

            if (MainWindow.SDVMMSettings.Language == null)
            {
                this.TopMost = true;
            }
        }
Ejemplo n.º 4
0
        public static void SaveSettings(SDVMMSettings settings)
        {
            if (!System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM", "SDVMM.json")))
            {
                System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM", "SDVMM.json"));
            }
            string path = Path.Combine(dataDirectory, "SDVMM", "SDVMM.json");

            File.WriteAllText(path, JsonConvert.SerializeObject(settings));
        }
Ejemplo n.º 5
0
        public static void DownloadSMAPI(string url, string gameFolder, string version)
        {
            DialogResult dialogResult = MessageBox.Show(MainWindow.Translation.SMAPIUpdateFound, MainWindow.Translation.UpdateTitle, MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (WebClient WC = new WebClient())
                {
                    string text = "0";
                    try
                    {
                        if (System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Smapi.zip")))
                        {
                            System.IO.File.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Smapi.zip"));
                        }
                        text = "1";
                        WC.Headers.Add("user-agent", "SDVMM/Version: 1.0");
                        WC.DownloadFile(url, Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Smapi.zip"));
                        text = "2";
                        if (System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked")))
                        {
                            Directory.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"), true);
                        }
                        text = "3";
                        if (!System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked")))
                        {
                            System.IO.Directory.CreateDirectory(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"));
                        }
                        text = "4";
                        zipHandling.extractZip(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Smapi.zip"), Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"));
                        var    x    = Directory.GetDirectories(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"));
                        string path = "";
                        text = "5";
                        if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                        {
                            path = Path.Combine(x[0], "internal", "Windows");
                        }
                        else
                        {
                            text = "6";
                            path = Path.Combine(x[0], "internal", "Mono");
                        }
                        text = "7";
                        var source      = new DirectoryInfo(System.IO.Path.GetFullPath(path));
                        var destination = new DirectoryInfo(gameFolder);
                        source.MoveMod(destination);
                        MainWindow.SDVMMSettings.SmapiVersion = version;
                        FileHandler.SaveSettings(MainWindow.SDVMMSettings);
                    }
                    catch {
                        MessageBox.Show(text);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public static void SaveModList(List <ModInfo> Mods)
        {
            // Write to JSON
            if (!System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM", "Mods.json")))
            {
                System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM", "Mods.json"));
            }
            string path = Path.Combine(dataDirectory, "SDVMM", "Mods.json");

            File.WriteAllText(path, JsonConvert.SerializeObject(Mods));
        }
Ejemplo n.º 7
0
        public ChooseLanguage()
        {
            var x = Directory.GetFiles(System.IO.Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Translations"), "*.json", SearchOption.TopDirectoryOnly).ToList();

            this.Build();
            ListStore store = new ListStore(typeof(string));

            foreach (String name in x)
            {
                store.AppendValues(System.IO.Path.GetFileNameWithoutExtension(name));
            }
            combobox1.Model = store;
        }
Ejemplo n.º 8
0
        private void webBrowser1_Navigating(object sender, Gecko.Events.GeckoNavigatingEventArgs e)
        {
            if (!fromHistory)
            {
                if (HistoryStack_Index < HistoryStack.Count)
                {
                    HistoryStack.RemoveRange(HistoryStack_Index, HistoryStack.Count - HistoryStack_Index);
                }
                HistoryStack.Add(e.Uri);
                HistoryStack_Index++;
                UpdateNavButtons();
            }
            fromHistory = false;

            if (e.Uri.Segments[e.Uri.Segments.Length - 1].EndsWith(".zip") || e.Uri.Segments[e.Uri.Segments.Length - 1].EndsWith(".rar"))
            {
                file = "Mod.zip";

                if (e.Uri.Segments[e.Uri.Segments.Length - 1].EndsWith(".rar"))
                {
                    file = "Mod.rar";
                }
                var url = e.Uri;
                e.Cancel = true;
                using (WebClient WC = new WebClient())
                {
                    try
                    {
                        if (System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), file)))
                        {
                            System.IO.File.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), file));
                        }

                        WC.Headers.Add("user-agent", "SDVMM/Version: 1.0");
                        WC.DownloadFileAsync(url, Path.Combine(DirectoryOperations.getFolder("ExeFolder"), file));
                        WC.DownloadFileCompleted += new AsyncCompletedEventHandler(WC_DownloadFileCompleted);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        void WC_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked")))
            {
                Directory.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"), true);
            }

            if (!System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked")))
            {
                System.IO.Directory.CreateDirectory(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unpacked"));
            }

            Mf.ManualRaise = false;
            ModManager mm = new ModManager(settings, Mf);

            mm.addMod(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), file), false, "");
            Mf.RefreshListView();
            Mf.ManualRaise = false;
        }
Ejemplo n.º 10
0
        internal static void SetupEnvironment()
        {
            if (dMode)
            {
                Console.Write("looking for Config of old version if windows...");
            }

            //first of we check if the old non mono version of SDVMM was used
            //if so migrate the ini to the new system
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                if (System.IO.File.Exists(Path.Combine(DirectoryOperations.getFolder("OldAppData"), "SDVMM.ini")))
                {
                    if (!System.IO.Directory.Exists(Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM")))
                    {
                        System.IO.Directory.CreateDirectory(Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM"));
                    }
                    string path = Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM", "SDVMM.json");

                    string language = "en";
                    string oldPath  = Path.Combine(DirectoryOperations.getFolder("OldAppData"), "SDVMM.ini");
                    string GFolder  = iniParsing.INI_ReadValueFromFile("General", "GameFolder", "C:\\", oldPath);
                    string SFolder  = iniParsing.INI_ReadValueFromFile("General", "SteamFolder", "C:\\", oldPath);
                    string GoGV     = iniParsing.INI_ReadValueFromFile("General", "SteamFolder", "C:\\", oldPath);
                    string SVersion = iniParsing.INI_ReadValueFromFile("SMAPI Details", "Version", "C:\\", oldPath);
                    bool   isGOG    = (GoGV == "1");
                    if (!System.IO.File.Exists(path))
                    {
                        DirectoryOperations.CreateFile(path);
                    }

                    var settings = new SDVMMSettings(language, SVersion, GFolder, SFolder, isGOG, false);

                    FileHandler.SaveSettings(settings);
                    System.IO.File.Delete(Path.Combine(DirectoryOperations.getFolder("OldAppData"), "SDVMM.ini"));
                }
            }
        }
Ejemplo n.º 11
0
 internal static string checkFile(string[] array)
 {
     if (checkValue == null)
     {
         checkValue = shaCheck.GetHashCode(array[0], new MD5CryptoServiceProvider());
     }
     for (int i = 1; i < array.Length; i++)
     {
         if (checkValue != shaCheck.GetHashCode(array[i], new MD5CryptoServiceProvider()))
         {
             return("");
         }
     }
     for (int x = 0; x < array.Length; x++)
     {
         if (mod == "add")
         {
             ModManager mm = new ModManager(Settings, ModStore);
             mm.addMod(spath, true, array[x]);
         }
         else
         {
             ModManager mm = new ModManager(Settings, ModStore);
             mm.removeMod(array[x]);
             if (Settings.overWrite == true)
             {
                 File.Copy(array[x].Replace(Path.Combine(MainWindow.SDVMMSettings.GameFolder, "Content"), Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Backup")), array[x]);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 12
0
        private static SDVMMSettings CreateDefaultSettings()
        {
            var    settings       = new SDVMMSettings("", "", "", "", false, false);
            string defaultSPath   = "";
            string defaultGogPath = "";
            string userpath       = DirectoryOperations.getFolder("User");

            //search for attached drives

            // TODO Find Steam Path. Only does game path

            //find out which OS SDVMM is running on and based on guess the paths
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                DriveInfo[] allDrives = DriveInfo.GetDrives();
                foreach (DriveInfo d in allDrives)
                {
                    //check if the drive is a HDD
                    if (d.DriveType == DriveType.Fixed)
                    {
                        if (System.IO.File.Exists(Path.Combine(d.Name, "Program Files (x86)", "Steam", "Steam.exe")))
                        {
                            settings.SteamFolder = Path.Combine(d.Name, "Program Files (x86)", "Steam");
                        }
                        defaultSPath   = Path.Combine(d.Name, "Program Files (x86)", "Steam", "steamapps", "common", "Stardew Valley");
                        defaultGogPath = Path.Combine(d.Name, "Program Files (x86)", "GalaxyClient", "Games", "Stardew Valley");
                        //if the registry entries exist take them instead.
                        if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\GOG.com\\Games\\1453375253", "Path", null) != null)
                        {
                            defaultGogPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\GOG.com\\Games\\1453375253", "Path", null).ToString();
                        }
                        if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 413150", "InstallLocation", null) != null)
                        {
                            defaultSPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 413150", "InstallLocation", null).ToString();
                        }
                        if (System.IO.Directory.Exists(defaultSPath) || System.IO.Directory.Exists(defaultGogPath))
                        {
                            if (System.IO.Directory.Exists(defaultSPath))
                            {
                                settings.GameFolder = defaultSPath;
                            }
                            else
                            {
                                settings.GameFolder  = defaultGogPath;
                                settings.SteamFolder = DirectoryOperations.getFolder("AppData");
                                settings.GoGVersion  = true;
                            }
                            break;
                        }
                    }
                }
            }
            if (Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                if (System.IO.Directory.Exists(Path.Combine(userpath, "Library", "Application Support", "Steam")))
                {
                    settings.SteamFolder = Path.Combine(userpath, "Library", "Application Support", "Steam");
                }
                defaultSPath   = Path.Combine(userpath, "Library", "Application Support", "Steam", "steamapps", "common", "Stardew Valley", "Contents", "MacOS");
                defaultGogPath = Path.Combine("Applications", "Stardew Valley.app", "Contents", "MacOS");
            }
            OperatingSystem os = Environment.OSVersion;

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                if (IsRunningOnMac())
                {
                    if (System.IO.Directory.Exists(Path.Combine(userpath, "Library", "Application Support", "Steam")))
                    {
                        settings.SteamFolder = Path.Combine(userpath, "Library", "Application Support", "Steam");
                    }
                    defaultSPath   = Path.Combine(userpath, "Library", "Application Support", "Steam", "steamapps", "common", "Stardew Valley", "Contents", "MacOS");
                    defaultGogPath = Path.Combine("Applications", "Stardew Valley.app", "Contents", "MacOS");
                }
                else
                {
                    if (System.IO.Directory.Exists(Path.Combine(userpath, ".local", "share", "Steam")))
                    {
                        settings.SteamFolder = Path.Combine(userpath, ".local", "share", "Steam");
                    }

                    defaultGogPath = Path.Combine(userpath, "Games", "Stardew Valley", "game");
                    defaultSPath   = Path.Combine(userpath, ".steam", "steam", "steamapps", "common", "Stardew Valley");
                }
                if (System.IO.Directory.Exists(defaultSPath) || System.IO.Directory.Exists(defaultGogPath))
                {
                    if (System.IO.Directory.Exists(defaultSPath))
                    {
                        settings.GameFolder = defaultSPath;
                    }
                    else
                    {
                        settings.GameFolder  = defaultGogPath;
                        settings.SteamFolder = DirectoryOperations.getFolder("AppData");
                        settings.GoGVersion  = true;
                    }
                }
            }
            settings.SmapiVersion = getSMAPIVersion(settings.GameFolder);
            settings.Language     = null;
            FileHandler.SaveSettings(settings);
            return(settings);
        }
Ejemplo n.º 13
0
        internal void addMod(string path, bool skipRec, string recdestPath)
        {
            try
            {
                string destFolder = "";
                if ((System.IO.Path.GetFileName(path).Contains(".zip") || System.IO.Path.GetFileName(path).Contains(".7z") || System.IO.Path.GetFileName(path).Contains(".rar")))
                {
                    string oldPath = path;
                    if (Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped")))
                    {
                        System.IO.Directory.Delete(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped"), true);
                    }
                    if (!Directory.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped")))
                    {
                        System.IO.Directory.CreateDirectory(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped"));
                    }
                    zipHandling.extractZip(path, Path.Combine(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped")));
                    var x = Directory.GetFiles(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped"), "*.dll", SearchOption.AllDirectories).ToList();
                    if (x.Count > 0)
                    {
                        path = x[0];
                    }
                    if (x.Count == 0)
                    {
                        x = Directory.GetFiles(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped"), "*.json", SearchOption.AllDirectories).ToList();
                    }
                    if (x.Count > 0)
                    {
                        path = x[0];
                    }
                    if (oldPath == path)
                    {
                        x = Directory.GetFiles(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "unzipped"), "*.xnb", SearchOption.AllDirectories).ToList();
                        if (x.Count > 0)
                        {
                            foreach (String s in x)
                            {
                                addMod(s, false, "");
                            }
                        }
                    }
                }
                if (System.IO.Path.GetFileName(path).Contains(".xnb"))
                {
                    string destPath = "";
                    string orgpath  = "";
                    if (skipRec == false)
                    {
                        destPath = recSearchForXNB.recXNB(System.IO.Path.Combine(Settings.GameFolder, "Content"), System.IO.Path.GetFileName(path), Settings, mf, path, "add", null);
                        orgpath  = destPath;
                    }
                    else
                    {
                        destPath = recdestPath;
                        orgpath  = path;
                    }

                    if (destPath != "" & Settings.overWrite == false & destPath != null)
                    {
                        string bpath = destPath;
                        destPath = destPath.Replace(Path.Combine(Settings.GameFolder, "Content"), Path.Combine(Settings.GameFolder, "Mods", "XNBLoader", "content"));
                        if (File.Exists(destPath))
                        {
                            File.Delete(destPath);
                        }


                        if (skipRec == true)
                        {
                            File.Copy(orgpath, destPath);
                        }
                        else
                        {
                            File.Move(orgpath, destPath);
                        }

                        //Directory.Delete(System.IO.Path.GetFullPath(path), true);
                        ModInfo newMod = new ModInfo(
                            name: System.IO.Path.GetFileNameWithoutExtension(path),
                            author: "Unknown",
                            version: "0.0",
                            filePath: destPath,
                            uid: shaCheck.GetHashCode(orgpath, new MD5CryptoServiceProvider()),
                            MiniApiVersion: "0.0",
                            Desc: "-",
                            entry: "-",
                            IsA: true,
                            IsX: true,
                            OrgXP: orgpath,
                            IsAll: false,
                            Key: null);
                        ModInfo modLookingFor = Mods.Find(x => x.UniqueID == newMod.UniqueID);
                        if (modLookingFor == null)
                        {
                            Mods.Add(newMod);
                            addToTree(newMod, mf);
                            FileHandler.SaveModList(Mods);
                        }
                    }
                    if (destPath != "" & Settings.overWrite == true & destPath != null)
                    {
                        if (!Directory.Exists(System.IO.Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Backup")))
                        {
                            Directory.CreateDirectory(System.IO.Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Backup"));
                        }
                        if (!File.Exists(Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Backup", "Minigames")))
                        {
                            var folder      = new DirectoryInfo(Path.Combine(MainWindow.SDVMMSettings.GameFolder, "content")).EnumerateDirectories("*.*", SearchOption.AllDirectories);
                            var folderarray = folder.ToArray();
                            for (int i = 0; i < folderarray.Length; i++)
                            {
                                string dir = Path.Combine(folderarray[i].FullName.Replace(Path.Combine(MainWindow.SDVMMSettings.GameFolder, "content"), Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Backup")));
                                Directory.CreateDirectory(dir);
                            }
                        }

                        var backupFolder = destPath.Replace(Path.Combine(MainWindow.SDVMMSettings.GameFolder, "Content"), Path.Combine(DirectoryOperations.getFolder("ExeFolder"), "Backup"));
                        if (!File.Exists(backupFolder))
                        {
                            File.Copy(destPath, backupFolder.ToString());
                        }
                        orgpath = destPath;
                        if (skipRec == true)
                        {
                            File.Copy(path, destPath, true);
                        }
                        else
                        {
                            File.Move(path, destPath);
                        }
                        //Directory.Delete(System.IO.Path.GetFullPath(path), true);

                        ModInfo newMod = new ModInfo(
                            name: System.IO.Path.GetFileNameWithoutExtension(path),
                            author: "Unknown",
                            version: "0.0",
                            filePath: destPath,
                            uid: shaCheck.GetHashCode(orgpath, new MD5CryptoServiceProvider()),
                            MiniApiVersion: "0.0",
                            Desc: "-",
                            entry: "-",
                            IsA: true,
                            IsX: true,
                            OrgXP: orgpath,
                            IsAll: false,
                            Key: null);
                        ModInfo modLookingFor = Mods.Find(x => x.UniqueID == newMod.UniqueID);
                        if (modLookingFor == null)
                        {
                            Mods.Add(newMod);
                            addToTree(newMod, mf);
                            FileHandler.SaveModList(Mods);
                        }
                    }
                    else
                    {
                        if (destPath != null & skipRec == false)
                        {
                            string folder = "";

                            OpenFileDialog filechooser = new OpenFileDialog();
                            filechooser.Filter = String.Join("", MainWindow.Translation.FCXNBTitle, "|*.xnb");
                            filechooser.Title  = MainWindow.Translation.FCTitle;
                            if (filechooser.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                folder = filechooser.FileName;
                                addMod(folder, false, "");
                            }
                        }
                    }
                }
                else
                {
                    string  pathwo        = System.IO.Path.GetDirectoryName(path);
                    string  mpath         = Path.Combine(pathwo, "manifest.json");
                    ModInfo modLookingFor = null;
                    ModInfo newMod        = null;
                    dynamic Manifest;
                    Manifest = FileHandler.LoadModManifest(mpath);
                    string uId     = "";
                    string version = "";
                    if (Manifest == null || Manifest.Name == null)
                    {
                        Manifest = FileHandler.LoadALLManifest(mpath);
                        try
                        {
                            uId     = String.Join(Manifest.About.ModName, Manifest.About.Author);
                            version = Manifest.About.Version;
                            newMod  = new ModInfo(Manifest.About.ModName, Manifest.About.Author, version, System.IO.Path.GetDirectoryName(path), uId, "", Manifest.About.Description, "", true, false /*isX*/, "OrgXP", true, null);
                        }
                        catch (Exception)
                        {
                            ModType mt = new ModType(mf);
                            mt.ShowDialog(mf);
                            if (mf.dpath != null)
                            {
                                string dirPath = Path.GetDirectoryName(path);
                                var    dirName = new DirectoryInfo(dirPath).Name;
                                destFolder = Path.Combine(mf.dpath, dirName);
                                if (destFolder.Contains("CustomFarming"))
                                {
                                    if (!Directory.Exists(Path.Combine(Settings.GameFolder, "Mods", "CustomFarming")))
                                    {
                                        MessageBox.Show("Custom Farming doesnt seem to be installed. Please install it first");
                                        return;
                                    }
                                    uId     = String.Join("", "CustomFarming-", dirName);
                                    version = "1.0";
                                    newMod  = new ModInfo(dirName, "CustomFarming", "1.0", System.IO.Path.GetDirectoryName(path), String.Join("", "CustomFarming-", Path.GetFileNameWithoutExtension(path)), "", "", Path.GetFileNameWithoutExtension(path), true, false /*isX*/, "OrgXP", false, null);
                                }
                                else
                                {
                                    if (!Directory.Exists(Path.Combine(Settings.GameFolder, "Mods", "CustomCritters")))
                                    {
                                        MessageBox.Show("Custom Critters doesnt seem to be installed. Please install it first");
                                        return;
                                    }
                                    uId     = String.Join("", "CustomCritter-", dirName);
                                    version = "1.0";
                                    newMod  = new ModInfo(dirName, "CustomCritter", "1.0", System.IO.Path.GetDirectoryName(path), String.Join("", "CustomCritter-", Path.GetFileNameWithoutExtension(path)), "", "", Path.GetFileNameWithoutExtension(path), true, false /*isX*/, "OrgXP", false, null);
                                }
                            }
                        }
                    }
                    else
                    {
                        uId     = Manifest.UniqueID;
                        version = Manifest.Version;
                        if (Manifest.UpdateKeys != null)
                        {
                            newMod = new ModInfo(Manifest.Name, Manifest.Author, version, System.IO.Path.GetDirectoryName(path), uId, Manifest.MinimumApiVersion, Manifest.Description, Manifest.EntryDll, true, false /*isX*/, "OrgXP", false, Manifest.UpdateKeys);
                        }
                        else
                        {
                            newMod = new ModInfo(Manifest.Name, Manifest.Author, version, System.IO.Path.GetDirectoryName(path), uId, Manifest.MinimumApiVersion, Manifest.Description, Manifest.EntryDll, true, false /*isX*/, "OrgXP", false, null);
                        }
                    }
                    modLookingFor = Mods.Find(x => x.UniqueID == uId);
                    if (modLookingFor != null)
                    {
                        var mod = Mods.Where(d => d.Version != version).FirstOrDefault();
                        if (mod != null)
                        {
                            mod.Version = version;
                        }
                    }
                    else
                    {
                        Mods.Add(newMod);
                        addToTree(newMod, mf);
                    }
                    DirectoryInfo source = new DirectoryInfo(System.IO.Path.GetDirectoryName(path));
                    if (newMod.IsALL)
                    {
                        string dirPath = Path.GetDirectoryName(path);
                        var    dirName = new DirectoryInfo(dirPath).Name;
                        destFolder = System.IO.Path.Combine(Settings.GameFolder, "Mods", "AdvancedLocationLoader", "locations", dirName);
                    }
                    else
                    {
                        if (newMod.EntryDll == "EntoaroxFramework.dll")
                        {
                            destFolder = System.IO.Path.Combine(Settings.GameFolder, "Mods", "!EntoaroxFramework");
                        }
                        else
                        {
                            if (destFolder == "")
                            {
                                destFolder = System.IO.Path.Combine(Settings.GameFolder, "Mods", Path.GetFileNameWithoutExtension(path));
                            }
                        }
                    }
                    var destination = new DirectoryInfo(destFolder);
                    source.MoveMod(destination);
                    FileHandler.SaveModList(Mods);
                    //Directory.Delete(System.IO.Path.GetFullPath(path), true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            Mods = FileHandler.LoadModList();
        }
Ejemplo n.º 14
0
 protected void OnOpenSDVMMFolderClicked(object sender, EventArgs e)
 {
     Process.Start(DirectoryOperations.getFolder("ExeFolder"));
 }
Ejemplo n.º 15
0
 protected void OnOpenAppDataFolderClicked(object sender, EventArgs e)
 {
     Process.Start(System.IO.Path.Combine(DirectoryOperations.getFolder("AppData"), "SDVMM"));
 }