/// <summary> /// Creates a new ImGui hook. /// </summary> /// <param name="render">Renders your imgui UI</param> /// <param name="windowHandle">Handle to the window to render on. Pass IntPtr.Zero to select main window.</param> /// <param name="implementations">List of implementations to use (regardless of whether they are supported or not).</param> /// <param name="options">The options with which to initialise the hook. Implementations defined here are ignored in this overload.</param> public static void Create(Action render, IntPtr windowHandle, List <IImguiHook> implementations, ImguiHookOptions options = null) { if (implementations.Count <= 0) { Disable(); throw new Exception("Unsupported or not found any compatible Implementation(s)."); } _created = true; Render = render; WindowHandle = windowHandle; Context = ImGui.CreateContext(null); IO = Context.IO; Options = options ?? new ImguiHookOptions(); if (Options.EnableViewports) { IO.ConfigFlags |= (int)ImGuiConfigFlags.ImGuiConfigFlagsViewportsEnable; } ImGui.StyleColorsDark(null); Implementations = implementations; foreach (var impl in Implementations) { impl.Initialize(); } }
/// <summary> /// Creates a new hook given the Reloaded.Hooks library. /// The library will hook to the main window. /// </summary> /// <param name="render">Renders your imgui UI</param> /// <param name="windowHandle">Handle of the window to draw on.</param> /// <param name="options">The options with which to initialise the hook.</param> public static async Task Create(Action render, IntPtr windowHandle, ImguiHookOptions options = null) { if (_created) { return; } var implementations = await Utility.GetSupportedImplementations(options.Implementations).ConfigureAwait(false); Create(render, windowHandle, implementations, options); }