Example #1
0
 private void UpdateUISpriteBeforeRender()
 {
     if (this.frameWidth > 0 && this.frameHeight > 0 && this.frameCount > 0 && this.sprt.Image != null)
     {
         if (this.sprt.Image.Ready)
         {
             this.sprt.Visible = true;
             int          num  = this.sprt.Image.Width / this.frameWidth;
             UISpriteUnit unit = this.sprt.GetUnit(0);
             unit.X                = 0f;
             unit.Y                = 0f;
             unit.Width            = (float)this.frameWidth;
             unit.Height           = (float)this.frameHeight;
             unit.U1               = (float)(this.frameWidth * (this.frameIndex % num)) / (float)this.sprt.Image.Width;
             unit.V1               = (float)(this.frameHeight * (this.frameIndex / num)) / (float)this.sprt.Image.Height;
             unit.U2               = (float)(this.frameWidth * (this.frameIndex % num) + this.frameWidth) / (float)this.sprt.Image.Width;
             unit.V2               = (float)(this.frameHeight * (this.frameIndex / num) + this.frameHeight) / (float)this.sprt.Image.Height;
             this.needUpdateSprite = false;
             return;
         }
     }
     else
     {
         this.sprt.Visible     = false;
         this.needUpdateSprite = false;
     }
 }
Example #2
0
 private void updateSprt()
 {
     if (this.texImage != null)
     {
         UISpriteUnit unit = this.animationSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         unit.U1     = (-this.frontPanel.X - this.textureOffsetX) / (float)this.texImage.Width;
         unit.V1     = (-this.frontPanel.Y - this.textureOffsetY) / (float)this.texImage.Height;
         unit.U2     = (-this.frontPanel.X - this.textureOffsetX + this.Width) / (float)this.texImage.Width;
         unit.V2     = (-this.frontPanel.Y - this.textureOffsetY + this.Height) / (float)this.texImage.Height;
         this.animationSprt.ShaderUniforms["u_touchCoord"] = new float[]
         {
             (this.touchPos.X - this.frontPanel.X - this.textureOffsetX) / (float)this.texImage.Width,
             (this.touchPos.Y - this.frontPanel.Y - this.textureOffsetY) / (float)this.texImage.Height
         };
         this.animationSprt.ShaderUniforms["u_tension"] = new float[]
         {
             this.tension.X / (float)this.texImage.Width * this.tensionCoeff,
             this.tension.Y / (float)this.texImage.Height * this.tensionCoeff
         };
         this.animationSprt.ShaderUniforms["u_clipRect"] = new float[]
         {
             this.Width / (float)this.texImage.Width,
             this.Height / (float)this.texImage.Height
         };
     }
 }
Example #3
0
        public ListPanel()
        {
            this.backgroundSprt = new UISprite(1);
            base.RootUIElement.AddChildLast(this.backgroundSprt);
            UISpriteUnit unit = this.backgroundSprt.GetUnit(0);

            unit.Color     = new UIColor(0f, 0f, 0f, 0f);
            this.scrollBar = new ScrollBar(ScrollBarOrientation.Vertical);
            this.AddChildLast(this.scrollBar);
            this.displayAllItems     = new List <ListPanelItem>();
            this.displayListItems    = new List <ListPanelItem>();
            this.cacheListItems      = new List <ListPanelItem>();
            this.displaySectionItems = new List <ListPanel.ListPanelSectionItem>();
            this.cacheSectionItems   = new List <ListPanel.ListPanelSectionItem>();
            this.animationState      = ListPanel.AnimationState.None;
            this.terminalState       = ListPanel.TerminalState.None;
            this.terminalDistance    = 0f;
            this.Sections            = null;
            this.ShowSection         = true;
            this.ShowEmptySection    = true;
            this.ShowItemBorder      = true;
            base.Clip = true;
            base.HookChildTouchEvent = true;
            DragGestureDetector dragGestureDetector = new DragGestureDetector();

            dragGestureDetector.DragDetected += new EventHandler <DragEventArgs>(this.DragEventHandler);
            base.AddGestureDetector(dragGestureDetector);
            FlickGestureDetector flickGestureDetector = new FlickGestureDetector();

            flickGestureDetector.FlickDetected += new EventHandler <FlickEventArgs>(this.FlickEventHandler);
            base.AddGestureDetector(flickGestureDetector);
        }
Example #4
0
        protected override void OnStart()
        {
            ImageAsset currentSceneRenderedImage = base.GetCurrentSceneRenderedImage();

            this.sprtCurrent            = new UISprite(1);
            this.sprtCurrent.Image      = currentSceneRenderedImage;
            this.sprtCurrent.ShaderType = ShaderType.OffscreenTexture;
            this.sprtCurrent.BlendMode  = BlendMode.Premultiplied;
            this.sprtCurrent.Alpha      = DefaultNavigationTransition.maxAlpha;
            this.sprtCurrent.Visible    = true;
            base.TransitionUIElement.AddChildLast(this.sprtCurrent);
            UISpriteUnit unit = this.sprtCurrent.GetUnit(0);

            unit.Width  = (float)UISystem.FramebufferWidth;
            unit.Height = (float)UISystem.FramebufferHeight;
            ImageAsset nextSceneRenderedImage = base.GetNextSceneRenderedImage();

            this.sprtNext            = new UISprite(1);
            this.sprtNext.Image      = nextSceneRenderedImage;
            this.sprtNext.ShaderType = ShaderType.OffscreenTexture;
            this.sprtNext.BlendMode  = BlendMode.Premultiplied;
            this.sprtNext.Alpha      = DefaultNavigationTransition.minAlpha;
            this.sprtNext.Visible    = true;
            base.TransitionUIElement.AddChildLast(this.sprtNext);
            unit        = this.sprtNext.GetUnit(0);
            unit.Width  = (float)UISystem.FramebufferWidth;
            unit.Height = (float)UISystem.FramebufferHeight;
        }
