Subversion Repositories AndroidProjects

Rev

Rev 1822 | Blame | Compare with Previous | Last modification | View Log | RSS feed

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;

using BurutaruEditor.file;
using BurutaruEditor.file.elements;
using BurutaruEditor.interaction;

using BauzoidNET.graphics;
using BauzoidNET.graphics.sprite;
using BauzoidNET.graphics.renderstates;
using BauzoidNET.math;

namespace BurutaruEditor.view
{
    public class DocumentView
    {
        public const float START_POSITION_SIZE = 16;
        public const float CHECKPOINT_SIZE = 16;
        public const float POSITION_MARKER_SIZE = 12;
        public const float SELECTION_FRAME_SIZE = 20;
        public const float SELECTION_FRAME_LINE_WIDTH = 2;

        public const int PART_START_POSITION = 0;

        public const float SELECTION_FRAME_OFFSET = 10;
        public const float SELECTION_FRAME_HOVER_ALPHA = 0.5f;

        public static readonly Vector4 CHECKPOINT_PATH_COLOR = new Vector4(0.3f, 0.8f, 0.3f, 1.0f);
        public static readonly Vector4 CHECKPOINT_FRAME_PATH_COLOR = new Vector4(0.3f, 0.5f, 0.5f, 0.3f);
        public static readonly Vector4 CHECKPOINT_FRAME_COLOR = new Vector4(0.8f, 0.3f, 0.3f, 0.7f);

        //========================================================================================================


        private MainForm mOwner = null;
        public MainForm Owner { get { return mOwner; } }

        ///< Current Camera Position relative to origin/startposition
        private Vector2 mCurrentPosition = new Vector2();
        private Vector2 mCurrentSnapPosition = new Vector2();
        public Vector2 CurrentPosition
        {
            get
            {
                if (Owner.SnapToPath)
                    return mCurrentSnapPosition;
                else
                    return mCurrentPosition;
            }
        }

        ///< Zoom Factor
        private float mZoomFactor = 1.0f;
        public float ZoomFactor
        {
            get { return mZoomFactor; }
            set
            {
                mZoomFactor = Math.Max(value, 0.1f);
                Owner.UpdateStatusBar();
                Owner.GlView.Refresh();
            }
        }

        public SimpleSprite StartPositionSprite { get; set; }
        public SimpleSprite CheckPointSprite { get; set; }
        public SimpleSprite PositionMarkerSprite { get; set; }

        private Grid mGrid = null;

        private static ViewResources mViewResources = null;
        public static ViewResources Resources { get { return mViewResources; } }

        public LevelObject SelectedObject = null;
        public int SelectedObjectPart = SelectMove.MOVE_ALL;

        private float mCurrentTime = 0.0f;
        public float CurrentTime { get { return mCurrentTime; } }

        //========================================================================================================

        public DocumentView(MainForm owner)
        {
            mOwner = owner;

            StartPositionSprite = new SimpleSprite(MainForm.App.getGraphics(), "data/textures/ui/startposition.png");
            CheckPointSprite = new SimpleSprite(MainForm.App.getGraphics(), "data/textures/ui/checkpoint.png");
            PositionMarkerSprite = new SimpleSprite(MainForm.App.getGraphics(), BurutaruEditor.Properties.Resources.positionMarker);

            mGrid = new Grid(this);
        }

        public void Init()
        {
            mViewResources = new ViewResources(Owner);
            mViewResources.Init();

            StartPositionSprite.init();
            StartPositionSprite.getSpriteTransform().set(0, 0, START_POSITION_SIZE, START_POSITION_SIZE);

            CheckPointSprite.init();
            CheckPointSprite.getSpriteTransform().set(0, 0, CHECKPOINT_SIZE, CHECKPOINT_SIZE);

            PositionMarkerSprite.init();
            PositionMarkerSprite.getSpriteTransform().set(0, 0, POSITION_MARKER_SIZE, POSITION_MARKER_SIZE);

            ResetView();
        }

        public void Exit()
        {
            StartPositionSprite.dispose();
            CheckPointSprite.dispose();

            mViewResources.Exit();
            mViewResources = null;
        }

        public void ResetView()
        {
            SelectedObject = null;
            SelectedObjectPart = -1;

            mCurrentPosition.set(Owner.Doc.StartPosition.x, Owner.Doc.StartPosition.y);
            ZoomFactor = 1.0f;
        }

