}
try
{
- System.Drawing.Font ftMessage = new System.Drawing.Font( @"MS PGothic", 40.0f, FontStyle.Bold, GraphicsUnit.Pixel );
+ CPrivateFastFont pfMessage;
+ //System.Drawing.Font ftMessage = new System.Drawing.Font( @"MS PGothic", 40.0f, FontStyle.Bold, GraphicsUnit.Pixel );
+
+ string fontname = CDTXMania.Instance.Resources.Explanation("strCfgPopupFontFileName");
+ string path = Path.Combine(@"Graphics\fonts", fontname);
+ pfMessage = new CPrivateFastFont(CSkin.Path(path), 40);
+
string strMessage = CDTXMania.Instance.Resources.Explanation("strEnumeratingSongs");
if ( ( strMessage != null ) && ( strMessage.Length > 0 ) )
{
- Bitmap image = new Bitmap(1, 1);
- Graphics graphics = Graphics.FromImage(image);
- SizeF ef = graphics.MeasureString(strMessage, ftMessage);
- Size size = new Size( (int) Math.Ceiling( (double) ef.Width ), (int) Math.Ceiling( (double) ef.Height ) );
- graphics.Dispose();
- image.Dispose();
- image = new Bitmap(size.Width, size.Height);
- graphics = Graphics.FromImage(image);
- graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- graphics.DrawString(strMessage, ftMessage, Brushes.White, (float) 0f, (float) 0f);
- graphics.Dispose();
- this.txMessage = new CTexture(CDTXMania.Instance.Device, image, CDTXMania.Instance.TextureFormat);
- image.Dispose();
- TextureFactory.t安全にDisposeする(ref ftMessage);
+ Bitmap image = pfMessage.DrawPrivateFont(
+ strMessage, System.Drawing.Color.White, System.Drawing.Color.Black,
+ new Size(SampleFramework.GameWindowSize.Width, (int)(128 * Scale.Y))
+ );
+ System.Drawing.Rectangle rect = pfMessage.RectStrings;
+
+ Bitmap image_trim = image.Clone(rect, image.PixelFormat);
+
+ this.txMessage = new CTexture(CDTXMania.Instance.Device, image_trim, CDTXMania.Instance.TextureFormat);
+
+
+ //Bitmap image = new Bitmap(1, 1);
+ //Graphics graphics = Graphics.FromImage(image);
+ //SizeF ef = graphics.MeasureString(strMessage, ftMessage);
+ //Size size = new Size( (int) Math.Ceiling( (double) ef.Width ), (int) Math.Ceiling( (double) ef.Height ) );
+ //graphics.Dispose();
+ //image.Dispose();
+ //image = new Bitmap(size.Width, size.Height);
+ //graphics = Graphics.FromImage(image);
+ //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+ //graphics.DrawString(strMessage, ftMessage, Brushes.White, (float) 0f, (float) 0f);
+ //graphics.Dispose();
+ //this.txMessage = new CTexture(CDTXMania.Instance.Device, image, CDTXMania.Instance.TextureFormat);
+ //image.Dispose();
+ TextureFactory.t安全にDisposeする(ref image_trim);
+ TextureFactory.t安全にDisposeする(ref image);
+ TextureFactory.t安全にDisposeする(ref pfMessage);
}
else
{
using System.Text;
using System.Drawing;
using System.Diagnostics;
+using System.IO;
using SharpDX;
using FDK;
+using Color = System.Drawing.Color;
using Rectangle = System.Drawing.Rectangle;
namespace DTXMania
Cスコア cスコア = CDTXMania.Instance.stage選曲.r現在選択中のスコア;
if (cスコア != null)
{
- Bitmap image = new Bitmap(1, 1);
+ #region [ Artist ]
+ //Bitmap image = new Bitmap(1, 1);
TextureFactory.tテクスチャの解放(ref this.txArtist);
this.strArtist = cスコア.譜面情報.アーティスト名;
if ((this.strArtist != null) && (this.strArtist.Length > 0))
{
- Graphics graphics = Graphics.FromImage(image);
- graphics.PageUnit = GraphicsUnit.Pixel;
- SizeF ef = graphics.MeasureString(this.strArtist, this.ft描画用フォント);
- graphics.Dispose();
- if (ef.Width > SampleFramework.GameWindowSize.Width)
- {
- ef.Width = SampleFramework.GameWindowSize.Width;
- }
+ Bitmap imageStrArtist = this.ftArtist描画フォント.DrawPrivateFont(this.strArtist, Color.White);
+
+ //Graphics graphics = Graphics.FromImage(image);
+ //graphics.PageUnit = GraphicsUnit.Pixel;
+ //SizeF ef = graphics.MeasureString(this.strArtist, this.ft描画用フォント);
+ //graphics.Dispose();
+ //if (imageStrArtist.Width > SampleFramework.GameWindowSize.Width)
+ //{
+ // ef.Width = SampleFramework.GameWindowSize.Width;
+ //}
try
{
- Bitmap bitmap2 = new Bitmap((int)Math.Ceiling((double)ef.Width), (int)Math.Ceiling((double)this.ft描画用フォント.Size));
- graphics = Graphics.FromImage(bitmap2);
- graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- graphics.DrawString(this.strArtist, this.ft描画用フォント, Brushes.White, (float)0f, (float)0f);
- graphics.Dispose();
- this.txArtist = new CTexture(CDTXMania.Instance.Device, bitmap2, CDTXMania.Instance.TextureFormat);
- this.txArtist.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f);
- bitmap2.Dispose();
+ //Bitmap bitmap2 = new Bitmap((int)Math.Ceiling((double)ef.Width), (int)Math.Ceiling((double)this.ft描画用フォント.Size));
+ //graphics = Graphics.FromImage(bitmap2);
+ //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+ //graphics.DrawString(this.strArtist, this.ft描画用フォント, Brushes.White, (float)0f, (float)0f);
+ //graphics.Dispose();
+ this.txArtist = new CTextureAf(CDTXMania.Instance.Device, imageStrArtist, CDTXMania.Instance.TextureFormat);
+ //this.txArtist.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f);
+ imageStrArtist.Dispose();
}
catch (CTextureCreateFailedException)
{
this.txArtist = null;
}
}
+ #endregion
+
+ #region [ Comment ]
TextureFactory.tテクスチャの解放(ref this.txComment);
this.strComment = cスコア.譜面情報.コメント;
if ((this.strComment != null) && (this.strComment.Length > 0))
{
- Graphics graphics2 = Graphics.FromImage(image);
- graphics2.PageUnit = GraphicsUnit.Pixel;
- SizeF ef2 = graphics2.MeasureString(this.strComment, this.ft描画用フォント);
- Size size = new Size((int)Math.Ceiling((double)ef2.Width), (int)Math.Ceiling((double)ef2.Height));
- graphics2.Dispose();
+ Bitmap imageStrComment = this.ftComment描画フォント.DrawPrivateFont(this.strComment, Color.White);
+
+ //Graphics graphics2 = Graphics.FromImage(image);
+ //graphics2.PageUnit = GraphicsUnit.Pixel;
+ //SizeF ef2 = graphics2.MeasureString(this.strComment, this.ft描画用フォント);
+ Size size = new Size(imageStrComment.Width, imageStrComment.Height);
+ //graphics2.Dispose();
this.nテクスチャの最大幅 = CDTXMania.Instance.Device.Capabilities.MaxTextureWidth;
int maxTextureHeight = CDTXMania.Instance.Device.Capabilities.MaxTextureHeight;
- Bitmap bitmap3 = new Bitmap(size.Width, (int)Math.Ceiling((double)this.ft描画用フォント.Size));
- graphics2 = Graphics.FromImage(bitmap3);
- graphics2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- graphics2.DrawString(this.strComment, this.ft描画用フォント, Brushes.White, (float)0f, (float)0f);
- graphics2.Dispose();
+ //Bitmap bitmap3 = new Bitmap(size.Width, (int)Math.Ceiling((double)this.ft描画用フォント.Size));
+ //graphics2 = Graphics.FromImage(bitmap3);
+ //graphics2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+ //graphics2.DrawString(this.strComment, this.ft描画用フォント, Brushes.White, (float)0f, (float)0f);
+ //graphics2.Dispose();
this.nComment行数 = 1;
this.nComment最終行の幅 = size.Width;
while (this.nComment最終行の幅 > this.nテクスチャの最大幅)
this.nComment行数++;
this.nComment最終行の幅 -= this.nテクスチャの最大幅;
}
- while ((this.nComment行数 * ((int)Math.Ceiling((double)this.ft描画用フォント.Size))) > maxTextureHeight)
+ while ((this.nComment行数 * ((int)Math.Ceiling((double)this.ftComment描画フォント.Size))) > maxTextureHeight)
{
this.nComment行数--;
this.nComment最終行の幅 = this.nテクスチャの最大幅;
}
- Bitmap bitmap4 = new Bitmap((this.nComment行数 > 1) ? this.nテクスチャの最大幅 : this.nComment最終行の幅, this.nComment行数 * ((int)Math.Ceiling((double)this.ft描画用フォント.Size)));
- graphics2 = Graphics.FromImage(bitmap4);
- Rectangle srcRect = new Rectangle();
- Rectangle destRect = new Rectangle();
- for (int i = 0; i < this.nComment行数; i++)
- {
- srcRect.X = i * this.nテクスチャの最大幅;
- srcRect.Y = 0;
- srcRect.Width = ((i + 1) == this.nComment行数) ? this.nComment最終行の幅 : this.nテクスチャの最大幅;
- srcRect.Height = bitmap3.Height;
- destRect.X = 0;
- destRect.Y = i * bitmap3.Height;
- destRect.Width = srcRect.Width;
- destRect.Height = srcRect.Height;
- graphics2.DrawImage(bitmap3, destRect, srcRect, GraphicsUnit.Pixel);
- }
- graphics2.Dispose();
+ //Bitmap bitmap4 = new Bitmap((this.nComment行数 > 1) ? this.nテクスチャの最大幅 : this.nComment最終行の幅, this.nComment行数 * ((int)Math.Ceiling((double)this.ft描画用フォント.Size)));
+ //graphics2 = Graphics.FromImage(bitmap4);
+ //Rectangle srcRect = new Rectangle();
+ //Rectangle destRect = new Rectangle();
+ //for (int i = 0; i < this.nComment行数; i++)
+ //{
+ // srcRect.X = i * this.nテクスチャの最大幅;
+ // srcRect.Y = 0;
+ // srcRect.Width = ((i + 1) == this.nComment行数) ? this.nComment最終行の幅 : this.nテクスチャの最大幅;
+ // srcRect.Height = bitmap3.Height;
+ // destRect.X = 0;
+ // destRect.Y = i * bitmap3.Height;
+ // destRect.Width = srcRect.Width;
+ // destRect.Height = srcRect.Height;
+ // graphics2.DrawImage(bitmap3, destRect, srcRect, GraphicsUnit.Pixel);
+ //}
+ //graphics2.Dispose();
try
{
- this.txComment = new CTexture(CDTXMania.Instance.Device, bitmap4, CDTXMania.Instance.TextureFormat);
- this.txComment.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f);
+ this.txComment = new CTextureAf(CDTXMania.Instance.Device, imageStrComment, CDTXMania.Instance.TextureFormat, _label:"Comment");
+ //this.txComment.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f);
}
catch (CTextureCreateFailedException)
{
Trace.TraceError("COMMENTテクスチャの生成に失敗しました。");
this.txComment = null;
}
- bitmap4.Dispose();
- bitmap3.Dispose();
+ imageStrComment.Dispose();
}
- image.Dispose();
if (this.txComment != null)
{
this.ctComment = new CCounter(
CDTXMania.Instance.Timer
);
}
+ #endregion
}
}
public override void On活性化()
{
- this.ft描画用フォント = new Font("MS PGothic", 26f * Scale.Y, GraphicsUnit.Pixel);
+ CResources cr = CDTXMania.Instance.Resources;
+ //string path = Path.Combine(@"Graphics\fonts", cr.Explanation("strCfgSelectMusicSongArtistFontFileName"));
+ string path = Path.Combine(@"Graphics\fonts", cr.Explanation("strCfgPopupFontFileName"));
+ this.ftArtist描画フォント = new CPrivateFastFont(CSkin.Path(path), (int)(17f * 1));
+
+ //path = Path.Combine(@"Graphics\fonts", cr.Explanation("strCfgSelectMusicSongCommentFontFileName"));
+ path = Path.Combine(@"Graphics\fonts", cr.Explanation("strCfgPopupFontFileName"));
+ this.ftComment描画フォント = new CPrivateFastFont(CSkin.Path(path), (int)(17f * 1));
+
this.txArtist = null;
this.txComment = null;
this.strArtist = "";
{
TextureFactory.tテクスチャの解放(ref this.txArtist);
TextureFactory.tテクスチャの解放(ref this.txComment);
- if (this.ft描画用フォント != null)
- {
- this.ft描画用フォント.Dispose();
- this.ft描画用フォント = null;
- }
+ TextureFactory.t安全にDisposeする(ref ftArtist描画フォント);
+ TextureFactory.t安全にDisposeする(ref ftComment描画フォント);
+
this.ctComment = null;
base.On非活性化();
}
{
this.ctComment.t進行Loop();
}
+ #region [ ARTIST ]
if (this.txArtist != null)
{
- int x = (int)(SampleFramework.GameWindowSize.Width - (6 + 12) * Scale.X) - ((int)(this.txArtist.szテクスチャサイズ.Width * this.txArtist.vc拡大縮小倍率.X)); // #27648 2012.3.14 yyagi: -12 for scrollbar
- int y = (int)(231 * Scale.Y);
+ //int x = (int)(SampleFramework.GameWindowSize.Width - (6 + 12) * Scale.X) - ((int)(this.txArtist.szテクスチャサイズ.Width * this.txArtist.vc拡大縮小倍率.X)); // #27648 2012.3.14 yyagi: -12 for scrollbar
+ int x = (int)(SampleFramework.GameWindowSize.Width - (6 + 1) * Scale.X) - ((int)(this.txArtist.sz画像サイズ.Width * this.txArtist.vc拡大縮小倍率.X)); // #27648 2012.3.14 yyagi: -12 for scrollbar
+ int y = (int)(232 * Scale.Y);
this.txArtist.t2D描画(CDTXMania.Instance.Device, x, y);
}
+ #endregion
+ #region [ Comment ]
if ((this.txComment != null) && ((this.ctComment.n現在の値 + nComment表示幅) >= 0))
{
- int num3 = (int)(0xf8 * Scale.X);
- int num4 = (int)(0xf5 * Scale.Y);
- Rectangle rectangle = new Rectangle(this.ctComment.n現在の値, 0, nComment表示幅, (int)this.ft描画用フォント.Size);
+ int posX = (int)(0xf8 * Scale.X);
+ int posY = (int)(0xf6 * Scale.Y);
+ Rectangle rectangle = new Rectangle(this.ctComment.n現在の値, 0, nComment表示幅, (int)this.ftComment描画フォント.Size);
if (rectangle.X < 0)
{
- num3 += -rectangle.X;
+ posX += -rectangle.X;
rectangle.Width -= -rectangle.X;
rectangle.X = 0;
}
while (rectangle.Width > 0)
{
rectangle2.X = ((int)(((float)rectangle.X) / this.txComment.vc拡大縮小倍率.X)) % this.nテクスチャの最大幅;
- rectangle2.Y = num5 * ((int)this.ft描画用フォント.Size);
- int num6 = ((num5 + 1) == this.nComment行数) ? this.nComment最終行の幅 : this.nテクスチャの最大幅;
+ rectangle2.Y = num5 * ((int)this.ftComment描画フォント.Size);
+ //int num6 = ((num5 + 1) == this.nComment行数) ? this.nComment最終行の幅 : this.nテクスチャの最大幅;
+ int num6 = this.nテクスチャの最大幅;
int num7 = num6 - rectangle2.X;
rectangle2.Width = num7;
- rectangle2.Height = (int)this.ft描画用フォント.Size;
- this.txComment.t2D描画(CDTXMania.Instance.Device, num3, num4, rectangle2);
+ rectangle2.Height = this.txComment.sz画像サイズ.Height; //(int)this.ftComment描画フォント.Size;
+ this.txComment.t2D描画(CDTXMania.Instance.Device, posX, posY, rectangle2);
if (++num5 == this.nComment行数)
{
break;
int num8 = (int)(rectangle2.Width * this.txComment.vc拡大縮小倍率.X);
rectangle.X += num8;
rectangle.Width -= num8;
- num3 += num8;
+ posX += num8;
}
}
+ #endregion
}
return 0;
}
#region [ private ]
//-----------------
private CCounter ctComment;
- private Font ft描画用フォント;
+ private CPrivateFastFont ftArtist描画フォント;
+ private CPrivateFastFont ftComment描画フォント;
private int nComment行数;
private int nComment最終行の幅;
private const int nComment表示幅 = (int)(0x182 * Scale.X);
private int nテクスチャの最大幅;
private string strArtist;
private string strComment;
- private CTexture txArtist;
- private CTexture txComment;
+ private CTextureAf txArtist;
+ private CTextureAf txComment;
//-----------------
#endregion
}
using System.Drawing.Imaging;
using System.Diagnostics;
using System.Drawing.Text;
+using System.IO;
using SharpDX;
using FDK;
FontStyle regular = FontStyle.Regular;
if (CDTXMania.Instance.ConfigIni.bItalicFontSongSelect) regular |= FontStyle.Italic;
if (CDTXMania.Instance.ConfigIni.bBoldFontSongSelect) regular |= FontStyle.Bold;
- this.ft曲リスト用フォント = new Font(
- CDTXMania.Instance.ConfigIni.strFontSongSelect,
- (float)(CDTXMania.Instance.ConfigIni.nFontSizeDotSongSelect * 2 * Scale.Y), // 後でScale.Yを掛けないように直すこと(Config.ini初期値変更)
- regular,
- GraphicsUnit.Pixel
- );
+
+ CResources cr = CDTXMania.Instance.Resources;
+ //string fontname = cr.Explanation("strCfgSelectMusicSongListFontFileName");
+ string fontname = cr.Explanation("strCfgTitleFontFileName");
+
+ string path = Path.Combine(@"Graphics\fonts", fontname);
+ this.ft曲リスト用フォント = new CPrivateFastFont(CSkin.Path(path),
+ (int)(CDTXMania.Instance.ConfigIni.nFontSizeDotSongSelect * 3),
+ regular);
// 現在選択中の曲がない(=はじめての活性化)なら、現在選択中の曲をルートの先頭ノードに設定する。
#region [ Songs not found画像 ]
try
{
- using (Bitmap image = new Bitmap(SampleFramework.GameWindowSize.Width, (int)(128 * Scale.Y)))
- using (Graphics graphics = Graphics.FromImage(image))
+// using (Bitmap image = new Bitmap(SampleFramework.GameWindowSize.Width, (int)(128 * Scale.Y)))
+// using (Graphics graphics = Graphics.FromImage(image))
{
- string[] s = cr.Explanation("strEnumeratingSongsNotFound").Split(new string[] { Environment.NewLine }, 3, StringSplitOptions.None);
- for (int i = 0; i < s.Length; i++)
- {
- if (i * 42 > 128 * Scale.Y) break; // break if drawstrings over texture size
- graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.DarkGray, (float)(2f * Scale.X), (float)((2 + 42 * i) * Scale.Y));
- graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.White, (float) 0f, (float)((42 * i) * Scale.Y));
- }
+ //string[] s = cr.Explanation("strEnumeratingSongsNotFound").Split(new string[] { Environment.NewLine }, 3, StringSplitOptions.None);
+ string s = cr.Explanation("strEnumeratingSongsNotFound");
+ //for (int i = 0; i < s.Length; i++)
+ //{
+ //if (i * 42 > 128 * Scale.Y) break; // break if drawstrings over texture size
+
+ Bitmap image = this.ft曲リスト用フォント.DrawPrivateFont(s, Color.White, Color.Black, new Size(SampleFramework.GameWindowSize.Width, (int)(128 * Scale.Y)));
+
+
+ //graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.DarkGray, (float)(2f * Scale.X), (float)((2 + 42 * i) * Scale.Y));
+ //graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.White, (float) 0f, (float)((42 * i) * Scale.Y));
+ //}
this.txSongNotFound = new CTexture(CDTXMania.Instance.Device, image, CDTXMania.Instance.TextureFormat);
this.txSongNotFound.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f); // 半分のサイズで表示する。
+
+ TextureFactory.t安全にDisposeする(ref image);
}
}
catch (CTextureCreateFailedException)
#region [ "曲データを検索しています"画像 ]
try
{
- using (Bitmap image = new Bitmap(SampleFramework.GameWindowSize.Width, (int)(96 * Scale.Y)))
- using (Graphics graphics = Graphics.FromImage(image))
+ //using (Bitmap image = new Bitmap(SampleFramework.GameWindowSize.Width, (int)(96 * Scale.Y)))
+ //using (Graphics graphics = Graphics.FromImage(image))
{
- string[] s = cr.Explanation("strEnumeratingSongs").Split(new string[] { Environment.NewLine }, 2, StringSplitOptions.None);
- for (int i = 0; i < s.Length; i++)
- {
- if (i * 42 > 96 * Scale.Y) break; // break if drawstrings over texture size
- graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.DarkGray, (float)(2f * Scale.X), (float)((2 + 42 * i) * Scale.Y));
- graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.White, (float) 0f, (float)((42 * i) * Scale.Y));
- }
+ //string[] s = cr.Explanation("strEnumeratingSongs").Split(new string[] { Environment.NewLine }, 2, StringSplitOptions.None);
+ string s = cr.Explanation("strEnumeratingSongs");
+ //for (int i = 0; i < s.Length; i++)
+ //{
+ // if (i * 42 > 96 * Scale.Y) break; // break if drawstrings over texture size
+ //graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.DarkGray, (float)(2f * Scale.X), (float)((2 + 42 * i) * Scale.Y));
+ //graphics.DrawString(s[i], this.ft曲リスト用フォント, Brushes.White, (float) 0f, (float)((42 * i) * Scale.Y));
+ //}
+ Bitmap image = this.ft曲リスト用フォント.DrawPrivateFont(s, Color.White, Color.Black, new Size(SampleFramework.GameWindowSize.Width, (int)(128 * Scale.Y)));
this.txEnumeratingSongs = new CTexture(CDTXMania.Instance.Device, image, CDTXMania.Instance.TextureFormat);
this.txEnumeratingSongs.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f); // 半分のサイズで表示する。
+
+ TextureFactory.t安全にDisposeする(ref image);
}
}
catch (CTextureCreateFailedException)
private Color color文字影 = Color.FromArgb(0x40, 10, 10, 10);
private CCounter[] ct登場アニメ用 = new CCounter[13];
private EPart e楽器パート;
- private Font ft曲リスト用フォント;
+ private CPrivateFastFont ft曲リスト用フォント;
private long nスクロールタイマ;
private int n現在のスクロールカウンタ;
private int n現在の選択行;
try
{
- SizeF sz曲名;
-
- #region [ 曲名表示に必要となるサイズを取得する。]
- //-----------------
- using (var bmpDummy = new Bitmap(1, 1))
- {
- var g = Graphics.FromImage(bmpDummy);
- g.PageUnit = GraphicsUnit.Pixel;
- sz曲名 = g.MeasureString(str曲名, this.ft曲リスト用フォント);
- }
- //-----------------
- #endregion
+ Bitmap bmp = this.ft曲リスト用フォント.DrawPrivateFont(str曲名, Color.White, Color.Black);
int n最大幅px = (int)(392 * Scale.Y);
int height = (int)(25 * Scale.Y);
- int width = (int)((sz曲名.Width + 2) * 0.5f);
+ int width = (int)((bmp.Width + 2) * 0.5f);
if (width > (CDTXMania.Instance.Device.Capabilities.MaxTextureWidth / 2))
width = CDTXMania.Instance.Device.Capabilities.MaxTextureWidth / 2; // 右端断ち切れ仕方ないよね
-
float f拡大率X = (width <= n最大幅px) ? 0.5f : (((float)n最大幅px / (float)width) * 0.5f); // 長い文字列は横方向に圧縮。
- using (var bmp = new Bitmap(width * 2, height * 2, PixelFormat.Format32bppArgb)) // 2倍(面積4倍)のBitmapを確保。(0.5倍で表示する前提。)
- using (var g = Graphics.FromImage(bmp))
- {
- g.TextRenderingHint = TextRenderingHint.AntiAlias;
- float y = (((float)bmp.Height) / 2f) - ((CDTXMania.Instance.ConfigIni.nFontSizeDotSongSelect * Scale.Y * 2f) / 2f);
- g.DrawString(str曲名, this.ft曲リスト用フォント, new SolidBrush(this.color文字影), (float)2f, (float)(y + 2f));
- g.DrawString(str曲名, this.ft曲リスト用フォント, new SolidBrush(color), 0f, y);
+ TextureFactory.t安全にDisposeする(ref this.stバー情報[nバー番号].txタイトル名);
- TextureFactory.t安全にDisposeする(ref this.stバー情報[nバー番号].txタイトル名);
-
- this.stバー情報[nバー番号].txタイトル名 = new CTexture(CDTXMania.Instance.Device, bmp, CDTXMania.Instance.TextureFormat);
- this.stバー情報[nバー番号].txタイトル名.vc拡大縮小倍率 = new Vector3(f拡大率X, 0.5f, 1f);
- }
+ this.stバー情報[nバー番号].txタイトル名 = new CTexture(CDTXMania.Instance.Device, bmp, CDTXMania.Instance.TextureFormat);
+ this.stバー情報[nバー番号].txタイトル名.vc拡大縮小倍率 = new Vector3(f拡大率X, 0.5f, 1f);
+ TextureFactory.t安全にDisposeする(ref bmp);
}
catch (CTextureCreateFailedException)
{
using FDK;
using Rectangle = System.Drawing.Rectangle;
+using RectangleF = System.Drawing.RectangleF;
using Color = System.Drawing.Color;
using Point = System.Drawing.Point;
+using GraphicPath = System.Drawing.Drawing2D.GraphicsPath;
namespace DTXMania
{
_ptOrigin = new Point(0, 0);
return new Bitmap(1, 1);
}
- bool bEdge = ((drawmode & DrawMode.Edge) == DrawMode.Edge);
- bool bGradation = ((drawmode & DrawMode.Gradation) == DrawMode.Gradation);
+ bool bEdge = drawmode.HasFlag(DrawMode.Edge);
+ bool bGradation = drawmode.HasFlag(DrawMode.Gradation);
// 縁取りの縁のサイズは、とりあえずフォントの大きさの1/4とする
- int nEdgePt = (bEdge) ? _pt / 4 : 0;
+ int nEdgePt = (bEdge) ? _pt / 4 : _pt /8;
// 描画サイズを測定する (外部から描画領域を指定した場合は、それを使う)
Size stringSize;
}
else
{
- stringSize = System.Windows.Forms.TextRenderer.MeasureText(drawstr, this._font, new Size(int.MaxValue, int.MaxValue),
- System.Windows.Forms.TextFormatFlags.NoPrefix |
- System.Windows.Forms.TextFormatFlags.NoPadding
- );
+ using (Bitmap b = new Bitmap(1, 1))
+ using (Graphics g = Graphics.FromImage(b))
+ using (StringFormat sf = new StringFormat(StringFormat.GenericTypographic))
+ {
+ //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+ //sf.FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.NoWrap;
+
+ //SizeF sizef = g.MeasureString(drawstr, this._font, int.MaxValue, sf) ;
+ //stringSize = sizef.ToSize();
+ stringSize = System.Windows.Forms.TextRenderer.MeasureText(drawstr, this._font, new Size(int.MaxValue, int.MaxValue),
+ System.Windows.Forms.TextFormatFlags.NoPrefix |
+ System.Windows.Forms.TextFormatFlags.NoPadding |
+ System.Windows.Forms.TextFormatFlags.Bottom
+ );
+
+ //Rectangle rc = MeasureStringPrecisely(g, drawstr, this._font, new Size(stringSize.Width * 2, stringSize.Height * 2), sf);
+ //stringSize = new Size(rc.Width, rc.Height);
+ }
}
+
+ // 文字数をカウントする (横幅に文字数*2の縁取り幅を確保するために用いる)
+ System.Globalization.StringInfo si = new System.Globalization.StringInfo(drawstr);
+ int len = si.LengthInTextElements;
+
+ Size stringSizeWithEdge = sz.HasValue ?
+ // sz.Value : new Size((int)(stringSize.Width + nEdgePt * len), stringSize.Height + nEdgePt * 2);
+ //sz.Value : stringSize;
+ sz.Value : new Size((int)(stringSize.Width * 1.05f), stringSize.Height);
+
//取得した描画サイズを基に、描画先のbitmapを作成する
- Bitmap bmp = new Bitmap(stringSize.Width + nEdgePt * 2, stringSize.Height + nEdgePt * 2);
+ //Bitmap bmp = new Bitmap(stringSize.Width + nEdgePt * 2, stringSize.Height + nEdgePt * 2);
+ Bitmap bmp = new Bitmap(stringSizeWithEdge.Width, stringSizeWithEdge.Height);
bmp.MakeTransparent();
using (Graphics g = Graphics.FromImage(bmp))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
+ g.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (StringFormat sf = new StringFormat())
{
if (sz.HasValue)
{
- // ç\94»é\9d¢ä¸\8b部(垂直方向位置)
+ // ç\94»é\9d¢ä¸\8a部(垂直方向位置)
sf.LineAlignment = StringAlignment.Near;
- // 画面中央(水平方向位置)
+ // 画面左(水平方向位置)
sf.Alignment = StringAlignment.Near;
sf.FormatFlags = StringFormatFlags.LineLimit;
}
else
{
- // ç\94»é\9d¢ä¸\8bé\83¨(垂直方向位置)
- sf.LineAlignment = StringAlignment.Far;
+ // ç\94»é\9d¢ä¸\8a(垂直方向位置)
+ sf.LineAlignment = StringAlignment.Near;
// 画面中央(水平方向位置)
- sf.Alignment = StringAlignment.Center;
+ //sf.Alignment = StringAlignment.Center;
+ sf.Alignment = StringAlignment.Near;
sf.FormatFlags = StringFormatFlags.NoWrap;
}
// レイアウト枠
- Rectangle r = new Rectangle(0, 0, stringSize.Width + nEdgePt * 2, stringSize.Height + nEdgePt * 2);
+ //Rectangle r = new Rectangle(0, 0, stringSize.Width + nEdgePt * 2, stringSize.Height + nEdgePt * 2);
+ //Rectangle r = new Rectangle(0, 0, stringSizeWithEdge.Width, stringSizeWithEdge.Height);
+ Rectangle r = (sz.HasValue)?
+ new Rectangle(0, 0, (int)(stringSize.Width), stringSize.Height) :
+ new Rectangle(0, 0, (int)(stringSize.Width * 1.2f), stringSize.Height);
// 縁取り有りの描画
if (bEdge)
// (これをしないと、単位が違うために、小さめに描画されてしまう)
float sizeInPixels = _font.SizeInPoints * g.DpiY / 72; // 1 inch = 72 points
- using (System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath())
+ using (GraphicsPath gp = new GraphicsPath())
{
gp.AddString(drawstr, this._fontfamily, (int)this._font.Style, sizeInPixels, r, sf);
}
// System.Windows.Forms.TextRenderer.DrawText(g, drawstr, _font, new Point(0, 0), fontColor);
}
-#if debug表示
- g.DrawRectangle( new Pen( Color.White, 1 ), new Rectangle( 1, 1, stringSize.Width-1, stringSize.Height-1 ) );
+//#if debug表示
+ g.DrawRectangle( new Pen( Color.White, 1 ), new Rectangle( 1, 1, stringSizeWithEdge.Width-1, stringSizeWithEdge.Height-1 ) );
g.DrawRectangle( new Pen( Color.Green, 1 ), new Rectangle( 0, 0, bmp.Width - 1, bmp.Height - 1 ) );
-#endif
+//#endif
_rectStrings = new Rectangle(0, 0, stringSize.Width, stringSize.Height);
_ptOrigin = new Point(nEdgePt * 2, nEdgePt * 2);
}
}
}
+ public float Size
+ {
+ get
+ {
+ if (_font != null)
+ {
+ return _font.Size;
+ }
+ return 0f;
+ }
+ }
+
#region [ IDisposable 実装 ]
//-----------------
public void Dispose()
#region [ private ]
//-----------------
protected bool bDispose完了済み;
- protected Font _font;
+ protected Font _font = null;
private System.Drawing.Text.PrivateFontCollection _pfc;
- private FontFamily _fontfamily;
+ private FontFamily _fontfamily = null;
private int _pt;
private Rectangle _rectStrings;
private Point _ptOrigin;