Exemplo n.º 1
0
        public virtual void CreateUI(GLEx g)
        {
            if (!visible)
            {
                return;
            }
            image = animation.GetSpriteImage();
            if (image == null)
            {
                return;
            }
            float width  = (image.GetWidth() * scaleX);
            float height = (image.GetHeight() * scaleY);

            if (filterColor == null)
            {
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(alpha);
                }
                if (LTrans.TRANS_NONE == transform)
                {
                    g.DrawTexture(image, X(), Y(), width, height, rotation);
                }
                else
                {
                    g.DrawRegion(image, 0, 0, GetWidth(), GetHeight(), transform,
                                 X(), Y(), LTrans.TOP | LTrans.LEFT);
                }
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(1);
                }
                return;
            }
            else
            {
                Color old = g.GetColor();
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(alpha);
                }
                g.SetColor(filterColor);
                if (LTrans.TRANS_NONE == transform)
                {
                    g.DrawTexture(image, X(), Y(), width, height, rotation);
                }
                else
                {
                    g.DrawRegion(image, 0, 0, GetWidth(), GetHeight(), transform,
                                 X(), Y(), LTrans.TOP | LTrans.LEFT);
                }
                g.SetColor(old);
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(1);
                }
                return;
            }
        }
Exemplo n.º 2
0
 public void CreateUI(GLEx g)
 {
     if (isClose)
     {
         return;
     }
     if (!visible)
     {
         return;
     }
     lock (image)
     {
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(alpha);
         }
         if (!IsComplete() && isDirty)
         {
             g.DrawTexture(image.Texture, x, y, width, height);
             isDirty = false;
         }
         else if (!IsComplete())
         {
             g.DrawTexture(image.Texture, x, y, width, height);
         }
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(1f);
         }
     }
 }
Exemplo n.º 3
0
 public void CreateUI(GLEx g)
 {
     if (!visible)
     {
         return;
     }
     if (style < 2)
     {
         if (alpha > 0.1f && alpha < 1.0f)
         {
             g.SetAlpha(alpha);
             wait.Draw(g, X(), Y());
             g.SetAlpha(1.0F);
         }
         else
         {
             wait.Draw(g, X(), Y());
         }
     }
     else
     {
         if (cycle != null)
         {
             cycle.CreateUI(g);
         }
     }
 }
Exemplo n.º 4
0
        protected internal override void CreateCustomUI(GLEx g, int x, int y, int w, int h)
        {
            if (!visible)
            {
                return;
            }
            LColor oldColor = g.GetColor();
            LFont  oldFont  = g.GetFont();

            g.SetColor(fontColor);
            g.SetFont(messageFont);
            sizeFont       = messageFont.GetSize();
            doubleSizeFont = sizeFont * 2;
            if (doubleSizeFont == 0)
            {
                doubleSizeFont = 20;
            }
            messageLeft = (x + doubleSizeFont + sizeFont / 2) + tmpOffset + left
                          + doubleSizeFont;
            // g.setAntiAlias(true);
            if (message != null)
            {
                messageTop = y + doubleSizeFont + top + 2;
                g.DrawString(message, messageLeft, messageTop);
            }
            else
            {
                messageTop = y + top + 2;
            }

            nTop = messageTop;
            if (selects != null)
            {
                nLeft = messageLeft - sizeFont / 4;
                for (int i = 0; i < selects.Length; i++)
                {
                    nTop    += 30;
                    type     = i + 1;
                    isSelect = (type == ((selectFlag > 0) ? selectFlag : 1));
                    if ((buoyage != null) && isSelect)
                    {
                        g.SetAlpha(autoAlpha);
                        g.DrawTexture(buoyage, nLeft,
                                      nTop - (int)(buoyage.GetHeight() / 1.5f));
                        g.SetAlpha(1.0F);
                    }
                    g.DrawString(selects[i], messageLeft, nTop);
                    if ((cursor != null) && isSelect)
                    {
                        g.DrawTexture(cursor, nLeft, nTop - cursor.GetHeight() / 2, LColor.white);
                    }
                }
            }
            // g.setAntiAlias(false);
            g.SetColor(oldColor);
            g.SetFont(oldFont);
        }
