/// <summary>
 /// Draw method.
 /// </summary>
 /// <param name="rect">Where to draw</param>
 /// <param name="color">Text color</param>
 /// <param name="text">Text</param>
 public override void Draw(HtRect rect, HtColor color, string text)
 {
     // just common implementation using GUIStyle
     content.text = text;
     style.normal.textColor = new Color32(color.R, color.G, color.B, color.A);
     style.Draw(new Rect(rect.X, rect.Y, rect.Width, rect.Height), content, false, false, false, false);
 }
Exemple #2
0
        /// <summary>
        /// FillRect implementation
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="color"></param>
        /// <param name="userData"></param>
        public override void FillRect(HtRect rect, HtColor color, object userData)
        {
            var root = userData as Transform;

            if (root != null)
            {
                var go = new GameObject("fill", typeof(UISprite));
                go.layer                   = root.gameObject.layer;
                go.transform.parent        = root;
                go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, 0f);
                go.transform.localScale    = Vector3.one;
                var spr = go.GetComponent <UISprite>();
                spr.pivot      = UIWidget.Pivot.Center;
                spr.atlas      = Resources.Load("atlases/white", typeof(UIAtlas)) as UIAtlas;
                spr.spriteName = "white";
                spr.color      = new Color32(color.R, color.G, color.B, color.A);
                spr.type       = UISprite.Type.Sliced;
                spr.width      = rect.Width != 0 ? rect.Width : 1;
                spr.height     = rect.Height != 0 ? rect.Height : 1;
                spr.depth      = NGUIHTML.currentDepth;
                spr.MakePixelPerfect();
            }
            else
            {
                HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
            }
        }
Exemple #3
0
        public override void FillRect(HtRect rect, HtColor color)
        {
            Debug.Assert(Context != null);
            var c = Color.FromArgb(color.A, color.R, color.G, color.B);

            Context.FillRectangle(new SolidBrush(c), rect.X, rect.Y, rect.Width, rect.Height);
        }
Exemple #4
0
 /// <summary>
 /// Draw method
 /// </summary>
 /// <param name="rect">Where to draw</param>
 /// <param name="color">Color to use (ignored for now)</param>
 /// <param name="linkText">Link text</param>
 /// <param name="userData">User data</param>
 public override void Draw(string id, HtRect rect, HtColor color, string linkText, object userData)
 {
     if (isTime)
     {
         var now = DateTime.Now;
         timeStyle.Draw(new Rect(rect.X, rect.Y, rect.Width, rect.Height),
                        string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", now.Hour, now.Minute, now.Second, now.Millisecond),
                        false, false, false, false);
     }
     else if (this.Texture != null)
     {
         // store current gui color
         var oldColor = GUI.color;
         // set control id.
         if (!string.IsNullOrEmpty(id))
         {
             GUI.SetNextControlName(id);
         }
         // fill rect with given color
         GUI.color = new Color32(color.R, color.G, color.B, color.A);
         GUI.DrawTexture(new Rect(rect.X, rect.Y, rect.Width, rect.Height), this.Texture);
         // restore gui color
         GUI.color = oldColor;
     }
 }
Exemple #5
0
        public override void Draw(HtRect rect, HtColor color, string text)
        {
            Debug.Assert(HtmlDevice.Context != null);
            var c = Color.FromArgb(color.A, color.R, color.G, color.B);

            HtmlDevice.Context.DrawString(text, this.font, new SolidBrush(c), rect.X, rect.Y, StringFormat.GenericTypographic);
        }