        public Vector2 SnapToPath()
        {
            Vector2 closestPt = null;
            Vector2 lastPt = new Vector2(Owner.Doc.StartPosition.x, Owner.Doc.StartPosition.x);
            Vector2 curPos = new Vector2(-mCurrentPosition.x, -mCurrentPosition.y);

            float accumTime = 0;
            float whichTime = 0.0f;
            for (int i = 0; i < Owner.Doc.CheckPoints.Count; i++)
            {
                Vector2 p = Owner.Doc.CheckPoints[i].Position;

                Line2 line = new Line2(lastPt, p);

                Vector2 pointOnLine = line.getClosestPointFrom(curPos);



                if (i == 0)
                {
                    closestPt = pointOnLine;

                    float diffX = closestPt.x - lastPt.x;
                    float diffY = closestPt.y - lastPt.y;
                    whichTime = accumTime + (float)Math.Sqrt(diffX*diffX + diffY*diffY) / Owner.Doc.CheckPoints[i].ScrollSpeed;
                }
                else
                {
                    Vector2 d1 = new Vector2(pointOnLine.x - curPos.x, pointOnLine.y - curPos.y);
                    Vector2 d2 = new Vector2(closestPt.x - curPos.x, closestPt.y - curPos.y);

                    if (d1.squaredLength() <= d2.squaredLength())
                    {
                        closestPt = pointOnLine;

                        float diffX = closestPt.x - lastPt.x;
                        float diffY = closestPt.y - lastPt.y;
                        whichTime = accumTime + (float)Math.Sqrt(diffX*diffX + diffY*diffY) / Owner.Doc.CheckPoints[i].ScrollSpeed;
                    }
                }

                float dx = p.x - lastPt.x;
                float dy = p.y - lastPt.y;
                float l = (float)Math.Sqrt((dx * dx) + (dy * dy));
                accumTime += (l / Owner.Doc.CheckPoints[i].ScrollSpeed);

                lastPt = p;
            }

            if (closestPt == null)
            {
                mCurrentTime = 0.0f;
                return new Vector2(0, 0);
            }

            mCurrentTime = whichTime;

            return new Vector2(-closestPt.x, -closestPt.y);
        }

        public void Render()
        {
            RenderStates rs = MainForm.App.getGraphics().renderStates;

            mGrid.Render(CurrentPosition.x, CurrentPosition.y);

            rs.pushViewMatrix();
            {
                Matrix4 translate1 = Matrix4.createTranslation(MainForm.App.getGraphics().getWidth() / 2,
                    MainForm.App.getGraphics().getHeight() / 2, 0);
                Matrix4 translate1a = Matrix4.createTranslation(-Document.VIRTUAL_WIDTH / 2, -Document.VIRTUAL_HEIGHT / 2, 0);
                Matrix4 translate2 = Matrix4.createTranslation(CurrentPosition.x, CurrentPosition.y, 0);
                Matrix4 translate2a = Matrix4.createTranslation(-CurrentPosition.x, -CurrentPosition.y, 0);
                Matrix4 scale = Matrix4.createScale(ZoomFactor);

                Matrix4 checkPointTransform = Matrix4.createIdentity();
                Matrix4 levelObjectTransform = Matrix4.createIdentity();

                checkPointTransform.multiply(translate2);
                checkPointTransform.multiply(scale);
                checkPointTransform.multiply(translate1);

                levelObjectTransform.multiply(translate1a);
                //levelObjectTransform.multiply(translate2);
                levelObjectTransform.multiply(scale);                
                levelObjectTransform.multiply(translate1);

                // current-position translation not done here because elements may scroll at different speeds
                //levelObjectTransform.multiply(translate2);

                rs.view.copyFrom(levelObjectTransform);

                // render level elements
                if (Owner.ViewBgLayer1)
                    RenderLevelElements(LevelElement.BACKGROUND_LAYER1);

                // starfield and other effects
                // TODO:


                if (Owner.ViewBgLayer2)
                    RenderLevelElements(LevelElement.BACKGROUND_LAYER2);

                if (Owner.ViewMainLayer)
                    RenderLevelElements(LevelElement.MAIN_LAYER);

                // everything else in between here

                // render spawners
                if (Owner.ViewEnemySpawners)
                    for (int i = 0; i < Owner.Doc.Spawners.Count; i++)
                    {
                        Owner.Doc.Spawners[i].Render();
                    }

                if (Owner.ViewFgLayer)
                    RenderLevelElements(LevelElement.FOREGROUND_LAYER);

                if (Owner.ViewScripting)
                    for (int i = 0; i < Owner.Doc.Scripting.Count; i++)
                    {
                        Owner.Doc.Scripting[i].Render();
                    }
               
                Owner.RenderInteraction();

                if (SelectedObject != null)
                    SelectedObject.RenderSelected(SelectedObjectPart);

                // render checkpoints
                rs.view.copyFrom(checkPointTransform);
                RenderCheckPoints();
            }

            rs.popViewMatrix();
            rs.view.identity();

            if (Owner.SnapToPath)
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                MainForm.App.getGraphics().getFont().drawTextDirect("Time: " + mCurrentTime + "sec", 10, 10, new Vector4(1, 1, 1, 1), 1.0f);
            }
        }

