예제 #1
0
 /// <summary>
 /// Called whenever the browser instance finished (re)loading the start menu
 /// </summary>
 /// <param name="surface"></param>
 public void StartMenuUILoaded(BrowserRenderSurface surface)
 {
     for (int i = 0; i < this.Mods.Count; i++)
     {
         this.Mods[i].StartMenuUILoaded(surface);
     }
 }
예제 #2
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;
            }
        }
예제 #3
0
        /// <summary>
        /// Inject the UI contents
        /// </summary>
        public override void IngameOverlayUILoaded(BrowserRenderSurface surface)
        {
            surface.CallPreparedFunction("(() => { const el = document.createElement('style'); el.type = 'text/css'; el.appendChild(document.createTextNode('" + this.CSSAsset + "')); document.head.appendChild(el); })();");
            surface.CallPreparedFunction("$('body').append(\"" + this.HTMLAsset + "\");");
            surface.CallPreparedFunction("try{ " + this.JSAsset + " } catch(e) { alert(e.toString()); }");

            this.SignController.Reset();
        }
예제 #4
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;
                }
            }
        }
예제 #5
0
 public UIReferencePair(ChromiumWebBrowser browser, BrowserRenderSurface surface)
 {
     this.Browser = browser;
     this.Surface = surface;
 }
예제 #6
0
 /// <summary>
 /// Called whenever the browser instance finished (re)loading the ingame overlay
 /// </summary>
 /// <param name="surface"></param>
 public virtual void IngameOverlayUILoaded(BrowserRenderSurface surface)
 {
 }
예제 #7
0
 /// <summary>
 /// Called whenever the browser instance finished (re)loading the start menu
 /// </summary>
 /// <param name="surface"></param>
 public virtual void StartMenuUILoaded(BrowserRenderSurface surface)
 {
 }
예제 #8
0
 /// <summary>
 /// Inject the UI contents
 /// </summary>
 public override void IngameOverlayUILoaded(BrowserRenderSurface surface)
 {
     surface.CallPreparedFunction("(() => { const el = document.createElement('style'); el.type = 'text/css'; el.appendChild(document.createTextNode('" + this.CSSAsset + "')); document.head.appendChild(el); })();");
     surface.CallPreparedFunction("$('#CharacterCreator:not(:has(#CharacterCreator_Info))').append(\"" + this.HTMLAsset + "\");");
     surface.CallPreparedFunction(this.JSAsset);
 }