Exemplo n.º 5
0
 // 绘制
 public void Draw(GLEx g)
 {
     if (!visible)
     {
         return;
     }
     alpha = startTime / 255f;
     g.SetAlpha(alpha);
     g.DrawTexture(texture, info.offsetX + x, info.offsetY + y, width, height);
     g.SetAlpha(1f);
 }
Exemplo n.º 6
0
 public override void CreateUI(GLEx g, int x, int y, LComponent component,
                               LTexture[] buttonImage)
 {
     if (this.visible)
     {
         g.SetAlpha(0.5f);
         g.DrawTexture(controlBase, x, y, baseWidth, baseHeight);
         g.DrawTexture(controlDot, x + centerX, y + centerY, dotWidth, dotHeight);
         g.SetAlpha(1f);
     }
 }
Exemplo n.º 7
0
 public virtual void CreateUI(GLEx g)
 {
     if (visible)
     {
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(alpha);
         }
         g.DrawTexture(image, X(), Y());
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(1.0f);
         }
     }
 }
Exemplo n.º 8
0
 public void Draw(GLEx g, LColor old)
 {
     if (!visible)
     {
         return;
     }
     alpha = g.GetAlpha();
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(1.0f);
     }
     DrawMessage(g, old);
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(alpha);
     }
 }
Exemplo n.º 9
0
        public void CreateUI(GLEx g)
        {
            if (!visible)
            {
                return;
            }
            if (!complete)
            {
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(alpha);
                }
                float x1 = v1.x + GetX();
                float y1 = v1.y + GetY();

                float x2 = v2.x + GetX();
                float y2 = v2.y + GetY();
                texture.GLBegin();
                switch (direction)
                {
                case Config.LEFT:
                case Config.RIGHT:
                case Config.TUP:
                case Config.TDOWN:
                    texture.Draw(x1, y1, width, halfHeight, 0, 0, width, halfHeight);
                    texture.Draw(x2, y2, width, halfHeight, 0, halfHeight, width,
                                 height);
                    break;

                case Config.UP:
                case Config.DOWN:
                case Config.TLEFT:
                case Config.TRIGHT:
                    texture.Draw(x1, y1, halfWidth, height, 0, 0, halfWidth, height);
                    texture.Draw(x2, y2, halfWidth, height, halfWidth, 0, width,
                                 height);
                    break;
                }
                texture.GLEnd();
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(1f);
                }
            }
        }
Exemplo n.º 10
0
 public override void Draw(GLEx g)
 {
     if (!running || !IsOnLoadComplete() || IsClose())
     {
         return;
     }
     if (scrCG == null)
     {
         return;
     }
     if (scrCG.sleep == 0)
     {
         scrCG.Paint(g);
         DrawScreen(g);
         if (desktop != null)
         {
             desktop.CreateUI(g);
         }
         if (sprites != null)
         {
             sprites.CreateUI(g);
         }
     }
     else
     {
         scrCG.sleep--;
         if (color != null)
         {
             float alpha = (float)(scrCG.sleepMax - scrCG.sleep)
                           / scrCG.sleepMax;
             if (alpha > 0 && alpha < 1.0)
             {
                 if (scrCG.getBackgroundCG() != null)
                 {
                     g.DrawTexture(scrCG.getBackgroundCG(), 0, 0);
                 }
                 Color c = g.GetColor();
                 g.SetColor(color.R, color.G, color.B, (byte)(alpha * 255));
                 g.FillRect(0, 0, GetWidth(), GetHeight());
                 g.SetColor(c);
             }
             else
             {
                 Color c = g.GetColor();
                 g.SetColor(color);
                 g.FillRect(0, 0, GetWidth(), GetHeight());
                 g.SetColor(c);
             }
         }
         if (scrCG.sleep <= 0)
         {
             scrCG.sleep = 0;
             color       = null;
         }
         g.SetAlpha(1.0f);
     }
 }
Exemplo n.º 11
0
 public void CreateUI(GLEx g)
 {
     if (!visible)
     {
         return;
     }
     if (!complete)
     {
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(alpha);
         }
         g.DrawTexture(texture, X(), Y());
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(1);
         }
     }
 }