        public void RenderLevelElements(int layer)
        {
            for (int i = 0; i < Owner.Doc.LevelElements.Count; i++)
            {
                if (Owner.Doc.LevelElements[i].Layer == layer)
                    Owner.Doc.LevelElements[i].Render();
            }
        }

        public enum CheckPointSectionDirection
        {
            UPPER_LEFT,
            UPPER_RIGHT,
            LOWER_RIGHT,
            LOWER_LEFT,
        }

        public class CheckPointSection
        {
            public CheckPointSectionDirection Direction = CheckPointSectionDirection.UPPER_LEFT;

            public Line2 a = new Line2();
            public Line2 b = new Line2();

            public Line2 edge1 = new Line2();
            public Line2 edge2 = new Line2();

            public bool isEdge = false;
        }

        public void RenderCheckPoints()
        {
            float halfW = Document.VIRTUAL_WIDTH / 2;
            float halfH = Document.VIRTUAL_HEIGHT / 2;

            for (int i = 0; i < Owner.Doc.CheckPoints.Count; i++)
            {
                RenderCheckPoint(Owner.Doc.CheckPoints[i].Position.x, Owner.Doc.CheckPoints[i].Position.y);
            }
           

            StartPositionSprite.getSpriteTransform().x = Owner.Doc.StartPosition.x;
            StartPositionSprite.getSpriteTransform().y = Owner.Doc.StartPosition.y;
            StartPositionSprite.render();

            if (!Owner.SnapToPath)
            {
                if (Owner.ViewCheckPointFrames)
                    RenderUtil.drawQuad(MainForm.App.getGraphics(), Owner.Doc.StartPosition.x - halfW, Owner.Doc.StartPosition.y - halfH,
                        Owner.Doc.StartPosition.x + halfW, Owner.Doc.StartPosition.y + halfH, CHECKPOINT_FRAME_COLOR);
            }
            else
            {
                PositionMarkerSprite.getSpriteTransform().setPosition(-CurrentPosition.x, -CurrentPosition.y);
                PositionMarkerSprite.render();

                if (Owner.ViewCheckPointFrames)
                    RenderUtil.drawQuad(MainForm.App.getGraphics(), -CurrentPosition.x - halfW, -CurrentPosition.y - halfH,
                        -CurrentPosition.x + halfW, -CurrentPosition.y + halfH, CHECKPOINT_FRAME_COLOR);
            }

            Vector2 lastPt = new Vector2(Owner.Doc.StartPosition.x, Owner.Doc.StartPosition.y);
            /*CheckPointSection[] sections = new CheckPointSection[Owner.Doc.CheckPoints.Count];
            for (int i = 0; i < Owner.Doc.CheckPoints.Count; i++)
            {
                Vector2 p = Owner.Doc.CheckPoints[i].Position;

                RenderUtil.drawLine(MainForm.App.getGraphics(), lastPt.x, lastPt.y, p.x, p.y, CHECKPOINT_PATH_COLOR);

                sections[i] = new CheckPointSection();

                if ((p.x > lastPt.x) && (p.y <= lastPt.y))
                {
                    if (i == 0)
                    {
                        sections[i].edge1.set(lastPt.x - halfW, lastPt.y - halfH, lastPt.x - halfW, lastPt.y + halfH);
                        sections[i].edge2.set(lastPt.x - halfW, lastPt.y + halfH, lastPt.x + halfW, lastPt.y + halfH);
                        sections[i].isEdge = true;
                    }
                    else if (i == (Owner.Doc.CheckPoints.Count - 1))
                    {
                        sections[i].edge1.set(p.x - halfW, p.y - halfH, p.x + halfW, p.y - halfH);
                        sections[i].edge2.set(p.x + halfW, p.y - halfH, p.x + halfW, p.y + halfH);
                        sections[i].isEdge = true;
                    }

                    sections[i].Direction = CheckPointSectionDirection.UPPER_RIGHT;
                    sections[i].a.set(lastPt.x - halfW, lastPt.y - halfH, p.x - halfW, p.y - halfH);
                    sections[i].b.set(lastPt.x + halfW, lastPt.y + halfH, p.x + halfW, p.y + halfH);
                }
                else if ((p.x < lastPt.x) && (p.y >= lastPt.y))
                {
                    if (i == 0)
                    {
                        sections[i].edge1.set(lastPt.x - halfW, lastPt.y - halfH, lastPt.x + halfW, lastPt.y - halfH);
                        sections[i].edge2.set(lastPt.x + halfW, lastPt.y - halfH, lastPt.x + halfW, lastPt.y + halfH);
                        sections[i].isEdge = true;
                    }
                    else if (i == (Owner.Doc.CheckPoints.Count - 1))
                    {
                        sections[i].edge1.set(p.x - halfW, p.y - halfH, p.x - halfW, p.y + halfH);
                        sections[i].edge2.set(p.x - halfW, p.y + halfH, p.x + halfW, p.y + halfH);
                        sections[i].isEdge = true;
                    }

                    sections[i].Direction = CheckPointSectionDirection.LOWER_LEFT;
                    sections[i].a.set(lastPt.x - halfW, lastPt.y - halfH, p.x - halfW, p.y - halfH);
                    sections[i].b.set(lastPt.x + halfW, lastPt.y + halfH, p.x + halfW, p.y + halfH);
                }
                else if ((p.x >= lastPt.x) && (p.y > lastPt.y))
                {
                    if (i == 0)
                    {
                        sections[i].edge1.set(lastPt.x - halfW, lastPt.y - halfH, lastPt.x + halfW, lastPt.y - halfH);
                        sections[i].edge2.set(lastPt.x - halfW, lastPt.y - halfH, lastPt.x - halfW, lastPt.y + halfH);
                        sections[i].isEdge = true;
                    }
                    else if (i == (Owner.Doc.CheckPoints.Count - 1))
                    {
                        sections[i].edge1.set(p.x + halfW, p.y - halfH, p.x + halfW, p.y + halfH);
                        sections[i].edge2.set(p.x + halfW, p.y + halfH, p.x - halfW, p.y + halfH);
                        sections[i].isEdge = true;
                    }

                    sections[i].Direction = CheckPointSectionDirection.LOWER_RIGHT;
                    sections[i].a.set(lastPt.x + halfW, lastPt.y - halfH, p.x + halfW, p.y - halfH);
                    sections[i].b.set(lastPt.x - halfW, lastPt.y + halfH, p.x - halfW, p.y + halfH);
                }
                else if ((p.x <= lastPt.x) && (p.y < lastPt.y))
                {
                    if (i == 0)
                    {
                        sections[i].edge1.set(lastPt.x + halfW, lastPt.y - halfH, lastPt.x + halfW, lastPt.y + halfH);
                        sections[i].edge2.set(lastPt.x + halfW, lastPt.y + halfH, lastPt.x - halfW, lastPt.y + halfH);
                        sections[i].isEdge = true;
                    }
                    else if (i == (Owner.Doc.CheckPoints.Count - 1))
                    {
                        sections[i].edge1.set(p.x - halfW, p.y - halfH, p.x + halfW, p.y - halfH);
                        sections[i].edge2.set(p.x - halfW, p.y - halfH, p.x - halfW, p.y + halfH);
                        sections[i].isEdge = true;
                    }

                    sections[i].Direction = CheckPointSectionDirection.UPPER_LEFT;
                    sections[i].a.set(lastPt.x + halfW, lastPt.y - halfH, p.x + halfW, p.y - halfH);
                    sections[i].b.set(lastPt.x - halfW, lastPt.y + halfH, p.x - halfW, p.y + halfH);
                }

                lastPt = p;
            }

            for (int i = 0; i < sections.Length; i++)
            {
                RenderUtil.drawLine(MainForm.App.getGraphics(), sections[i].a, CHECKPOINT_FRAME_PATH_COLOR);
                RenderUtil.drawLine(MainForm.App.getGraphics(), sections[i].b, CHECKPOINT_FRAME_PATH_COLOR);

                if (sections[i].isEdge)
                {
                    RenderUtil.drawLine(MainForm.App.getGraphics(), sections[i].edge1, CHECKPOINT_FRAME_PATH_COLOR);
                    RenderUtil.drawLine(MainForm.App.getGraphics(), sections[i].edge2, CHECKPOINT_FRAME_PATH_COLOR);
                }
            }

            return;*/



            for (int i = 0; i < Owner.Doc.CheckPoints.Count; i++)
            {
                Vector2 p = Owner.Doc.CheckPoints[i].Position;

                if (Owner.ViewCheckPointPath)
                    RenderUtil.drawLine(MainForm.App.getGraphics(), lastPt.x, lastPt.y, p.x, p.y, CHECKPOINT_PATH_COLOR);

                if ((!Owner.SnapToPath) && (Owner.ViewCheckPointFrames))
                {
                    RenderUtil.drawLine(MainForm.App.getGraphics(), lastPt.x - halfW, lastPt.y - halfH, p.x - halfW, p.y - halfH, CHECKPOINT_FRAME_PATH_COLOR);
                    RenderUtil.drawLine(MainForm.App.getGraphics(), lastPt.x + halfW, lastPt.y - halfH, p.x + halfW, p.y - halfH, CHECKPOINT_FRAME_PATH_COLOR);
                    RenderUtil.drawLine(MainForm.App.getGraphics(), lastPt.x - halfW, lastPt.y + halfH, p.x - halfW, p.y + halfH, CHECKPOINT_FRAME_PATH_COLOR);
                    RenderUtil.drawLine(MainForm.App.getGraphics(), lastPt.x + halfW, lastPt.y + halfH, p.x + halfW, p.y + halfH, CHECKPOINT_FRAME_PATH_COLOR);
                }

                lastPt = p;
            }
        }

