public MapRenderer(Mpq mpq, Chk chk) { this.mpq = mpq; this.chk = chk; pixel_width = (ushort)(chk.Width * 32); pixel_height = (ushort)(chk.Height * 32); Stream cv5_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.cv5", Util.TilesetNames[(int)chk.Tileset])); cv5 = new byte [cv5_fs.Length]; cv5_fs.Read (cv5, 0, (int)cv5_fs.Length); cv5_fs.Close (); Stream vx4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vx4", Util.TilesetNames[(int)chk.Tileset])); vx4 = new byte [vx4_fs.Length]; vx4_fs.Read (vx4, 0, (int)vx4_fs.Length); vx4_fs.Close (); Stream vr4_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.vr4", Util.TilesetNames[(int)chk.Tileset])); vr4 = new byte [vr4_fs.Length]; vr4_fs.Read (vr4, 0, (int)vr4_fs.Length); vr4_fs.Close (); Stream wpe_fs = (Stream)mpq.GetResource (String.Format ("tileset\\{0}.wpe", Util.TilesetNames[(int)chk.Tileset])); wpe = new byte [wpe_fs.Length]; wpe_fs.Read (wpe, 0, (int)wpe_fs.Length); wpe_fs.Close (); }
public BriefingRunner(ReadyRoomScreen screen, Chk scenario, string scenario_prefix) { this.screen = screen; this.scenario = scenario; this.prefix = scenario_prefix; triggerData = scenario.BriefingData; }
public void getDgChkBox(string sender) { for (int i = 0; i < Chk.Items.Count; i++) { if (sender == Chk.Items[i].ToString()) { Chk.SetItemChecked(i, true); } } }
public GameScreen(Mpq mpq, string prefix, Chk scenario) : base(mpq) { this.effectpal_path = "game\\tblink.pcx"; this.arrowgrp_path = "cursor\\arrow.grp"; this.fontpal_path = "game\\tfontgam.pcx"; //this.scenario_mpq = scenario_mpq; this.scenario = scenario; ScrollCursors = new CursorAnimator[8]; }
public GameScreen(Mpq mpq, Mpq scenario_mpq, Chk scenario, Got template) : base(mpq) { effectpal_path = "game\\tblink.pcx"; arrowgrp_path = "cursor\\arrow.grp"; fontpal_path = "game\\tfontgam.pcx"; //this.scenario_mpq = scenario_mpq; this.scenario = scenario; this.template = template; ScrollCursors = new CursorAnimator[8]; }
void FileListSelectionChanged(int selectedIndex) { string map_path = Path.Combine(curdir, file_listbox.SelectedItem); if (selectedScenario != null) { selectedScenario.Dispose(); } if (selectedIndex < directories.Length) { selectedScenario = null; selectedChk = null; } else { selectedScenario = new MpqArchive(map_path); selectedChk = (Chk)selectedScenario.GetResource("staredit\\scenario.chk"); } Elements[MAPTITLE_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Name; Elements[MAPDESCRIPTION_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Description; string mapSizeString = GlobalResources.Instance.GluAllTbl.Strings[MAPSIZE_FORMAT_INDEX]; // string mapDimString = GlobalResources.Instance.GluAllTbl.Strings[MAPDIM_FORMAT_INDEX]; string tileSetString = GlobalResources.Instance.GluAllTbl.Strings[TILESET_FORMAT_INDEX]; mapSizeString = mapSizeString.Replace("%c", " "); /* should probably be a tab.. */ mapSizeString = mapSizeString.Replace("%s", (selectedChk == null ? "" : String.Format("{0}x{1}", selectedChk.Width, selectedChk.Height))); tileSetString = tileSetString.Replace("%c", " "); /* should probably be a tab.. */ tileSetString = tileSetString.Replace("%s", (selectedChk == null ? "" : String.Format("{0}", selectedChk.Tileset))); Elements[MAPSIZE_ELEMENT_INDEX].Text = mapSizeString; Elements[MAPTILESET_ELEMENT_INDEX].Text = tileSetString; UpdatePlayersDisplay(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["m_UserID"] != null && _VR.Check(Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath), Session["m_UserID"].ToString())) { if (!IsPostBack) { Show(); showData(); } if (Request.QueryString["id"] != null && Request.QueryString["St"] != null) { string ID = Request.QueryString["id"].ToString(); string Status = Request.QueryString["St"].ToString(); if (Status == "1") { Status = "Approved"; } else { Status = "Pending"; } if (Chk.BoolSecurityCheck("update Expanse set Status='" + Status + "',InputDateTime='" + DateTime.Now.ToString() + "' where e_id=" + ID) && Chk.int32CheckSecurity("select count(*) from Expanse where e_id=" + ID, 1)) { Response.Redirect("../Expanse/ExpanseAdd"); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Messege 1: " + Chk.BoolSecurityErrorMessege + " \n Messege 2:" + Chk.Int32SecurityCheckError + "');", true); } } if (Request.QueryString["eid"] != null) { string ID = Request.QueryString["id"].ToString(); if (Chk.BoolSecurityCheck("delete from Expanse where e_id=" + ID) && Chk.int32CheckSecurity("select count(*) from Expanse where e_id=" + ID, 1)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Messege : Delete Successfully');", true); Response.Redirect("../Expanse/ExpanseAdd"); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Messege 1: " + Chk.BoolSecurityErrorMessege + " \n Messege 2:" + Chk.Int32SecurityCheckError + "');", true); } } } else { Response.Redirect("~/AuthorizationFailed"); } }
public MapRenderer(Mpq mpq, Chk chk) { this.mpq = mpq; this.chk = chk; pixel_width = (ushort)(chk.Width * 32); pixel_height = (ushort)(chk.Height * 32); Stream cv5_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.cv5", Util.TilesetNames[(int)chk.Tileset])); cv5 = new byte [cv5_fs.Length]; cv5_fs.Read(cv5, 0, (int)cv5_fs.Length); cv5_fs.Close(); Stream vx4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vx4", Util.TilesetNames[(int)chk.Tileset])); vx4 = new byte [vx4_fs.Length]; vx4_fs.Read(vx4, 0, (int)vx4_fs.Length); vx4_fs.Close(); Stream vr4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vr4", Util.TilesetNames[(int)chk.Tileset])); vr4 = new byte [vr4_fs.Length]; vr4_fs.Read(vr4, 0, (int)vr4_fs.Length); vr4_fs.Close(); Stream vf4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vf4", Util.TilesetNames[(int)chk.Tileset])); vf4 = new byte [vf4_fs.Length]; vf4_fs.Read(vf4, 0, (int)vf4_fs.Length); vf4_fs.Close(); Stream wpe_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.wpe", Util.TilesetNames[(int)chk.Tileset])); wpe = new byte [wpe_fs.Length]; wpe_fs.Read(wpe, 0, (int)wpe_fs.Length); wpe_fs.Close(); mapLayer = (CATiledLayer)CATiledLayer.Create(); mapLayer.TileSize = new SizeF(32, 32); mapLayer.Bounds = new RectangleF(0, 0, pixel_width, pixel_height); mapLayer.AnchorPoint = new PointF(0, 0); mapLayerDelegate = new MapLayerDelegate(this); mapLayer.Delegate = mapLayerDelegate; mapLayer.SetNeedsDisplay(); }
public MapRenderer(Mpq mpq, Chk chk) { this.mpq = mpq; this.chk = chk; pixel_width = (ushort)(chk.Width * 32); pixel_height = (ushort)(chk.Height * 32); Stream cv5_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.cv5", Util.TilesetNames[(int)chk.Tileset])); cv5 = new byte [cv5_fs.Length]; cv5_fs.Read(cv5, 0, (int)cv5_fs.Length); cv5_fs.Close(); Stream vx4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vx4", Util.TilesetNames[(int)chk.Tileset])); vx4 = new byte [vx4_fs.Length]; vx4_fs.Read(vx4, 0, (int)vx4_fs.Length); vx4_fs.Close(); Stream vr4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vr4", Util.TilesetNames[(int)chk.Tileset])); vr4 = new byte [vr4_fs.Length]; vr4_fs.Read(vr4, 0, (int)vr4_fs.Length); vr4_fs.Close(); Stream vf4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vf4", Util.TilesetNames[(int)chk.Tileset])); vf4 = new byte [vf4_fs.Length]; vf4_fs.Read(vf4, 0, (int)vf4_fs.Length); vf4_fs.Close(); Stream wpe_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.wpe", Util.TilesetNames[(int)chk.Tileset])); wpe = new byte [wpe_fs.Length]; wpe_fs.Read(wpe, 0, (int)wpe_fs.Length); wpe_fs.Close(); }
void FileListSelectionChanged(int selectedIndex) { string map_path = Path.Combine (curdir, file_listbox.SelectedItem); if (selectedScenario !=null) selectedScenario.Dispose (); if (selectedIndex < directories.Length) { selectedScenario = null; selectedChk = null; } else { selectedScenario = new MpqArchive (map_path); selectedChk = (Chk)selectedScenario.GetResource ("staredit\\scenario.chk"); } Elements[MAPTITLE_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Name; Elements[MAPDESCRIPTION_ELEMENT_INDEX].Text = selectedChk == null ? "" : selectedChk.Description; string mapSizeString = GlobalResources.Instance.GluAllTbl.Strings[MAPSIZE_FORMAT_INDEX]; // string mapDimString = GlobalResources.Instance.GluAllTbl.Strings[MAPDIM_FORMAT_INDEX]; string tileSetString = GlobalResources.Instance.GluAllTbl.Strings[TILESET_FORMAT_INDEX]; mapSizeString = mapSizeString.Replace ("%c", " "); /* should probably be a tab.. */ mapSizeString = mapSizeString.Replace ("%s", (selectedChk == null ? "" : String.Format ("{0}x{1}", selectedChk.Width, selectedChk.Height))); tileSetString = tileSetString.Replace ("%c", " "); /* should probably be a tab.. */ tileSetString = tileSetString.Replace ("%s", (selectedChk == null ? "" : String.Format ("{0}", selectedChk.Tileset))); Elements[MAPSIZE_ELEMENT_INDEX].Text = mapSizeString; Elements[MAPTILESET_ELEMENT_INDEX].Text = tileSetString; UpdatePlayersDisplay (); }
public byte[] RenderToBitmap(Mpq mpq, Chk chk) { ushort[,] mapTiles = chk.MapTiles; byte[] image = new byte[pixel_width * pixel_height * 4]; for (int map_y = 0; map_y < chk.Height; map_y++) { for (int map_x = 0; map_x < chk.Width; map_x++) { int mapTile = mapTiles[map_x, map_y]; // bool odd = (mapTile & 0x10) == 0x10; int tile_group = mapTile >> 4; /* the tile's group in the cv5 file */ int tile_number = mapTile & 0x0F; /* the megatile within the tile group */ int megatile_id = Util.ReadWord(cv5, (tile_group * 26 + 10 + tile_number) * 2); int minitile_x, minitile_y; for (minitile_y = 0; minitile_y < 4; minitile_y++) { for (minitile_x = 0; minitile_x < 4; minitile_x++) { ushort minitile_id = Util.ReadWord(vx4, megatile_id * 32 + minitile_y * 8 + minitile_x * 2); bool flipped = (minitile_id & 0x01) == 0x01; minitile_id >>= 1; int pixel_x, pixel_y; if (flipped) { for (pixel_y = 0; pixel_y < 8; pixel_y++) { for (pixel_x = 0; pixel_x < 8; pixel_x++) { int x = map_x * 32 + (minitile_x + 1) * 8 - pixel_x - 1; int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width; byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x]; image[0 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]); image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 2]; image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 1]; image[3 + 4 * (x + y)] = wpe[palette_entry * 4 + 0]; } } } else { for (pixel_y = 0; pixel_y < 8; pixel_y++) { for (pixel_x = 0; pixel_x < 8; pixel_x++) { int x = map_x * 32 + minitile_x * 8 + pixel_x; int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width; byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x]; image[0 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]); image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 2]; image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 1]; image[3 + 4 * (x + y)] = wpe[palette_entry * 4 + 0]; } } } } } } } return(image); }
public MapRenderer(Mpq mpq, Chk chk, int width, int height) : this(mpq, chk) { this.width = width; this.height = height; }
public static void Convert(string title, string[] args) // E.g.: /convert *.txt SubRip { const int ATTACH_PARENT_PROCESS = -1; if (!Configuration.IsRunningOnMac() && !Configuration.IsRunningOnLinux()) { NativeMethods.AttachConsole(ATTACH_PARENT_PROCESS); } var currentFolder = Directory.GetCurrentDirectory(); Console.WriteLine(); Console.WriteLine(title + " - Batch converter"); Console.WriteLine(); if (args.Length < 4) { if (args.Length == 3 && (args[2].Equals("/list", StringComparison.OrdinalIgnoreCase) || args[2].Equals("-list", StringComparison.OrdinalIgnoreCase))) { Console.WriteLine("- Supported formats (input/output):"); foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) { Console.WriteLine(" " + format.Name.Replace(" ", string.Empty)); } Console.WriteLine(); Console.WriteLine("- Supported formats (input only):"); Console.WriteLine(" " + CapMakerPlus.NameOfFormat); Console.WriteLine(" " + Captionate.NameOfFormat); Console.WriteLine(" " + Cavena890.NameOfFormat); Console.WriteLine(" " + CheetahCaption.NameOfFormat); Console.WriteLine(" " + Chk.NameOfFormat); Console.WriteLine(" Matroska (.mkv)"); Console.WriteLine(" Matroska subtitle (.mks)"); Console.WriteLine(" " + NciCaption.NameOfFormat); Console.WriteLine(" " + AvidStl.NameOfFormat); Console.WriteLine(" " + Pac.NameOfFormat); Console.WriteLine(" " + Spt.NameOfFormat); Console.WriteLine(" " + Ultech130.NameOfFormat); Console.WriteLine("- For Blu-ray .sup output use: '" + BatchConvert.BluRaySubtitle.Replace(" ", string.Empty) + "'"); Console.WriteLine("- For VobSub .sub output use: '" + BatchConvert.VobSubSubtitle.Replace(" ", string.Empty) + "'"); } else { Console.WriteLine("- Usage: SubtitleEdit /convert <pattern> <name-of-format-without-spaces> [<optional-parameters>]"); Console.WriteLine(); Console.WriteLine(" pattern:"); Console.WriteLine(" one or more file name patterns separated by commas"); Console.WriteLine(" relative patterns are relative to /inputfolder if specified"); Console.WriteLine(" optional-parameters:"); Console.WriteLine(" /offset:hh:mm:ss:ms"); Console.WriteLine(" /fps:<frame rate>"); Console.WriteLine(" /targetfps:<frame rate>"); Console.WriteLine(" /encoding:<encoding name>"); Console.WriteLine(" /pac-codepage:<code page>"); Console.WriteLine(" /inputfolder:<folder name>"); Console.WriteLine(" /outputfolder:<folder name>"); Console.WriteLine(" /removetextforhi"); Console.WriteLine(" /fixcommonerrors"); Console.WriteLine(" /redocasing"); Console.WriteLine(" /multiplereplace"); Console.WriteLine(); Console.WriteLine(" example: SubtitleEdit /convert *.srt sami"); Console.WriteLine(" list available formats: SubtitleEdit /convert /list"); } Console.WriteLine(); if (!Configuration.IsRunningOnMac() && !Configuration.IsRunningOnLinux()) { Console.Write(currentFolder + ">"); NativeMethods.FreeConsole(); } Environment.Exit(1); } int count = 0; int converted = 0; int errors = 0; try { var pattern = args[2].Trim(); var targetFormat = args[3].Trim().Replace(" ", string.Empty); var offset = GetArgument(args, "offset:"); double?targetFrameRate = null; { var fps = GetArgument(args, "targetfps:"); if (fps.Length > 1) { fps = fps.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."); double d; if (double.TryParse(fps, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) { targetFrameRate = d; } } fps = GetArgument(args, "fps:"); if (fps.Length > 1) { fps = fps.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."); double d; if (double.TryParse(fps, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) { Configuration.Settings.General.CurrentFrameRate = d; } } } var targetEncoding = Encoding.UTF8; try { var encodingName = GetArgument(args, "encoding:"); if (encodingName.Length > 0) { targetEncoding = Encoding.GetEncoding(encodingName); } } catch (Exception exception) { Console.WriteLine("Unable to set encoding (" + exception.Message + ") - using UTF-8"); } var outputFolder = string.Empty; { var folder = GetArgument(args, "outputfolder:"); if (folder.Length > 0 && Directory.Exists(folder)) { outputFolder = folder; } } var inputFolder = currentFolder; { var folder = GetArgument(args, "inputFolder:"); if (folder.Length > 0 && Directory.Exists(folder)) { inputFolder = folder; } } int pacCodePage = -1; { var pcp = GetArgument(args, "pac-codepage:"); if (pcp.Length > 0) { if (pcp.Equals("Latin", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageLatin; } else if (pcp.Equals("Greek", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageGreek; } else if (pcp.Equals("Czech", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageLatinCzech; } else if (pcp.Equals("Arabic", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageArabic; } else if (pcp.Equals("Hebrew", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageHebrew; } else if (pcp.Equals("Thai", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageThai; } else if (pcp.Equals("Cyrillic", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageCyrillic; } else if (pcp.Equals("CHT", StringComparison.OrdinalIgnoreCase) || pcp.Replace(" ", string.Empty).Equals("TraditionalChinese", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageChineseTraditional; } else if (pcp.Equals("CHS", StringComparison.OrdinalIgnoreCase) || pcp.Replace(" ", string.Empty).Equals("SimplifiedChinese", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageChineseSimplified; } else if (pcp.Equals("Korean", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageKorean; } else if (pcp.Equals("Japanese", StringComparison.OrdinalIgnoreCase)) { pacCodePage = Pac.CodePageJapanese; } else if (!int.TryParse(pcp, out pacCodePage) || !Pac.IsValidCodePage(pacCodePage)) { Console.WriteLine("Unknown pac code page '" + pcp + "' - using default code page"); pacCodePage = -1; } } } bool overwrite = GetArgument(args, "overwrite").Equals("overwrite"); bool removeTextForHi = GetArgument(args, "removetextforhi").Equals("removetextforhi"); bool fixCommonErrors = GetArgument(args, "fixcommonerrors").Equals("fixcommonerrors"); bool redoCasing = GetArgument(args, "redocasing").Equals("redocasing"); bool multipleReplace = GetArgument(args, "multiplereplace").Equals("multiplereplace"); var patterns = Enumerable.Empty <string>(); if (pattern.Contains(',') && !File.Exists(pattern)) { patterns = pattern.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(fn => fn.Trim()).Where(fn => fn.Length > 0); } else { patterns = patterns.DefaultIfEmpty(pattern); } var files = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var p in patterns) { var folderName = Path.GetDirectoryName(p); var fileName = Path.GetFileName(p); if (string.IsNullOrEmpty(folderName) || string.IsNullOrEmpty(fileName)) { folderName = inputFolder; fileName = p; } else if (!Path.IsPathRooted(folderName)) { folderName = Path.Combine(inputFolder, folderName); } foreach (var fn in Directory.EnumerateFiles(folderName, fileName)) { files.Add(fn); // silently ignore duplicates } } var formats = SubtitleFormat.AllSubtitleFormats; foreach (var fileName in files) { count++; var fileInfo = new FileInfo(fileName); if (fileInfo.Exists) { var sub = new Subtitle(); SubtitleFormat format = null; bool done = false; if (fileInfo.Extension.Equals(".mkv", StringComparison.OrdinalIgnoreCase) || fileInfo.Extension.Equals(".mks", StringComparison.OrdinalIgnoreCase)) { using (var matroska = new MatroskaFile(fileName)) { if (matroska.IsValid) { var tracks = matroska.GetTracks(); if (tracks.Count > 0) { foreach (var track in tracks) { if (track.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("{0}: {1} - Cannot convert from VobSub image based format!", fileName, targetFormat); } else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("{0}: {1} - Cannot convert from Blu-ray image based format!", fileName, targetFormat); } else { var ss = matroska.GetSubtitle(track.TrackNumber, null); format = Utilities.LoadMatroskaTextSubtitle(track, matroska, ss, sub); string newFileName = fileName; if (tracks.Count > 1) { newFileName = fileName.Insert(fileName.Length - 4, "_" + track.TrackNumber + "_" + track.Language.Replace("?", string.Empty).Replace("!", string.Empty).Replace("*", string.Empty).Replace(",", string.Empty).Replace("/", string.Empty).Trim()); } if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha)) { if (!AdvancedSubStationAlpha.NameOfFormat.Replace(" ", string.Empty).Equals(targetFormat, StringComparison.OrdinalIgnoreCase) && !SubStationAlpha.NameOfFormat.Replace(" ", string.Empty).Equals(targetFormat, StringComparison.OrdinalIgnoreCase)) { foreach (SubtitleFormat sf in formats) { if (sf.Name.Replace(" ", string.Empty).Equals(targetFormat, StringComparison.OrdinalIgnoreCase)) { format.RemoveNativeFormatting(sub, sf); break; } } } } BatchConvertSave(targetFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, newFileName, sub, format, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing, multipleReplace); done = true; } } } } } } if (!done && FileUtil.IsBluRaySup(fileName)) { Console.WriteLine("Found Blu-Ray subtitle format"); ConvertBluRaySubtitle(fileName, targetFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing, multipleReplace); done = true; } if (!done && FileUtil.IsVobSub(fileName)) { Console.WriteLine("Found VobSub subtitle format"); ConvertVobSubSubtitle(fileName, targetFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing, multipleReplace); done = true; } if (!done && fileInfo.Length < 10 * 1024 * 1024) // max 10 mb { Encoding encoding; format = sub.LoadSubtitle(fileName, out encoding, null, true); if (format == null || format.GetType() == typeof(Ebu)) { var ebu = new Ebu(); if (ebu.IsMine(null, fileName)) { ebu.LoadSubtitle(sub, null, fileName); format = ebu; } } if (format == null) { var pac = new Pac(); if (pac.IsMine(null, fileName)) { pac.BatchMode = true; pac.CodePage = pacCodePage; pac.LoadSubtitle(sub, null, fileName); format = pac; } } if (format == null) { var cavena890 = new Cavena890(); if (cavena890.IsMine(null, fileName)) { cavena890.LoadSubtitle(sub, null, fileName); format = cavena890; } } if (format == null) { var spt = new Spt(); if (spt.IsMine(null, fileName)) { spt.LoadSubtitle(sub, null, fileName); format = spt; } } if (format == null) { var cheetahCaption = new CheetahCaption(); if (cheetahCaption.IsMine(null, fileName)) { cheetahCaption.LoadSubtitle(sub, null, fileName); format = cheetahCaption; } } if (format == null) { var chk = new Chk(); if (chk.IsMine(null, fileName)) { chk.LoadSubtitle(sub, null, fileName); format = chk; } } if (format == null) { var ayato = new Ayato(); if (ayato.IsMine(null, fileName)) { ayato.LoadSubtitle(sub, null, fileName); format = ayato; } } if (format == null) { var capMakerPlus = new CapMakerPlus(); if (capMakerPlus.IsMine(null, fileName)) { capMakerPlus.LoadSubtitle(sub, null, fileName); format = capMakerPlus; } } if (format == null) { var captionate = new Captionate(); if (captionate.IsMine(null, fileName)) { captionate.LoadSubtitle(sub, null, fileName); format = captionate; } } if (format == null) { var ultech130 = new Ultech130(); if (ultech130.IsMine(null, fileName)) { ultech130.LoadSubtitle(sub, null, fileName); format = ultech130; } } if (format == null) { var nciCaption = new NciCaption(); if (nciCaption.IsMine(null, fileName)) { nciCaption.LoadSubtitle(sub, null, fileName); format = nciCaption; } } if (format == null) { var tsb4 = new TSB4(); if (tsb4.IsMine(null, fileName)) { tsb4.LoadSubtitle(sub, null, fileName); format = tsb4; } } if (format == null) { var avidStl = new AvidStl(); if (avidStl.IsMine(null, fileName)) { avidStl.LoadSubtitle(sub, null, fileName); format = avidStl; } } if (format == null) { var elr = new ELRStudioClosedCaption(); if (elr.IsMine(null, fileName)) { elr.LoadSubtitle(sub, null, fileName); format = elr; } } } if (format == null) { if (fileInfo.Length < 1024 * 1024) // max 1 mb { Console.WriteLine("{0}: {1} - input file format unknown!", fileName, targetFormat); } else { Console.WriteLine("{0}: {1} - input file too large!", fileName, targetFormat); } } else if (!done) { BatchConvertSave(targetFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, fileName, sub, format, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing, multipleReplace); } } else { Console.WriteLine("{0}: {1} - file not found!", count, fileName); errors++; } } } catch (Exception exception) { Console.WriteLine(); Console.WriteLine("Oops - an error occured: " + exception.Message); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("{0} file(s) converted", converted); Console.WriteLine(); if (!Configuration.IsRunningOnMac() && !Configuration.IsRunningOnLinux()) { Console.Write(currentFolder + ">"); NativeMethods.FreeConsole(); } if (count == converted && errors == 0) { Environment.Exit(0); } else { Environment.Exit(1); } }
private void ButtonOpenSubtitle1Click(object sender, EventArgs e) { openFileDialog1.FileName = string.Empty; if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName)) { MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); return; } _subtitle1 = new Subtitle(); Encoding encoding; var format = _subtitle1.LoadSubtitle(openFileDialog1.FileName, out encoding, null); if (format == null) { var pac = new Pac(); if (pac.IsMine(null, openFileDialog1.FileName)) { pac.BatchMode = true; pac.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); format = pac; } } if (format == null) { var cavena890 = new Cavena890(); if (cavena890.IsMine(null, openFileDialog1.FileName)) { cavena890.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); } } if (format == null) { var spt = new Spt(); if (spt.IsMine(null, openFileDialog1.FileName)) { spt.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); } } if (format == null) { var cheetahCaption = new CheetahCaption(); if (cheetahCaption.IsMine(null, openFileDialog1.FileName)) { cheetahCaption.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); } } if (format == null) { var chk = new Chk(); if (chk.IsMine(null, openFileDialog1.FileName)) { chk.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); } } if (format == null) { var asc = new TimeLineAscii(); if (asc.IsMine(null, openFileDialog1.FileName)) { asc.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); } } if (format == null) { var asc = new TimeLineFootageAscii(); if (asc.IsMine(null, openFileDialog1.FileName)) { asc.LoadSubtitle(_subtitle1, null, openFileDialog1.FileName); } } subtitleListView1.Fill(_subtitle1); subtitleListView1.SelectIndexAndEnsureVisible(0); subtitleListView2.SelectIndexAndEnsureVisible(0); labelSubtitle1.Text = openFileDialog1.FileName; _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); if (_subtitle1.Paragraphs.Count > 0) { CompareSubtitles(); } } }
public byte[] RenderToBitmap(Mpq mpq, Chk chk) { ushort[,] mapTiles = chk.MapTiles; byte[] image = new byte[pixel_width * pixel_height * 4]; for (int map_y = 0; map_y < chk.Height; map_y++) { for (int map_x = 0; map_x < chk.Width; map_x ++) { int mapTile = mapTiles[map_x,map_y]; // bool odd = (mapTile & 0x10) == 0x10; int tile_group = mapTile >> 4; /* the tile's group in the cv5 file */ int tile_number = mapTile & 0x0F; /* the megatile within the tile group */ int megatile_id = Util.ReadWord (cv5, (tile_group * 26 + 10 + tile_number) * 2); int minitile_x, minitile_y; for (minitile_y = 0; minitile_y < 4; minitile_y ++) { for (minitile_x = 0; minitile_x < 4; minitile_x ++) { ushort minitile_id = Util.ReadWord (vx4, megatile_id * 32 + minitile_y * 8 + minitile_x * 2); bool flipped = (minitile_id & 0x01) == 0x01; minitile_id >>= 1; int pixel_x, pixel_y; if (flipped) { for (pixel_y = 0; pixel_y < 8; pixel_y++) for (pixel_x = 0; pixel_x < 8; pixel_x ++) { int x = map_x * 32 + (minitile_x + 1) * 8 - pixel_x - 1; int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width; byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x]; image[0 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]); image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 2]; image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 1]; image[3 + 4 * (x + y)] = wpe[palette_entry * 4 + 0]; } } else { for (pixel_y = 0; pixel_y < 8; pixel_y++) { for (pixel_x = 0; pixel_x < 8; pixel_x ++) { int x = map_x * 32 + minitile_x * 8 + pixel_x; int y = (map_y * 32 + minitile_y * 8) * pixel_width + pixel_y * pixel_width; byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x]; image[0 + 4 * (x + y)] = (byte)(255 - wpe[palette_entry * 4 + 3]); image[1 + 4 * (x + y)] = wpe[palette_entry * 4 + 2]; image[2 + 4 * (x + y)] = wpe[palette_entry * 4 + 1]; image[3 + 4 * (x + y)] = wpe[palette_entry * 4 + 0]; } } } } } } } return image; }
private static SubtitleFormat GetSubtitleFormat(SubtitleFormat format, string fileName, Subtitle sub, string pacCodePage) { if (format == null || format.GetType() == typeof(Ebu)) { var ebu = new Ebu(); if (ebu.IsMine(null, fileName)) { ebu.LoadSubtitle(sub, null, fileName); format = ebu; } } if (format == null) { var pac = new Pac(); if (pac.IsMine(null, fileName)) { pac.BatchMode = true; if (!string.IsNullOrEmpty(pacCodePage) && Utilities.IsInteger(pacCodePage)) { pac.CodePage = int.Parse(pacCodePage); } else { pac.CodePage = -1; } pac.LoadSubtitle(sub, null, fileName); format = pac; } } if (format == null) { var cavena890 = new Cavena890(); if (cavena890.IsMine(null, fileName)) { cavena890.LoadSubtitle(sub, null, fileName); format = cavena890; } } if (format == null) { var spt = new Spt(); if (spt.IsMine(null, fileName)) { spt.LoadSubtitle(sub, null, fileName); format = spt; } } if (format == null) { var cheetahCaption = new CheetahCaption(); if (cheetahCaption.IsMine(null, fileName)) { cheetahCaption.LoadSubtitle(sub, null, fileName); format = cheetahCaption; } } if (format == null) { var chk = new Chk(); if (chk.IsMine(null, fileName)) { chk.LoadSubtitle(sub, null, fileName); format = chk; } } if (format == null) { var ayato = new Ayato(); if (ayato.IsMine(null, fileName)) { ayato.LoadSubtitle(sub, null, fileName); format = ayato; } } if (format == null) { var capMakerPlus = new CapMakerPlus(); if (capMakerPlus.IsMine(null, fileName)) { capMakerPlus.LoadSubtitle(sub, null, fileName); format = capMakerPlus; } } if (format == null) { var captionate = new Captionate(); if (captionate.IsMine(null, fileName)) { captionate.LoadSubtitle(sub, null, fileName); format = captionate; } } if (format == null) { var ultech130 = new Ultech130(); if (ultech130.IsMine(null, fileName)) { ultech130.LoadSubtitle(sub, null, fileName); format = ultech130; } } if (format == null) { var nciCaption = new NciCaption(); if (nciCaption.IsMine(null, fileName)) { nciCaption.LoadSubtitle(sub, null, fileName); format = nciCaption; } } if (format == null) { var tsb4 = new TSB4(); if (tsb4.IsMine(null, fileName)) { tsb4.LoadSubtitle(sub, null, fileName); format = tsb4; } } if (format == null) { var avidStl = new AvidStl(); if (avidStl.IsMine(null, fileName)) { avidStl.LoadSubtitle(sub, null, fileName); format = avidStl; } } if (format == null) { var elr = new ELRStudioClosedCaption(); if (elr.IsMine(null, fileName)) { elr.LoadSubtitle(sub, null, fileName); format = elr; } } return format; }
public GameScreen (Mpq mpq, Mpq scenario_mpq, Chk scenario, Got template) : base (mpq) { effectpal_path = "game\\tblink.pcx"; arrowgrp_path = "cursor\\arrow.grp"; fontpal_path = "game\\tfontgam.pcx"; //this.scenario_mpq = scenario_mpq; this.scenario = scenario; this.template = template; ScrollCursors = new CursorAnimator[8]; }
public GameScreen (Mpq mpq, string prefix, Chk scenario) : base (mpq) { this.effectpal_path = "game\\tblink.pcx"; this.arrowgrp_path = "cursor\\arrow.grp"; this.fontpal_path = "game\\tfontgam.pcx"; //this.scenario_mpq = scenario_mpq; this.scenario = scenario; ScrollCursors = new CursorAnimator[8]; }
public static void Main(string[] args) { string mpqpath = args[0]; string mappath = args[1]; Console.WriteLine("Map name {0}", mappath); Mpq mpq = GetMPQ(mpqpath); Mpq map = GetMPQ(mappath); Chk chk = (Chk)map.GetResource("staredit\\scenario.chk"); ushort[,] mapTiles = chk.MapTiles; byte[] image = new byte[chk.Width * 32 * chk.Height * 32 * 3]; /* * 00 - Badlands * 01 - Space Platform * 02 - Installation * 03 - Ashworld * 04 - Jungle World * 05 - Desert World * 06 - Arctic World * 07 - Twilight World */ string[] tileset_names = new string[] { "badlands", "platform", "install", "ashworld", "jungle", "desert", "ice", "twilight" }; Stream cv5_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.cv5", tileset_names[(int)chk.Tileset])); Stream vx4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vx4", tileset_names[(int)chk.Tileset])); Stream vr4_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.vr4", tileset_names[(int)chk.Tileset])); Stream wpe_fs = (Stream)mpq.GetResource(String.Format("tileset\\{0}.wpe", tileset_names[(int)chk.Tileset])); byte[] cv5 = new byte [cv5_fs.Length]; cv5_fs.Read(cv5, 0, (int)cv5_fs.Length); byte[] vx4 = new byte [vx4_fs.Length]; vx4_fs.Read(vx4, 0, (int)vx4_fs.Length); byte[] vr4 = new byte [vr4_fs.Length]; vr4_fs.Read(vr4, 0, (int)vr4_fs.Length); byte[] wpe = new byte [wpe_fs.Length]; wpe_fs.Read(wpe, 0, (int)wpe_fs.Length); for (int map_y = 0; map_y < chk.Height; map_y++) { for (int map_x = 0; map_x < chk.Width; map_x++) { int mapTile = mapTiles[map_x, map_y]; bool odd = (mapTile & 0x10) == 0x10; int tile_group = mapTile >> 4; /* the tile's group in the cv5 file */ int tile_number = mapTile & 0x0F; /* the megatile within the tile group */ int megatile_id = Util.ReadWord(cv5, (tile_group * 26 + 10 + tile_number) * 2); if (map_y == 0) { Console.Write("[{0}.{1}:0x{2:x}]", tile_group, tile_number, megatile_id); if (map_x == chk.Width - 1) { Console.WriteLine(); } } int minitile_x, minitile_y; // Console.WriteLine ("[{0},{1}] = {2} ({3:x} = {4:x}:{5:x})", map_x, map_y, megatile_id, mapTile, tile_group, tile_number); for (minitile_y = 0; minitile_y < 4; minitile_y++) { for (minitile_x = 0; minitile_x < 4; minitile_x++) { ushort minitile_id = Util.ReadWord(vx4, megatile_id * 32 + minitile_y * 8 + minitile_x * 2); bool flipped = (minitile_id & 0x01) == 0x01; minitile_id >>= 1; // Console.WriteLine ("minitile [{0},{1}] = {2}", minitile_x, minitile_y, minitile_id); int pixel_x, pixel_y; if (flipped) { for (pixel_y = 0; pixel_y < 8; pixel_y++) { for (pixel_x = 0; pixel_x < 8; pixel_x++) { int x = map_x * 32 + (minitile_x + 1) * 8 - pixel_x - 1; int y = (map_y * 32 + minitile_y * 8) * chk.Width * 32 + pixel_y * chk.Width * 32; byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x]; image[0 + 3 * (x + y)] = wpe[palette_entry * 4 + 2]; image[1 + 3 * (x + y)] = wpe[palette_entry * 4 + 1]; image[2 + 3 * (x + y)] = wpe[palette_entry * 4 + 0]; } } } else { for (pixel_y = 0; pixel_y < 8; pixel_y++) { for (pixel_x = 0; pixel_x < 8; pixel_x++) { int x = map_x * 32 + minitile_x * 8 + pixel_x; int y = (map_y * 32 + minitile_y * 8) * chk.Width * 32 + pixel_y * chk.Width * 32; byte palette_entry = vr4[minitile_id * 64 + pixel_y * 8 + pixel_x]; image[0 + 3 * (x + y)] = wpe[palette_entry * 4 + 2]; image[1 + 3 * (x + y)] = wpe[palette_entry * 4 + 1]; image[2 + 3 * (x + y)] = wpe[palette_entry * 4 + 0]; } } } } } } } TGA.WriteTGA("map.tga", image, (uint)chk.Width * 32, (uint)chk.Height * 32); }
public static void Convert(string title, string[] args) // E.g.: /convert *.txt SubRip { const int ATTACH_PARENT_PROCESS = -1; if (!Configuration.IsRunningOnMac() && !Configuration.IsRunningOnLinux()) { NativeMethods.AttachConsole(ATTACH_PARENT_PROCESS); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(title + " - Batch converter"); Console.WriteLine(); Console.WriteLine("- Syntax: SubtitleEdit /convert <pattern> <name-of-format-without-spaces> [/offset:hh:mm:ss:ms] [/encoding:<encoding name>] [/fps:<frame rate>] [/targetfps:<frame rate>] [/inputfolder:<input folder>] [/outputfolder:<output folder>] [/removetextforhi] [/fixcommonerrors] [/pac-codepage:<code page>]"); Console.WriteLine(); Console.WriteLine(" example: SubtitleEdit /convert *.srt sami"); Console.WriteLine(" list available formats: SubtitleEdit /convert /list"); Console.WriteLine(); string currentDir = Directory.GetCurrentDirectory(); if (args.Length < 4) { if (args.Length == 3 && (args[2].Equals("/list", StringComparison.OrdinalIgnoreCase) || args[2].Equals("-list", StringComparison.OrdinalIgnoreCase))) { Console.WriteLine("- Supported formats (input/output):"); foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) { Console.WriteLine(" " + format.Name.Replace(" ", string.Empty)); } Console.WriteLine(); Console.WriteLine("- Supported formats (input only):"); Console.WriteLine(" " + CapMakerPlus.NameOfFormat); Console.WriteLine(" " + Captionate.NameOfFormat); Console.WriteLine(" " + Cavena890.NameOfFormat); Console.WriteLine(" " + CheetahCaption.NameOfFormat); Console.WriteLine(" " + Chk.NameOfFormat); Console.WriteLine(" Matroska (.mkv)"); Console.WriteLine(" Matroska subtitle (.mks)"); Console.WriteLine(" " + NciCaption.NameOfFormat); Console.WriteLine(" " + AvidStl.NameOfFormat); Console.WriteLine(" " + Pac.NameOfFormat); Console.WriteLine(" " + Spt.NameOfFormat); Console.WriteLine(" " + Ultech130.NameOfFormat); Console.WriteLine("- For Blu-ray .sup output use: '" + BatchConvert.BluRaySubtitle.Replace(" ", string.Empty) + "'"); Console.WriteLine("- For VobSub .sub output use: '" + BatchConvert.VobSubSubtitle.Replace(" ", string.Empty) + "'"); } Console.WriteLine(); Console.Write(currentDir + ">"); if (!Configuration.IsRunningOnMac() && !Configuration.IsRunningOnLinux()) { NativeMethods.FreeConsole(); } Environment.Exit(1); } int count = 0; int converted = 0; int errors = 0; try { string pattern = args[2]; string toFormat = args[3]; string offset = GetArgument(args, "/offset:"); var fps = GetArgument(args, "/fps:"); if (fps.Length > 6) { fps = fps.Remove(0, 5).Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".").Trim(); double d; if (double.TryParse(fps, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) { Configuration.Settings.General.CurrentFrameRate = d; } } var targetFps = GetArgument(args, "/targetfps:"); double?targetFrameRate = null; if (targetFps.Length > 12) { targetFps = targetFps.Remove(0, 11).Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".").Trim(); double d; if (double.TryParse(targetFps, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) { targetFrameRate = d; } } var targetEncodingName = GetArgument(args, "/encoding:");; var targetEncoding = Encoding.UTF8; try { if (!string.IsNullOrEmpty(targetEncodingName)) { targetEncodingName = targetEncodingName.Substring(10); if (!string.IsNullOrEmpty(targetEncodingName)) { targetEncoding = Encoding.GetEncoding(targetEncodingName); } } } catch (Exception exception) { Console.WriteLine("Unable to set encoding (" + exception.Message + ") - using UTF-8"); targetEncoding = Encoding.UTF8; } var outputFolder = GetArgument(args, "/outputfolder:");; if (outputFolder.Length > "/outputFolder:".Length) { outputFolder = outputFolder.Remove(0, "/outputFolder:".Length); if (!Directory.Exists(outputFolder)) { outputFolder = string.Empty; } } var inputFolder = GetArgument(args, "/inputFolder:", Directory.GetCurrentDirectory()); if (inputFolder.Length > "/inputFolder:".Length) { inputFolder = inputFolder.Remove(0, "/inputFolder:".Length); if (!Directory.Exists(inputFolder)) { inputFolder = Directory.GetCurrentDirectory(); } } var pacCodePage = GetArgument(args, "/pac-codepage:"); if (pacCodePage.Length > "/pac-codepage:".Length) { pacCodePage = pacCodePage.Remove(0, "/pac-codepage:".Length); if (string.Compare("Latin", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "0"; } else if (string.Compare("Greek", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "1"; } else if (string.Compare("Czech", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "2"; } else if (string.Compare("Arabic", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "3"; } else if (string.Compare("Hebrew", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "4"; } else if (string.Compare("Encoding", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "5"; } else if (string.Compare("Cyrillic", pacCodePage, StringComparison.OrdinalIgnoreCase) == 0) { pacCodePage = "6"; } } bool overwrite = GetArgument(args, "/overwrite", string.Empty).Equals("/overwrite"); bool removeTextForHi = GetArgument(args, "/removetextforhi", string.Empty).Equals("/removetextforhi"); bool fixCommonErrors = GetArgument(args, "/fixcommonerrors", string.Empty).Equals("/fixcommonerrors"); bool redoCasing = GetArgument(args, "/redocasing", string.Empty).Equals("/redocasing"); string[] files; string inputDirectory = Directory.GetCurrentDirectory(); if (!string.IsNullOrEmpty(inputFolder)) { inputDirectory = inputFolder; } if (pattern.Contains(',') && !File.Exists(pattern)) { files = pattern.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int k = 0; k < files.Length; k++) { files[k] = files[k].Trim(); } } else { int indexOfDirectorySeparatorChar = pattern.LastIndexOf(Path.DirectorySeparatorChar); if (indexOfDirectorySeparatorChar > 0 && indexOfDirectorySeparatorChar < pattern.Length) { pattern = pattern.Substring(indexOfDirectorySeparatorChar + 1); inputDirectory = args[2].Substring(0, indexOfDirectorySeparatorChar); } files = Directory.GetFiles(inputDirectory, pattern); } var formats = SubtitleFormat.AllSubtitleFormats; foreach (string fName in files) { string fileName = fName; count++; if (!string.IsNullOrEmpty(inputFolder) && File.Exists(Path.Combine(inputFolder, fileName))) { fileName = Path.Combine(inputFolder, fileName); } if (File.Exists(fileName)) { var sub = new Subtitle(); SubtitleFormat format = null; bool done = false; if (Path.GetExtension(fileName).Equals(".mkv", StringComparison.OrdinalIgnoreCase) || Path.GetExtension(fileName).Equals(".mks", StringComparison.OrdinalIgnoreCase)) { using (var matroska = new MatroskaFile(fileName)) { if (matroska.IsValid) { var tracks = matroska.GetTracks(); if (tracks.Count > 0) { foreach (var track in tracks) { if (track.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("{0}: {1} - Cannot convert from VobSub image based format!", fileName, toFormat); } else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("{0}: {1} - Cannot convert from Blu-ray image based format!", fileName, toFormat); } else { var ss = matroska.GetSubtitle(track.TrackNumber, null); format = Utilities.LoadMatroskaTextSubtitle(track, matroska, ss, sub); string newFileName = fileName; if (tracks.Count > 1) { newFileName = fileName.Insert(fileName.Length - 4, "_" + track.TrackNumber + "_" + track.Language.Replace("?", string.Empty).Replace("!", string.Empty).Replace("*", string.Empty).Replace(",", string.Empty).Replace("/", string.Empty).Trim()); } if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha)) { if (toFormat.ToLower() != AdvancedSubStationAlpha.NameOfFormat.ToLower().Replace(" ", string.Empty) && toFormat.ToLower() != SubStationAlpha.NameOfFormat.ToLower().Replace(" ", string.Empty)) { foreach (SubtitleFormat sf in formats) { if (sf.Name.Replace(" ", string.Empty).Equals(toFormat, StringComparison.OrdinalIgnoreCase) || sf.Name.Replace(" ", string.Empty).Equals(toFormat.Replace(" ", string.Empty), StringComparison.OrdinalIgnoreCase)) { format.RemoveNativeFormatting(sub, sf); break; } } } } BatchConvertSave(toFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, newFileName, sub, format, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing); done = true; } } } } } } if (FileUtil.IsBluRaySup(fileName)) { Console.WriteLine("Found Blu-Ray subtitle format"); ConvertBluRaySubtitle(fileName, toFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing); done = true; } if (!done && FileUtil.IsVobSub(fileName)) { Console.WriteLine("Found VobSub subtitle format"); ConvertVobSubSubtitle(fileName, toFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing); done = true; } var fi = new FileInfo(fileName); if (fi.Length < 10 * 1024 * 1024 && !done) // max 10 mb { Encoding encoding; format = sub.LoadSubtitle(fileName, out encoding, null, true); if (format == null || format.GetType() == typeof(Ebu)) { var ebu = new Ebu(); if (ebu.IsMine(null, fileName)) { ebu.LoadSubtitle(sub, null, fileName); format = ebu; } } if (format == null) { var pac = new Pac(); if (pac.IsMine(null, fileName)) { pac.BatchMode = true; if (!string.IsNullOrEmpty(pacCodePage) && Utilities.IsInteger(pacCodePage)) { pac.CodePage = int.Parse(pacCodePage); } else { pac.CodePage = -1; } pac.LoadSubtitle(sub, null, fileName); format = pac; } } if (format == null) { var cavena890 = new Cavena890(); if (cavena890.IsMine(null, fileName)) { cavena890.LoadSubtitle(sub, null, fileName); format = cavena890; } } if (format == null) { var spt = new Spt(); if (spt.IsMine(null, fileName)) { spt.LoadSubtitle(sub, null, fileName); format = spt; } } if (format == null) { var cheetahCaption = new CheetahCaption(); if (cheetahCaption.IsMine(null, fileName)) { cheetahCaption.LoadSubtitle(sub, null, fileName); format = cheetahCaption; } } if (format == null) { var chk = new Chk(); if (chk.IsMine(null, fileName)) { chk.LoadSubtitle(sub, null, fileName); format = chk; } } if (format == null) { var ayato = new Ayato(); if (ayato.IsMine(null, fileName)) { ayato.LoadSubtitle(sub, null, fileName); format = ayato; } } if (format == null) { var capMakerPlus = new CapMakerPlus(); if (capMakerPlus.IsMine(null, fileName)) { capMakerPlus.LoadSubtitle(sub, null, fileName); format = capMakerPlus; } } if (format == null) { var captionate = new Captionate(); if (captionate.IsMine(null, fileName)) { captionate.LoadSubtitle(sub, null, fileName); format = captionate; } } if (format == null) { var ultech130 = new Ultech130(); if (ultech130.IsMine(null, fileName)) { ultech130.LoadSubtitle(sub, null, fileName); format = ultech130; } } if (format == null) { var nciCaption = new NciCaption(); if (nciCaption.IsMine(null, fileName)) { nciCaption.LoadSubtitle(sub, null, fileName); format = nciCaption; } } if (format == null) { var tsb4 = new TSB4(); if (tsb4.IsMine(null, fileName)) { tsb4.LoadSubtitle(sub, null, fileName); format = tsb4; } } if (format == null) { var avidStl = new AvidStl(); if (avidStl.IsMine(null, fileName)) { avidStl.LoadSubtitle(sub, null, fileName); format = avidStl; } } if (format == null) { var elr = new ELRStudioClosedCaption(); if (elr.IsMine(null, fileName)) { elr.LoadSubtitle(sub, null, fileName); format = elr; } } } if (format == null) { if (fi.Length < 1024 * 1024) // max 1 mb { Console.WriteLine("{0}: {1} - input file format unknown!", fileName, toFormat); } else { Console.WriteLine("{0}: {1} - input file too large!", fileName, toFormat); } } else if (!done) { BatchConvertSave(toFormat, offset, targetEncoding, outputFolder, count, ref converted, ref errors, formats, fileName, sub, format, overwrite, pacCodePage, targetFrameRate, removeTextForHi, fixCommonErrors, redoCasing); } } else { Console.WriteLine("{0}: {1} - file not found!", count, fileName); errors++; } } } catch (Exception exception) { Console.WriteLine(); Console.WriteLine("Ups - an error occured: " + exception.Message); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("{0} file(s) converted", converted); Console.WriteLine(); Console.Write(currentDir + ">"); if (!Configuration.IsRunningOnMac() && !Configuration.IsRunningOnLinux()) { NativeMethods.FreeConsole(); } if (count == converted && errors == 0) { Environment.Exit(0); } else { Environment.Exit(1); } }
public ReadyRoomScreen(Mpq mpq, string scenario_prefix, int start_element_index, int cancel_element_index, int skiptutorial_element_index, int replay_element_index, int transmission_element_index, int objectives_element_index, int first_portrait_element_index) : base(mpq, String.Format ("glue\\Ready{0}", Util.RaceChar[(int)Game.Instance.Race]), String.Format (Builtins.rez_GluRdyBin, Util.RaceCharLower[(int)Game.Instance.Race])) { background_path = String.Format ("glue\\PalR{0}\\Backgnd.pcx", Util.RaceCharLower[(int)Game.Instance.Race]); fontpal_path = String.Format ("glue\\PalR{0}\\tFont.pcx", Util.RaceCharLower[(int)Game.Instance.Race]); effectpal_path = String.Format ("glue\\PalR{0}\\tEffect.pcx", Util.RaceCharLower[(int)Game.Instance.Race]); arrowgrp_path = String.Format ("glue\\PalR{0}\\arrow.grp", Util.RaceCharLower[(int)Game.Instance.Race]); this.start_element_index = start_element_index; this.cancel_element_index = cancel_element_index; this.skiptutorial_element_index = skiptutorial_element_index; this.replay_element_index = replay_element_index; this.transmission_element_index = transmission_element_index; this.objectives_element_index = objectives_element_index; this.first_portrait_element_index = first_portrait_element_index; this.scenario = (Chk)mpq.GetResource (scenario_prefix + "\\staredit\\scenario.chk"); this.scenario_prefix = scenario_prefix; }