コード例 #1
0
ファイル: MSButton.cs プロジェクト: verngutz/MoodSwing
 /// <summary>
 /// Constructs an MSButton.
 /// </summary>
 /// <param name="label">Add text to this MSButton with an MSLabel. Use null if you don't need to add text. Make sure to position the MSLabel relative to the upper-left corner of this MSButton.</param>
 /// <param name="action">will be executed when this MSButton is clicked</param>
 /// <param name="boundingRectangle">the bounding Rectangle of thisMSButton</param>
 /// <param name="unhovered">will be drawn when this MSButton is unhovered</param>
 /// <param name="clicked">will be drawn when this MSButton is pressed and hovered</param>
 /// <param name="hovered">will be drawn when this MSButton is released and hovered</param>
 /// <param name="spriteBatch">the SpriteBatch that will draw this MSButton</param>
 /// <param name="highlight">the Color to overlay this MSButton with</param>
 /// <param name="shape">the Shape of this MSButton<seealso cref="MoodSwingCoreComponents.Shape"/></param>
 /// <param name="game">the Game where this MSButton will be used</param>
 public MSButton(MSLabel label, MSAction action, Rectangle boundingRectangle, Texture2D unhovered, Texture2D clicked, Texture2D hovered, Color highlight, MSToolTip toolTip, Shape shape, SpriteBatch spriteBatch, Game game)
     : base(boundingRectangle, toolTip, shape, spriteBatch, game)
 {
     unhoveredTexture = unhovered;
     clickedTexture = clicked;
     hoveredTexture = hovered;
     this.highlight = highlight;
     collisionTexture = unhovered;
     if (label != null)
     {
         this.label = label;
         this.label.Position += Position;
     }
     this.action = action;
     this.shape = shape;
     UnHover();
 }
コード例 #2
0
ファイル: MSTextField.cs プロジェクト: verngutz/MoodSwing
        /// <summary>
        /// Constructs and MSTextField from the given parameters
        /// </summary>
        /// <param name="text">the initial text this MSTextField contains</param>
        /// <param name="boundingRectangle">the bounding Rectangle of this MSTextField</param>
        /// <param name="onEnter">the MSAction to perform when this MSTextField is focused and the Enter key has been pressed</param>
        /// <param name="onTab">the MSGUITypable that will be given the keyboard focus when this MSTextField is focused and the Tab key has been pressed</param>
        /// <param name="maxTextLength">the maximum length of the text that this MSTextField can contain</param>
        /// <param name="spriteFont">the SpriteFont that will be used to draw the text on this MSTextField</param>
        /// <param name="color">the text color of this MSTextField</param>
        /// <param name="spriteBatch">the SpriteBatch that will draw this MSTextField</param>
        /// <param name="game">the Game where this MSTextField will be used</param>
        public MSTextField(String text, Rectangle boundingRectangle, MSAction onEnter, MSGUITypable onTab, int maxTextLength, SpriteFont spriteFont, Color color, SpriteBatch spriteBatch, Game game)
            : base(boundingRectangle, null, Shape.RECTANGULAR, spriteBatch, game)
        {
            this.spriteFont = spriteFont;
            fontScale = boundingRectangle.Height / spriteFont.MeasureString(CURSOR).Y;
            cursorIndex = 0;
            cursorBlinkCounter = 0;
            cursorPosition = new Vector2(boundingRectangle.X - spriteFont.MeasureString(CURSOR).X * 5 * fontScale / 12, boundingRectangle.Y);
            Editable = false;
            text = "";
            this.maxTextLength = maxTextLength;
            Text = text;
            this.color = color;

            this.onEnter = onEnter;
            this.onTab = onTab;
            TabIsFired = false;
        }
