Finished slider button, made a better menu background function, and made the slider button update the menu.

This commit is contained in:
2018-08-25 01:57:10 -07:00
parent b62a5eb076
commit a979ab479c
5 changed files with 83 additions and 12 deletions

View File

@ -84,6 +84,66 @@ namespace StardustCore.UIUtilities
this.drawDialogueBoxBackground(xPosition, yPosition, width, height, false, true, color); this.drawDialogueBoxBackground(xPosition, yPosition, width, height, false, true, color);
} }
public virtual void drawOnlyDialogueBoxBackground(int x, int y, int width, int height, Color color, float depth)
{
int height1 = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Height;
int width1 = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Width;
int dialogueX = 0;
int num1 = y > Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Y ? 0 : Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Y;
int num2 = 0;
width = Math.Min(Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Width, width);
Microsoft.Xna.Framework.Rectangle rectangle1 = new Microsoft.Xna.Framework.Rectangle(0, 0, Game1.tileSize, Game1.tileSize);
int addedTileHeightForQuestions = -1;
if (Game1.questionChoices.Count >= 3)
addedTileHeightForQuestions = Game1.questionChoices.Count - 3;
rectangle1.Width = Game1.tileSize;
rectangle1.Height = Game1.tileSize;
rectangle1.X = Game1.tileSize;
rectangle1.Y = Game1.tileSize * 2;
depth += 0.001f;
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(x+Game1.tileSize/2,y+Game1.tileSize/2,width, height), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color,0f,Vector2.Zero,SpriteEffects.None,depth);
rectangle1.Y = 0;
rectangle1.X = 0;
depth += 0.001f;
//Draw the corners
Game1.spriteBatch.Draw(Game1.menuTexture, new Rectangle((x), (y),rectangle1.Width,rectangle1.Height), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.X = Game1.tileSize * 3;
depth += 0.001f;
Game1.spriteBatch.Draw(Game1.menuTexture, new Rectangle((x + width), (y),rectangle1.Width,rectangle1.Height), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.Y = Game1.tileSize * 3;
depth += 0.001f;
Game1.spriteBatch.Draw(Game1.menuTexture, new Rectangle((x + width), (y + height),rectangle1.Width,rectangle1.Height), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.X = 0;
depth += 0.001f;
Game1.spriteBatch.Draw(Game1.menuTexture, new Rectangle((x), (y + height),rectangle1.Width,rectangle1.Height), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.X = Game1.tileSize * 2;
rectangle1.Y = 0;
depth += 0.001f;
//top
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(x+Game1.tileSize, y, width-Game1.tileSize, Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.Y = 3 * Game1.tileSize;
depth += 0.001f;
//bottom??
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(Game1.tileSize + x, y + height,width-Game1.tileSize, Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.Y = Game1.tileSize * 2;
rectangle1.X = 0;
depth += 0.001f;
//left
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(x, y+Game1.tileSize, Game1.tileSize,height-Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
rectangle1.X = 3 * Game1.tileSize;
depth += 0.001f;
//right
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(x + width, y+Game1.tileSize ,Game1.tileSize, height-Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color, 0f, Vector2.Zero, SpriteEffects.None, depth);
}
/// <summary> /// <summary>
/// Draws the dialogue box background. Takes in a color. /// Draws the dialogue box background. Takes in a color.
/// </summary> /// </summary>

View File

@ -446,7 +446,7 @@ namespace StardustCore.UIUtilities.MenuComponents
//Draw the slider bar. //Draw the slider bar.
sliderBar.draw(b, color, offset, layerDepth); sliderBar.draw(b, color, offset, layerDepth);
//b.Draw(this..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(this..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(this.animationManager.getTexture(), new Vector2(this.bounds.X + (int)offset.X, this.bounds.Y), this.sourceRect, color, 0f, Vector2.Zero, this.scale, SpriteEffects.None, layerDepth); b.Draw(this.animationManager.getTexture(), new Vector2(this.bounds.X + (int)offset.X, this.bounds.Y), this.sourceRect, color, 0f, Vector2.Zero, this.scale, SpriteEffects.None, layerDepth+0.01f);
if (this.extraTextures != null) if (this.extraTextures != null)
{ {
@ -462,7 +462,7 @@ namespace StardustCore.UIUtilities.MenuComponents
if (string.IsNullOrEmpty(this.label)) if (string.IsNullOrEmpty(this.label))
return; return;
b.DrawString(Game1.smallFont, this.label+this.sliderInformation.getLabelInformation(this.getLabelXYPos), new Vector2((float)((this.bounds.X + this.bounds.Width+offset.X)*this.scale), (float)this.bounds.Y + ((float)(this.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)+offset.X+this.sliderInformation.yPos), textColor); b.DrawString(Game1.smallFont, this.label+this.sliderInformation.getLabelInformation(this.getLabelXYPos), new Vector2((float)((sliderBar.bounds.X + sliderBar.bounds.Width+offset.X+this.bounds.Width)), (float)sliderBar.bounds.Y + ((float)(sliderBar.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)+offset.X), textColor,0f,Vector2.Zero,1f,SpriteEffects.None,layerDepth+0.02f);
} }

View File

@ -33,7 +33,7 @@ namespace Vocalization.Framework.Menus
Button bar = new Button(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 200, 40), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png")),new Rectangle(0,0,100,10),2f); Button bar = new Button(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 200, 40), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png")),new Rectangle(0,0,100,10),2f);
//Texture2DExtended barTexture = new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png")); //Texture2DExtended barTexture = new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png"));
Rectangle sourceRect = new Rectangle(0, 0, 4, 16); 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, 100, 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true); 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);
} }
@ -57,12 +57,23 @@ namespace Vocalization.Framework.Menus
public override void draw(SpriteBatch b) public override void draw(SpriteBatch b)
{ {
//INCLUDE A COLOR FOR THE MENU!!!!! this.drawOnlyDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, new Color(255, 255, 255, 255),0.4f);
this.drawDialogueBoxBackground(this.xPositionOnScreen,this.yPositionOnScreen,this.width,this.height);
sliderButton.draw(b,Color.White,Vector2.Zero,0.5f); sliderButton.draw(b,Color.White,Vector2.Zero,0.5f);
}
Vocalization.ModMonitor.Log(this.xPositionOnScreen.ToString()+" "+this.yPositionOnScreen.ToString()); /// <summary>
/// Save the menu information upon menu being closed.
/// </summary>
/// <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;
return true;
} }

