Finished cyclic buttons and integrated them into the vocalization menu. Also minor upgrades for the Button class.
This commit is contained in:
parent
70b076322a
commit
3029ed2c2f
|
@ -2299,6 +2299,14 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
return key;
|
||||
}
|
||||
|
||||
|
||||
if (this.currentlySelectedMenu != null)
|
||||
{
|
||||
return this.currentlySelectedMenu.label;
|
||||
}
|
||||
if (this.currentlySelectedFestival != null) return this.currentlySelectedFestival.label;
|
||||
if (this.currentlySelectedEvent != null) return this.currentlySelectedEvent.label;
|
||||
|
||||
#region
|
||||
if (this.currentlySelectedOption != null)
|
||||
{
|
||||
|
@ -2358,13 +2366,6 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
|||
}
|
||||
#endregion
|
||||
|
||||
if (this.currentlySelectedMenu != null)
|
||||
{
|
||||
return this.currentlySelectedMenu.label;
|
||||
}
|
||||
if (this.currentlySelectedFestival != null) return this.currentlySelectedFestival.label;
|
||||
if (this.currentlySelectedEvent != null) return this.currentlySelectedEvent.label;
|
||||
|
||||
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@
|
|||
<Compile Include="Objects\Tools\SerializationInformation\SerializedObjectBase.cs" />
|
||||
<Compile Include="UIUtilities\IClickableMenuExtended.cs" />
|
||||
<Compile Include="UIUtilities\LayeredTexture.cs" />
|
||||
<Compile Include="UIUtilities\MenuComponents\CycleButton.cs" />
|
||||
<Compile Include="UIUtilities\MenuComponents\Delegates\Delegates.cs" />
|
||||
<Compile Include="UIUtilities\MenuComponents\Delegates\DelegatePairing.cs" />
|
||||
<Compile Include="UIUtilities\MenuComponents\Delegates\Functionality\ButtonFunctionality.cs" />
|
||||
|
|
|
@ -43,6 +43,19 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
this.animationManager = new Animations.AnimationManager(Texture, new Animations.Animation(sourceRect), false);
|
||||
}
|
||||
|
||||
public Button(string Name,Rectangle Bounds, Texture2DExtended Texture, Rectangle sourceRect, float Scale) : base(Bounds, Texture.getTexture(), sourceRect, Scale)
|
||||
{
|
||||
this.name = Name;
|
||||
this.animationManager = new Animations.AnimationManager(Texture, new Animations.Animation(sourceRect), false);
|
||||
}
|
||||
|
||||
public Button(string Name, string displayText, Rectangle Bounds, Texture2DExtended Texture, Rectangle sourceRect, float Scale) : base(Bounds, Texture.getTexture(), sourceRect, Scale)
|
||||
{
|
||||
this.name = Name;
|
||||
this.label = displayText;
|
||||
this.animationManager = new Animations.AnimationManager(Texture, new Animations.Animation(sourceRect), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Basic Button constructor.
|
||||
/// </summary>
|
||||
|
|
|
@ -21,16 +21,19 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
public CycleButton(Rectangle bounds, List<Button> buttons, Rectangle SourceRect, float scale) : base(bounds, buttons.ElementAt(0).animationManager.getExtendedTexture(), SourceRect, scale)
|
||||
{
|
||||
this.buttons = buttons;
|
||||
this.buttonIndex = 0;
|
||||
}
|
||||
|
||||
public CycleButton(string Name, string displayText, Rectangle bounds, List<Button> buttons, Rectangle SourceRect, float scale, Animations.Animation defaultAnimation, Color DrawColor, Color TextColor, ButtonFunctionality buttonFunctionality, bool AnimationEnabled, List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>> extraTexture) : base(Name, bounds, buttons.ElementAt(0).animationManager.getExtendedTexture(), displayText, SourceRect, scale, defaultAnimation, DrawColor, TextColor, buttonFunctionality, AnimationEnabled, extraTexture)
|
||||
{
|
||||
this.buttons = buttons;
|
||||
this.buttonIndex = 0;
|
||||
}
|
||||
|
||||
public CycleButton(string Name, string displayText, Rectangle bounds, List<Button> buttons, Rectangle SourceRect, float scale, Animations.Animation defaultAnimation, Color DrawColor, Color TextColor, ButtonFunctionality buttonFunctionality, bool AnimationEnabled, Dictionary<string, List<Animations.Animation>> animationsToPlay, string startingKey, int startingAnimationFrame, List<KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>> extraTexture) : base(Name, bounds, buttons.ElementAt(0).animationManager.getExtendedTexture(), displayText, SourceRect, scale, defaultAnimation, animationsToPlay, startingKey, DrawColor, TextColor, buttonFunctionality, startingAnimationFrame, AnimationEnabled, extraTexture)
|
||||
{
|
||||
this.buttons = buttons;
|
||||
this.buttonIndex = 0;
|
||||
}
|
||||
|
||||
public override void onLeftClick()
|
||||
|
@ -50,10 +53,13 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
{
|
||||
if (this.containsPoint(x, y))
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("CLICK THE CYCLE BUTTON!");
|
||||
//cycle button to next button and loop around if necessary.
|
||||
buttonIndex++;
|
||||
StardustCore.ModCore.ModMonitor.Log("Index is! "+buttonIndex.ToString());
|
||||
if (buttonIndex >= buttons.Count)
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("NANIIII????");
|
||||
buttonIndex = 0;
|
||||
}
|
||||
|
||||
|
@ -71,6 +77,11 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
return buttons.ElementAt(buttonIndex).label;
|
||||
}
|
||||
|
||||
public string getCurrentButtonName()
|
||||
{
|
||||
return buttons.ElementAt(buttonIndex).name;
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
draw(b, Color.White);
|
||||
|
@ -103,7 +114,7 @@ namespace StardustCore.UIUtilities.MenuComponents
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
b.Draw(getCurrentButton().animationManager.getTexture(), new Vector2(this.bounds.X + (int)offset.X, this.bounds.Y + (int)offset.Y), getCurrentButton().sourceRect, color, 0f, Vector2.Zero, getCurrentButton().scale, SpriteEffects.None, layerDepth);
|
||||
|
||||
if (this.extraTextures != null)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace StardustCore.UIUtilities
|
|||
public string path;
|
||||
IModHelper helper;
|
||||
public string modID;
|
||||
public ContentSource source;
|
||||
|
||||
/// <summary>
|
||||
/// Empty/null constructor.
|
||||
|
@ -33,22 +34,24 @@ namespace StardustCore.UIUtilities
|
|||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="path">The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path);
|
||||
public Texture2DExtended(IModHelper helper,IManifest manifest,string path)
|
||||
public Texture2DExtended(IModHelper helper,IManifest manifest,string path,ContentSource contentSource=ContentSource.ModFolder)
|
||||
{
|
||||
this.Name = Path.GetFileNameWithoutExtension(path);
|
||||
this.path = path;
|
||||
this.texture = helper.Content.Load<Texture2D>(path);
|
||||
this.texture = helper.Content.Load<Texture2D>(path,contentSource);
|
||||
this.helper = helper;
|
||||
this.modID = manifest.UniqueID;
|
||||
this.source = contentSource;
|
||||
}
|
||||
|
||||
public Texture2DExtended(IModHelper helper, string modID, string path)
|
||||
public Texture2DExtended(IModHelper helper, string modID, string path, ContentSource contentSource = ContentSource.ModFolder)
|
||||
{
|
||||
this.Name = Path.GetFileNameWithoutExtension(path);
|
||||
this.path = path;
|
||||
this.texture = helper.Content.Load<Texture2D>(path);
|
||||
this.texture = helper.Content.Load<Texture2D>(path,contentSource);
|
||||
this.helper = helper;
|
||||
this.modID = modID;
|
||||
this.source = contentSource;
|
||||
}
|
||||
|
||||
public Texture2DExtended Copy()
|
||||
|
|
|
@ -21,8 +21,9 @@ namespace Vocalization.Framework.Menus
|
|||
/// </summary>
|
||||
public class VocalizationMenu: IClickableMenuExtended
|
||||
{
|
||||
SliderButton sliderButton;
|
||||
public SliderButton sliderButton;
|
||||
|
||||
public CycleButton languages;
|
||||
|
||||
public VocalizationMenu(int xPos, int yPos, int width, int height, bool showCloseButton = false) : base(xPos, yPos, width, height,showCloseButton)
|
||||
{
|
||||
|
@ -42,12 +43,41 @@ namespace Vocalization.Framework.Menus
|
|||
//Texture2DExtended barTexture = new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png"));
|
||||
Rectangle sourceRect = new Rectangle(0, 0, 4, 16);
|
||||
this.sliderButton = new SliderButton("Slider", "Volume", new Rectangle(this.xPositionOnScreen+100, this.yPositionOnScreen+220, 4, 16), buttonTexture, bar, sourceRect, 2f, new SliderInformation(SliderStyle.Horizontal, (int)(Vocalization.config.voiceVolume*100), 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true);
|
||||
|
||||
Button English = new Button("EnglishButton", "English", new Rectangle(0, 0, 174, 39),new Texture2DExtended(Vocalization.ModHelper,Vocalization.Manifest,Path.Combine("LooseSprites","LanguageButtons.xnb"),StardewModdingAPI.ContentSource.GameContent),new Rectangle(0,0,174,39), 1f);
|
||||
Button Spanish = new Button("SpanishButton", "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"),StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39*2, 174, 39), 1f);
|
||||
Button Portuguese = new Button("PortugueseButton", "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39*4, 174, 39), 1f);
|
||||
Button Russian = new Button("RussianButton", "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39*6, 174, 39), 1f);
|
||||
Button Chinese = new Button("ChineseButton", "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39*8, 174, 39), 1f);
|
||||
Button Japanese = new Button("JapaneseButton", "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39*10, 174, 39), 1f);
|
||||
Button German = new Button("GermanButton", "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39*12, 174, 39), 1f);
|
||||
List<Button> buttons = new List<Button>();
|
||||
buttons.Add(English);
|
||||
buttons.Add(Spanish);
|
||||
buttons.Add(Portuguese);
|
||||
buttons.Add(Russian);
|
||||
buttons.Add(Chinese);
|
||||
buttons.Add(Japanese);
|
||||
buttons.Add(German);
|
||||
|
||||
languages = new CycleButton(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 75, 174, 39),buttons,new Rectangle(0,0,174,39),1f);
|
||||
|
||||
for(int i=0; i < languages.buttons.Count; i++)
|
||||
{
|
||||
if (Vocalization.config.translationInfo.currentTranslation == languages.buttons.ElementAt(i).label)
|
||||
{
|
||||
|
||||
languages.buttonIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
this.sliderButton.onLeftClick(x, y);
|
||||
this.languages.onLeftClick(x, y);
|
||||
base.receiveLeftClick(x, y, playSound);
|
||||
}
|
||||
|
||||
|
@ -59,7 +89,6 @@ namespace Vocalization.Framework.Menus
|
|||
|
||||
public override IClickableMenuExtended clone()
|
||||
{
|
||||
Vocalization.ModMonitor.Log("Cloning with position: " + xPositionOnScreen.ToString());
|
||||
return new VocalizationMenu(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.showRightCloseButton);
|
||||
}
|
||||
|
||||
|
@ -67,6 +96,7 @@ namespace Vocalization.Framework.Menus
|
|||
{
|
||||
this.drawOnlyDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, new Color(255, 255, 255, 255),0.4f);
|
||||
sliderButton.draw(b,Color.White,Vector2.Zero,0.5f);
|
||||
languages.draw(b, Color.White, Vector2.Zero, 0.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -75,18 +105,17 @@ namespace Vocalization.Framework.Menus
|
|||
/// <returns></returns>
|
||||
public override bool readyToClose()
|
||||
{
|
||||
Vocalization.ModMonitor.Log(sliderButton.sliderInformation.xPos.ToString());
|
||||
decimal xPos = sliderButton.sliderInformation.xPos;
|
||||
Vocalization.config.voiceVolume = (decimal)(xPos/ 100.0M);
|
||||
Vocalization.ModMonitor.Log(Vocalization.config.voiceVolume.ToString());
|
||||
Vocalization.ModHelper.WriteConfig<ModConfig>(Vocalization.config);
|
||||
Vocalization.soundManager.volume =(float) Vocalization.config.voiceVolume;
|
||||
|
||||
if (Vocalization.config.translationInfo.currentTranslation != getTranslationInfo())
|
||||
{
|
||||
//Change the mod config translation info
|
||||
//Clear out the Sound manager sounds and Vocalization Dialogue Cues
|
||||
//Reload all of the dialogue files
|
||||
Vocalization.config.translationInfo.currentTranslation = getTranslationInfo();
|
||||
Vocalization.soundManager.sounds.Clear();
|
||||
Vocalization.DialogueCues.Clear();
|
||||
Vocalization.loadAllVoiceFiles();
|
||||
}
|
||||
|
||||
if (Vocalization.config.currentMode != getAudioMode())
|
||||
|
@ -101,7 +130,7 @@ namespace Vocalization.Framework.Menus
|
|||
public string getTranslationInfo()
|
||||
{
|
||||
//Return the name of the button which will have the translation stuff here!
|
||||
return "English";
|
||||
return languages.getCurrentButtonLabel();
|
||||
}
|
||||
|
||||
public string getAudioMode()
|
||||
|
|
|
@ -746,7 +746,7 @@ namespace Vocalization
|
|||
/// <summary>
|
||||
/// Loads in all of the .wav files associated with voice acting clips.
|
||||
/// </summary>
|
||||
public void loadAllVoiceFiles()
|
||||
public static void loadAllVoiceFiles()
|
||||
{
|
||||
//get a list of all translations supported by this mod.
|
||||
List<string> translations = Directory.GetDirectories(VoicePath).ToList();
|
||||
|
@ -806,7 +806,7 @@ namespace Vocalization
|
|||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModMonitor.Log("WHY NO ADD IN???"+err.ToString());
|
||||
ModMonitor.Log(err.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ namespace Vocalization
|
|||
/// Used to obtain all strings for almost all possible dialogue in the game.
|
||||
/// </summary>
|
||||
/// <param name="cue"></param>
|
||||
public void scrapeDictionaries(string path,CharacterVoiceCue cue,string translation)
|
||||
public static void scrapeDictionaries(string path,CharacterVoiceCue cue,string translation)
|
||||
{
|
||||
|
||||
var dialoguePath = Path.Combine("Characters", "Dialogue");
|
||||
|
@ -2201,7 +2201,7 @@ namespace Vocalization
|
|||
//DialogueCues.Add(cue.name, cue);
|
||||
}
|
||||
|
||||
public List<string> getEventSpeakerLines(string rawDialogue, string speakerName)
|
||||
public static List<string> getEventSpeakerLines(string rawDialogue, string speakerName)
|
||||
{
|
||||
string[] dialogueSplit= rawDialogue.Split('/');
|
||||
List<string> speakingData = new List<string>();
|
||||
|
@ -2228,7 +2228,7 @@ namespace Vocalization
|
|||
/// <param name="i"></param>
|
||||
/// <param name="npcName"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> getPurchasedItemDialogueForNPC(StardewValley.Object i, string npcName, string str3,string translation)
|
||||
public static List<string> getPurchasedItemDialogueForNPC(StardewValley.Object i, string npcName, string str3,string translation)
|
||||
{
|
||||
NPC n = Game1.getCharacterFromName(npcName);
|
||||
if (n == null) return new List<string>();
|
||||
|
@ -2375,7 +2375,7 @@ namespace Vocalization
|
|||
/// </summary>
|
||||
/// <param name="dialogue"></param>
|
||||
/// <returns></returns>
|
||||
public string sanitizeDialogueInGame(string dialogue)
|
||||
public static string sanitizeDialogueInGame(string dialogue)
|
||||
{
|
||||
if (dialogue.Contains(Game1.player.Name))
|
||||
{
|
||||
|
@ -2772,7 +2772,7 @@ namespace Vocalization
|
|||
return possibleDialogues;
|
||||
}
|
||||
|
||||
public string sanitizeDialogueFromSpeechBubblesDictionary(string text)
|
||||
public static string sanitizeDialogueFromSpeechBubblesDictionary(string text)
|
||||
{
|
||||
if (text.Contains("{0}"))
|
||||
{
|
||||
|
@ -2790,7 +2790,7 @@ namespace Vocalization
|
|||
/// </summary>
|
||||
/// <param name="mailText"></param>
|
||||
/// <returns></returns>
|
||||
public string sanitizeDialogueFromMailDictionary(string mailText)
|
||||
public static string sanitizeDialogueFromMailDictionary(string mailText)
|
||||
{
|
||||
|
||||
List<string> texts = mailText.Split('%').ToList();
|
||||
|
|
Loading…
Reference in New Issue