Colored background menus for UIUtilities, and a fancier menu for Symphony.

This commit is contained in:
2018-03-30 05:46:24 -07:00
parent dad514a6d6
commit 6ef666af6e
14 changed files with 901 additions and 47 deletions

View File

@ -10,20 +10,50 @@ using StardustCore.UIUtilities;
using StardustCore.UIUtilities.MenuComponents;
using StardustCore.UIUtilities.MenuComponents.Delegates;
using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality;
using StardustCore.UIUtilities.SpriteFonts;
using StardustCore.UIUtilities.SpriteFonts.Components;
namespace StardewSymphonyRemastered.Framework.Menus
{
public class MusicManagerMenu : IClickableMenuExtended
{
public enum DrawMode
{
AlbumSelection,
SongSelection,
AlbumFancySelection,
}
public List<Button> musicAlbumButtons;
public MusicPack currentMusicPack;
public DrawMode drawMode;
public int currentAlbumIndex;
public List<Button> fancyButtons;
public int framesSinceLastUpdate;
public bool searchBoxSelected;
/// <summary>
/// Empty Constructor
/// </summary>
public MusicManagerMenu()
{
}
public MusicManagerMenu(float width, float height)
{
this.width = (int)width;
this.height = (int)height;
this.texturedStrings = new List<StardustCore.UIUtilities.SpriteFonts.Components.TexturedString>();
this.texturedStrings.Add(StardustCore.UIUtilities.SpriteFonts.SpriteFont.vanillaFont.ParseString("Hello", new Microsoft.Xna.Framework.Vector2(100, 100),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Blue)));
this.buttons = new List<StardustCore.UIUtilities.MenuComponents.Button>();
//this.buttons.Add(new Button("myButton", new Rectangle(100, 100, 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White,new ButtonFunctionality(new DelegatePairing(hello,null),null,null),false)); //A button that does nothing on the left click.
this.musicAlbumButtons = new List<StardustCore.UIUtilities.MenuComponents.Button>();
//thismusicAlbumButtons.Add(new Button("myButton", new Rectangle(100, 100, 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White,new ButtonFunctionality(new DelegatePairing(hello,null),null,null),false)); //A button that does nothing on the left click.
fancyButtons = new List<Button>();
int numOfButtons = 0;
int rows = 0;
@ -31,7 +61,10 @@ namespace StardewSymphonyRemastered.Framework.Menus
{
if (v.Value.musicPackInformation.Icon == null)
{
this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), StardewSymphony.textureManager.getTexture("MusicDisk"), "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.Colors.randomColor(), Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List<object>
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>
{
(object)v
}
@ -42,7 +75,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
else
{
this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List<object>
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>
{
(object)v
}
@ -59,19 +93,146 @@ namespace StardewSymphonyRemastered.Framework.Menus
rows++;
}
}
if (Game1.timeOfDay < 1200) this.dialogueBoxBackgroundColor = Color.SpringGreen;
if (Game1.timeOfDay >= 1200&& Game1.timeOfDay < 1800) this.dialogueBoxBackgroundColor = Color.White;
if (Game1.timeOfDay >= 1800) this.dialogueBoxBackgroundColor = Color.DarkViolet;
this.currentAlbumIndex = 0;
this.drawMode = DrawMode.AlbumFancySelection;
this.updateFancyButtons();
this.framesSinceLastUpdate = 0;
this.searchBoxSelected = false;
this.menuTextures = new List<Texture2DExtended>();
}
public override void update(GameTime time)
{
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))
{
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))
{
this.currentAlbumIndex++;
if (this.currentAlbumIndex == this.musicAlbumButtons.Count) this.currentAlbumIndex = 0;
this.updateFancyButtons();
this.framesSinceLastUpdate = 0;
Game1.playSound("shwip");
}
}
else
{
this.framesSinceLastUpdate++;
}
}
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)
{
for (int i = -3; i < 4; i++)
{
try
{
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)
{
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);
}
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++;
}
}
}
public override void receiveRightClick(int x, int y, bool playSound = true)
{
foreach (var v in this.buttons)
if (this.drawMode == DrawMode.AlbumSelection)
{
foreach (var v in this.musicAlbumButtons)
{
if (v.containsPoint(x, y)) v.onRightClick();
}
}
if (this.drawMode == DrawMode.AlbumFancySelection)
{
int count = 0;
foreach (var v in this.fancyButtons)
{
count++;
//if (v.containsPoint(x, y)) v.onRightClick();
//this.currentAlbumIndex += count;
//if (this.currentAlbumIndex >= this.musicAlbumButtons.Count) this.currentAlbumIndex -= this.musicAlbumButtons.Count;
//this.updateFancyButtons();
}
}
}
public override void performHoverAction(int x, int y)
{
foreach(var v in this.buttons)
if (this.drawMode == DrawMode.AlbumSelection)
{
foreach (var v in this.musicAlbumButtons)
{
if (v.containsPoint(x, y))
{
@ -87,32 +248,116 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
if (this.drawMode == DrawMode.AlbumFancySelection)
{
int count = 0;
foreach (var v in this.fancyButtons)
{
if (v.containsPoint(x, y))
{
if (v == null)
{
// StardewSymphony.ModMonitor.Log("v is null at count: " + count);
continue;
}
if (v.buttonFunctionality == null)
{
// StardewSymphony.ModMonitor.Log("button functionality is null at count: " + count);
continue;
}
if (v.buttonFunctionality.hover == null)
{
// StardewSymphony.ModMonitor.Log("hover is null at count: " + count);
continue;
}
if (v.buttonFunctionality.hover.paramaters == null)
{
// StardewSymphony.ModMonitor.Log("Params are null at count: " + count);
continue;
}
if (v.buttonFunctionality.hover.paramaters.Count==0)
{
//StardewSymphony.ModMonitor.Log("Params are 0 at count: " + count);
continue;
}
var pair = (KeyValuePair<string, MusicPack>)v.buttonFunctionality.hover.paramaters[0];
v.hoverText = (string)pair.Key;
//if (v.buttonFunctionality.hover != null) v.buttonFunctionality.hover.run();
//StardewSymphony.ModMonitor.Log(pair.Key);
v.onHover();
//StardewSymphony.ModMonitor.Log(pair.Key);
}
else
{
v.hoverText = "";
}
count++;
}
}
}
public override void receiveLeftClick(int x, int y, bool playSound = true)
{
foreach (var v in this.buttons)
if (this.drawMode == DrawMode.AlbumSelection) {
foreach (var v in this.musicAlbumButtons)
{
if (v.containsPoint(x, y)) v.onLeftClick();
}
}
public override void drawBackground(SpriteBatch b)
if (this.drawMode == DrawMode.AlbumFancySelection)
{
Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true);
int count = 0;
foreach (var v in this.fancyButtons)
{
if (v.containsPoint(x, y) && v.buttonFunctionality.leftClick != null)
{
v.onLeftClick();
this.currentAlbumIndex += count - 3;
//if (this.currentAlbumIndex >= this.musicAlbumButtons.Count) this.currentAlbumIndex -= (this.musicAlbumButtons.Count);
StardewSymphony.ModMonitor.Log(this.currentAlbumIndex.ToString());
}
if (v.buttonFunctionality.leftClick != null)
{
count++;
}
}
while(currentAlbumIndex < 0) {
this.currentAlbumIndex = (this.musicAlbumButtons.Count - (this.currentAlbumIndex*-1));
}
this.updateFancyButtons();
}
}
public override void draw(SpriteBatch b)
{
this.drawBackground(b);
foreach(var v in texturedStrings)
if (this.drawMode == DrawMode.AlbumSelection)
{
this.drawDialogueBoxBackground();
foreach (var v in this.musicAlbumButtons)
{
v.draw(b);
}
}
foreach (var v in buttons)
if (this.drawMode == DrawMode.AlbumFancySelection)
{
Vector4 placement = new Vector4(Game1.viewport.Width/4-50, Game1.viewport.Height/4, 8 * 100, 128*2);
this.drawDialogueBoxBackground((int)placement.X, (int)placement.Y, (int)placement.Z, (int)placement.W, new Color(new Vector4(this.dialogueBoxBackgroundColor.ToVector3(), 0)));
foreach(var v in fancyButtons)
{
v.draw(b);
}
foreach (var v in this.texturedStrings)
{
v.draw(b);
}
}
this.drawMouse(b);
}
@ -123,7 +368,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
StardewSymphony.ModMonitor.Log("Hello");
}
public void displayMusicPack(List<object> param)
public void PlayRandomSongFromSelectedMusicPack(List<object> param)
{
var info=(KeyValuePair<string, MusicPack>)param[0];
StardewSymphony.ModMonitor.Log(info.ToString());

View File

@ -246,8 +246,8 @@ namespace StardewSymphonyRemastered.Framework
{
if (Game1.weatherIcon == Game1.weather_sunny) return "sunny";
if (Game1.weatherIcon == Game1.weather_rain) return "rainy";
if (Game1.weatherIcon == Game1.weather_debris) return "debris";
if (Game1.weatherIcon == Game1.weather_lightning) return "lightning";
if (Game1.weatherIcon == Game1.weather_debris) return "lightning";
if (Game1.weatherIcon == Game1.weather_lightning) return "debris"; //????
if (Game1.weatherIcon == Game1.weather_festival) return "festival";
if (Game1.weatherIcon == Game1.weather_snow) return "snow";
if (Game1.weatherIcon == Game1.weather_wedding) return "wedding";

View File

@ -17,10 +17,9 @@ namespace StardewSymphonyRemastered
/// <summary>
/// BIG WIP. Don't use this at all because it does nothing right now.
/// TODO:
/// 1.Make Xwb packs work
/// 2.Make stream files work
/// -Make way to swap between album menu draw modes
/// -make a currently playing menu off to the side to tell you what song is playing from what album.
/// 3.Make interface.
/// 4.Make sure stuff doesn't blow up.
/// 5.Release
/// 6.Make videos documenting how to make this mod work.
/// 7.Make way to generate new music packs.
@ -133,9 +132,11 @@ namespace StardewSymphonyRemastered
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
string musicNote = Path.Combine(path, "MusicNote.png");
string musicCD = Path.Combine(path, "MusicDisk.png");
string outlineBox = Path.Combine(path, "OutlineBox.png");
textureManager.addTexture("MusicNote",new Texture2DExtended(ModHelper,StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicNote)));
textureManager.addTexture("MusicDisk", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicCD)));
textureManager.addTexture("MusicCD", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicCD)));
textureManager.addTexture("OutlineBox", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", outlineBox)));
if (!Directory.Exists(MusicPath)) Directory.CreateDirectory(MusicPath);
if (!Directory.Exists(WavMusicDirectory)) Directory.CreateDirectory(WavMusicDirectory);

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardustCore.Enums
{
public class Directions
{
public enum Direction
{
[Description("Up")]
up,
[Description("Right")]
right,
[Description("Down")]
down,
[Description("Left")]
left
}
public static Direction GetUp()
{
return Direction.up;
}
public static Direction GetDown()
{
return Direction.down;
}
public static Direction GetLeft()
{
return Direction.left;
}
public static Direction GetRight()
{
return Direction.right;
}
public static int DirectionToInt(Direction dir)
{
return (int)dir;
}
public static string getString(Direction dir)
{
return dir.GetEnumDescription();
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardustCore.Enums
{
public class Weather
{
public enum weather
{
sunny,
rainy,
lightning,
debris,
festival,
snow,
wedding
}
}
}

View File

@ -4,6 +4,7 @@ using StardewValley;
using StardewValley.Menus;
using StardustCore.ModInfo;
using StardustCore.Serialization;
using StardustCore.UIUtilities.SpriteFonts;
using System;
using System.Collections.Generic;
using System.IO;
@ -41,7 +42,7 @@ namespace StardustCore
IlluminateFramework.Colors.initializeColors();
ContentDirectory = Path.Combine(ModHelper.DirectoryPath, "Content");
if (!Directory.Exists(ContentDirectory)) Directory.CreateDirectory(ContentDirectory);
UIUtilities.SpriteFonts.SpriteFont.initialize();
SpriteFonts.initialize();
}

View File

@ -44,6 +44,8 @@
<ItemGroup>
<Compile Include="Animations\Animation.cs" />
<Compile Include="Animations\AnimationManager.cs" />
<Compile Include="Enums\Directions.cs" />
<Compile Include="Enums\Weather.cs" />
<Compile Include="IlluminateFramework\Colors.cs" />
<Compile Include="Math\Hex.cs" />
<Compile Include="Math\Hex32.cs" />

View File

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@ -27,5 +29,38 @@ namespace StardustCore
{
return !Double.IsNaN(value) && !Double.IsInfinity(value);
}
/// <summary>
/// Returns the description tag above an enum property to return a user friendly string.
/// Thanks again to Stack Overflow: https://stackoverflow.com/questions/479410/enum-tostring-with-user-friendly-strings
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerationValue"></param>
/// <returns></returns>
public static string GetEnumDescription<T>(this T enumerationValue)
where T : struct
{
Type type = enumerationValue.GetType();
if (!type.IsEnum)
{
throw new ArgumentException("EnumerationValue must be of Enum type", "enumerationValue");
}
//Tries to find a DescriptionAttribute for a potential friendly name
//for the enum
MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString());
if (memberInfo != null && memberInfo.Length > 0)
{
object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs != null && attrs.Length > 0)
{
//Pull out the description value
return ((DescriptionAttribute)attrs[0]).Description;
}
}
//If we have no description attribute, just return the ToString of the enum
return enumerationValue.ToString();
}
}
}