        public void RenderCheckPoint(float x, float y)
        {
            float halfW = Document.VIRTUAL_WIDTH / 2;
            float halfH = Document.VIRTUAL_HEIGHT / 2;

            if ((!Owner.SnapToPath) && Owner.ViewCheckPointFrames)
                RenderUtil.drawQuad(MainForm.App.getGraphics(), x - halfW, y - halfH, x + halfW, y + halfH, CHECKPOINT_FRAME_COLOR);

            CheckPointSprite.getSpriteTransform().setPosition(x, y);
            CheckPointSprite.render();
        }

        public void Pan(float dx, float dy)
        {
            mCurrentPosition.x += (dx / ZoomFactor);
            mCurrentPosition.y += (dy / ZoomFactor);

            mCurrentSnapPosition = SnapToPath();

            if (Owner.SnapToPath)
                mCurrentPosition.setFrom(mCurrentSnapPosition);

            Owner.GlView.Refresh();            
        }

        public int FindDocumentObjectPart(float x, float y)
        {
            float tx;
            float ty;
            TransformToWorldSpace(out tx, out ty, x, y, true);

            if (Math.Abs(tx - Owner.Doc.StartPosition.x) < (START_POSITION_SIZE / 2) &&
                Math.Abs(ty - Owner.Doc.StartPosition.y) < (START_POSITION_SIZE / 2))
                return PART_START_POSITION;

            return -1;
        }

