Beispiel #1
0
        public override void OnMain()
        {
            //加载LGame默认资源(不进行此操作,LGame内置的模拟按钮之类功能无法使用)

            XNAFont = new LFont("Content/Fonts", "black", 0, 20);
            LSetting setting = new LSetting();

            setting.fps       = 60;
            setting.width     = 480;
            setting.height    = 320;
            setting.showFPS   = true;
            setting.landscape = true;

            Register(setting, typeof(AVGTitle));

            /*
             *
             * //加载LGame使用的默认字体(不进行此操作,LGame默认的DrawString之类函数无法使用(PS:XNAConfig载入
             * //默认包时,可获得部分英文字体支持))
             * XNAFont = new LFont("Content/Fonts", "black", 0, 20);
             * MaxScreen(480, 320);
             * //设定初始化屏幕为竖屏,自动最大化游戏画面为屏幕大小
             * Initialization(true, LMode.Fill);
             * //帧数60
             * SetFPS(60);
             * //显示帧数
             * SetShowFPS(true);
             * //加载Screen
             * SetScreen(new AVGTitle());
             * //显示Screen
             * ShowScreen();*/
        }
Beispiel #2
0
		public void SetMessage(string context, LFont font, bool isComplete) {
			if (strings != null) {
				strings.Dispose();
			}
			this.strings = new LSTRFont(font, context);
			this.lazyHashCade = 1;
			this.wait = 0;
			this.visible = false;
			this.showMessages = new char[] { '\0' };
			this.interceptMaxString = 0;
			this.next = 0;
			this.messageCount = 0;
			this.interceptCount = 0;
			this.size = 0;
			this.tmp_left = 0;
			this.left = 0;
			this.fontSize = 0;
			this.fontHeight = 0;
			this.messages = context;
			this.next = context.Length;
			this.onComplete = false;
			this.newLine = false;
			this.messageCount = 0;
			this.messageBuffer.Clear();
			if (isComplete) {
				this.Complete();
			}
			this.visible = true;
		}
Beispiel #3
0
 public LSTRFont(LFont font, bool anti, char[] additionalChars)
 {
     if (displays == null)
     {
         displays = new System.Collections.Generic.Dictionary <string, Loon.Core.Graphics.Opengl.LTextureBatch.GLCache>(totalCharSet);
     }
     else
     {
         displays.Clear();
     }
     this.useCache  = true;
     this.font      = font;
     this.fontSize  = font.GetSize();
     this.ascent    = font.GetAscent();
     this.antiAlias = anti;
     if (antiAlias)
     {
         if (trueFont == null)
         {
             trueFont = LFont.GetTrueFont();
         }
         if (additionalChars != null && additionalChars.Length > (textureWidth / trueFont.GetSize()))
         {
             this.textureWidth  *= 2;
             this.textureHeight *= 2;
         }
         this.fontScale = (float)fontSize / (float)trueFont.GetSize();
         this.Make(trueFont, additionalChars);
     }
     else
     {
         this.Make(this.font, additionalChars);
     }
 }
Beispiel #4
0
 public void SetMessage(string context, LFont font, bool isComplete)
 {
     if (strings != null)
     {
         strings.Dispose();
     }
     this.strings            = new LSTRFont(font, context);
     this.lazyHashCade       = 1;
     this.wait               = 0;
     this.visible            = false;
     this.showMessages       = new char[] { '\0' };
     this.interceptMaxString = 0;
     this.next               = 0;
     this.messageCount       = 0;
     this.interceptCount     = 0;
     this.size               = 0;
     this.tmp_left           = 0;
     this.left               = 0;
     this.fontSize           = 0;
     this.fontHeight         = 0;
     this.messages           = context;
     this.next               = context.Length;
     this.onComplete         = false;
     this.newLine            = false;
     this.messageCount       = 0;
     this.messageBuffer.Clear();
     if (isComplete)
     {
         this.Complete();
     }
     this.visible = true;
 }