Example #5
0
        protected override void OnStart()
        {
            ImageAsset currentSceneRenderedImage = base.GetCurrentSceneRenderedImage();

            this.currentSprt            = new UISprite(1);
            this.currentSprt.ShaderType = ShaderType.OffscreenTexture;
            this.currentSprt.BlendMode  = BlendMode.Premultiplied;
            this.currentSprt.Image      = currentSceneRenderedImage;
            UISpriteUnit unit = this.currentSprt.GetUnit(0);

            unit.Width         = (float)UISystem.FramebufferWidth;
            unit.Height        = (float)UISystem.FramebufferHeight;
            unit.X             = (float)(-(float)UISystem.FramebufferWidth) / 2f;
            unit.Y             = (float)(-(float)UISystem.FramebufferHeight) / 2f;
            this.currentSprt.X = (float)UISystem.FramebufferWidth / 2f;
            this.currentSprt.Y = (float)UISystem.FramebufferHeight / 2f;
            base.TransitionUIElement.AddChildLast(this.currentSprt);
            this.pivotOffsetX       = (float)UISystem.FramebufferWidth / 2f;
            this.pivotOffsetY       = (float)UISystem.FramebufferHeight / 2f;
            this.fromX              = 0f;
            this.fromY              = 0f;
            this.outsideMargin      = (float)Math.Sqrt((double)(this.pivotOffsetX * this.pivotOffsetX + this.pivotOffsetY * this.pivotOffsetY));
            this.targetRadianSpeed  = 0f;
            this.targetRadian       = 0f;
            this.targetOffsetXSpeed = 0f;
            this.targetOffsetX      = 0f;
            this.targetOffsetYSpeed = 0f;
            this.targetOffsetY      = 0f;
            this.T        = 40f;
            this.leftTime = this.T / (14f + 4f * (float)this.rand.NextDouble());
            this.setupLeftPos();
        }
Example #6
0
        private void SetupUISpriteAspectOutside()
        {
            this.sprt.Visible          = true;
            this.ninePatchPrim.Visible = false;
            float        num   = (float)this.sprt.Image.Width;
            float        num2  = (float)this.sprt.Image.Height;
            float        num3  = this.Width / this.clipImageWidth;
            float        num4  = this.Height / this.clipImageHeight;
            float        num5  = (num3 > num4) ? num3 : num4;
            float        num6  = num * num5;
            float        num7  = num2 * num5;
            float        num8  = this.clipImageX * num5;
            float        num9  = this.clipImageY * num5;
            float        num10 = this.clipImageWidth * num5;
            float        num11 = this.clipImageHeight * num5;
            float        num12 = num8 + (num10 - this.Width) / 2f;
            float        num13 = num9 + (num11 - this.Height) / 2f;
            UISpriteUnit unit  = this.sprt.GetUnit(0);

            unit.X      = 0f;
            unit.Y      = 0f;
            unit.Width  = this.Width;
            unit.Height = this.Height;
            unit.U1     = num12 / num6;
            unit.V1     = num13 / num7;
            unit.U2     = (num12 + this.Width) / num6;
            unit.V2     = (num13 + this.Height) / num7;
        }
Example #7
0
        protected override void OnStart()
        {
            ImageAsset currentSceneRenderedImage = base.GetCurrentSceneRenderedImage();

            this.currentSprt            = new UISprite(1);
            this.currentSprt.Image      = currentSceneRenderedImage;
            this.currentSprt.ShaderType = ShaderType.OffscreenTexture;
            this.currentSprt.BlendMode  = BlendMode.Premultiplied;
            base.TransitionUIElement.AddChildLast(this.currentSprt);
            UISpriteUnit unit = this.currentSprt.GetUnit(0);

            unit.Width  = (float)UISystem.FramebufferWidth;
            unit.Height = (float)UISystem.FramebufferHeight;
            ImageAsset nextSceneRenderedImage = base.GetNextSceneRenderedImage();

            this.nextSprt            = new UISprite(1);
            this.nextSprt.Image      = nextSceneRenderedImage;
            this.nextSprt.ShaderType = ShaderType.OffscreenTexture;
            this.nextSprt.BlendMode  = BlendMode.Premultiplied;
            base.TransitionUIElement.AddChildLast(this.nextSprt);
            unit        = this.nextSprt.GetUnit(0);
            unit.Width  = (float)UISystem.FramebufferWidth;
            unit.Height = (float)UISystem.FramebufferHeight;
            this.currentSprt.Visible = true;
            this.nextSprt.Visible    = false;
            this.time       = ((this.Speed == JumpFlipTransitionSpeed.Fast) ? 500f : 1000f);
            this.fromDegree = 0f;
            this.toDegree   = ((this.RotateDirection == JumpFlipTransitionRotateDirection.ClockWise) ? 180f : -180f);
        }
Example #8
0
        private void RotateNextLowerSprite()
        {
            float        num     = (this.degree - 180f) / 360f * 2f * 3.14159274f;
            UISpriteUnit unit    = this.nextLowerSprt.GetUnit(0);
            Matrix4      matrix  = Matrix4.Translation(0f, unit.Height * 0.5f, 0f);
            Matrix4      matrix2 = Matrix4.RotationX(num);
            Matrix4      matrix3 = Matrix4.Translation(this.centerPosition.X, this.centerPosition.Y, 0f);

            this.nextLowerSprt.Transform3D = matrix3 * matrix2 * matrix;
        }
Example #9
0
 private void UpdateBackgroundSprite()
 {
     if ((this.updateFlags & Label.UpdateFlags.Background) == Label.UpdateFlags.Background)
     {
         UISpriteUnit unit = this.backgroundSprt.GetUnit(0);
         unit.Width        = this.Width;
         unit.Height       = this.Height;
         unit.Color        = this.BackgroundColor;
         this.updateFlags &= ~Label.UpdateFlags.Background;
     }
 }
Example #10
0
        private void RotateNextLowerSprite()
        {
            float        num     = (this.degree - 180f) / 360f * 2f * 3.14159274f;
            UISpriteUnit unit    = this.nextLowerSprt.GetUnit(0);
            Matrix4      matrix  = Matrix4.Translation(new Vector3(0f, unit.Height, 0f));
            Matrix4      matrix2 = Matrix4.RotationX(num);
            Matrix4      transform3D;

            matrix.Multiply(ref matrix2, out transform3D);
            this.nextLowerSprt.Transform3D = transform3D;
        }
