1
0
mirror of synced 2024-11-28 09:20:53 +01:00
OpenTaiko/TJAPlayer3/Common/Modal.cs
Takkkom f048e419ee
ほとんどの画像の位置を自由に変更可能に (#366)
* ほとんどの画像の位置を自由に変更可能に

* マイルームのプチキャラが大きすぎる問題の修正
2023-02-04 15:47:55 +09:00

208 lines
7.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FDK;
using System.Drawing;
using static TJAPlayer3.CActSelect曲リスト;
namespace TJAPlayer3
{
internal class Modal
{
public Modal(EModalType mt, int ra, int re)
{
modalType = mt;
rarity = ra;
reference = re;
_isSet = false;
}
public void tSetupModal()
{
CTexture[] arrRef;
if (modalFormat == EModalFormat.Half)
arrRef = TJAPlayer3.Tx.Modal_Half;
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];
}
_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);
tGenerateTextures();
_isSet = true;
}
public void tDisplayModal()
{
if (_isSet == true)
{
_box?.t2D描画(TJAPlayer3.app.Device, (_box.szテクスチャサイズ.Width / 2) * player, 0, _boxRect);
Point[] Pos = new Point[]
{
(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
(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)) :
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
};
_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
}
}
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))
{
_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);
}
else
{
_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);
}
}
#region [Enum definitions]
public enum EModalType
{
Coin = 0,
Puchichara = 1,
Character = 2,
Title = 3,
Text = 4,
Confirm = 5,
}
// Full : 1P standard modal, Half : Splitted screen modal
public enum EModalFormat
{
Full,
Half,
}
#endregion
#region [Public variables]
// 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;
#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,
1800);
string content = "";
if (modalType == EModalType.Coin)
{
content = String.Format("+{0} {1} ({2}: {3})",
reference,
CLangManager.LangInstance.GetString(306),
CLangManager.LangInstance.GetString(307),
TJAPlayer3.NamePlateConfig.data.Medals[player]
);
}
TitleTextureKey _content = new TitleTextureKey(
content,
(modalFormat == EModalFormat.Full)
? _pfModalContentFull
: _pfModalContentHalf,
Color.White,
Color.Black,
1800);
_ModalText = TJAPlayer3.stage選曲.act曲リスト.ResolveTitleTexture(_content);
_ModalTitle = TJAPlayer3.stage選曲.act曲リスト.ResolveTitleTexture(_title);
}
private CTexture _box;
private Rectangle _boxRect;
private bool _isSet;
private static CPrivateFastFont _pfModalTitleHalf;
private static CPrivateFastFont _pfModalContentHalf;
private static CPrivateFastFont _pfModalTitleFull;
private static CPrivateFastFont _pfModalContentFull;
private CTexture _ModalTitle;
private CTexture _ModalText;
#endregion
}
}