Exemplo n.º 1
0
    /// <summary>Clears all content from the UI and all WorldUI's.
    /// Please note that it is safer to set innerHTML to a blank string for a particular UI than calling this.</summary>
    public static void ClearAll()
    {
        content = null;

        if (Renderer != null)
        {
            Renderer.Destroy();
            Renderer = null;
            document = null;
        }

        Fonts.Clear();
        AtlasStacks.Clear();
        Web.Clear();
        Spa.SPA.Clear();
        UIAnimation.Clear();
        ScreenInfo.Clear();
        WorldUI currentWorldUI = FirstWorldUI;

        while (currentWorldUI != null)
        {
            currentWorldUI.Destroy();
            currentWorldUI = currentWorldUI.UIAfter;
        }

        LastWorldUI  = null;
        FirstWorldUI = null;
    }
Exemplo n.º 2
0
    /// <summary>Clears all content from the UI and all WorldUI's.
    /// Please note that it is safer to set innerHTML to a blank string for a particular UI than calling this.</summary>
    public static void ClearAll()
    {
        content = null;

        if (Renderer != null)
        {
            Renderer.Destroy();
            Renderer = null;
            document = null;
        }

        Fonts.Clear();
        AtlasStacks.Clear();
        Http.Clear();
        SPA.Clear();
        UIAnimation.Clear();
        DynamicTexture.RemoveAll();
        PowerUI.Input.Clear();
        ScreenInfo.Clear();
        WorldUI currentWorldUI = FirstWorldUI;

        while (currentWorldUI != null)
        {
            currentWorldUI.Destroy();
            currentWorldUI = currentWorldUI.UIAfter;
        }

        LastWorldUI  = null;
        FirstWorldUI = null;
    }
Exemplo n.º 3
0
    /// <summary>Updates the UI. Don't call this - PowerUI knows when it's needed; This is done from Start and WorldUI constructors.</summary>
    public static void InternalUpdate()
    {
        // Get a deltaTime unaffected by timeScale:
        float deltaTime = Time.unscaledDeltaTime;

        RedrawTimer += deltaTime;

        // Update any callbacks:
        if (Callbacks.FirstToRun != null)
        {
            Callbacks.RunAll();
        }

        // OnUpdate queue too:
        if (OnUpdate.FirstElement != null)
        {
            OnUpdate.Update();
        }

        // Update animations:
        Spa.SPA.Update(deltaTime);

        if (WorldUI.LiveUpdatablesAvailable)
        {
            WorldUI.UpdateAll();
        }

        if (RedrawTimer < RedrawRate)
        {
            return;
        }

        // Currently, RedrawTimer is exactly the amount of time we took:
        float frameTime = RedrawTimer;

        RedrawTimer = 0f;

        if (GUICamera == null)
        {
            return;
        }

        // Check for timeouts:
        Web.Update(frameTime);

        // Atlases:
        AtlasStacks.Update();

        // Screen size:
        ScreenInfo.Update();

        // Update Input (mouse/keys etc).
        PowerUI.Input.Update();

        // Animations:
        UIAnimation.Update(frameTime);

        // Dynamic graphics:
        DynamicTexture.Update();

        // Redraw the root html document (if it needs to be redrawn):
        Renderer.Update();

        // Redraw any in-world documents (if they need it).

        // Did we call update all above?
        bool worldUIRequiresUpdate = !WorldUI.LiveUpdatablesAvailable;

        // Clear the flag:
        WorldUI.LiveUpdatablesAvailable = false;

        if (FirstWorldUI != null)
        {
            WorldUI current = FirstWorldUI;
            while (current != null)
            {
                if (worldUIRequiresUpdate)
                {
                    // Update:
                    current.Update();

                    // Was it destroyed?
                    if (current.Renderer == null)
                    {
                        // Hop to the next one:
                        current = current.UIAfter;

                        continue;
                    }
                }

                if (current.Expires)
                {
                    current.ExpiresIn -= frameTime;

                    if (current.ExpiresIn <= 0f)
                    {
                        // Expire it:
                        current.Expire();

                        // Hop to the next one:
                        current = current.UIAfter;

                        continue;
                    }
                }

                // Update the renderer:
                current.Renderer.Update();

                // Update the flag:
                if (current.PixelPerfect || current.AlwaysFaceCamera)
                {
                    // We have at least one which is updateable:
                    WorldUI.LiveUpdatablesAvailable = true;
                }

                current = current.UIAfter;
            }
        }

        // Draw characters:
        Blaze.TextureCameras.Update(frameTime);

        // Flush any atlases:
        AtlasStacks.Flush();
    }
Exemplo n.º 4
0
    /// <summary>Updates the UI. Don't call this - PowerUI knows when it's needed; This is done from Start and WorldUI constructors.</summary>
    public static void InternalUpdate()
    {
        // Update any callbacks:
        if (Callbacks.FirstToRun != null)
        {
            Callbacks.RunAll();
        }

        // Update animations:
        SPA.Update();

        // Update any Http requests:
        Http.Update();

        if (WorldUI.LiveUpdatablesAvailable)
        {
            WorldUI.UpdateAll();
        }

        RedrawTimer += Time.deltaTime;

        if (RedrawTimer < RedrawRate)
        {
            return;
        }
        RedrawTimer = 0f;

        if (GUICamera == null)
        {
            return;
        }

        // Atlases:
        AtlasStacks.Update();

        // Screen size:
        ScreenInfo.Update();

        // Update Input (mouse/keys etc).
        PowerUI.Input.Update();

        // Animations:
        UIAnimation.Update();

        // Dynamic graphics:
        DynamicTexture.Update();

        // Redraw the root html document (if it needs to be redrawn):
        Renderer.Update();

        if (MainCameraPool != null && MainCameraPool.DidLayout)
        {
            // The main UI did a layout and we have a camera pool.
            // We now need to do some post-layout spring cleaning.
            MainCameraPool.ClearPool();
        }

        // Redraw any in-world documents (if they need it).

        // Did we call update all above?
        bool worldUIRequiresUpdate = !WorldUI.LiveUpdatablesAvailable;

        // Clear the flag:
        WorldUI.LiveUpdatablesAvailable = false;

        if (FirstWorldUI != null)
        {
            WorldUI current = FirstWorldUI;
            while (current != null)
            {
                if (worldUIRequiresUpdate)
                {
                    // Update:
                    current.Update();

                    // Was it destroyed?
                    if (current.Renderer == null)
                    {
                        // Hop to the next one:
                        current = current.UIAfter;

                        continue;
                    }
                }

                if (current.Expires)
                {
                    current.ExpiresIn -= RedrawRate;

                    if (current.ExpiresIn <= 0f)
                    {
                        // Expire it:
                        current.Expire();

                        // Hop to the next one:
                        current = current.UIAfter;

                        continue;
                    }
                }

                // Update the renderer:
                current.Renderer.Update();

                // Update the flag:
                if (current.PixelPerfect || current.AlwaysFaceCamera)
                {
                    // We have at least one which is updateable:
                    WorldUI.LiveUpdatablesAvailable = true;
                }

                current = current.UIAfter;
            }
        }

        // Flush any atlases:
        AtlasStacks.Flush();
    }