        public void MoveDocPartBy(float dx, float dy, int part)
        {
            if (part == PART_START_POSITION)
            {
                Owner.Doc.StartPosition.x += (dx / ZoomFactor);
                Owner.Doc.StartPosition.y += (dy / ZoomFactor);
            }
        }

        public void TransformToWorldSpace(out float tx, out float ty, float x, float y, bool isCheckPoint = false)
        {
            tx = x;
            ty = y;

            tx -= MainForm.App.getGraphics().getWidth() / 2;
            ty -= MainForm.App.getGraphics().getHeight() / 2;

            tx /= ZoomFactor;
            ty /= ZoomFactor;

            if (isCheckPoint)
            {
                tx -= mCurrentPosition.x;
                ty -= mCurrentPosition.y;
            }
            else
            {
                tx += Document.VIRTUAL_WIDTH / 2;
                ty += Document.VIRTUAL_HEIGHT / 2;
            }
        }

        public LevelObject FindObjectAt(float x, float y, out int selectedPart, bool selectInList = false)
        {
            selectedPart = -1;

            // transform coordinates
            float tx;
            float ty;

            switch (Owner.CurrentObjectMode)
            {
                case MainForm.ObjectMode.CHECKPOINTS:
                    {
                        TransformToWorldSpace(out tx, out ty, x, y, true);

                        for (int i = (Owner.Doc.CheckPoints.Count - 1); i >= 0; i--)
                        {
                            if (Owner.Doc.CheckPoints[i].IsInside(tx, ty, out selectedPart))
                            {
                                if (selectInList)
                                {
                                    Owner.CheckPoints.SelectedIndex = i;
                                }
                                return Owner.Doc.CheckPoints[i];
                            }
                        }
                    }
                    break;
                case MainForm.ObjectMode.SPAWNERS:
                    {
                        TransformToWorldSpace(out tx, out ty, x, y);

                        for (int i = (Owner.Doc.Spawners.Count - 1); i >= 0; i--)
                        {
                            if (Owner.Doc.Spawners[i].IsInside(tx, ty, out selectedPart))
                            {
                                if (selectInList)
                                {
                                    Owner.Spawners.SelectedIndex = i;
                                }
                                return Owner.Doc.Spawners[i];
                            }
                        }
                    }
                    break;
                case MainForm.ObjectMode.ELEMENTS:
                    {
                        TransformToWorldSpace(out tx, out ty, x, y);

                        for (int i = (Owner.Doc.LevelElements.Count - 1); i >= 0; i--)
                        {
                            if (Owner.Doc.LevelElements[i].IsInside(tx, ty, out selectedPart))
                            {
                                if (selectInList)
                                {
                                    Owner.LevelElements.SelectedIndex = i;
                                }
                                return Owner.Doc.LevelElements[i];
                            }
                        }
                    }
                    break;
                case MainForm.ObjectMode.SCRIPTING:
                    {
                        TransformToWorldSpace(out tx, out ty, x, y);

                        for (int i = (Owner.Doc.Scripting.Count - 1); i >= 0; i--)
                        {
                            if (Owner.Doc.Scripting[i].IsInside(tx, ty, out selectedPart))
                            {
                                if (selectInList)
                                {
                                    Owner.Scripting.SelectedIndex = i;
                                }
                                return Owner.Doc.Scripting[i];
                            }
                        }
                    }
                    break;
            }

            return null;
        }