Beispiel #5
0
 public LSTRFont(LFont font, bool anti, char[] additionalChars)
 {
     if (displays == null)
     {
         displays = new System.Collections.Generic.Dictionary<string, Loon.Core.Graphics.Opengl.LTextureBatch.GLCache>(totalCharSet);
     }
     else
     {
         displays.Clear();
     }
     this.useCache = true;
     this.font = font;
     this.fontSize = font.GetSize();
     this.ascent = font.GetAscent();
     this.antiAlias = anti;
     if (antiAlias)
     {
         if (trueFont == null)
         {
             trueFont = LFont.GetTrueFont();
         }
         if (additionalChars != null && additionalChars.Length > (textureWidth / trueFont.GetSize()))
         {
             this.textureWidth *= 2;
             this.textureHeight *= 2;
         }
         this.fontScale = (float)fontSize / (float)trueFont.GetSize();
         this.Make(trueFont, additionalChars);
     }
     else
     {
         this.Make(this.font, additionalChars);
     }
 }
Beispiel #6
0
 public void SetMessage(string context, LFont f, bool isComplete)
 {
     if (batch == null)
     {
         batch = new SpriteBatch(GLEx.Device);
     }
     this.strings            = f;
     this.wait               = 0;
     this.visible            = false;
     this.showMessages       = new char[] { '\0' };
     this.interceptMaxString = 0;
     this.next               = 0;
     this.messageCount       = 0;
     this.interceptCount     = 0;
     this.size               = 0;
     this.tmp_left           = 0;
     this.left               = 0;
     this.fontSize           = 0;
     this.fontHeight         = 0;
     this.messages           = context;
     this.next               = context.Length;
     this.onComplete         = false;
     this.newLine            = false;
     this.messageCount       = 0;
     this.messageBuffer.Remove(0, messageBuffer.Length - (0));
     if (isComplete)
     {
         this.Complete();
     }
     this.visible = true;
 }
Beispiel #7
0
 public virtual LFont GetFont()
 {
     if (batch != null)
     {
         return(batch.GetFont());
     }
     return(LFont.GetDefaultFont());
 }
Beispiel #8
0
 public void SetShowFPS(bool showFps)
 {
     this.isFPS = showFps;
     if (showFps && fpsFont == null)
     {
         this.fpsFont = new LSTRFont(LFont.GetFont(20), pFontString);
     }
 }
Beispiel #9
0
 public Label(LFont f, string l, int x, int y)
 {
     this.font    = f;
     this.label   = l;
     this.color   = LColor.black;
     this.visible = true;
     this.SetLocation(x, y);
 }
Beispiel #10
0
 public LNLabel(string text, LNLabel.LabelType type, LFont spriteFont)
     : base()
 {
     this._spriteFont = spriteFont;
     this._type       = type;
     SetString(text);
     this.SetNodeSize(_spriteFont.StringWidth(text), _spriteFont.GetHeight());
 }
Beispiel #11
0
            public void Run()
            {
                screen.stage = new Label("Stage - " + screen.stageNo, 140, 25);
                screen.stage.SetColor(LColor.black);
                screen.stage.SetFont(LFont.GetDefaultFont());
                screen.Add(screen.stage);
                screen.time = new Label("time", 270, 25);
                screen.time.SetColor(LColor.black);
                screen.time.SetFont(LFont.GetDefaultFont());
                screen.Add(screen.time);
                message.SetVisible(false);
                screen.role.SetVisible(false);
                message.SetVisible(false);
                screen.init  = true;
                screen.count = 0;

                screen.progress = new StatusBar(screen.progress_number,
                                                screen.progress_number, 325, 5, 150, 25);
                screen.progress.SetDead(true);
                screen.Add(screen.progress);
                if (screen.title == null)
                {
                    screen.title = new LPaper(screen.GetImage(15), 55, 55);
                }
                else
                {
                    screen.title.SetLocation(55, 55);
                }
                screen.CenterOn(screen.title);
                screen.Add(screen.title);
                if (screen.stageNo < 5)
                {
                    if (screen.helpRole == null)
                    {
                        screen.helpRole = new Sprite(screen.GetImage(8));
                        screen.helpRole.SetLocation(screen
                                                    .GetWidth()
                                                    - screen.helpRole.GetWidth() - 10,
                                                    screen.GetHeight()
                                                    - screen.helpRole.GetHeight()
                                                    - 10);
                        screen.Add(screen.helpRole);
                    }
                    else
                    {
                        screen.helpRole.SetVisible(true);
                        screen.Add(screen.helpRole);
                    }
                }
                else
                {
                    if (screen.helpRole != null)
                    {
                        screen.helpRole.SetVisible(false);
                    }
                }
            }