Exemple #6
0
        /// <summary>
        /// FillRect implementation
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="color"></param>
        /// <param name="userData"></param>
        public override void FillRect(HtRect rect, HtColor color, object userData)
        {
            var root = userData as Transform;

            if (root != null)
            {
                var go = new GameObject("fill", typeof(UISprite));
                go.layer                   = root.gameObject.layer;
                go.transform.parent        = root;
                go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2 - 2, -1f);
                go.transform.localScale    = new Vector3(rect.Width, rect.Height, 1f);
                var spr = go.GetComponent <UISprite>();
                spr.pivot = UIWidget.Pivot.Center;
                spr.atlas = Fillatlas;
                //PacketManage.Single.GetPacket("rom_upd").Load("html_engine") as UIAtlas;
                //Resources.Load("atlases/white", typeof(UIAtlas)) as UIAtlas;
                spr.spriteName = "white";
                spr.color      = new Color32(color.R, color.G, color.B, color.A);
                spr.MakePixelPerfect();
                if (go.transform.localScale.y == 0f)
                {
                    go.transform.localScale = new Vector3(go.transform.localScale.x, 1f, 1f);
                }
            }
            else
            {
                HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
            }
        }
Exemple #7
0
 /// <summary>
 /// Draw method.
 /// </summary>
 /// <param name="rect">Where to draw</param>
 /// <param name="color">Text color</param>
 /// <param name="text">Text</param>
 public override void Draw(HtRect rect, HtColor color, string text)
 {
     // just common implementation using GUIStyle
     content.text           = text;
     style.normal.textColor = new Color32(color.R, color.G, color.B, color.A);
     style.Draw(new Rect(rect.X, rect.Y, rect.Width, rect.Height), content, false, false, false, false);
 }
 public override void Draw(HtRect rect, HtColor color, string text)
 {
     if (this.font != null)
     {
         HtmlDevice.Context.DrawString(this.font, text, new Vector2(rect.X, rect.Y),
                                       new Color(color.R, color.G, color.B, color.A));
     }
 }
 public override void Draw(HtRect rect, HtColor color)
 {
     Debug.Assert(HtmlDevice.Context != null);
     if (this.texture != null)
     {
         HtmlDevice.Context.Draw(this.texture, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height),
                                 Color.White);
     }
 }
 public override void Draw(HtRect rect, HtColor color)
 {
     Debug.Assert(HtmlDevice.Context != null);
     if (this.texture != null)
     {
         HtmlDevice.Context.Draw(this.texture, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height),
                                 Color.White);
     }
 }
 /// <summary>
 /// Draw method.
 /// </summary>
 /// <param name="rect">Where to draw</param>
 /// <param name="color">Text color</param>
 /// <param name="text">Text</param>
 /// <param name="isEffect">Is effect</param>
 /// <param name="effect">Effect</param>
 /// <param name="effectColor">Effect color</param>
 /// <param name="effectAmount">Effect amount</param>
 /// <param name="linkText">Link text</param>
 /// <param name="userData">User data</param>
 public override void Draw(string id, HtRect rect, HtColor color, string text, bool isEffect, Core.DrawTextEffect effect, HtColor effectColor, int effectAmount, string linkText, object userData)
 {
     // just common implementation using GUIStyle
     if (string.IsNullOrEmpty(id))
     {
         GUI.SetNextControlName(id);
     }
     content.text           = text;
     style.normal.textColor = new Color32(color.R, color.G, color.B, color.A);
     style.Draw(new Rect(rect.X, rect.Y, rect.Width, rect.Height), content, false, false, false, false);
 }
 public override void FillRect(HtRect rect, HtColor color)
 {
     Debug.Assert(Context != null);
     if (WhiteTexture == null)
     {
         WhiteTexture = new Texture2D(Context.GraphicsDevice, 1, 1);
         WhiteTexture.SetData(new[] {Color.White});
     }
     Context.Draw(WhiteTexture,
                  new Rectangle(rect.X, rect.Y, rect.Width, rect.Height),
                  new Color(color.R, color.G, color.B, color.A));
 }
 public override void FillRect(HtRect rect, HtColor color)
 {
     Debug.Assert(Context != null);
     if (WhiteTexture == null)
     {
         WhiteTexture = new Texture2D(Context.GraphicsDevice, 1, 1);
         WhiteTexture.SetData(new[] { Color.White });
     }
     Context.Draw(WhiteTexture,
                  new Rectangle(rect.X, rect.Y, rect.Width, rect.Height),
                  new Color(color.R, color.G, color.B, color.A));
 }
 /// <summary>
 /// Draw method
 /// </summary>
 /// <param name="rect">Where to draw</param>
 /// <param name="color">Color to use (ignored for now)</param>
 public override void Draw(HtRect rect, HtColor color)
 {
     if (isTime)
     {
         var now = DateTime.Now;
         timeStyle.Draw(new Rect(rect.X, rect.Y, rect.Width, rect.Height),
                        string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", now.Hour, now.Minute, now.Second, now.Millisecond),
                        false, false, false, false);
     }
     else if (this.Texture != null)
     {
         GUI.DrawTexture(new Rect(rect.X, rect.Y, rect.Width, rect.Height), this.Texture);
     }
 }
 /// <summary>
 /// Draw method
 /// </summary>
 /// <param name="rect">Where to draw</param>
 /// <param name="color">Color to use (ignored for now)</param>
 public override void Draw(HtRect rect, HtColor color)
 {
     if (isTime)
     {
         var now = DateTime.Now;
         timeStyle.Draw(new Rect(rect.X, rect.Y, rect.Width, rect.Height), 
         string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}",now.Hour,now.Minute,now.Second,now.Millisecond),
                        false, false, false, false);
     }
     else if (this.Texture != null)
     {
         GUI.DrawTexture(new Rect(rect.X, rect.Y, rect.Width, rect.Height), this.Texture);
     }
 }
 /// <summary>
 /// FillRect implementation
 /// </summary>
 /// <param name="rect"></param>
 /// <param name="color"></param>
 public override void FillRect(HtRect rect, HtColor color)
 {
     // create white texture if need
     if (whiteTex==null)
     {
         whiteTex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
         whiteTex.SetPixel(0, 0, Color.white);
         whiteTex.Apply(false, true);
     }
     // store current gui color
     var oldColor = GUI.color;
     // fill rect with given color
     GUI.color = new Color32(color.R,color.G,color.B,color.A);
     GUI.DrawTexture(new Rect(rect.X, rect.Y, rect.Width, rect.Height), whiteTex);
     // restore gui color
     GUI.color = oldColor;
 }
        /// <summary>
        /// FillRect implementation
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="color"></param>
        public override void FillRect(HtRect rect, HtColor color)
        {
            // create white texture if need
            if (whiteTex == null)
            {
                whiteTex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                whiteTex.SetPixel(0, 0, Color.white);
                whiteTex.Apply(false, true);
            }
            // store current gui color
            var oldColor = GUI.color;

            // fill rect with given color
            GUI.color = new Color32(color.R, color.G, color.B, color.A);
            GUI.DrawTexture(new Rect(rect.X, rect.Y, rect.Width, rect.Height), whiteTex);
            // restore gui color
            GUI.color = oldColor;
        }
