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; } }
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)); }
internal static string recXNB(string SourcePath, string search, SDVMMSettings settings, MainWindow mf, string filepath, string mode, string CheckValue) { Settings = settings; ModStore = mf; spath = filepath; mod = mode; checkValue = CheckValue; var x = Directory.GetFiles(SourcePath, search, SearchOption.AllDirectories).ToList(); return(x.Count == 1 ? System.IO.Path.GetFullPath(x[0]) : checkFile(x.ToArray())); }
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")); } } }
public Browser(string url, MainWindow mf, SDVMMSettings set) { try { Mf = mf; settings = set; bHome = url; string URL = url; HistoryStack = new List <Uri>(); HistoryStack_Index = 0; fromHistory = false; InitializeComponent(); var app_dir = Path.GetDirectoryName(Application.ExecutablePath); Gecko.Xpcom.Initialize(Path.Combine("Firefox")); webBrowser1.Navigate(URL); //webBrowser1.ScriptErrorsSuppressed = true; UpdateNavButtons(); }catch (Exception ex) { MessageBox.Show((ex.ToString())); } }
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); }
internal static void EditVDF(SDVMMSettings Settings) { try { var files = Directory.GetFiles(Path.Combine(Settings.SteamFolder, "userdata"), "localconfig.vdf", SearchOption.AllDirectories).ToArray(); // find game settings int i = 0; for (i = 0; i < files.Length; i++) { // read file var fileText = File.ReadAllText(files[i]); if (fileText == null) { continue; } VdfSerializerSettings ste = new VdfSerializerSettings(); ste.UsesEscapeSequences = true; raw = VdfConvert.Deserialize(fileText, ste); VObject data = (VObject)raw.Value.Software.Valve.Steam.Apps; if (data.ContainsKey("413150")) { game = (VObject)raw.Value.Software.Valve.Steam.Apps["413150"]; break; } } // check fail conditions if (game == null) { MessageBox.Show(MainWindow.Translation.SDVInstalled, "error"); return; } if (game.ContainsKey("LaunchOptions")) { MessageBox.Show(MainWindow.Translation.LaunchOptionExist, "error"); return; } if (File.Exists(Path.Combine(files[i], "localconfig-sdvmm.vdf.bak"))) { MessageBox.Show(MainWindow.Translation.LaunchOptionApplied, "error"); return; } // kill steam foreach (var process in Process.GetProcessesByName("Steam")) { process.Kill(); } // apply launch options if (!File.Exists(Path.Combine(Path.GetDirectoryName(files[i]), "localconfig-sdvmm.vdf.bak"))) { File.Copy(files[i], Path.Combine(Path.GetDirectoryName(files[i]), "localconfig-sdvmm.vdf.bak")); } //VValue launchOptions = new VValue(@String.Join(""," ","\\\"",MainWindow.SDVMMSettings.GameFolder.Replace("\\","\\\\"),"\\\\" ,"StardewModdingAPI.exe","\\\" ", "%command%")); string path = Path.Combine(MainWindow.SDVMMSettings.GameFolder, "StardewModdingAPI.exe").Replace(@"\", @"\\"); VValue launchOptions = new VValue($" \\\"{path}\\\" %command%"); game.Add("LaunchOptions", launchOptions); File.WriteAllText(files[i], raw.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "error"); } }
public ModManager(SDVMMSettings settings, MainWindow nMainForm) { mf = nMainForm; this.Settings = settings; }