OSDN Git Service

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