Exemple #18
0
 /// <summary>
 /// FillRect implementation
 /// </summary>
 /// <param name="rect"></param>
 /// <param name="color"></param>
 /// <param name="userData"></param>
 public override void FillRect(HtRect rect, HtColor color, object userData) {
   var root = userData as Transform;
   if (root != null) {
     var go = new GameObject("fill", typeof(UISprite));
     go.layer = root.gameObject.layer;
     go.transform.parent = root;
     go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, 0f);
     go.transform.localScale = new Vector3(1f, 0.5f, 1f);//Vector3.one;
     var spr = go.GetComponent<UISprite>();
     spr.pivot = UIWidget.Pivot.Center;
     spr.atlas = Resources.Load("HTMLEngine/white", typeof(UIAtlas)) as UIAtlas;
     spr.spriteName = "white";
     spr.color = new Color32(color.R, color.G, color.B, color.A);
     spr.type = UISprite.Type.Sliced;
     spr.width = rect.Width != 0 ? rect.Width : 1;
     spr.height = rect.Height != 0 ? rect.Height : 1;
     spr.depth = NGUIHTML.currentDepth;
     //spr.MakePixelPerfect();
   } else {
     HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
  }
 }
Exemple #19
0
 public abstract void Draw(HtRect rect, HtColor color, string text);
Exemple #20
0
		public abstract void Draw(string id, HtRect rect, object userData);
