Cyclic buttons should work now.
This commit is contained in:
parent
f237cd2c10
commit
70b076322a
|
@ -170,7 +170,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// Draw the button.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
public new void draw(SpriteBatch b)
|
||||
public virtual void draw(SpriteBatch b)
|
||||
{
|
||||
if (!this.visible)
|
||||
return;
|
||||
|
@ -333,7 +333,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// Returns a new object based off of the data of this object.
|
||||
/// </summary>
|
||||
/// <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);
|
||||
if (b.buttonFunctionality.hover == null)
|
||||
|
@ -348,7 +348,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// </summary>
|
||||
/// <param name="newPosition"></param>
|
||||
/// <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);
|
||||
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.
|
||||
/// </summary>
|
||||
/// <returns>A Button object that is identical to the one passed in.</returns>
|
||||
public Button copy()
|
||||
public virtual Button copy()
|
||||
{
|
||||
return this.clone();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality;
|
||||
using System;
|
||||
|
@ -36,27 +37,88 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
{
|
||||
|
||||
//cycle button to next button and loop around if necessary.
|
||||
buttonIndex++;
|
||||
if (buttonIndex >= buttons.Count)
|
||||
{
|
||||
buttonIndex = 0;
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
//Also add in the code to also draw the label of the current button!!!
|
||||
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)
|
||||
{
|
||||
base.draw(b, color, offset);
|
||||
draw(b, color, offset, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,6 @@ namespace Vocalization.Framework.Menus
|
|||
//Change the mod config translation info
|
||||
//Clear out the Sound manager sounds and Vocalization Dialogue Cues
|
||||
//Reload all of the dialogue files
|
||||
//Change the game's localized code
|
||||
}
|
||||
|
||||
if (Vocalization.config.currentMode != getAudioMode())
|
||||
|
|
Loading…
Reference in New Issue