Example #11
0
        private void UpdateIconSprite()
        {
            if ((this.updateFlags & Button.UpdateFlags.Icon) == Button.UpdateFlags.Icon)
            {
                this.updateFlags &= ~Button.UpdateFlags.Icon;
                if (this.IconImage == null)
                {
                    this.iconSprt.Visible = false;
                    return;
                }
                if (this.IconImage.Ready)
                {
                    UISpriteUnit unit = this.iconSprt.GetUnit(0);
                    unit.Width  = (float)this.IconImage.Width;
                    unit.Height = (float)this.IconImage.Height;
                    switch (this.HorizontalAlignment)
                    {
                    case HorizontalAlignment.Left:
                        unit.X = 0f;
                        break;

                    case HorizontalAlignment.Center:
                        unit.X = (this.Width - unit.Width) / 2f;
                        break;

                    case HorizontalAlignment.Right:
                        unit.X = this.Width - unit.Width;
                        break;
                    }
                    switch (this.VerticalAlignment)
                    {
                    case VerticalAlignment.Top:
                        unit.Y = 0f;
                        break;

                    case VerticalAlignment.Middle:
                        unit.Y = (this.Height - unit.Height) / 2f;
                        break;

                    case VerticalAlignment.Bottom:
                        unit.Y = this.Height - unit.Height;
                        break;
                    }
                    this.iconSprt.ShaderType = ShaderType.Texture;
                    this.iconSprt.Image      = this.IconImage;
                    this.iconSprt.Visible    = true;
                    this.textSprt.Visible    = false;
                    return;
                }
                this.iconSprt.Visible = false;
                this.textSprt.Visible = false;
                this.updateFlags     |= Button.UpdateFlags.Icon;
            }
        }
Example #12
0
 private void UpdateBackgroundSprite()
 {
     if ((this.updateFlags & EditableText.UpdateFlags.Background) == EditableText.UpdateFlags.Background)
     {
         UISpriteUnit unit = this.backgroundSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         UISpriteUtility.SetupNinePatch(this.backgroundSprt, this.Width, this.Height, 0f, 0f, this.backgroundNinePatchMargin);
         this.updateFlags &= ~EditableText.UpdateFlags.Background;
     }
 }
Example #13
0
 protected internal override void Render()
 {
     if (this.needUpdateFlag)
     {
         UISpriteUnit unit = this.sprt.GetUnit(0);
         unit.Width          = this.Width;
         unit.Height         = this.Height;
         this.sprt.Image     = this.images[(int)this.Style, (int)this.buttonState, this.Checked ? 1 : 0];
         this.needUpdateFlag = false;
     }
     base.Render();
 }
Example #14
0
        private void RotateCurrentUpperSprite()
        {
            float        num     = this.degree / 360f * 2f * 3.14159274f;
            UISpriteUnit unit    = this.currentUpperSprt.GetUnit(0);
            Matrix4      matrix  = Matrix4.Translation(new Vector3(0f, unit.Height, 0f));
            Matrix4      matrix2 = Matrix4.RotationX(num);
            Matrix4      matrix3;

            matrix.Multiply(ref matrix2, out matrix3);
            Matrix4 matrix4 = Matrix4.Translation(new Vector3(0f, -unit.Height, 0f));
            Matrix4 transform3D;

            matrix3.Multiply(ref matrix4, out transform3D);
            this.currentUpperSprt.Transform3D = transform3D;
        }
Example #15
0
 protected override void OnUpdate(float elapsedTime)
 {
     base.OnUpdate(elapsedTime);
     if (this.animation)
     {
         this.animationElapsedTime += elapsedTime;
         if (this.animationElapsedTime > 500f)
         {
             this.animationElapsedTime -= 500f;
         }
         float        num  = this.animationElapsedTime / 500f;
         UISpriteUnit unit = this.acceleratorSprt.GetUnit(0);
         unit.U1 = num;
         unit.U2 = this.barImage.Width / 45f + num;
     }
 }
Example #16
0
 private void UpdateTextSprite()
 {
     if (string.IsNullOrEmpty(this.Text))
     {
         this.textSprt.Visible = false;
         this.updateFlags     &= ~Button.UpdateFlags.Text;
     }
     if ((this.updateFlags & Button.UpdateFlags.Text) == Button.UpdateFlags.Text)
     {
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.LineBreak           = LineBreak.AtCode;
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.Font         = this.TextFont;
         textRenderHelper.TextTrimming = this.TextTrimming;
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         unit.Color  = this.TextColor;
         if (this.textSprt.Image != null)
         {
             this.textSprt.Image.Dispose();
         }
         this.textSprt.Image      = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height);
         this.textSprt.Alpha      = ((this.State == Button.ButtonState.Disabled) ? 0.3f : 1f);
         this.textSprt.ShaderType = ShaderType.TextTexture;
         this.textSprt.Visible    = true;
         this.iconSprt.Visible    = false;
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~Button.UpdateFlags.Text;
     }
 }
Example #17
0
 private void updateSprite()
 {
     if (this.bgImageSprt != null && this.bgColorSprt != null)
     {
         this.needUpdateSprite = false;
         if (this.backgroundStyle == DialogBackgroundStyle.Default)
         {
             this.bgColorSprt.Visible = false;
             this.bgImageSprt.Visible = true;
             if (this.defaultImageAsset == null)
             {
                 this.defaultImageAsset = new ImageAsset(SystemImageAsset.DialogBackground);
             }
             this.bgImageSprt.Image = this.defaultImageAsset;
             UISpriteUtility.SetupNinePatch(this.bgImageSprt, this.Width, this.Height, 0f, 0f, AssetManager.GetNinePatchMargin(SystemImageAsset.DialogBackground));
         }
         else
         {
             UISpriteUnit unit = this.bgColorSprt.GetUnit(0);
             unit.Color = this.customBackgroundColor;
             unit.SetSize(this.Width, this.Height);
             this.bgColorSprt.Visible = true;
             if (this.customBackgroundImage == null)
             {
                 this.bgImageSprt.Image   = null;
                 this.bgImageSprt.Visible = false;
             }
             else if (this.customBackgroundImage.Ready)
             {
                 this.bgImageSprt.Image   = this.customBackgroundImage;
                 this.bgImageSprt.Visible = true;
                 UISpriteUtility.SetupNinePatch(this.bgImageSprt, this.Width, this.Height, 0f, 0f, this.customBackgroundNinePatchMargin);
             }
             else
             {
                 this.bgImageSprt.Visible = false;
                 this.needUpdateSprite    = true;
             }
         }
         for (int i = 0; i < this.bgImageSprt.UnitCount; i++)
         {
             UISpriteUnit unit2 = this.bgImageSprt.GetUnit(i);
             unit2.Color = this.backgroundFilterColor;
         }
     }
 }