Exemple #21
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="rect">Where to draw</param>
        /// <param name="color">Color to use (ignored for now)</param>
        /// <param name="linkText">Link text</param>
        /// <param name="userData">User data</param>
        public override void Draw(string id, HtRect rect, HtColor color, string linkText, object userData)
        {
            if (isTime)
            {
                var now = DateTime.Now;
                timeFont.Draw(
                    "time",
                    rect,
                    color,
                    string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", now.Hour, now.Minute, now.Second, now.Millisecond),
                    false,
                    Core.DrawTextEffect.None,
                    HtColor.white,
                    0,
                    linkText,
                    userData);
            }
            else if (uiAtlas != null)
            {
                var root = userData as Transform;
                if (root != null)
                {
                    var go = new GameObject(string.IsNullOrEmpty(id) ? "image" : id, typeof(UISprite));
                    go.layer                   = root.gameObject.layer;
                    go.transform.parent        = root;
                    go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, -1f);
                    go.transform.localScale    = Vector3.one;
                    var spr = go.GetComponent <UISprite>();
                    spr.pivot  = UIWidget.Pivot.Center;
                    spr.atlas  = uiAtlas;
                    spr.color  = new Color32(color.R, color.G, color.B, color.A);
                    spr.type   = UISprite.Type.Simple;
                    spr.width  = rect.Width != 0 ? rect.Width : 1;
                    spr.height = rect.Height != 0 ? rect.Height : 1;
                    spr.depth  = NGUIHTML.currentDepth;

                    if (isAnim)
                    {
                        var sprAnim = go.AddComponent <UISpriteAnimation>();
                        sprAnim.framesPerSecond = FPS;
                        sprAnim.namePrefix      = spriteName;
                        sprAnim.loop            = true;
                        sprAnim.Reset();
                    }
                    else
                    {
                        spr.spriteName = spriteName;
                        spr.MakePixelPerfect();
                    }

                    if (!string.IsNullOrEmpty(linkText))
                    {
                        var collider = go.AddComponent <BoxCollider>();
                        collider.isTrigger = true;
                        collider.center    = new Vector3(0f, 0f, -0.25f);
                        collider.size      = new Vector3(1f, 1f, 1f);

                        var nguiLinkText = go.AddComponent <NGUILinkText>();
                        nguiLinkText.linkText = linkText;

                        var uiButtonColor = go.AddComponent <UIButtonColor>();
                        uiButtonColor.tweenTarget = go;
                        uiButtonColor.hover       = new Color32(
                            HtEngine.LinkHoverColor.R,
                            HtEngine.LinkHoverColor.G,
                            HtEngine.LinkHoverColor.B,
                            HtEngine.LinkHoverColor.A);
                        uiButtonColor.pressed = new Color(
                            spr.color.r * HtEngine.LinkPressedFactor,
                            spr.color.g * HtEngine.LinkPressedFactor,
                            spr.color.b * HtEngine.LinkPressedFactor, spr.color.a);
                        uiButtonColor.duration = 0f;

                        var uiButtonMessage = go.AddComponent <UIButtonMessage>();
                        uiButtonMessage.target       = root.gameObject;
                        uiButtonMessage.functionName = HtEngine.LinkFunctionName;
                    }
                }
                else
                {
                    HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
                }
            }
        }