Exemplo n.º 12
0
            public override void Step(GLEx g, float x, float y, float progress,
                                      int index, int frame_0, LColor color_1, float alpha_2)
            {
                float cx = this.padding + 50, cy = this.padding + 50, angle = (MathUtils.PI / 180)
                                                                              * (progress * 360);

                alpha_2 = MathUtils.Max(0.5f, alpha_2);
                g.SetAlpha(alpha_2);
                if (path == null)
                {
                    path = new Path(GetX() + x * scale, GetY() + y * scale);
                }
                else
                {
                    path.Clear();
                    path.Set(GetX() + x * scale, GetY() + y * scale);
                }
                path.LineTo(GetX() + ((MathUtils.Cos(angle) * 35) + cx)
                            * scale, GetY()
                            + ((MathUtils.Sin(angle) * 35) + cy) * scale);
                path.Close();
                g.Draw(path);
                if (path == null)
                {
                    path = new Path(GetX()
                                    + ((MathUtils.Cos(-angle) * 32) + cx) * scale,
                                    GetY() + ((MathUtils.Sin(-angle) * 32) + cy)
                                    * scale);
                }
                else
                {
                    path.Clear();
                    path.Set(GetX() + ((MathUtils.Cos(-angle) * 32) + cx)
                             * scale, GetY()
                             + ((MathUtils.Sin(-angle) * 32) + cy) * scale);
                }
                path.LineTo(GetX() + ((MathUtils.Cos(-angle) * 27) + cx)
                            * scale, GetY()
                            + ((MathUtils.Sin(-angle) * 27) + cy) * scale);
                path.Close();
                g.Draw(path);
                g.SetAlpha(1);
            }
Exemplo n.º 13
0
 public virtual void CreateUI(GLEx g)
 {
     if (!visible)
     {
         return;
     }
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(alpha);
     }
     for (int i = 0; i < drops.Length; ++i)
     {
         g.FillOval((int)drops[i].x, (int)drops[i].y, 2, 2, color.Color);
     }
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(1);
     }
 }
Exemplo n.º 14
0
 public void CreateUI(GLEx g)
 {
     if (!visible)
     {
         return;
     }
     if (complete)
     {
         return;
     }
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(alpha);
     }
     if (count <= 1)
     {
         g.SetColor(color);
         g.FillRect(X(), Y(), width, height);
         g.ResetColor();
     }
     else
     {
         g.SetColor(color);
         int length = (int)MathUtils.Sqrt(MathUtils.Pow(width / 2, 2.0f)
                                          + MathUtils.Pow(height / 2, 2.0f));
         float x   = X() + (width / 2 - length);
         float y   = Y() + (height / 2 - length);
         float w   = width / 2 + length - x;
         float h   = height / 2 + length - y;
         float deg = 360f / this.div * this.count;
         g.FillArc(x, y, w, h, 0, this.sign[this.turn] * deg);
         g.ResetColor();
     }
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(1f);
     }
 }
Exemplo n.º 15
0
            public void Draw(GLEx g, int x, int y)
            {
                LColor oldColor = g.GetColor();

                g.SetColor(color);
                switch (style)
                {
                case 0:
                    float alpha = 0.0f;
                    int   nx    = x + width / 2 - (int)r * 4,
                          ny    = y + height / 2 - (int)r * 4;
                    g.Translate(nx, ny);
                    for (IIterator it = new IteratorAdapter(list.GetEnumerator()); it.HasNext();)
                    {
                        RectBox s = (RectBox)it.Next();
                        alpha = alpha + 0.1f;
                        g.SetAlpha(alpha);
                        g.FillOval(s.x, s.y, s.width, s.height);
                    }
                    g.SetAlpha(1.0F);
                    g.Translate(-nx, -ny);
                    break;

                case 1:
                    g.SetLineWidth(10);
                    g.Translate(x, y);
                    g.SetColor(Fill);
                    g.DrawOval(0, 0, width, height);
                    int sa = angle % 360;
                    g.FillArc(x + (width - paintWidth) / 2, y
                              + (height - paintHeight) / 2, paintWidth, paintHeight,
                              sa, sa + ANGLE_STEP);
                    g.Translate(-x, -y);
                    g.ResetLineWidth();
                    break;
                }
                g.SetColor(oldColor);
            }