Beispiel #12
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);
        }
Beispiel #13
0
 public static LImage CreateFontImage(LFont font, LColor color, string text)
 {
     LImage image = LImage.CreateImage(font.StringWidth(text), font.GetHeight());
     LGraphics g = image.GetLGraphics();
     g.SetFont(font);
     g.DrawString(text, 0, 0, color);
     g.Dispose();
     return image;
 }
Beispiel #14
0
 public void SetFont(LFont deffont)
 {
     if (deffont == null)
     {
         return;
     }
     this.deffont  = deffont;
     this.fontSize = deffont.GetSize();
 }
Beispiel #15
0
		public Print(string context, LFont font, Vector2f vector, int width,
				int height) {
                    this.messageBuffer = new StringBuilder(messageLength);
			this.SetMessage(context, font);
			this.vector = vector;
			this.width = width;
			this.height = height;
			this.wait = 0;
			this.isWait = false;
		}
Beispiel #16
0
        public static LImage CreateFontImage(LFont font, LColor color, string text)
        {
            LImage    image = LImage.CreateImage(font.StringWidth(text), font.GetHeight());
            LGraphics g     = image.GetLGraphics();

            g.SetFont(font);
            g.DrawString(text, 0, 0, color);
            g.Dispose();
            return(image);
        }
Beispiel #17
0
 public Print(string context, LFont f, Vector2f v, int w,
         int h)
 {
     this.SetMessage(context, f);
     this.vector = v;
     this.width = w;
     this.height = h;
     this.wait = 0;
     this.isWait = false;
 }
Beispiel #18
0
 public Print(string context, LFont f, Vector2f v, int w,
              int h)
 {
     this.SetMessage(context, f);
     this.vector = v;
     this.width  = w;
     this.height = h;
     this.wait   = 0;
     this.isWait = false;
 }
Beispiel #19
0
 public Print(string context, LFont font, Vector2f vector, int width,
              int height)
 {
     this.messageBuffer = new StringBuilder(messageLength);
     this.SetMessage(context, font);
     this.vector = vector;
     this.width  = width;
     this.height = height;
     this.wait   = 0;
     this.isWait = false;
 }
Beispiel #20
0
 public virtual void Dispose()
 {
     if (strings != null)
     {
         strings = null;
     }
     if (batch != null)
     {
         batch.Dispose();
         batch = null;
     }
 }
Beispiel #21
0
 public virtual void Dispose()
 {
     if (strings != null)
     {
         strings = null;
     }
     if (batch != null)
     {
         batch.Dispose();
         batch = null;
     }
 }
