private async ValueTask DoMain(CommandLineOptions options) { var logger = new Logger { TraceEnabled = options.TraceLog }; CmdUtil.NoCacheWarn(options.CacheFilePath); await using var mapping = new ObjectIdCache(options.CacheFilePath); using var rootdirRepo = CmdUtil.PrepareRepository(options.RootdirPath, "rootdir repository", maxDepth: 1, allowEmpty: false, allowRemote: options.PushAfterCommit, mustLocalTailingMessage: " if --push is not specified"); using var subdirRepo = CmdUtil.PrepareRepository(options.SubdirRepoPath, "subdir repository", maxDepth: options.MaxDepth, allowEmpty: false, allowRemote: true); var subdirDesc = CmdUtil.GetDescription( descriptionRepository: subdirRepo, descriptionByOption: options.SubdirRepoDesc, otherRepository: rootdirRepo, repositoryType: "subdir"); var backCopyOptions = new BackCopyOptions(subdirDesc: subdirDesc) { ObjectMapping = mapping, DirInSrcs = options.DirInSrcs, Branches = CmdUtil.Branches(options.BranchNames, subdirRepo), MaxDepth = options.MaxDepth, Logger = logger, }; using ICopyCommitProgressHandler progressHandler = options.TraceLog ? new NopProgressBarCopyCommitProgressHandler() : new ConsoleProgressBarCopyCommitProgressHandler(); var main = new BackCopyCommitMain(backCopyOptions); main.DoMain(rootdirRepo, subdirRepo, progressHandler); #if SUPPORT_REMOTE_REPOSITORY if (options.PushAfterCommit) { var branches = CmdUtil.Branches(options.BranchNames, rootdirRepo, notFoundError: false, remoteTrackingError: false); foreach (var branch in branches) { if (branch.RemoteName == null) { rootdirRepo.Config.Set($"branch.{branch.FriendlyName}.remote", $"origin"); } } rootdirRepo.Network.Push(branches, new PushOptions()); } #endif }
private void Push() { var nugetExe = txtNugetPath.Text; var script = new StringBuilder(); var deployVM = _deployControl.ViewModel; if (deployVM.NuGetServer.Length > 0) { script.AppendLine(); if (!string.IsNullOrWhiteSpace(deployVM.V2Login)) { script.AppendFormat(@"""{0}"" sources Add -Name ""{1}"" -Source ""{2}"" -Username ""{3}"" -Password ""{4}""", nugetExe, deployVM.NuGetServer, deployVM.NuGetServer, deployVM.V2Login, deployVM.ApiKey); script.AppendFormat(@" || ""{0}"" sources Update -Name ""{1}"" -Source ""{2}"" -Username ""{3}"" -Password ""{4}""", nugetExe, deployVM.NuGetServer, deployVM.NuGetServer, deployVM.V2Login, deployVM.ApiKey); script.AppendLine(); } script.AppendFormat("\"{0}\" push \"{1}{4}.{5}.nupkg\" -source {2} {3}", nugetExe, _outputDir, deployVM.NuGetServer, deployVM.ApiKey, _metadata.Id, _metadata.Version); } if (chkSymbol.Checked && !string.IsNullOrWhiteSpace(deployVM.SymbolServer)) { script.AppendLine(); script.AppendFormat("nuget SetApiKey {0}", deployVM.ApiKey); script.AppendLine(); script.AppendFormat("nuget push \"{0}{1}.{2}.symbols.nupkg\" -source {3}", _outputDir, _metadata.Id, _metadata.Version, deployVM.SymbolServer); } CmdUtil.RunCmd(script.ToString()); ShowPackages(); }
public override CommandFeedback Execute(string[] args) { if (args.Length == 1) { return(CommandFeedback.WrongNumberOfArguments); } string targetFolder = args[1]; if (!Directory.Exists(targetFolder)) { return(CommandFeedback.Error); } var outputFolder = ""; if (args.Length > 2) { outputFolder = args[2]; } var sampleRate = "48000"; if (args.Length > 3) { sampleRate = args[3]; } var dir = new DirectoryInfo(targetFolder); var files = new List <FileInfo>(); RecursiveGetFiles(dir, files); for (var i = 0; i < files.Count; i++) { var file = files[i]; //ffmpeg -i input.wav -vn -ar 44100 -ac 2 -ab 192k -f mp3 output.mp3 string target; if (string.IsNullOrEmpty(outputFolder)) { target = Path.Combine(Path.GetDirectoryName(file.FullName), file.Name + ".mp3"); } else { target = Path.Combine(outputFolder, file.Name + ".mp3"); } string startArgs = $"ffmpeg -i \"{file.FullName}\" -vn -ar {sampleRate} -ac 2 -ab `192k -f mp3 \"{target}\""; int exitCode; CmdUtil.ExecuteCommand("", out exitCode, startArgs); } return(CommandFeedback.Success); }
public override CommandFeedback Execute(string[] args) { if (args.Length == 1) { return(CommandFeedback.WrongNumberOfArguments); } string target = args[1]; if (!File.Exists(target)) { return(CommandFeedback.Error); } string startTime = args[2]; string cutDuration = args[3]; // rename the source file to backup string dir = Path.GetDirectoryName(target); string fileName = Path.GetFileNameWithoutExtension(target); string sourceFile = Path.Combine(dir, fileName + "_Backup.m4a"); File.Move(target, sourceFile); //ffmpeg - ss 1:01:42 - i c:\Data\temp\in.m4a - vn - c copy - t 1:00:00 out.m4a //The first time(1:01:42) is the start time of the cut. //-vn means that only the audio stream is copied from the file. //The second time(1:00:00) is the duration of the cut.It can be longer then the length of the whole file. string startArgs = $"ffmpeg -ss {startTime} -i \"{sourceFile}\" -vn -c copy -t {cutDuration} \"{target}\""; int exitCode; CmdUtil.ExecuteCommand("", out exitCode, startArgs); bool makeBackup = false; if (File.Exists(target)) { if (!makeBackup) { File.Delete(sourceFile); } ConsoleU.WriteLine($"Okay", Palette.Success); } else { ConsoleU.WriteLine($"Failed", Palette.Error); } return(CommandFeedback.Success); }
public override CommandFeedback Execute(string[] args) { if (args.Length == 1) { return(CommandFeedback.WrongNumberOfArguments); } string target = args[1]; if (!Path.IsPathRooted(target)) { // relative path string currentDir = Environment.CurrentDirectory; target = Path.Combine(currentDir, target); } if (!File.Exists(target)) { Console.WriteLine($"File not found: {target}"); return(CommandFeedback.Error); } // rename the source file to backup string dir = Path.GetDirectoryName(target); string fileName = Path.GetFileNameWithoutExtension(target); string sourceFile = Path.Combine(dir, fileName + "_Backup.m4a"); File.Move(target, sourceFile); string startArgs = $"ffmpeg -i \"{sourceFile}\" -acodec copy -movflags faststart \"{target}\""; int exitCode; CmdUtil.ExecuteCommand("", out exitCode, startArgs); bool makeBackup = false; if (File.Exists(target)) { if (!makeBackup) { File.Delete(sourceFile); } ConsoleU.WriteLine($"Okay", Palette.Success); } else { ConsoleU.WriteLine($"FFMPEG failed with code {exitCode}", Palette.Error); return(CommandFeedback.Error); } return(CommandFeedback.Success); }
private void StartSend() { if (_connected) { if (_sendPackages.Count == 0) { return; } if (_clientSocket == null) { return; } try { ByteArray bytes = _sendData; bytes.Clear(); while (_sendPackages.Count > 0) { SendPackage sendData = _sendPackages[0]; _sendPackages.RemoveAt(0); //ByteArray package = CmdUtil.GetPackage(sendData.CmdID, (uint)TimeManager.ServerTime, sendData.Body); ByteArray package = CmdUtil.GetPackage(sendData.CmdID, 0, sendData.Body); if (CanLog()) { //Log(">>>> [" + _ip + ":" + _port + "][CmdID:" + sendData.CmdID + "][Data Length:" + (package.Length - COMMAND_HEAD_LENGTH) + "]"); } bytes.WriteBytes(package); } _clientSocket.BeginSend(bytes.Bytes, 0, bytes.Length, SocketFlags.None, new AsyncCallback(SendCallback), _clientSocket); if (CanLog()) { //Log(">>>> [" + _ip + ":" + _port + "][Flush....][Data Length:" + bytes.Length + "]"); } } catch (SocketException socketEx) { Debug.Log("StartSend...[" + socketEx.ErrorCode + "]" + socketEx.Message); if (socketEx.NativeErrorCode != 10035) { Close(true); } } catch (Exception ex) { Debug.Log("Start Send Exception " + ex.Message); Close(true); throw ex; } } }
private void Run(IQuery query) { var timer = new Stopwatch(); timer.Start(); String args = query.Build(); mTsharkProcess = CmdUtil.StartProcess(TSharkHelper.GetTSharkPath(), args); timer.Stop(); Console.WriteLine("TShark query:\"{0}\" {1} ms ellapsed", args, timer.ElapsedMilliseconds); }
private void convertToGif() { ConfigUtil.INPUT_PATH = tbMp4Path.Text; string fileGif = ConfigUtil.INPUT_PATH.Replace(ConfigUtil.MP4, ConfigUtil.GIF); ConfigUtil.FFMPEG_PALETTE_PNG = FileUtil.getPath(ConfigUtil.INPUT_PATH) + @"\" + ConfigUtil.FFMPEG_PALETTE_PNG; if (!File.Exists(fileGif)) { updateStatus(ConfigUtil.CONVERTING); startTimer(); string generateAPalette = string.Format( ConfigUtil.FFMPEG_GENERATE_PALETTE, ConfigUtil.FFMPEG_START_AT_SECOND, ConfigUtil.FFMPEG_LENGTH_OF_GIF_VIDEO, ConfigUtil.INPUT_PATH, ConfigUtil.FFMPEG_SCALE, ConfigUtil.FFMPEG_PALETTE_PNG ); string outputGifUsingPalette = string.Format( ConfigUtil.FFMPEG_OUTPUT_GIF_USING_PALETTE, ConfigUtil.FFMPEG_START_AT_SECOND, ConfigUtil.FFMPEG_LENGTH_OF_GIF_VIDEO, ConfigUtil.INPUT_PATH, ConfigUtil.FFMPEG_PALETTE_PNG, ConfigUtil.FFMPEG_SCALE, ConfigUtil.INPUT_PATH.Replace(ConfigUtil.MP4, "") ); String genPalette = string.Format("{0} {1}", ConfigUtil.FFMPEG, generateAPalette); String convGif = string.Format("{0} {1}", ConfigUtil.FFMPEG, outputGifUsingPalette); String delPalett = string.Format(ConfigUtil.DELETE_FILE, ConfigUtil.FFMPEG_PALETTE_PNG); String options = string.Format("{0} & {1} & {2} & exit", genPalette, convGif, delPalett); String command = string.Format("/c start {0} /k \"{1}\"", ConfigUtil.CMD, options); CmdUtil.RunProcess(ConfigUtil.CMD, command); } else { MessageBox.Show("File already exists, " + fileGif); workThread.Abort(); } }
private void Pack() { var nugetExe = txtNugetPath.Text; _outputDir = _outputDir.Replace("\\\\", "\\"); var script = new StringBuilder(); script.AppendFormat( @"""{0}"" pack ""{1}"" -Build -Version ""{2}"" -Properties Configuration=Release -OutputDirectory ""{3} "" ", nugetExe, _project.FileName, _metadata.Version, _outputDir); if (chkForceEnglishOutput.Checked) { script.Append(" -ForceEnglishOutput "); } if (chkIncludeReferencedProjects.Checked) { script.Append(" -IncludeReferencedProjects "); } if (chkSymbol.Checked) { script.Append(" -Symbols "); } var deployVM = _deployControl.ViewModel; if (deployVM.NuGetServer.Length > 0) { script.AppendLine(); if (!string.IsNullOrWhiteSpace(deployVM.V2Login)) { script.AppendFormat(@"""{0}"" sources Add -Name ""{1}"" -Source ""{2}"" -Username ""{3}"" -Password ""{4}""", nugetExe, deployVM.NuGetServer, deployVM.NuGetServer, deployVM.V2Login, deployVM.ApiKey); script.AppendFormat(@" || ""{0}"" sources Update -Name ""{1}"" -Source ""{2}"" -Username ""{3}"" -Password ""{4}""", nugetExe, deployVM.NuGetServer, deployVM.NuGetServer, deployVM.V2Login, deployVM.ApiKey); script.AppendLine(); } script.AppendFormat("\"{0}\" push \"{1}{4}.{5}.nupkg\" -source {2} {3}", nugetExe, _outputDir, deployVM.NuGetServer, deployVM.ApiKey, _metadata.Id, _metadata.Version); } if (chkSymbol.Checked && !string.IsNullOrWhiteSpace(deployVM.SymbolServer)) { script.AppendLine(); script.AppendFormat("nuget SetApiKey {0}", deployVM.ApiKey); script.AppendLine(); script.AppendFormat("nuget push \"{0}{1}.{2}.symbols.nupkg\" -source {3}", _outputDir, _metadata.Id, _metadata.Version, deployVM.SymbolServer); } CmdUtil.RunCmd(script.ToString()); }
private void Pack() { var nugetExe = txtNugetPath.Text; //_outputDir = _outputDir.Replace("\\\\", "\\"); //this statement cause a bug of network path,see https://github.com/cnsharp/nupack/issues/20 var script = new StringBuilder(); script.AppendFormat( @"""{0}"" pack ""{1}"" -Build -Version ""{2}"" -Properties Configuration=Release -OutputDirectory ""{3}"" ", nugetExe, _project.FileName, _metadata.Version, _outputDir.TrimEnd('\\'));//nuget pack path shouldn't end with slash if (chkForceEnglishOutput.Checked) { script.Append(" -ForceEnglishOutput "); } if (chkIncludeReferencedProjects.Checked) { script.Append(" -IncludeReferencedProjects "); } if (chkSymbol.Checked) { script.Append(" -Symbols "); } var deployVM = _deployControl.ViewModel; if (deployVM.NuGetServer.Length > 0) { script.AppendLine(); if (!string.IsNullOrWhiteSpace(deployVM.V2Login)) { script.AppendFormat(@"""{0}"" sources Add -Name ""{1}"" -Source ""{2}"" -Username ""{3}"" -Password ""{4}""", nugetExe, deployVM.NuGetServer, deployVM.NuGetServer, deployVM.V2Login, deployVM.ApiKey); script.AppendFormat(@" || ""{0}"" sources Update -Name ""{1}"" -Source ""{2}"" -Username ""{3}"" -Password ""{4}""", nugetExe, deployVM.NuGetServer, deployVM.NuGetServer, deployVM.V2Login, deployVM.ApiKey); script.AppendLine(); } script.AppendFormat("\"{0}\" push \"{1}{4}.{5}.nupkg\" -source {2} {3}", nugetExe, _outputDir, deployVM.NuGetServer, deployVM.ApiKey, _metadata.Id, _metadata.Version); } if (chkSymbol.Checked && !string.IsNullOrWhiteSpace(deployVM.SymbolServer)) { script.AppendLine(); script.AppendFormat("\"{0}\" SetApiKey {1}", nugetExe, deployVM.ApiKey); script.AppendLine(); script.AppendFormat("\"{0}\" push \"{1}{2}.{3}.symbols.nupkg\" -source {4}", nugetExe, _outputDir, _metadata.Id, _metadata.Version, deployVM.SymbolServer); } CmdUtil.RunCmd(script.ToString()); }
public static void Main(string[] args) { Log.SetConsoleLogging(true, LogLevel.All); while (true) { Console.Write(".map file: "); try { string input = Console.ReadLine().Trim(); CmdUtil.Do(input); } catch (Exception e) { Log.Fatal(e.ToString()); break; } } Log.Error("Press any key to close the window"); Console.ReadLine(); }
private bool Pack() { var script = new StringBuilder(); script.AppendFormat(" \"{0}\" \"{1}\" /t:pack /p:Configuration=Release ", GetMsbuildPath(), _project.FileName); if (chkSymbol.Checked) { script.Append(" /p:IncludeSymbols=true "); } if (File.Exists(_nuspecFile)) { script.AppendFormat(" /p:NuspecFile=\"{0}\" ", _nuspecFile); } CmdUtil.RunCmd(script.ToString()); if (_metadata.Version.EndsWith(".*")) { var outputFileName = _project.Properties.Item("OutputFileName").Value.ToString(); var outputFile = Path.Combine(_releaseDir, outputFileName); _metadata.Version = FileVersionInfo.GetVersionInfo(outputFile).FileVersion; } var file = $"{_releaseDir}\\{_metadata.Id}.{_metadata.Version}.nupkg"; return(File.Exists(file)); }
static void Main(string[] args) { Console.Title = "QiNiu File Backup Tool"; ConsoleColor consoleColor = Console.ForegroundColor; if (args.Length < 2) { Console.WriteLine("Please input your qiniu username:"******"Please input your qiniu password:"******"login {username} {password}"); if (!string.IsNullOrWhiteSpace(loginOutput)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(loginOutput); return; } // check buckets var checkBucketsOutput = CmdUtil.Execute(qrsctl, "buckets"); var bucketMatch = bucketRegex.Match(checkBucketsOutput); if (!bucketMatch.Success) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(checkBucketsOutput); return; } var buckets = bucketMatch.Groups[1].Value.Split(' '); if (buckets.Length == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("No buckets."); return; } // list and download for (int i = 0; i < buckets.Length; i++) { var bucket = buckets[i]; var bucketDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, imagePath, bucket); if (!Directory.Exists(bucketDir)) { Directory.CreateDirectory(bucketDir); } var markersOutput = CmdUtil.Execute(qrsctl, $@"listprefix {bucket} """""); var markers = markersOutput.Split('\n', StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray(); if (markers.Length == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"No markers."); } else { Parallel.ForEach(markers, marker => { var markerDir = Path.Combine(bucketDir, marker); var downloadOutput = CmdUtil.Execute(qrsctl, $"get {bucket} {marker} {markerDir}"); if (downloadOutput != "\n") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Download {markerDir} failed:{downloadOutput}"); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"Download finished, bucket:{bucket}, marker:{marker}, target:{markerDir}"); } }); } } Console.ForegroundColor = consoleColor; Console.WriteLine("QiNiu File Backup Finished."); Console.ReadKey(); }
public static void AcquireUnity(string unityPoolDir, string unitySvnUrl, string unitySvnRev, out string unityExePath, out IFLock unityLock) { if (DoodleEnv.curPlatform != Platform.OSX) { throw new NssIntegrationException($"'{nameof(AcquireUnity)}'只能在OS X系统使用!"); } if (!Directory.Exists(unityPoolDir)) { throw new NotDirException(unityPoolDir, nameof(unityPoolDir)); } unityExePath = null; unityLock = null; // 遍历目录下所有Unity,返回可以得到写锁的那个 string unityAppPath = null; var rootDir = new DirectoryInfo(unityPoolDir); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IFLock flock = null; RepeateDo repeateDo = new RepeateDo(600); repeateDo.Do(() => { foreach (var dir in rootDir.GetDirectories("*.app")) { flock = FLockUtil.NewFLock(Path.Combine(unityPoolDir, dir.Name, "lock")); if (!flock.TryAcquireExclusiveLock()) { continue; } unityAppPath = Path.Combine(unityPoolDir, dir.Name, "Contents/MacOS/Unity"); break; } if (unityAppPath == null) { Logger.Log($"没有可用的Unity引擎,已等待{stopwatch.ElapsedMilliseconds / 1000 / 60}分钟..."); Thread.Sleep(60 * 1000); return(false); } return(true); }); repeateDo = new RepeateDo(5); repeateDo.IgnoreException <ExecutableException>(); repeateDo.Do(() => SvnUtil.Sync(unityAppPath, unitySvnUrl, unitySvnRev)); if (!flock.TryAcquireShareLock()) { throw new ImpossibleException($"之前已经获取了写锁了,获取读锁不可能失败!"); } // 赋执行权限 CmdUtil.Execute($"chmod -R +x {unityAppPath}"); unityExePath = Path.Combine(unityAppPath, "Contents/MacOS/Unity"); unityLock = flock; return; }
public string Play() { if (!SteamUtil.IsSteamRunning()) { return("Steam must be opened to play Left 4 Dead 2 splitScreen"); } using (Stream videoStream = new FileStream(videoFile, FileMode.Open)) { videoCfg = new SourceCfgFile(videoStream); } string originalCFG = String.Copy(videoCfg.RawData); // minimize everything User32.MinimizeEverything(); Screen[] allScreens = Screen.AllScreens; string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string l4dFolder = Path.GetDirectoryName(executablePlace); int gamePadId = 0; if (instances) { for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; Screen screen = allScreens[p.ScreenIndex]; int width = 0; int height = 0; Rectangle bounds = screen.Bounds; Point location = new Point(); ViewportUtil.GetPlayerViewport(p, 0, out width, out height, out location); CultureInfo c = CultureInfo.InvariantCulture; UpdateVideoCfg(width.ToString(c), height.ToString(c), "0", "1"); if (i == 0) { MakeAutoExecServer(); } else { MakeAutoExecClient(); } MakeMakeSplit(); string execPlace = executablePlace; string l4dBinFolder; if (i == 0) { l4dBinFolder = Path.Combine(l4dFolder, "bin"); } else { string l4d = Path.Combine(folder, "L4D2_" + (i + 1)); Directory.CreateDirectory(l4d); int exitCode; #region mklink CmdUtil.ExecuteCommand(l4d, out exitCode, "mklink /d \"" + Path.Combine(l4d, "config") + "\" \"" + Path.Combine(l4dFolder, "config") + "\"", "mklink /d \"" + Path.Combine(l4d, "hl2") + "\" \"" + Path.Combine(l4dFolder, "hl2") + "\"", "mklink /d \"" + Path.Combine(l4d, "left4dead2") + "\" \"" + Path.Combine(l4dFolder, "left4dead2") + "\"", "mklink /d \"" + Path.Combine(l4d, "left4dead2_dlc1") + "\" \"" + Path.Combine(l4dFolder, "left4dead2_dlc1") + "\"", "mklink /d \"" + Path.Combine(l4d, "left4dead2_dlc2") + "\" \"" + Path.Combine(l4dFolder, "left4dead2_dlc2") + "\"", "mklink /d \"" + Path.Combine(l4d, "left4dead2_dlc3") + "\" \"" + Path.Combine(l4dFolder, "left4dead2_dlc3") + "\"", "mklink /d \"" + Path.Combine(l4d, "platform") + "\" \"" + Path.Combine(l4dFolder, "platform") + "\"", "mklink /d \"" + Path.Combine(l4d, "RemStorage") + "\" \"" + Path.Combine(l4dFolder, "RemStorage") + "\"", "mklink /d \"" + Path.Combine(l4d, "update") + "\" \"" + Path.Combine(l4dFolder, "update") + "\""); #endregion // copy executable File.Copy(Path.Combine(l4dFolder, "left4dead2.exe"), Path.Combine(l4d, "left4dead2.exe"), true); // make bin folder now l4dBinFolder = Path.Combine(l4d, "bin"); string originalBinFolder = Path.Combine(l4dFolder, "bin"); Directory.CreateDirectory(l4dBinFolder); #region mklink CmdUtil.ExecuteCommand(l4d, out exitCode, "mklink /d \"" + Path.Combine(l4dBinFolder, "dedicated") + "\" \"" + Path.Combine(originalBinFolder, "dedicated") + "\"", "mklink /d \"" + Path.Combine(l4dBinFolder, "linux32") + "\" \"" + Path.Combine(originalBinFolder, "linux32") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "addoninstaller.exe") + "\" \"" + Path.Combine(originalBinFolder, "addoninstaller.exe") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "addoninstaller_osx") + "\" \"" + Path.Combine(originalBinFolder, "addoninstaller_osx") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "adminserver.dll") + "\" \"" + Path.Combine(originalBinFolder, "adminserver.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "binkw32.dll") + "\" \"" + Path.Combine(originalBinFolder, "binkw32.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "bsppack.dll") + "\" \"" + Path.Combine(originalBinFolder, "bsppack.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "bugreporter.dll") + "\" \"" + Path.Combine(originalBinFolder, "bugreporter.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "bugreporter_public.dll") + "\" \"" + Path.Combine(originalBinFolder, "bugreporter_public.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "chromehtml.dll") + "\" \"" + Path.Combine(originalBinFolder, "chromehtml.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "config.SoftTHconfig") + "\" \"" + Path.Combine(originalBinFolder, "config.SoftTHconfig") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "crashhandler.dll") + "\" \"" + Path.Combine(originalBinFolder, "crashhandler.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "datacache.dll") + "\" \"" + Path.Combine(originalBinFolder, "datacache.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "dxsupport.cfg") + "\" \"" + Path.Combine(originalBinFolder, "dxsupport.cfg") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "dxsupport_episodic.cfg") + "\" \"" + Path.Combine(originalBinFolder, "dxsupport_episodic.cfg") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "dxsupport_mac.cfg") + "\" \"" + Path.Combine(originalBinFolder, "dxsupport_mac.cfg") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "engine.dll") + "\" \"" + Path.Combine(originalBinFolder, "engine.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "export_entity_group.pl") + "\" \"" + Path.Combine(originalBinFolder, "export_entity_group.pl") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "export_entity_layer.pl") + "\" \"" + Path.Combine(originalBinFolder, "export_entity_layer.pl") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "filesystemopendialog.dll") + "\" \"" + Path.Combine(originalBinFolder, "filesystemopendialog.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "filesystem_stdio.dll") + "\" \"" + Path.Combine(originalBinFolder, "filesystem_stdio.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "GameOverlayRenderer.log") + "\" \"" + Path.Combine(originalBinFolder, "GameOverlayRenderer.log") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "gameui.dll") + "\" \"" + Path.Combine(originalBinFolder, "gameui.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "hl_ent.cnt") + "\" \"" + Path.Combine(originalBinFolder, "hl_ent.cnt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "icudt.dll") + "\" \"" + Path.Combine(originalBinFolder, "icudt.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "icudt42.dll") + "\" \"" + Path.Combine(originalBinFolder, "icudt42.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "inputsystem.dll") + "\" \"" + Path.Combine(originalBinFolder, "inputsystem.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "launcher.dll") + "\" \"" + Path.Combine(originalBinFolder, "launcher.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "libcef.dll") + "\" \"" + Path.Combine(originalBinFolder, "libcef.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "libmysql.dll") + "\" \"" + Path.Combine(originalBinFolder, "libmysql.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "maplist_terror.txt") + "\" \"" + Path.Combine(originalBinFolder, "maplist_terror.txt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "materialsystem.dll") + "\" \"" + Path.Combine(originalBinFolder, "materialsystem.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "mdllib.dll") + "\" \"" + Path.Combine(originalBinFolder, "mdllib.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "mss32.dll") + "\" \"" + Path.Combine(originalBinFolder, "mss32.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "mssdolby.flt") + "\" \"" + Path.Combine(originalBinFolder, "mssdolby.flt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "mssds3d.flt") + "\" \"" + Path.Combine(originalBinFolder, "mssds3d.flt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "mssdsp.flt") + "\" \"" + Path.Combine(originalBinFolder, "mssdsp.flt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "msseax.flt") + "\" \"" + Path.Combine(originalBinFolder, "msseax.flt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "mssmp3.asi") + "\" \"" + Path.Combine(originalBinFolder, "mssmp3.asi") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "msssrs.flt") + "\" \"" + Path.Combine(originalBinFolder, "msssrs.flt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "msvcr71.dll") + "\" \"" + Path.Combine(originalBinFolder, "msvcr71.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "parsifal.dll") + "\" \"" + Path.Combine(originalBinFolder, "parsifal.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "rdmwin32.dll") + "\" \"" + Path.Combine(originalBinFolder, "rdmwin32.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "scenefilecache.dll") + "\" \"" + Path.Combine(originalBinFolder, "scenefilecache.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "serverbrowser.dll") + "\" \"" + Path.Combine(originalBinFolder, "serverbrowser.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "serverplugin_empty.dll") + "\" \"" + Path.Combine(originalBinFolder, "serverplugin_empty.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "shaderapidx10.dll") + "\" \"" + Path.Combine(originalBinFolder, "shaderapidx10.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "shaderapidx9.dll") + "\" \"" + Path.Combine(originalBinFolder, "shaderapidx9.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "shaderapiempty.dll") + "\" \"" + Path.Combine(originalBinFolder, "shaderapiempty.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "soundemittersystem.dll") + "\" \"" + Path.Combine(originalBinFolder, "soundemittersystem.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "soundsystem.dll") + "\" \"" + Path.Combine(originalBinFolder, "soundsystem.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "stats.bin") + "\" \"" + Path.Combine(originalBinFolder, "stats.bin") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "stdshader_dbg.dll") + "\" \"" + Path.Combine(originalBinFolder, "stdshader_dbg.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "stdshader_dx9.dll") + "\" \"" + Path.Combine(originalBinFolder, "stdshader_dx9.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "Steam.dll") + "\" \"" + Path.Combine(originalBinFolder, "Steam.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "steamclient.dll") + "\" \"" + Path.Combine(originalBinFolder, "steamclient.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "steamclient_l4d2.dll") + "\" \"" + Path.Combine(originalBinFolder, "steamclient_l4d2.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "steam_api.dll") + "\" \"" + Path.Combine(originalBinFolder, "steam_api.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "steam_appid.txt") + "\" \"" + Path.Combine(originalBinFolder, "steam_appid.txt") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "Steam_l4d2.dll") + "\" \"" + Path.Combine(originalBinFolder, "Steam_l4d2.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "studiorender.dll") + "\" \"" + Path.Combine(originalBinFolder, "studiorender.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "texturecompile_dll.dll") + "\" \"" + Path.Combine(originalBinFolder, "texturecompile_dll.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "tier0.dll") + "\" \"" + Path.Combine(originalBinFolder, "tier0.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "tier0_s.dll") + "\" \"" + Path.Combine(originalBinFolder, "tier0_s.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "unicode.dll") + "\" \"" + Path.Combine(originalBinFolder, "unicode.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "unicows.dll") + "\" \"" + Path.Combine(originalBinFolder, "unicows.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "unitlib.dll") + "\" \"" + Path.Combine(originalBinFolder, "unitlib.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "valve_avi.dll") + "\" \"" + Path.Combine(originalBinFolder, "valve_avi.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vaudio_miles.dll") + "\" \"" + Path.Combine(originalBinFolder, "vaudio_miles.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vaudio_speex.dll") + "\" \"" + Path.Combine(originalBinFolder, "vaudio_speex.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vgui2.dll") + "\" \"" + Path.Combine(originalBinFolder, "vgui2.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vguimatsurface.dll") + "\" \"" + Path.Combine(originalBinFolder, "vguimatsurface.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vidcfg.bin") + "\" \"" + Path.Combine(originalBinFolder, "vidcfg.bin") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vphysics.dll") + "\" \"" + Path.Combine(originalBinFolder, "vphysics.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vscript.dll") + "\" \"" + Path.Combine(originalBinFolder, "vscript.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vstdlib.dll") + "\" \"" + Path.Combine(originalBinFolder, "vstdlib.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vstdlib_s.dll") + "\" \"" + Path.Combine(originalBinFolder, "vstdlib_s.dll") + "\"", "mklink \"" + Path.Combine(l4dBinFolder, "vtex_dll.dll") + "\" \"" + Path.Combine(originalBinFolder, "vtex_dll.dll") + "\""); #endregion execPlace = Path.Combine(l4d, "left4dead2.exe"); } if ((int)keyboardId == i) { // delete if there are any xinput string xinputPath = Path.Combine(l4dBinFolder, "xinput1_3.dll"); if (File.Exists(xinputPath)) { File.Delete(xinputPath); } } else { // copy the correct xinput to the bin folder byte[] xdata = null; switch (gamePadId) { case 0: xdata = Nucleus.Coop.Games.GamesResources._1_xinput1_3; break; case 1: xdata = Nucleus.Coop.Games.GamesResources._2_xinput1_3; break; case 2: xdata = Nucleus.Coop.Games.GamesResources._3_xinput1_3; break; case 3: xdata = Nucleus.Coop.Games.GamesResources._4_xinput1_3; break; default: xdata = Nucleus.Coop.Games.GamesResources._4_xinput1_3; break; } string xinputPath = Path.Combine(l4dBinFolder, "xinput1_3.dll"); using (MemoryStream stream = new MemoryStream(xdata)) { // write to bin folder using (FileStream file = new FileStream(xinputPath, FileMode.Create)) { stream.CopyTo(file); } } gamePadId++; } int pid = StartGameUtil.StartGame(execPlace, "-novid -insecure", delayTime, "hl2_singleton_mutex", "steam_singleton_mutext"); Process proc = Process.GetProcessById(pid); HwndObject hwnd = new HwndObject(proc.Handle); ScreenData data = new ScreenData(); data.Position = location; data.HWND = hwnd; data.Size = new Size(width, height); p.Process = proc; p.Tag = data; Thread.Sleep(delayTime); //uint processHandle; //IntPtr windowHandle = proc.MainWindowHandle; //uint threadID = User32.GetWindowThreadProcessId(windowHandle, out processHandle); //bool installed = InstallHook(threadID); } } else { List <DuetPlayerInfo> duets = ViewportUtil.GetPlayerDuets(players); for (int i = 0; i < duets.Count; i++) { DuetPlayerInfo duet = duets[i]; } } int screenIndex = -1; bool twoScreens = false; int fullWidth = 0; int fullHeight = 0; for (int i = 0; i < players.Count; i++) { PlayerInfo player = players[i]; Screen scr = allScreens[player.ScreenIndex]; if (screenIndex == -1) { screenIndex = player.ScreenIndex; fullWidth = scr.Bounds.Width; fullHeight = scr.Bounds.Height; } else { if (screenIndex != player.ScreenIndex) { twoScreens = true; // Add 2nd monitor fullWidth += scr.Bounds.Width; } } } loaded = true; return(""); string fWidth = fullWidth.ToString(); string fHeight = fullHeight.ToString(); string fullScr = (0).ToString(); string noWindowBorderStr = (1).ToString(); //if (players.Count == 1) //{ // // 1 monitor // Screen monitor = allScreens[players.First().Key]; // fWidth = monitor.Bounds.Width.ToString(CultureInfo.InvariantCulture); // fHeight = monitor.Bounds.Height.ToString(CultureInfo.InvariantCulture); // fullScr = (0).ToString(); // noWindowBorderStr = (1).ToString(); //} //else //{ // // 2 or more monitors // //?? // fullScr = (1).ToString(); // noWindowBorderStr = (0).ToString(); //} fWidth = "1920";// 960x540 fHeight = "540"; string d3d9Path = binFolder + @"\d3d9.dll"; // SoftTH if (twoScreens) { // Copy SoftTH to the game folder // Get the SoftTH stream if (!File.Exists(d3d9Path)) { using (MemoryStream stream = new MemoryStream(Nucleus.Coop.Games.GamesResources.d3d9)) { // write to bin folder using (FileStream file = new FileStream(d3d9Path, FileMode.Create)) { stream.CopyTo(file); } } } } else { // Delete SoftTH from the game folder FileInfo file = new FileInfo(d3d9Path); // Only delete if it's not read only if (File.Exists(d3d9Path)) { File.Delete(d3d9Path); } } // PAK hex edit if (twoScreens) { FileInfo f = new FileInfo(pak01_000_path); if (!f.IsReadOnly) { // make a backup of pak01_000, if it isn't already made string dir = Path.GetDirectoryName(backupPak); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (!File.Exists(backupPak)) { File.Copy(pak01_000_path, backupPak); } using (FileStream str = File.OpenRead(backupPak)) { // Now modify some stuff // Eat Point that comes at 29.664.480 // The 8 is at position 29.664.483 // 29.675.904 byte one = 49; byte six = 54; using (FileStream stream = new FileStream(pak01_000_path, FileMode.Create)) { byte[] buff = new byte[4096]; int point = 29664480; while (str.Position < point) { int length = 4096; if (point - str.Position < length) { length = (int)(point - str.Position); } str.Read(buff, 0, length); stream.Write(buff, 0, length); } // Jumps 1 byte str.Position += 1; str.Read(buff, 0, 2); stream.Write(buff, 0, 2); // Jumps the 8 str.Position += 1; buff[0] = one; buff[1] = six; stream.Write(buff, 0, 2); while (stream.Position < str.Length) { int length = 4096; if (str.Length - str.Position < length) { length = (int)(str.Length - str.Position); } str.Read(buff, 0, length); stream.Write(buff, 0, length); } } } f.IsReadOnly = true; } } //else //{ // if (File.Exists(backupPak)) // { // if (File.Exists(pak01_000)) // { // FileInfo f = new FileInfo(pak01_000); // f.IsReadOnly = false; // File.Delete(pak01_000); // } // File.Copy(backupPak, pak01_000); // } //} int splitMode = 1; for (int i = 0; i < players.Count; i++) { PlayerInfo player = players[i]; if (player.ScreenType == ScreenType.HorizontalBottom || player.ScreenType == ScreenType.HorizontalTop) { splitMode = 1; } else { splitMode = 2; } } MakeAutoExecSplitscreen(splitMode.ToString(CultureInfo.InvariantCulture)); MakeMakeSplit(); /* if (player.ScreenType == ScreenType.VerticalLeft || * player.ScreenType == ScreenType.VerticalRight)*/ //ss_splitmode 1 = horizontal //ss_splitmode 2 = vertical //ProcessStartInfo startInfo = new ProcessStartInfo(); //startInfo.FileName = executablePlace; //startInfo.WindowStyle = ProcessWindowStyle.Hidden; //MessageBox.Show("Press the F8 key after the game is loaded to begin splitscreen!"); //proc = Process.Start(startInfo); return(string.Empty); }
public static void LinkFiles(string rootFolder, string destination, out int exitCode, string[] exclusions, string[] copyInstead, bool hardLink) { exitCode = 1; FileInfo[] files = new DirectoryInfo(rootFolder).GetFiles(); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; string lower = file.Name.ToLower(); bool exclude = false; if (!string.IsNullOrEmpty(exclusions[0])) { for (int j = 0; j < exclusions.Length; j++) { string exc = exclusions[j]; if (!string.IsNullOrEmpty(exc) && lower.Contains(exc)) { // check if the file is i exclude = true; break; } } } if (exclude) { continue; } if (!string.IsNullOrEmpty(copyInstead[0])) { for (int j = 0; j < copyInstead.Length; j++) { string copy = copyInstead[j]; if (!string.IsNullOrEmpty(copy) && lower.Contains(copy)) { exclude = true; break; } } } string relative = file.FullName.Replace(rootFolder + @"\", ""); string linkPath = Path.Combine(destination, relative); if (exclude) { // should copy! try { File.Copy(file.FullName, linkPath, true); } catch (Exception ex) { CmdUtil.ExecuteCommand(Path.GetDirectoryName(linkPath), out int exitCode2, "copy \"" + file.FullName + "\" \"" + linkPath + "\""); } //CopyFile(file.FullName, linkPath); } else { //CmdUtil.MkLinkFile(file.FullName, linkPath, out exitCode); if (hardLink) { Kernel32Interop.CreateHardLink(linkPath, file.FullName, IntPtr.Zero); } else { Kernel32Interop.CreateSymbolicLink(linkPath, file.FullName, Nucleus.Gaming.Platform.Windows.Interop.SymbolicLink.File); } } } }
public override void PrePlayPlayer(PlayerInfo playerInfo, int index, HandlerContext context) { if (handlerData.SymlinkGame || handlerData.HardcopyGame) { List <string> dirExclusions = new List <string>(); List <string> fileExclusions = new List <string>(); List <string> fileCopies = new List <string>(); // symlink the game folder (and not the bin folder, if we have one) linkFolder = Path.Combine(tempDir, "Instance" + index); Directory.CreateDirectory(linkFolder); linkBinFolder = linkFolder; if (!string.IsNullOrEmpty(handlerData.BinariesFolder)) { linkBinFolder = Path.Combine(linkFolder, handlerData.BinariesFolder); dirExclusions.Add(handlerData.BinariesFolder); } exePath = Path.Combine(linkBinFolder, Path.GetFileName(this.userGame.ExePath)); if (!string.IsNullOrEmpty(handlerData.WorkingFolder)) { linkBinFolder = Path.Combine(linkFolder, handlerData.WorkingFolder); dirExclusions.Add(handlerData.WorkingFolder); } // some games have save files inside their game folder, so we need to access them inside the loop handlerData.RegisterAdditional(Folder.InstancedGameFolder.ToString(), linkFolder); if (handlerData.Hook.CustomDllEnabled) { fileExclusions.Add("xinput1_3.dll"); fileExclusions.Add("ncoop.ini"); } if (!handlerData.SymlinkExe) { fileCopies.Add(handlerData.ExecutableName.ToLower()); } // additional ignored files by the generic info if (handlerData.FileSymlinkExclusions != null) { string[] symlinkExclusions = handlerData.FileSymlinkExclusions; for (int k = 0; k < symlinkExclusions.Length; k++) { string s = symlinkExclusions[k]; // make sure it's lower case fileExclusions.Add(s.ToLower()); } } if (handlerData.FileSymlinkCopyInstead != null) { string[] fileSymlinkCopyInstead = handlerData.FileSymlinkCopyInstead; for (int k = 0; k < fileSymlinkCopyInstead.Length; k++) { string s = fileSymlinkCopyInstead[k]; // make sure it's lower case fileCopies.Add(s.ToLower()); } } if (handlerData.DirSymlinkExclusions != null) { string[] symlinkExclusions = handlerData.DirSymlinkExclusions; for (int k = 0; k < symlinkExclusions.Length; k++) { string s = symlinkExclusions[k]; // make sure it's lower case dirExclusions.Add(s.ToLower()); } } string[] fileExclusionsArr = fileExclusions.ToArray(); string[] fileCopiesArr = fileCopies.ToArray(); if (handlerData.HardcopyGame) { // copy the directory //int exitCode; //FileUtil.CopyDirectory(rootFolder, new DirectoryInfo(rootFolder), linkFolder, out exitCode, dirExclusions.ToArray(), fileExclusionsArr, true); } else { int exitCode; CmdUtil.LinkDirectory(rootFolder, new DirectoryInfo(rootFolder), linkFolder, out exitCode, dirExclusions.ToArray(), fileExclusionsArr, fileCopiesArr, true); if (!handlerData.SymlinkExe) { //File.Copy(userGame.ExePath, exePath, true); } } } else { exePath = userGame.ExePath; linkBinFolder = rootFolder; linkFolder = workingFolder; } context.ExePath = exePath; context.RootInstallFolder = exeFolder; context.RootFolder = linkFolder; }
private static IEnumerator Send(WWWForm form, EnumHTTPHead head) { string url = "http://" + ip + ":" + port + "/" + GetHeadString(head); WWW www = new WWW(url, form.data, cookies); //Debug.Log("request http url " + url + " cmdID, " + _cmdFormDic[form]); yield return(www); int cmdID = _cmdFormDic[form]; _cmdFormDic.Remove(form); if (www.error != null) { Debug.Log("serch fail..."); } else if (www.isDone) { if (www.bytes.Length == 0) { HttpEvent evt = new HttpEvent(cmdID.ToString()); _dispatcher.DispatchEventInstance(evt); yield break; } ByteArray receiveBytes = new ByteArray(); receiveBytes.WriteBytes(www.bytes); ReceivePackage pack = CmdUtil.ParseCmd(receiveBytes); if (pack.CmdID == (int)MsgType.ErrorMsg) { RetErrorMsg errorMsg = ProtoBuf.Serializer.Deserialize <RetErrorMsg>(pack.BodyStream); if (errorMsg.RetCode == 0) { Debug.Log("response http url success" + url); HttpEvent evt = new HttpEvent(cmdID.ToString()); _dispatcher.DispatchEventInstance(evt); } else { if (LoginServerErrorCode.ErrorCodeName == errorMsg.RetCode) { PopManager.ShowSimpleItem("用户名最多为4个汉字或8个英文字符"); } else if (LoginServerErrorCode.ErrorCodeAuthErr == errorMsg.RetCode) { PopManager.ShowSimpleItem("验证码错误,还可以输入" + errorMsg.Params + "次"); } else if (LoginServerErrorCode.ErrorCodeDb == errorMsg.RetCode) { PopManager.ShowSimpleItem("设置密码错误"); } else if (LoginServerErrorCode.ErrorCodePass == errorMsg.RetCode) { if (cmdID == (int)MsgType.CheckOldPassword) { PopManager.ShowSimpleItem("密码错误"); } else { PopManager.ShowSimpleItem("账号或密码错误"); } } else if (LoginServerErrorCode.ErrorCodeParam == errorMsg.RetCode) { if (cmdID == (int)MsgType.ChangePasswd || cmdID == (int)MsgType.SetPasswd || cmdID == (int)MsgType.CheckOldPassword) { PopManager.ShowSimpleItem("密码复杂度不够"); } else if (cmdID == (int)MsgType.AuthCode) { PopManager.ShowSimpleItem("获取验证码过于频繁"); HttpEvent evt = new HttpEvent(MsgType.ErrorMsg.ToString()); _dispatcher.DispatchEventInstance(evt); } else { PopManager.ShowSimpleItem("参数错误"); } } else if (LoginServerErrorCode.ErrorCodeIsBind == errorMsg.RetCode) { PopManager.ShowSimpleItem("手机号已被绑定"); } else if (LoginServerErrorCode.ErrorCodeMsgErr == errorMsg.RetCode) { PopManager.ShowSimpleItem("短信服务器出错"); } else if (LoginServerErrorCode.ErrorCodeTelErr == errorMsg.RetCode) { PopManager.ShowSimpleItem("手机号错误"); } else if (LoginServerErrorCode.ErrorCodeMaxMsg == errorMsg.RetCode) { PopManager.ShowSimpleItem("今天短信次数已用完"); } else if (LoginServerErrorCode.ErrorCodeMaxErr == errorMsg.RetCode) { PopManager.ShowSimpleItem("密码错误已超过最大限制"); } else if (LoginServerErrorCode.ErrorCodeExist == errorMsg.RetCode) { PopManager.ShowSimpleItem("用户名已存在"); } else if (LoginServerErrorCode.ErrorCodeUnBind == errorMsg.RetCode) { PopManager.ShowSimpleItem("未绑定手机"); } else if (LoginServerErrorCode.ErrorCodeSetAccountTm == errorMsg.RetCode) { ulong leftDays = errorMsg.Params / (24 * 60 * 60); if (leftDays >= 1) { PopManager.ShowSimpleItem("还需 " + (uint)leftDays + "天才可以修改用户名"); } else { ulong leftHours = errorMsg.Params / (60 * 60); if (leftHours >= 1) { PopManager.ShowSimpleItem("还需 " + (uint)leftHours + "小时才可以修改用户名"); } else { PopManager.ShowSimpleItem("还需 " + (uint)(errorMsg.Params / 60) + "分钟才可以修改用户名"); } } } else if (LoginServerErrorCode.ErrorCodeSignReward == errorMsg.RetCode) { PopManager.ShowSimpleItem("签到奖励领取失败"); } else if (LoginServerErrorCode.ErrorCodeSignIned == errorMsg.RetCode) { PopManager.ShowSimpleItem("已签到"); } else if (LoginServerErrorCode.ErrorCodeRoom == errorMsg.RetCode) { PopManager.ShowSimpleItem("未找到房间"); } else if (LoginServerErrorCode.ErrorCodeIsFull == errorMsg.RetCode) { PopManager.ShowSimpleItem("目标房间已满"); } else if (LoginServerErrorCode.ErrorCodeDb == errorMsg.RetCode) { PopManager.ShowSimpleItem("数据库错误"); } Log("http cmd error code:" + errorMsg.RetCode + " para:" + errorMsg.Params); } } else { Log("response http url success " + url + " CmdID:" + (MsgType)pack.CmdID); HttpEvent evt = new HttpEvent(pack.CmdID.ToString(), pack.BodyStream); _dispatcher.DispatchEventInstance(evt); } } }
public string Play() { if (!SteamUtil.IsSteamRunning()) { MessageBox.Show("If you own the Steam Version, please open Steam, then click OK"); } var options = profile.Options; KeyboardPlayer playerKeyboard = (KeyboardPlayer)profile.Options["keyboardPlayer"]; int pKeyboard = (int)playerKeyboard; IniFile file = new IniFile(saveFile); file.IniWriteValue("SystemSettings", "WindowedFullscreen", "False"); file.IniWriteValue("SystemSettings", "Fullscreen", "False"); file.IniWriteValue("Engine.Engine", "bMuteAudioWhenNotInFocus", "False"); file.IniWriteValue("Engine.Engine", "bPauseOnLossOfFocus", "False"); file.IniWriteValue("WillowGame.WillowGameEngine", "bPauseLostFocusWindowed", "False"); file.IniWriteValue("WillowGame.WillowGameEngine", "bMuteAudioWhenNotInFocus", "False"); Screen[] all = Screen.AllScreens; // minimize everything //User32.MinimizeEverything(); List <PlayerInfo> players = profile.PlayerData; string backupDir = GameManager.Instance.GetBackupFolder(this.userGame.Game); string binFolder = Path.GetDirectoryName(executablePlace); string rootFolder = Path.GetDirectoryName( Path.GetDirectoryName(binFolder)); int gamePadId = 0; for (int i = 0; i < players.Count; i++) { string linkFolder = Path.Combine(backupDir, "Instance" + i); PlayerInfo player = players[i]; // Set Borderlands 2 Resolution and stuff to run Rectangle playerBounds = player.monitorBounds; // find the monitor that has this screen Screen owner = null; for (int j = 0; j < all.Length; j++) { Screen s = all[j]; if (s.Bounds.Contains(playerBounds)) { owner = s; break; } } int width = playerBounds.Width; int height = playerBounds.Height; if (owner == null) { // log // screen doesn't exist //continue; } else { Rectangle ob = owner.Bounds; if (playerBounds.X == ob.X && playerBounds.Y == ob.Y && playerBounds.Width == ob.Width && playerBounds.Height == ob.Height) { // borderlands 2 has a limitation for max-screen size, we can't go up to the monitor's bounds // in windowed mode file.IniWriteValue("SystemSettings", "WindowedFullscreen", "True"); } else { file.IniWriteValue("SystemSettings", "WindowedFullscreen", "False"); } } file.IniWriteValue("SystemSettings", "ResX", width.ToString(CultureInfo.InvariantCulture)); file.IniWriteValue("SystemSettings", "ResY", height.ToString(CultureInfo.InvariantCulture)); // Link-making Directory.CreateDirectory(linkFolder); int exitCode; CmdUtil.LinkDirectories(rootFolder, linkFolder, out exitCode, "binaries"); string linkBin = Path.Combine(linkFolder, @"Binaries\Win32"); Directory.CreateDirectory(linkBin); CmdUtil.LinkDirectories(binFolder, linkBin, out exitCode); CmdUtil.LinkFiles(binFolder, linkBin, out exitCode, "xinput", "borderlands"); string exePath = Path.Combine(linkBin, this.userGame.Game.ExecutableName); File.Copy(this.executablePlace, exePath, true); // Link-end ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = exePath; startInfo.WindowStyle = ProcessWindowStyle.Hidden; // NEW object option = options["saveid" + i]; //object option = 11; int id = (int)option; if (i == pKeyboard) { startInfo.Arguments = "-AlwaysFocus -NoController -SaveDataId=" + id.ToString(CultureInfo.InvariantCulture); } else { byte[] xdata = null; switch (gamePadId) { case 0: xdata = Nucleus.Coop.Games.GamesResources.xinput1; break; case 1: xdata = Nucleus.Coop.Games.GamesResources.xinput2; break; case 2: xdata = Nucleus.Coop.Games.GamesResources.xinput3; break; case 3: xdata = Nucleus.Coop.Games.GamesResources.xinput4; break; default: xdata = Nucleus.Coop.Games.GamesResources.xinput4; break; } using (Stream str = File.OpenWrite(Path.Combine(linkBin, "xinput1_3.dll"))) { str.Write(xdata, 0, xdata.Length); } startInfo.Arguments = "-AlwaysFocus -nostartupmovies -SaveDataId=" + id.ToString(CultureInfo.InvariantCulture); gamePadId++; } startInfo.UseShellExecute = true; startInfo.WorkingDirectory = Path.GetDirectoryName(exePath); Process proc = Process.Start(startInfo); ScreenData data = new ScreenData(); data.Position = new Point(playerBounds.X, playerBounds.Y); data.Size = new Size(playerBounds.Width, playerBounds.Height); player.Process = proc; player.Tag = data; } return(string.Empty); }