public override void PlayPlayer(int index, HandlerContext context) { Process proc; IOModule ioModule = handler.GetModule <IOModule>(Player); string startArgs = context.StartArguments; string startingApp = ioModule.LinkedExePath; if (!string.IsNullOrEmpty(context.OverrideStartProcess)) { startingApp = context.OverrideStartProcess; } if (context.KillMutex?.Length > 0) { int processId = StartGameUtil.StartGame(startingApp, startArgs, ioModule.LinkedWorkingDir); proc = Process.GetProcessById(processId); } else { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = startingApp; //startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.Arguments = startArgs; startInfo.UseShellExecute = true; startInfo.WorkingDirectory = Path.GetDirectoryName(ioModule.LinkedExePath); proc = Process.Start(startInfo); } if (proc == null) { for (int times = 0; times < 200; times++) { Thread.Sleep(50); Process[] procs = Process.GetProcesses(); string proceName = Path.GetFileNameWithoutExtension(context.ExecutableName).ToLower(); string launcherName = string.IsNullOrEmpty(context.LauncherExe) ? string.Empty : Path.GetFileNameWithoutExtension(context.LauncherExe).ToLower(); for (int j = 0; j < procs.Length; j++) { Process p = procs[j]; string lowerP = p.ProcessName.ToLower(); if (((lowerP == proceName) || lowerP == launcherName) && !attached.Contains(p)) { attached.Add(p); proc = p; break; } } if (proc != null) { break; } } } else { attached.Add(proc); } ProcessInfo data = new ProcessInfo(proc); Rectangle playerBounds = Player.MonitorBounds; UserScreen owner = Player.Owner; int width = playerBounds.Width; int height = playerBounds.Height; data.Position = new Point(playerBounds.X, playerBounds.Y); data.Size = new Size(playerBounds.Width, playerBounds.Height); data.KilledMutexes = context.KillMutex?.Length == 0; Player.ProcessData = data; }
public override void PlayPlayer(PlayerInfo playerInfo, int index, HandlerContext context) { if (!context.Hook.CustomDllEnabled) { return; } IOModule ioModule = handler.GetModule <IOModule>(); byte[] xdata = Properties.Resources.xinput1_3; if (context.Hook.XInputNames == null) { using (Stream str = File.OpenWrite(Path.Combine(ioModule.LinkedBinFolder, "xinput1_3.dll"))) { str.Write(xdata, 0, xdata.Length); } } else { string[] xinputs = context.Hook.XInputNames; for (int z = 0; z < xinputs.Length; z++) { string xinputName = xinputs[z]; using (Stream str = File.OpenWrite(Path.Combine(ioModule.LinkedBinFolder, xinputName))) { str.Write(xdata, 0, xdata.Length); } } } Rectangle playerBounds = playerInfo.MonitorBounds; string ncoopIni = Path.Combine(ioModule.LinkedBinFolder, "ncoop.ini"); using (Stream str = File.OpenWrite(ncoopIni)) { byte[] ini = Properties.Resources.ncoop; str.Write(ini, 0, ini.Length); } IniFile x360 = new IniFile(ncoopIni); x360.IniWriteValue("Options", "ForceFocus", handlerData.Hook.ForceFocus.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "ForceFocusWindowName", handlerData.Hook.ForceFocusWindowName.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "WindowX", playerBounds.X.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "WindowY", playerBounds.Y.ToString(CultureInfo.InvariantCulture)); if (context.Hook.SetWindowSize) { x360.IniWriteValue("Options", "ResWidth", context.Width.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "ResHeight", context.Height.ToString(CultureInfo.InvariantCulture)); } else { x360.IniWriteValue("Options", "ResWidth", "0"); x360.IniWriteValue("Options", "ResHeight", "0"); } x360.IniWriteValue("Options", "RerouteInput", context.Hook.XInputReroute.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "RerouteJoystickTemplate", JoystickDatabase.GetID(playerInfo.GamepadProductGuid.ToString()).ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "EnableMKBInput", playerInfo.IsKeyboardPlayer.ToString(CultureInfo.InvariantCulture)); // windows events x360.IniWriteValue("Options", "BlockInputEvents", context.Hook.BlockInputEvents.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "BlockMouseEvents", context.Hook.BlockMouseEvents.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "BlockKeyboardEvents", context.Hook.BlockKeyboardEvents.ToString(CultureInfo.InvariantCulture)); // xinput x360.IniWriteValue("Options", "XInputEnabled", context.Hook.XInputEnabled.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "XInputPlayerID", playerInfo.GamepadId.ToString(CultureInfo.InvariantCulture)); // dinput x360.IniWriteValue("Options", "DInputEnabled", context.Hook.DInputEnabled.ToString(CultureInfo.InvariantCulture)); x360.IniWriteValue("Options", "DInputGuid", playerInfo.GamepadGuid.ToString().ToUpper()); x360.IniWriteValue("Options", "DInputForceDisable", context.Hook.DInputForceDisable.ToString()); }
private MapTemplate ReadFromFile(string path) { return(IOModule.ReadFromBinaryFile <MapTemplate>(path)); }
private void MainForm_Load(object sender, EventArgs e) { ProjectMemoConsole.CustomConsole.Log("Loading ProjectMemo.MainForm on thread: " + Thread.CurrentThread.ManagedThreadId); // If the preferences file cannot be loaded, generate a default config file if (!Config.PMConfig.LoadFromFile(Directory.GetCurrentDirectory() + "/preferences.conf")) { Config.PMConfig.GenerateDefaultConfigFile(Directory.GetCurrentDirectory() + "/preferences.conf"); } Console.WriteLine("[" + Config.PMConfig.GetConfigValueString("mainNoteDir") + "]"); IOModule.SetupCurrentDirectory(); CustomConsole.Init(); ThisForm = this; mStopwatch = new Stopwatch(); mStopwatch.Start(); filesListBox.TimeSinceLastUpdate = mStopwatch.ElapsedMilliseconds; versionLabel.Text = Version; MainContent.InitFontStyles(template_richTextBox.Font.Size); RtfCodeFormatter.LoadLanguageThemes(); mAutoSaveModule = new AutoSaveModule(); mAutoSaveModule.OnAutoSaveTriggered += AutosaveAllNotes; foreach (string str in MainContent.GetFontStyleList()) { if (str != "Code Fragment") { format_textStyleSelector.Items.Add(str); } } format_languageSelector.Items.Clear(); format_languageSelector.Items.AddRange(RtfCodeFormatter.LoadedLanguageThemes); mainFormTimer.Start(); if (Config.PMConfig.DoesConfigValueExist("mainNoteDir")) { MainNoteDirectory = Config.PMConfig.GetConfigValueString("mainNoteDir"); } else { MainNoteDirectory = "ERRORDIR"; } // Set the valid semester choices string[] semesterFolders = new string[] { }; if (!string.IsNullOrEmpty(MainNoteDirectory)) { semesterFolders = Directory.GetDirectories(MainNoteDirectory); } mLoadedSemesters.Clear(); foreach (string str in semesterFolders) { if (str.EndsWith("_s2") || str.EndsWith("_s1")) { mLoadedSemesters.Add(str.Replace(MainNoteDirectory, "")); } } template_rtb = template_richTextBox; activeRichTextBox = null; CustomConsole.Log("Set activeRichTextBox to null"); template_richTextBox.Visible = false; CustomConsole.Log("Set the visibility of the template_richTextBox to False"); mainTabControl.TabPages.RemoveAt(0); CustomConsole.Log("Removed the default tab from mainTabControl"); /* * string[] semesterFolders = Directory.GetDirectories(mMainNoteDirectory); * * semesterSelector.Items.Clear(); * * foreach (string str in semesterFolders) * if (str.EndsWith("_s2") || str.EndsWith("_s1")) * semesterSelector.Items.Add(str.Replace(mMainNoteDirectory, ""));*/ formLoaded = true; format_textStyleSelector.SelectedIndex = 0; SetTabControlRTBSize(); }
/// <summary> /// Для заданного модуля возвращает строку, отображающую этот модуль в таблице /// </summary> private string GetModuleCellLabel(IOModule module) { return(module is DigitalModule ? module.VarNames[0].DisplayName : String.Format("{0} - {1}", module.VarNames[0].DisplayName, module.VarNames[module.VarNames.Length - 1].DisplayName)); }
public override void PlayPlayer(PlayerInfo playerInfo, int index, HandlerContext context) { Process proc; IOModule ioModule = handler.GetModule <IOModule>(); string startArgs = context.StartArguments; if (context.KillMutex?.Length > 0) { //DirectoryInfo exeFolderDir = new DirectoryInfo(Path.GetDirectoryName(ioModule.ExePath)); //DirectoryInfo linkedFolderDir = new DirectoryInfo(ioModule.LinkedFolder); //string exePath = Path.Combine(exeFolderDir.GetRelativePath(ioModule.NucleusRootFolder), Path.GetFileName(ioModule.ExePath)); //string exeRoot = linkedFolderDir.GetRelativePath(ioModule.NucleusRootFolder); proc = Process.GetProcessById(StartGameUtil.StartGame(ioModule.ExePath, startArgs, ioModule.WorkingFolder)); } else { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = ioModule.ExePath; //startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.Arguments = startArgs; startInfo.UseShellExecute = true; startInfo.WorkingDirectory = Path.GetDirectoryName(ioModule.ExePath); proc = Process.Start(startInfo); } if (proc == null) { for (int times = 0; times < 200; times++) { Thread.Sleep(50); Process[] procs = Process.GetProcesses(); string proceName = Path.GetFileNameWithoutExtension(context.ExecutableName).ToLower(); string launcherName = Path.GetFileNameWithoutExtension(context.LauncherExe).ToLower(); for (int j = 0; j < procs.Length; j++) { Process p = procs[j]; string lowerP = p.ProcessName.ToLower(); if (((lowerP == proceName) || lowerP == launcherName) && !attached.Contains(p)) { attached.Add(p); proc = p; break; } } if (proc != null) { break; } } } else { attached.Add(proc); } ProcessInfo data = new ProcessInfo(proc); Rectangle playerBounds = playerInfo.MonitorBounds; UserScreen owner = playerInfo.Owner; int width = playerBounds.Width; int height = playerBounds.Height; bool isFullscreen = owner.Type == UserScreenType.FullScreen; data.Position = new Point(playerBounds.X, playerBounds.Y); data.Size = new Size(playerBounds.Width, playerBounds.Height); data.KilledMutexes = context.KillMutex?.Length == 0; playerInfo.ProcessData = data; }