コード例 #1
0
ファイル: SkinManager.cs プロジェクト: mateuscezar/netgore
        /// <summary>
        /// Creates a new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>. This method should
        /// always return a new <see cref="ControlBorder"/> and not use any sort of caching.
        /// </summary>
        /// <param name="controlName">The name of the <see cref="Control"/>.</param>
        /// <param name="subCategory">The optional sub-category. Can be null.</param>
        /// <returns>A new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>.</returns>
        protected virtual ControlBorder CreateBorder(string controlName, SpriteCategory subCategory)
        {
            // Get the full sub-category
            var fullSubCategory = GetControlSpriteSubCategory(controlName);
            if (subCategory != null && subCategory.ToString().Length > 0)
                fullSubCategory += SpriteCategorization.Delimiter + subCategory;

            // Load all the sides
            var bg = GetSprite(fullSubCategory, "Background");
            var l = GetSprite(fullSubCategory, "Left");
            var r = GetSprite(fullSubCategory, "Right");
            var b = GetSprite(fullSubCategory, "Bottom");
            var bl = GetSprite(fullSubCategory, "BottomLeft");
            var br = GetSprite(fullSubCategory, "BottomRight");
            var tl = GetSprite(fullSubCategory, "TopLeft");
            var t = GetSprite(fullSubCategory, "Top");
            var tr = GetSprite(fullSubCategory, "TopRight");

            // Create the control
            var ret = new ControlBorder(tl, t, tr, r, br, b, bl, l, bg);

            // Try to load the user-defined border drawing styles
            var borderDrawStylesFile = GetBorderDrawStylesFilePath(fullSubCategory);
            if (!string.IsNullOrEmpty(borderDrawStylesFile))
                ret.TrySetDrawStyles(borderDrawStylesFile);

            return ret;
        }
コード例 #2
0
ファイル: SkinManager.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Creates a new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>. This method should
        /// always return a new <see cref="ControlBorder"/> and not use any sort of caching.
        /// </summary>
        /// <param name="controlName">The name of the <see cref="Control"/>.</param>
        /// <param name="subCategory">The optional sub-category. Can be null.</param>
        /// <returns>A new <see cref="ControlBorder"/> for the given skin and <see cref="Control"/>.</returns>
        protected virtual ControlBorder CreateBorder(string controlName, SpriteCategory subCategory)
        {
            // Get the full sub-category
            var fullSubCategory = GetControlSpriteSubCategory(controlName);

            if (subCategory != null && subCategory.ToString().Length > 0)
            {
                fullSubCategory += SpriteCategorization.Delimiter + subCategory;
            }

            // Load all the sides
            var bg = GetSprite(fullSubCategory, "Background");
            var l  = GetSprite(fullSubCategory, "Left");
            var r  = GetSprite(fullSubCategory, "Right");
            var b  = GetSprite(fullSubCategory, "Bottom");
            var bl = GetSprite(fullSubCategory, "BottomLeft");
            var br = GetSprite(fullSubCategory, "BottomRight");
            var tl = GetSprite(fullSubCategory, "TopLeft");
            var t  = GetSprite(fullSubCategory, "Top");
            var tr = GetSprite(fullSubCategory, "TopRight");

            // Create the control
            var ret = new ControlBorder(tl, t, tr, r, br, b, bl, l, bg);

            // Try to load the user-defined border drawing styles
            var borderDrawStylesFile = GetBorderDrawStylesFilePath(fullSubCategory);

            if (!string.IsNullOrEmpty(borderDrawStylesFile))
            {
                ret.TrySetDrawStyles(borderDrawStylesFile);
            }

            return(ret);
        }