Exemplo n.º 16
0
 public void CreateUI(GLEx g)
 {
     if (isClose)
     {
         return;
     }
     if (!isVisible)
     {
         return;
     }
     if (IsComplete())
     {
         return;
     }
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(alpha);
     }
     pixmap.Draw(g, X(), Y(), width, height);
     if (alpha > 0 && alpha < 1)
     {
         g.SetAlpha(1f);
     }
 }
Exemplo n.º 17
0
 public virtual void CreateUI(GLEx g)
 {
     if (visible)
     {
         LFont oldFont  = g.GetFont();
         Color oldColor = g.GetColor();
         g.SetFont(font);
         g.SetColor(color);
         this.width  = font.StringWidth(label);
         this.height = font.GetSize();
         if (alpha > 0 && alpha < 1)
         {
             g.SetAlpha(alpha);
             g.DrawString(label, X(), Y() - font.GetAscent());
             g.SetAlpha(1.0F);
         }
         else
         {
             g.DrawString(label, X(), Y() - font.GetAscent());
         }
         g.SetFont(oldFont);
         g.SetColor(oldColor);
     }
 }
Exemplo n.º 18
0
            public void Draw(GLEx g, int x, int y)
            {
                switch (style)
                {
                case 0:
                    Color oldColor = g.GetColor();
                    g.SetColor(color);
                    float alpha = 0.0f;
                    int   nx    = x + width / 2 - (int)r * 4,
                          ny    = y + height / 2 - (int)r * 4;
                    g.Translate(nx, ny);
                    for (IEnumerator <RectBox> it = list.GetEnumerator(); it.MoveNext();)
                    {
                        RectBox s = it.Current;
                        alpha = alpha + 0.1f;
                        g.SetAlpha(alpha);
                        g.FillOval(s.x, s.y, s.width, s.height);
                    }
                    g.SetAlpha(1.0F);
                    g.Translate(-nx, -ny);
                    g.SetColor(oldColor);
                    break;

                case 1:
                    g.SetLineWidth(10);
                    g.Translate(x, y);
                    g.FillOval(0, 0, width, height, fill.Color);
                    int sa = angle % 360;
                    g.FillArc(x + (width - paintWidth) / 2, y
                              + (height - paintHeight) / 2, paintWidth, paintHeight,
                              sa, sa + ANGLE_STEP, Color.Red);
                    g.Translate(-x, -y);
                    g.ResetLineWidth();
                    break;
                }
            }
Exemplo n.º 19
0
 public void Draw(GLEx gl)
 {
     if (logo == null || finish)
     {
         return;
     }
     if (!logo.IsLoaded())
     {
         this.logo.LoadTexture();
     }
     if (centerX == 0 || centerY == 0)
     {
         this.centerX = (int)(LSystem.screenRect.width)
                        / 2 - logo.GetWidth() / 2;
         this.centerY = (int)(LSystem.screenRect.height)
                        / 2 - logo.GetHeight() / 2;
     }
     if (logo == null || !logo.IsLoaded())
     {
         return;
     }
     alpha = (curFrame / curTime);
     if (inToOut)
     {
         curFrame++;
         if (curFrame == curTime)
         {
             alpha   = 1f;
             inToOut = false;
         }
     }
     else if (!inToOut)
     {
         curFrame--;
         if (curFrame == 0)
         {
             alpha  = 0f;
             finish = true;
         }
     }
     gl.Reset(true);
     gl.SetAlpha(alpha);
     gl.DrawTexture(logo, centerX, centerY);
 }
Exemplo n.º 20
0
        protected override void CreateCustomUI(GLEx g, int x, int y, int w,
                                               int h)
        {
            if (!visible)
            {
                return;
            }
            LFont oldFont = g.GetFont();

            g.SetFont(messageFont);
            print.Draw(g, fontColor);
            g.SetFont(oldFont);
            if (print.IsComplete() && animation != null)
            {
                if (animation.GetSpriteImage() != null)
                {
                    g.SetAlpha(1.0F);
                    UpdateIcon();
                    g.DrawTexture(animation.GetSpriteImage(), dx, dy);
                }
            }
            g.ResetColor();
        }
