示例#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;
            }
        }
示例#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);
         }
     }
 }
示例#3
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);
        }
示例#4
0
文件: LControl.cs 项目: vb0067/LGame
 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);
     }
 }
示例#5
0
文件: LButton.cs 项目: vb0067/LGame
        public override void CreateUI(GLEx g, int x, int y, LComponent component,
                                      LTexture[] buttonImage)
        {
            LButton button = (LButton)component;

            if (buttonImage != null)
            {
                if (!button.IsEnabled())
                {
                    g.DrawTexture(buttonImage[3], x, y);
                }
                else if (button.IsTouchPressed())
                {
                    g.DrawTexture(buttonImage[2], x, y);
                }
                else if (button.IsTouchOver())
                {
                    g.DrawTexture(buttonImage[1], x, y);
                }
                else
                {
                    if (type == 1)
                    {
                        g.DrawTexture(buttonImage[0], x, y, LColor.gray);
                    }
                    else
                    {
                        g.DrawTexture(buttonImage[0], x, y);
                    }
                }
            }
            if (text != null)
            {
                LFont old = g.GetFont();
                g.SetFont(font);
                g.SetColor(fontColor);
                g.DrawString(
                    text,
                    x + button.GetOffsetLeft()
                    + (button.GetWidth() - font.StringWidth(text)) / 2,
                    y + button.GetOffsetTop()
                    + (button.GetHeight() - font.GetLineHeight()) / 2
                    + font.GetLineHeight());
                g.SetFont(old);
                g.ResetColor();
            }
        }
示例#6
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);
     }
 }
示例#7
0
 public void Draw(GLEx g, float x, float y, float w, float h)
 {
     if (isClose)
     {
         return;
     }
     lock (buffer)
     {
         g.DrawTexture(buffer.Texture, x, y, w, h);
     }
 }
示例#8
0
文件: LInfo.cs 项目: vb0067/LGame
 // 绘制
 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);
 }
示例#9
0
 public void Draw(GLEx g, int x, int y, int sx, int sy, LColor[] color)
 {
     if (target.IsBatch())
     {
         float nx = sx * tw;
         float ny = sy * th;
         target.Draw(x, y, tw, th, nx, ny, nx + tw, ny + th, color);
     }
     else
     {
         CheckImage(sx, sy);
         g.DrawTexture(subImages[sx][sy], x, y);
     }
 }
示例#10
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);
         }
     }
 }
示例#11
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);
 }
示例#12
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);
         }
     }
 }
示例#13
0
文件: LPaper.cs 项目: vb0067/LGame
 protected override void CreateCustomUI(GLEx g, int x, int y, int w, int h)
 {
     if (visible)
     {
         if (animation.GetSpriteImage() != null)
         {
             g.DrawTexture(animation.GetSpriteImage(), x, y);
         }
         if (x != 0 && y != 0)
         {
             g.Translate(x, y);
             Paint(g);
             g.Translate(-x, -y);
         }
         else
         {
             Paint(g);
         }
     }
 }
示例#14
0
文件: Grid.cs 项目: zx8326123/LGame
        public override void CreateUI(GLEx g)
        {
            base.CreateUI(g);
            switch (type)
            {
            case 0:
                if (a1 == null)
                {
                    a1 = Animation.GetDefaultAnimation("assets/s.png", 3, 48, 48,
                                                       100);
                }
                animation = a1;
                break;

            case 2:
                if (a2 == null)
                {
                    a2 = Animation
                         .GetDefaultAnimation("assets/s1.png", 48, 48, 100);
                }
                animation = a2;
                break;

            default:
                break;
            }
            if (animation == null)
            {
                return;
            }
            if (type == 0 || type == 2)
            {
                LTexture img = animation.GetSpriteImage();
                if (img != null)
                {
                    g.DrawTexture(img, X() + (GetWidth() - img.GetWidth()) / 2, Y()
                                  + (GetHeight() - img.GetHeight()) / 2);
                }
            }
        }
