Пример #1
1
        /// <summary>
        /// Generates a Windows 8 like skin based on a start color.
        /// </summary>
        /// <param name="baseColor">The base color</param>
        /// <param name="fontName">Font name</param>
        /// <param name="animated">set to true to generate "Hover" and "Clicked" skins</param>
        /// <returns>The skin</returns>
        public static YnSkin Generate(Color baseColor, string fontName, bool animated)
        {
            Color tempColor;
            YnSkin skin = new YnSkin();

            // Default state
            skin.FontNameDefault = fontName;
            skin.FontDefault = YnG.Game.Content.Load<SpriteFont>(fontName);
            skin.TextColorDefault = Color.White;
            skin.BackgroundDefault = YnGraphics.CreateTexture(baseColor, 1, 1);
            skin.BorderDefault = null; // Borders are left blank

            // If the skin is "animated", generate data for "Hover" and "Clicked" states
            if (animated)
            {
                // Hover state : change only background color
                tempColor = Add(baseColor, 50, 50, 50);
                skin.BackgroundHover = YnGraphics.CreateTexture(tempColor, 1, 1);

                // Clicked state : invert background & text color
                skin.TextColorClicked = baseColor;
                skin.BackgroundClicked = YnGraphics.CreateTexture(Color.White, 1, 1);
            }

            return skin;
        }
Пример #2
0
        /// <summary>
        /// Generates a Windows 8 like skin based on a start color.
        /// </summary>
        /// <param name="baseColor">The base color</param>
        /// <param name="fontName">Font name</param>
        /// <param name="animated">set to true to generate "Hover" and "Clicked" skins</param>
        /// <returns>The skin</returns>
        public static YnSkin Generate(Color baseColor, string fontName, bool animated)
        {
            Color  tempColor;
            YnSkin skin = new YnSkin();

            // Default state
            skin.FontNameDefault   = fontName;
            skin.FontDefault       = YnG.Game.Content.Load <SpriteFont>(fontName);
            skin.TextColorDefault  = Color.White;
            skin.BackgroundDefault = YnGraphics.CreateTexture(baseColor, 1, 1);
            skin.BorderDefault     = null; // Borders are left blank

            // If the skin is "animated", generate data for "Hover" and "Clicked" states
            if (animated)
            {
                // Hover state : change only background color
                tempColor            = Add(baseColor, 50, 50, 50);
                skin.BackgroundHover = YnGraphics.CreateTexture(tempColor, 1, 1);

                // Clicked state : invert background & text color
                skin.TextColorClicked  = baseColor;
                skin.BackgroundClicked = YnGraphics.CreateTexture(Color.White, 1, 1);
            }

            return(skin);
        }
Пример #3
0
 /// <summary>
 /// Register a new skin in the cache. Be carefull when registering a new skin : names must
 /// be unique.
 /// </summary>
 /// <param name="name">The skin name</param>
 /// <param name="skin">The skin definition</param>
 public static void RegisterSkin(string name, YnSkin skin)
 {
     if (__skinCache.ContainsKey(name))
     {
         // Skin overwriting
         // TODO Add warning log
     }
     __skinCache[name] = skin;
 }
Пример #4
0
 	/// <summary>
 	/// Register a new skin in the cache. Be carefull when registering a new skin : names must
 	/// be unique. 
 	/// </summary>
 	/// <param name="name">The skin name</param>
 	/// <param name="skin">The skin definition</param>
 	public static void RegisterSkin(string name, YnSkin skin)
 	{
 		if(__skinCache.ContainsKey(name))
 		{
 			// Skin overwriting
 			// TODO Add warning log
 		}
 		__skinCache[name] = skin;
 	}