コード例 #1
0
        /// <summary>
        /// Callback that gets called on every frameload end
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
        {
            for (int i = InitPatch.UIPairs.Count - 1; i >= 0; i--)
            {
                UIReferencePair UIPair = InitPatch.UIPairs[i];

                if (UIPair.Browser.Address.Contains("startmenu.html"))
                {
                    InitPatch.StartMenuSurface = UIPair.Surface;
                    InitPatch.UIPairs.RemoveAt(i);
                    continue;
                }

                if (UIPair.Browser.Address.Contains("overlay.html"))
                {
                    InitPatch.OverlaySurface = UIPair.Surface;
                    InitPatch.UIPairs.RemoveAt(i);
                    continue;
                }
            }


            if (e.Url.Contains("startmenu.html") && InitPatch.StartMenuSurface != null)
            {
                SunbeamController.Instance.StartMenuUILoaded(InitPatch.StartMenuSurface);
                return;
            }

            if (e.Url.Contains("overlay.html") && InitPatch.OverlaySurface != null)
            {
                SunbeamController.Instance.IngameOverlayUILoaded(InitPatch.OverlaySurface);
                return;
            }
        }
コード例 #2
0
        static void AfterInit(BrowserRenderSurface __instance)
        {
            FieldInfo          BrowserField    = __instance.GetType().GetField("_browser", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
            ChromiumWebBrowser BrowserInstance = BrowserField.GetValue(__instance) as ChromiumWebBrowser;

            FieldInfo InitializedField = __instance.GetType().GetField("_initialized", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
            bool      Initialized      = (bool)InitializedField.GetValue(__instance);

            if (!Initialized)
            {
                InitializedField.SetValue(__instance, true);

                UIReferencePair Pair = new UIReferencePair(BrowserInstance, __instance);
                if (!InitPatch.UIPairs.Contains(Pair))
                {
                    InitPatch.UIPairs.Add(Pair);
                    BrowserInstance.FrameLoadEnd += InitPatch.FrameLoadEnd;
                }
            }
        }