        public void RenderSelectionFrame(float x1, float y1, float x2, float y2, float alpha = 1.0f)
        {
            float left = Math.Min(x1, x2);
            float right = Math.Max(x1, x2);
            float top = Math.Min(y1, y2);
            float bottom = Math.Max(y1, y2);

            SpriteTransform t = mViewResources.SelectionFrame.getSpriteTransform();

            float frameWidth = Math.Min(SELECTION_FRAME_SIZE, (right - left) / 4);
            float frameHeight = Math.Min(SELECTION_FRAME_SIZE, (bottom - top) / 4);

            mViewResources.SelectionFrame.getSpriteInstance().alpha = alpha;

            t.x = left;
            t.y = top;
            t.w = frameWidth;
            t.h = SELECTION_FRAME_LINE_WIDTH;
            t.pivotX = 0;
            t.pivotY = 0;
            mViewResources.SelectionFrame.render();
            t.w = SELECTION_FRAME_LINE_WIDTH;
            t.h = frameHeight;
            mViewResources.SelectionFrame.render();

            t.x = right;
            t.y = top;
            t.w = frameWidth;
            t.h = SELECTION_FRAME_LINE_WIDTH;
            t.pivotX = t.w;
            t.pivotY = 0;
            mViewResources.SelectionFrame.render();
            t.w = SELECTION_FRAME_LINE_WIDTH;
            t.h = frameHeight;
            t.pivotX = t.w;
            mViewResources.SelectionFrame.render();

            t.x = left;
            t.y = bottom;
            t.w = frameWidth;
            t.h = SELECTION_FRAME_LINE_WIDTH;
            t.pivotX = 0;
            t.pivotY = t.h;
            mViewResources.SelectionFrame.render();
            t.w = SELECTION_FRAME_LINE_WIDTH;
            t.h = frameHeight;
            t.pivotY = t.h;
            mViewResources.SelectionFrame.render();

            t.x = right;
            t.y = bottom;
            t.w = frameWidth;
            t.h = SELECTION_FRAME_LINE_WIDTH;
            t.pivotX = t.w;
            t.pivotY = t.h;
            mViewResources.SelectionFrame.render();
            t.w = SELECTION_FRAME_LINE_WIDTH;
            t.h = frameHeight;
            t.pivotX = t.w;
            t.pivotY = t.h;
            mViewResources.SelectionFrame.render();

        }
    }
}