Example #18
0
        private void SetupUISpriteNormal()
        {
            this.sprt.Visible          = true;
            this.ninePatchPrim.Visible = false;
            float        num  = (float)this.sprt.Image.Width;
            float        num2 = (float)this.sprt.Image.Height;
            UISpriteUnit unit = this.sprt.GetUnit(0);

            unit.X      = 0f;
            unit.Y      = 0f;
            unit.Width  = this.Width;
            unit.Height = this.Height;
            unit.U1     = this.clipImageX / num;
            unit.V1     = this.clipImageY / num2;
            unit.U2     = (this.clipImageX + this.clipImageWidth) / num;
            unit.V2     = (this.clipImageY + this.clipImageHeight) / num2;
        }
Example #19
0
 private void UpdateTextSprite()
 {
     if ((this.updateFlags & Label.UpdateFlags.Text) == Label.UpdateFlags.Text)
     {
         //FIXME:refresh text texture
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         unit.Color  = this.TextColor;
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.Font = this.Font;
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.LineBreak           = this.LineBreak;
         textRenderHelper.TextTrimming        = this.TextTrimming;
         textRenderHelper.LineGap             = this.LineGap;
         this.textSprt.Visible    = true;
         this.textSprt.ShaderType = ShaderType.TextTexture;
         this.textSprt.__name     = "see UpdateTextSprite";
         if (this.textSprt.Image != null)
         {
             this.textSprt.Image.Dispose();
         }
         //FIXME:write text to memory bitmap
         this.textSprt.Image = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height);
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~Label.UpdateFlags.Text;
     }
 }
Example #20
0
        public int InsertPage(int index, Panel panel)
        {
            if (index < 0 || index > this.pageCount)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (panel == null)
            {
                throw new ArgumentNullException("panel");
            }
            panel.Y      = 0f;
            panel.Width  = this.Width;
            panel.Height = this.Height;
            if (index > 0)
            {
                this.panelContainer.InsertChildBefore(panel, this.panelList[index - 1]);
            }
            else
            {
                this.panelContainer.AddChildFirst(panel);
            }
            this.panelList.Insert(index, panel);
            this.updatePagePos();
            UISprite uISprite = new UISprite(1);

            uISprite.ShaderType = ShaderType.Texture;
            uISprite.Image      = this.normalImage;
            UISpriteUnit unit = uISprite.GetUnit(0);

            unit.X      = 24f * (float)this.pageCount;
            unit.Y      = 0f;
            unit.Width  = 24f;
            unit.Height = 24f;
            this.sprtContainer.RootUIElement.AddChildLast(uISprite);
            this.sprtList.Add(uISprite);
            this.pageCount++;
            if (this.pageIndex >= index || this.pageIndex == -1)
            {
                this.pageIndex++;
                this.panelContainer.X = -(this.Width * (float)this.pageIndex);
            }
            this.UpdateSprite();
            return(index);
        }
Example #21
0
        private void updateSprtSize()
        {
            this.removeTextures();
            this.frontSprt.X = base.Width / 2f;
            this.frontSprt.Y = base.Height / 2f;
            UISpriteUnit unit = this.frontSprt.GetUnit(0);

            unit.Width      = base.Width;
            unit.Height     = base.Height;
            unit.X          = -this.frontSprt.X;
            unit.Y          = -this.frontSprt.Y;
            this.backSprt.X = this.frontSprt.X;
            this.backSprt.Y = this.frontSprt.Y;
            unit            = this.backSprt.GetUnit(0);
            unit.Width      = base.Width;
            unit.Height     = base.Height;
            unit.X          = -this.backSprt.X;
            unit.Y          = -this.backSprt.Y;
        }
Example #22
0
        private void SetupUISpriteAspectInside()
        {
            this.sprt.Visible          = true;
            this.ninePatchPrim.Visible = false;
            float        num  = (float)this.sprt.Image.Width;
            float        num2 = (float)this.sprt.Image.Height;
            float        num3 = this.Width / this.clipImageWidth;
            float        num4 = this.Height / this.clipImageHeight;
            float        num5 = (num3 < num4) ? num3 : num4;
            float        num6 = this.clipImageWidth * num5;
            float        num7 = this.clipImageHeight * num5;
            UISpriteUnit unit = this.sprt.GetUnit(0);

            unit.X      = (this.Width - num6) / 2f;
            unit.Y      = (this.Height - num7) / 2f;
            unit.Width  = num6;
            unit.Height = num7;
            unit.U1     = this.clipImageX / num;
            unit.V1     = this.clipImageY / num2;
            unit.U2     = (this.clipImageX + this.clipImageWidth) / num;
            unit.V2     = (this.clipImageY + this.clipImageHeight) / num2;
        }