View File

@ -1,4 +1,7 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -10,10 +13,449 @@ namespace StardustCore.UIUtilities
{
public List<StardustCore.UIUtilities.SpriteFonts.Components.TexturedString> texturedStrings;
public List<StardustCore.UIUtilities.MenuComponents.Button> buttons;
public Color dialogueBoxBackgroundColor;
public List<Texture2DExtended> menuTextures;
public override void receiveRightClick(int x, int y, bool playSound = true)
{
}
/// <summary>
/// Draws a dialogue box background with the menu's position and dimentions as the paramaters for size and position.
/// </summary>
public virtual void drawDialogueBoxBackground()
{
if (this.dialogueBoxBackgroundColor == null) this.dialogueBoxBackgroundColor = Color.White;
this.drawDialogueBoxBackground(this.dialogueBoxBackgroundColor);
}
/// <summary>
/// Draws a dialogue box background.
/// </summary>
/// <param name="color"></param>
public virtual void drawDialogueBoxBackground(Color color)
{
this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, color);
}
/// <summary>
/// Draws a dialogue box background.
/// </summary>
/// <param name="xPosition"></param>
/// <param name="yPosition"></param>
/// <param name="width"></param>
/// <param name="height"></param>
public virtual void drawDialogueBoxBackground(int xPosition, int yPosition, int width, int height)
{
if (this.dialogueBoxBackgroundColor == null) this.dialogueBoxBackgroundColor = Color.White;
this.drawDialogueBoxBackground(xPosition, yPosition, width, height, false, true, this.dialogueBoxBackgroundColor);
}
/// <summary>
/// Draws a dialogue box backround.
/// </summary>
/// <param name="xPosition"></param>
/// <param name="yPosition"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="color"></param>
public virtual void drawDialogueBoxBackground(int xPosition, int yPosition, int width, int height, Color color)
{
this.drawDialogueBoxBackground(xPosition, yPosition, width, height, false, true, color);
}
/// <summary>
/// Draws the dialogue box background. Takes in a color.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="speaker"></param>
/// <param name="drawOnlyBox"></param>
/// <param name="color"></param>
/// <param name="message"></param>
/// <param name="objectDialogueWithPortrait"></param>
public virtual void drawDialogueBoxBackground(int x, int y, int width, int height, bool speaker, bool drawOnlyBox, Color color, string message = null, bool objectDialogueWithPortrait = false)
{
if (!drawOnlyBox)
return;
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);
if (!Game1.isQuestion && Game1.currentSpeaker == null && (Game1.currentObjectDialogue.Count > 0 && !drawOnlyBox))
{
width = (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).X + Game1.tileSize * 2;
height = (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y + Game1.tileSize;
x = width1 / 2 - width / 2;
num2 = height > Game1.tileSize * 4 ? -(height - Game1.tileSize * 4) : 0;
}
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;
if (!drawOnlyBox && Game1.currentObjectDialogue.Count > 0)
{
if ((double)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y >= (double)(height - Game1.tileSize * 2))
{
addedTileHeightForQuestions -= (int)(((double)(height - Game1.tileSize * 2) - (double)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y) / (double)Game1.tileSize) - 1;
}
else
{
height += (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y / 2;
num2 -= (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y / 2;
if ((int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y / 2 > Game1.tileSize)
addedTileHeightForQuestions = 0;
}
}
if (Game1.currentSpeaker != null && Game1.isQuestion && Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue().Substring(0, Game1.currentDialogueCharacterIndex).Contains(Environment.NewLine))
++addedTileHeightForQuestions;
rectangle1.Width = Game1.tileSize;
rectangle1.Height = Game1.tileSize;
rectangle1.X = Game1.tileSize;
rectangle1.Y = Game1.tileSize * 2;
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(28 + x + dialogueX, 28 + y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2, width - Game1.tileSize, height - Game1.tileSize + addedTileHeightForQuestions * Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = 0;
rectangle1.X = 0;
Game1.spriteBatch.Draw(Game1.menuTexture, new Vector2((float)(x + dialogueX), (float)(y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = Game1.tileSize * 3;
Game1.spriteBatch.Draw(Game1.menuTexture, new Vector2((float)(x + width + dialogueX - Game1.tileSize), (float)(y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = Game1.tileSize * 3;
Game1.spriteBatch.Draw(Game1.menuTexture, new Vector2((float)(x + width + dialogueX - Game1.tileSize), (float)(y + height + num1 - Game1.tileSize + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = 0;
Game1.spriteBatch.Draw(Game1.menuTexture, new Vector2((float)(x + dialogueX), (float)(y + height + num1 - Game1.tileSize + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = Game1.tileSize * 2;
rectangle1.Y = 0;
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(Game1.tileSize + x + dialogueX, y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2, width - Game1.tileSize * 2, Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = 3 * Game1.tileSize;
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(Game1.tileSize + x + dialogueX, y + height + num1 - Game1.tileSize + num2, width - Game1.tileSize * 2, Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1),color);
rectangle1.Y = Game1.tileSize * 2;
rectangle1.X = 0;
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(x + dialogueX, y - Game1.tileSize * addedTileHeightForQuestions + num1 + Game1.tileSize + num2, Game1.tileSize, height - Game1.tileSize * 2 + addedTileHeightForQuestions * Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = 3 * Game1.tileSize;
Game1.spriteBatch.Draw(Game1.menuTexture, new Microsoft.Xna.Framework.Rectangle(x + width + dialogueX - Game1.tileSize, y - Game1.tileSize * addedTileHeightForQuestions + num1 + Game1.tileSize + num2, Game1.tileSize, height - Game1.tileSize * 2 + addedTileHeightForQuestions * Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
if (objectDialogueWithPortrait && Game1.objectDialoguePortraitPerson != null || speaker && Game1.currentSpeaker != null && (Game1.currentSpeaker.CurrentDialogue.Count > 0 && Game1.currentSpeaker.CurrentDialogue.Peek().showPortrait))
{
Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 0, 64, 64);
NPC npc = objectDialogueWithPortrait ? Game1.objectDialoguePortraitPerson : Game1.currentSpeaker;
string s = objectDialogueWithPortrait ? (Game1.objectDialoguePortraitPerson.name.Equals(Game1.player.spouse) ? "$l" : "$neutral") : npc.CurrentDialogue.Peek().CurrentEmotion;
switch (s)
{
case "$a":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(64, 128, 64, 64);
break;
case "$u":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(64, 64, 64, 64);
break;
case "$s":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 64, 64, 64);
break;
case "$h":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(64, 0, 64, 64);
break;
case "$l":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 128, 64, 64);
break;
default:
rectangle2 = (s == "$k" || s == "$neutral" ? new Microsoft.Xna.Framework.Rectangle(0, 0, 64, 64) : Game1.getSourceRectForStandardTileSheet(npc.Portrait, Convert.ToInt32(npc.CurrentDialogue.Peek().CurrentEmotion.Substring(1)), -1, -1));
break;
}
Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
if (npc.Portrait != null)
{
Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(dialogueX + x + Game1.tileSize * 12), (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions - 256 + num1 + Game1.tileSize / 4 - 60 + num2)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(333, 305, 80, 87)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.98f);
Game1.spriteBatch.Draw(npc.Portrait, new Vector2((float)(dialogueX + x + Game1.tileSize * 12 + 32), (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions - 256 + num1 + Game1.tileSize / 4 - 60 + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle2), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.99f);
}
Game1.spriteBatch.End();
Game1.spriteBatch.Begin();
if (Game1.isQuestion)
Game1.spriteBatch.DrawString(Game1.dialogueFont, npc.displayName, new Vector2((float)(Game1.tileSize * 14 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(npc.displayName).X / 2f + (float)dialogueX + (float)x, (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions) - Game1.dialogueFont.MeasureString(npc.displayName).Y + (float)num1 + (float)(Game1.tileSize / 3) + (float)num2) + new Vector2(2f, 2f), new Color(150, 150, 150));
Game1.spriteBatch.DrawString(Game1.dialogueFont, npc.name.Equals("DwarfKing") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3754") : (npc.name.Equals("Lewis") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3756") : npc.displayName), new Vector2((float)(dialogueX + x + Game1.tileSize * 14 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(npc.name.Equals("Lewis") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3756") : npc.displayName).X / 2f, (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions) - Game1.dialogueFont.MeasureString(npc.name.Equals("Lewis") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3756") : npc.displayName).Y + (float)num1 + (float)(Game1.tileSize / 3) + (float)(Game1.tileSize / 8) + (float)num2), Game1.textColor);
}
if (drawOnlyBox || Game1.nameSelectUp && (!Game1.messagePause || Game1.currentObjectDialogue == null))
return;
string text = "";
if (Game1.currentSpeaker != null && Game1.currentSpeaker.CurrentDialogue.Count > 0)
{
if (Game1.currentSpeaker.CurrentDialogue.Peek() == null || Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue().Length < Game1.currentDialogueCharacterIndex - 1)
{
Game1.dialogueUp = false;
Game1.currentDialogueCharacterIndex = 0;
Game1.playSound("dialogueCharacterClose");
Game1.player.forceCanMove();
return;
}
text = Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue().Substring(0, Game1.currentDialogueCharacterIndex);
}
else if (message != null)
text = message;
else if (Game1.currentObjectDialogue.Count > 0)
text = Game1.currentObjectDialogue.Peek().Length <= 1 ? "" : Game1.currentObjectDialogue.Peek().Substring(0, Game1.currentDialogueCharacterIndex);
Vector2 position = (double)Game1.dialogueFont.MeasureString(text).X <= (double)(width1 - Game1.tileSize * 4 - dialogueX) ? (Game1.currentSpeaker == null || Game1.currentSpeaker.CurrentDialogue.Count <= 0 ? (message == null ? (!Game1.isQuestion ? new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Count == 0 ? "" : Game1.currentObjectDialogue.Peek()).X / 2f + (float)dialogueX, (float)(y + Game1.pixelZoom + num2)) : new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Count == 0 ? "" : Game1.currentObjectDialogue.Peek()).X / 2f + (float)dialogueX, (float)(height1 - Game1.tileSize * addedTileHeightForQuestions - 4 * Game1.tileSize - (Game1.tileSize / 4 + (Game1.questionChoices.Count - 2) * Game1.tileSize) + num1 + num2))) : new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(text).X / 2f + (float)dialogueX, (float)(y + Game1.tileSize * 3 / 2 + Game1.pixelZoom))) : new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue()).X / 2f + (float)dialogueX, (float)(height1 - Game1.tileSize * addedTileHeightForQuestions - 4 * Game1.tileSize - Game1.tileSize / 4 + num1 + num2))) : new Vector2((float)(Game1.tileSize * 2 + dialogueX), (float)(height1 - Game1.tileSize * addedTileHeightForQuestions - 4 * Game1.tileSize - Game1.tileSize / 4 + num1 + num2));
if (!drawOnlyBox)
{
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position + new Vector2(3f, 0.0f), Game1.textShadowColor);
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position + new Vector2(3f, 3f), Game1.textShadowColor);
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position + new Vector2(0.0f, 3f), Game1.textShadowColor);
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position, Game1.textColor);
}
if ((double)Game1.dialogueFont.MeasureString(text).Y <= (double)Game1.tileSize)
num1 += Game1.tileSize;
if (Game1.isQuestion && !Game1.dialogueTyping)
{
for (int index = 0; index < Game1.questionChoices.Count; ++index)
{
if (Game1.currentQuestionChoice == index)
{
position.X = (float)(Game1.tileSize * 5 / 4 + dialogueX + x);
position.Y = (float)(height1 - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + (text.Trim().Length > 0 ? Game1.dialogueFont.MeasureString(text).Y : 0.0f) + (float)(Game1.tileSize * 2) + (float)((Game1.tileSize / 2 + Game1.tileSize / 4) * index) - (float)(Game1.tileSize / 4 + (Game1.questionChoices.Count - 2) * Game1.tileSize) + (float)num1 + (float)num2;
Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
Game1.spriteBatch.Draw(Game1.objectSpriteSheet, position + new Vector2((float)Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) * 3f, 0.0f), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(26)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
Game1.spriteBatch.End();
Game1.spriteBatch.Begin();
position.X = (float)(Game1.tileSize * 5 / 2 + dialogueX + x);
position.Y = (float)(height1 - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + (text.Trim().Length > 1 ? Game1.dialogueFont.MeasureString(text).Y : 0.0f) + (float)(Game1.tileSize * 3 / 2 + Game1.tileSize / 2) - (float)((Game1.questionChoices.Count - 2) * Game1.tileSize) + (float)((Game1.tileSize / 2 + Game1.tileSize / 4) * index) + (float)num1 + (float)num2;
Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.questionChoices[index].responseText, position, Game1.textColor);
}
else
{
position.X = (float)(Game1.tileSize * 2 + dialogueX + x);
position.Y = (float)(height1 - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + (text.Trim().Length > 1 ? Game1.dialogueFont.MeasureString(text).Y : 0.0f) + (float)(Game1.tileSize * 3 / 2 + Game1.tileSize / 2) - (float)((Game1.questionChoices.Count - 2) * Game1.tileSize) + (float)((Game1.tileSize / 2 + Game1.tileSize / 4) * index) + (float)num1 + (float)num2;
Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.questionChoices[index].responseText, position, Game1.unselectedOptionColor);
}
}
}
else if (Game1.numberOfSelectedItems != -1 && !Game1.dialogueTyping)
this.drawItemSelectDialogue(x, y, dialogueX, num1 + num2, height1, addedTileHeightForQuestions, text);
if (drawOnlyBox || Game1.dialogueTyping || message != null)
return;
Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x + dialogueX + width - Game1.tileSize * 3 / 2), (float)(y + height + num1 + num2 - Game1.tileSize * 3 / 2) - Game1.dialogueButtonScale), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, Game1.dialogueButtonShrinking || (double)Game1.dialogueButtonScale >= (double)(Game1.tileSize / 8) ? 2 : 3, -1, -1)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.9999999f);
}
/// <summary>
/// Draws the dialogue box background. Takes in a color.
/// </summary>
/// <param name="texture">A custom menu texture to use.</param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="speaker"></param>
/// <param name="drawOnlyBox"></param>
/// <param name="color"></param>
/// <param name="message"></param>
/// <param name="objectDialogueWithPortrait"></param>
public virtual void drawDialogueBoxBackground(Texture2DExtended texture,int x, int y, int width, int height, bool speaker, bool drawOnlyBox, Color color, string message = null, bool objectDialogueWithPortrait = false)
{
if (!drawOnlyBox)
return;
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);
if (!Game1.isQuestion && Game1.currentSpeaker == null && (Game1.currentObjectDialogue.Count > 0 && !drawOnlyBox))
{
width = (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).X + Game1.tileSize * 2;
height = (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y + Game1.tileSize;
x = width1 / 2 - width / 2;
num2 = height > Game1.tileSize * 4 ? -(height - Game1.tileSize * 4) : 0;
}
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;
if (!drawOnlyBox && Game1.currentObjectDialogue.Count > 0)
{
if ((double)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y >= (double)(height - Game1.tileSize * 2))
{
addedTileHeightForQuestions -= (int)(((double)(height - Game1.tileSize * 2) - (double)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y) / (double)Game1.tileSize) - 1;
}
else
{
height += (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y / 2;
num2 -= (int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y / 2;
if ((int)Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Peek()).Y / 2 > Game1.tileSize)
addedTileHeightForQuestions = 0;
}
}
if (Game1.currentSpeaker != null && Game1.isQuestion && Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue().Substring(0, Game1.currentDialogueCharacterIndex).Contains(Environment.NewLine))
++addedTileHeightForQuestions;
rectangle1.Width = Game1.tileSize;
rectangle1.Height = Game1.tileSize;
rectangle1.X = Game1.tileSize;
rectangle1.Y = Game1.tileSize * 2;
Game1.spriteBatch.Draw(texture.texture, new Microsoft.Xna.Framework.Rectangle(28 + x + dialogueX, 28 + y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2, width - Game1.tileSize, height - Game1.tileSize + addedTileHeightForQuestions * Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = 0;
rectangle1.X = 0;
Game1.spriteBatch.Draw(texture.texture, new Vector2((float)(x + dialogueX), (float)(y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = Game1.tileSize * 3;
Game1.spriteBatch.Draw(texture.texture, new Vector2((float)(x + width + dialogueX - Game1.tileSize), (float)(y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = Game1.tileSize * 3;
Game1.spriteBatch.Draw(texture.texture, new Vector2((float)(x + width + dialogueX - Game1.tileSize), (float)(y + height + num1 - Game1.tileSize + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = 0;
Game1.spriteBatch.Draw(texture.texture, new Vector2((float)(x + dialogueX), (float)(y + height + num1 - Game1.tileSize + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = Game1.tileSize * 2;
rectangle1.Y = 0;
Game1.spriteBatch.Draw(texture.texture, new Microsoft.Xna.Framework.Rectangle(Game1.tileSize + x + dialogueX, y - Game1.tileSize * addedTileHeightForQuestions + num1 + num2, width - Game1.tileSize * 2, Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = 3 * Game1.tileSize;
Game1.spriteBatch.Draw(texture.texture, new Microsoft.Xna.Framework.Rectangle(Game1.tileSize + x + dialogueX, y + height + num1 - Game1.tileSize + num2, width - Game1.tileSize * 2, Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.Y = Game1.tileSize * 2;
rectangle1.X = 0;
Game1.spriteBatch.Draw(texture.texture, new Microsoft.Xna.Framework.Rectangle(x + dialogueX, y - Game1.tileSize * addedTileHeightForQuestions + num1 + Game1.tileSize + num2, Game1.tileSize, height - Game1.tileSize * 2 + addedTileHeightForQuestions * Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
rectangle1.X = 3 * Game1.tileSize;
Game1.spriteBatch.Draw(texture.texture, new Microsoft.Xna.Framework.Rectangle(x + width + dialogueX - Game1.tileSize, y - Game1.tileSize * addedTileHeightForQuestions + num1 + Game1.tileSize + num2, Game1.tileSize, height - Game1.tileSize * 2 + addedTileHeightForQuestions * Game1.tileSize), new Microsoft.Xna.Framework.Rectangle?(rectangle1), color);
if (objectDialogueWithPortrait && Game1.objectDialoguePortraitPerson != null || speaker && Game1.currentSpeaker != null && (Game1.currentSpeaker.CurrentDialogue.Count > 0 && Game1.currentSpeaker.CurrentDialogue.Peek().showPortrait))
{
Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 0, 64, 64);
NPC npc = objectDialogueWithPortrait ? Game1.objectDialoguePortraitPerson : Game1.currentSpeaker;
string s = objectDialogueWithPortrait ? (Game1.objectDialoguePortraitPerson.name.Equals(Game1.player.spouse) ? "$l" : "$neutral") : npc.CurrentDialogue.Peek().CurrentEmotion;
switch (s)
{
case "$a":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(64, 128, 64, 64);
break;
case "$u":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(64, 64, 64, 64);
break;
case "$s":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 64, 64, 64);
break;
case "$h":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(64, 0, 64, 64);
break;
case "$l":
rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 128, 64, 64);
break;
default:
rectangle2 = (s == "$k" || s == "$neutral" ? new Microsoft.Xna.Framework.Rectangle(0, 0, 64, 64) : Game1.getSourceRectForStandardTileSheet(npc.Portrait, Convert.ToInt32(npc.CurrentDialogue.Peek().CurrentEmotion.Substring(1)), -1, -1));
break;
}
Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
if (npc.Portrait != null)
{
Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(dialogueX + x + Game1.tileSize * 12), (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions - 256 + num1 + Game1.tileSize / 4 - 60 + num2)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(333, 305, 80, 87)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.98f);
Game1.spriteBatch.Draw(npc.Portrait, new Vector2((float)(dialogueX + x + Game1.tileSize * 12 + 32), (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions - 256 + num1 + Game1.tileSize / 4 - 60 + num2)), new Microsoft.Xna.Framework.Rectangle?(rectangle2), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.99f);
}
Game1.spriteBatch.End();
Game1.spriteBatch.Begin();
if (Game1.isQuestion)
Game1.spriteBatch.DrawString(Game1.dialogueFont, npc.displayName, new Vector2((float)(Game1.tileSize * 14 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(npc.displayName).X / 2f + (float)dialogueX + (float)x, (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions) - Game1.dialogueFont.MeasureString(npc.displayName).Y + (float)num1 + (float)(Game1.tileSize / 3) + (float)num2) + new Vector2(2f, 2f), new Color(150, 150, 150));
Game1.spriteBatch.DrawString(Game1.dialogueFont, npc.name.Equals("DwarfKing") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3754") : (npc.name.Equals("Lewis") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3756") : npc.displayName), new Vector2((float)(dialogueX + x + Game1.tileSize * 14 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(npc.name.Equals("Lewis") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3756") : npc.displayName).X / 2f, (float)(height1 - 5 * Game1.tileSize - Game1.tileSize * addedTileHeightForQuestions) - Game1.dialogueFont.MeasureString(npc.name.Equals("Lewis") ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3756") : npc.displayName).Y + (float)num1 + (float)(Game1.tileSize / 3) + (float)(Game1.tileSize / 8) + (float)num2), Game1.textColor);
}
if (drawOnlyBox || Game1.nameSelectUp && (!Game1.messagePause || Game1.currentObjectDialogue == null))
return;
string text = "";
if (Game1.currentSpeaker != null && Game1.currentSpeaker.CurrentDialogue.Count > 0)
{
if (Game1.currentSpeaker.CurrentDialogue.Peek() == null || Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue().Length < Game1.currentDialogueCharacterIndex - 1)
{
Game1.dialogueUp = false;
Game1.currentDialogueCharacterIndex = 0;
Game1.playSound("dialogueCharacterClose");
Game1.player.forceCanMove();
return;
}
text = Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue().Substring(0, Game1.currentDialogueCharacterIndex);
}
else if (message != null)
text = message;
else if (Game1.currentObjectDialogue.Count > 0)
text = Game1.currentObjectDialogue.Peek().Length <= 1 ? "" : Game1.currentObjectDialogue.Peek().Substring(0, Game1.currentDialogueCharacterIndex);
Vector2 position = (double)Game1.dialogueFont.MeasureString(text).X <= (double)(width1 - Game1.tileSize * 4 - dialogueX) ? (Game1.currentSpeaker == null || Game1.currentSpeaker.CurrentDialogue.Count <= 0 ? (message == null ? (!Game1.isQuestion ? new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Count == 0 ? "" : Game1.currentObjectDialogue.Peek()).X / 2f + (float)dialogueX, (float)(y + Game1.pixelZoom + num2)) : new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(Game1.currentObjectDialogue.Count == 0 ? "" : Game1.currentObjectDialogue.Peek()).X / 2f + (float)dialogueX, (float)(height1 - Game1.tileSize * addedTileHeightForQuestions - 4 * Game1.tileSize - (Game1.tileSize / 4 + (Game1.questionChoices.Count - 2) * Game1.tileSize) + num1 + num2))) : new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(text).X / 2f + (float)dialogueX, (float)(y + Game1.tileSize * 3 / 2 + Game1.pixelZoom))) : new Vector2((float)(width1 / 2) - Game1.dialogueFont.MeasureString(Game1.currentSpeaker.CurrentDialogue.Peek().getCurrentDialogue()).X / 2f + (float)dialogueX, (float)(height1 - Game1.tileSize * addedTileHeightForQuestions - 4 * Game1.tileSize - Game1.tileSize / 4 + num1 + num2))) : new Vector2((float)(Game1.tileSize * 2 + dialogueX), (float)(height1 - Game1.tileSize * addedTileHeightForQuestions - 4 * Game1.tileSize - Game1.tileSize / 4 + num1 + num2));
if (!drawOnlyBox)
{
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position + new Vector2(3f, 0.0f), Game1.textShadowColor);
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position + new Vector2(3f, 3f), Game1.textShadowColor);
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position + new Vector2(0.0f, 3f), Game1.textShadowColor);
Game1.spriteBatch.DrawString(Game1.dialogueFont, text, position, Game1.textColor);
}
if ((double)Game1.dialogueFont.MeasureString(text).Y <= (double)Game1.tileSize)
num1 += Game1.tileSize;
if (Game1.isQuestion && !Game1.dialogueTyping)
{
for (int index = 0; index < Game1.questionChoices.Count; ++index)
{
if (Game1.currentQuestionChoice == index)
{
position.X = (float)(Game1.tileSize * 5 / 4 + dialogueX + x);
position.Y = (float)(height1 - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + (text.Trim().Length > 0 ? Game1.dialogueFont.MeasureString(text).Y : 0.0f) + (float)(Game1.tileSize * 2) + (float)((Game1.tileSize / 2 + Game1.tileSize / 4) * index) - (float)(Game1.tileSize / 4 + (Game1.questionChoices.Count - 2) * Game1.tileSize) + (float)num1 + (float)num2;
Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
Game1.spriteBatch.Draw(Game1.objectSpriteSheet, position + new Vector2((float)Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) * 3f, 0.0f), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(26)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
Game1.spriteBatch.End();
Game1.spriteBatch.Begin();
position.X = (float)(Game1.tileSize * 5 / 2 + dialogueX + x);
position.Y = (float)(height1 - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + (text.Trim().Length > 1 ? Game1.dialogueFont.MeasureString(text).Y : 0.0f) + (float)(Game1.tileSize * 3 / 2 + Game1.tileSize / 2) - (float)((Game1.questionChoices.Count - 2) * Game1.tileSize) + (float)((Game1.tileSize / 2 + Game1.tileSize / 4) * index) + (float)num1 + (float)num2;
Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.questionChoices[index].responseText, position, Game1.textColor);
}
else
{
position.X = (float)(Game1.tileSize * 2 + dialogueX + x);
position.Y = (float)(height1 - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + (text.Trim().Length > 1 ? Game1.dialogueFont.MeasureString(text).Y : 0.0f) + (float)(Game1.tileSize * 3 / 2 + Game1.tileSize / 2) - (float)((Game1.questionChoices.Count - 2) * Game1.tileSize) + (float)((Game1.tileSize / 2 + Game1.tileSize / 4) * index) + (float)num1 + (float)num2;
Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.questionChoices[index].responseText, position, Game1.unselectedOptionColor);
}
}
}
else if (Game1.numberOfSelectedItems != -1 && !Game1.dialogueTyping)
this.drawItemSelectDialogue(x, y, dialogueX, num1 + num2, height1, addedTileHeightForQuestions, text);
if (drawOnlyBox || Game1.dialogueTyping || message != null)
return;
Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x + dialogueX + width - Game1.tileSize * 3 / 2), (float)(y + height + num1 + num2 - Game1.tileSize * 3 / 2) - Game1.dialogueButtonScale), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, Game1.dialogueButtonShrinking || (double)Game1.dialogueButtonScale >= (double)(Game1.tileSize / 8) ? 2 : 3, -1, -1)), color, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.9999999f);
}
/// <summary>
/// Work around drawing function instead of using Game1.drawItemSelectDialogue.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="dialogueX"></param>
/// <param name="dialogueY"></param>
/// <param name="screenHeight"></param>
/// <param name="addedTileHeightForQuestions"></param>
/// <param name="text"></param>
public virtual void drawItemSelectDialogue(int x, int y, int dialogueX, int dialogueY, int screenHeight, int addedTileHeightForQuestions, string text)
{
string selectedItemsType = Game1.selectedItemsType;
string text1;
if (!(selectedItemsType == "flutePitch") && !(selectedItemsType == "drumTome"))
{
if (selectedItemsType == "jukebox")
text1 = "@ " + Game1.player.songsHeard.ElementAt<string>(Game1.numberOfSelectedItems) + " > ";
else
text1 = "@ " + (object)Game1.numberOfSelectedItems + " > " + (object)(Game1.priceOfSelectedItem * Game1.numberOfSelectedItems) + "g";
}
else
text1 = "@ " + (object)Game1.numberOfSelectedItems + " > ";
if (Game1.currentLocation.Name.Equals("Club"))
text1 = "@ " + (object)Game1.numberOfSelectedItems + " > ";
Game1.spriteBatch.DrawString(Game1.dialogueFont, text1, new Vector2((float)(dialogueX + x + Game1.tileSize), (float)(screenHeight - (5 + addedTileHeightForQuestions + 1) * Game1.tileSize) + Game1.dialogueFont.MeasureString(text).Y + (float)(Game1.tileSize * 3 / 2 + Game1.tileSize / 8) + (float)dialogueY), Game1.textColor);
}
public override void update(GameTime time)
{
}
}
}

View File

@ -39,7 +39,7 @@ namespace StardustCore.UIUtilities.MenuComponents
{
this.textureColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
}
this.textColor = DrawColor;
this.textColor = TextColor;
if (this.textColor == null)
{
this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
@ -115,6 +115,10 @@ namespace StardustCore.UIUtilities.MenuComponents
}
/// <summary>
/// Draw the button.
/// </summary>
/// <param name="b"></param>
public new void draw(SpriteBatch b)
{
if (!this.visible)
@ -122,6 +126,18 @@ namespace StardustCore.UIUtilities.MenuComponents
this.draw(b, Color.White, (float)(0.860000014305115 + (double)this.bounds.Y / 20000.0));
}
/// <summary>
/// Draw the button.
/// </summary>
/// <param name="b"></param>
/// <param name="color"></param>
public virtual void draw(SpriteBatch b, Color color)
{
if (!this.visible)
return;
this.draw(b, color, (float)(0.860000014305115 + (double)this.bounds.Y / 20000.0));
}
/// <summary>
/// Swaps if the button is visible or not. Also toggles the animation manager appropriately.
/// </summary>
@ -134,7 +150,9 @@ namespace StardustCore.UIUtilities.MenuComponents
}
}
/// <summary>
/// The functionality that occurs when the button is clicked with the right mouse button.
/// </summary>
public void onRightClick()
{
if (this.buttonFunctionality == null) return;
@ -145,7 +163,10 @@ namespace StardustCore.UIUtilities.MenuComponents
}
}
public void onLeftClick()
/// <summary>
/// The functionality that occurs when the button is clicked with the left mouse button.
/// </summary>
public virtual void onLeftClick()
{
if (this.buttonFunctionality == null) return;
else
@ -155,7 +176,10 @@ namespace StardustCore.UIUtilities.MenuComponents
}
}
public void onHover()
/// <summary>
/// The functionality that occcurs when the button is hover overed.
/// </summary>
public virtual void onHover()
{
if (this.buttonFunctionality == null) return;
else
@ -164,5 +188,19 @@ namespace StardustCore.UIUtilities.MenuComponents
else this.buttonFunctionality.hover.run();
}
}
/// <summary>
/// Returns a new object based off of the data of this object.
/// </summary>
/// <returns></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);
if (b.buttonFunctionality.hover == null)
{
StardustCore.ModCore.ModMonitor.Log("I'm null!");
}
return b;
}
}
}