Exemple #22
0
        /// <summary>
        /// Draw method.
        /// </summary>
        /// <param name="rect">Where to draw</param>
        /// <param name="color">Text color</param>
        /// <param name="text">Text</param>
        /// <param name="isEffect">Is effect</param>
        /// <param name="effect">Effect</param>
        /// <param name="effectColor">Effect color</param>
        /// <param name="effectAmount">Effect amount</param>
        /// <param name="linkText">Link text</param>
        /// <param name="userData">User data</param>
        public override void Draw(string id, HtRect rect, HtColor color, string text, bool isEffect, Core.DrawTextEffect effect, HtColor effectColor, int effectAmount, string linkText, object userData)
        {
            if (isEffect)
            {
                return;
            }

            var root = userData as Transform;

            if (root != null)
            {
                var go = new GameObject(string.IsNullOrEmpty(id) ? "label" : id, typeof(UILabel));
                go.layer                   = root.gameObject.layer;
                go.transform.parent        = root;
                go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, 0f);
                go.transform.localScale    = Vector3.one;//Vector3.zero; //new Vector3(this.style.font.fontSize, this.style.font.fontSize, 1f);
                var lab = go.GetComponent <UILabel>();
                lab.pivot           = UIWidget.Pivot.Center;
                lab.supportEncoding = false;

                lab.bitmapFont = m_font;
                lab.fontSize   = this.Size;
                lab.text       = text;
                lab.color      = new Color32(color.R, color.G, color.B, color.A);
                switch (effect)
                {
                case Core.DrawTextEffect.Outline:
                    lab.effectStyle = UILabel.Effect.Outline;
                    break;

                case Core.DrawTextEffect.Shadow:
                    lab.effectStyle = UILabel.Effect.Shadow;
                    break;
                }

                if (this.Bold && this.Italic)
                {
                    lab.fontStyle = FontStyle.BoldAndItalic;
                }
                else if (this.Bold)
                {
                    lab.fontStyle = FontStyle.Bold;
                }
                else if (this.Italic)
                {
                    lab.fontStyle = FontStyle.Italic;
                }


                lab.effectColor    = new Color32(effectColor.R, effectColor.G, effectColor.B, effectColor.A);
                lab.effectDistance = new Vector2(effectAmount, effectAmount);
                lab.MakePixelPerfect();

                lab.width  = rect.Width + 1;
                lab.height = rect.Height + 1;
                // build link.
                if (!string.IsNullOrEmpty(linkText))
                {
                    var collider = go.AddComponent <BoxCollider>();
                    collider.isTrigger = true;

                    lab.autoResizeBoxCollider = true;
                    lab.ResizeCollider();

                    var nguiLinkText = go.AddComponent <NGUILinkText>();
                    nguiLinkText.linkText = linkText;

                    var uiButtonColor = go.AddComponent <UIButtonColor>();
                    uiButtonColor.tweenTarget = go;
                    uiButtonColor.hover       = new Color32(
                        HtEngine.LinkHoverColor.R,
                        HtEngine.LinkHoverColor.G,
                        HtEngine.LinkHoverColor.B,
                        HtEngine.LinkHoverColor.A);
                    uiButtonColor.pressed = new Color(
                        lab.color.r * HtEngine.LinkPressedFactor,
                        lab.color.g * HtEngine.LinkPressedFactor,
                        lab.color.b * HtEngine.LinkPressedFactor, lab.color.a);
                    uiButtonColor.duration = 0f;

                    var uiButtonMessage = go.AddComponent <UIButtonMessage>();
                    uiButtonMessage.target       = root.gameObject;
                    uiButtonMessage.functionName = HtEngine.LinkFunctionName;
                }
            }
            else
            {
                HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
            }
        }
Exemple #23
0
 public abstract void Draw(HtRect rect, HtColor color);
Exemple #24
0
 public abstract void FillRect(HtRect rect, HtColor color, object userData);
 public override void FillRect(HtRect rect, HtColor color)
 {
     Debug.Assert(Context != null);
     var c = Color.FromArgb(color.A, color.R, color.G, color.B);
     Context.FillRectangle(new SolidBrush(c), rect.X, rect.Y, rect.Width, rect.Height);
 }