Example #23
0
        private bool isExistRenderedUnit()
        {
            if (this.unitCount == 0)
            {
                return(false);
            }
            if (this.finalAlpha < 0.003921569f)
            {
                return(false);
            }
            bool result = false;

            for (int i = 0; i < this.unitCount; i++)
            {
                UISpriteUnit uISpriteUnit = this.units[i];
                if (uISpriteUnit.Color.A * this.finalAlpha >= 0.003921569f && uISpriteUnit.Width > 0f && uISpriteUnit.Height > 0f)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Example #24
0
        private void SetupUISpriteNone()
        {
            this.sprt.Visible          = true;
            this.ninePatchPrim.Visible = false;
            float        num  = (float)this.sprt.Image.Width;
            float        num2 = (float)this.sprt.Image.Height;
            float        num3 = Math.Abs(this.Width - this.clipImageWidth) / 2f;
            float        num4 = Math.Abs(this.Height - this.clipImageHeight) / 2f;
            UISpriteUnit unit = this.sprt.GetUnit(0);

            if (this.clipImageWidth > this.Width)
            {
                unit.X     = 0f;
                unit.Width = this.Width;
                unit.U1    = (this.clipImageX + num3) / num;
                unit.U2    = (this.clipImageX + num3 + this.Width) / num;
            }
            else
            {
                unit.X     = num3;
                unit.Width = this.clipImageWidth;
                unit.U1    = this.clipImageX / num;
                unit.U2    = (this.clipImageX + this.clipImageWidth) / num;
            }
            if (this.clipImageHeight > this.Height)
            {
                unit.Y      = 0f;
                unit.Height = this.Height;
                unit.V1     = (this.clipImageY + num4) / num2;
                unit.V2     = (this.clipImageY + num4 + this.Height) / num2;
                return;
            }
            unit.Y      = num4;
            unit.Height = this.clipImageHeight;
            unit.V1     = this.clipImageY / num2;
            unit.V2     = (this.clipImageY + this.clipImageHeight) / num2;
        }
Example #25
0
        public ProgressBar()
        {
            base.Width                     = 362f;
            base.Height                    = 16f;
            this.progress                  = 0f;
            this.style                     = ProgressBarStyle.Normal;
            this.animationElapsedTime      = 0f;
            this.baseImage                 = new ImageBox();
            this.baseImage.Image           = new ImageAsset(SystemImageAsset.ProgressBarBase);
            this.baseImage.NinePatchMargin = AssetManager.GetNinePatchMargin(SystemImageAsset.ProgressBarBase);
            this.baseImage.ImageScaleType  = ImageScaleType.NinePatch;
            this.baseImage.Width           = 362f;
            this.baseImage.Height          = 16f;
            base.AddChildLast(this.baseImage);
            this.barImage                 = new ImageBox();
            this.barImage.Image           = new ImageAsset(SystemImageAsset.ProgressBarNormal);
            this.barImage.NinePatchMargin = AssetManager.GetNinePatchMargin(SystemImageAsset.ProgressBarNormal);
            this.barImage.ImageScaleType  = ImageScaleType.NinePatch;
            this.barImage.Width           = 0f;
            this.barImage.Height          = 16f;
            base.AddChildLast(this.barImage);
            this.acceleratorSprt                 = new UISprite(1);
            this.acceleratorSprt.X               = 3f;
            this.acceleratorSprt.Y               = 3f;
            this.acceleratorSprt.ShaderType      = ShaderType.Texture;
            this.acceleratorSprt.Image           = new ImageAsset(SystemImageAsset.ProgressBarAccelerator);
            this.acceleratorSprt.Visible         = false;
            this.acceleratorSprt.TextureWrapMode = 0;
            this.acceleratorSprt.BlendMode       = BlendMode.Add;
            this.acceleratorSprt.Alpha           = 0.5f;
            this.barImage.RootUIElement.AddChildLast(this.acceleratorSprt);
            UISpriteUnit unit = this.acceleratorSprt.GetUnit(0);

            unit.Width  = 0f;
            unit.Height = (float)this.acceleratorSprt.Image.Height;
        }
Example #26
0
        protected override void OnStart()
        {
            if (this.texturize)
            {
                base.DrawOrder = TransitionDrawOrder.TransitionUIElement;
            }
            else if (this.nextSceneForward)
            {
                base.DrawOrder = TransitionDrawOrder.CS_NS;
            }
            else
            {
                base.DrawOrder = TransitionDrawOrder.NS_CS;
            }
            switch (this.Interpolator)
            {
            case CrossFadeTransitionInterpolator.EaseOutQuad:
                if (this.nextSceneForward)
                {
                    this.nextInterpolatorCallback    = new AnimationInterpolator(AnimationUtility.EaseOutQuadInterpolator);
                    this.currentInterpolatorCallback = new AnimationInterpolator(this.constInterpolator);
                    goto IL_145;
                }
                this.nextInterpolatorCallback    = new AnimationInterpolator(this.constInterpolator);
                this.currentInterpolatorCallback = new AnimationInterpolator(AnimationUtility.EaseOutQuadInterpolator);
                goto IL_145;

            case CrossFadeTransitionInterpolator.Custom:
                if (this.customNextSceneInterpolator != null)
                {
                    this.nextInterpolatorCallback = this.customNextSceneInterpolator;
                }
                else
                {
                    this.nextInterpolatorCallback = new AnimationInterpolator(this.constInterpolator);
                }
                if (this.customCurrentSceneInterpolator != null)
                {
                    this.currentInterpolatorCallback = this.customCurrentSceneInterpolator;
                    goto IL_145;
                }
                this.currentInterpolatorCallback = new AnimationInterpolator(this.constInterpolator);
                goto IL_145;
            }
            if (this.nextSceneForward)
            {
                this.nextInterpolatorCallback    = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                this.currentInterpolatorCallback = new AnimationInterpolator(this.constInterpolator);
            }
            else
            {
                this.nextInterpolatorCallback    = new AnimationInterpolator(this.constInterpolator);
                this.currentInterpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
            }
IL_145:
            if (this.texturize)
            {
                ImageAsset currentSceneRenderedImage = base.GetCurrentSceneRenderedImage();
                if (this.currentSprt == null)
                {
                    this.currentSprt            = new UISprite(1);
                    this.currentSprt.ShaderType = ShaderType.OffscreenTexture;
                    this.currentSprt.BlendMode  = BlendMode.Premultiplied;
                }
                this.currentSprt.Image = currentSceneRenderedImage;
                UISpriteUnit unit = this.currentSprt.GetUnit(0);
                unit.Width  = (float)UISystem.FramebufferWidth;
                unit.Height = (float)UISystem.FramebufferHeight;
                ImageAsset nextSceneRenderedImage = base.GetNextSceneRenderedImage();
                if (this.nextSprt == null)
                {
                    this.nextSprt            = new UISprite(1);
                    this.nextSprt.ShaderType = ShaderType.OffscreenTexture;
                    this.nextSprt.BlendMode  = BlendMode.Premultiplied;
                }
                this.nextSprt.Image = nextSceneRenderedImage;
                unit        = this.nextSprt.GetUnit(0);
                unit.Width  = (float)UISystem.FramebufferWidth;
                unit.Height = (float)UISystem.FramebufferHeight;
                if (this.nextSceneForward)
                {
                    base.TransitionUIElement.AddChildLast(this.currentSprt);
                    base.TransitionUIElement.AddChildLast(this.nextSprt);
                }
                else
                {
                    base.TransitionUIElement.AddChildLast(this.nextSprt);
                    base.TransitionUIElement.AddChildLast(this.currentSprt);
                }
                this.nextSprt.Alpha = 0f;
            }
            base.NextScene.RootWidget.Alpha = 0f;
        }
Example #27
0
        protected override void OnStart()
        {
            ImageAsset currentSceneRenderedImage = base.GetCurrentSceneRenderedImage();

            this.currentSprt = new UISprite(1);
            base.TransitionUIElement.AddChildLast(this.currentSprt);
            this.currentSprt.ShaderType = ShaderType.OffscreenTexture;
            this.currentSprt.BlendMode  = BlendMode.Premultiplied;
            this.currentSprt.Image      = currentSceneRenderedImage;
            UISpriteUnit unit = this.currentSprt.GetUnit(0);

            unit.Width  = (float)UISystem.FramebufferWidth;
            unit.Height = (float)UISystem.FramebufferHeight;
            ImageAsset nextSceneRenderedImage = base.GetNextSceneRenderedImage();

            this.nextSprt = new UISprite(1);
            base.TransitionUIElement.AddChildLast(this.nextSprt);
            this.nextSprt.ShaderType = ShaderType.OffscreenTexture;
            this.nextSprt.BlendMode  = BlendMode.Premultiplied;
            this.nextSprt.Image      = nextSceneRenderedImage;
            unit        = this.nextSprt.GetUnit(0);
            unit.Width  = (float)UISystem.FramebufferWidth;
            unit.Height = (float)UISystem.FramebufferHeight;
            this.from   = 0f;
            switch (this.MoveDirection)
            {
            case FourWayDirection.Up:
                this.nextSprt.X = 0f;
                this.nextSprt.Y = (this.to = (float)(-(float)UISystem.FramebufferHeight));
                break;

            case FourWayDirection.Down:
                this.nextSprt.X = 0f;
                this.nextSprt.Y = (this.to = (float)UISystem.FramebufferHeight);
                break;

            case FourWayDirection.Left:
                this.nextSprt.X = (this.to = (float)(-(float)UISystem.FramebufferWidth));
                this.nextSprt.Y = 0f;
                break;

            case FourWayDirection.Right:
                this.nextSprt.X = (this.to = (float)UISystem.FramebufferWidth);
                this.nextSprt.Y = 0f;
                break;
            }
            switch (this.Interpolator)
            {
            case PushTransitionInterpolator.Linear:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                return;

            case PushTransitionInterpolator.EaseOutQuad:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.EaseOutQuadInterpolator);
                return;

            case PushTransitionInterpolator.Overshoot:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.OvershootInterpolator);
                return;

            case PushTransitionInterpolator.Elastic:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.ElasticInterpolator);
                return;

            case PushTransitionInterpolator.Custom:
                if (this.CustomInterpolator != null)
                {
                    this.interpolatorCallback = this.CustomInterpolator;
                    return;
                }
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                return;

            default:
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.LinearInterpolator);
                return;
            }
        }