Beispiel #22
0
        public static Dict Bind(LFont font, string mes)
        {
            string message = mes + added;

            if (cacheList.Count > size)
            {
                ClearStringLazy();
            }
            lock (fontList)
            {
                LFont cFont = (LFont)CollectionUtils.Get(cacheList, message);
                Dict  pDict = (Dict)CollectionUtils.Get(fontList, font);
                if (cFont == null || pDict == null)
                {
                    if (pDict == null)
                    {
                        pDict = Dict.NewDict();
                        CollectionUtils.Put(fontList, font, pDict);
                    }
                    lock (pDict)
                    {
                        CollectionUtils.Put(cacheList, message, font);
                        List <char> charas  = pDict.dicts;
                        int         oldSize = charas.Count;
                        char[]      chars   = message.ToCharArray();
                        for (int i = 0; i < chars.Length; i++)
                        {
                            if (!charas.Contains(chars[i]))
                            {
                                charas.Add(chars[i]);
                            }
                        }
                        int newSize = charas.Count;
                        if (oldSize != newSize)
                        {
                            if (pDict.font != null)
                            {
                                pDict.font.Dispose();
                                pDict.font = null;
                            }
                            StringBuilder sbr = new StringBuilder(newSize);
                            for (int i = 0; i < newSize; i++)
                            {
                                sbr.Append(charas[i]);
                            }
                            pDict.font = new LSTRFont(font, sbr.ToString());
                        }
                    }
                }
                return(pDict);
            }
        }
Beispiel #23
0
        public static void DrawString(LFont font, string message, float x,
                                      float y, float angle, LColor c)
        {
            Dict pDict = Bind(font, message);

            if (pDict.font != null)
            {
                lock (pDict.font)
                {
                    pDict.font.DrawString(message, x, y, angle, c);
                }
            }
        }
Beispiel #24
0
 public static Dict Bind(LFont font, string mes)
 {
     string message = mes + added;
     if (cacheList.Count > size)
     {
         ClearStringLazy();
     }
     lock (fontList)
     {
         LFont cFont = (LFont)CollectionUtils.Get(cacheList,message);
         Dict pDict = (Dict)CollectionUtils.Get(fontList,font);
         if (cFont == null || pDict == null)
         {
             if (pDict == null)
             {
                 pDict = Dict.NewDict();
                CollectionUtils.Put(fontList,font, pDict);
             }
             lock (pDict)
             {
                 CollectionUtils.Put(cacheList,message, font);
                 List<char> charas = pDict.dicts;
                 int oldSize = charas.Count;
                 char[] chars = message.ToCharArray();
                 for (int i = 0; i < chars.Length; i++)
                 {
                     if (!charas.Contains(chars[i]))
                     {
                         charas.Add(chars[i]);
                     }
                 }
                 int newSize = charas.Count;
                 if (oldSize != newSize)
                 {
                     if (pDict.font != null)
                     {
                         pDict.font.Dispose();
                         pDict.font = null;
                     }
                     StringBuilder sbr = new StringBuilder(newSize);
                     for (int i = 0; i < newSize; i++)
                     {
                         sbr.Append(charas[i]);
                     }
                     pDict.font = new LSTRFont(font, sbr.ToString());
                 }
             }
         }
         return pDict;
     }
 }
Beispiel #25
0
        public static LSTRFont GetGLFont(LFont f)
        {
            if (lazyEnglish.Count > LSystem.DEFAULT_MAX_CACHE_SIZE)
            {
                ClearEnglishLazy();
            }
            string   key  = MakeLazyWestKey(f);
            LSTRFont font = (LSTRFont)CollectionUtils.Get(lazyEnglish, key);

            if (font == null)
            {
                font = new LSTRFont(f, true);
                CollectionUtils.Put(lazyEnglish, key, font);
            }
            return(font);
        }
Beispiel #26
0
        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();
            }
        }
Beispiel #27
0
 public override void OnMain()
 {
     //加载LGame使用的默认字体(不进行此操作,LGame默认的DrawString之类函数无法使用(PS:XNAConfig载入
     //默认包时,可获得部分英文字体支持))
     XNAFont = new LFont("Content/Fonts", "black", 0, 20);
     MaxScreen(480, 320);
     //设定初始化屏幕为竖屏,自动最大化游戏画面为屏幕大小
     Initialization(true, LMode.Fill);
     //帧数60
     SetFPS(60);
     //显示帧数
     SetShowFPS(true);
     //加载Screen
     SetScreen(new LLKScreen());
     //显示Screen
     ShowScreen();
 }
