示例#1
0
 public override void CreateUI(GLEx g)
 {
     if (isClose)
     {
         return;
     }
     if (!this.IsVisible())
     {
         return;
     }
     lock (childs)
     {
         base.CreateUI(g);
         if (this.elastic)
         {
             g.SetClip(this.GetScreenX(), this.GetScreenY(),
                       this.GetWidth(), this.GetHeight());
         }
         this.RenderComponents(g);
         if (this.elastic)
         {
             g.ClearClip();
         }
     }
 }
示例#2
0
文件: Sprites.cs 项目: vb0067/LGame
        /// <summary>
        /// 创建UI图像
        /// </summary>
        ///
        /// <param name="g"></param>
        public void CreateUI(GLEx g, int x, int y)
        {
            if (!visible)
            {
                return;
            }
            int minX, minY, maxX, maxY;
            int clipWidth  = g.GetClipWidth();
            int clipHeight = g.GetClipHeight();

            if (this.isViewWindowSet)
            {
                g.SetClip(x, y, this.width, this.height);
                minX = this.viewX;
                maxX = minX + this.width;
                minY = this.viewY;
                maxY = minY + this.height;
            }
            else
            {
                minX = x;
                maxX = x + clipWidth;
                minY = y;
                maxY = y + clipHeight;
            }
            g.Translate(x - this.viewX, y - this.viewY);
            for (int i = 0; i < this.size; i++)
            {
                ISprite spr = sprites[i];
                if (spr.IsVisible())
                {
                    int layerX = spr.X();
                    int layerY = spr.Y();

                    int layerWidth  = spr.GetWidth();
                    int layerHeight = spr.GetHeight();

                    if (layerX + layerWidth < minX || layerX > maxX ||
                        layerY + layerHeight < minY || layerY > maxY)
                    {
                        continue;
                    }

                    spr.CreateUI(g);
                }
            }
            g.Translate(-(x - this.viewX), -(y - this.viewY));
            if (this.isViewWindowSet)
            {
                g.ClearClip();
            }
        }
示例#3
0
        /// <summary>
        /// 渲染当前组件画面于指定绘图器之上
        /// </summary>
        ///
        /// <param name="g"></param>
        public virtual void CreateUI(GLEx g)
        {
            if (isClose)
            {
                return;
            }
            if (!this.visible)
            {
                return;
            }
            int width  = this.GetWidth();
            int height = this.GetHeight();

            if (rotation != 0)
            {
                float centerX = this.screenX + width / 2;
                float centerY = this.screenY + height / 2;
                g.Rotate(centerX, centerY, rotation);
            }
            else if (!(scaleX == 1f && scaleY == 1f))
            {
                g.Scale(scaleX, scaleY);
            }
            else if (this.elastic)
            {
                g.SetClip(this.screenX, this.screenY, width, height);
            }
            // 变更透明度
            if (alpha > 0.1f && alpha < 1.0f)
            {
                g.SetAlpha(alpha);
                if (background != null)
                {
                    g.DrawTexture(background, this.screenX, this.screenY,
                                  this.width, this.height);
                }
                if (this.customRendering)
                {
                    this.CreateCustomUI(g, this.screenX, this.screenY, this.width,
                                        this.height);
                }
                else
                {
                    this.CreateUI(g, this.screenX, this.screenY, this, this.imageUI);
                }
                g.SetAlpha(1.0F);
                // 不变更
            }
            else
            {
                if (background != null)
                {
                    g.DrawTexture(background, this.screenX, this.screenY,
                                  this.width, this.height);
                }
                if (this.customRendering)
                {
                    this.CreateCustomUI(g, this.screenX, this.screenY, this.width,
                                        this.height);
                }
                else
                {
                    this.CreateUI(g, this.screenX, this.screenY, this, this.imageUI);
                }
            }
            if (rotation != 0 || !(scaleX == 1f && scaleY == 1f))
            {
                g.Restore();
            }
            else if (this.elastic)
            {
                g.ClearClip();
            }
        }