Cyclic buttons should work now.

This commit is contained in:
2018-08-25 10:18:41 -07:00
parent f237cd2c10
commit 70b076322a
3 changed files with 70 additions and 9 deletions

View File

@ -170,7 +170,7 @@ namespace StardustCore.UIUtilities.MenuComponents
/// Draw the button. /// Draw the button.
/// </summary> /// </summary>
/// <param name="b"></param> /// <param name="b"></param>
public new void draw(SpriteBatch b) public virtual void draw(SpriteBatch b)
{ {
if (!this.visible) if (!this.visible)
return; return;
@ -333,7 +333,7 @@ namespace StardustCore.UIUtilities.MenuComponents
/// Returns a new object based off of the data of this object. /// Returns a new object based off of the data of this object.
/// </summary> /// </summary>
/// <returns>A Button object that is identical to the one passed in.</returns> /// <returns>A Button object that is identical to the one passed in.</returns>
public Button clone() public virtual Button clone()
{ {
var b= new Button(this.name, this.bounds, this.animationManager.getExtendedTexture(), this.label, this.sourceRect, this.scale, this.animationManager.defaultDrawFrame, this.textureColor, this.textColor, this.buttonFunctionality, true); var b= new Button(this.name, this.bounds, this.animationManager.getExtendedTexture(), this.label, this.sourceRect, this.scale, this.animationManager.defaultDrawFrame, this.textureColor, this.textColor, this.buttonFunctionality, true);
if (b.buttonFunctionality.hover == null) if (b.buttonFunctionality.hover == null)
@ -348,7 +348,7 @@ namespace StardustCore.UIUtilities.MenuComponents
/// </summary> /// </summary>
/// <param name="newPosition"></param> /// <param name="newPosition"></param>
/// <returns></returns> /// <returns></returns>
public Button clone(Vector2 newPosition) public virtual Button clone(Vector2 newPosition)
{ {
var b = new Button(this.name, new Rectangle((int)newPosition.X,(int)newPosition.Y,this.bounds.Width,this.bounds.Height), this.animationManager.getExtendedTexture(), this.label, this.sourceRect, this.scale, this.animationManager.defaultDrawFrame, this.textureColor, this.textColor, this.buttonFunctionality, true); var b = new Button(this.name, new Rectangle((int)newPosition.X,(int)newPosition.Y,this.bounds.Width,this.bounds.Height), this.animationManager.getExtendedTexture(), this.label, this.sourceRect, this.scale, this.animationManager.defaultDrawFrame, this.textureColor, this.textColor, this.buttonFunctionality, true);
if (b.buttonFunctionality.hover == null) if (b.buttonFunctionality.hover == null)
@ -362,7 +362,7 @@ namespace StardustCore.UIUtilities.MenuComponents
/// Returns a new object based off of the data of this object. /// Returns a new object based off of the data of this object.
/// </summary> /// </summary>
/// <returns>A Button object that is identical to the one passed in.</returns> /// <returns>A Button object that is identical to the one passed in.</returns>
public Button copy() public virtual Button copy()
{ {
return this.clone(); return this.clone();
} }

View File

@ -1,5 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using StardewValley;
using StardewValley.Menus; using StardewValley.Menus;
using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality; using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality;
using System; using System;
@ -36,27 +37,88 @@ namespace StardustCore.UIUtilities.MenuComponents
{ {
//cycle button to next button and loop around if necessary. //cycle button to next button and loop around if necessary.
buttonIndex++;
if (buttonIndex >= buttons.Count)
{
buttonIndex = 0;
}
base.onLeftClick(); base.onLeftClick();
} }
public override void onLeftClick(int x, int y)
{
if (this.containsPoint(x, y))
{
//cycle button to next button and loop around if necessary.
buttonIndex++;
if (buttonIndex >= buttons.Count)
{
buttonIndex = 0;
}
base.onLeftClick();
}
}
public Button getCurrentButton()
{
return buttons.ElementAt(buttonIndex);
}
public string getCurrentButtonLabel()
{
return buttons.ElementAt(buttonIndex).label;
}
public override void draw(SpriteBatch b)
{
draw(b, Color.White);
}
//CHANGE ALL DRAW FUNCTIONS TO DRAW THE CURRENT BUTTON TEXTURE. //CHANGE ALL DRAW FUNCTIONS TO DRAW THE CURRENT BUTTON TEXTURE.
//Also add in the code to also draw the label of the current button!!!
public override void draw(SpriteBatch b, Color color) public override void draw(SpriteBatch b, Color color)
{ {
base.draw(b, color); draw(b, color, Vector2.Zero);
} }
public override void draw(SpriteBatch b, Color color, Vector2 offset) public override void draw(SpriteBatch b, Color color, Vector2 offset)
{ {
base.draw(b, color, offset); draw(b, color, offset, 0.5f);
} }
public override void draw(SpriteBatch b, Color color, Vector2 offset, float layerDepth) public override void draw(SpriteBatch b, Color color, Vector2 offset, float layerDepth)
{ {
base.draw(b, color, offset, layerDepth);
if (this.extraTextures != null)
{
foreach (var v in this.extraTextures)
{
if (v.Value == ExtraTextureDrawOrder.before)
{
v.Key.draw(b, color, layerDepth);
}
}
}
b.Draw(getCurrentButton().animationManager.getTexture(), new Vector2(this.bounds.X + (int)offset.X, this.bounds.Y + (int)offset.Y), this.sourceRect, color, 0f, Vector2.Zero, this.scale, SpriteEffects.None, layerDepth);
if (this.extraTextures != null)
{
foreach (var v in this.extraTextures)
{
if (v.Value == ExtraTextureDrawOrder.after)
{
v.Key.draw(b, color, layerDepth);
}
}
}
if (string.IsNullOrEmpty(this.label))
return;
b.DrawString(Game1.smallFont, "Voice Mode: "+getCurrentButtonLabel(), new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)), textColor);
} }
} }

View File

@ -87,7 +87,6 @@ namespace Vocalization.Framework.Menus
//Change the mod config translation info //Change the mod config translation info
//Clear out the Sound manager sounds and Vocalization Dialogue Cues //Clear out the Sound manager sounds and Vocalization Dialogue Cues
//Reload all of the dialogue files //Reload all of the dialogue files
//Change the game's localized code
} }
if (Vocalization.config.currentMode != getAudioMode()) if (Vocalization.config.currentMode != getAudioMode())