2018-03-30 20:46:24 +08:00
using System ;
2018-03-06 12:46:45 +08:00
using System.Collections.Generic ;
using System.Linq ;
2018-12-30 18:00:05 +08:00
using Microsoft.Xna.Framework ;
using Microsoft.Xna.Framework.Graphics ;
using StardewValley ;
2019-07-25 05:16:04 +08:00
using StardustCore.UIUtilities.MenuComponents.ComponentsV1 ;
2018-03-06 12:46:45 +08:00
namespace StardustCore.UIUtilities
{
public class IClickableMenuExtended : StardewValley . Menus . IClickableMenu
{
2019-06-19 06:06:18 +08:00
/// <summary>
/// All stings to be displayed on this menu.
/// </summary>
2018-12-30 18:00:05 +08:00
public List < SpriteFonts . Components . TexturedString > texturedStrings ;
2019-06-19 06:06:18 +08:00
/// <summary>
/// All buttons belonging to this menu.
/// </summary>
2019-07-25 05:16:04 +08:00
public List < Button > buttons ;
2019-06-19 06:06:18 +08:00
/// <summary>
/// The background color of this menu.
/// </summary>
2018-03-30 20:46:24 +08:00
public Color dialogueBoxBackgroundColor ;
2019-06-19 06:06:18 +08:00
public Texture2D menuBackgroundTexture ;
/// <summary>
/// The textures used for this menu.
/// </summary>
2018-03-30 20:46:24 +08:00
public List < Texture2DExtended > menuTextures ;
2018-08-23 16:23:42 +08:00
public bool showRightCloseButton ;
2018-12-30 18:00:05 +08:00
public IClickableMenuExtended ( ) { }
2018-08-23 16:23:42 +08:00
2018-12-30 18:00:05 +08:00
public IClickableMenuExtended ( int x , int y , int width , int height , bool showCloseButton )
: base ( x , y , width , height , showCloseButton )
2018-08-23 16:23:42 +08:00
{
this . showRightCloseButton = showCloseButton ;
}
2019-06-19 06:06:18 +08:00
/// <summary>
/// Get a clone of this menu.
/// </summary>
/// <returns></returns>
2018-08-23 16:23:42 +08:00
public virtual IClickableMenuExtended clone ( )
{
2018-12-30 18:00:05 +08:00
return new IClickableMenuExtended ( this . xPositionOnScreen , this . yPositionOnScreen , this . width , this . height , this . showRightCloseButton ) ;
2018-08-23 16:23:42 +08:00
}
2018-12-30 18:00:05 +08:00
/// <summary>Draws a dialogue box background with the menu's position and dimentions as the paramaters for size and position.</summary>
2018-03-30 20:46:24 +08:00
public virtual void drawDialogueBoxBackground ( )
{
this . drawDialogueBoxBackground ( this . dialogueBoxBackgroundColor ) ;
}
2018-12-30 18:00:05 +08:00
/// <summary>Draws a dialogue box background.</summary>
2018-03-30 20:46:24 +08:00
public virtual void drawDialogueBoxBackground ( Color color )
{
this . drawDialogueBoxBackground ( this . xPositionOnScreen , this . yPositionOnScreen , this . width , this . height , color ) ;
}
2018-12-30 18:00:05 +08:00
/// <summary>Draws a dialogue box background.</summary>
2018-03-30 20:46:24 +08:00
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 ) ;
}
2018-12-30 18:00:05 +08:00
/// <summary>Draws a dialogue box background.</summary>
2018-03-30 20:46:24 +08:00
public virtual void drawDialogueBoxBackground ( int xPosition , int yPosition , int width , int height , Color color )
{
this . drawDialogueBoxBackground ( xPosition , yPosition , width , height , false , true , color ) ;
}
2018-08-25 16:57:10 +08:00
public virtual void drawOnlyDialogueBoxBackground ( int x , int y , int width , int height , Color color , float depth )
{
width = Math . Min ( Game1 . graphics . GraphicsDevice . Viewport . TitleSafeArea . Width , width ) ;
2018-12-30 18:00:05 +08:00
Rectangle rectangle1 = new Rectangle ( Game1 . tileSize , Game1 . tileSize * 2 , Game1 . tileSize , Game1 . tileSize ) ;
2018-08-25 16:57:10 +08:00
depth + = 0.001f ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x + Game1 . tileSize / 2 , y + Game1 . tileSize / 2 , width , height ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . Y = 0 ;
rectangle1 . X = 0 ;
depth + = 0.001f ;
//Draw the corners
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x , y , rectangle1 . Width , rectangle1 . Height ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . X = Game1 . tileSize * 3 ;
depth + = 0.001f ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( ( x + width ) , ( y ) , rectangle1 . Width , rectangle1 . Height ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . Y = Game1 . tileSize * 3 ;
depth + = 0.001f ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( ( x + width ) , ( y + height ) , rectangle1 . Width , rectangle1 . Height ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . X = 0 ;
depth + = 0.001f ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( ( x ) , ( y + height ) , rectangle1 . Width , rectangle1 . Height ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . X = Game1 . tileSize * 2 ;
rectangle1 . Y = 0 ;
depth + = 0.001f ;
//top
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x + Game1 . tileSize , y , width - Game1 . tileSize , Game1 . tileSize ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . Y = 3 * Game1 . tileSize ;
depth + = 0.001f ;
//bottom??
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( Game1 . tileSize + x , y + height , width - Game1 . tileSize , Game1 . tileSize ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . Y = Game1 . tileSize * 2 ;
rectangle1 . X = 0 ;
depth + = 0.001f ;
//left
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x , y + Game1 . tileSize , Game1 . tileSize , height - Game1 . tileSize ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
rectangle1 . X = 3 * Game1 . tileSize ;
depth + = 0.001f ;
//right
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x + width , y + Game1 . tileSize , Game1 . tileSize , height - Game1 . tileSize ) , rectangle1 , color , 0f , Vector2 . Zero , SpriteEffects . None , depth ) ;
2018-08-25 16:57:10 +08:00
}
2018-12-30 18:00:05 +08:00
/// <summary>Draws the dialogue box background. Takes in a color.</summary>
2018-03-30 20:46:24 +08:00
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 ;
}
2018-12-30 18:00:05 +08:00
Rectangle rectangle1 = new Rectangle ( 0 , 0 , Game1 . tileSize , Game1 . tileSize ) ;
2018-03-30 20:46:24 +08:00
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 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( 28 + x + dialogueX , 28 + y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 , width - Game1 . tileSize , height - Game1 . tileSize + addedTileHeightForQuestions * Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = 0 ;
rectangle1 . X = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Vector2 ( ( float ) ( x + dialogueX ) , ( float ) ( y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = Game1 . tileSize * 3 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Vector2 ( ( float ) ( x + width + dialogueX - Game1 . tileSize ) , ( float ) ( y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = Game1 . tileSize * 3 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Vector2 ( ( float ) ( x + width + dialogueX - Game1 . tileSize ) , ( float ) ( y + height + num1 - Game1 . tileSize + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Vector2 ( ( float ) ( x + dialogueX ) , ( float ) ( y + height + num1 - Game1 . tileSize + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = Game1 . tileSize * 2 ;
rectangle1 . Y = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( Game1 . tileSize + x + dialogueX , y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 , width - Game1 . tileSize * 2 , Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = 3 * Game1 . tileSize ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( Game1 . tileSize + x + dialogueX , y + height + num1 - Game1 . tileSize + num2 , width - Game1 . tileSize * 2 , Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = Game1 . tileSize * 2 ;
rectangle1 . X = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x + dialogueX , y - Game1 . tileSize * addedTileHeightForQuestions + num1 + Game1 . tileSize + num2 , Game1 . tileSize , height - Game1 . tileSize * 2 + addedTileHeightForQuestions * Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = 3 * Game1 . tileSize ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . menuTexture , new Rectangle ( x + width + dialogueX - Game1 . tileSize , y - Game1 . tileSize * addedTileHeightForQuestions + num1 + Game1 . tileSize + num2 , Game1 . tileSize , height - Game1 . tileSize * 2 + addedTileHeightForQuestions * Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
if ( objectDialogueWithPortrait & & Game1 . objectDialoguePortraitPerson ! = null | | speaker & & Game1 . currentSpeaker ! = null & & ( Game1 . currentSpeaker . CurrentDialogue . Count > 0 & & Game1 . currentSpeaker . CurrentDialogue . Peek ( ) . showPortrait ) )
{
2018-12-30 18:00:05 +08:00
Rectangle rectangle2 = new Rectangle ( 0 , 0 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
NPC npc = objectDialogueWithPortrait ? Game1 . objectDialoguePortraitPerson : Game1 . currentSpeaker ;
2018-05-01 09:21:31 +08:00
string s = objectDialogueWithPortrait ? ( Game1 . objectDialoguePortraitPerson . Name . Equals ( Game1 . player . spouse ) ? "$l" : "$neutral" ) : npc . CurrentDialogue . Peek ( ) . CurrentEmotion ;
2018-03-30 20:46:24 +08:00
switch ( s )
{
case "$a" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 64 , 128 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$u" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 64 , 64 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$s" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 0 , 64 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$h" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 64 , 0 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$l" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 0 , 128 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
default :
2018-12-30 18:00:05 +08:00
rectangle2 = ( s = = "$k" | | s = = "$neutral" ? new Rectangle ( 0 , 0 , 64 , 64 ) : Game1 . getSourceRectForStandardTileSheet ( npc . Portrait , Convert . ToInt32 ( npc . CurrentDialogue . Peek ( ) . CurrentEmotion . Substring ( 1 ) ) , - 1 , - 1 ) ) ;
2018-03-30 20:46:24 +08:00
break ;
}
Game1 . spriteBatch . End ( ) ;
Game1 . spriteBatch . Begin ( SpriteSortMode . Deferred , BlendState . NonPremultiplied , SamplerState . PointClamp , ( DepthStencilState ) null , ( RasterizerState ) null ) ;
if ( npc . Portrait ! = null )
{
2018-12-30 18:00:05 +08:00
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 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 ) ) , rectangle2 , Color . White , 0.0f , Vector2 . Zero , 4f , SpriteEffects . None , 0.99f ) ;
2018-03-30 20:46:24 +08:00
}
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 ) ) ;
2018-05-01 09:21:31 +08:00
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 ) ;
2018-03-30 20:46:24 +08:00
}
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 ) ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . objectSpriteSheet , position + new Vector2 ( ( float ) Math . Cos ( ( double ) Game1 . currentGameTime . TotalGameTime . Milliseconds * Math . PI / 512.0 ) * 3f , 0.0f ) , GameLocation . getSourceRectForObject ( 26 ) , Color . White , 0.0f , Vector2 . Zero , ( float ) Game1 . pixelZoom , SpriteEffects . None , 1f ) ;
2018-03-30 20:46:24 +08:00
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 ;
2018-12-30 18:00:05 +08:00
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 ) , 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 ) ;
2018-03-30 20:46:24 +08:00
}
2018-12-30 18:00:05 +08:00
/// <summary>Draws the dialogue box background. Takes in a color.</summary>
2018-03-30 20:46:24 +08:00
/// <param name="texture">A custom menu texture to use.</param>
2018-12-30 18:00:05 +08:00
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 )
2018-03-30 20:46:24 +08:00
{
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 ;
}
2018-12-30 18:00:05 +08:00
Rectangle rectangle1 = new Rectangle ( 0 , 0 , Game1 . tileSize , Game1 . tileSize ) ;
2018-03-30 20:46:24 +08:00
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 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Rectangle ( 28 + x + dialogueX , 28 + y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 , width - Game1 . tileSize , height - Game1 . tileSize + addedTileHeightForQuestions * Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = 0 ;
rectangle1 . X = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Vector2 ( ( float ) ( x + dialogueX ) , ( float ) ( y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = Game1 . tileSize * 3 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Vector2 ( ( float ) ( x + width + dialogueX - Game1 . tileSize ) , ( float ) ( y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = Game1 . tileSize * 3 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Vector2 ( ( float ) ( x + width + dialogueX - Game1 . tileSize ) , ( float ) ( y + height + num1 - Game1 . tileSize + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Vector2 ( ( float ) ( x + dialogueX ) , ( float ) ( y + height + num1 - Game1 . tileSize + num2 ) ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = Game1 . tileSize * 2 ;
rectangle1 . Y = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Rectangle ( Game1 . tileSize + x + dialogueX , y - Game1 . tileSize * addedTileHeightForQuestions + num1 + num2 , width - Game1 . tileSize * 2 , Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = 3 * Game1 . tileSize ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Rectangle ( Game1 . tileSize + x + dialogueX , y + height + num1 - Game1 . tileSize + num2 , width - Game1 . tileSize * 2 , Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . Y = Game1 . tileSize * 2 ;
rectangle1 . X = 0 ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Rectangle ( x + dialogueX , y - Game1 . tileSize * addedTileHeightForQuestions + num1 + Game1 . tileSize + num2 , Game1 . tileSize , height - Game1 . tileSize * 2 + addedTileHeightForQuestions * Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
rectangle1 . X = 3 * Game1 . tileSize ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( texture . getTexture ( ) , new Rectangle ( x + width + dialogueX - Game1 . tileSize , y - Game1 . tileSize * addedTileHeightForQuestions + num1 + Game1 . tileSize + num2 , Game1 . tileSize , height - Game1 . tileSize * 2 + addedTileHeightForQuestions * Game1 . tileSize ) , rectangle1 , color ) ;
2018-03-30 20:46:24 +08:00
if ( objectDialogueWithPortrait & & Game1 . objectDialoguePortraitPerson ! = null | | speaker & & Game1 . currentSpeaker ! = null & & ( Game1 . currentSpeaker . CurrentDialogue . Count > 0 & & Game1 . currentSpeaker . CurrentDialogue . Peek ( ) . showPortrait ) )
{
2018-12-30 18:00:05 +08:00
Rectangle rectangle2 = new Rectangle ( 0 , 0 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
NPC npc = objectDialogueWithPortrait ? Game1 . objectDialoguePortraitPerson : Game1 . currentSpeaker ;
2018-05-01 09:21:31 +08:00
string s = objectDialogueWithPortrait ? ( Game1 . objectDialoguePortraitPerson . Name . Equals ( Game1 . player . spouse ) ? "$l" : "$neutral" ) : npc . CurrentDialogue . Peek ( ) . CurrentEmotion ;
2018-03-30 20:46:24 +08:00
switch ( s )
{
case "$a" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 64 , 128 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$u" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 64 , 64 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$s" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 0 , 64 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$h" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 64 , 0 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
case "$l" :
2018-12-30 18:00:05 +08:00
rectangle2 = new Rectangle ( 0 , 128 , 64 , 64 ) ;
2018-03-30 20:46:24 +08:00
break ;
default :
2018-12-30 18:00:05 +08:00
rectangle2 = ( s = = "$k" | | s = = "$neutral" ? new Rectangle ( 0 , 0 , 64 , 64 ) : Game1 . getSourceRectForStandardTileSheet ( npc . Portrait , Convert . ToInt32 ( npc . CurrentDialogue . Peek ( ) . CurrentEmotion . Substring ( 1 ) ) , - 1 , - 1 ) ) ;
2018-03-30 20:46:24 +08:00
break ;
}
Game1 . spriteBatch . End ( ) ;
Game1 . spriteBatch . Begin ( SpriteSortMode . Deferred , BlendState . NonPremultiplied , SamplerState . PointClamp , ( DepthStencilState ) null , ( RasterizerState ) null ) ;
if ( npc . Portrait ! = null )
{
2018-12-30 18:00:05 +08:00
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 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 ) ) , rectangle2 , Color . White , 0.0f , Vector2 . Zero , 4f , SpriteEffects . None , 0.99f ) ;
2018-03-30 20:46:24 +08:00
}
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 ) ) ;
2018-05-01 09:21:31 +08:00
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 ) ;
2018-03-30 20:46:24 +08:00
}
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 ) ;
2018-12-30 18:00:05 +08:00
Game1 . spriteBatch . Draw ( Game1 . objectSpriteSheet , position + new Vector2 ( ( float ) Math . Cos ( ( double ) Game1 . currentGameTime . TotalGameTime . Milliseconds * Math . PI / 512.0 ) * 3f , 0.0f ) , GameLocation . getSourceRectForObject ( 26 ) , Color . White , 0.0f , Vector2 . Zero , ( float ) Game1 . pixelZoom , SpriteEffects . None , 1f ) ;
2018-03-30 20:46:24 +08:00
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 ;
2018-12-30 18:00:05 +08:00
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 ) , 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 ) ;
2018-03-30 20:46:24 +08:00
}
2018-12-30 18:00:05 +08:00
/// <summary>Work around drawing function instead of using Game1.drawItemSelectDialogue.</summary>
2018-03-30 20:46:24 +08:00
public virtual void drawItemSelectDialogue ( int x , int y , int dialogueX , int dialogueY , int screenHeight , int addedTileHeightForQuestions , string text )
{
string selectedItemsType = Game1 . selectedItemsType ;
string text1 ;
2018-12-30 18:00:05 +08:00
if ( selectedItemsType ! = "flutePitch" & & selectedItemsType ! = "drumTome" )
2018-03-30 20:46:24 +08:00
{
if ( selectedItemsType = = "jukebox" )
2018-12-30 18:00:05 +08:00
text1 = "@ " + Game1 . player . songsHeard . ElementAt ( Game1 . numberOfSelectedItems ) + " > " ;
2018-03-30 20:46:24 +08:00
else
2018-12-30 18:00:05 +08:00
text1 = "@ " + Game1 . numberOfSelectedItems + " > " + Game1 . priceOfSelectedItem * Game1 . numberOfSelectedItems + "g" ;
2018-03-30 20:46:24 +08:00
}
else
2018-12-30 18:00:05 +08:00
text1 = "@ " + Game1 . numberOfSelectedItems + " > " ;
2018-03-30 20:46:24 +08:00
if ( Game1 . currentLocation . Name . Equals ( "Club" ) )
2018-12-30 18:00:05 +08:00
text1 = "@ " + Game1 . numberOfSelectedItems + " > " ;
Game1 . spriteBatch . DrawString ( Game1 . dialogueFont , text1 , new Vector2 ( dialogueX + x + Game1 . tileSize , screenHeight - ( 5 + addedTileHeightForQuestions + 1 ) * Game1 . tileSize + Game1 . dialogueFont . MeasureString ( text ) . Y + ( Game1 . tileSize * 3 / 2 + Game1 . tileSize / 8 ) + dialogueY ) , Game1 . textColor ) ;
2018-03-30 20:46:24 +08:00
}
2018-12-30 18:00:05 +08:00
public override void update ( GameTime time ) { }
2019-06-19 06:06:18 +08:00
/// <summary>
/// Gets a relative position for teh component on the menu.
/// </summary>
/// <param name="relativeOffset">A vector representing a relative offset. (.1,.1) means the new position should be set 10% away from the left and 10% away from the top in respect to teh edges of the menu.</param>
/// <returns></returns>
public Vector2 getRelativePositionToMenu ( Vector2 relativeOffset )
{
return new Vector2 ( this . xPositionOnScreen + ( relativeOffset . X * this . width ) , this . yPositionOnScreen + ( relativeOffset . Y * this . height ) ) ;
}
public Vector2 getRelativePositionToMenu ( float relx , float rely )
{
return new Vector2 ( this . xPositionOnScreen + ( relx * this . width ) , this . yPositionOnScreen + ( rely * this . height ) ) ;
}
/// <summary>
/// Gets an absolute position away from the edge of the menu.
/// </summary>
/// <param name="relativeOffset"></param>
/// <returns></returns>
public Vector2 getFixedPositionFromMenu ( Vector2 relativeOffset )
{
return new Vector2 ( this . xPositionOnScreen + relativeOffset . X , this . yPositionOnScreen + relativeOffset . Y ) ;
}
/// <summary>
/// Gets an absolute position away from the edge of the menu.
/// </summary>
/// <param name="relx"></param>
/// <param name="rely"></param>
/// <returns></returns>
public Vector2 getFixedPositionFromMenu ( float relx , float rely )
{
return new Vector2 ( this . xPositionOnScreen + relx , this . yPositionOnScreen + rely ) ;
}
2019-07-19 08:16:17 +08:00
public virtual void exitMenu ( bool playSound = true )
{
//Do extra stuff here.
this . exitThisMenu ( playSound ) ;
}
2018-03-06 12:46:45 +08:00
}
}