コード例 #3
0
ファイル: Button.cs プロジェクト: Furt/netgore
        /// <summary>
        /// When overridden in the derived class, loads the skinning information for the <see cref="Control"/>
        /// from the given <paramref name="skinManager"/>.
        /// </summary>
        /// <param name="skinManager">The <see cref="ISkinManager"/> to load the skinning information from.</param>
        public override void LoadSkin(ISkinManager skinManager)
        {
            BorderNormal = skinManager.GetBorder(_controlSkinName);
            BorderOver = skinManager.GetBorder(_controlSkinName, "MouseOver");
            BorderPressed = skinManager.GetBorder(_controlSkinName, "Pressed");

            Border = BorderNormal;
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlBorder"/> class.
        /// </summary>
        /// <param name="source">ControlBorder to copy from</param>
        public ControlBorder(ControlBorder source)
        {
            _sprites    = new ISprite[_numSprites];
            _drawStyles = new ControlBorderDrawStyle[_numSprites];

            Array.Copy(source._sprites, 0, _sprites, 0, _sprites.Length);
            Array.Copy(source._drawStyles, 0, _drawStyles, 0, _drawStyles.Length);
        }
コード例 #5
0
ファイル: Button.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// When overridden in the derived class, loads the skinning information for the <see cref="Control"/>
        /// from the given <paramref name="skinManager"/>.
        /// </summary>
        /// <param name="skinManager">The <see cref="ISkinManager"/> to load the skinning information from.</param>
        public override void LoadSkin(ISkinManager skinManager)
        {
            BorderNormal  = skinManager.GetBorder(_controlSkinName);
            BorderOver    = skinManager.GetBorder(_controlSkinName, "MouseOver");
            BorderPressed = skinManager.GetBorder(_controlSkinName, "Pressed");

            Border = BorderNormal;
        }
コード例 #6
0
ファイル: ControlBorder.cs プロジェクト: Vizzini/netgore
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlBorder"/> class.
        /// </summary>
        /// <param name="source">ControlBorder to copy from</param>
        public ControlBorder(ControlBorder source)
        {
            _sprites = new ISprite[_numSprites];
            _drawStyles = new ControlBorderDrawStyle[_numSprites];

            Array.Copy(source._sprites, 0, _sprites, 0, _sprites.Length);
            Array.Copy(source._drawStyles, 0, _drawStyles, 0, _drawStyles.Length);
        }
コード例 #7
0
        /// <summary>
        /// Draws the <see cref="ITooltip"/>.
        /// </summary>
        /// <param name="sb">The <see cref="ISpriteBatch"/> to draw the <see cref="ITooltip"/> with.</param>
        /// <exception cref="ArgumentNullException"><paramref name="sb" /> is <c>null</c>.</exception>
        public virtual void Draw(ISpriteBatch sb)
        {
            if (sb == null)
            {
                throw new ArgumentNullException("sb");
            }

            // Do nothing if not being displayed
            if (!IsDisplayed)
            {
                return;
            }

            Vector2 pos  = GUIManager.CursorPosition + DrawOffset + BorderPadding;
            Vector2 size = _borderSize + (BorderPadding * 2);
            Vector2 ss   = GUIManager.ScreenSize;

            // Ensure the tooltip is in the screen
            if (pos.X < 0)
            {
                pos.X = 0;
            }
            else if (pos.X + size.X > ss.X)
            {
                pos.X = ss.X - size.X;
            }

            if (pos.Y < 0)
            {
                pos.Y = 0;
            }
            else if (pos.Y + size.Y > ss.Y)
            {
                pos.Y = ss.Y - size.Y;
            }

            // Draw the border
            Rectangle borderRect = new Rectangle(pos.X, pos.Y, _borderSize.X, _borderSize.Y).Inflate(BorderPadding.X, BorderPadding.Y);

            ControlBorder b = _args.Border;

            if (b != null)
            {
                b.Draw(sb, borderRect);
            }
            else
            {
                RenderRectangle.Draw(sb, borderRect, _args.BackgroundColor);
            }

            // Draw the text
            _drawer.Draw(sb, _args.FontColor, pos);
        }
コード例 #8
0
            /// <summary>
            /// When overridden in the derived class, loads the skinning information for the <see cref="Control"/>
            /// from the given <paramref name="skinManager"/>.
            /// </summary>
            /// <param name="skinManager">The <see cref="ISkinManager"/> to load the skinning information from.</param>
            public override void LoadSkin(ISkinManager skinManager)
            {
                _defaultBorder = skinManager.GetBorder(_controlSkinName);
                _mouseOverBorder = skinManager.GetBorder(_controlSkinName, "MouseOver");

                if (IsMouseEntered)
                    Border = _mouseOverBorder;
                else
                    Border = _defaultBorder;
            }
コード例 #9
0
ファイル: Control.cs プロジェクト: mateuscezar/netgore
        /// <summary>
        /// Initializes a new instance of the <see cref="Control"/> class.
        /// </summary>
        /// <param name="parent">Parent <see cref="Control"/> of this <see cref="Control"/>.</param>
        /// <param name="guiManager">The GUI manager this <see cref="Control"/> will be managed by.</param>
        /// <param name="position">Position of the Control reletive to its parent.</param>
        /// <param name="clientSize">The size of the <see cref="Control"/>'s client area.</param>
        /// <exception cref="ArgumentNullException"><paramref name="guiManager"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="parent"/> control is disposed.</exception>
        Control(Control parent, IGUIManager guiManager, Vector2 position, Vector2 clientSize)
        {
            if (guiManager == null)
                throw new ArgumentNullException("guiManager", "GUIManager cannot be null.");

            _gui = guiManager;
            _parent = parent;

            _border = ControlBorder.Empty;
            _position = position;
            _size = clientSize;

            // Get the root
            if (Parent == null)
                _root = this;
            else
                _root = Parent.Root;

            if (Parent != null)
            {
                // Check that the parent isn't disposed
                if (Parent.IsDisposed)
                    throw new ArgumentException("Parent control is disposed and cannot be used.", "parent");

                // Add the Control to the parent
                Parent._controls.Add(this);
                KeepInParent();

                if (Parent.ResizeToChildren)
                    Parent.UpdateResizeToChildren();
            }
            else
            {
                _alwaysOnTop = GetIsAlwaysOnTop();

                // This control is the root, so add it directly to the GUI manager
                GUIManager.Add(this);
            }

            SetDefaultValues();
        }
コード例 #10
0
 /// <summary>
 /// Initializes the <see cref="ControlBorder"/> class.
 /// </summary>
 static ControlBorder()
 {
     _numSprites = EnumHelper <ControlBorderSpriteType> .MaxValue + 1;
     _empty      = new ControlBorder(null, null, null, null, null, null, null, null, null);
 }
コード例 #11
0
ファイル: ControlBorder.cs プロジェクト: Vizzini/netgore
 /// <summary>
 /// Initializes the <see cref="ControlBorder"/> class.
 /// </summary>
 static ControlBorder()
 {
     _numSprites = EnumHelper<ControlBorderSpriteType>.MaxValue + 1;
     _empty = new ControlBorder(null, null, null, null, null, null, null, null, null);
 }