Example #28
0
        protected override void OnStart()
        {
            if (this.Interpolator == FlipBoardEffectInterpolator.Custom && this.CustomInterpolator != null)
            {
                this.interpolatorCallback = this.CustomInterpolator;
            }
            else
            {
                this.interpolatorCallback = new AnimationInterpolator(AnimationUtility.FlipBounceInterpolator);
            }
            int num;
            int num2;
            int num3;
            int num4;

            if (UISystem.Scaled)
            {
                num  = (int)(base.Widget.Width * UISystem.Scale);
                num2 = (int)(base.Widget.Height * UISystem.Scale);
                num3 = (int)(this.NextWidget.Width * UISystem.Scale);
                num4 = (int)(this.NextWidget.Height * UISystem.Scale);
            }
            else
            {
                num  = (int)base.Widget.Width;
                num2 = (int)base.Widget.Height;
                num3 = (int)this.NextWidget.Width;
                num4 = (int)this.NextWidget.Height;
            }
            if (!UISystem.CheckTextureSizeCapacity(num, num2) || !UISystem.CheckTextureSizeCapacity(num3, num4))
            {
                throw new ArgumentOutOfRangeException();
            }
            Texture2D texture2D = new Texture2D(num, num2, false, (PixelFormat)1, (PixelBufferOption)1);

            base.Widget.RenderToTexture(texture2D);
            ImageAsset imageAsset = new ImageAsset(texture2D);

            imageAsset.AdjustScaledSize = true;
            texture2D.Dispose();
            Texture2D texture2D2 = new Texture2D(num3, num4, false, (PixelFormat)1, (PixelBufferOption)1);

            this.NextWidget.RenderToTexture(texture2D2);
            ImageAsset imageAsset2 = new ImageAsset(texture2D2);

            imageAsset2.AdjustScaledSize = true;
            texture2D2.Dispose();
            float     width     = base.Widget.Width;
            float     num5      = base.Widget.Height / 2f;
            float     width2    = this.NextWidget.Width;
            float     num6      = this.NextWidget.Height / 2f;
            PivotType pivotType = base.Widget.PivotType;

            base.Widget.PivotType            = PivotType.MiddleCenter;
            this.centerPosition              = new Vector2(base.Widget.X, base.Widget.Y);
            base.Widget.PivotType            = pivotType;
            pivotType                        = this.NextWidget.PivotType;
            this.NextWidget.PivotType        = PivotType.MiddleCenter;
            this.NextWidget.Transform3D      = Matrix4.Translation(this.centerPosition.X, this.centerPosition.Y, 0f);
            this.NextWidget.PivotType        = pivotType;
            this.currentUpperSprt            = new UISprite(1);
            this.currentUpperSprt.X          = this.centerPosition.X;
            this.currentUpperSprt.Y          = this.centerPosition.Y - num5 * 0.5f;
            this.currentUpperSprt.Image      = imageAsset;
            this.currentUpperSprt.ShaderType = ShaderType.OffscreenTexture;
            this.currentUpperSprt.BlendMode  = BlendMode.Premultiplied;
            UISpriteUnit unit = this.currentUpperSprt.GetUnit(0);

            unit.X                           = -width * 0.5f;
            unit.Y                           = -num5 * 0.5f;
            unit.Width                       = width;
            unit.Height                      = num5;
            unit.V2                          = 0.5f;
            this.currentLowerSprt            = new UISprite(1);
            this.currentLowerSprt.X          = this.centerPosition.X;
            this.currentLowerSprt.Y          = this.centerPosition.Y + num5 * 0.5f;
            this.currentLowerSprt.Image      = imageAsset;
            this.currentLowerSprt.ShaderType = ShaderType.OffscreenTexture;
            this.currentLowerSprt.BlendMode  = BlendMode.Premultiplied;
            UISpriteUnit unit2 = this.currentLowerSprt.GetUnit(0);

            unit2.X                       = -width * 0.5f;
            unit2.Y                       = -num5 * 0.5f;
            unit2.Width                   = width;
            unit2.Height                  = num5;
            unit2.V1                      = 0.5f;
            this.nextUpperSprt            = new UISprite(1);
            this.nextUpperSprt.X          = this.centerPosition.X;
            this.nextUpperSprt.Y          = this.centerPosition.Y - num6 * 0.5f;
            this.nextUpperSprt.Image      = imageAsset2;
            this.nextUpperSprt.ShaderType = ShaderType.OffscreenTexture;
            this.nextUpperSprt.BlendMode  = BlendMode.Premultiplied;
            UISpriteUnit unit3 = this.nextUpperSprt.GetUnit(0);

            unit3.X                       = -width2 * 0.5f;
            unit3.Y                       = -num6 * 0.5f;
            unit3.Width                   = width2;
            unit3.Height                  = num6;
            unit3.V2                      = 0.5f;
            this.nextLowerSprt            = new UISprite(1);
            this.nextLowerSprt.X          = this.centerPosition.X;
            this.nextLowerSprt.Y          = this.centerPosition.Y + num6 * 0.5f;
            this.nextLowerSprt.Image      = imageAsset2;
            this.nextLowerSprt.ShaderType = ShaderType.OffscreenTexture;
            this.nextLowerSprt.BlendMode  = BlendMode.Premultiplied;
            UISpriteUnit unit4 = this.nextLowerSprt.GetUnit(0);

            unit4.X      = -width2 * 0.5f;
            unit4.Y      = -num6 * 0.5f;
            unit4.Width  = width2;
            unit4.Height = num6;
            unit4.V1     = 0.5f;
            base.Widget.Parent.RootUIElement.AddChildLast(this.currentLowerSprt);
            this.NextWidget.Parent.RootUIElement.AddChildLast(this.nextUpperSprt);
            base.Widget.Parent.RootUIElement.AddChildLast(this.currentUpperSprt);
            this.NextWidget.Parent.RootUIElement.AddChildLast(this.nextLowerSprt);
            this.degree                       = 0f;
            this.turnupTime                   = this.Time;
            this.secondZOffset                = num5 / 4f;
            base.Widget.Visible               = false;
            this.NextWidget.Visible           = false;
            this.currentUpperSprt.Culling     = true;
            this.nextLowerSprt.Culling        = true;
            this.currentUpperSprt.ZSort       = true;
            this.currentLowerSprt.ZSort       = true;
            this.nextUpperSprt.ZSort          = true;
            this.nextLowerSprt.ZSort          = true;
            this.currentUpperSprt.ZSortOffset = -this.secondZOffset - this.firstZOffset;
            this.currentLowerSprt.ZSortOffset = 0f;
            this.nextUpperSprt.ZSortOffset    = -this.firstZOffset;
            this.nextLowerSprt.ZSortOffset    = -this.secondZOffset - this.firstZOffset;
            this.RotateNextLowerSprite();
        }
