2 using System.Collections.Generic;
6 using SharpDX.Direct3D9;
8 using System.Diagnostics;
12 internal class CAct演奏AVI : CActivity
14 private long n移動開始時刻ms;
15 private int n画像側開始位置X;
16 private int n画像側開始位置Y;
17 private int n画像側終了位置X;
18 private int n画像側終了位置Y;
24 private int n表示側開始位置X;
25 private int n表示側開始位置Y;
26 private int n表示側終了位置X;
27 private int n表示側終了位置Y;
28 private CDTX.CAVI rAVI;
29 private CTexture tx描画用;
35 /// On活性化()の前にフラグ操作すること。(活性化中に、本フラグを見て動作を変える部分があるため)
37 public bool bIsPreviewMovie
41 //public bool bIsPreviewMovie
45 // return _bIsPreviewMovie;
49 // _bIsPreviewMovie = value;
50 // //if (value == true)
52 // // this.bFullScreenMovieCentering = true;
56 //private bool _bIsPreviewMovie;
65 /// AVIをウインドウ全体に表示するかどうか
67 public bool bFullScreenMovie
73 /// ウインドウ全体で再生するAVIを、センタリング表示するかどうか
75 //public bool bFullScreenMovieCentering
98 ///// ウインドウ全体で再生するAVIを、センタリング表示しない場合の、表示X座標
100 //public int nFullScreenMovieX
106 ///// ウインドウ全体で再生するAVIを、センタリング表示しない場合の、表示Y座標
108 //public int nFullScreenMovieY
115 public void PrepareProperSizeTexture(int width, int height)
119 if (this.tx描画用 != null && (this.tx描画用.szテクスチャサイズ.Width != width || this.tx描画用.szテクスチャサイズ.Height != height))
121 this.tx描画用.Dispose();
124 if (this.tx描画用 == null)
127 if ( width % 32 != 0 )
133 this.tx描画用 = new CTexture(
134 CDTXMania.Instance.Device, width, height,
135 CDTXMania.Instance.GraphicsDeviceManager.CurrentSettings.BackBufferFormat,
136 Pool.Default, Usage.Dynamic );
138 this.tx描画用 = new CTexture(
139 CDTXMania.Instance.Device, width, height,
140 CDTXMania.Instance.GraphicsDeviceManager.CurrentSettings.BackBufferFormat,
145 catch (CTextureCreateFailedException e)
147 Trace.TraceError("CActAVI: OnManagedリソースの作成(): " + e.Message);
152 public void Start(EChannel 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)
154 if (nチャンネル番号 == EChannel.Movie || nチャンネル番号 == EChannel.MovieFull)
157 this.n開始サイズW = n開始サイズW;
158 this.n開始サイズH = n開始サイズH;
159 this.n終了サイズW = n終了サイズW;
160 this.n終了サイズH = n終了サイズH;
161 this.n画像側開始位置X = n画像側開始位置X;
162 this.n画像側開始位置Y = n画像側開始位置Y;
163 this.n画像側終了位置X = n画像側終了位置X;
164 this.n画像側終了位置Y = n画像側終了位置Y;
165 this.n表示側開始位置X = n表示側開始位置X * 2;
166 this.n表示側開始位置Y = n表示側開始位置Y * 2;
167 this.n表示側終了位置X = n表示側終了位置X * 2;
168 this.n表示側終了位置Y = n表示側終了位置Y * 2;
169 this.n総移動時間ms = n総移動時間ms;
170 this.PrepareProperSizeTexture((int)this.rAVI.avi.nフレーム幅, (int)this.rAVI.avi.nフレーム高さ);
171 this.n移動開始時刻ms = (n移動開始時刻ms != -1) ? n移動開始時刻ms : CSound管理.rc演奏用タイマ.n現在時刻;
175 public void SkipStart(int n移動開始時刻ms)
177 foreach (CChip chip in CDTXMania.Instance.DTX.listChip)
179 if (chip.n発声時刻ms > n移動開始時刻ms)
187 if (chip.rAVI != null)
189 if (this.rAVI == null)
191 this.rAVI = chip.rAVI; // DTXVモードで、最初に途中再生で起動したときに、ここに来る
193 this.bFullScreenMovie = (chip.eチャンネル番号 == EChannel.MovieFull); // DTXVモードで、最初に途中再生で起動したときのために必要
194 this.rAVI.avi.Seek(n移動開始時刻ms - chip.n発声時刻ms);
195 //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 );
196 this.Start( chip.eチャンネル番号, chip.rAVI, (int)chip.rAVI.avi.nフレーム幅, (int)chip.rAVI.avi.nフレーム高さ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, chip.n発声時刻ms );
200 case EAVIType.AVIPAN:
202 if (chip.rAVIPan != null)
204 if (this.rAVI == null)
206 this.rAVI = chip.rAVI; // DTXVモードで、最初に途中再生で起動したときに、ここに来る
208 //this.bFullScreenMovie = (chip.eチャンネル番号 == EChannel.MovieFull || CDTXMania.Instance.ConfigIni.bForceScalingAVI); // DTXVモードで、最初に途中再生で起動したときのために必要
209 this.bFullScreenMovie = (chip.eチャンネル番号 == EChannel.MovieFull); // DTXVモードで、最初に途中再生で起動したときのために必要
210 this.rAVI.avi.Seek(n移動開始時刻ms - chip.n発声時刻ms);
211 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);
220 if ((this.rAVI != null) && (this.rAVI.avi != null))
226 public void Cont(int n再開時刻ms)
228 if ((this.rAVI != null) && (this.rAVI.avi != null))
230 this.n移動開始時刻ms = n再開時刻ms;
235 /// この関数は AVI 再生のために使用できません。かわりに座標と大きさ指定可能な描画関数を使用してください。
237 /// <returns></returns>
238 public override int On進行描画()
243 public int t進行描画(int x, int y, int w, int h)
253 int x = X, y = Y, w = Width, h = Height;
256 CDTXMania.Instance.ConfigIni.bAVI &&
257 !CDTXMania.Instance.ConfigIni.bStoicMode)
259 if (((this.n移動開始時刻ms == -1) || (this.rAVI == null)) || (this.rAVI.avi == null))
263 if (this.tx描画用 == null)
267 int time = (int)((CSound管理.rc演奏用タイマ.n現在時刻 - this.n移動開始時刻ms) * (((double)CDTXMania.Instance.ConfigIni.nPlaySpeed) / 20.0));
268 if ((this.n総移動時間ms != 0) && (this.n総移動時間ms < time))
274 if ((this.n総移動時間ms == 0) && time >= this.rAVI.avi.GetDuration())
276 if (!bIsPreviewMovie)
281 // PREVIEW時はループ再生する。移動開始時刻msを現時刻にして(=AVIを最初に巻き戻して)、ここまでに行った計算をやり直す。
282 this.n移動開始時刻ms = CSound管理.rc演奏用タイマ.n現在時刻;
283 time = (int)((CSound管理.rc演奏用タイマ.n現在時刻 - this.n移動開始時刻ms) * (((double)CDTXMania.Instance.ConfigIni.nPlaySpeed) / 20.0));
284 this.rAVI.avi.Seek(0);
287 if ((this.tx描画用 != null) && (this.n総移動時間ms != -1))
289 this.rAVI.avi.tGetBitmap(CDTXMania.Instance.Device, this.tx描画用, time);
290 // 旧動画 (278x355以下)の場合と、それ以上の場合とで、拡大/表示位置補正ロジックを変えること。
291 // 旧動画の場合は、「278x355の領域に表示される」ことを踏まえて扱う必要あり。
292 // 例: 上半分だけ動画表示するような場合は・・・「上半分だけ」という表示意図を維持すべきか?それとも無視して全画面拡大すべきか??
293 // chnmr0 : プレビューの場合表示領域いっぱいにアス比保持で拡縮します。
294 // プレビューでない場合単純に縦横2倍、位置変更なしで表示します。
295 // yyagi: BGAの有無を見ないで、単純にFullScreenMovieならアス比保持で拡縮、そうでないなら縦横2倍+位置変更なし。
296 // chnmr0 : 従来の大きさ以上のプレビュー動画で不都合が起きますのでここは常にアス比保持でフィッティングします。
299 float magX = 2, magY = 2;
300 if ( CDTXMania.Instance.DTX != null && CDTXMania.Instance.DTX.bUse556x710BGAAVI )
305 //if (bFullScreenMovie || bIsPreviewMovie) // #37227 2017.5.29 yyagi: 動画表示の拡縮を、右横ウインドウ表示での動画再生にも適用
307 CPreviewMagnifier.EPreviewType e = CPreviewMagnifier.EPreviewType.PlayingFrontScalable;
308 if ( bFullScreenMovie ) e = CPreviewMagnifier.EPreviewType.PlayingBackground;
309 if ( bIsPreviewMovie ) e = CPreviewMagnifier.EPreviewType.MusicSelect;
311 //Trace.TraceInformation("InMovie1:{0},{1},{2},{3} Type={4}", x, y, w, h, e);
313 CPreviewMagnifier cmg = new CPreviewMagnifier( e, xx, yy, w, h );
315 (int) this.rAVI.avi.nフレーム幅,
316 (int) this.rAVI.avi.nフレーム高さ,
322 //if (bFullScreenMovieCentering)
327 ////else if (bFullScreenMovie)
329 //// xx = nFullScreenMovieX;
330 //// yy = nFullScreenMovieY;
332 // fullscreenでないときはxx=x, yy=yだが、xx,yyの初期値がx,yのためここでわざわざ記載する必要なし
338 //Trace.TraceInformation("InMovie2:{0},{1},{2},{3}: {4}, {5}", xx, yy, w*magX, w*magY, magX, magY);
341 this.tx描画用.vc拡大縮小倍率.X = magX;
342 this.tx描画用.vc拡大縮小倍率.Y = magY;
343 this.tx描画用.vc拡大縮小倍率.Z = 1.0f;
344 this.tx描画用.bFlipY = true;
345 this.tx描画用.t2D描画(CDTXMania.Instance.Device, xx, yy);
351 public override void On活性化()
357 this.bHasBGA = false;
358 //this.bFullScreenMovie = false;
363 public override void OnManagedリソースの作成()
368 this.PrepareProperSizeTexture(
369 ( bIsPreviewMovie ) ? 204 : SampleFramework.GameWindowSize.Width,
370 ( bIsPreviewMovie ) ? 269 : SampleFramework.GameWindowSize.Height
373 this.PrepareProperSizeTexture(
374 (bIsPreviewMovie) ? 204 : SampleFramework.GameWindowSize.Width,
375 (bIsPreviewMovie) ? 269 : SampleFramework.GameWindowSize.Height
378 this.tx描画用.vc拡大縮小倍率 = new Vector3(Scale.X, Scale.Y, 1f);
379 base.OnManagedリソースの作成();
382 public override void OnManagedリソースの解放()
386 if (this.tx描画用 != null)
388 this.tx描画用.Dispose();
391 base.OnManagedリソースの解放();