Exemplo n.º 21
0
        public void CreateUI(GLEx g)
        {
            if (!visible)
            {
                return;
            }
            if (complete)
            {
                if (ntexture != null)
                {
                    if (alpha > 0 && alpha < 1)
                    {
                        g.SetAlpha(alpha);
                    }
                    g.DrawTexture(ntexture, X(), Y());
                    if (alpha > 0 && alpha < 1)
                    {
                        g.SetAlpha(1f);
                    }
                }
                return;
            }
            if (alpha > 0 && alpha < 1)
            {
                g.SetAlpha(alpha);
            }
            part  = 0;
            left  = 0;
            right = 0;
            tmp   = null;
            switch (code)
            {
            default:
                part = width / this.maxcount / 2;
                for (int i = 0; i <= this.maxcount; i++)
                {
                    if (i <= this.count)
                    {
                        tmp = this.ntexture;
                        if (tmp == null)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        tmp = this.otexture;
                    }
                    tmp.GLBegin();
                    left  = i * 2 * part;
                    right = width - ((i + 1) * 2 - 1) * part;
                    tmp.Draw(X() + left, Y(), part, height, left, 0, left + part,
                             height);
                    tmp.Draw(X() + right, Y(), part, height, right, 0,
                             right + part, height);
                    tmp.GLEnd();
                }
                break;

            case 1:

                part = height / this.maxcount / 2;
                for (int i = 0; i <= this.maxcount; i++)
                {
                    if (i <= this.count)
                    {
                        tmp = this.ntexture;
                        if (tmp == null)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        tmp = this.otexture;
                    }
                    int up   = i * 2 * part;
                    int down = height - ((i + 1) * 2 - 1) * part;
                    tmp.GLBegin();
                    tmp.Draw(0, up, width, part, 0, up, width, up + part);
                    tmp.Draw(0, down, width, part, 0, down, width, down + part);
                    tmp.GLEnd();
                }
                break;
            }
            if (alpha > 0 && alpha < 1)
            {
                g.SetAlpha(1f);
            }
        }