View File

@ -37,8 +37,8 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
{
c.position = new Vector2(this.position.X + c.spacing.LeftPadding + lastSeenChar.spacing.RightPadding+lastSeenChar.texture.Width*index, this.position.Y);
}
StardustCore.ModCore.ModMonitor.Log(c.character.ToString());
StardustCore.ModCore.ModMonitor.Log(c.position.ToString());
//StardustCore.ModCore.ModMonitor.Log(c.character.ToString());
//StardustCore.ModCore.ModMonitor.Log(c.position.ToString());
lastSeenChar = c;
index++;
}

View File

@ -17,7 +17,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
/// </summary>
public VanillaFont()
{
this.path = Path.Combine(StardustCore.UIUtilities.SpriteFonts.SpriteFont.FontDirectory, "Vanilla");
this.path = Path.Combine(SpriteFonts.FontDirectory, "Vanilla");
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
this.characterSheet = new VanillaCharacterSheet(path);
}
@ -27,7 +27,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public TexturedString voidParseString(string str)
public TexturedString ParseString(string str)
{
List<TexturedCharacter> characters=new List<TexturedCharacter>();
foreach(var chr in str)

View File

@ -11,7 +11,7 @@ namespace StardustCore.UIUtilities.SpriteFonts
/// <summary>
/// Manages Fonts for Stardust core. While all fonts variables can be accessed from their classes, they can also hold a reference here.
/// </summary>
public class SpriteFont
public class SpriteFonts
{
public static string FontDirectory;
@ -19,7 +19,6 @@ namespace StardustCore.UIUtilities.SpriteFonts
public static void initialize()
{
StardustCore.ModCore.ModMonitor.Log("HEY THERE!!");
FontDirectory = Path.Combine(StardustCore.ModCore.ContentDirectory, "Fonts");
if (!Directory.Exists(FontDirectory)) Directory.CreateDirectory(FontDirectory);
vanillaFont = new VanillaFont();

View File

@ -38,6 +38,19 @@ namespace StardustCore
return s.Remove(0, 1);
}
public static string getRelativeDiretory(IModHelper modHelper, string path)
{
string s = getShortenedDirectory(modHelper, path);
return s.Remove(0, 1);
}
public static string getShortenedDirectory(IModHelper modHelper, string path)
{
string lol = (string)path.Clone();
string[] spliter = lol.Split(new string[] { modHelper.DirectoryPath }, StringSplitOptions.None);
return spliter[1];
}
public static int sellToStorePrice(CoreObject c)
{
return (int)((double)c.price * (1.0 + (double)c.quality * 0.25));