public GameSetupPanel(AppManager Manager, DialogsHelpers DialogsHelpers, Game GameData) : base(Manager, DialogsHelpers, GameData) { InitializeComponent(); InitializePanel(); }
public GameInfoPanel(AppManager Manager, DialogsHelpers DialogsHelpers, Game GameData, Dictionary<String, Category> Cats) : base(Manager,DialogsHelpers,GameData) { InitializeComponent(); _cats = Cats; InitializePanel(); }
public GamePanelBase(AppManager Manager, DialogsHelpers DialogsHelpers, Game GameData) { InitializeComponent(); _manager = Manager; _settings = _manager.AppSettings; _translator = _manager.Translator; _dialogsHelpers = DialogsHelpers; _game = GameData; }
public GameDialog(AppManager Manager, Game GameData, bool isEditing) { InitializeComponent(); _manager = Manager; _game = (Game)GameData.Clone(); _dialogsHelpers = new DialogsHelpers(); _manager.Translator.TranslateUI(_manager.AppSettings.Language, this.Name, this.Controls); _cats = _manager.DB.GetAllCategories(); LoadPanel(1); }
public bool SaveGame(Game game) { try { if (_Connection.State != System.Data.ConnectionState.Open) //I raise an error as there is no connection to the database throw new Exception("There is no connection to the database"); String sql; if (game.ID != 0) { //Edit sql = String.Format("UPDATE Games SET " + "category_id = {0}, title = '{1}', year = {2}, developer = '{3}', setup_exe_path = '{4}', " + "directory = '{5}', db_config_path = '{6}', dos_exe_path = '{7}', cd_path = '{8}', cd_image = {9}, " + "use_IOCTL = {10}, mount_as_floppy = {11}, additional_commands = '{12}', no_config = {13}, " + "in_full_screen = {14}, no_console = {15}, quit_on_exit = {16}, image_path = '{17}', created_at = '{18}', " + "platform = '{20}', released_in = '{21}', publisher = '{22}', themes = '{23}', perspectives = '{24}', " + "dosbox_version = '{25}', vote = '{26}', description = '{27}' " + "WHERE id = {19};", game.CategoryID, game.Title.Replace("'", "''"), game.Year, game.Developer.Replace("'", "''"), game.SetupExePath.Replace("'", "''"), game.Directory.Replace("'", "''"), game.DBConfigPath.Replace("'", "''"), game.DOSExePath.Replace("'", "''"), game.CDPath.Replace("'", "''"), BoolToInt(game.IsCDImage), BoolToInt(game.UseIOCTL), BoolToInt(game.MountAsFloppy), game.AdditionalCommands.Replace("'", "''"), BoolToInt(game.NoConfig), BoolToInt(game.InFullScreen), BoolToInt(game.NoConsole), BoolToInt(game.QuitOnExit), game.ImagePath.Replace("'", "''"), DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), game.ID, game.Platform.Replace("'", "''"), game.ReleasedIn.Replace("'", "''"), game.Publisher.Replace("'", "''"), game.Themes.Replace("'", "''"), game.Perspectives.Replace("'", "''"), game.DosboxVersion.Replace("'", "''"), game.Vote.Replace("'", "''"), game.Description.Replace("'", "''")); } else { //Add sql = String.Format("INSERT INTO Games (category_id, title, year, developer, setup_exe_path, " + "directory, db_config_path, dos_exe_path, cd_path, cd_image, " + "use_IOCTL, mount_as_floppy, additional_commands, no_config, " + "in_full_screen, no_console, quit_on_exit, image_path, created_at, " + "platform, released_in, publisher, themes, perspectives, dosbox_version, " + "vote, description) " + "VALUES ({0}, '{1}', {2}, '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', " + "{9}, {10}, {11}, '{12}', {13}, {14}, {15}, {16}, '{17}', '{18}', " + "'{19}', '{20}', '{21}', '{22}', '{23}', '{24}', '{25}', '{26}');", game.CategoryID, game.Title.Replace("'", "''"), game.Year, game.Developer.Replace("'", "''"), game.SetupExePath.Replace("'", "''"), game.Directory.Replace("'", "''"), game.DBConfigPath.Replace("'", "''"), game.DOSExePath.Replace("'", "''"), game.CDPath.Replace("'", "''"), BoolToInt(game.IsCDImage), BoolToInt(game.UseIOCTL), BoolToInt(game.MountAsFloppy), game.AdditionalCommands.Replace("'", "''"), BoolToInt(game.NoConfig), BoolToInt(game.InFullScreen), BoolToInt(game.NoConsole), BoolToInt(game.QuitOnExit), game.ImagePath.Replace("'", "''"), DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), game.Platform.Replace("'", "''"), game.ReleasedIn.Replace("'", "''"), game.Publisher.Replace("'", "''"), game.Themes.Replace("'", "''"), game.Perspectives.Replace("'", "''"), game.DosboxVersion.Replace("'", "''"), game.Vote.Replace("'", "''"), game.Description.Replace("'", "''")); } SQLiteCommand command = new SQLiteCommand(sql, _Connection); command.ExecuteNonQuery(); return true; } catch (Exception) { return false; } }
private void OpenGameDialog(Game game, bool isEditing) { GameDialog gameDialog = new GameDialog(_manager, game, isEditing); if (gameDialog.ShowDialog() != DialogResult.OK) return; game = gameDialog.GameData; if (game == null) return; //First I check if there are new categories to be added Dictionary<String, Category> cats = gameDialog.Cats; foreach (Category cat in cats.Values) { if (cat.ID == -1) { int catID = _manager.DB.AddCategory(cat.Name, string.Empty); if (catID > 0) { game.CategoryID = catID; } } } //I check the game cover path. If it is the temporary path used when loading screenshots from MyAbandonware // then I copy it inside the game path and I remove the temporary one. if (game.ImagePath == Application.StartupPath + "\\tmp.img") { string newCoverPath = string.Empty; if (game.Directory != string.Empty) { newCoverPath = game.Directory + string.Format("\\{0}.jpg",GetHDFineFileName(game.Title)); } else if (game.DOSExePath != string.Empty) { newCoverPath = _manager.FileHelper.ExtractFilePath(game.DOSExePath) + string.Format("\\{0}.jpg", GetHDFineFileName(game.Title)); } if (newCoverPath != string.Empty) { newCoverPath = GetOverwriteSafeFileName(newCoverPath, 0); File.Copy(game.ImagePath, newCoverPath, true); } game.ImagePath = newCoverPath; } //Now I save the game if (_manager.DB.SaveGame(game)) { RefreshCategories(); UpdateStatusBar(); LoadCategoryGames(_SelectedCategory); } else { CustomMessageBox customMessageBox = new CustomMessageBox(_manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 24, "An issue raised while saving the game."), _manager.Translator.GetTranslatedMessage(_manager.AppSettings.Language, 28, "Error"), MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); customMessageBox.ShowDialog(); customMessageBox.Dispose(); } }
public String BuildArgs(bool Setup, Game game, Settings settings) { //Arguments string for DOSBox.exe String Arguments = String.Empty; if (settings.DosboxPath != String.Empty && settings.DosboxPath != "dosbox.exe isn't in the same directory as DosBoxManager.exe!" && File.Exists(settings.DosboxPath)) { String qt = char.ToString('"'); if (game.Directory[0] != '/') qt = "'"; //string for the Game's configuration file. String DBCfgPath = String.Empty; //if the "do not use any config file at all" has not been checked if (game.NoConfig == false) { //use at first the game's custom config file if (game.DBConfigPath != String.Empty) DBCfgPath = game.DBConfigPath; //if not, use the default dosbox.conf file else if (settings.DosboxDefaultConfFilePath != String.Empty && settings.DosboxDefaultConfFilePath != "No configuration file (*.conf) found in DosBoxManager's directory.") DBCfgPath = settings.DosboxDefaultConfFilePath; } //The arguments for DOSBox begins with the game executable (.exe, .bat, or .com) if (game.DOSExePath != String.Empty) { if (!Setup) Arguments = '"' + game.DOSExePath + '"'; else Arguments = '"' + game.DOSExePath + '"'; } //the game directory mounted as C (if the DOSEXEPath is specified, the DOSEXEPath parent directory will be mounted as C: by DOSBox //hence the "else if" instead of "if". else if (game.Directory != String.Empty) Arguments = " -c " + '"' + "mount c " + qt + game.Directory + qt + '"'; //puting DBCfgPath and Arguments together if (DBCfgPath != String.Empty) Arguments = Arguments + " -conf " + '"' + DBCfgPath + '"'; //Path for the default language file used for DOSBox and specified by the user in the Tools menu if (settings.DosboxDefaultLangFilePath != String.Empty && settings.DosboxDefaultLangFilePath != "No language file (*.lng) found in DosBoxManager's directory.") Arguments = Arguments + " -lang " + '"' + settings.DosboxDefaultLangFilePath + '"'; //Path for the game's CD image (.bin, .cue, or .iso) mounted as D: if (game.CDPath != String.Empty) { //put ' and _not_ " after imgmount (or else the path will be misunderstood by DOSBox). Paths with spaces will NOT work either way on GNU/Linux! if (game.IsCDImage == true) { Arguments = Arguments + " -c " + '"' + "imgmount"; if (game.MountAsFloppy == true) Arguments = Arguments + " a " + qt + game.CDPath + qt + " -t floppy" + '"'; else Arguments = Arguments + " d " + qt + game.CDPath + qt + " -t iso" + '"'; } else { if (game.UseIOCTL == true) Arguments = Arguments + " -c " + '"' + "mount d " + qt + game.CDPath + qt + " -t cdrom -usecd 0 -ioctl" + '"'; else if (game.MountAsFloppy == true) Arguments = Arguments + " -c " + '"' + "mount a " + qt + game.CDPath + qt + " -t floppy" + '"'; else Arguments = Arguments + " -c " + '"' + "mount d " + qt + game.CDPath + qt; } } //Additionnal user commands for the game if (game.AdditionalCommands != String.Empty) Arguments = Arguments + " " + game.AdditionalCommands; //corresponds to the Fullscreen checkbox in GameForm if (game.InFullScreen == true) Arguments = Arguments + " -fullscreen"; //corresponds to the "no console" checkbox in the GameForm if (game.NoConsole == true) Arguments = Arguments + " -noconsole"; //corresponds to the "quit on exit (only for .exe)" checkbox in the GameForm if (game.QuitOnExit == true) Arguments = Arguments + " -exit"; return Arguments; } else { return null; } }
public bool MakeGamesConfiguration(TranslationsHelpers translator, Settings settings, Game game) { string body; string title; CustomMessageBox cmb; if (game != null && settings.DosboxDefaultConfFilePath != String.Empty) { if(File.Exists(settings.DosboxDefaultConfFilePath)){ body = "'" + game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath) + "' " + translator.GetTranslatedMessage(settings.Language, 64, "already exists, do you want to overwrite it ?"); title = translator.GetTranslatedMessage(settings.Language, 8, "Attention"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.YesNo, MessageBoxDialogIcon.Question, false, false); if ((!File.Exists(game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath))) || (cmb.ShowDialog() == DialogResult.Yes)) { if (Directory.Exists(game.Directory)) { File.Copy(settings.DosboxDefaultConfFilePath, game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath), true); game.DBConfigPath = game.Directory + "/" + Path.GetFileName(settings.DosboxDefaultConfFilePath); body = translator.GetTranslatedMessage(settings.Language, 65, "The configuration file has been created correctly."); title = translator.GetTranslatedMessage(settings.Language, 66, "Success"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Information, false, false); cmb.ShowDialog(); cmb.Dispose(); return true; } else { body = translator.GetTranslatedMessage(settings.Language, 67, "The path to the selected game seems missing, please check and eventually modify the game folder location to continue."); title = translator.GetTranslatedMessage(settings.Language, 28, "Error"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return false; } } else { return false; } } else { body = translator.GetTranslatedMessage(settings.Language, 68, "The path to the given DosBox configuration file seems missing, please check and eventually modify the DosBox configuration file location to continue."); title = translator.GetTranslatedMessage(settings.Language, 28, "Error"); cmb = new CustomMessageBox(body, title, MessageBoxDialogButtons.Ok, MessageBoxDialogIcon.Error, false, false); cmb.ShowDialog(); cmb.Dispose(); return false; } } return false; }