OSDN Git Service

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