Exemple #26
0
		/// <summary>
		/// Draw method
		/// </summary>
		/// <param name="rect">Where to draw</param>
		/// <param name="userData">User data</param>
		public override void Draw(string id, HtRect rect, object userData)
		{
			var root = userData as Transform;
			if (root != null)
			{
				NGUIHTML html = root.gameObject.GetComponent<NGUIHTML>();
				GameObject go = null;
				bool newgo = false;
				if (html != null)
				{
					GameObject tmp;
					if (html.gameobjs.TryGetValue(id, out tmp))
					{
						go = tmp;
						html.gameobjinuse[id] = go;
					}
				}
				if (go == null)
				{
					go = new GameObject(id);
					if (html != null)
					{
						html.gameobjs[id] = go;
						html.gameobjinuse[id] = go;
					}
					newgo = true;
				}
				go.layer = root.gameObject.layer;
				go.transform.parent = root;
				go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, -1f);
				go.transform.localScale = new Vector3(rect.Width, rect.Height, 1f);

				if (newgo)
				{
					if (_hasboxcollider)
					{
						var collider = go.AddComponent<BoxCollider>();
						if (collider != null)
						{
							collider.isTrigger = true;
							collider.center = new Vector3(0f, 0f, -0.25f);
							collider.size = new Vector3(1f, 1f, 1f);
						}


						var uiButtonMessage = go.AddComponent<UIButtonMessage>();
						if (_command != null)
						{
							uiButtonMessage.target = go;
							uiButtonMessage.functionName = _command;
						}
						else
						{
							uiButtonMessage.target = root.gameObject;
							uiButtonMessage.functionName = HtEngine.LinkFunctionName;
						}
					}

					if (_componentname != null)
					{
						var componet = go.AddComponent(_componentname) as NGUIHtmlComponent;
						if (componet != null)
						{
							componet.param = _param;
						}
					}
				}

			}
		}
 public override void Draw(HtRect rect, HtColor color)
 {
     Debug.Assert(HtmlDevice.Context != null);
     HtmlDevice.Context.DrawImage(this.image, rect.X, rect.Y, rect.Width, rect.Height);
 }
 public override void Draw(HtRect rect, HtColor color, string text)
 {
     Debug.Assert(HtmlDevice.Context != null);
     var c = Color.FromArgb(color.A, color.R, color.G, color.B);
     HtmlDevice.Context.DrawString(text, this.font, new SolidBrush(c), rect.X, rect.Y,StringFormat.GenericTypographic);
 }
Exemple #29
0
 public abstract void Draw(string id, HtRect rect, HtColor color, string linkText, object userData);
 public override void Draw(HtRect rect, HtColor color, string text)
 {
     if (this.font != null)
         HtmlDevice.Context.DrawString(this.font, text, new Vector2(rect.X, rect.Y),
                                       new Color(color.R, color.G, color.B, color.A));
 }
Exemple #31
0
    /// <summary>
    /// Draw method
    /// </summary>
    /// <param name="rect">Where to draw</param>
    /// <param name="color">Color to use (ignored for now)</param>
		/// <param name="linkText">Link text</param>
    /// <param name="userData">User data</param>
    public override void Draw(string id, HtRect rect, HtColor color, Core.HtmlLink link, object userData) {
      if (isTime) {
        var now = DateTime.Now;
        timeFont.Draw(
			null,	//no span info
			"time",
			rect,
			color,
			string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", now.Hour, now.Minute, now.Second, now.Millisecond),
					false,
					Core.DrawTextEffect.None,
					HtColor.white,
					0,
					link,
			userData);
      } else if (uiAtlas != null) {
        var root = userData as Transform;
        if (root != null) {
          var go = new GameObject(string.IsNullOrEmpty(id) ? "image" : id, typeof(UISprite));
          go.layer = root.gameObject.layer;
          go.transform.parent = root;
          go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, -1f);
          go.transform.localScale = Vector3.one;
          var spr = go.GetComponent<UISprite>();
          spr.pivot = UIWidget.Pivot.Center;
          spr.atlas = uiAtlas;
          spr.color = new Color32(color.R, color.G, color.B, color.A);
          spr.type = UISprite.Type.Simple;
          spr.width = rect.Width != 0 ? rect.Width : 1;
          spr.height = rect.Height != 0 ? rect.Height : 1;
          spr.depth = NGUIHTML.currentDepth;
          
          if (isAnim) {
            var sprAnim = go.AddComponent<UISpriteAnimation>();
            sprAnim.framesPerSecond = FPS;
            sprAnim.namePrefix = spriteName;
            sprAnim.pixelSnap = PixelSnap;
            sprAnim.loop = true;
            sprAnim.Reset();
          } else {
            spr.spriteName = spriteName;
            spr.MakePixelPerfect();
          }

          if (link != null && !string.IsNullOrEmpty(link.linkText)) 
		  {
			  var collider = go.AddComponent<BoxCollider>();
			  collider.isTrigger = true;
			  collider.center = new Vector3(0f, 0f, -0.25f);
			  collider.size = new Vector3(1f, 1f, 1f);
              spr.autoResizeBoxCollider = true;
              spr.ResizeCollider();
			  var nguiLinkText = go.AddComponent<NGUILinkText>();
			  string[] split = link.linkText.Split('#');
			  if (split.Length >= 1)
			  {
				  nguiLinkText.linkText = split[0];

				  if (split.Length >= 2)
				  {
					  var componet = go.AddComponent(split[1]);
				  }
				  
				  if (split.Length >= 3)
				  {
					  var componet = go.GetComponent<NGUIHtmlComponent>();
					  if (componet != null)
					  {
						  componet.param = split[2];
					  }
				  }
			  }

			  
			  
			  var uiButtonColor = go.AddComponent<UIButtonColor>();
			  uiButtonColor.tweenTarget = go;
			  uiButtonColor.hover = new Color32(
					HtEngine.LinkHoverColor.R,
					HtEngine.LinkHoverColor.G,
					HtEngine.LinkHoverColor.B,
					HtEngine.LinkHoverColor.A);
			  uiButtonColor.pressed = new Color(
					spr.color.r * HtEngine.LinkPressedFactor,
					spr.color.g * HtEngine.LinkPressedFactor,
					spr.color.b * HtEngine.LinkPressedFactor, spr.color.a);
			  uiButtonColor.duration = 0f;
			  var uiButtonMessage = go.AddComponent<UIButtonMessage>();
			  uiButtonMessage.target = root.gameObject;
			  uiButtonMessage.functionName = HtEngine.LinkFunctionName;
		  }
        } else {
          HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
        }
      }
    }