Exemplo n.º 22
0
 public void Paint(GLEx g)
 {
     if (background != null)
     {
         if (shakeNumber > 0)
         {
             g.DrawTexture(background,
                           shakeNumber / 2 - LSystem.random.Next(shakeNumber),
                           shakeNumber / 2 - LSystem.random.Next(shakeNumber));
         }
         else
         {
             g.DrawTexture(background, 0, 0);
         }
     }
     lock (charas)
     {
         for (int i = 0; i < charas.Size(); i++)
         {
             AVGChara chara = (AVGChara)charas.Get(i);
             if (chara == null || !chara.isVisible)
             {
                 continue;
             }
             if (style)
             {
                 if (chara.flag != -1)
                 {
                     if (chara.flag == FadeEffect.TYPE_FADE_IN)
                     {
                         chara.currentFrame--;
                         if (chara.currentFrame == 0)
                         {
                             chara.opacity = 0;
                             chara.flag    = -1;
                             chara.Dispose();
                             charas.Remove(chara);
                         }
                     }
                     else
                     {
                         chara.currentFrame++;
                         if (chara.currentFrame == chara.time)
                         {
                             chara.opacity = 0;
                             chara.flag    = -1;
                         }
                     }
                     chara.opacity = (chara.currentFrame / chara.time) * 255;
                     if (chara.opacity > 0)
                     {
                         g.SetAlpha(chara.opacity / 255);
                     }
                 }
             }
             if (chara.isAnimation)
             {
                 AVGAnm animation = chara.anm;
                 if (animation.load)
                 {
                     if (animation.loop && animation.startTime == -1)
                     {
                         animation.Start(0, loop);
                     }
                     Point.Point2i point = animation.GetPos(JavaRuntime
                                                            .CurrentTimeMillis());
                     if (animation.alpha != 1f)
                     {
                         g.SetAlpha(animation.alpha);
                     }
                     g.DrawTexture(animation.texture, chara.x, chara.y,
                                   animation.width, animation.height, point.x,
                                   point.y, point.x + animation.imageWidth,
                                   point.y + animation.imageHeight,
                                   animation.angle, animation.color);
                     if (animation.alpha != 1f)
                     {
                         g.SetAlpha(1f);
                     }
                 }
             }
             else
             {
                 chara.Next();
                 chara.draw(g);
             }
             if (style)
             {
                 if (chara.flag != -1 && chara.opacity > 0)
                 {
                     g.SetAlpha(1f);
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
        public virtual void CreateUI(GLEx g)
        {
            if (!isVisible)
            {
                return;
            }

            this.Setup();

            int pointsLength = points.Count;

            CycleProgress point;
            int           index;
            int           frameD;
            int           indexD;

            float size = (pointsLength * this.trailLength);

            for (float i = -1, l = size; ++i < l && !this.stopped;)
            {
                index = (int)(frame + i);
                if (index < pointsLength)
                {
                    point = points[index];
                }
                else
                {
                    point = points[index - pointsLength];
                }
                this.alpha = (i / (l - 1));
                frameD     = frame / (pointsLength - 1);
                indexD     = (int)alpha;
                if (lineWidth > 0)
                {
                    g.SetLineWidth(lineWidth);
                }
                if (scaleX != 1 || scaleY != 1)
                {
                    g.Scale(scaleX, scaleY);
                }
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(alpha);
                }
                g.SetColor(color);
                Step(g, point, indexD, frameD, color, alpha);
                g.ResetColor();
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(1);
                }
                if (lineWidth > 0)
                {
                    g.ResetLineWidth();
                }
                if (scaleX != 1 || scaleY != 1)
                {
                    g.Restore();
                }
            }
        }
Exemplo n.º 24
0
        protected override void CreateCustomUI(GLEx g, int x, int y, int w, int h)
        {
            if (!visible)
            {
                return;
            }
            if (batch == null)
            {
                return;
            }
            sizeFont = messageFont.GetSize();
            if (sizeFont > 25)
            {
                sizeFont       = messageFont.GetSize();
                doubleSizeFont = sizeFont * 2;
                if (doubleSizeFont == 0)
                {
                    doubleSizeFont = 20;
                }
                messageLeft = (x + doubleSizeFont + sizeFont / 2) + tmpOffset + left
                              + doubleSizeFont;

                batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, GLEx.Device.RasterizerState, null, GLEx.cemera.viewMatrix);

                if (message != null)
                {
                    messageTop = y + doubleSizeFont + top - 10;
                    batch.DrawString(messageFont.Font, message, new Vector2(messageLeft, messageTop), fontColor.Color);
                }
                else
                {
                    messageTop = y + top;
                }
                nTop = messageTop;
                if (selects != null)
                {
                    nLeft = messageLeft - sizeFont / 4;

                    for (int i = 0; i < selects.Length; i++)
                    {
                        nTop    += messageFont.GetHeight();
                        type     = i + 1;
                        isSelect = (type == ((selectFlag > 0) ? selectFlag : 1));
                        if ((buoyage != null) && isSelect)
                        {
                            g.SetAlpha(autoAlpha);
                            g.DrawTexture(buoyage, nLeft,
                                          nTop - (int)(buoyage.GetHeight() / 1.5f));
                            g.SetAlpha(1.0F);
                        }
                        batch.DrawString(messageFont.Font, selects[i], new Vector2(messageLeft, nTop), fontColor.Color);
                        if ((cursor != null) && isSelect)
                        {
                            batch.Draw(cursor.Texture, new Vector2(nLeft, nTop - cursor.GetHeight() / 4), Color.White);
                        }
                    }
                    batch.End();
                }
            }
            else
            {
                doubleSizeFont = (int)(sizeFont * 1.4f * 2);
                if (doubleSizeFont == 0)
                {
                    doubleSizeFont = 20;
                }
                messageLeft = (x + doubleSizeFont + sizeFont / 2) + tmpOffset + left
                              + doubleSizeFont;
                batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

                if (message != null)
                {
                    messageTop = y + doubleSizeFont + top + (int)(messageFont.GetAscent() * 2) + 10;
                    batch.DrawString(messageFont.Font, message, new Vector2(messageLeft, messageTop), fontColor.Color);
                }
                else
                {
                    messageTop = y + top + (int)(messageFont.GetAscent() * 2) + 10;
                }
                nTop = messageTop;
                if (selects != null)
                {
                    nLeft = messageLeft - sizeFont / 4;

                    for (int i = 0; i < selects.Length; i++)
                    {
                        nTop    += (int)((messageFont.GetHeight() + messageFont.GetAscent()) * 1.2f);
                        type     = i + 1;
                        isSelect = (type == ((selectFlag > 0) ? selectFlag : 1));
                        if ((buoyage != null) && isSelect)
                        {
                            g.SetAlpha(autoAlpha);
                            g.DrawTexture(buoyage, nLeft,
                                          nTop - (int)(buoyage.GetHeight() / 1.5f));
                            g.SetAlpha(1.0F);
                        }
                        batch.DrawString(messageFont.Font, selects[i], new Vector2(messageLeft, nTop), fontColor.Color);
                        if ((cursor != null) && isSelect)
                        {
                            batch.Draw(cursor.Texture, new Vector2(nLeft, (nTop - cursor.GetHeight() / 4)), Color.White);
                        }
                    }
                    batch.End();
                }
            }
        }
Exemplo n.º 25
0
        public void PaintObjects(GLEx g, int minX, int minY, int maxX, int maxY)
        {
            lock (objects)
            {
                batch.Begin();
                IIterator it = objects.Iterator();
                for (; it.HasNext();)
                {
                    thing = (Actor)it.Next();
                    if (!thing.visible)
                    {
                        continue;
                    }
                    isListener = (thing.actorListener != null);

                    if (isVSync)
                    {
                        if (isListener)
                        {
                            thing.actorListener.Update(elapsedTime);
                        }
                        thing.Update(elapsedTime);
                    }

                    RectBox rect = thing.GetRectBox();
                    actorX      = minX + thing.GetX();
                    actorY      = minY + thing.GetY();
                    actorWidth  = rect.width;
                    actorHeight = rect.height;
                    if (actorX + actorWidth < minX || actorX > maxX ||
                        actorY + actorHeight < minY || actorY > maxY)
                    {
                        continue;
                    }
                    LTexture actorImage = thing.GetImage();
                    if (actorImage != null)
                    {
                        width          = (actorImage.GetWidth() * thing.scaleX);
                        height         = (actorImage.GetHeight() * thing.scaleY);
                        isBitmapFilter = (thing.filterColor != null);
                        thing.SetLastPaintSeqNum(paintSeq++);
                        angle      = thing.GetRotation();
                        colorAlpha = thing.alpha;

                        if (isBitmapFilter)
                        {
                            batch.Draw(actorImage, actorX, actorY, width,
                                       height, angle, thing.filterColor);
                        }
                        else
                        {
                            if (colorAlpha != 1f)
                            {
                                g.SetAlpha(colorAlpha);
                            }
                            batch.Draw(actorImage, actorX, actorY, width,
                                       height, angle);
                            if (colorAlpha != 1f)
                            {
                                g.SetAlpha(1f);
                            }
                        }
                    }
                    if (actorX == 0 && actorY == 0)
                    {
                        thing.Draw(g);
                        if (isListener)
                        {
                            thing.actorListener.Draw(g);
                        }
                    }
                    else
                    {
                        g.Translate(actorX, actorY);
                        thing.Draw(g);
                        if (isListener)
                        {
                            thing.actorListener.Draw(g);
                        }
                        g.Translate(-actorX, -actorY);
                    }
                }
                batch.End();
            }
        }
Exemplo n.º 26
0
        public void CreateUI(GLEx g)
        {
            if (!visible)
            {
                return;
            }
            if (alpha > 0 && alpha < 1)
            {
                g.SetAlpha(alpha);
            }
            texture.GLBegin();
            switch (code)
            {
            case Config.DOWN:
            case Config.TDOWN:
                for (int i = -1; i < 1; i++)
                {
                    for (int j = 0; j < 1; j++)
                    {
                        texture.Draw(X() + (j * width), Y()
                                     + (i * height + backgroundLoop), width, height, 0,
                                     0, width, height);
                    }
                }
                break;

            case Config.RIGHT:
            case Config.TRIGHT:
                for (int j = -1; j < 1; j++)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        texture.Draw(X() + (j * width + backgroundLoop), Y()
                                     + (i * height), width, height, 0, 0, width, height);
                    }
                }
                break;

            case Config.UP:
            case Config.TUP:
                for (int i = -1; i < 1; i++)
                {
                    for (int j = 0; j < 1; j++)
                    {
                        texture.Draw(X() + (j * width), Y()
                                     - (i * height + backgroundLoop), width, height, 0,
                                     0, width, height);
                    }
                }
                break;

            case Config.LEFT:
            case Config.TLEFT:
                for (int j = -1; j < 1; j++)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        texture.Draw(X() - (j * width + backgroundLoop), Y()
                                     + (i * height), width, height, 0, 0, width, height);
                    }
                }
                break;
            }
            texture.GLEnd();
            if (alpha > 0 && alpha < 1)
            {
                g.SetAlpha(1f);
            }
        }
