static bool Prefix(Form __instance, string __0) { __instance.Load += (sender, e) => __instance.Close(); Uri uri; // URL after redirects var request = WebRequest.Create(__0); var headers = new StringBuilder(); using (var response = request.GetResponse()) { uri = response.ResponseUri; } foreach (var header in request.Headers.AllKeys) { headers.AppendFormat("{0}: {1}\r\n", header, request.Headers[header]); } var drawText = new[] { "enable='between(t,0,5)'", "text='PRESS ESC TO EXIT'", "fontfile=" + InjectorService.DefaultFont, "fontcolor=white", "fontsize=48", "box=1", "[email protected]", "boxborderw=16", "x=(w-tw)/2", "y=h-(2*lh)" }; PLAYER?.Stop(); PLAYER = FF.Play(string.Format( "{0} -noborder -autoexit -reconnect 1 -http_proxy {1} -headers \"{2}\" -vf \"drawtext={3}\"", uri, Overrides.Proxy.Address, headers, string.Join(":", drawText))); while (PLAYER.Process.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(20); PLAYER.Process.Refresh(); } // Set the owner of the player to the main window SetWindowLong(PLAYER.Process.MainWindowHandle, GWL_HWNDPARENT, PROCESS.MainWindowHandle); return(false); }
public static void Init() { var args = Environment.GetCommandLineArgs(); var ipcType = (IPCType)Enum.Parse(typeof(IPCType), args[2]); var launcherUri = args[3]; IPCUtil.CreateService( ipcType, typeof(InjectorService), typeof(IInjectorService), out var serviceUri ); LauncherService = IPCUtil.CreateChannel <ILauncherService>(ipcType, launcherUri); LauncherService.SendInjectorSettings(serviceUri); Harmony = new Harmony("me.failedshack.usbhelperinjector"); var assembly = Assembly.GetExecutingAssembly(); assembly.GetTypes() .Where(type => VersionSpecific.Applies(type, HelperVersion) && !(Overrides.DisableOptionalPatches && Optional.IsOptional(type)) && (!WineOnly.IsWineOnly(type) || WineCompat) ) .Do(type => Harmony.CreateClassProcessor(type).Patch()); if (WineCompat) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } NusGrabberFormPatch.Shown += (form, e) => { FF player = null; var button = new OnOffButton() { OnImage = Resources.AudioOn, OffImage = Resources.AudioOff, State = PlayMusic }; button.StateChanged += (sender, e1) => { // avoid preloading ffplay // TODO: make this not so hackish if (player == null) { if (!button.State) { return; } player = FF.Play("-loop 0 -nodisp loop.ogg"); } player.Pause = !button.State; LauncherService.SetPlayMusic(button.State); }; var toolWindow = ((Form)form).Controls.Find("toolWindow5", true)[0]; toolWindow.Controls.Add(button); button.BringToFront(); }; }