Modular game menu working with Vocalization tab added in.
This commit is contained in:
parent
4defd4f24b
commit
8cfff47a58
|
@ -75,9 +75,6 @@ EndProject
|
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedSaveBackup", "AdvancedSaveBackup\AdvancedSaveBackup.csproj", "{12984468-2B79-4B3B-B045-EE917301DEE0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocalization", "Vocalization\Vocalization\Vocalization.csproj", "{1651701C-DB36-43C7-B66D-2700171DD9A9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A} = {7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
@ -0,0 +1,339 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents;
|
||||
|
||||
namespace StardustCore.Menus
|
||||
{
|
||||
public class ModularGameMenu : StardustCore.UIUtilities.IClickableMenuExtended
|
||||
{
|
||||
public static SortedDictionary<string, List<KeyValuePair<StardustCore.UIUtilities.MenuComponents.Button, IClickableMenuExtended>>> StaticMenuTabsAndPages = new SortedDictionary<string, List<KeyValuePair<Button, IClickableMenuExtended>>>();
|
||||
|
||||
|
||||
|
||||
public string hoverText = "";
|
||||
public string descriptionText = "";
|
||||
public Dictionary<StardustCore.UIUtilities.MenuComponents.Button, IClickableMenuExtended> menuTabsAndPages;
|
||||
|
||||
public Button currentButton;
|
||||
public IClickableMenuExtended currentMenu;
|
||||
|
||||
public bool invisible;
|
||||
public static bool forcePreventClose;
|
||||
|
||||
public const int tabsPerPage = 12;
|
||||
|
||||
public ModularGameMenu()
|
||||
: base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true)
|
||||
{
|
||||
ModCore.ModMonitor.Log("INITIALIZE MENU: ", LogLevel.Alert);
|
||||
if (Game1.activeClickableMenu == null)
|
||||
Game1.playSound("bigSelect");
|
||||
GameMenu.forcePreventClose = false;
|
||||
|
||||
this.menuTabsAndPages = new Dictionary<Button, IClickableMenuExtended>();
|
||||
ModCore.ModMonitor.Log("INITIALIZE MENU: ", LogLevel.Alert);
|
||||
foreach (var v in StaticMenuTabsAndPages)
|
||||
{
|
||||
ModCore.ModMonitor.Log("LIST A GO GO", LogLevel.Alert);
|
||||
foreach (var pair in v.Value)
|
||||
{
|
||||
this.AddMenuTab(pair.Key, pair.Value.clone());
|
||||
ModCore.ModMonitor.Log("ADD IN A PART", LogLevel.Alert);
|
||||
}
|
||||
//this.menuTabsAndPages.Add(v.Key,v.Value.clone());
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddTabsForMod(IManifest modManifest, List<KeyValuePair<Button, IClickableMenuExtended>> menuComponents)
|
||||
{
|
||||
StaticMenuTabsAndPages.Add(modManifest.UniqueID, menuComponents);
|
||||
}
|
||||
|
||||
public void AddMenuTab(Button b, IClickableMenuExtended menu)
|
||||
{
|
||||
int count = menuTabsAndPages.Count % tabsPerPage;
|
||||
int xPos = this.xPositionOnScreen + count * 64;
|
||||
int yPos = this.yPositionOnScreen;
|
||||
|
||||
b.bounds = new Rectangle(xPos, yPos, b.bounds.Width, b.bounds.Height);
|
||||
|
||||
|
||||
if (b.extraTextures == null)
|
||||
{
|
||||
menuTabsAndPages.Add(b, menu);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < b.extraTextures.Count; i++)
|
||||
{
|
||||
ClickableTextureComponent text = b.extraTextures.ElementAt(i).Key;
|
||||
Rectangle bounds = new Rectangle(b.bounds.X + text.bounds.X, b.bounds.Y + text.bounds.Y, text.bounds.Width, text.bounds.Height);
|
||||
text.bounds = bounds;
|
||||
b.extraTextures[i] =new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(text,b.extraTextures.ElementAt(i).Value);
|
||||
}
|
||||
|
||||
menuTabsAndPages.Add(b, menu);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get how many pages there should be for the modular menu.
|
||||
/// </summary>
|
||||
public int getNumberOfPages()
|
||||
{
|
||||
int count = (menuTabsAndPages.Count / tabsPerPage);
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes in the static declared tabs and tries to set the menu tabs to that.
|
||||
/// </summary>
|
||||
/// <param name="startingTab"></param>
|
||||
public ModularGameMenu(int startingTab) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true)
|
||||
{
|
||||
ModCore.ModMonitor.Log("INITIALIZE MENU: ", LogLevel.Alert);
|
||||
if (Game1.activeClickableMenu == null)
|
||||
Game1.playSound("bigSelect");
|
||||
GameMenu.forcePreventClose = false;
|
||||
|
||||
this.menuTabsAndPages = new Dictionary<Button, IClickableMenuExtended>();
|
||||
ModCore.ModMonitor.Log("INITIALIZE MENU: ", LogLevel.Alert);
|
||||
foreach (var v in StaticMenuTabsAndPages)
|
||||
{
|
||||
ModCore.ModMonitor.Log("LIST A GO GO", LogLevel.Alert);
|
||||
foreach (var pair in v.Value)
|
||||
{
|
||||
this.AddMenuTab(pair.Key, pair.Value.clone());
|
||||
ModCore.ModMonitor.Log("ADD IN A PART", LogLevel.Alert);
|
||||
}
|
||||
//this.menuTabsAndPages.Add(v.Key,v.Value.clone());
|
||||
}
|
||||
this.changeTab(startingTab);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// More modular menu to only have a subset of buttons and pages.
|
||||
/// </summary>
|
||||
/// <param name="startingTab"></param>
|
||||
/// <param name="tabsAndPages"></param>
|
||||
public ModularGameMenu(int startingTab, Dictionary<Button, IClickableMenuExtended> tabsAndPages)
|
||||
: this()
|
||||
{
|
||||
foreach (var v in tabsAndPages)
|
||||
{
|
||||
this.AddMenuTab(v.Key, v.Value.clone());
|
||||
}
|
||||
this.changeTab(startingTab);
|
||||
}
|
||||
|
||||
public override void snapToDefaultClickableComponent()
|
||||
{
|
||||
/*
|
||||
if (this.currentTab < this.pages.Count)
|
||||
this.pages[this.currentTab].snapToDefaultClickableComponent();
|
||||
if (this.junimoNoteIcon == null || this.currentTab >= this.pages.Count || this.pages[this.currentTab].allClickableComponents.Contains((ClickableComponent)this.junimoNoteIcon))
|
||||
return;
|
||||
this.pages[this.currentTab].allClickableComponents.Add((ClickableComponent)this.junimoNoteIcon);
|
||||
*/
|
||||
currentMenu.snapToDefaultClickableComponent();
|
||||
}
|
||||
|
||||
public override void receiveGamePadButton(Buttons b)
|
||||
{
|
||||
base.receiveGamePadButton(b);
|
||||
/*
|
||||
switch (b)
|
||||
{
|
||||
case Buttons.Back:
|
||||
if (this.currentTab != 0)
|
||||
break;
|
||||
this.pages[this.currentTab].receiveGamePadButton(b);
|
||||
break;
|
||||
case Buttons.RightTrigger:
|
||||
if (this.currentTab == 3)
|
||||
{
|
||||
Game1.activeClickableMenu = (IClickableMenu)new GameMenu(4, -1);
|
||||
break;
|
||||
}
|
||||
if (this.currentTab >= 7 || !this.pages[this.currentTab].readyToClose())
|
||||
break;
|
||||
this.changeTab(this.currentTab + 1);
|
||||
break;
|
||||
case Buttons.LeftTrigger:
|
||||
if (this.currentTab == 3)
|
||||
{
|
||||
Game1.activeClickableMenu = (IClickableMenu)new GameMenu(2, -1);
|
||||
break;
|
||||
}
|
||||
if (this.currentTab <= 0 || !this.pages[this.currentTab].readyToClose())
|
||||
break;
|
||||
this.changeTab(this.currentTab - 1);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
currentMenu.receiveGamePadButton(b);
|
||||
}
|
||||
|
||||
public override void setUpForGamePadMode()
|
||||
{
|
||||
base.setUpForGamePadMode();
|
||||
}
|
||||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
base.receiveLeftClick(x, y, playSound);
|
||||
//click the menu and stuff here I guess.
|
||||
foreach (var v in menuTabsAndPages)
|
||||
{
|
||||
if (v.Key.containsPoint(x, y))
|
||||
{
|
||||
//Make sub menu this menu value.
|
||||
}
|
||||
}
|
||||
//Check for submenu leftclick
|
||||
currentMenu.receiveLeftClick(x, y, playSound);
|
||||
}
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
//base.receiveLeftClick(x, y, playSound);
|
||||
//click the menu and stuff here I guess.
|
||||
foreach (var v in menuTabsAndPages)
|
||||
{
|
||||
if (v.Key.containsPoint(x, y))
|
||||
{
|
||||
//Make sub menu this menu value.
|
||||
}
|
||||
}
|
||||
//Check for submenu right
|
||||
currentMenu.receiveRightClick(x, y);
|
||||
}
|
||||
|
||||
public override void receiveScrollWheelAction(int direction)
|
||||
{
|
||||
base.receiveScrollWheelAction(direction);
|
||||
//this.pages[this.currentTab].receiveScrollWheelAction(direction);
|
||||
//check for submenu scroll action.
|
||||
currentMenu.receiveScrollWheelAction(direction);
|
||||
}
|
||||
|
||||
public override void performHoverAction(int x, int y)
|
||||
{
|
||||
base.performHoverAction(x, y);
|
||||
this.hoverText = "";
|
||||
currentMenu.performHoverAction(x, y);
|
||||
//this.pages[this.currentTab].performHoverAction(x, y);
|
||||
foreach (var tab in this.menuTabsAndPages)
|
||||
{
|
||||
if (tab.Key.containsPoint(x, y))
|
||||
{
|
||||
this.hoverText = tab.Key.label;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void releaseLeftClick(int x, int y)
|
||||
{
|
||||
base.releaseLeftClick(x, y);
|
||||
//this.pages[this.currentTab].releaseLeftClick(x, y);
|
||||
currentMenu.releaseLeftClick(x, y);
|
||||
}
|
||||
|
||||
public override void leftClickHeld(int x, int y)
|
||||
{
|
||||
base.leftClickHeld(x, y);
|
||||
//this.pages[this.currentTab].leftClickHeld(x, y);
|
||||
currentMenu.leftClickHeld(x, y);
|
||||
}
|
||||
|
||||
public override bool readyToClose()
|
||||
{
|
||||
if (!GameMenu.forcePreventClose)
|
||||
return currentMenu.readyToClose();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void changeTab(int which)
|
||||
{
|
||||
currentButton = menuTabsAndPages.ElementAt(which).Key;
|
||||
currentMenu = menuTabsAndPages.ElementAt(which).Value;
|
||||
}
|
||||
|
||||
public void setTabNeighborsForCurrentPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (!this.invisible)
|
||||
{
|
||||
if (!Game1.options.showMenuBackground)
|
||||
b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.4f);
|
||||
//Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, currentMenu.width, currentMenu.height, false, true, (string)null, false);
|
||||
//this.pages[this.currentTab].draw(b);
|
||||
drawDialogueBoxBackground();
|
||||
|
||||
b.End();
|
||||
b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
|
||||
Dictionary<Button, IClickableMenuExtended> subTabs = new Dictionary<Button, IClickableMenuExtended>();
|
||||
for (int i = getNumberOfPages() * tabsPerPage; i < (getNumberOfPages() + 1) * tabsPerPage; i++)
|
||||
{
|
||||
if (i >= menuTabsAndPages.Count) break;
|
||||
else
|
||||
{
|
||||
var pair = menuTabsAndPages.ElementAt(i);
|
||||
subTabs.Add(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var tab in subTabs)
|
||||
{
|
||||
if (tab.Key.visible)
|
||||
{
|
||||
if (tab.Key == currentButton)
|
||||
{
|
||||
tab.Key.draw(b, Color.White, new Vector2(0,0));
|
||||
continue;
|
||||
}
|
||||
tab.Key.draw(b);
|
||||
}
|
||||
}
|
||||
//currentMenu.draw(b);
|
||||
|
||||
if (Game1.options.hardwareCursor)
|
||||
return;
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)Game1.getOldMouseX(), (float)Game1.getOldMouseY()), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, Game1.options.gamepadControls ? 44 : 0, 16, 16)), Color.White, 0.0f, Vector2.Zero, (float)(4.0 + (double)Game1.dialogueButtonScale / 150.0), SpriteEffects.None, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool areGamePadControlsImplemented()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void receiveKeyPress(Keys key)
|
||||
{
|
||||
if (((IEnumerable<InputButton>)Game1.options.menuButton).Contains<InputButton>(new InputButton(key)) && this.readyToClose())
|
||||
{
|
||||
Game1.exitActiveMenu();
|
||||
Game1.playSound("bigDeSelect");
|
||||
}
|
||||
//this.pages[this.currentTab].receiveKeyPress(key);
|
||||
currentMenu.receiveKeyPress(key);
|
||||
}
|
||||
|
||||
public override void emergencyShutDown()
|
||||
{
|
||||
base.emergencyShutDown();
|
||||
currentMenu.emergencyShutDown();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ namespace StardustCore
|
|||
public class ModConfig
|
||||
{
|
||||
public bool enableMultiplayerHack { get; set; } = false;
|
||||
public string modularMenuKey { get; set; } = "P";
|
||||
|
||||
|
||||
public ModConfig()
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ using StardewModdingAPI;
|
|||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using StardewValley.Network;
|
||||
using StardustCore.Menus;
|
||||
using StardustCore.ModInfo;
|
||||
using StardustCore.NetCode;
|
||||
using StardustCore.Objects;
|
||||
|
@ -30,6 +31,7 @@ namespace StardustCore
|
|||
public static UIUtilities.TextureManager TextureManager;
|
||||
public static Dictionary<string, TextureManager> TextureManagers;
|
||||
|
||||
|
||||
|
||||
public static Multiplayer multiplayer;
|
||||
bool serverHack;
|
||||
|
@ -187,6 +189,10 @@ namespace StardustCore
|
|||
|
||||
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
||||
{
|
||||
if(e.KeyPressed.ToString()== config.modularMenuKey && Game1.activeClickableMenu==null)
|
||||
{
|
||||
Game1.activeClickableMenu = new ModularGameMenu(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
||||
|
@ -232,7 +238,8 @@ namespace StardustCore
|
|||
|
||||
private void ControlEvents_MouseChanged(object sender, StardewModdingAPI.Events.EventArgsMouseStateChanged e)
|
||||
{
|
||||
|
||||
//???
|
||||
return;
|
||||
if (Game1.activeClickableMenu == null) return;
|
||||
var MouseState = Mouse.GetState();
|
||||
if (Game1.activeClickableMenu is StardewValley.Menus.ItemGrabMenu && MouseState.LeftButton == ButtonState.Released)
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
<Compile Include="Interfaces\IToolSerializer.cs" />
|
||||
<Compile Include="Math\Hex.cs" />
|
||||
<Compile Include="Math\Hex32.cs" />
|
||||
<Compile Include="Menus\ModualGameMenu.cs" />
|
||||
<Compile Include="ModConfig.cs" />
|
||||
<Compile Include="NetCode\Graphics\NetAnimation.cs" />
|
||||
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
|
||||
|
|
|
@ -15,11 +15,31 @@ namespace StardustCore.UIUtilities
|
|||
public List<StardustCore.UIUtilities.MenuComponents.Button> buttons;
|
||||
public Color dialogueBoxBackgroundColor;
|
||||
public List<Texture2DExtended> menuTextures;
|
||||
|
||||
public bool showRightCloseButton;
|
||||
|
||||
public IClickableMenuExtended(): base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IClickableMenuExtended(int x, int y, int width, int height, bool showCloseButton): base(x, y, width, height, showCloseButton)
|
||||
{
|
||||
this.showRightCloseButton = showCloseButton;
|
||||
}
|
||||
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual IClickableMenuExtended clone()
|
||||
{
|
||||
return new IClickableMenuExtended(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.showRightCloseButton);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a dialogue box background with the menu's position and dimentions as the paramaters for size and position.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -12,9 +13,9 @@ namespace StardustCore.UIUtilities
|
|||
/// </summary>
|
||||
public class LayeredTexture
|
||||
{
|
||||
public List<Texture2DExtended> textureLayers;
|
||||
public List<KeyValuePair<Rectangle,Texture2DExtended>> textureLayers;
|
||||
|
||||
public LayeredTexture(List<Texture2DExtended> textures)
|
||||
public LayeredTexture(List<KeyValuePair<Rectangle,Texture2DExtended>> textures)
|
||||
{
|
||||
this.textureLayers = textures;
|
||||
}
|
||||
|
@ -23,7 +24,7 @@ namespace StardustCore.UIUtilities
|
|||
/// Adds a new texture as the top layer.
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
public void addTexture(Texture2DExtended texture)
|
||||
public void addTexture(KeyValuePair<Rectangle,Texture2DExtended> texture)
|
||||
{
|
||||
this.textureLayers.Add(texture);
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ namespace StardustCore.UIUtilities
|
|||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="index"></param>
|
||||
public void addTexture(Texture2DExtended texture, int index)
|
||||
public void addTexture(KeyValuePair<Rectangle, Texture2DExtended>texture , int index)
|
||||
{
|
||||
this.textureLayers.Insert(index, texture);
|
||||
}
|
||||
|
@ -43,5 +44,13 @@ namespace StardustCore.UIUtilities
|
|||
return new LayeredTexture(this.textureLayers);
|
||||
}
|
||||
|
||||
public void draw(SpriteBatch b, Color color, float layerDepth)
|
||||
{
|
||||
foreach(var texture in this.textureLayers)
|
||||
{
|
||||
b.Draw(texture.Value.getTexture(), texture.Key, color);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using StardustCore.UIUtilities.MenuComponents.Delegates;
|
||||
using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality;
|
||||
using System;
|
||||
|
@ -12,14 +13,27 @@ using static StardustCore.UIUtilities.MenuComponents.Delegates.Delegates;
|
|||
|
||||
namespace StardustCore.UIUtilities.MenuComponents
|
||||
{
|
||||
public enum ExtraTextureDrawOrder
|
||||
{
|
||||
before,
|
||||
after
|
||||
}
|
||||
|
||||
public class Button : StardewValley.Menus.ClickableTextureComponent
|
||||
{
|
||||
|
||||
|
||||
|
||||
public Animations.AnimationManager animationManager;
|
||||
public Color textureColor;
|
||||
public Color textColor;
|
||||
|
||||
public ButtonFunctionality buttonFunctionality;
|
||||
|
||||
/// <summary>
|
||||
/// A list of textures to be drawn on top of the button.
|
||||
/// </summary>
|
||||
public List<KeyValuePair<StardewValley.Menus.ClickableTextureComponent,ExtraTextureDrawOrder>> extraTextures;
|
||||
|
||||
/// <summary>
|
||||
/// Empty Constructor.
|
||||
|
@ -38,7 +52,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// <param name="Scale"></param>
|
||||
/// <param name="defaultAnimation"></param>
|
||||
/// <param name="AnimationEnabled"></param>
|
||||
public Button(string Name,Rectangle Bounds,Texture2DExtended Texture,string displayText,Rectangle sourceRect,float Scale,Animations.Animation defaultAnimation, Color DrawColor,Color TextColor, ButtonFunctionality Functionality, bool AnimationEnabled=true) : base(Bounds,Texture.getTexture(), sourceRect,Scale)
|
||||
public Button(string Name,Rectangle Bounds,Texture2DExtended Texture,string displayText,Rectangle sourceRect,float Scale,Animations.Animation defaultAnimation, Color DrawColor,Color TextColor, ButtonFunctionality Functionality, bool AnimationEnabled=true,List<KeyValuePair<ClickableTextureComponent,ExtraTextureDrawOrder>> extraTexture=null) : base(Bounds,Texture.getTexture(), sourceRect,Scale)
|
||||
{
|
||||
this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation,AnimationEnabled);
|
||||
this.label = displayText;
|
||||
|
@ -54,6 +68,10 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
|
||||
}
|
||||
this.buttonFunctionality = Functionality;
|
||||
if (extraTexture == null) extraTexture = new List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>>();
|
||||
extraTextures = extraTexture;
|
||||
|
||||
this.scale = Scale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -70,7 +88,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// <param name="startingAnimationKey"></param>
|
||||
/// <param name="startingAnimationFrame"></param>
|
||||
/// <param name="AnimationEnabled"></param>
|
||||
public Button(string Name,Rectangle Bounds,Texture2DExtended Texture, string displayText, Rectangle sourceRect,float Scale, Animations.Animation defaultAnimation,Dictionary<string, List<Animations.Animation>> animationsToPlay,string startingAnimationKey,Color DrawColor,Color TextColor, ButtonFunctionality Functionality,int startingAnimationFrame=0,bool AnimationEnabled=true) : base(Bounds, Texture.getTexture(), sourceRect, Scale)
|
||||
public Button(string Name,Rectangle Bounds,Texture2DExtended Texture, string displayText, Rectangle sourceRect,float Scale, Animations.Animation defaultAnimation,Dictionary<string, List<Animations.Animation>> animationsToPlay,string startingAnimationKey,Color DrawColor,Color TextColor, ButtonFunctionality Functionality,int startingAnimationFrame=0,bool AnimationEnabled=true, List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>> extraTexture =null) : base(Bounds, Texture.getTexture(), sourceRect, Scale)
|
||||
{
|
||||
this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation, animationsToPlay, startingAnimationKey, startingAnimationFrame, AnimationEnabled);
|
||||
this.label = displayText;
|
||||
|
@ -86,6 +104,10 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
|
||||
}
|
||||
this.buttonFunctionality = Functionality;
|
||||
if (extraTexture == null) extraTexture = new List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>>();
|
||||
this.extraTextures = extraTexture;
|
||||
|
||||
this.scale = Scale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -94,9 +116,19 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
/// <param name="b"></param>
|
||||
/// <param name="c"></param>
|
||||
/// <param name="layerDepth"></param>
|
||||
public void draw(SpriteBatch b,Color color ,float layerDepth)
|
||||
public new void draw(SpriteBatch b,Color color ,float layerDepth)
|
||||
{
|
||||
|
||||
if (this.extraTextures != null)
|
||||
{
|
||||
foreach (var v in this.extraTextures)
|
||||
{
|
||||
if (v.Value == ExtraTextureDrawOrder.before)
|
||||
{
|
||||
v.Key.draw(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.animationManager.tickAnimation();
|
||||
if (!this.visible)
|
||||
return;
|
||||
|
@ -119,7 +151,17 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
{
|
||||
//Game1.drawDialogueBox(Game1.getMousePosition().X, Game1.getMousePosition().Y, false, false, this.hoverText);
|
||||
//StardustCore.ModCore.ModMonitor.Log("HOVER???");
|
||||
b.DrawString(Game1.smallFont, this.hoverText, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor,0f,Vector2.Zero,1f,SpriteEffects.None,layerDepth-0.5f);
|
||||
b.DrawString(Game1.smallFont, this.hoverText, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor,0f,Vector2.Zero,scale,SpriteEffects.None,layerDepth-0.5f);
|
||||
}
|
||||
if (this.extraTextures != null)
|
||||
{
|
||||
foreach(var v in this.extraTextures)
|
||||
{
|
||||
if (v.Value == ExtraTextureDrawOrder.after)
|
||||
{
|
||||
v.Key.draw(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -132,7 +174,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
{
|
||||
if (!this.visible)
|
||||
return;
|
||||
this.draw(b, Color.White, (float)(0.860000014305115 + (double)this.bounds.Y / 20000.0));
|
||||
this.draw(b, Color.White, Vector2.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -144,7 +186,35 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
{
|
||||
if (!this.visible)
|
||||
return;
|
||||
this.draw(b, color, (float)(0.860000014305115 + (double)this.bounds.Y / 20000.0));
|
||||
this.draw(b, color, Vector2.Zero);
|
||||
}
|
||||
|
||||
public virtual void draw(SpriteBatch b, Color color, Vector2 offset)
|
||||
{
|
||||
if (this.extraTextures != null)
|
||||
{
|
||||
foreach (var v in this.extraTextures)
|
||||
{
|
||||
if (v.Value == ExtraTextureDrawOrder.before)
|
||||
{
|
||||
v.Key.draw(b,color,0.4f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float depth = 0.4f;
|
||||
b.Draw(this.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, depth);
|
||||
|
||||
if (this.extraTextures != null)
|
||||
{
|
||||
foreach (var v in this.extraTextures)
|
||||
{
|
||||
if (v.Value == ExtraTextureDrawOrder.after)
|
||||
{
|
||||
v.Key.draw(b,color,0.4f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 265 B |
Binary file not shown.
After Width: | Height: | Size: 270 B |
|
@ -12,6 +12,9 @@ using StardewModdingAPI;
|
|||
using StardewValley;
|
||||
using StardewValley.BellsAndWhistles;
|
||||
using StardewValley.Menus;
|
||||
using StardustCore.Menus;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents;
|
||||
using Vocalization.Framework;
|
||||
|
||||
namespace Vocalization
|
||||
|
@ -166,6 +169,7 @@ namespace Vocalization
|
|||
/// </summary>
|
||||
public static SimpleSoundManager.Framework.SoundManager soundManager;
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -190,6 +194,7 @@ namespace Vocalization
|
|||
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
||||
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
|
||||
StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed;
|
||||
StardewModdingAPI.Events.MenuEvents.MenuChanged += MenuEvents_MenuChanged;
|
||||
ModMonitor = Monitor;
|
||||
ModHelper = Helper;
|
||||
DialogueCues = new Dictionary<string, CharacterVoiceCue>();
|
||||
|
@ -205,6 +210,15 @@ namespace Vocalization
|
|||
|
||||
config.verifyValidMode(); //Make sure the current mode is valid.
|
||||
soundManager.volume = config.voiceVolume; //Set the volume for voices.
|
||||
|
||||
}
|
||||
|
||||
private void MenuEvents_MenuChanged(object sender, StardewModdingAPI.Events.EventArgsClickableMenuChanged e)
|
||||
{
|
||||
if (Game1.activeClickableMenu.GetType() == typeof(ModularGameMenu))
|
||||
{
|
||||
npcPortraitHack();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -233,10 +247,86 @@ namespace Vocalization
|
|||
/// <param name="e"></param>
|
||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
initialzeModualGameMenuHack();
|
||||
initialzeDirectories();
|
||||
loadAllVoiceFiles();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the menu tab for Vocalization for the modular menu.
|
||||
/// </summary>
|
||||
public void initialzeModualGameMenuHack()
|
||||
{
|
||||
List<Texture2D> textures = new List<Texture2D>();
|
||||
foreach (GameLocation loc in Game1.locations)
|
||||
{
|
||||
foreach (NPC npc in loc.characters)
|
||||
{
|
||||
if (npc.isVillager() == false) continue;
|
||||
Texture2D text = npc.Sprite.Texture;
|
||||
if (text == null) continue;
|
||||
textures.Add(text);
|
||||
}
|
||||
}
|
||||
int randNum = Game1.random.Next(0, textures.Count);
|
||||
Texture2D myText = textures.ElementAt(randNum);
|
||||
ClickableTextureComponent c = new ClickableTextureComponent(new Rectangle(0, 16, 16, 24), myText, new Rectangle(0, 0, 16, 24), 2f, false);
|
||||
|
||||
ClickableTextureComponent speech = new ClickableTextureComponent(new Rectangle(0, 0, 32, 32), ModHelper.Content.Load<Texture2D> (Path.Combine("Content", "Graphics", "SpeechBubble.png")), new Rectangle(0, 0, 32, 32), 2f, false);
|
||||
List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>> components = new List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>>();
|
||||
|
||||
components.Add(new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(c,ExtraTextureDrawOrder.after));
|
||||
components.Add(new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(speech, ExtraTextureDrawOrder.after));
|
||||
|
||||
Button menuTab = new Button("Vocalization", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "Vocalization", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null,null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null,null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null,null)), false, components);
|
||||
|
||||
//Change this to take the vocalization menu instead
|
||||
List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>();
|
||||
modTabs.Add(new KeyValuePair<Button, IClickableMenuExtended>(menuTab, new IClickableMenuExtended(0,0,300,300,false)));
|
||||
StardustCore.Menus.ModularGameMenu.AddTabsForMod(ModManifest,modTabs);
|
||||
|
||||
ModMonitor.Log("VOCALIZATION MENU HACK COMPLETE!", LogLevel.Alert);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Randomize the npc below the speech bubble every time the modular game menu is drawn.
|
||||
/// </summary>
|
||||
public void npcPortraitHack()
|
||||
{
|
||||
List<KeyValuePair<Button, IClickableMenuExtended>> menuHacks = new List<KeyValuePair<Button, IClickableMenuExtended>>();
|
||||
|
||||
List<Texture2D> textures = new List<Texture2D>();
|
||||
foreach (GameLocation loc in Game1.locations)
|
||||
{
|
||||
foreach (NPC npc in loc.characters)
|
||||
{
|
||||
if (npc.isVillager() == false) continue;
|
||||
Texture2D text = npc.Sprite.Texture;
|
||||
textures.Add(text);
|
||||
}
|
||||
}
|
||||
int randNum = Game1.random.Next(0, textures.Count);
|
||||
Texture2D myText = textures.ElementAt(randNum);
|
||||
ClickableTextureComponent c = new ClickableTextureComponent(new Rectangle(0, 16, 16, 24), myText, new Rectangle(0, 0, 16, 24), 2f, false);
|
||||
List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>> components = new List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>>();
|
||||
|
||||
|
||||
ClickableTextureComponent speech = new ClickableTextureComponent(new Rectangle(0, 0, 32, 32), ModHelper.Content.Load<Texture2D>(Path.Combine("Content", "Graphics", "SpeechBubble.png")), new Rectangle(0, 0, 32, 32), 2f, false);
|
||||
|
||||
components.Add(new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(c, ExtraTextureDrawOrder.after));
|
||||
components.Add(new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(speech, ExtraTextureDrawOrder.after));
|
||||
|
||||
Button menuTab = new Button("Vocalization", new Rectangle(0,0, 32, 32), new Texture2DExtended(ModHelper, ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "Vocalization", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, components);
|
||||
|
||||
//Change this to take the vocalization menu instead
|
||||
List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>();
|
||||
modTabs.Add(new KeyValuePair<Button, IClickableMenuExtended>(menuTab, new IClickableMenuExtended(0, 0, 300, 300,false)));
|
||||
|
||||
StardustCore.Menus.ModularGameMenu.StaticMenuTabsAndPages[ModManifest.UniqueID] = modTabs;
|
||||
}
|
||||
|
||||
public static object GetInstanceField(Type type, object instance, string fieldName)
|
||||
{
|
||||
BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
|
||||
|
@ -499,9 +589,11 @@ namespace Vocalization
|
|||
{
|
||||
string basePath = ModHelper.DirectoryPath;
|
||||
string contentPath = Path.Combine(basePath, "Content");
|
||||
string graphicsPath = Path.Combine(contentPath, "Graphics");
|
||||
string audioPath = Path.Combine(contentPath, "Audio");
|
||||
string voicePath = Path.Combine(audioPath, "VoiceFiles");
|
||||
|
||||
if (!Directory.Exists(graphicsPath)) Directory.CreateDirectory(graphicsPath);
|
||||
|
||||
VoicePath = voicePath; //Set a static reference to my voice files directory.
|
||||
|
||||
|
|
|
@ -61,7 +61,23 @@
|
|||
<None Include="manifest.json" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StardustCore\StardustCore.csproj">
|
||||
<Project>{0756D36A-95C8-480D-8EA6-4584C03010C6}</Project>
|
||||
<Name>StardustCore</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Graphics\MenuTab.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\SpeechBubble.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
@ -69,5 +85,7 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net461" />
|
||||
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.1.0" targetFramework="net461" />
|
||||
</packages>
|
Loading…
Reference in New Issue