From ff5c9a279950ed249697b156405ed4b4c64a71e7 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Wed, 15 Feb 2012 00:43:21 +0000 Subject: [PATCH] refactor movie convert into movie import. Currently this breaks movie conversion, as the main convert function now needs implementation --- .../BizHawk.MultiClient.csproj | 2 +- BizHawk.MultiClient/MainForm.cs | 36 ++-------------- .../movie/{MovieConvert.cs => MovieImport.cs} | 41 +++++++++++++------ 3 files changed, 32 insertions(+), 47 deletions(-) rename BizHawk.MultiClient/movie/{MovieConvert.cs => MovieImport.cs} (89%) diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 49abc665c9..add72c303f 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -198,8 +198,8 @@ EditSubtitlesForm.cs - + diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index d980a618da..209b8ee5ed 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -755,48 +755,18 @@ namespace BizHawk.MultiClient RamWatch1.LoadWatchFile(filePaths[0], false); RamWatch1.DisplayWatchList(); } - else if (Path.GetExtension(filePaths[0]).ToUpper() == ".FCM") - { - LoadRom(CurrentlyOpenRom); - string error = ""; - Movie m = MovieConvert.ConvertFCM(filePaths[0], out error); - if (error.Length > 0) - MessageBox.Show(error, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); - else - StartNewMovie(m, false); - } - else if (Path.GetExtension(filePaths[0]).ToUpper() == ".SMV") + else if (MovieImport.IsValidMovieExtension(Path.GetExtension(filePaths[0]))) { LoadRom(CurrentlyOpenRom); string error = ""; - Movie m = MovieConvert.ConvertSMV(filePaths[0], out error); + Movie m = MovieImport.ImportFile(filePaths[0], out error); if (error.Length > 0) MessageBox.Show(error, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); else StartNewMovie(m, false); + } - } - else if (Path.GetExtension(filePaths[0]).ToUpper() == ".MMV") - { - LoadRom(CurrentlyOpenRom); - string error = ""; - Movie m = MovieConvert.ConvertMMV(filePaths[0], out error); - if (error.Length > 0) - MessageBox.Show(error, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); - else - StartNewMovie(m, false); - } - else if (Path.GetExtension(filePaths[0]).ToUpper() == ".VBM") - { - LoadRom(CurrentlyOpenRom); - string error = ""; - Movie m = MovieConvert.ConvertVBM(filePaths[0], out error); - if (error.Length > 0) - MessageBox.Show(error, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); - else - StartNewMovie(m, false); - } else LoadRom(filePaths[0]); } diff --git a/BizHawk.MultiClient/movie/MovieConvert.cs b/BizHawk.MultiClient/movie/MovieImport.cs similarity index 89% rename from BizHawk.MultiClient/movie/MovieConvert.cs rename to BizHawk.MultiClient/movie/MovieImport.cs index df90b87fda..25ef866f69 100644 --- a/BizHawk.MultiClient/movie/MovieConvert.cs +++ b/BizHawk.MultiClient/movie/MovieImport.cs @@ -8,9 +8,24 @@ using System.IO; namespace BizHawk.MultiClient { - public static class MovieConvert + public static class MovieImport { - public static Movie ConvertFCM(string path, out string errorMsg) + public static Movie ImportFile(string path, out string errorMsg) + { + //TODO: This function will receive a file, parse the file extension, + //then decide which import function to call, call it, and return a movie object + //the multiclient should only call this and not the import members (make them private) + errorMsg = ""; + return new Movie(); + } + + public static bool IsValidMovieExtension(string extension) + { + //TODO: This function will receive, parse the extension and decide if it is a movie type that it can parse + return true; + } + + private static Movie ImportFCM(string path, out string errorMsg) { errorMsg = ""; @@ -132,7 +147,7 @@ namespace BizHawk.MultiClient } } - public static Movie ConvertMMV(string path, out string errorMsg) + private static Movie ImportMMV(string path, out string errorMsg) { errorMsg = ""; Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY); @@ -258,14 +273,14 @@ namespace BizHawk.MultiClient return m; } - public static string ConvertMCM(string path) + private static string ImportMCM(string path) { string converted = Path.ChangeExtension(path, ".tas"); return converted; } - public static Movie ConvertSMV(string path, out string errorMSG) + private static Movie ImportSMV(string path, out string errorMSG) { errorMSG = ""; FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); @@ -286,11 +301,11 @@ namespace BizHawk.MultiClient switch (version) { case 1: - return ConvertSMV143(r, path); + return ImportSMV143(r, path); case 4: - return ConvertSMV151(r, path); + return ImportSMV151(r, path); case 5: - return ConvertSMV152(r, path); + return ImportSMV152(r, path); default: { errorMSG = "SMV version not recognized, 143, 151, and 152 are currently supported"; @@ -299,7 +314,7 @@ namespace BizHawk.MultiClient } } - private static Movie ConvertSMV152(BinaryReader r, string path) + private static Movie ImportSMV152(BinaryReader r, string path) { Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY); @@ -308,14 +323,14 @@ namespace BizHawk.MultiClient return m; } - private static Movie ConvertSMV151(BinaryReader r, string path) + private static Movie ImportSMV151(BinaryReader r, string path) { Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY); return m; } - private static Movie ConvertSMV143(BinaryReader r, string path) + private static Movie ImportSMV143(BinaryReader r, string path) { Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY); @@ -374,7 +389,7 @@ namespace BizHawk.MultiClient return m; } - public static Movie ConvertGMV(string path, out string errorMsg) + private static Movie ImportGMV(string path, out string errorMsg) { errorMsg = ""; Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY); @@ -382,7 +397,7 @@ namespace BizHawk.MultiClient return m; } - public static Movie ConvertVBM(string path, out string errorMsg) + private static Movie ImportVBM(string path, out string errorMsg) { errorMsg = ""; //Converts vbm to native text based format.