Made the song selection menu. Can now click songs to play them. Now to make the selected songmenu where you can play the song or set triggers.
This commit is contained in:
parent
6ef666af6e
commit
e42e91e30d
|
@ -7,7 +7,12 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace EventSystem
|
||||
{
|
||||
{
|
||||
/*
|
||||
*TODO: Make Bed/Sleep Event.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class EventSystem: Mod
|
||||
{
|
||||
public static IModHelper ModHelper;
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
using StardustCore.Animations;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents;
|
||||
using StardustCore.UIUtilities.MenuComponents.Delegates;
|
||||
|
@ -21,14 +22,16 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
public enum DrawMode
|
||||
{
|
||||
AlbumSelection,
|
||||
SongSelection,
|
||||
AlbumFancySelection,
|
||||
SongSelectionMode,
|
||||
}
|
||||
|
||||
public List<Button> musicAlbumButtons;
|
||||
public MusicPack currentMusicPack;
|
||||
public Button currentMusicPackAlbum;
|
||||
public Button currentSelectedSong;
|
||||
public DrawMode drawMode;
|
||||
public int currentAlbumIndex;
|
||||
public int currentSongPageIndex;
|
||||
|
||||
public List<Button> fancyButtons;
|
||||
public int framesSinceLastUpdate;
|
||||
|
@ -43,6 +46,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="width"></param>
|
||||
/// <param name="height"></param>
|
||||
public MusicManagerMenu(float width, float height)
|
||||
{
|
||||
this.width = (int)width;
|
||||
|
@ -59,12 +67,14 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
int rows = 0;
|
||||
foreach(var v in StardewSymphony.musicManager.musicPacks)
|
||||
{
|
||||
var sortedQuery = v.Value.songInformation.listOfSongsWithoutTriggers.OrderBy(x => x.name);
|
||||
v.Value.songInformation.listOfSongsWithoutTriggers=sortedQuery.ToList(); //Alphabetize.
|
||||
if (v.Value.musicPackInformation.Icon == null)
|
||||
{
|
||||
Texture2DExtended texture = StardewSymphony.textureManager.getTexture("MusicDisk");
|
||||
float scale = 1.00f / ((float)texture.texture.Width / 64f);
|
||||
|
||||
this.musicAlbumButtons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64),texture, "", new Rectangle(0, 0, 16, 16), scale, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.Colors.randomColor(), Color.White,new ButtonFunctionality(new DelegatePairing(PlayRandomSongFromSelectedMusicPack, new List<object>
|
||||
this.musicAlbumButtons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64),texture, "", new Rectangle(0, 0, 16, 16), scale, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.Colors.randomColor(), Color.White,new ButtonFunctionality(new DelegatePairing(null, new List<object>
|
||||
{
|
||||
(object)v
|
||||
}
|
||||
|
@ -76,7 +86,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
else
|
||||
{
|
||||
float scale = 1.00f / ((float)v.Value.musicPackInformation.Icon.texture.Width / 64f);
|
||||
this.musicAlbumButtons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, v.Value.musicPackInformation.Icon.texture.Width, v.Value.musicPackInformation.Icon.texture.Height), scale, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, StardustCore.IlluminateFramework.LightColorsList.Black, new ButtonFunctionality(new DelegatePairing(PlayRandomSongFromSelectedMusicPack, new List<object>
|
||||
this.musicAlbumButtons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, v.Value.musicPackInformation.Icon.texture.Width, v.Value.musicPackInformation.Icon.texture.Height), scale, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, StardustCore.IlluminateFramework.LightColorsList.Black, new ButtonFunctionality(new DelegatePairing(null, new List<object>
|
||||
{
|
||||
(object)v
|
||||
}
|
||||
|
@ -111,94 +121,159 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs every game tick to check for stuff.
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
|
||||
if (framesSinceLastUpdate == 20)
|
||||
if (this.drawMode == DrawMode.AlbumFancySelection)
|
||||
{
|
||||
var state = Microsoft.Xna.Framework.Input.Keyboard.GetState();
|
||||
if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A))
|
||||
if (framesSinceLastUpdate == 20)
|
||||
{
|
||||
this.currentAlbumIndex--;
|
||||
if (this.currentAlbumIndex < 0) this.currentAlbumIndex = this.musicAlbumButtons.Count - 1;
|
||||
this.updateFancyButtons();
|
||||
this.framesSinceLastUpdate = 0;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
var state = Microsoft.Xna.Framework.Input.Keyboard.GetState();
|
||||
if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A))
|
||||
{
|
||||
this.currentAlbumIndex--;
|
||||
if (this.currentAlbumIndex < 0) this.currentAlbumIndex = this.musicAlbumButtons.Count - 1;
|
||||
this.updateFancyButtons();
|
||||
this.framesSinceLastUpdate = 0;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
|
||||
if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D))
|
||||
if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D))
|
||||
{
|
||||
this.currentAlbumIndex++;
|
||||
if (this.currentAlbumIndex == this.musicAlbumButtons.Count) this.currentAlbumIndex = 0;
|
||||
this.updateFancyButtons();
|
||||
this.framesSinceLastUpdate = 0;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentAlbumIndex++;
|
||||
if (this.currentAlbumIndex == this.musicAlbumButtons.Count) this.currentAlbumIndex = 0;
|
||||
this.updateFancyButtons();
|
||||
this.framesSinceLastUpdate = 0;
|
||||
Game1.playSound("shwip");
|
||||
this.framesSinceLastUpdate++;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (this.drawMode == DrawMode.SongSelectionMode)
|
||||
{
|
||||
this.framesSinceLastUpdate++;
|
||||
if (framesSinceLastUpdate == 20)
|
||||
{
|
||||
var state = Microsoft.Xna.Framework.Input.Keyboard.GetState();
|
||||
if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A))
|
||||
{
|
||||
if (this.currentSongPageIndex > 0)
|
||||
{
|
||||
this.currentSongPageIndex--;
|
||||
}
|
||||
this.updateFancyButtons();
|
||||
this.framesSinceLastUpdate = 0;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
|
||||
if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D))
|
||||
{
|
||||
this.currentSongPageIndex++;
|
||||
this.updateFancyButtons();
|
||||
this.framesSinceLastUpdate = 0;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.framesSinceLastUpdate++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update the position of the album artwork when displaying it using the fancy buttons menu.
|
||||
/// </summary>
|
||||
public virtual void updateFancyButtons()
|
||||
{
|
||||
this.fancyButtons.Clear();
|
||||
Vector4 placement = new Vector4((Game1.viewport.Width / 3), (Game1.viewport.Height / 4)+128, this.width, this.height / 2);
|
||||
//generate buttons
|
||||
int offsetX = 200;
|
||||
if (this.musicAlbumButtons.Count > 0)
|
||||
if (this.drawMode == DrawMode.AlbumFancySelection)
|
||||
{
|
||||
for (int i = -3; i < 4; i++)
|
||||
this.fancyButtons.Clear();
|
||||
Vector4 placement = new Vector4((Game1.viewport.Width / 3), (Game1.viewport.Height / 4) + 128, this.width, this.height / 2);
|
||||
//generate buttons
|
||||
int offsetX = 200;
|
||||
if (this.musicAlbumButtons.Count > 0)
|
||||
{
|
||||
try
|
||||
for (int i = -3; i < 4; i++)
|
||||
{
|
||||
Button button = this.musicAlbumButtons.ElementAt(this.currentAlbumIndex + i).clone();
|
||||
button.bounds = new Rectangle((int)placement.X + (i * 100)+offsetX, (int)placement.Y, 64, 64);
|
||||
fancyButtons.Add(button);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
if (this.currentAlbumIndex + i == 0)
|
||||
try
|
||||
{
|
||||
Button button = this.musicAlbumButtons.ElementAt(0).clone();
|
||||
button.bounds = new Rectangle((int)placement.X + (i * 100) + offsetX, (int)placement.Y,64, 64);
|
||||
Button button = this.musicAlbumButtons.ElementAt(this.currentAlbumIndex + i).clone();
|
||||
button.bounds = new Rectangle((int)placement.X + (i * 100) + offsetX, (int)placement.Y, 64, 64);
|
||||
fancyButtons.Add(button);
|
||||
}
|
||||
else {
|
||||
|
||||
try
|
||||
catch (Exception err)
|
||||
{
|
||||
if (this.currentAlbumIndex + i == 0)
|
||||
{
|
||||
Button button = this.musicAlbumButtons.ElementAt(((this.currentAlbumIndex + i) - this.musicAlbumButtons.Count)%this.musicAlbumButtons.Count).clone();
|
||||
Button button = this.musicAlbumButtons.ElementAt(0).clone();
|
||||
button.bounds = new Rectangle((int)placement.X + (i * 100) + offsetX, (int)placement.Y, 64, 64);
|
||||
fancyButtons.Add(button);
|
||||
}
|
||||
catch (Exception err2)
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Button button = this.musicAlbumButtons.ElementAt(((this.currentAlbumIndex + i) - this.musicAlbumButtons.Count) % this.musicAlbumButtons.Count).clone();
|
||||
button.bounds = new Rectangle((int)placement.X + (i * 100) + offsetX, (int)placement.Y, 64, 64);
|
||||
fancyButtons.Add(button);
|
||||
}
|
||||
catch (Exception err2)
|
||||
{
|
||||
|
||||
Button button = this.musicAlbumButtons.ElementAt(((this.currentAlbumIndex + i) + this.musicAlbumButtons.Count) % this.musicAlbumButtons.Count).clone();
|
||||
button.bounds = new Rectangle((int)placement.X + (i * 100) + offsetX, (int)placement.Y, 64, 64);
|
||||
fancyButtons.Add(button);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.fancyButtons.Add(new Button("Outline", new Rectangle((int)placement.X + offsetX - 16, (int)placement.Y - 16, 64, 64), StardewSymphony.textureManager.getTexture("OutlineBox"), "", new Rectangle(0, 0, 16, 16), 6f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White, new ButtonFunctionality(null, null, new DelegatePairing(null, new List<object>())), false));
|
||||
int count = 0;
|
||||
foreach (var v in fancyButtons)
|
||||
{
|
||||
|
||||
if (count == 3)
|
||||
{
|
||||
var pair = (KeyValuePair<string, MusicPack>)fancyButtons.ElementAt(count).buttonFunctionality.hover.paramaters[0];
|
||||
//v.hoverText = (string)pair.Key;
|
||||
//Do something like current album name =
|
||||
this.texturedStrings.Clear();
|
||||
this.texturedStrings.Add(SpriteFonts.vanillaFont.ParseString("Current Album Name:" + (string)pair.Key, new Microsoft.Xna.Framework.Vector2(v.bounds.X / 2, v.bounds.Y + 128), v.textColor));
|
||||
v.hoverText = "";
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
this.fancyButtons.Add(new Button("Outline", new Rectangle((int)placement.X + offsetX-16, (int)placement.Y-16, 64, 64), StardewSymphony.textureManager.getTexture("OutlineBox"), "", new Rectangle(0, 0, 16, 16), 6f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White, new ButtonFunctionality(null, null, new DelegatePairing(null,new List<object>())), false));
|
||||
int count = 0;
|
||||
foreach (var v in fancyButtons)
|
||||
}
|
||||
|
||||
if(this.drawMode == DrawMode.SongSelectionMode)
|
||||
{
|
||||
this.fancyButtons.Clear();
|
||||
//Vector4 placement = new Vector4((Game1.viewport.Width / 3), (Game1.viewport.Height / 4) + 128, this.width, this.height / 2);
|
||||
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
||||
var musicPackSongList = info.Value.songInformation.listOfSongsWithoutTriggers;
|
||||
|
||||
Vector4 placement2 = new Vector4(this.width * .2f + 400, this.height * .05f, 5 * 100, this.height * .9f);
|
||||
for (int i = 0; i < musicPackSongList.Count; i++)
|
||||
{
|
||||
|
||||
if (count == 3)
|
||||
{
|
||||
var pair = (KeyValuePair<string, MusicPack>)fancyButtons.ElementAt(count).buttonFunctionality.hover.paramaters[0];
|
||||
//v.hoverText = (string)pair.Key;
|
||||
//Do something like current album name =
|
||||
this.texturedStrings.Clear();
|
||||
this.texturedStrings.Add(SpriteFonts.vanillaFont.ParseString("Current Album Name:" + (string)pair.Key, new Microsoft.Xna.Framework.Vector2(v.bounds.X / 2, v.bounds.Y + 128), v.textColor));
|
||||
v.hoverText = "";
|
||||
}
|
||||
count++;
|
||||
//Allow 8 songs to be displayed per page.
|
||||
Texture2DExtended texture = StardewSymphony.textureManager.getTexture("MusicNote");
|
||||
float scale = 1.00f / ((float)texture.texture.Width / 64f);
|
||||
Song s = musicPackSongList.ElementAt(i);
|
||||
Rectangle srcRect = new Rectangle(0, 0, texture.texture.Width, texture.texture.Height);
|
||||
this.fancyButtons.Add(new Button(s.name, new Rectangle((int)placement2.X+25, (int)placement2.Y + ((i%6) * 100)+100, 64, 64), texture, s.name, srcRect, scale, new Animation(srcRect), Color.White, Color.White, new ButtonFunctionality(null, null, null)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,16 +376,22 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
if (this.drawMode == DrawMode.AlbumSelection) {
|
||||
if (this.drawMode == DrawMode.AlbumSelection)
|
||||
{
|
||||
foreach (var v in this.musicAlbumButtons)
|
||||
{
|
||||
if (v.containsPoint(x, y)) v.onLeftClick();
|
||||
if (v.containsPoint(x, y))
|
||||
{
|
||||
this.selectAlbum(v);
|
||||
v.onLeftClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.drawMode == DrawMode.AlbumFancySelection)
|
||||
{
|
||||
int count = 0;
|
||||
Button ok = Button.Empty();
|
||||
foreach (var v in this.fancyButtons)
|
||||
{
|
||||
if (v.containsPoint(x, y) && v.buttonFunctionality.leftClick != null)
|
||||
|
@ -318,21 +399,67 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
v.onLeftClick();
|
||||
this.currentAlbumIndex += count - 3;
|
||||
//if (this.currentAlbumIndex >= this.musicAlbumButtons.Count) this.currentAlbumIndex -= (this.musicAlbumButtons.Count);
|
||||
StardewSymphony.ModMonitor.Log(this.currentAlbumIndex.ToString());
|
||||
//StardewSymphony.ModMonitor.Log(this.currentAlbumIndex.ToString());
|
||||
while (currentAlbumIndex < 0)
|
||||
{
|
||||
this.currentAlbumIndex = (this.musicAlbumButtons.Count - (this.currentAlbumIndex * -1));
|
||||
}
|
||||
ok = v;
|
||||
}
|
||||
if (v.buttonFunctionality.leftClick != null)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
while(currentAlbumIndex < 0) {
|
||||
this.currentAlbumIndex = (this.musicAlbumButtons.Count - (this.currentAlbumIndex*-1));
|
||||
//this.updateFancyButtons();
|
||||
this.selectAlbum(ok);
|
||||
|
||||
}
|
||||
|
||||
if (this.drawMode == DrawMode.SongSelectionMode)
|
||||
{
|
||||
Button ok = Button.Empty();
|
||||
int amountToShow = 6;
|
||||
this.updateFancyButtons();
|
||||
|
||||
int count = this.fancyButtons.Count - 1;
|
||||
int amount = 0;
|
||||
if (0 + ((this.currentSongPageIndex + 1) * amountToShow) >= this.fancyButtons.Count)
|
||||
{
|
||||
amount = (0 + ((this.currentSongPageIndex + 1) * (amountToShow)) - fancyButtons.Count);
|
||||
amount = amountToShow - amount;
|
||||
if (amount < 0) amount = 0;
|
||||
}
|
||||
else if (this.fancyButtons.Count < amountToShow)
|
||||
{
|
||||
amount = this.fancyButtons.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
amount = amountToShow;
|
||||
}
|
||||
if (amount == 0 && this.currentSongPageIndex > 1)
|
||||
{
|
||||
this.currentSongPageIndex--;
|
||||
}
|
||||
var drawList = this.fancyButtons.GetRange(0 + (this.currentSongPageIndex * (amountToShow)), amount);
|
||||
|
||||
|
||||
foreach (var v in drawList)
|
||||
{
|
||||
if (v.containsPoint(x, y))
|
||||
{
|
||||
selectSong(v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Draws the menu and it's respective components depending on the drawmode that is currently set.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (this.drawMode == DrawMode.AlbumSelection)
|
||||
|
@ -355,12 +482,62 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
}
|
||||
foreach (var v in this.texturedStrings)
|
||||
{
|
||||
v.draw(b);
|
||||
v.draw(b);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.drawMode == DrawMode.SongSelectionMode)
|
||||
{
|
||||
Vector4 placement = new Vector4(this.width*.1f, this.height*.05f, 4 * 100, 128 * 2);
|
||||
this.drawDialogueBoxBackground((int)placement.X, (int)placement.Y, (int)placement.Z, (int)placement.W, new Color(new Vector4(this.dialogueBoxBackgroundColor.ToVector3(), 255)));
|
||||
|
||||
|
||||
Vector4 placement2 = new Vector4(this.width * .2f + 400, this.height * .05f, 5 * 100, this.height*.95f);
|
||||
this.drawDialogueBoxBackground((int)placement2.X, (int)placement2.Y, (int)placement2.Z, (int)placement2.W, new Color(new Vector4(this.dialogueBoxBackgroundColor.ToVector3(), 255)));
|
||||
|
||||
int amountToShow = 6;
|
||||
this.currentMusicPackAlbum.draw(b);
|
||||
|
||||
int count = this.fancyButtons.Count-1;
|
||||
int amount = 0;
|
||||
if (0 + ( (this.currentSongPageIndex+1) * amountToShow) >= this.fancyButtons.Count)
|
||||
{
|
||||
amount = (0 + ((this.currentSongPageIndex+1) * (amountToShow)) - fancyButtons.Count);
|
||||
amount = amountToShow - amount;
|
||||
if (amount < 0) amount = 0;
|
||||
}
|
||||
else if (this.fancyButtons.Count < amountToShow)
|
||||
{
|
||||
amount = this.fancyButtons.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
amount = amountToShow;
|
||||
}
|
||||
if (amount==0 && this.currentSongPageIndex>1)
|
||||
{
|
||||
this.currentSongPageIndex--;
|
||||
}
|
||||
var drawList = this.fancyButtons.GetRange(0 + (this.currentSongPageIndex * (amountToShow)), amount);
|
||||
|
||||
foreach(var v in drawList)
|
||||
{
|
||||
v.draw(b);
|
||||
}
|
||||
|
||||
foreach(var v in this.texturedStrings)
|
||||
{
|
||||
v.draw(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.drawMouse(b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Button Functionality
|
||||
#region
|
||||
private void hello(List<object> param)
|
||||
|
@ -371,12 +548,37 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
public void PlayRandomSongFromSelectedMusicPack(List<object> param)
|
||||
{
|
||||
var info=(KeyValuePair<string, MusicPack>)param[0];
|
||||
StardewSymphony.ModMonitor.Log(info.ToString());
|
||||
//StardewSymphony.ModMonitor.Log(info.ToString());
|
||||
StardewSymphony.musicManager.swapMusicPacks(info.Key);
|
||||
StardewSymphony.musicManager.playRandomSongFromPack(info.Key);
|
||||
//info.Value.playRandomSong();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select a album artwork and change the draw mode to go to the song selection screen.
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
public void selectAlbum(Button b)
|
||||
{
|
||||
if (b.label == "Null") return;
|
||||
this.currentMusicPackAlbum = b.clone(new Vector2(this.width*.1f+64,this.height*.05f+128));
|
||||
StardewSymphony.ModMonitor.Log("Album Selected!"+b.name);
|
||||
this.texturedStrings.Clear();
|
||||
this.texturedStrings.Add(SpriteFonts.vanillaFont.ParseString("Name:" + (string)b.name, new Microsoft.Xna.Framework.Vector2(this.width*.1f, this.height*.05f + 256), b.textColor));
|
||||
this.drawMode = DrawMode.SongSelectionMode;
|
||||
}
|
||||
|
||||
public void selectSong(Button b)
|
||||
{
|
||||
if (b.label == "Null") return;
|
||||
this.currentSelectedSong = b;
|
||||
StardewSymphony.ModMonitor.Log("Song Selected!" + b.name);
|
||||
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
||||
StardewSymphony.ModMonitor.Log("Select Pack:"+info.Key);
|
||||
StardewSymphony.musicManager.swapMusicPacks(info.Key);
|
||||
StardewSymphony.musicManager.playSongFromCurrentPack(b.name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,10 @@ namespace StardewSymphonyRemastered.Framework
|
|||
}
|
||||
this.currentMusicPack = getMusicPack(nameOfNewMusicPack);
|
||||
}
|
||||
else
|
||||
{
|
||||
StardewSymphony.ModMonitor.Log("ERROR: Music Pack " + nameOfNewMusicPack + " isn't valid for some reason.", StardewModdingAPI.LogLevel.Alert);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -134,11 +138,7 @@ namespace StardewSymphonyRemastered.Framework
|
|||
/// <returns></returns>
|
||||
public bool isMusicPackValid(string nameOfMusicPack)
|
||||
{
|
||||
if (this.currentMusicPack.isNull() == false)
|
||||
{
|
||||
return musicPacks.ContainsKey(nameOfMusicPack);
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -20,6 +20,15 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
|
||||
public ButtonFunctionality buttonFunctionality;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Empty Constructor.
|
||||
/// </summary>
|
||||
public Button(Rectangle Bounds,Texture2DExtended Texture,Rectangle sourceRect,float Scale): base(Bounds, Texture.texture, sourceRect, Scale)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Basic Button constructor.
|
||||
/// </summary>
|
||||
|
@ -192,7 +201,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// <summary>
|
||||
/// Returns a new object based off of the data of this object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>A Button object that is identical to the one passed in.</returns>
|
||||
public Button clone()
|
||||
{
|
||||
var b= new Button(this.name, this.bounds, this.animationManager.objectTexture, this.label, this.sourceRect, this.scale, this.animationManager.defaultDrawFrame, this.textureColor, this.textColor, this.buttonFunctionality, true);
|
||||
|
@ -202,5 +211,51 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes a clone of the passed in button but at a new position.
|
||||
/// </summary>
|
||||
/// <param name="newPosition"></param>
|
||||
/// <returns></returns>
|
||||
public 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.objectTexture, this.label, this.sourceRect, this.scale, this.animationManager.defaultDrawFrame, this.textureColor, this.textColor, this.buttonFunctionality, true);
|
||||
if (b.buttonFunctionality.hover == null)
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("I'm null!");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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()
|
||||
{
|
||||
return this.clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new "null" Button.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Button EmptyButton()
|
||||
{
|
||||
var b= new Button(new Rectangle(0, 0, 16, 16), new Texture2DExtended(), new Rectangle(0, 0, 16, 16), 1f);
|
||||
b.label = "Null";
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new "null" Button.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Button Empty()
|
||||
{
|
||||
return EmptyButton();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,13 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
|
|||
{
|
||||
public class TexturedString
|
||||
{
|
||||
List<TexturedCharacter> characters;
|
||||
Vector2 position;
|
||||
public List<TexturedCharacter> characters;
|
||||
public Vector2 position;
|
||||
public string label;
|
||||
|
||||
public TexturedString(Vector2 Position,List<TexturedCharacter> Characters)
|
||||
public TexturedString(string Label,Vector2 Position,List<TexturedCharacter> Characters)
|
||||
{
|
||||
this.label = Label;
|
||||
this.characters = Characters;
|
||||
this.position = Position;
|
||||
setCharacterPositions();
|
||||
|
@ -99,11 +101,13 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
|
|||
{
|
||||
characterList.Add(v);
|
||||
}
|
||||
TexturedString newString = new TexturedString(new Vector2(0, 0), characterList);
|
||||
TexturedString newString = new TexturedString("",new Vector2(0, 0), characterList);
|
||||
return newString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Removes the characters from the textured word.
|
||||
/// </summary>
|
||||
|
@ -125,5 +129,35 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
|
|||
v.draw(b);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of this object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TexturedString copy()
|
||||
{
|
||||
return new TexturedString(this.label,this.position, this.characters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of this object at the specified position.
|
||||
/// </summary>
|
||||
/// <param name="newPosition"></param>
|
||||
/// <returns></returns>
|
||||
public TexturedString copy(Vector2 newPosition)
|
||||
{
|
||||
return new TexturedString(this.label,newPosition, this.characters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new textured strings with a different label and position.
|
||||
/// </summary>
|
||||
/// <param name="label"></param>
|
||||
/// <param name="newPosition"></param>
|
||||
/// <returns></returns>
|
||||
public TexturedString copy(string label, Vector2 newPosition)
|
||||
{
|
||||
return new TexturedString(label, newPosition, this.characters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
|
|||
{
|
||||
characters.Add(characterSheet.getTexturedCharacter(chr));
|
||||
}
|
||||
var tStr = new TexturedString(new Microsoft.Xna.Framework.Vector2(0, 0), characters);
|
||||
var tStr = new TexturedString(str,new Microsoft.Xna.Framework.Vector2(0, 0), characters);
|
||||
return tStr;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
|
|||
{
|
||||
characters.Add(characterSheet.getTexturedCharacter(chr));
|
||||
}
|
||||
var tStr = new TexturedString(Position, characters);
|
||||
var tStr = new TexturedString(str,Position, characters);
|
||||
return tStr;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,28 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
|
|||
c.drawColor = stringColor;
|
||||
characters.Add(c);
|
||||
}
|
||||
var tStr = new TexturedString(Position, characters);
|
||||
var tStr = new TexturedString(str,Position, characters);
|
||||
return tStr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes a string and returns a textured string in it's place. Also sets the new position, label and string color.
|
||||
/// </summary>
|
||||
/// <param name="label">The label for the string.</param>
|
||||
/// <param name="str">The string that wil be parsed into textured characters.</param>
|
||||
/// <param name="Position">The position to draw the textured string.</param>
|
||||
/// <param name="stringColor">The color of the textured string.</param>
|
||||
/// <returns></returns>
|
||||
public TexturedString ParseString(string label,string str, Vector2 Position, Color stringColor)
|
||||
{
|
||||
List<TexturedCharacter> characters = new List<TexturedCharacter>();
|
||||
foreach (var chr in str)
|
||||
{
|
||||
var c = characterSheet.getTexturedCharacter(chr);
|
||||
c.drawColor = stringColor;
|
||||
characters.Add(c);
|
||||
}
|
||||
var tStr = new TexturedString(label, Position, characters);
|
||||
return tStr;
|
||||
}
|
||||
|
||||
|
@ -93,7 +114,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
|
|||
characters.Add(c);
|
||||
index++;
|
||||
}
|
||||
var tStr = new TexturedString(Position, characters);
|
||||
var tStr = new TexturedString(str,Position, characters);
|
||||
return tStr;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,16 @@ namespace StardustCore.UIUtilities
|
|||
public Texture2D texture;
|
||||
public string path;
|
||||
|
||||
/// <summary>
|
||||
/// Empty/null constructor.
|
||||
/// </summary>
|
||||
public Texture2DExtended()
|
||||
{
|
||||
this.Name = "";
|
||||
this.texture = null;
|
||||
this.path = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue