2 using System.Collections.Generic;
\r
4 using System.Drawing;
\r
6 using SlimDX.Direct3D9;
\r
8 using System.Diagnostics;
\r
12 internal class CAct演奏AVI : CActivity
\r
18 base.b活性化してない = true;
\r
24 /// On活性化()の前にフラグ操作すること。(活性化中に、本フラグを見て動作を変える部分があるため)
\r
26 public bool bIsPreviewMovie
\r
36 public bool bFullScreenMovie
\r
42 public void PrepareProperSizeTexture(int width, int height)
\r
46 if (this.tx描画用 != null && (this.tx描画用.szテクスチャサイズ.Width != width || this.tx描画用.szテクスチャサイズ.Height != height))
\r
48 this.tx描画用.Dispose();
\r
51 if (this.tx描画用 == null)
\r
53 #if TEST_Direct3D9Ex
\r
54 if ( width % 32 != 0 )
\r
60 this.tx描画用 = new CTexture(
\r
61 CDTXMania.Instance.Device, width, height,
\r
62 CDTXMania.Instance.GraphicsDeviceManager.CurrentSettings.BackBufferFormat,
\r
63 Pool.Default, Usage.Dynamic );
\r
65 this.tx描画用 = new CTexture(
\r
66 CDTXMania.Instance.Device, width, height,
\r
67 CDTXMania.Instance.GraphicsDeviceManager.CurrentSettings.BackBufferFormat,
\r
72 catch (CTextureCreateFailedException e)
\r
74 Trace.TraceError("CActAVI: OnManagedリソースの作成(): " + e.Message);
\r
80 public void Start(Ech定義 nチャンネル番号, CDTX.CAVI rAVI, int n開始サイズW, int n開始サイズH, int n終了サイズW, int n終了サイズH, int n画像側開始位置X, int n画像側開始位置Y, int n画像側終了位置X, int n画像側終了位置Y, int n表示側開始位置X, int n表示側開始位置Y, int n表示側終了位置X, int n表示側終了位置Y, int n総移動時間ms, int n移動開始時刻ms)
\r
82 if (nチャンネル番号 == Ech定義.Movie || nチャンネル番号 == Ech定義.MovieFull)
\r
85 this.n開始サイズW = n開始サイズW;
\r
86 this.n開始サイズH = n開始サイズH;
\r
87 this.n終了サイズW = n終了サイズW;
\r
88 this.n終了サイズH = n終了サイズH;
\r
89 this.n画像側開始位置X = n画像側開始位置X;
\r
90 this.n画像側開始位置Y = n画像側開始位置Y;
\r
91 this.n画像側終了位置X = n画像側終了位置X;
\r
92 this.n画像側終了位置Y = n画像側終了位置Y;
\r
93 this.n表示側開始位置X = n表示側開始位置X * 2;
\r
94 this.n表示側開始位置Y = n表示側開始位置Y * 2;
\r
95 this.n表示側終了位置X = n表示側終了位置X * 2;
\r
96 this.n表示側終了位置Y = n表示側終了位置Y * 2;
\r
97 this.n総移動時間ms = n総移動時間ms;
\r
98 this.PrepareProperSizeTexture((int)this.rAVI.avi.nフレーム幅, (int)this.rAVI.avi.nフレーム高さ);
\r
99 this.n移動開始時刻ms = (n移動開始時刻ms != -1) ? n移動開始時刻ms : CSound管理.rc演奏用タイマ.n現在時刻;
\r
100 this.rAVI.avi.Run();
\r
103 public void SkipStart(int n移動開始時刻ms)
\r
105 foreach (CChip chip in CDTXMania.Instance.DTX.listChip)
\r
107 if (chip.n発声時刻ms > n移動開始時刻ms)
\r
111 switch (chip.eAVI種別)
\r
115 if (chip.rAVI != null)
\r
117 if (this.rAVI == null)
\r
119 this.rAVI = chip.rAVI; // DTXVモードで、最初に途中再生で起動したときに、ここに来る
\r
121 this.bFullScreenMovie = (chip.eチャンネル番号 == Ech定義.MovieFull || CDTXMania.Instance.ConfigIni.bForceAVIFullscreen); // DTXVモードで、最初に途中再生で起動したときのために必要
\r
122 this.rAVI.avi.Seek(n移動開始時刻ms - chip.n発声時刻ms);
\r
123 this.Start(chip.eチャンネル番号, chip.rAVI, SampleFramework.GameWindowSize.Width, SampleFramework.GameWindowSize.Height, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, chip.n発声時刻ms);
\r
127 case EAVI種別.AVIPAN:
\r
129 if (chip.rAVIPan != null)
\r
131 if (this.rAVI == null)
\r
133 this.rAVI = chip.rAVI; // DTXVモードで、最初に途中再生で起動したときに、ここに来る
\r
135 this.bFullScreenMovie = (chip.eチャンネル番号 == Ech定義.MovieFull || CDTXMania.Instance.ConfigIni.bForceAVIFullscreen); // DTXVモードで、最初に途中再生で起動したときのために必要
\r
136 this.rAVI.avi.Seek(n移動開始時刻ms - chip.n発声時刻ms);
\r
137 this.Start(chip.eチャンネル番号, chip.rAVI, chip.rAVIPan.sz開始サイズ.Width, chip.rAVIPan.sz開始サイズ.Height, chip.rAVIPan.sz終了サイズ.Width, chip.rAVIPan.sz終了サイズ.Height, chip.rAVIPan.pt動画側開始位置.X, chip.rAVIPan.pt動画側開始位置.Y, chip.rAVIPan.pt動画側終了位置.X, chip.rAVIPan.pt動画側終了位置.Y, chip.rAVIPan.pt表示側開始位置.X, chip.rAVIPan.pt表示側開始位置.Y, chip.rAVIPan.pt表示側終了位置.X, chip.rAVIPan.pt表示側終了位置.Y, chip.n総移動時間, chip.n発声時刻ms);
\r
146 if ((this.rAVI != null) && (this.rAVI.avi != null))
\r
148 this.n移動開始時刻ms = -1;
\r
151 public void Cont(int n再開時刻ms)
\r
153 if ((this.rAVI != null) && (this.rAVI.avi != null))
\r
155 this.n移動開始時刻ms = n再開時刻ms;
\r
158 public unsafe int t進行描画(int x, int y, int areaDrawingWidth, int areaDrawingHeight)
\r
160 if (!base.b活性化してない)
\r
162 // Rectangle rectangle;
\r
163 // Rectangle rectangle2;
\r
165 if (((this.n移動開始時刻ms == -1) || (this.rAVI == null)) || (this.rAVI.avi == null))
\r
169 if (this.tx描画用 == null)
\r
173 int time = (int)((CSound管理.rc演奏用タイマ.n現在時刻 - this.n移動開始時刻ms) * (((double)CDTXMania.Instance.ConfigIni.n演奏速度) / 20.0));
\r
174 if ((this.n総移動時間ms != 0) && (this.n総移動時間ms < time))
\r
177 this.n移動開始時刻ms = -1;
\r
180 if ((this.n総移動時間ms == 0) && time >= this.rAVI.avi.GetDuration())
\r
182 if (!bIsPreviewMovie)
\r
184 this.n移動開始時刻ms = -1;
\r
187 // PREVIEW時はループ再生する。移動開始時刻msを現時刻にして(=AVIを最初に巻き戻して)、ここまでに行った計算をやり直す。
\r
188 this.n移動開始時刻ms = CSound管理.rc演奏用タイマ.n現在時刻;
\r
189 time = (int)((CSound管理.rc演奏用タイマ.n現在時刻 - this.n移動開始時刻ms) * (((double)CDTXMania.Instance.ConfigIni.n演奏速度) / 20.0));
\r
190 this.rAVI.avi.Seek(0);
\r
193 if( ( this.n前回表示したフレーム番号 != frameNoFromTime ) && !this.bフレームを作成した )
\r
195 // this.pBmp = this.rAVI.avi.GetFramePtr( frameNoFromTime );
\r
196 this.n前回表示したフレーム番号 = frameNoFromTime;
\r
197 this.bフレームを作成した = true;
\r
199 Size size = new Size( (int) this.rAVI.avi.nフレーム幅, (int) this.rAVI.avi.nフレーム高さ );
\r
200 // Size size2 = new Size( 278, 355);
\r
201 Size size2 = new Size( SampleFramework.GameWindowSize.Width, SampleFramework.GameWindowSize.Height);
\r
202 Size 開始サイズ = new Size( this.n開始サイズW, this.n開始サイズH );
\r
203 Size 終了サイズ = new Size( this.n終了サイズW, this.n終了サイズH );
\r
204 Point 画像側開始位置 = new Point( this.n画像側開始位置X, this.n画像側終了位置Y );
\r
205 Point 画像側終了位置 = new Point( this.n画像側終了位置X, this.n画像側終了位置Y );
\r
206 Point 表示側開始位置 = new Point( this.n表示側開始位置X, this.n表示側開始位置Y );
\r
207 Point 表示側終了位置 = new Point( this.n表示側終了位置X, this.n表示側終了位置Y );
\r
208 long num3 = this.n総移動時間ms;
\r
209 long num4 = this.n移動開始時刻ms;
\r
210 if( CSound管理.rc演奏用タイマ.n現在時刻 < num4 )
\r
212 num4 = CSound管理.rc演奏用タイマ.n現在時刻;
\r
214 time = (int) ( ( CSound管理.rc演奏用タイマ.n現在時刻 - num4 ) * ( ( (double) CDTXMania.Instance.ConfigIni.n演奏速度 ) / 20.0 ) );
\r
217 rectangle = new Rectangle( 画像側開始位置, 開始サイズ );
\r
218 rectangle2 = new Rectangle( 表示側開始位置, 開始サイズ );
\r
222 double num5 = ( (double) time ) / ( (double) num3 );
\r
223 Size size5 = new Size( 開始サイズ.Width + ( (int) ( ( 終了サイズ.Width - 開始サイズ.Width ) * num5 ) ), 開始サイズ.Height + ( (int) ( ( 終了サイズ.Height - 開始サイズ.Height ) * num5 ) ) );
\r
224 rectangle = new Rectangle( (int) ( ( 画像側終了位置.X - 画像側開始位置.X ) * num5 ), (int) ( ( 画像側終了位置.Y - 画像側開始位置.Y ) * num5 ), ( (int) ( ( 画像側終了位置.X - 画像側開始位置.X ) * num5 ) ) + size5.Width, ( (int) ( ( 画像側終了位置.Y - 画像側開始位置.Y ) * num5 ) ) + size5.Height );
\r
225 rectangle2 = new Rectangle( (int) ( ( 表示側終了位置.X - 表示側開始位置.X ) * num5 ), (int) ( ( 表示側終了位置.Y - 表示側開始位置.Y ) * num5 ), ( (int) ( ( 表示側終了位置.X - 表示側開始位置.X ) * num5 ) ) + size5.Width, ( (int) ( ( 表示側終了位置.Y - 表示側開始位置.Y ) * num5 ) ) + size5.Height );
\r
226 if( ( ( rectangle.Right <= 0 ) || ( rectangle.Bottom <= 0 ) ) || ( ( rectangle.Left >= size.Width ) || ( rectangle.Top >= size.Height ) ) )
\r
230 if( ( ( rectangle2.Right <= 0 ) || ( rectangle2.Bottom <= 0 ) ) || ( ( rectangle2.Left >= size2.Width ) || ( rectangle2.Top >= size2.Height ) ) )
\r
234 if( rectangle.X < 0 )
\r
236 int num6 = -rectangle.X;
\r
237 rectangle2.X += num6;
\r
238 rectangle2.Width -= num6;
\r
240 rectangle.Width -= num6;
\r
242 if( rectangle.Y < 0 )
\r
244 int num7 = -rectangle.Y;
\r
245 rectangle2.Y += num7;
\r
246 rectangle2.Height -= num7;
\r
248 rectangle.Height -= num7;
\r
250 if( rectangle.Right > size.Width )
\r
252 int num8 = rectangle.Right - size.Width;
\r
253 rectangle2.Width -= num8;
\r
254 rectangle.Width -= num8;
\r
256 if( rectangle.Bottom > size.Height )
\r
258 int num9 = rectangle.Bottom - size.Height;
\r
259 rectangle2.Height -= num9;
\r
260 rectangle.Height -= num9;
\r
262 if( rectangle2.X < 0 )
\r
264 int num10 = -rectangle2.X;
\r
265 rectangle.X += num10;
\r
266 rectangle.Width -= num10;
\r
268 rectangle2.Width -= num10;
\r
270 if( rectangle2.Y < 0 )
\r
272 int num11 = -rectangle2.Y;
\r
273 rectangle.Y += num11;
\r
274 rectangle.Height -= num11;
\r
276 rectangle2.Height -= num11;
\r
278 if( rectangle2.Right > size2.Width )
\r
280 int num12 = rectangle2.Right - size2.Width;
\r
281 rectangle.Width -= num12;
\r
282 rectangle2.Width -= num12;
\r
284 if( rectangle2.Bottom > size2.Height )
\r
286 int num13 = rectangle2.Bottom - size2.Height;
\r
287 rectangle.Height -= num13;
\r
288 rectangle2.Height -= num13;
\r
290 if( ( rectangle.X >= rectangle.Right ) || ( rectangle.Y >= rectangle.Bottom ) )
\r
294 if( ( rectangle2.X >= rectangle2.Right ) || ( rectangle2.Y >= rectangle2.Bottom ) )
\r
298 if( ( ( rectangle.Right < 0 ) || ( rectangle.Bottom < 0 ) ) || ( ( rectangle.X > size.Width ) || ( rectangle.Y > size.Height ) ) )
\r
302 if( ( ( rectangle2.Right < 0 ) || ( rectangle2.Bottom < 0 ) ) || ( ( rectangle2.X > size2.Width ) || ( rectangle2.Y > size2.Height ) ) )
\r
308 if ((this.tx描画用 != null) && (this.n総移動時間ms != -1))
\r
310 this.rAVI.avi.tGetBitmap(CDTXMania.Instance.Device, this.tx描画用, time);
\r
311 // 旧動画 (278x355以下)の場合と、それ以上の場合とで、拡大/表示位置補正ロジックを変えること。
\r
312 // 旧動画の場合は、「278x355の領域に表示される」ことを踏まえて扱う必要あり。
\r
313 // 例: 上半分だけ動画表示するような場合は・・・「上半分だけ」という表示意図を維持すべきか?それとも無視して全画面拡大すべきか??
\r
314 // chnmr0 : プレビューの場合表示領域いっぱいにアス比保持で拡縮します。
\r
315 // プレビューでない場合単純に縦横2倍、位置変更なしで表示します。
\r
316 // yyagi: BGAの有無を見ないで、単純にFullScreenMovieならアス比保持で拡縮、そうでないなら縦横2倍+位置変更なし。
\r
317 // chnmr0 : 従来の大きさ以上のプレビュー動画で不都合が起きますのでここは常にアス比保持でフィッティングします。
\r
319 float magX = 2, magY = 2;
\r
320 int xx = x, yy = y;
\r
322 if (CDTXMania.Instance.DTX != null && CDTXMania.Instance.DTX.bUse556x710BGAAVI)
\r
327 if (bFullScreenMovie || bIsPreviewMovie)
\r
329 #region [ アスペクト比を維持した拡大縮小 ]
\r
330 if (bFullScreenMovie)
\r
334 areaDrawingWidth = SampleFramework.GameWindowSize.Width;
\r
335 areaDrawingHeight = SampleFramework.GameWindowSize.Height;
\r
338 magX = (float)areaDrawingWidth / this.rAVI.avi.nフレーム幅;
\r
339 magY = (float)areaDrawingHeight / this.rAVI.avi.nフレーム高さ;
\r
343 xx += (int)((areaDrawingWidth - (this.rAVI.avi.nフレーム幅 * magY)) / 2);
\r
348 yy += (int)((areaDrawingHeight - (this.rAVI.avi.nフレーム高さ * magX)) / 2);
\r
353 this.tx描画用.vc拡大縮小倍率.X = magX;
\r
354 this.tx描画用.vc拡大縮小倍率.Y = magY;
\r
355 this.tx描画用.vc拡大縮小倍率.Z = 1.0f;
\r
356 this.tx描画用.bFlipY = true;
\r
357 this.tx描画用.t2D描画(CDTXMania.Instance.Device, xx, yy);
\r
366 public override void On活性化()
\r
369 this.n移動開始時刻ms = -1;
\r
370 this.bHasBGA = false;
\r
371 this.bFullScreenMovie = false;
\r
374 public override void OnManagedリソースの作成()
\r
376 if (!base.b活性化してない)
\r
378 #if TEST_Direct3D9Ex
\r
379 this.PrepareProperSizeTexture(
\r
380 ( bIsPreviewMovie ) ? 204 : SampleFramework.GameWindowSize.Width,
\r
381 ( bIsPreviewMovie ) ? 269 : SampleFramework.GameWindowSize.Height
\r
384 this.PrepareProperSizeTexture(
\r
385 (bIsPreviewMovie) ? 204 : SampleFramework.GameWindowSize.Width,
\r
386 (bIsPreviewMovie) ? 269 : SampleFramework.GameWindowSize.Height
\r
389 this.tx描画用.vc拡大縮小倍率 = new Vector3(Scale.X, Scale.Y, 1f);
\r
390 base.OnManagedリソースの作成();
\r
393 public override void OnManagedリソースの解放()
\r
395 if (!base.b活性化してない)
\r
397 if (this.tx描画用 != null)
\r
399 this.tx描画用.Dispose();
\r
402 base.OnManagedリソースの解放();
\r
405 public override int On進行描画()
\r
407 throw new InvalidOperationException("t進行描画(int,int)のほうを使用してください。");
\r
410 private long n移動開始時刻ms;
\r
411 private int n画像側開始位置X;
\r
412 private int n画像側開始位置Y;
\r
413 private int n画像側終了位置X;
\r
414 private int n画像側終了位置Y;
\r
415 private int n開始サイズH;
\r
416 private int n開始サイズW;
\r
417 private int n終了サイズH;
\r
418 private int n終了サイズW;
\r
419 private int n総移動時間ms;
\r
420 private int n表示側開始位置X;
\r
421 private int n表示側開始位置Y;
\r
422 private int n表示側終了位置X;
\r
423 private int n表示側終了位置Y;
\r
424 private CDTX.CAVI rAVI;
\r
425 private CTexture tx描画用;
\r