Beispiel #28
0
 private static string MakeLazyWestKey(LFont font)
 {
     if (lazyKey == null)
     {
         lazyKey = new StringBuilder();
         lazyKey.Append(font.GetFontName().ToLower());
         lazyKey.Append(font.GetStyle());
         lazyKey.Append(font.GetSize());
     }
     else
     {
         lazyKey.Clear();
         lazyKey.Append(font.GetFontName().ToLower());
         lazyKey.Append(font.GetStyle());
         lazyKey.Append(font.GetSize());
     }
     return(lazyKey.ToString());
 }
Beispiel #29
0
 public override void Draw(SpriteBatch batch)
 {
     if (base._visible)
     {
         pos      = base.ConvertToWorldPos();
         scale    = base.ConvertToWorldScale();
         rotation = base.ConvertToWorldRot();
         batch.SetColor(base._color.r, base._color.g, base._color.b,
                        base._alpha);
         LFont font = batch.GetFont();
         batch.SetFont(_spriteFont);
         batch.DrawString(this._text, pos[0], pos[1], scale[0], scale[1],
                          _anchor.x, _anchor.y, MathUtils.ToDegrees(rotation),
                          batch.GetColor());
         batch.SetFont(font);
         batch.ResetColor();
     }
 }
Beispiel #30
0
        public override void OnMain()
        {
            //加载LGame默认资源(不进行此操作,LGame内置的模拟按钮之类功能无法使用)
            XNAConfig.Load("assets/loon.def");
            //加载字体文件(此处是预编译好的xnb文件,也可以加载Content下的)
            XNAFont = new LFont("assets", "black", 0, 20);

            //注册AD监听(标准XNA事件监听)
            SetXNAListener(new ADListener());

            //设定启动参数
            LSetting setting = new LSetting();

            setting.fps       = 60;
            setting.width     = 480;
            setting.height    = 320;
            setting.showFPS   = true;
            setting.landscape = true;
            //注册初始Screen
            Register(setting, typeof(ScreenTest));
        }
Beispiel #31
0
        public override void OnMain()
        {
            //加载LGame默认资源(不进行此操作,LGame内置的模拟按钮之类功能无法使用)
            XNAConfig.Load("content/loon.def");
            //加载字体文件(此处是预编译好的xnb文件 PS:当自定义资源文件夹命名为Content时,
            //打包后会自动和标准的Content文件夹合并,这里做个演示。另,Windows系统不区分文件
            //名大小写)
            XNAFont = new LFont("content", "black", 0, 20);

            //注册AD监听(标准XNA事件监听)
            SetXNAListener(new ADListener());

            //设定启动参数
            LSetting setting = new LSetting();

            setting.fps       = 60;
            setting.width     = 480;
            setting.height    = 320;
            setting.showFPS   = true;
            setting.landscape = false;
            //注册初始Screen
            Register(setting, typeof(ScreenTest));
        }
Beispiel #32
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();
        }
Beispiel #33
0
        public static string MakeStringLazyKey(LFont font, string text)
        {
            int hashCode = 0;

            hashCode = LSystem.Unite(hashCode, font.GetSize());
            hashCode = LSystem.Unite(hashCode, font.GetStyle());
            if (lazyKey == null)
            {
                lazyKey = new StringBuilder();
                lazyKey.Append(font.GetFontName().ToLower());
                lazyKey.Append(hashCode);
                lazyKey.Append(split);
                lazyKey.Append(text);
            }
            else
            {
                lazyKey.Clear();
                lazyKey.Append(font.GetFontName().ToLower());
                lazyKey.Append(hashCode);
                lazyKey.Append(split);
                lazyKey.Append(text);
            }
            return(lazyKey.ToString());
        }
