public string GetCommandLineArguments() { string sep = " "; // space after mednafen.exe string baseStr = sep; // Get a Dictionary object with a list of config parameter names, along with the object itself //Dictionary<string, object> cmds = DictionaryFromType(Config); // Create a new List object to hold actual parameters that will be passed to Mednafen List <ConfigKeyValue> activeCmds = new List <ConfigKeyValue>(); foreach (var thing in SysConfigObject) { // Check for Null and Empty values if (thing.Value == null || thing.Value.ToString().Trim() == "") { // null or empty value - continue continue; } // convert all values to strings string v = thing.Value.ToString(); // convert SQL bool values to 0 and 1 strings if (thing.Value.ToString() == "True") { v = "1"; } if (thing.Value.ToString() == "False") { v = "0"; } if (thing.Key == "ConfigId" || thing.Key == "UpdatedTime" || thing.Key == "isEnabled" || thing.Key == "systemIdent" || thing.Key.Contains("__enable")) { // non-mednafen config settings or settings that must be added as a - param } else if (thing.Key.Contains("shared_memcards")) { if (SystemId == 9) { ConfigKeyValue ckvSharedMem = new ConfigKeyValue(); ckvSharedMem.Key = "filesys.fname_sav"; // psx if (v == "1") { ckvSharedMem.Value = "%s.%X"; } else { ckvSharedMem.Value = "%F.%M%x"; } activeCmds.Add(ckvSharedMem); } } else { // convert key to correct mednafen config format string k = thing.Key.Replace("__", "."); // is the parameter illegal (ie. in the list of illegal config parameters) if (IsParameterLegal(k) == false) { // illegal - break out of the loop and continue to next parameter continue; } // add command to activeCmds ConfigKeyValue ckv = new ConfigKeyValue(); ckv.Key = k; ckv.Value = v; activeCmds.Add(ckv); } } // build parameter string foreach (var pair in activeCmds) { baseStr += "-" + pair.Key + sep + Validate(pair.Value) + sep; } // add netplay settings if (Global.enableNetplay == true) { // add -connect switch baseStr += "-connect" + sep; // console font baseStr += "-netplay.console.font " + Validate(Netplay.netplay__console__font) + sep; // console lines baseStr += "-netplay.console.lines " + Validate(Netplay.netplay__console__lines.ToString()) + sep; // console scale baseStr += "-netplay.console.scale " + Validate(Netplay.netplay__console__scale.ToString()) + sep; // localplayers baseStr += "-netplay.localplayers " + Validate(Netplay.netplay__localplayers.ToString()) + sep; // nickname baseStr += "-netplay.nick " + Validate(Netplay.netplay__nick) + sep; // add server settings // host if (Server.netplay__host == null || Server.netplay__host.Trim() == "") { // ignore } else { // host has been set baseStr += "-netplay.host " + Validate(Server.netplay__host) + sep; } // port if (Server.netplay__port == null || Server.netplay__port.ToString().Trim() == "") { // no port set } else { baseStr += "-netplay.port " + Validate(Server.netplay__port.ToString()) + sep; } // add password and gamekey fields from Server row // password if (Server.netplay__password == null || Server.netplay__password.Trim() == "") { // no password set - apply blank baseStr += "-netplay.password \"\"" + sep; } else { baseStr += "-netplay.password " + Validate(Server.netplay__password) + sep; } // gamekey if (Server.netplay__gamekey == null || Server.netplay__gamekey.Trim() == "") { // no gamekey set - set blank baseStr += "-netplay.gamekey \"\"" + sep; } else { baseStr += "-netplay.gamekey " + Validate(Server.netplay__gamekey) + sep; } } /* * // password * baseStr += "-netplay.password " + Server.netplay__password + sep; * // gamekey * baseStr += "-netplay.gamekey " + Server.netplay__gamekey + sep; */ // faust if (SystemId == 16) { // force faust baseStr += "-force_module snes_faust" + sep; } // pce_fast if (SystemId == 17) { // force pce_fast baseStr += "-force_module pce_fast" + sep; } // shared memcard // perform mednafen version check and replace/remove config options that are not viable baseStr = VersionChecker.GetCompatLaunchString(baseStr); // add gamepath to command line baseStr += "\"" + BuildFullGamePath(RomFolder, RomPath) + "\""; //MessageBox.Show(baseStr); return(baseStr); }
public static bool CheckVersions() { // skip this as still testing // return false; string dbPath = @"Data\Settings\MedLaunch.db"; // first check whether the database exists - return if it does not if (!File.Exists(dbPath)) { return(false); } // create System.Data.SQLite connection string connString = "Data Source=" + AppDomain.CurrentDomain.BaseDirectory + dbPath; string dbVersion = ""; string appVersion = VersionChecker.ReturnApplicationVersion(); // connect to database and retreive the current version using (SQLiteConnection conn = new SQLiteConnection(connString)) { StringBuilder query = new StringBuilder(); query.Append("SELECT dbVersion "); query.Append("FROM Versions "); query.Append("WHERE versionId = 1"); using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), conn)) { conn.Open(); using (SQLiteDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { //Console.WriteLine(dr.GetValue(0) + " " + dr.GetValue(1) + " " + dr.GetValue(2)); dbVersion = dr.GetValue(0).ToString(); } } } } // check the two versions string[] dbVersionArr = dbVersion.Split('.'); string[] appVersionArr = appVersion.Split('.'); int i = 0; bool upgradeNeeded = false; while (i < 3) { // if anything but the 4th number (private build) is greater in the appVersion - database needs to be upgraded if (Convert.ToInt32(appVersionArr[i]) > Convert.ToInt32(dbVersionArr[i])) { // database upgrade needed upgradeNeeded = true; break; } i++; } if (upgradeNeeded == false) { return(false); } /* start the DB upgrade procedure */ DoDbUpgrade(); return(false); }
/// <summary> /// Initialises the single instance of logparser /// </summary> public static void Init() { Instance = new VersionChecker(); }