View File

@ -31,7 +31,7 @@ namespace Vocalization
/// <summary> /// <summary>
/// The volume at which the sound for voices is played at. /// The volume at which the sound for voices is played at.
/// </summary> /// </summary>
public float voiceVolume; public decimal voiceVolume;
public ModConfig() public ModConfig()
{ {
@ -46,7 +46,7 @@ namespace Vocalization
translationInfo = new TranslationInfo(); translationInfo = new TranslationInfo();
this.voiceVolume = 1.0f; this.voiceVolume = (decimal)1.0f;
} }
/// <summary> /// <summary>

View File

@ -212,7 +212,7 @@ namespace Vocalization
config = ModHelper.ReadConfig<ModConfig>(); config = ModHelper.ReadConfig<ModConfig>();
config.verifyValidMode(); //Make sure the current mode is valid. config.verifyValidMode(); //Make sure the current mode is valid.
soundManager.volume = config.voiceVolume; //Set the volume for voices. soundManager.volume = (float)config.voiceVolume; //Set the volume for voices.
} }
@ -287,7 +287,7 @@ namespace Vocalization
//Change this to take the vocalization menu instead //Change this to take the vocalization menu instead
List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>(); List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>();
modTabs.Add(new KeyValuePair<Button, IClickableMenuExtended>(menuTab, new VocalizationMenu(100,100,300,300,true))); modTabs.Add(new KeyValuePair<Button, IClickableMenuExtended>(menuTab, new VocalizationMenu(100,64,600,300,true)));
StardustCore.Menus.ModularGameMenu.AddTabsForMod(ModManifest,modTabs); StardustCore.Menus.ModularGameMenu.AddTabsForMod(ModManifest,modTabs);
ModMonitor.Log("VOCALIZATION MENU HACK COMPLETE!", LogLevel.Alert); ModMonitor.Log("VOCALIZATION MENU HACK COMPLETE!", LogLevel.Alert);
@ -325,7 +325,7 @@ namespace Vocalization
//Change this to take the vocalization menu instead //Change this to take the vocalization menu instead
List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>(); List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>();
modTabs.Add(new KeyValuePair<Button, IClickableMenuExtended>(menuTab, new VocalizationMenu(100, 100, 300, 300,true))); modTabs.Add(new KeyValuePair<Button, IClickableMenuExtended>(menuTab, new VocalizationMenu(100, 64, 600, 300,true)));
StardustCore.Menus.ModularGameMenu.StaticMenuTabsAndPages[ModManifest.UniqueID] = modTabs; StardustCore.Menus.ModularGameMenu.StaticMenuTabsAndPages[ModManifest.UniqueID] = modTabs;
} }