示例#1
0
 /// <summary>
 /// Copies a skin so you can make a new custom skin from an already defined one
 /// </summary>
 /// <param name="SkinID">The string ID of the custom skin</param>
 /// <returns>The new copy of the skin</returns>
 internal static GUISkin CopySkin(String SkinID)
 {
     if (List.ContainsKey(SkinID))
     {
         return((GUISkin)CC_MBE.Instantiate(List[SkinID]));
     }
     else
     {
         CC_MBE.LogFormatted("Unable to copy GUISkin to {0}, GUISkin not found", SkinID);
         throw new SystemException(String.Format("Unable to copy GUISkin to {0}, GUISkin not found", SkinID));
     }
 }
示例#2
0
        /// <summary>
        /// Copies a skin so you can make a new custom skin from an already defined one
        /// </summary>
        /// <param name="DefaultSkin">Which predefined skin to use</param>
        /// <returns>The new copy of the skin</returns>
        internal static GUISkin CopySkin(DefSkinType DefaultSkin)
        {
            switch (DefaultSkin)
            {
            case DefSkinType.Unity: return((GUISkin)CC_MBE.Instantiate(DefUnitySkin));

            case DefSkinType.KSP: return((GUISkin)CC_MBE.Instantiate(DefKSPSkin));

            //case DefSkinType.None: return new GUISkin();
            default: return((GUISkin)CC_MBE.Instantiate(DefKSPSkin));
            }
        }
示例#3
0
        /// <summary>
        /// Sets the current Skin to one of the Pre-Defined types
        /// </summary>
        /// <param name="DefaultSkin">Which predefined skin to use</param>
        internal static void SetCurrent(DefSkinType DefaultSkin)
        {
            CC_MBE.LogFormatted_DebugOnly("Setting GUISkin to {0}", DefaultSkin);
            GUISkin OldSkin = _CurrentSkin;

            switch (DefaultSkin)
            {
            case DefSkinType.Unity: _CurrentSkin = DefUnitySkin; break;

            case DefSkinType.KSP: _CurrentSkin = DefKSPSkin; break;

            //case DefSkinType.None: _CurrentSkin = new GUISkin(); break;
            default: _CurrentSkin = DefKSPSkin; break;
            }
            //Now set the tooltip style as well
            SetCurrentTooltip();

            if (OldSkin != CurrentSkin && OnSkinChanged != null)
            {
                OnSkinChanged();
            }
        }
示例#4
0
        /// <summary>
        /// Sets the current skin to one of the custom skins
        /// </summary>
        /// <param name="SkinID">The string ID of the custom skin</param>
        internal static void SetCurrent(String SkinID)
        {
            CC_MBE.LogFormatted_DebugOnly("Setting GUISkin to {0}", SkinID);
            GUISkin OldSkin = _CurrentSkin;

            //check the skin exists, and throw a log line if it doesnt
            if (List.ContainsKey(SkinID))
            {
                _CurrentSkin = List[SkinID];
            }
            else
            {
                CC_MBE.LogFormatted("Unable to change GUISkin to {0}, GUISkin not found", SkinID);
            }

            //Now set the tooltip style as well
            SetCurrentTooltip();

            if (OldSkin != CurrentSkin && OnSkinChanged != null)
            {
                OnSkinChanged();
            }
        }
示例#5
0
        /// <summary>
        /// Add a style to a skin, if the styleID already exists it will update the style
        /// </summary>
        /// <param name="SkinToAction">The GUISkin we are going to adjust. The name of the Style is its ID</param>
        /// <param name="NewStyle">The GUIStyle to add or update</param>
        internal static void AddStyle(ref GUISkin SkinToAction, GUIStyle NewStyle)
        {
            if (NewStyle.name == null || NewStyle.name == "")
            {
                CC_MBE.LogFormatted("No Name Provided in the Style to add to {0}. Cannot add this.", SkinToAction.name);
                return;
            }

            //Convert to a list
            List <GUIStyle> lstTemp = SkinToAction.customStyles.ToList <GUIStyle>();

            //Add or edit the customstyle
            if (lstTemp.Any(x => x.name == NewStyle.name))
            {
                //if itexists then remove it first
                GUIStyle styleTemp = lstTemp.First(x => x.name == NewStyle.name);
                lstTemp.Remove(styleTemp);
            }
            //add the new style
            lstTemp.Add(NewStyle);

            //Write the list back to the array
            SkinToAction.customStyles = lstTemp.ToArray <GUIStyle>();
        }