Exemplo n.º 27
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();
            }
        }
Exemplo n.º 28
0
        public virtual void PaintObjects(GLEx g, int minX, int minY, int maxX, int maxY)
        {
            lock (objects)
            {
                IIterator it = objects.Iterator();
                for (; it.HasNext();)
                {
                    thing = (Actor)it.Next();
                    if (!thing.visible)
                    {
                        continue;
                    }
                    isListener = (thing.actorListener != null);

                    if (isVSync)
                    {
                        if (isListener)
                        {
                            thing.actorListener.Update(elapsedTime);
                        }
                        thing.Update(elapsedTime);
                    }

                    RectBox rect = thing.GetRectBox();
                    actorX      = minX + thing.GetX();
                    actorY      = minY + thing.GetY();
                    actorWidth  = rect.width;
                    actorHeight = rect.height;
                    if (actorX + actorWidth < minX || actorX > maxX ||
                        actorY + actorHeight < minY || actorY > maxY)
                    {
                        continue;
                    }
                    LTexture actorImage = thing.GetImage();
                    if (actorImage != null)
                    {
                        width          = (actorImage.GetWidth() * thing.scaleX);
                        height         = (actorImage.GetHeight() * thing.scaleY);
                        isBitmapFilter = (thing.filterColor != null);
                        thing.SetLastPaintSeqNum(paintSeq++);
                        angle      = thing.GetRotation();
                        colorAlpha = thing.alpha;

                        if (thing.isAnimation)
                        {
                            if (isBitmapFilter)
                            {
                                g.DrawTexture(actorImage, actorX, actorY, width,
                                              height, angle, thing.filterColor);
                            }
                            else
                            {
                                if (colorAlpha != 1f)
                                {
                                    g.SetAlpha(colorAlpha);
                                }
                                g.DrawTexture(actorImage, actorX, actorY, width,
                                              height, angle);
                                if (colorAlpha != 1f)
                                {
                                    g.SetAlpha(1f);
                                }
                            }
                        }
                        else
                        {
                            int texId = actorImage.GetTextureID();

                            LTextureBatch batch = (LTextureBatch)textures
                                                  .GetValue(texId);

                            if (batch == null)
                            {
                                LTextureBatch pBatch = LTextureBatch
                                                       .BindBatchCache(this, texId,
                                                                       actorImage);
                                batch = pBatch;
                                batch.GLBegin();

                                textures.Put(texId, batch);
                            }

                            batch.SetTexture(actorImage);

                            if (isBitmapFilter)
                            {
                                batch.Draw(actorX, actorY, width, height, angle,
                                           thing.filterColor);
                            }
                            else
                            {
                                if (colorAlpha != 1f)
                                {
                                    alphaColor.a = colorAlpha;
                                }
                                batch.Draw(actorX, actorY, width, height, angle,
                                           alphaColor);
                                if (colorAlpha != 1f)
                                {
                                    alphaColor.a = 1;
                                }
                            }
                        }
                    }
                    if (thing.isConsumerDrawing)
                    {
                        if (actorX == 0 && actorY == 0)
                        {
                            thing.Draw(g);
                            if (isListener)
                            {
                                thing.actorListener.Draw(g);
                            }
                        }
                        else
                        {
                            g.Translate(actorX, actorY);
                            thing.Draw(g);
                            if (isListener)
                            {
                                thing.actorListener.Draw(g);
                            }
                            g.Translate(-actorX, -actorY);
                        }
                    }
                }

                int size = textures.Size();
                if (size > 0)
                {
                    for (int i = 0; i < size; i++)
                    {
                        LTextureBatch batch = (LTextureBatch)textures.Get(i);
                        batch.GLEnd();
                    }
                    textures.Clear();
                }
            }
        }