Exemple #32
0
 public override void Draw(HtRect rect, HtColor color)
 {
     Debug.Assert(HtmlDevice.Context != null);
     HtmlDevice.Context.DrawImage(this.image, rect.X, rect.Y, rect.Width, rect.Height);
 }
Exemple #33
0
 public abstract void Draw(string id, HtRect rect, HtColor color, string text, bool isEffect, Core.DrawTextEffect effect, HtColor effectColor, int effectAmount, string linkText, object userData);
Exemple #34
0
 public abstract void Draw(HtRect rect, HtColor color, string text);
 public abstract void FillRect(HtRect rect, HtColor color);
Exemple #36
0
 public abstract void FillRect(HtRect rect, HtColor color);
Exemple #37
0
 public abstract void Draw(HtSpan span, string id, HtRect rect, HtColor color, string text, bool isEffect, Core.DrawTextEffect effect, HtColor effectColor, int effectAmount, Core.HtmlLink link, object userData);
Exemple #38
0
		/// <summary>
		/// Draw method.
		/// </summary>
		/// <param name="rect">Where to draw</param>
		/// <param name="color">Text color</param>
		/// <param name="text">Text</param>
		/// <param name="isEffect">Is effect</param>
		/// <param name="effect">Effect</param>
		/// <param name="effectColor">Effect color</param>
		/// <param name="effectAmount">Effect amount</param>
		/// <param name="linkText">Link text</param>
		/// <param name="userData">User data</param>
		public override void Draw(HtSpan span, string id, HtRect rect, HtColor color, string text, bool isEffect, Core.DrawTextEffect effect, HtColor effectColor, int effectAmount, Core.HtmlLink link, object userData)
		{
			// NGUI do not need to draw effect.
			if (isEffect) return;

			var root = userData as Transform;
			if (root != null)
			{
				var go = new GameObject(string.IsNullOrEmpty(id) ? "label" : id, typeof(UILabel));
				go.layer = root.gameObject.layer;
				go.transform.parent = root;
				go.transform.localPosition = new Vector3(rect.X + rect.Width / 2, -rect.Y - rect.Height / 2, 0f);
				go.transform.localScale = Vector3.one;
				var lab = go.GetComponent<UILabel>();
				lab.enabled = false;
				lab.pivot = UIWidget.Pivot.Center;
                //lab.supportEncoding = false; //L.DF
				lab.fontSize = style.fontSize;
				lab.fontStyle = style.fontStyle;
				lab.color = new Color32(color.R, color.G, color.B, color.A);
				lab.spacingX = SpacingX;
				lab.spacingY = SpacingY;
				switch (effect)
				{
					case Core.DrawTextEffect.Outline:
						lab.effectStyle = UILabel.Effect.Outline;
						break;
					case Core.DrawTextEffect.Shadow:
						lab.effectStyle = UILabel.Effect.Shadow;
						break;
				}
				lab.effectColor = new Color32(effectColor.R, effectColor.G, effectColor.B, effectColor.A);
				lab.effectDistance = new Vector2(effectAmount, effectAmount);
				if (NGUIHTML.currentLabelOverflow == UILabel.Overflow.ShrinkContent && NGUIHTML.currentLabelCrispness != UILabel.Crispness.Never)
				{
					lab.width = rect.Width + Mathf.Max(1, (int)(rect.Width * 0.05f));
					lab.height = rect.Height + Mathf.Max(1, (int)(rect.Height * 0.05f));
				}
				else
				{
					lab.width = 0;//rect.Width;
					lab.height = 0;//rect.Height;
				}
				lab.depth = NGUIHTML.currentDepth;
				lab.overflowMethod = NGUIHTML.currentLabelOverflow;
				lab.keepCrispWhenShrunk = NGUIHTML.currentLabelCrispness;
				lab.trueTypeFont = style.font;
				lab.enabled = true;
                if (lab.supportEncoding)
                    lab.text = text.Replace("\\", "\\\\");
                else
                    lab.text = text;
				lab.MakePixelPerfect();

				// build link.
				if (link != null && !string.IsNullOrEmpty(link.linkText))
				{
					var collider = go.AddComponent<BoxCollider>();
					collider.isTrigger = true;
					collider.center = new Vector3(0f, 0f, -0.25f);
					collider.size = new Vector3(lab.width, lab.height, 1f);

					//           var nguiLinkText = go.AddComponent<NGUILinkText>();
					//           nguiLinkText.linkText = linkText;

					var nguiLinkText = go.AddComponent<NGUILinkText>();
					nguiLinkText.span = span;
					string[] split = link.linkText.Split('#');
					if (split.Length >= 1)
					{
						nguiLinkText.linkText = split[0];

						if (split.Length >= 2)
						{
							var componet = go.AddComponent(split[1]);
						}

						if (split.Length >= 3)
						{
							var componet = go.GetComponent<NGUIHtmlComponent>();
							if (componet != null)
							{
								componet.param = split[2];
							}
						}
					}

                    var uiButtonColor = lab.gameObject.GetComponent<UIButtonColorExt>();
                    if (uiButtonColor == null)
                    {
                        uiButtonColor = lab.gameObject.AddComponent<UIButtonColorExt>();
                    }
                    link.labelList.Add(lab.gameObject);

                    uiButtonColor.tweenTargets = link.labelList;

                    uiButtonColor.hover = new Color32(
                      HtEngine.LinkHoverColor.R,
                      HtEngine.LinkHoverColor.G,
                      HtEngine.LinkHoverColor.B,
                      HtEngine.LinkHoverColor.A);
                    uiButtonColor.pressed = new Color(
                      lab.color.r * HtEngine.LinkPressedFactor,
                      lab.color.g * HtEngine.LinkPressedFactor,
                      lab.color.b * HtEngine.LinkPressedFactor, lab.color.a);
                    uiButtonColor.duration = 0f;

					var uiButtonMessage = go.AddComponent<UIButtonMessage>();
					uiButtonMessage.target = root.gameObject;
					uiButtonMessage.functionName = HtEngine.LinkFunctionName;
				}
			}
			else
			{
				HtEngine.Log(HtLogLevel.Error, "Can't draw without root.");
			}
		}
Exemple #39
0
 public abstract void FillRect(HtRect rect, HtColor color, object userData);
 public abstract void Draw(HtRect rect, HtColor color);
Exemple #41
0
 public abstract void Draw(string id, HtRect rect, HtColor color, Core.HtmlLink link, object userData);