2022-03-06 20:20:45 +01:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
using FDK ;
using System.Drawing ;
2022-03-07 16:05:35 +01:00
using static TJAPlayer3 . CActSelect曲リスト ;
2022-03-06 20:20:45 +01:00
namespace TJAPlayer3
{
internal class Modal
{
2022-03-07 10:55:49 +01:00
public Modal ( EModalType mt , int ra , int re )
2022-03-06 20:20:45 +01:00
{
modalType = mt ;
rarity = ra ;
reference = re ;
2022-03-07 10:55:49 +01:00
_isSet = false ;
2022-03-06 20:20:45 +01:00
}
2022-03-07 10:55:49 +01:00
public void tSetupModal ( )
2022-03-06 20:20:45 +01:00
{
CTexture [ ] arrRef ;
if ( modalFormat = = EModalFormat . Half )
arrRef = TJAPlayer3 . Tx . Modal_Half ;
2023-02-15 01:27:05 +01:00
else if ( modalFormat = = EModalFormat . Half_4P )
arrRef = TJAPlayer3 . Tx . Modal_Half_4P ;
else if ( modalFormat = = EModalFormat . Half_5P )
arrRef = TJAPlayer3 . Tx . Modal_Half_5P ;
2022-03-06 20:20:45 +01:00
else
arrRef = TJAPlayer3 . Tx . Modal_Full ;
if ( modalType = = EModalType . Coin )
_box = arrRef [ arrRef . Length - 1 ] ;
else
{
int usedTex = Math . Max ( 0 , Math . Min ( arrRef . Length - 2 , rarity ) ) ;
_box = arrRef [ usedTex ] ;
}
2023-02-15 01:27:05 +01:00
/ *
2022-03-06 20:20:45 +01:00
_boxRect = new Rectangle (
( modalFormat = = EModalFormat . Full | | player = = 0 )
? 0
2023-02-04 07:47:55 +01:00
: _box . szテクスチャサイズ . Width / 2 ,
2022-03-06 20:20:45 +01:00
0 ,
( modalFormat = = EModalFormat . Full )
2023-02-04 07:47:55 +01:00
? _box . szテクスチャサイズ . Width
: _box . szテクスチャサイズ . Width / 2 ,
_box . szテクスチャサイズ . Height ) ;
2023-02-15 01:27:05 +01:00
* /
_boxRect = new Rectangle (
( modalFormat = = EModalFormat . Full | | player = = 0 ) ? 0 : _box . szテクスチャサイズ . Width / 2 ,
0 ,
( modalFormat = = EModalFormat . Full ) ? _box . szテクスチャサイズ . Width : _box . szテクスチャサイズ . Width / 2 ,
_box . szテクスチャサイズ . Height / ( ( ( TJAPlayer3 . ConfigIni . nPlayerCount - 1 ) / 2 ) + 1 ) ) ;
2022-03-07 10:55:49 +01:00
2022-03-07 16:05:35 +01:00
tGenerateTextures ( ) ;
2022-03-07 10:55:49 +01:00
_isSet = true ;
2022-03-06 20:20:45 +01:00
}
public void tDisplayModal ( )
{
2022-03-07 10:55:49 +01:00
if ( _isSet = = true )
{
2023-02-15 01:27:05 +01:00
_box ? . t2D描画 ( TJAPlayer3 . app . Device , _boxRect . Width * ( player % 2 ) , _boxRect . Height * ( player / 2 ) , _boxRect ) ;
int [ ] title_x ;
int [ ] title_y ;
int [ ] text_x ;
int [ ] text_y ;
int moveX ;
int moveY ;
if ( modalFormat = = EModalFormat . Full )
{
title_x = new int [ ] { TJAPlayer3 . Skin . Modal_Title_Full [ 0 ] } ;
title_y = new int [ ] { TJAPlayer3 . Skin . Modal_Title_Full [ 1 ] } ;
2022-03-07 16:05:35 +01:00
2023-02-15 01:27:05 +01:00
text_x = new int [ ] { TJAPlayer3 . Skin . Modal_Text_Full [ 0 ] } ;
text_y = new int [ ] { TJAPlayer3 . Skin . Modal_Text_Full [ 1 ] } ;
moveX = TJAPlayer3 . Skin . Modal_Text_Full_Move [ 0 ] ;
moveY = TJAPlayer3 . Skin . Modal_Text_Full_Move [ 1 ] ;
}
else if ( modalFormat = = EModalFormat . Half )
{
title_x = TJAPlayer3 . Skin . Modal_Title_Half_X ;
title_y = TJAPlayer3 . Skin . Modal_Title_Half_Y ;
text_x = TJAPlayer3 . Skin . Modal_Text_Half_X ;
text_y = TJAPlayer3 . Skin . Modal_Text_Half_Y ;
moveX = TJAPlayer3 . Skin . Modal_Text_Half_Move [ 0 ] ;
moveY = TJAPlayer3 . Skin . Modal_Text_Half_Move [ 1 ] ;
}
else if ( modalFormat = = EModalFormat . Half_4P )
{
title_x = TJAPlayer3 . Skin . Modal_Title_Half_X_4P ;
title_y = TJAPlayer3 . Skin . Modal_Title_Half_Y_4P ;
text_x = TJAPlayer3 . Skin . Modal_Text_Half_X_4P ;
text_y = TJAPlayer3 . Skin . Modal_Text_Half_Y_4P ;
moveX = TJAPlayer3 . Skin . Modal_Text_Half_Move_4P [ 0 ] ;
moveY = TJAPlayer3 . Skin . Modal_Text_Half_Move_4P [ 1 ] ;
}
else // 5P
{
title_x = TJAPlayer3 . Skin . Modal_Title_Half_X_5P ;
title_y = TJAPlayer3 . Skin . Modal_Title_Half_Y_5P ;
text_x = TJAPlayer3 . Skin . Modal_Text_Half_X_5P ;
text_y = TJAPlayer3 . Skin . Modal_Text_Half_Y_5P ;
moveX = TJAPlayer3 . Skin . Modal_Text_Half_Move_5P [ 0 ] ;
moveY = TJAPlayer3 . Skin . Modal_Text_Half_Move_5P [ 1 ] ;
}
/ *
2022-03-07 16:05:35 +01:00
Point [ ] Pos = new Point [ ]
{
2023-02-04 07:47:55 +01:00
( modalFormat = = EModalFormat . Full ) ? new Point ( TJAPlayer3 . Skin . Modal_Title_Full [ 0 ] , TJAPlayer3 . Skin . Modal_Title_Full [ 1 ] ) : new Point ( TJAPlayer3 . Skin . Modal_Title_Half_X [ player ] , TJAPlayer3 . Skin . Modal_Title_Half_Y [ player ] ) , // title
2023-02-15 01:27:05 +01:00
( modalFormat = = EModalFormat . Full ) ?
new Point ( TJAPlayer3 . Skin . Modal_Text_Full [ 0 ] + ( tTextCentered ( ) ? TJAPlayer3 . Skin . Modal_Text_Full_Move [ 0 ] : 0 ) ,
TJAPlayer3 . Skin . Modal_Text_Full [ 1 ] + ( tTextCentered ( ) ? TJAPlayer3 . Skin . Modal_Text_Full_Move [ 1 ] : 0 ) ) :
2023-02-04 07:47:55 +01:00
new Point ( TJAPlayer3 . Skin . Modal_Text_Half_X [ player ] + ( tTextCentered ( ) ? TJAPlayer3 . Skin . Modal_Text_Half_Move [ 0 ] : 0 ) ,
TJAPlayer3 . Skin . Modal_Text_Half_Y [ player ] + ( tTextCentered ( ) ? TJAPlayer3 . Skin . Modal_Text_Half_Move [ 1 ] : 0 ) ) , // content
2022-03-07 16:05:35 +01:00
} ;
2023-02-15 01:27:05 +01:00
* /
Point [ ] Pos = new Point [ ]
{
new Point ( title_x [ player ] , title_y [ player ] ) ,
new Point ( text_x [ player ] + ( tTextCentered ( ) ? moveX : 0 ) ,
text_y [ player ] + ( tTextCentered ( ) ? moveY : 0 ) ) , // content
} ;
2022-03-07 16:05:35 +01:00
_ModalTitle ? . t2D中心基準描画 ( TJAPlayer3 . app . Device , Pos [ 0 ] . X , Pos [ 0 ] . Y ) ;
_ModalText ? . t2D中心基準描画 ( TJAPlayer3 . app . Device , Pos [ 1 ] . X , Pos [ 1 ] . Y ) ;
// Extra texture for Puchichara, Character and Titles next
2022-03-07 10:55:49 +01:00
}
2022-03-06 20:20:45 +01:00
}
2022-03-07 16:05:35 +01:00
public void tPlayModalSfx ( )
{
if ( modalType = = EModalType . Coin )
TJAPlayer3 . Skin . soundModal [ TJAPlayer3 . Skin . soundModal . Length - 1 ] . t再生する ( ) ;
else
TJAPlayer3 . Skin . soundModal [ Math . Max ( 0 , Math . Min ( TJAPlayer3 . Skin . soundModal . Length - 2 , rarity ) ) ] . t再生する ( ) ;
}
public static void tInitModalFonts ( )
{
if ( _pfModalContentHalf ! = null
& & _pfModalTitleHalf ! = null
& & _pfModalContentFull ! = null
& & _pfModalTitleFull ! = null )
return ;
if ( ! string . IsNullOrEmpty ( TJAPlayer3 . ConfigIni . FontName ) )
{
2023-02-04 07:47:55 +01:00
_pfModalContentHalf = new CPrivateFastFont ( new FontFamily ( TJAPlayer3 . ConfigIni . FontName ) , TJAPlayer3 . Skin . Modal_Font_ModalContentHalf_Size ) ;
_pfModalTitleHalf = new CPrivateFastFont ( new FontFamily ( TJAPlayer3 . ConfigIni . FontName ) , TJAPlayer3 . Skin . Modal_Font_ModalTitleHalf_Size ) ;
_pfModalContentFull = new CPrivateFastFont ( new FontFamily ( TJAPlayer3 . ConfigIni . FontName ) , TJAPlayer3 . Skin . Modal_Font_ModalContentFull_Size ) ;
_pfModalTitleFull = new CPrivateFastFont ( new FontFamily ( TJAPlayer3 . ConfigIni . FontName ) , TJAPlayer3 . Skin . Modal_Font_ModalTitleFull_Size ) ;
2022-03-07 16:05:35 +01:00
}
else
{
2023-02-04 07:47:55 +01:00
_pfModalContentHalf = new CPrivateFastFont ( new FontFamily ( "MS UI Gothic" ) , TJAPlayer3 . Skin . Modal_Font_ModalContentHalf_Size ) ;
_pfModalTitleHalf = new CPrivateFastFont ( new FontFamily ( "MS UI Gothic" ) , TJAPlayer3 . Skin . Modal_Font_ModalTitleHalf_Size ) ;
_pfModalContentFull = new CPrivateFastFont ( new FontFamily ( "MS UI Gothic" ) , TJAPlayer3 . Skin . Modal_Font_ModalContentFull_Size ) ;
_pfModalTitleFull = new CPrivateFastFont ( new FontFamily ( "MS UI Gothic" ) , TJAPlayer3 . Skin . Modal_Font_ModalTitleFull_Size ) ;
2022-03-07 16:05:35 +01:00
}
}
#region [ Enum definitions ]
2022-03-06 20:20:45 +01:00
public enum EModalType
{
2022-03-07 16:05:35 +01:00
Coin = 0 ,
Puchichara = 1 ,
Character = 2 ,
Title = 3 ,
Text = 4 ,
Confirm = 5 ,
2022-03-06 20:20:45 +01:00
}
2022-03-07 16:05:35 +01:00
// Full : 1P standard modal, Half : Splitted screen modal
2022-03-06 20:20:45 +01:00
public enum EModalFormat
{
Full ,
Half ,
2023-02-15 01:27:05 +01:00
Half_4P ,
Half_5P ,
2022-03-06 20:20:45 +01:00
}
2022-03-07 16:05:35 +01:00
#endregion
#region [ Public variables ]
2022-03-06 20:20:45 +01:00
// Coin number for coin; database/unlockable asset for puchichara, character and title; no effect on text, confirm
public int reference ;
public int rarity ;
public EModalType modalType ;
public EModalFormat modalFormat ;
// For modalFormat = Half only
public int player ;
2022-03-07 16:05:35 +01:00
#endregion
#region [ private ]
// Check if the text is vertically centered or slightly up (to let enough space for the unlocked unit texture)
private bool tTextCentered ( )
{
if ( modalType = = EModalType . Coin | | modalType = = EModalType . Text )
return true ;
return false ;
}
// Generate the modal title and content text textures
private void tGenerateTextures ( )
{
TitleTextureKey _title = new TitleTextureKey (
CLangManager . LangInstance . GetString ( 300 + ( int ) modalType ) ,
( modalFormat = = EModalFormat . Full )
? _pfModalTitleFull
: _pfModalTitleHalf ,
Color . White ,
Color . Black ,
2022-04-02 14:49:26 +02:00
1800 ) ;
2022-03-07 16:05:35 +01:00
string content = "" ;
if ( modalType = = EModalType . Coin )
{
content = String . Format ( "+{0} {1} ({2}: {3})" ,
reference ,
CLangManager . LangInstance . GetString ( 306 ) ,
CLangManager . LangInstance . GetString ( 307 ) ,
2023-02-16 18:59:12 +01:00
TJAPlayer3 . SaveFileInstances [ player ] . data . Medals
2022-03-07 16:05:35 +01:00
) ;
}
TitleTextureKey _content = new TitleTextureKey (
content ,
( modalFormat = = EModalFormat . Full )
? _pfModalContentFull
: _pfModalContentHalf ,
Color . White ,
Color . Black ,
2022-04-02 14:49:26 +02:00
1800 ) ;
2022-03-07 16:05:35 +01:00
_ModalText = TJAPlayer3 . stage選曲 . act曲リスト . ResolveTitleTexture ( _content ) ;
_ModalTitle = TJAPlayer3 . stage選曲 . act曲リスト . ResolveTitleTexture ( _title ) ;
}
2022-03-06 20:20:45 +01:00
private CTexture _box ;
private Rectangle _boxRect ;
2022-03-07 10:55:49 +01:00
private bool _isSet ;
2022-03-07 16:05:35 +01:00
private static CPrivateFastFont _pfModalTitleHalf ;
private static CPrivateFastFont _pfModalContentHalf ;
private static CPrivateFastFont _pfModalTitleFull ;
private static CPrivateFastFont _pfModalContentFull ;
private CTexture _ModalTitle ;
private CTexture _ModalText ;
#endregion
2022-03-06 20:20:45 +01:00
}
}