コード例 #3
0
 /// <summary>
 /// Constructs an MSButton.
 /// </summary>
 /// <param name="label">Add text to this MSButton with an MSLabel. Use null if you don't need to add text. Make sure to position the MSLabel relative to the upper-left corner of this MSButton.</param>
 /// <param name="action">will be executed when this MSButton is clicked</param>
 /// <param name="boundingRectangle">the bounding Rectangle of thisMSButton</param>
 /// <param name="unhovered">will be drawn when this MSButton is unhovered</param>
 /// <param name="clicked">will be drawn when this MSButton is pressed and hovered</param>
 /// <param name="hovered">will be drawn when this MSButton is released and hovered</param>
 /// <param name="spriteBatch">the SpriteBatch that will draw this MSButton</param>
 /// <param name="highlight">the Color to overlay this MSButton with</param>
 /// <param name="shape">the Shape of this MSButton<seealso cref="MoodSwingCoreComponents.Shape"/></param>
 /// <param name="game">the Game where this MSButton will be used</param>
 public MSAnimatingButton(MSLabel label, MSAction action, Rectangle boundingRectangle, Texture2D unhovered, Texture2D clicked, Texture2D hovered, Color highlight, MSToolTip toolTip, Shape shape, SpriteBatch spriteBatch, Game game)
     : base(label, action, boundingRectangle, unhovered, clicked, hovered, highlight, toolTip, shape, spriteBatch, game)
 {
     clickTimer = 0;
     unclickTimer = 0;
     UnclickTimerLimit = 0;
     unclickTriggered = false;
     hoverTimer = 0;
     unhoverTimer = 0;
     ClickPosition = new ConstantParametricCurve();
     ClickSize = new ConstantParametricCurve();
     HoverPosition = new ConstantParametricCurve();
     HoverSize = new ConstantParametricCurve();
     UnclickPosition = new ConstantParametricCurve();
     UnclickSize = new ConstantParametricCurve();
     UnhoverPosition = new ConstantParametricCurve();
     UnhoverSize = new ConstantParametricCurve();
     x0 = boundingRectangle.X;
     y0 = boundingRectangle.Y;
     w0 = boundingRectangle.Width;
     h0 = boundingRectangle.Height;
 }
コード例 #4
0
 /// <summary>
 /// Constructs an MSAnimatingButton with no highlight.
 /// </summary>
 /// <param name="label">Add text to this MSAnimatingButton with an MSLabel. Use null if you don't need to add text. Make sure to position the MSLabel relative to the upper-left corner of this MSButton.</param>
 /// <param name="action">will be executed when this MSAnimatingButton is clicked</param>
 /// <param name="boundingRectangle">the bounding Rectangle of this MSAnimatingButton</param>
 /// <param name="unhovered">will be drawn when this MSAnimatingButton is unhovered</param>
 /// <param name="clicked">will be drawn when this MSAnimatingButton is pressed and hovered</param>
 /// <param name="hovered">will be drawn when this MSAnimatingButton is released and hovered</param>
 /// <param name="spriteBatch">the SpriteBatch that will draw this MSButton</param>
 /// <param name="shape">the Shape of this MSButton<seealso cref="MoodSwingCoreComponents.Shape"/></param>
 /// <param name="game">the Game where this MSButton will be used</param>
 public MSAnimatingButton(MSLabel label, MSAction action, Rectangle boundingRectangle, Texture2D unhovered, Texture2D clicked, Texture2D hovered, MSToolTip toolTip, Shape shape, SpriteBatch spriteBatch, Game game)
     : this(label, action, boundingRectangle, unhovered, clicked, hovered, Color.White, toolTip, shape, spriteBatch, game)
 {
 }
コード例 #5
0
ファイル: MSTextField.cs プロジェクト: verngutz/MoodSwing
 public MSTextField(String text, Rectangle boundingRectangle, MSAction onEnter, MSGUITypable onTab, int maxTextLength, SpriteFont spriteFont, SpriteBatch spriteBatch, Game game)
     : this(text, boundingRectangle, onEnter, onTab, maxTextLength, spriteFont, Color.Black, spriteBatch, game)
 {
 }