2 using System.Collections.Generic;
\r
4 using System.Drawing;
\r
6 using System.Diagnostics;
\r
8 using SlimDX.Direct3D9;
\r
13 internal class CActSelectPreimageパネル : CActivity
\r
17 public CActSelectPreimageパネル()
\r
19 base.b活性化してない = true;
\r
21 public void t選択曲が変更された()
\r
23 this.ct遅延表示 = new CCounter(-CDTXMania.Instance.ConfigIni.n曲が選択されてからプレビュー画像が表示開始されるまでのウェイトms, 100, 1, CDTXMania.Instance.Timer);
\r
24 this.b新しいプレビューファイルを読み込んだ = false;
\r
27 public bool bIsPlayingPremovie // #27060
\r
31 return (this.rAVI != null);
\r
34 public CAct演奏AVI actAVI
\r
42 public override void On活性化()
\r
44 this.n本体X = (int)(8 * Scale.X);
\r
45 this.n本体Y = (int)(0x39 * Scale.Y);
\r
46 this.r表示するプレビュー画像 = this.txプレビュー画像がないときの画像;
\r
47 this.str現在のファイル名 = "";
\r
48 this.b新しいプレビューファイルを読み込んだ = false;
\r
51 this.actAVI.bIsPreviewMovie = true;
\r
52 this.actAVI.On活性化();
\r
54 public override void On非活性化()
\r
56 this.ct登場アニメ用 = null;
\r
58 if (this.rAVI != null)
\r
60 this.rAVI.Dispose();
\r
64 this.actAVI.On非活性化();
\r
66 public override void OnManagedリソースの作成()
\r
70 this.txパネル本体 = TextureFactory.tテクスチャの生成(CSkin.Path(@"Graphics\ScreenSelect preimage panel.png"), false);
\r
71 this.txセンサ = TextureFactory.tテクスチャの生成(CSkin.Path(@"Graphics\ScreenSelect sensor.png"), false);
\r
72 this.txセンサ光 = TextureFactory.tテクスチャの生成(CSkin.Path(@"Graphics\ScreenSelect sensor light.png"), false);
\r
73 this.txプレビュー画像 = null;
\r
74 this.txプレビュー画像がないときの画像 = TextureFactory.tテクスチャの生成(CSkin.Path(@"Graphics\ScreenSelect preimage default.png"), false);
\r
75 //this.sfAVI画像 = Surface.CreateOffscreenPlain( CDTXMania.Instance.app.Device, 0xcc, 0x10d, CDTXMania.Instance.app.GraphicsDeviceManager.CurrentSettings.BackBufferFormat, Pool.SystemMemory );
\r
76 //this.sfAVI画像 = Surface.CreateOffscreenPlain( CDTXMania.Instance.app.Device, 192, 269, CDTXMania.Instance.app.GraphicsDeviceManager.CurrentSettings.BackBufferFormat, Pool.Default );
\r
77 //this.nAVI再生開始時刻 = -1;
\r
78 //this.n前回描画したフレーム番号 = -1;
\r
79 //this.b動画フレームを作成した = false;
\r
80 //this.pAVIBmp = IntPtr.Zero;
\r
81 this.tプレビュー画像_動画の変更();
\r
82 base.OnManagedリソースの作成();
\r
84 this.actAVI.OnManagedリソースの作成();
\r
87 public override void OnManagedリソースの解放()
\r
91 TextureFactory.tテクスチャの解放(ref this.txパネル本体);
\r
92 TextureFactory.tテクスチャの解放(ref this.txセンサ);
\r
93 TextureFactory.tテクスチャの解放(ref this.txセンサ光);
\r
94 TextureFactory.tテクスチャの解放(ref this.txプレビュー画像);
\r
95 TextureFactory.tテクスチャの解放(ref this.txプレビュー画像がないときの画像);
\r
96 //if( this.sfAVI画像 != null )
\r
98 // this.sfAVI画像.Dispose();
\r
99 // this.sfAVI画像 = null;
\r
101 base.OnManagedリソースの解放();
\r
102 this.actAVI.OnManagedリソースの解放();
\r
105 public override int On進行描画()
\r
107 if (!base.b活性化してない)
\r
109 if (base.b初めての進行描画)
\r
111 this.ct登場アニメ用 = new CCounter(0, 100, 5, CDTXMania.Instance.Timer);
\r
112 this.ctセンサ光 = new CCounter(0, 100, 30, CDTXMania.Instance.Timer);
\r
113 this.ctセンサ光.n現在の値 = 70;
\r
114 base.b初めての進行描画 = false;
\r
116 this.ct登場アニメ用.t進行();
\r
117 this.ctセンサ光.t進行Loop();
\r
118 if ((!CDTXMania.Instance.stage選曲.bスクロール中 && (this.ct遅延表示 != null)) && this.ct遅延表示.b進行中)
\r
121 if ((this.ct遅延表示.n現在の値 >= 0) && this.b新しいプレビューファイルをまだ読み込んでいない)
\r
123 this.tプレビュー画像_動画の変更();
\r
124 CDTXMania.Instance.Timer.t更新();
\r
125 this.ct遅延表示.n現在の経過時間ms = CDTXMania.Instance.Timer.n現在時刻;
\r
126 this.b新しいプレビューファイルを読み込んだ = true;
\r
128 else if (this.ct遅延表示.b終了値に達した && this.ct遅延表示.b進行中)
\r
133 //else if( ( ( this.avi != null ) && ( this.sfAVI画像 != null ) ) && ( this.nAVI再生開始時刻 != -1 ) )
\r
135 // int time = (int) ( ( CDTXMania.Instance.Timer.n現在時刻 - this.nAVI再生開始時刻 ) * ( ( (double) CDTXMania.Instance.ConfigIni.n演奏速度 ) / 20.0 ) );
\r
136 // int frameNoFromTime = this.avi.GetFrameNoFromTime( time );
\r
137 // if( frameNoFromTime >= this.avi.GetMaxFrameCount() )
\r
139 // this.nAVI再生開始時刻 = CDTXMania.Instance.Timer.n現在時刻;
\r
141 // else if( ( this.n前回描画したフレーム番号 != frameNoFromTime ) && !this.b動画フレームを作成した )
\r
143 // this.b動画フレームを作成した = true;
\r
144 // this.n前回描画したフレーム番号 = frameNoFromTime;
\r
145 // this.pAVIBmp = this.avi.GetFramePtr( frameNoFromTime );
\r
148 this.t描画処理_パネル本体();
\r
149 this.t描画処理_ジャンル文字列();
\r
150 this.t描画処理_プレビュー画像();
\r
152 this.t描画処理_センサ本体();
\r
161 #region [ private ]
\r
162 //-----------------
\r
163 //private CAvi avi;
\r
164 private CDTX.CAVI rAVI;
\r
166 //private bool b動画フレームを作成した;
\r
167 private CCounter ctセンサ光;
\r
168 private CCounter ct遅延表示;
\r
169 private CCounter ct登場アニメ用;
\r
170 //private long nAVI再生開始時刻;
\r
171 //private int n前回描画したフレーム番号;
\r
174 //private IntPtr pAVIBmp;
\r
175 private readonly Rectangle rcセンサ光 = new Rectangle((int)(0 * Scale.X), (int)(0xc0 * Scale.Y), (int)(0x40 * Scale.X), (int)(0x40 * Scale.Y));
\r
176 private readonly Rectangle rcセンサ本体下半分 = new Rectangle((int)(0x40 * Scale.X), (int)(0 * Scale.Y), (int)(0x40 * Scale.X), (int)(0x80 * Scale.Y));
\r
177 private readonly Rectangle rcセンサ本体上半分 = new Rectangle((int)(0 * Scale.X), (int)(0 * Scale.Y), (int)(0x40 * Scale.X), (int)(0x80 * Scale.Y));
\r
178 private CTexture r表示するプレビュー画像;
\r
179 //private Surface sfAVI画像;
\r
180 private string str現在のファイル名;
\r
181 private CTexture txセンサ;
\r
182 private CTexture txセンサ光;
\r
183 private CTexture txパネル本体;
\r
184 private CTexture txプレビュー画像;
\r
185 private CTexture txプレビュー画像がないときの画像;
\r
186 private bool b新しいプレビューファイルを読み込んだ;
\r
187 private bool b新しいプレビューファイルをまだ読み込んでいない
\r
191 return !this.b新しいプレビューファイルを読み込んだ;
\r
195 this.b新しいプレビューファイルを読み込んだ = !value;
\r
199 //private unsafe void tサーフェイスをクリアする( Surface sf )
\r
201 // DataRectangle rectangle = sf.LockRectangle( LockFlags.None );
\r
202 // DataStream data = rectangle.Data;
\r
203 // switch( ( rectangle.Pitch / sf.Description.Width ) )
\r
207 // uint* numPtr = (uint*) data.DataPointer.ToPointer();
\r
208 // for( int i = 0; i < sf.Description.Height; i++ )
\r
210 // for( int j = 0; j < sf.Description.Width; j++ )
\r
212 // ( numPtr + ( i * sf.Description.Width ) )[ j ] = 0;
\r
219 // ushort* numPtr2 = (ushort*) data.DataPointer.ToPointer();
\r
220 // for( int k = 0; k < sf.Description.Height; k++ )
\r
222 // for( int m = 0; m < sf.Description.Width; m++ )
\r
224 // ( numPtr2 + ( k * sf.Description.Width ) )[ m ] = 0;
\r
230 // sf.UnlockRectangle();
\r
232 private void tプレビュー画像_動画の変更()
\r
234 this.actAVI.Stop();
\r
235 if (this.rAVI != null)
\r
237 this.rAVI.Dispose();
\r
240 //this.pAVIBmp = IntPtr.Zero;
\r
241 //this.nAVI再生開始時刻 = -1;
\r
242 if (!CDTXMania.Instance.ConfigIni.bストイックモード)
\r
244 if (this.tプレビュー動画の指定があれば構築する())
\r
248 if (this.tプレビュー画像の指定があれば構築する())
\r
252 if (this.t背景画像があればその一部からプレビュー画像を構築する())
\r
257 this.r表示するプレビュー画像 = this.txプレビュー画像がないときの画像;
\r
258 this.str現在のファイル名 = "";
\r
260 private bool tプレビュー画像の指定があれば構築する()
\r
262 Cスコア cスコア = CDTXMania.Instance.stage選曲.r現在選択中のスコア;
\r
263 if ((cスコア == null) || string.IsNullOrEmpty(cスコア.譜面情報.Preimage))
\r
267 string str = cスコア.ファイル情報.フォルダの絶対パス + cスコア.譜面情報.Preimage;
\r
268 if (!str.Equals(this.str現在のファイル名))
\r
270 TextureFactory.tテクスチャの解放(ref this.txプレビュー画像);
\r
271 this.str現在のファイル名 = str;
\r
272 if (!File.Exists(this.str現在のファイル名))
\r
274 Trace.TraceWarning("ファイルが存在しません。({0})", new object[] { this.str現在のファイル名 });
\r
277 this.txプレビュー画像 = TextureFactory.tテクスチャの生成(this.str現在のファイル名, false);
\r
278 if (this.txプレビュー画像 != null)
\r
280 this.r表示するプレビュー画像 = this.txプレビュー画像;
\r
284 this.r表示するプレビュー画像 = this.txプレビュー画像がないときの画像;
\r
289 private bool tプレビュー動画の指定があれば構築する()
\r
291 Cスコア cスコア = CDTXMania.Instance.stage選曲.r現在選択中のスコア;
\r
292 if ((CDTXMania.Instance.ConfigIni.bAVI有効 && (cスコア != null)) && !string.IsNullOrEmpty(cスコア.譜面情報.Premovie))
\r
294 string filename = cスコア.ファイル情報.フォルダの絶対パス + cスコア.譜面情報.Premovie;
\r
295 if (filename.Equals(this.str現在のファイル名))
\r
299 if (this.rAVI != null)
\r
301 this.rAVI.Dispose();
\r
304 this.str現在のファイル名 = filename;
\r
305 if (!File.Exists(this.str現在のファイル名))
\r
307 Trace.TraceWarning("ファイルが存在しません。({0})", Path.GetFileName(this.str現在のファイル名));
\r
312 this.rAVI = new CDTX.CAVI(00, this.str現在のファイル名, "", CDTXMania.Instance.ConfigIni.n演奏速度);
\r
313 this.rAVI.OnDeviceCreated();
\r
314 this.actAVI.Start(Ech定義.Movie, rAVI, 204, 269, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1);
\r
316 catch (Exception e)
\r
318 Trace.TraceError("動画の生成に失敗しました。({0})", Path.GetFileName(filename));
\r
319 Trace.TraceError("例外メッセージ:{0}", e.Message);
\r
320 Trace.TraceError(" スタックトレース:{0}", e.StackTrace);
\r
326 private bool t背景画像があればその一部からプレビュー画像を構築する()
\r
328 Cスコア cスコア = CDTXMania.Instance.stage選曲.r現在選択中のスコア;
\r
329 if ((cスコア == null) || string.IsNullOrEmpty(cスコア.譜面情報.Backgound))
\r
333 string path = cスコア.ファイル情報.フォルダの絶対パス + cスコア.譜面情報.Backgound;
\r
334 if (!path.Equals(this.str現在のファイル名))
\r
336 if (!File.Exists(path))
\r
338 Trace.TraceWarning("ファイルが存在しません。({0})", new object[] { path });
\r
341 TextureFactory.tテクスチャの解放(ref this.txプレビュー画像);
\r
342 this.str現在のファイル名 = path;
\r
343 Bitmap image = null;
\r
344 Bitmap bitmap2 = null;
\r
345 Bitmap bitmap3 = null;
\r
348 image = new Bitmap(this.str現在のファイル名);
\r
349 bitmap2 = new Bitmap(SampleFramework.GameWindowSize.Width, SampleFramework.GameWindowSize.Height);
\r
350 Graphics graphics = Graphics.FromImage(bitmap2);
\r
352 for (int i = 0; i < SampleFramework.GameWindowSize.Height; i += image.Height)
\r
354 for (x = 0; x < SampleFramework.GameWindowSize.Width; x += image.Width)
\r
356 graphics.DrawImage(image, x, i, image.Width, image.Height);
\r
359 graphics.Dispose();
\r
360 bitmap3 = new Bitmap(0xcc, 0x10d);
\r
361 graphics = Graphics.FromImage(bitmap3);
\r
362 graphics.DrawImage(bitmap2, 5, 5, new Rectangle(0x157, 0x6d, 0xcc, 0x10d), GraphicsUnit.Pixel);
\r
363 graphics.Dispose();
\r
364 this.txプレビュー画像 = new CTexture(CDTXMania.Instance.Device, bitmap3, CDTXMania.Instance.TextureFormat);
\r
365 this.r表示するプレビュー画像 = this.txプレビュー画像;
\r
369 Trace.TraceError("背景画像の読み込みに失敗しました。({0})", new object[] { this.str現在のファイル名 });
\r
370 this.r表示するプレビュー画像 = this.txプレビュー画像がないときの画像;
\r
379 if (bitmap2 != null)
\r
383 if (bitmap3 != null)
\r
391 private void t描画処理_ジャンル文字列()
\r
393 C曲リストノード c曲リストノード = CDTXMania.Instance.stage選曲.r現在選択中の曲;
\r
394 Cスコア cスコア = CDTXMania.Instance.stage選曲.r現在選択中のスコア;
\r
395 if ((c曲リストノード != null) && (cスコア != null))
\r
398 switch (c曲リストノード.eノード種別)
\r
400 case C曲リストノード.Eノード種別.SCORE:
\r
401 if ((c曲リストノード.strジャンル == null) || (c曲リストノード.strジャンル.Length <= 0))
\r
403 if ((cスコア.譜面情報.ジャンル != null) && (cスコア.譜面情報.ジャンル.Length > 0))
\r
405 str = cスコア.譜面情報.ジャンル;
\r
407 #if false // #32644 2013.12.21 yyagi "Unknown"なジャンル表示を削除。DTX/BMSなどの種別表示もしない。
\r
410 switch( cスコア.譜面情報.曲種別 )
\r
437 str = c曲リストノード.strジャンル;
\r
440 case C曲リストノード.Eノード種別.SCORE_MIDI:
\r
444 case C曲リストノード.Eノード種別.BOX:
\r
448 case C曲リストノード.Eノード種別.BACKBOX:
\r
452 case C曲リストノード.Eノード種別.RANDOM:
\r
460 CDTXMania.Instance.act文字コンソール.tPrint(
\r
461 this.n本体X + (int)(0x12 * Scale.X),
\r
462 this.n本体Y - (int)(1 * Scale.Y),
\r
463 C文字コンソール.Eフォント種別.赤細,
\r
468 private void t描画処理_センサ光()
\r
470 int num = this.ctセンサ光.n現在の値;
\r
473 int x = this.n本体X + (int)(0xcc * Scale.X);
\r
474 int y = this.n本体Y + (int)(0x7b * Scale.Y);
\r
475 if (this.txセンサ光 != null)
\r
477 this.txセンサ光.vc拡大縮小倍率 = new Vector3(1f, 1f, 1f);
\r
478 this.txセンサ光.n透明度 = 0xff;
\r
480 CDTXMania.Instance.Device,
\r
484 (int)((num % 4) * 0x40 * Scale.X),
\r
485 (int)((num / 4) * 0x40 * Scale.Y),
\r
486 (int)(0x40 * Scale.X),
\r
487 (int)(0x40 * Scale.Y)
\r
492 else if (num < 0x18)
\r
494 int num4 = num - 11;
\r
495 double num5 = ((double)num4) / 11.0;
\r
496 double num6 = 1.0 + (num5 * 0.5);
\r
497 int num7 = (int)(64.0 * num6);
\r
498 int num8 = (int)(64.0 * num6);
\r
499 int x = ((this.n本体X + (int)(0xcc * Scale.X)) + (int)(0x20 * Scale.X)) - ((int)(num7 * Scale.X) / 2);
\r
500 int y = ((this.n本体Y + (int)(0x7b * Scale.Y)) + (int)(0x20 * Scale.Y)) - ((int)(num8 * Scale.Y) / 2);
\r
501 if (this.txセンサ光 != null)
\r
503 this.txセンサ光.vc拡大縮小倍率 = new Vector3((float)num6, (float)num6, 1f);
\r
504 this.txセンサ光.n透明度 = (int)(255.0 * (1.0 - num5));
\r
506 CDTXMania.Instance.Device,
\r
514 private void t描画処理_センサ本体()
\r
516 int x = this.n本体X + (int)(0xcd * Scale.X);
\r
517 int y = this.n本体Y - (int)(4 * Scale.Y);
\r
518 if (this.txセンサ != null)
\r
520 this.txセンサ.t2D描画(CDTXMania.Instance.Device, x, y, this.rcセンサ本体上半分);
\r
521 y += (int)(0x80 * Scale.Y);
\r
522 this.txセンサ.t2D描画(CDTXMania.Instance.Device, x, y, this.rcセンサ本体下半分);
\r
525 private void t描画処理_パネル本体()
\r
527 if (this.ct登場アニメ用.b終了値に達した || (this.txパネル本体 != null))
\r
529 this.n本体X = (int)(8 * Scale.X);
\r
530 this.n本体Y = (int)(0x39 * Scale.Y);
\r
534 double num = ((double)this.ct登場アニメ用.n現在の値) / 100.0;
\r
535 double num2 = Math.Cos((1.5 + (0.5 * num)) * Math.PI);
\r
536 this.n本体X = (int)(8 * Scale.X);
\r
537 this.n本体Y = (int)(0x39 * Scale.Y) - ((int)(this.txパネル本体.sz画像サイズ.Height * (1.0 - (num2 * num2))));
\r
539 if (this.txパネル本体 != null)
\r
541 this.txパネル本体.t2D描画(CDTXMania.Instance.Device, this.n本体X, this.n本体Y);
\r
544 private unsafe void t描画処理_プレビュー画像()
\r
546 if (!CDTXMania.Instance.stage選曲.bスクロール中 && (((this.ct遅延表示 != null) && (this.ct遅延表示.n現在の値 > 0)) && !this.b新しいプレビューファイルをまだ読み込んでいない))
\r
548 int x = this.n本体X + (int)(18 * Scale.X);
\r
549 int y = this.n本体Y + (int)(16 * Scale.Y);
\r
551 if (this.rAVI != null)
\r
553 this.actAVI.t進行描画(x, y, 612, 605);
\r
557 float num3 = ((float)this.ct遅延表示.n現在の値) / 100f;
\r
558 float mag = 0.9f + (0.1f * num3);
\r
560 #region [ プレビュー画像表示 ]
\r
561 if (this.r表示するプレビュー画像 != null)
\r
563 CPreviewMagnifier cmg = new CPreviewMagnifier();
\r
564 cmg.GetMagnifier(this.r表示するプレビュー画像.sz画像サイズ.Width, this.r表示するプレビュー画像.sz画像サイズ.Height, mag, mag, true);
\r
566 int width = cmg.width;
\r
567 int height = cmg.height;
\r
568 this.r表示するプレビュー画像.vc拡大縮小倍率.X = cmg.magX;
\r
569 this.r表示するプレビュー画像.vc拡大縮小倍率.Y = cmg.magY;
\r
571 x += (int)((612 - width * cmg.magX ) / 2 );
\r
572 y += (int)((605 - height * cmg.magY ) / 2 );
\r
573 this.r表示するプレビュー画像.n透明度 = (int)(255f * num3);
\r
574 this.r表示するプレビュー画像.t2D描画(CDTXMania.Instance.Device, x, y);
\r
579 //-----------------
\r