Beispiel #34
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);
     }
 }
Beispiel #35
0
 public void SetFont(LFont deffont)
 {
     if (deffont == null)
     {
         return;
     }
     this.deffont = deffont;
     this.fontSize = deffont.GetSize();
 }
Beispiel #36
0
 public void SetMessage(string context, LFont f, bool isComplete)
 {
     if (batch == null)
     {
         batch = new SpriteBatch(GLEx.Device);
     }
     this.strings = f;
     this.wait = 0;
     this.visible = false;
     this.showMessages = new char[] { '\0' };
     this.interceptMaxString = 0;
     this.next = 0;
     this.messageCount = 0;
     this.interceptCount = 0;
     this.size = 0;
     this.tmp_left = 0;
     this.left = 0;
     this.fontSize = 0;
     this.fontHeight = 0;
     this.messages = context;
     this.next = context.Length;
     this.onComplete = false;
     this.newLine = false;
     this.messageCount = 0;
     this.messageBuffer.Remove(0, messageBuffer.Length - (0));
     if (isComplete)
     {
         this.Complete();
     }
     this.visible = true;
 }
Beispiel #37
0
 public LSTRFont(LFont font, string strings)
     : this(font, true, strings.ToCharArray())
 {
 }
Beispiel #38
0
 public void SetFont(LFont f)
 {
     this.font = f;
 }
Beispiel #39
0
 public virtual void SetFont(LFont font)
 {
     this.font = font;
 }
Beispiel #40
0
 public void SetMessage(string context, LFont f)
 {
     SetMessage(context, f, false);
 }
Beispiel #41
0
 public LSTRFont(LFont font, bool antiAlias)
     : this(font, antiAlias, (char[])null)
 {
 }
Beispiel #42
0
 public static string MakeStringLazyKey(LFont font, string text)
 {
     int hashCode = 0;
     hashCode = LSystem.Unite(hashCode, font.GetSize());
     hashCode = LSystem.Unite(hashCode, font.GetStyle());
     if (lazyKey == null)
     {
         lazyKey = new StringBuilder();
         lazyKey.Append(font.GetFontName().ToLower());
         lazyKey.Append(hashCode);
         lazyKey.Append(split);
         lazyKey.Append(text);
     }
     else
     {
         lazyKey.Clear();
         lazyKey.Append(font.GetFontName().ToLower());
         lazyKey.Append(hashCode);
         lazyKey.Append(split);
         lazyKey.Append(text);
     }
     return lazyKey.ToString();
 }
Beispiel #43
0
 private static string MakeLazyWestKey(LFont font)
 {
     if (lazyKey == null)
     {
         lazyKey = new StringBuilder();
         lazyKey.Append(font.GetFontName().ToLower());
         lazyKey.Append(font.GetStyle());
         lazyKey.Append(font.GetSize());
     }
     else
     {
         lazyKey.Clear();
         lazyKey.Append(font.GetFontName().ToLower());
         lazyKey.Append(font.GetStyle());
         lazyKey.Append(font.GetSize());
     }
     return lazyKey.ToString();
 }
Beispiel #44
0
 public static LSTRFont GetGLFont(LFont f)
 {
     if (lazyEnglish.Count > LSystem.DEFAULT_MAX_CACHE_SIZE)
     {
         ClearEnglishLazy();
     }
     string key = MakeLazyWestKey(f);
     LSTRFont font = (LSTRFont)CollectionUtils.Get(lazyEnglish, key);
     if (font == null)
     {
         font = new LSTRFont(f, true);
         CollectionUtils.Put(lazyEnglish, key, font);
     }
     return font;
 }