示例#15
0
 public void DrawHeight(GLEx g, int x, int y)
 {
     try {
         if (drawTexHeight == null)
         {
             LImage    img = LImage.CreateImage(width, height, true);
             LGraphics gl  = img.GetLGraphics();
             for (int i = 0; i < height; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (height - i)) / height
                     + (end.GetRed() * i) / height,
                     (start.GetGreen() * (height - i)) / height
                     + (end.GetGreen() * i) / height,
                     (start.GetBlue() * (height - i)) / height
                     + (end.GetBlue() * i) / height, alpha);
                 gl.DrawLine(0, i, width, i);
             }
             drawTexHeight = new LTexture(GLLoader.GetTextureData(img),
                                          Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
             gl.Dispose();
             gl = null;
         }
         g.DrawTexture(drawTexHeight, x, y);
     } catch (Exception) {
         for (int i = 0; i < height; i++)
         {
             g.SetColorValue(
                 (start.GetRed() * (height - i)) / height
                 + (end.GetRed() * i) / height,
                 (start.GetGreen() * (height - i)) / height
                 + (end.GetGreen() * i) / height,
                 (start.GetBlue() * (height - i)) / height
                 + (end.GetBlue() * i) / height, alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
示例#16
0
 public void DrawWidth(GLEx g, int x, int y)
 {
     try {
         if (drawTexWidth == null)
         {
             LImage    img = LImage.CreateImage(width, height, true);
             LGraphics gl  = img.GetLGraphics();
             for (int i = 0; i < width; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (width - i)) / width
                     + (end.GetRed() * i) / width,
                     (start.GetGreen() * (width - i)) / width
                     + (end.GetGreen() * i) / width,
                     (start.GetBlue() * (width - i)) / width
                     + (end.GetBlue() * i) / width, alpha);
                 gl.DrawLine(i, 0, i, height);
             }
             drawTexWidth = new LTexture(GLLoader.GetTextureData(img),
                                         Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
             gl.Dispose();
             gl = null;
         }
         g.DrawTexture(drawTexWidth, x, y);
     } catch (Exception) {
         for (int i = 0; i < width; i++)
         {
             g.SetColorValue(
                 (start.GetRed() * (width - i)) / width
                 + (end.GetRed() * i) / width,
                 (start.GetGreen() * (width - i)) / width
                 + (end.GetGreen() * i) / width,
                 (start.GetBlue() * (width - i)) / width
                 + (end.GetBlue() * i) / width, alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
示例#17
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();
        }
示例#18
0
 public void DrawWidth(GLEx g, int x, int y)
 {
     try
     {
         if (drawTexWidth == null)
         {
             LPixmap img = new LPixmap(width, height, true);
             for (int i = 0; i < width; i++)
             {
                 img.SetColor(
                     (byte)((start.R * (width - i)) / width
                            + (end.R * i) / width),
                     (byte)((start.G * (width - i)) / width
                            + (end.G * i) / width),
                     (byte)((start.B * (width - i)) / width
                            + (end.B * i) / width), (byte)alpha);
                 img.DrawLine(i, 0, i, height);
             }
             drawTexWidth = img.Texture;
         }
         g.DrawTexture(drawTexWidth, x, y);
     }
     catch
     {
         for (int i = 0; i < width; i++)
         {
             g.SetColor(
                 (byte)((start.R * (width - i)) / width
                        + (end.R * i) / width),
                 (byte)((start.G * (width - i)) / width
                        + (end.G * i) / width),
                 (byte)((start.B * (width - i)) / width
                        + (end.B * i) / width), (byte)alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
示例#19
0
 public void DrawHeight(GLEx g, int x, int y)
 {
     try
     {
         if (drawTexHeight == null)
         {
             LPixmap img = new LPixmap(width, height, true);
             for (int i = 0; i < height; i++)
             {
                 img.SetColor((byte)(
                                  (start.R * (height - i)) / height
                                  + (end.R * i) / height),
                              (byte)((start.G * (height - i)) / height
                                     + (end.G * i) / height),
                              (byte)((start.B * (height - i)) / height
                                     + (end.B * i) / height), (byte)(alpha));
                 img.DrawLine(0, i, width, i);
             }
             drawTexHeight = img.Texture;
         }
         g.DrawTexture(drawTexHeight, x, y);
     }
     catch
     {
         for (int i = 0; i < height; i++)
         {
             g.SetColor(
                 (byte)((start.R * (height - i)) / height
                        + (end.R * i) / height),
                 (byte)((start.G * (height - i)) / height
                        + (end.G * i) / height),
                 (byte)((start.B * (height - i)) / height
                        + (end.B * i) / height), (byte)alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
示例#20
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);
            }
        }
示例#21
0
文件: AVGChara.cs 项目: vb0067/LGame
 internal void draw(GLEx g)
 {
     g.DrawTexture(characterCG, moveX, y);
 }
示例#22
0
        public void Draw(GLEx gl, long elapsed)
        {
            if (logo == null || finish)
            {
                return;
            }
            if (!logo.isLoaded)
            {
                this.logo.LoadTexture();
                this.centerX = (int)(LSystem.screenRect.width * LSystem.scaleWidth) / 2 - logo.Width / 2;
                this.centerY = (int)(LSystem.screenRect.height * LSystem.scaleHeight) / 2 - logo.Height / 2;
            }
            if (logo == null || !logo.isLoaded)
            {
                finish = true;
                return;
            }
            lock (logo)
            {
                gl.Clear();
                color.A = (byte)(255 * alpha);
                gl.DrawTexture(logo, centerX, centerY, color);
            }
            switch (type)
            {
            case 0:
                if (alpha >= 1f)
                {
                    alpha = 1f;
                    type  = 1;
                }
                if (alpha < 1.0f)
                {
                    if (timer.Action(elapsed))
                    {
                        alpha += 0.015f;
                    }
                }
                break;

            case 1:
                if (timer.Action(elapsed))
                {
                    alpha = 1f;
                    type  = 2;
                }
                break;

            case 2:
                if (alpha > 0.0f)
                {
                    if (timer.Action(elapsed))
                    {
                        alpha -= 0.015f;
                    }
                }
                else if (alpha <= 0f)
                {
                    alpha  = 0;
                    type   = 3;
                    finish = true;
                    if (logo != null)
                    {
                        logo.Destroy();
                        logo = null;
                    }
                    return;
                }
                break;
            }
        }
示例#23
0
        protected virtual void DrawXNA(float totalSeconds)
        {
            GLEx gl = process.GL;

            if (gl != null)
            {
                if (!process.Next())
                {
                    return;
                }

                if (isScale)
                {
                    gl.Scale(LSystem.scaleWidth,
                             LSystem.scaleHeight);
                }

                int repaintMode = process.GetRepaintMode();

                switch (repaintMode)
                {
                case Screen.SCREEN_BITMAP_REPAINT:
                    gl.Reset(clear);
                    if (process.GetX() == 0 && process.GetY() == 0)
                    {
                        gl.DrawTexture(process.GetBackground(), 0, 0);
                    }
                    else
                    {
                        gl.DrawTexture(process.GetBackground(), process.GetX(),
                                       process.GetY());
                    }
                    break;

                case Screen.SCREEN_COLOR_REPAINT:
                    LColor c = process.GetColor();
                    if (c != null)
                    {
                        gl.DrawClear(c);
                    }
                    break;

                case Screen.SCREEN_CANVAS_REPAINT:
                    gl.Reset(clear);
                    break;

                case Screen.SCREEN_NOT_REPAINT:
                    gl.Reset(clear);
                    break;

                default:
                    gl.Reset(clear);
                    if (process.GetX() == 0 && process.GetY() == 0)
                    {
                        gl.DrawTexture(
                            process.GetBackground(),
                            repaintMode / 2
                            - LSystem.random.Next(repaintMode),
                            repaintMode / 2
                            - LSystem.random.Next(repaintMode));
                    }
                    else
                    {
                        gl.DrawTexture(process.GetBackground(),
                                       process.GetX() + repaintMode / 2
                                       - LSystem.random.Next(repaintMode),
                                       process.GetY() + repaintMode / 2
                                       - LSystem.random.Next(repaintMode));
                    }
                    break;
                }

                process.Draw();

                process.Drawable(elapsedTime);

                if (isFPS)
                {
                    gl.Reset(false);

                    framecount++;
                    timeSinceLastUpdate += totalSeconds;
                    if (timeSinceLastUpdate > updateInterval)
                    {
                        frameRate            = Convert.ToInt16(framecount / timeSinceLastUpdate);
                        framecount           = 0;
                        timeSinceLastUpdate -= updateInterval;
                    }

                    fps = string.Format(numformat, "FPS:{0}", frameRate);

                    if (gl.UseFont)
                    {
                        gl.DrawString(fps, 5, 5, LColor.white);
                    }
                    else
                    {
                        if (XNAConfig.IsActive() && font == null)
                        {
                            font = XNAConfig.LoadFnt(LSystem.FRAMEWORK_IMG_NAME + "system");
                        }
                        if (font != null)
                        {
                            font.DrawBatchString(5, 5, fps, LColor.white);
                        }
                    }
                }
                process.DrawEmulator();

                gl.RestoreMatrix();
            }
        }
示例#24
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();
                }
            }
        }
示例#25
0
        private void DrawMessage(GLEx gl, LColor old)
        {
            if (!visible)
            {
                return;
            }
            if (strings == null)
            {
                return;
            }
            lock (showMessages)
            {
                this.size     = showMessages.Length;
                this.fontSize = (isEnglish) ? strings.GetSize() / 2 : gl.GetFont()
                                .GetSize();
                this.fontHeight = strings.GetHeight();
                this.tmp_left   = isLeft ? 0 : (width - (fontSize * messageLength))
                                  / 2 - (int)(fontSize * 1.5);
                this.left           = tmp_left;
                this.index          = offset = font = tmp_font = 0;
                this.fontSizeDouble = fontSize * 2;

                int hashCode = 1;
                hashCode = LSystem.Unite(hashCode, size);
                hashCode = LSystem.Unite(hashCode, left);
                hashCode = LSystem.Unite(hashCode, fontSize);
                hashCode = LSystem.Unite(hashCode, fontHeight);

                if (strings == null)
                {
                    return;
                }

                if (hashCode == lazyHashCade)
                {
                    strings.PostCharCache();
                    if (iconX != 0 && iconY != 0)
                    {
                        gl.DrawTexture(creeseIcon, iconX, iconY);
                    }
                    return;
                }

                strings.StartChar();
                fontColor = old;

                for (int i = 0; i < size; i++)
                {
                    text = showMessages[i];
                    if (text == '\0')
                    {
                        continue;
                    }
                    if (interceptCount < interceptMaxString)
                    {
                        interceptCount++;
                        continue;
                    }
                    else
                    {
                        interceptMaxString = 0;
                        interceptCount     = 0;
                    }
                    if (showMessages[i] == 'n' &&
                        showMessages[(i > 0) ? i - 1 : 0] == '\\')
                    {
                        index = 0;
                        left  = tmp_left;
                        offset++;
                        continue;
                    }
                    else if (text == '\n')
                    {
                        index = 0;
                        left  = tmp_left;
                        offset++;
                        continue;
                    }
                    else if (text == '<')
                    {
                        LColor color = GetColor(showMessages[(i < size - 1) ? i + 1
                                : i]);
                        if (color != null)
                        {
                            interceptMaxString = 1;
                            fontColor          = color;
                        }
                        continue;
                    }
                    else if (showMessages[(i > 0) ? i - 1 : i] == '<' &&
                             GetColor(text) != null)
                    {
                        continue;
                    }
                    else if (text == '/')
                    {
                        if (showMessages[(i < size - 1) ? i + 1 : i] == '>')
                        {
                            interceptMaxString = 1;
                            fontColor          = old;
                        }
                        continue;
                    }
                    else if (index > messageLength)
                    {
                        index = 0;
                        left  = tmp_left;
                        offset++;
                        newLine = false;
                    }
                    else if (text == '\\')
                    {
                        continue;
                    }
                    tmp_font = strings.CharWidth(text);
                    if (System.Char.IsLetter(text))
                    {
                        if (tmp_font < fontSize)
                        {
                            font = fontSize;
                        }
                        else
                        {
                            font = tmp_font;
                        }
                    }
                    else
                    {
                        font = fontSize;
                    }
                    left += font;

                    if (i != size - 1)
                    {
                        strings.AddChar(text, vector.x + left + leftOffset,
                                        (offset * fontHeight) + vector.y + fontSizeDouble
                                        + topOffset - font - 2, fontColor);
                    }
                    else if (!newLine && !onComplete)
                    {
                        iconX = vector.x + left + leftOffset + iconWidth;
                        iconY = (offset * fontHeight) + vector.y + fontSize
                                + topOffset + strings.GetAscent();
                        if (iconX != 0 && iconY != 0)
                        {
                            gl.DrawTexture(creeseIcon, iconX, iconY);
                        }
                    }
                    index++;
                }

                strings.StopChar();
                strings.SaveCharCache();

                lazyHashCade = hashCode;

                if (messageCount == next)
                {
                    onComplete = true;
                }
            }
        }
示例#26
0
文件: LSelect.cs 项目: vb0067/LGame
        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();
                }
            }
        }
示例#27
0
        public override void Draw(GL g)
        {
            this.m_onRunning = false;
            this.m_onPause   = false;
            this.m_onDestroy = false;
            this.m_onResume  = false;

            lock (m_sync)
            {
                m_onRunning = LSystem.isRunning;
                m_onPause   = LSystem.isPaused;
                m_onDestroy = LSystem.isDestroy;
                m_onResume  = LSystem.isResume;

                if (LSystem.isResume)
                {
                    LSystem.isResume = false;
                }

                if (LSystem.isPaused)
                {
                    LSystem.isPaused = false;
                    JavaRuntime.NotifyAll(m_sync);
                }

                if (LSystem.isDestroy)
                {
                    LSystem.isDestroy = false;
                    JavaRuntime.NotifyAll(m_sync);
                }

                if (m_onResume)
                {
                    m_log.I("m_onResume");
                    timer           = LSystem.GetSystemTimer();
                    lastTimeMicros  = timer.GetTimeMicros();
                    elapsedTime     = 0;
                    remainderMicros = 0;
                    m_process.OnResume();
                }


                if (m_onRunning)
                {
                    if (LSystem.isLogo)
                    {
                        if (logoFlag == null)
                        {
                            LSystem.isLogo = false;
                            return;
                        }
                        logoFlag.Draw(m_process.gl);
                        if (logoFlag.finish)
                        {
                            m_process.gl.SetAlpha(1.0f);
                            m_process.gl.DrawClear(LColor.black);
                            LSystem.isLogo = false;
                            logoFlag.Dispose();
                            logoFlag = null;
                            return;
                        }
                        return;
                    }

                    if (!m_process.Next())
                    {
                        return;
                    }

                    m_process.Load();

                    m_process.Calls();

                    goalTimeMicros    = lastTimeMicros + 1000000L / maxFrames;
                    currTimeMicros    = timer.SleepTimeMicros(goalTimeMicros);
                    elapsedTimeMicros = currTimeMicros - lastTimeMicros
                                        + remainderMicros;
                    elapsedTime     = MathUtils.Max(0, (elapsedTimeMicros / 1000));
                    remainderMicros = elapsedTimeMicros - elapsedTime * 1000;
                    lastTimeMicros  = currTimeMicros;
                    timerContext.millisSleepTime     = remainderMicros;
                    timerContext.timeSinceLastUpdate = elapsedTime;

                    ActionControl.Update(elapsedTime);

                    m_process.RunTimer(timerContext);

                    if (LSystem.AUTO_REPAINT)
                    {
                        GLEx gl = m_process.gl;

                        if (gl != null)
                        {
                            if (!m_process.Next())
                            {
                                return;
                            }

                            //设定graphics.PreferredBackBufferWidth和graphics.PreferredBackBufferHeight时WP会自动缩放画面,
                            //此处无需再缩放一次。

                            /*if (LSystem.scaleWidth != 1f || LSystem.scaleHeight != 1f)
                             * {
                             *  gl.Scale(LSystem.scaleWidth,
                             *          LSystem.scaleHeight);
                             * }*/

                            int repaintMode = m_process.GetRepaintMode();

                            switch (repaintMode)
                            {
                            case Screen.SCREEN_BITMAP_REPAINT:
                                gl.Reset(true);
                                if (m_process.GetX() == 0 && m_process.GetY() == 0)
                                {
                                    gl.DrawTexture(m_process.GetBackground(), 0, 0);
                                }
                                else
                                {
                                    gl.DrawTexture(m_process.GetBackground(), m_process.GetX(),
                                                   m_process.GetY());
                                }
                                break;

                            case Screen.SCREEN_COLOR_REPAINT:
                                LColor c = m_process.GetColor();
                                if (c != null)
                                {
                                    gl.DrawClear(c);
                                }
                                break;

                            case Screen.SCREEN_CANVAS_REPAINT:
                                gl.Reset(true);
                                break;

                            case Screen.SCREEN_NOT_REPAINT:
                                gl.Reset(true);
                                break;

                            default:
                                gl.Reset(true);
                                if (m_process.GetX() == 0 && m_process.GetY() == 0)
                                {
                                    gl.DrawTexture(
                                        m_process.GetBackground(),
                                        repaintMode / 2
                                        - LSystem.random.Next(repaintMode),
                                        repaintMode / 2
                                        - LSystem.random.Next(repaintMode));
                                }
                                else
                                {
                                    gl.DrawTexture(m_process.GetBackground(),
                                                   m_process.GetX() + repaintMode / 2
                                                   - LSystem.random.Next(repaintMode),
                                                   m_process.GetY() + repaintMode / 2
                                                   - LSystem.random.Next(repaintMode));
                                }
                                break;
                            }

                            m_process.Draw();

                            m_process.Drawable(elapsedTime);

                            if (isFPS)
                            {
                                this.TickFrames();
                                fpsFont.DrawString(string.Format(numformat, "FPS:{0}", frameRate), 5, 5, 0, LColor.white);
                            }

                            m_process.DrawEmulator();

                            m_process.Unload();

                            gl.Restore();
                        }
                    }
                }
            }
        }
示例#28
0
        public void Draw(GLEx g, SpriteBatch batch, float offsetX, float offsetY)
        {
            bool useBatch = (batch != null);

            if (!dirty && lastOffsetX == offsetX && lastOffsetY == offsetY)
            {
                imgPack.GLCache();
                if (playAnimation)
                {
                    int[][] maps = field.GetMap();
                    for (int i = firstTileX; i < lastTileX; i++)
                    {
                        for (int j = firstTileY; j < lastTileY; j++)
                        {
                            if (i > -1 && j > -1 && i < field.width &&
                                j < field.height)
                            {
                                int id = maps[j][i];
                                foreach (Tile tile  in  arrays)
                                {
                                    if (tile.isAnimation && tile.id == id)
                                    {
                                        if (useBatch)
                                        {
                                            batch.Draw(
                                                tile.animation.GetSpriteImage(),
                                                field.TilesToWidthPixels(i)
                                                + offsetX,
                                                field.TilesToHeightPixels(j)
                                                + offsetY,
                                                field.GetTileWidth(),
                                                field.GetTileHeight());
                                        }
                                        else
                                        {
                                            g.DrawTexture(
                                                tile.animation.GetSpriteImage(),
                                                field.TilesToWidthPixels(i)
                                                + offsetX,
                                                field.TilesToHeightPixels(j)
                                                + offsetY,
                                                field.GetTileWidth(),
                                                field.GetTileHeight());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (arrays.Count == 0)
                {
                    throw new Exception("Not to add any tiles !");
                }
                imgPack.GLBegin();
                firstTileX = field.PixelsToTilesWidth(-offsetX);
                firstTileY = field.PixelsToTilesHeight(-offsetY);
                lastTileX  = firstTileX + field.PixelsToTilesWidth(maxWidth) + 1;
                lastTileX  = MathUtils.Min(lastTileX, field.width);
                lastTileY  = firstTileY + field.PixelsToTilesHeight(maxHeight) + 1;
                lastTileY  = MathUtils.Min(lastTileY, field.height);
                int[][] maps = field.GetMap();
                for (int i = firstTileX; i < lastTileX; i++)
                {
                    for (int j = firstTileY; j < lastTileY; j++)
                    {
                        if (i > -1 && j > -1 && i < field.width && j < field.height)
                        {
                            int id = maps[j][i];
                            foreach (Tile tile  in  arrays)
                            {
                                if (playAnimation)
                                {
                                    if (tile.id == id)
                                    {
                                        if (tile.isAnimation)
                                        {
                                            if (useBatch)
                                            {
                                                batch.Draw(
                                                    tile.animation
                                                    .GetSpriteImage(),
                                                    field.TilesToWidthPixels(i)
                                                    + offsetX,
                                                    field.TilesToHeightPixels(j)
                                                    + offsetY, field
                                                    .GetTileWidth(),
                                                    field.GetTileHeight());
                                            }
                                            else
                                            {
                                                g.DrawTexture(
                                                    tile.animation
                                                    .GetSpriteImage(),
                                                    field.TilesToWidthPixels(i)
                                                    + offsetX,
                                                    field.TilesToHeightPixels(j)
                                                    + offsetY, field
                                                    .GetTileWidth(),
                                                    field.GetTileHeight());
                                            }
                                        }
                                        else
                                        {
                                            imgPack.Draw(tile.imgId,
                                                         field.TilesToWidthPixels(i)
                                                         + offsetX,
                                                         field.TilesToHeightPixels(j)
                                                         + offsetY,
                                                         field.GetTileWidth(),
                                                         field.GetTileHeight());
                                        }
                                    }
                                }
                                else if (tile.id == id)
                                {
                                    imgPack.Draw(tile.imgId,
                                                 field.TilesToWidthPixels(i) + offsetX,
                                                 field.TilesToHeightPixels(j) + offsetY,
                                                 field.GetTileWidth(),
                                                 field.GetTileHeight());
                                }
                            }
                        }
                    }
                }
                imgPack.GLEnd();
                lastOffsetX = offsetX;
                lastOffsetY = offsetY;
                dirty       = false;
            }
            if (listener != null)
            {
                listener.Draw(g, offsetX, offsetY);
            }
        }
示例#29
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();
            }
        }
示例#30
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);
                 }
             }
         }
     }
 }