OSDN Git Service

DTXManiaソリューション、DTXManiaプロジェクト、DTXCreatorプロジェクト、FDKプロジェクトについて英語化。
[dtxmania/dtxmania.git] / DTXMania / コード / ステージ / 05.選曲 / CActSelectArtistComment.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Drawing;
5 using System.Diagnostics;
6 using SharpDX;
7 using FDK;
8
9 using Rectangle = System.Drawing.Rectangle;
10
11 namespace DTXMania
12 {
13         internal class CActSelectArtistComment : CActivity
14         {
15                 // メソッド
16
17                 public CActSelectArtistComment()
18                 {
19                         base.b活性化してない = true;
20                 }
21                 public void t選択曲が変更された()
22                 {
23                         Cスコア cスコア = CDTXMania.Instance.stage選曲.r現在選択中のスコア;
24                         if (cスコア != null)
25                         {
26                                 Bitmap image = new Bitmap(1, 1);
27                                 TextureFactory.tテクスチャの解放(ref this.txArtist);
28                                 this.strArtist = cスコア.譜面情報.アーティスト名;
29                                 if ((this.strArtist != null) && (this.strArtist.Length > 0))
30                                 {
31                                         Graphics graphics = Graphics.FromImage(image);
32                                         graphics.PageUnit = GraphicsUnit.Pixel;
33                                         SizeF ef = graphics.MeasureString(this.strArtist, this.ft描画用フォント);
34                                         graphics.Dispose();
35                                         if (ef.Width > SampleFramework.GameWindowSize.Width)
36                                         {
37                                                 ef.Width = SampleFramework.GameWindowSize.Width;
38                                         }
39                                         try
40                                         {
41                                                 Bitmap bitmap2 = new Bitmap((int)Math.Ceiling((double)ef.Width), (int)Math.Ceiling((double)this.ft描画用フォント.Size));
42                                                 graphics = Graphics.FromImage(bitmap2);
43                                                 graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
44                                                 graphics.DrawString(this.strArtist, this.ft描画用フォント, Brushes.White, (float)0f, (float)0f);
45                                                 graphics.Dispose();
46                                                 this.txArtist = new CTexture(CDTXMania.Instance.Device, bitmap2, CDTXMania.Instance.TextureFormat);
47                                                 this.txArtist.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f);
48                                                 bitmap2.Dispose();
49                                         }
50                                         catch (CTextureCreateFailedException)
51                                         {
52                                                 Trace.TraceError("ARTISTテクスチャの生成に失敗しました。");
53                                                 this.txArtist = null;
54                                         }
55                                 }
56                                 TextureFactory.tテクスチャの解放(ref this.txComment);
57                                 this.strComment = cスコア.譜面情報.コメント;
58                                 if ((this.strComment != null) && (this.strComment.Length > 0))
59                                 {
60                                         Graphics graphics2 = Graphics.FromImage(image);
61                                         graphics2.PageUnit = GraphicsUnit.Pixel;
62                                         SizeF ef2 = graphics2.MeasureString(this.strComment, this.ft描画用フォント);
63                                         Size size = new Size((int)Math.Ceiling((double)ef2.Width), (int)Math.Ceiling((double)ef2.Height));
64                                         graphics2.Dispose();
65                                         this.nテクスチャの最大幅 = CDTXMania.Instance.Device.Capabilities.MaxTextureWidth;
66                                         int maxTextureHeight = CDTXMania.Instance.Device.Capabilities.MaxTextureHeight;
67                                         Bitmap bitmap3 = new Bitmap(size.Width, (int)Math.Ceiling((double)this.ft描画用フォント.Size));
68                                         graphics2 = Graphics.FromImage(bitmap3);
69                                         graphics2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
70                                         graphics2.DrawString(this.strComment, this.ft描画用フォント, Brushes.White, (float)0f, (float)0f);
71                                         graphics2.Dispose();
72                                         this.nComment行数 = 1;
73                                         this.nComment最終行の幅 = size.Width;
74                                         while (this.nComment最終行の幅 > this.nテクスチャの最大幅)
75                                         {
76                                                 this.nComment行数++;
77                                                 this.nComment最終行の幅 -= this.nテクスチャの最大幅;
78                                         }
79                                         while ((this.nComment行数 * ((int)Math.Ceiling((double)this.ft描画用フォント.Size))) > maxTextureHeight)
80                                         {
81                                                 this.nComment行数--;
82                                                 this.nComment最終行の幅 = this.nテクスチャの最大幅;
83                                         }
84                                         Bitmap bitmap4 = new Bitmap((this.nComment行数 > 1) ? this.nテクスチャの最大幅 : this.nComment最終行の幅, this.nComment行数 * ((int)Math.Ceiling((double)this.ft描画用フォント.Size)));
85                                         graphics2 = Graphics.FromImage(bitmap4);
86                                         Rectangle srcRect = new Rectangle();
87                                         Rectangle destRect = new Rectangle();
88                                         for (int i = 0; i < this.nComment行数; i++)
89                                         {
90                                                 srcRect.X = i * this.nテクスチャの最大幅;
91                                                 srcRect.Y = 0;
92                                                 srcRect.Width = ((i + 1) == this.nComment行数) ? this.nComment最終行の幅 : this.nテクスチャの最大幅;
93                                                 srcRect.Height = bitmap3.Height;
94                                                 destRect.X = 0;
95                                                 destRect.Y = i * bitmap3.Height;
96                                                 destRect.Width = srcRect.Width;
97                                                 destRect.Height = srcRect.Height;
98                                                 graphics2.DrawImage(bitmap3, destRect, srcRect, GraphicsUnit.Pixel);
99                                         }
100                                         graphics2.Dispose();
101                                         try
102                                         {
103                                                 this.txComment = new CTexture(CDTXMania.Instance.Device, bitmap4, CDTXMania.Instance.TextureFormat);
104                                                 this.txComment.vc拡大縮小倍率 = new Vector3(0.5f, 0.5f, 1f);
105                                         }
106                                         catch (CTextureCreateFailedException)
107                                         {
108                                                 Trace.TraceError("COMMENTテクスチャの生成に失敗しました。");
109                                                 this.txComment = null;
110                                         }
111                                         bitmap4.Dispose();
112                                         bitmap3.Dispose();
113                                 }
114                                 image.Dispose();
115                                 if (this.txComment != null)
116                                 {
117                                         this.ctComment = new CCounter(
118                                                 -nComment表示幅,
119                                                 (int)((((this.nComment行数 - 1) * this.nテクスチャの最大幅) + this.nComment最終行の幅) * this.txComment.vc拡大縮小倍率.X),
120                                                 unchecked((int)(10 * 2 / Scale.X)),
121                                                 CDTXMania.Instance.Timer
122                                         );
123                                 }
124                         }
125                 }
126
127
128                 // CActivity 実装
129
130                 public override void On活性化()
131                 {
132                         this.ft描画用フォント = new Font("MS PGothic", 26f * Scale.Y, GraphicsUnit.Pixel);
133                         this.txArtist = null;
134                         this.txComment = null;
135                         this.strArtist = "";
136                         this.strComment = "";
137                         this.nComment最終行の幅 = 0;
138                         this.nComment行数 = 0;
139                         this.nテクスチャの最大幅 = 0;
140                         this.ctComment = new CCounter();
141                         base.On活性化();
142                 }
143                 public override void On非活性化()
144                 {
145                         TextureFactory.tテクスチャの解放(ref this.txArtist);
146                         TextureFactory.tテクスチャの解放(ref this.txComment);
147                         if (this.ft描画用フォント != null)
148                         {
149                                 this.ft描画用フォント.Dispose();
150                                 this.ft描画用フォント = null;
151                         }
152                         this.ctComment = null;
153                         base.On非活性化();
154                 }
155                 public override void OnManagedリソースの作成()
156                 {
157                         if (!base.b活性化してない)
158                         {
159                                 this.t選択曲が変更された();
160                                 base.OnManagedリソースの作成();
161                         }
162                 }
163                 public override void OnManagedリソースの解放()
164                 {
165                         if (!base.b活性化してない)
166                         {
167                                 TextureFactory.tテクスチャの解放(ref this.txArtist);
168                                 TextureFactory.tテクスチャの解放(ref this.txComment);
169                                 base.OnManagedリソースの解放();
170                         }
171                 }
172                 public override int On進行描画()
173                 {
174                         if (!base.b活性化してない)
175                         {
176                                 if (this.ctComment.b進行中)
177                                 {
178                                         this.ctComment.t進行Loop();
179                                 }
180                                 if (this.txArtist != null)
181                                 {
182                                         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
183                                         int y = (int)(231 * Scale.Y);
184                                         this.txArtist.t2D描画(CDTXMania.Instance.Device, x, y);
185                                 }
186                                 if ((this.txComment != null) && ((this.ctComment.n現在の値 + nComment表示幅) >= 0))
187                                 {
188                                         int num3 = (int)(0xf8 * Scale.X);
189                                         int num4 = (int)(0xf5 * Scale.Y);
190                                         Rectangle rectangle = new Rectangle(this.ctComment.n現在の値, 0, nComment表示幅, (int)this.ft描画用フォント.Size);
191                                         if (rectangle.X < 0)
192                                         {
193                                                 num3 += -rectangle.X;
194                                                 rectangle.Width -= -rectangle.X;
195                                                 rectangle.X = 0;
196                                         }
197                                         int num5 = ((int)(((float)rectangle.X) / this.txComment.vc拡大縮小倍率.X)) / this.nテクスチャの最大幅;
198                                         Rectangle rectangle2 = new Rectangle();
199                                         while (rectangle.Width > 0)
200                                         {
201                                                 rectangle2.X = ((int)(((float)rectangle.X) / this.txComment.vc拡大縮小倍率.X)) % this.nテクスチャの最大幅;
202                                                 rectangle2.Y = num5 * ((int)this.ft描画用フォント.Size);
203                                                 int num6 = ((num5 + 1) == this.nComment行数) ? this.nComment最終行の幅 : this.nテクスチャの最大幅;
204                                                 int num7 = num6 - rectangle2.X;
205                                                 rectangle2.Width = num7;
206                                                 rectangle2.Height = (int)this.ft描画用フォント.Size;
207                                                 this.txComment.t2D描画(CDTXMania.Instance.Device, num3, num4, rectangle2);
208                                                 if (++num5 == this.nComment行数)
209                                                 {
210                                                         break;
211                                                 }
212                                                 int num8 = (int)(rectangle2.Width * this.txComment.vc拡大縮小倍率.X);
213                                                 rectangle.X += num8;
214                                                 rectangle.Width -= num8;
215                                                 num3 += num8;
216                                         }
217                                 }
218                         }
219                         return 0;
220                 }
221
222
223                 // その他
224
225                 #region [ private ]
226                 //-----------------
227                 private CCounter ctComment;
228                 private Font ft描画用フォント;
229                 private int nComment行数;
230                 private int nComment最終行の幅;
231                 private const int nComment表示幅 = (int)(0x182 * Scale.X);
232                 private int nテクスチャの最大幅;
233                 private string strArtist;
234                 private string strComment;
235                 private CTexture txArtist;
236                 private CTexture txComment;
237                 //-----------------
238                 #endregion
239         }
240 }