Beispiel #45
0
        private void Make(LFont font, char[] customCharsArray)
        {
            if (charArray == null)
            {
                charArray = new IntObject[totalCharSet];
            }
            if (customCharsArray != null && customCharsArray.Length > totalCharSet)
            {
                textureWidth *= 2;
            }
            try
            {
                LImage imgTemp = LImage.CreateImage(textureWidth, textureHeight, true);
                LGraphics g = imgTemp.GetLGraphics();
                g.SetFont(font);
                int rowHeight = 0;
                int positionX = 0;
                int positionY = 0;
                int customCharsLength = (customCharsArray != null) ? customCharsArray.Length
                        : 0;
                this.totalCharSet = customCharsLength == 0 ? totalCharSet : 0;
                StringBuilder sbr = new StringBuilder(totalCharSet);
                for (int i = 0; i < totalCharSet + customCharsLength; i++)
                {
                    char ch = (i < totalCharSet) ? (char)i : customCharsArray[i
                            - totalCharSet];

                    int charwidth = font.CharWidth(ch);
                    if (charwidth <= 0)
                    {
                        charwidth = 1;
                    }
                    int charheight = font.GetHeight();
                    if (charheight <= 0)
                    {
                        charheight = font.GetSize();
                    }

                    IntObject newIntObject = new IntObject();

                    newIntObject.width = charwidth;
                    newIntObject.height = charheight;

                    if (positionX + newIntObject.width >= textureWidth)
                    {
                        g.DrawString(sbr.ToString(), 0, positionY);
                        sbr.Clear();
                        positionX = 0;
                        positionY += rowHeight;
                        rowHeight = 0;
                    }

                    newIntObject.storedX = positionX;
                    newIntObject.storedY = positionY;

                    if (newIntObject.height > fontHeight)
                    {
                        fontHeight = newIntObject.height;

                    }

                    if (newIntObject.height > rowHeight)
                    {
                        rowHeight = newIntObject.height;
                    }

                    sbr.Append(ch);

                    positionX += newIntObject.width;

                    if (i < totalCharSet)
                    {
                        charArray[i] = newIntObject;

                    }
                    else
                    {

                        CollectionUtils.Put(customChars, ch, newIntObject);
                    }

                }
                if (sbr.Length > 0)
                {
                    g.DrawString(sbr.ToString(), 0, positionY);
                    sbr = null;
                }
                g.Dispose();
                g = null;

                fontBatch = new LTextureBatch(imgTemp.GetTexture());

            }
            catch (Exception ex)
            {
                Loon.Utils.Debug.Log.Exception(ex);
            }
        }
Beispiel #46
0
 public void SetMessageFont(LFont f)
 {
     this.messageFont = f;
 }
Beispiel #47
0
        public virtual void SetFont(LFont font)
        {
			this.font = font;
		}
Beispiel #48
0
 public void SetFont(LFont font)
 {
     this.m_fontsize = font.GetSize();
 }
Beispiel #49
0
		public Print(Vector2f vector, LFont font, int width, int height):this("", font, vector, width, height) {
			
		}
Beispiel #50
0
 public void SetFont(LFont font)
 {
     this.font = font;
 }
Beispiel #51
0
 public Print(Vector2f v, LFont f, int w, int h)
     : this("", f, v, w, h)
 {
 }
Beispiel #52
0
 public static void DrawString(LFont font, string message, float x,
         float y, float sx, float sy, float ax, float ay, float angle,
         LColor c)
 {
     Dict pDict = Bind(font, message);
     if (pDict.font != null)
     {
         lock (pDict.font)
         {
             pDict.font.DrawString(message, x, y, sx, sy, ax, ay, angle, c);
         }
     }
 }
Beispiel #53
0
 public LSTRFont(LFont font, bool antiAlias, string strings)
     : this(font, antiAlias, strings.ToCharArray())
 {
 }
Beispiel #54
0
		public void SetMessageFont(LFont messageFont) {
			this.messageFont = messageFont;
		}
Beispiel #55
0
 public void SetFont(LFont f)
 {
     this.font = f;
 }