Example #29
0
        protected internal override void Render()
        {
            if (!this.isExistRenderedUnit())
            {
                return;
            }

//			if (__USE_SampleDraw)
//			{
//				Sample.SampleDraw.DrawText("UISprite test", 0xffffffff, 0, 100); //FIXME:
//			}

            GraphicsContext graphicsContext = UISystem.GraphicsContext;

            ShaderProgramManager.ShaderProgramUnit shaderProgramUnit = ShaderProgramManager.GetShaderProgramUnit(base.InternalShaderType);
            graphicsContext.SetShaderProgram(shaderProgramUnit.ShaderProgram);
            Texture2D texture = base.GetTexture();

            if (__USE_SampleDraw)
            {
                texture = Sample.SampleDraw.__DrawText("1234 test", 0xffffffff, 0, 0, new Matrix4(), true);
            }
            graphicsContext.SetTexture(0, texture);
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;

            for (int i = 0; i < this.unitCount; i++)
            {
                UISpriteUnit uISpriteUnit = this.units[i];
                flag  |= uISpriteUnit.NeedUpdatePosition;
                flag2 |= uISpriteUnit.NeedUpdateColor;
                flag3 |= uISpriteUnit.NeedUpdateTexcoord;
                uISpriteUnit.NeedUpdatePosition = false;
                uISpriteUnit.NeedUpdateColor    = false;
                uISpriteUnit.NeedUpdateTexcoord = false;
            }
            if (this.needUpdateVertexAll | flag)
            {
                float[] array = new float[12 * this.UnitCount];
                int     num   = 0;
                for (int j = 0; j < this.unitCount; j++)
                {
                    UISpriteUnit unit = this.GetUnit(j);
                    array[num++] = unit.X;
                    array[num++] = unit.Y;
                    array[num++] = unit.Z;

                    array[num++] = unit.X;
                    array[num++] = unit.Y + unit.Height;
                    array[num++] = unit.Z;

                    array[num++] = unit.X + unit.Width;
                    array[num++] = unit.Y;
                    array[num++] = unit.Z;

                    array[num++] = unit.X + unit.Width;
                    array[num++] = unit.Y + unit.Height;
                    array[num++] = unit.Z;
                }
                this.vertexBuffer.SetVertices(0, array, 0, 0, 4 * this.UnitCount);                 //len==???  //>attrib['a_Position'].location == 0
            }
            if (this.needUpdateVertexAll | flag2)
            {
                UIColor[] array2 = new UIColor[4 * this.UnitCount];
                int       num2   = 0;
                for (int k = 0; k < this.unitCount; k++)
                {
                    UISpriteUnit uISpriteUnit2 = this.units[k];
                    array2[num2++] = uISpriteUnit2.Color;
                    array2[num2++] = uISpriteUnit2.Color;
                    array2[num2++] = uISpriteUnit2.Color;
                    array2[num2++] = uISpriteUnit2.Color;
                }
                this.vertexBuffer.SetVertices(1, array2, 0, 0, 4 * this.UnitCount);                 //len==4  //>attrib['a_Color'].location == 1
            }
            if (texture != null)
            {
                if (this.needUpdateVertexAll | flag3)
                {
                    float[] array3 = new float[8 * this.UnitCount];
                    int     num3   = 0;
                    for (int l = 0; l < this.unitCount; l++)
                    {
                        UISpriteUnit uISpriteUnit3 = this.units[l];
                        array3[num3++] = uISpriteUnit3.U1;
                        array3[num3++] = uISpriteUnit3.V1;
                        array3[num3++] = uISpriteUnit3.U1;
                        array3[num3++] = uISpriteUnit3.V2;
                        array3[num3++] = uISpriteUnit3.U2;
                        array3[num3++] = uISpriteUnit3.V1;
                        array3[num3++] = uISpriteUnit3.U2;
                        array3[num3++] = uISpriteUnit3.V2;
                    }
                    this.vertexBuffer.SetVertices(2, array3, 0, 0, 4 * this.UnitCount);
                }
            }
            else if ((this.needUpdateVertexAll || flag3) && this.unitCount > 0)
            {
                this.units[0].NeedUpdateTexcoord = true;
            }
            if (this.needUpdateVertexAll)
            {
                ushort[] array4 = new ushort[this.UnitCount * 6 - 2];
                ushort   num4   = 0;
                int      num5   = 0;
                while (true)
                {
                    ushort[] arg_3E8_0 = array4;
                    int      expr_3DB  = num5++;
                    ushort   expr_3E2  = num4;
                    num4 = (ushort)(expr_3E2 + 1);
                    arg_3E8_0[expr_3DB] = expr_3E2;
                    ushort[] arg_3FA_0 = array4;
                    int      expr_3ED  = num5++;
                    ushort   expr_3F4  = num4;
                    num4 = (ushort)(expr_3F4 + 1);
                    arg_3FA_0[expr_3ED] = expr_3F4;
                    ushort[] arg_40C_0 = array4;
                    int      expr_3FF  = num5++;
                    ushort   expr_406  = num4;
                    num4 = (ushort)(expr_406 + 1);
                    arg_40C_0[expr_3FF] = expr_406;
                    array4[num5++]      = num4;
                    if (num5 >= array4.Length)
                    {
                        break;
                    }
                    ushort[] arg_432_0 = array4;
                    int      expr_425  = num5++;
                    ushort   expr_42C  = num4;
                    num4 = (ushort)(expr_42C + 1);
                    arg_432_0[expr_425] = expr_42C;
                    array4[num5++]      = num4;
                }
                this.vertexBuffer.SetIndices(array4, 0, 0, array4.Length);
            }
            this.needUpdateVertexAll = false;
            graphicsContext.SetVertexBuffer(0, this.vertexBuffer);
            this.updateLocalToWorld();
            Matrix4 matrix;

            UISystem.viewProjectionMatrix.Multiply(ref this.localToWorld, out matrix);
            shaderProgramUnit.ShaderProgram.SetUniformValue(shaderProgramUnit.UniformIndexOfModelViewProjection, ref matrix);
            shaderProgramUnit.ShaderProgram.SetUniformValue(shaderProgramUnit.UniformIndexOfAlpha, this.finalAlpha);
//			Debug.WriteLine(">>>>>>><<<<<<<<<>>>>>>> base.ShaderUniforms.Count : " + base.ShaderUniforms.Count);
            using (List <string> .Enumerator enumerator = shaderProgramUnit.OtherUniformNames.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    if (base.ShaderUniforms.ContainsKey(current))
                    {
                        shaderProgramUnit.ShaderProgram.SetUniformValue(shaderProgramUnit.Uniforms[current], base.ShaderUniforms[current]);
                    }
                }
            }


//			if (false)
//			{
//			    graphicsContext.Enable(EnableMode.Blend);
//			    graphicsContext.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);
//			}

            graphicsContext.DrawArrays((DrawMode)4, 0, this.UnitCount * 6 - 2);
//			Debug.WriteLine(">>>>>>>>>>>>>>" + (this.UnitCount * 6 - 2));

//			if (__USE_SampleDraw)
//			{
//				Sample.SampleDraw.__DrawText("UISprite test", 0xffffffff, 0, 0, matrix, false); //FIXME:
//			}
        }
Example #30
0
 private void UpdateTextSprite()
 {
     if ((this.updateFlags & EditableText.UpdateFlags.Text) == EditableText.UpdateFlags.Text)
     {
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.X      = 10f;
         unit.Y      = 4f;
         unit.Width  = this.Width - 20f;
         unit.Height = this.Height - 8f;
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.LineBreak           = this.LineBreak;
         textRenderHelper.TextTrimming        = this.TextTrimming;
         textRenderHelper.LineGap             = this.LineGap;
         if (string.IsNullOrEmpty(this.Text))
         {
             unit.Color               = this.DefaultTextColor;
             textRenderHelper.Font    = this.DefaultFont;
             this.textSprt.ShaderType = ShaderType.TextTexture;
             if (this.textSprt.Image != null)
             {
                 this.textSprt.Image.Dispose();
             }
             this.textSprt.Image = textRenderHelper.DrawText(ref this.defaultText, (int)unit.Width, (int)unit.Height);
         }
         else
         {
             string text;
             if (this.TextInputMode == (TextInputMode)2)
             {
                 text = new string('*', this.Text.Length);
             }
             else
             {
                 text = this.Text;
             }
             unit.Color               = this.TextColor;
             textRenderHelper.Font    = this.Font;
             this.textSprt.ShaderType = ShaderType.TextTexture;
             if (this.textSprt.Image != null)
             {
                 this.textSprt.Image.Dispose();
             }
             this.textSprt.Image = textRenderHelper.DrawText(ref text, (int)unit.Width, (int)unit.Height);
         }
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~EditableText.UpdateFlags.Text;
     }
 }