Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/DTXManiaプロジェクト/コード/全体/CDTXMania.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 556 - (show annotations) (download)
Sun Jun 26 01:46:17 2016 UTC (7 years, 9 months ago) by kairera0467
File size: 104870 byte(s)
#35905 XG表示のステータスパネル選択をスクリプト方式に一本化
#35943 GITADORA風表示のギター画面での表示座標を調整。
#xxxxx GITADORA風表示の演奏画面の曲名、アーティスト名表示で使うPrivateFontのコードを解放していなかったので修正。
#xxxxx GITADORA風表示の演奏画面の曲名、アーティスト名表示で使われていたFontのコードを削除。
#xxxxx GITADORA風表示のギター画面に入れなかった不具合を修正。
#xxxxx XG表示で現在使用されていないコードを削除。
#xxxxx 不要なファイルの削除
1 using System;
2 using System.Collections.Generic;
3 using System.Globalization;
4 using System.Text;
5 using System.Windows.Forms;
6 using System.Drawing;
7 using System.Diagnostics;
8 using System.Runtime.InteropServices;
9 using System.IO;
10 using System.Threading;
11 using System.Runtime.Serialization.Formatters.Binary;
12 using SlimDX;
13 using SlimDX.Direct3D9;
14 using FDK;
15 using SampleFramework;
16 using DTXMania.Properties;
17 using System.Reflection;
18 using DirectShowLib;
19
20 namespace DTXMania
21 {
22 internal class CDTXMania : Game
23 {
24 // プロパティ
25
26 public static readonly string VERSION = "Ver3.60(16----)";
27 public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
28 public static readonly string D3DXDLL = "d3dx9_43.dll"; // June 2010
29 //public static readonly string D3DXDLL = "d3dx9_42.dll"; // February 2010
30 //public static readonly string D3DXDLL = "d3dx9_41.dll"; // March 2009
31
32 public static CDTXMania app
33 {
34 get;
35 private set;
36 }
37 public static Folder Folder
38 {
39 get;
40 protected set;
41 }
42 public static CApp App
43 {
44 get;
45 private set;
46 }
47 public static C文字コンソ act文字コンソ
48 {
49 get;
50 private set;
51 }
52 public static bool bコンパクトモ
53 {
54 get;
55 private set;
56 }
57 public static CConfigIni ConfigIni
58 {
59 get;
60 private set;
61 }
62 public static CDTX DTX
63 {
64 get
65 {
66 return dtx;
67 }
68 set
69 {
70 if( ( dtx != null ) && ( app != null ) )
71 {
72 dtx.On非活性化();
73 app.listトップレベルActivities.Remove( dtx );
74 }
75 dtx = value;
76 if( ( dtx != null ) && ( app != null ) )
77 {
78 app.listトップレベルActivities.Add( dtx );
79 }
80 }
81 }
82 public static CFPS FPS
83 {
84 get;
85 private set;
86 }
87 public static CInput管理 Input管理
88 {
89 get;
90 private set;
91 }
92 public static int nSongDifficulty
93 {
94 get;
95 set;
96 }
97
98 #region [ 入力範囲ms ]
99 public static int nPerfect範囲ms
100 {
101 get
102 {
103 if( stage選曲.r確定された曲 != null )
104 {
105 C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
106 if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nPerfect範囲ms >= 0 ) )
107 {
108 return c曲リストノ.nPerfect範囲ms;
109 }
110 }
111 return ConfigIni.nヒット範囲ms.Perfect;
112 }
113 }
114 public static int nGreat範囲ms
115 {
116 get
117 {
118 if( stage選曲.r確定された曲 != null )
119 {
120 C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
121 if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nGreat範囲ms >= 0 ) )
122 {
123 return c曲リストノ.nGreat範囲ms;
124 }
125 }
126 return ConfigIni.nヒット範囲ms.Great;
127 }
128 }
129 public static int nGood範囲ms
130 {
131 get
132 {
133 if( stage選曲.r確定された曲 != null )
134 {
135 C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
136 if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nGood範囲ms >= 0 ) )
137 {
138 return c曲リストノ.nGood範囲ms;
139 }
140 }
141 return ConfigIni.nヒット範囲ms.Good;
142 }
143 }
144 public static int nPoor範囲ms
145 {
146 get
147 {
148 if( stage選曲.r確定された曲 != null )
149 {
150 C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
151 if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nPoor範囲ms >= 0 ) )
152 {
153 return c曲リストノ.nPoor範囲ms;
154 }
155 }
156 return ConfigIni.nヒット範囲ms.Poor;
157 }
158 }
159 #endregion
160 public static CPad Pad
161 {
162 get;
163 private set;
164 }
165 public static Random Random
166 {
167 get;
168 private set;
169 }
170 public static CSkin Skin
171 {
172 get;
173 private set;
174 }
175 public static CSongs管理 Songs管理
176 {
177 get;
178 set; // 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
179 }
180 public static CEnumSongs EnumSongs
181 {
182 get;
183 private set;
184 }
185 public static CActEnumSongs actEnumSongs
186 {
187 get;
188 private set;
189 }
190 public static CActFlushGPU actFlushGPU
191 {
192 get;
193 private set;
194 }
195 public static CSound管理 Sound管理
196 {
197 get;
198 private set;
199 }
200 public static CStage起動 stage起動
201 {
202 get;
203 private set;
204 }
205 public static CStageタイトル stageタイトル
206 {
207 get;
208 private set;
209 }
210 public static CStageオプション stageオプション
211 {
212 get;
213 private set;
214 }
215 public static CStageコンフィグ stageコンフィグ
216 {
217 get;
218 private set;
219 }
220 public static CStage選曲 stage選曲
221 {
222 get;
223 private set;
224 }
225 public static CStage曲読み込み stage曲読み込み
226 {
227 get;
228 private set;
229 }
230 public static CStage演奏ギタ画面 stage演奏ギタ画面
231 {
232 get;
233 private set;
234 }
235 public static CStage演奏ドラム画面 stage演奏ドラム画面
236 {
237 get;
238 private set;
239 }
240 public static CStage演奏画面共通 stage演奏画面共通
241 {
242 get;
243 private set;
244 }
245 public static CStage結果 stage結果
246 {
247 get;
248 private set;
249 }
250 public static CStageChangeSkin stageChangeSkin
251 {
252 get;
253 private set;
254 }
255 public static CStage終了 stage終了
256 {
257 get;
258 private set;
259 }
260 public static CStage r現在のステ = null;
261 public static CStage r直前のステ = null;
262 public bool b汎用ムである = false;
263 public static string strEXEのあるフォルダ
264 {
265 get;
266 private set;
267 }
268 public static string strコンパクトモドファイル
269 {
270 get;
271 private set;
272 }
273 public static CTimer Timer
274 {
275 get;
276 private set;
277 }
278 public static Format TextureFormat = Format.A8R8G8B8;
279 internal static IPluginActivity act現在入力を占有中のプラグイン = null;
280 public bool bApplicationActive
281 {
282 get;
283 private set;
284 }
285 public bool b次のタイミングで垂直帰線同期切り替えを行う
286 {
287 get;
288 set;
289 }
290 public bool b次のタイミングで全画面・ウィンドウ切り替えを行う
291 {
292 get;
293 set;
294 }
295
296 public Device Device
297 {
298 get { return base.GraphicsDeviceManager.Direct3D9.Device; }
299 }
300 public CPluginHost PluginHost
301 {
302 get;
303 private set;
304 }
305 public List<STPlugin> listプラグイン = new List<STPlugin>();
306 public struct STPlugin
307 {
308 public IPluginActivity plugin;
309 public string strプラグインフォルダ;
310 public string strアセンブリ簡易名;
311 public Version Version;
312 }
313 private static Size currentClientSize // #23510 2010.10.27 add yyagi to keep current window size
314 {
315 get;
316 set;
317 }
318 // public static CTimer ct;
319 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
320 {
321 get { return base.Window.Handle; }
322 }
323 public static CDTXVmode DTXVmode // #28821 2014.1.23 yyagi
324 {
325 get;
326 set;
327 }
328 //fork
329 public static STDGBVALUE< List<int> > listAutoGhostLag = new STDGBVALUE<List<int>>();
330 public static STDGBVALUE< List<int> > listTargetGhsotLag = new STDGBVALUE<List<int>>();
331 public static STDGBVALUE< CScoreIni.C演奏記録 > listTargetGhostScoreData = new STDGBVALUE< CScoreIni.C演奏記録 >();
332
333 // コンストラクタ
334
335 public CDTXMania()
336 {
337 CDTXMania.app = this;
338 this.t起動処理();
339 }
340
341
342 // メソッド
343
344 public void t全画面・ウィンドウモド切り替え()
345 {
346 #if WindowedFullscreen
347 if ( ConfigIni != null )
348 #else
349 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
350 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモ != settings.Windowed ) )
351 #endif
352 {
353 #if !WindowedFullscreen
354 settings.Windowed = ConfigIni.bウィンドウモ;
355 #endif
356 if ( ConfigIni.bウィンドウモ == false ) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
357 {
358 currentClientSize = this.Window.ClientSize;
359 ConfigIni.nウインドウwidth = this.Window.ClientSize.Width;
360 ConfigIni.nウインドウheight = this.Window.ClientSize.Height;
361 // FDK.CTaskBar.ShowTaskBar( false );
362 }
363 #if !WindowedFullscreen
364 base.GraphicsDeviceManager.ChangeDevice( settings );
365 #endif
366 if ( ConfigIni.bウィンドウモ == true ) // #23510 2010.10.27 yyagi: to resume window size from backuped value
367 {
368 #if WindowedFullscreen
369 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
370 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
371 // in spite of using fullscreen mode.
372 app.Window.WindowState = FormWindowState.Normal;
373 app.Window.FormBorderStyle = FormBorderStyle.Sizable;
374 app.Window.WindowState = FormWindowState.Normal;
375 #endif
376 base.Window.ClientSize =
377 new Size( currentClientSize.Width, currentClientSize.Height );
378 // FDK.CTaskBar.ShowTaskBar( true );
379 }
380 #if WindowedFullscreen
381 else
382 {
383 app.Window.WindowState = FormWindowState.Normal;
384 app.Window.FormBorderStyle = FormBorderStyle.None;
385 app.Window.WindowState = FormWindowState.Maximized;
386 }
387 if ( ConfigIni.bウィンドウモ )
388 {
389 if ( !this.bマウスカソル表示中 )
390 {
391 Cursor.Show();
392 this.bマウスカソル表示中 = true;
393 }
394 }
395 else if ( this.bマウスカソル表示中 )
396 {
397 Cursor.Hide();
398 this.bマウスカソル表示中 = false;
399 }
400 #endif
401 }
402 }
403
404
405 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
406 /// <summary>
407 /// リザルト画像のキャプチャと保存。
408 /// </summary>
409 /// <param name="strFilename">保存するファイル名(フルパス)</param>
410 public bool SaveResultScreen( string strFullPath )
411 {
412 string strSavePath = Path.GetDirectoryName( strFullPath );
413 if ( !Directory.Exists( strSavePath ) )
414 {
415 try
416 {
417 Directory.CreateDirectory( strSavePath );
418 }
419 catch
420 {
421 return false;
422 }
423 }
424
425 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
426 using ( Surface pSurface = CDTXMania.app.Device.GetRenderTarget( 0 ) )
427 {
428 Surface.ToFile( pSurface, strFullPath, ImageFileFormat.Png );
429 }
430 return true;
431 }
432 #endregion
433
434 // Game 実装
435 protected override void Initialize()
436 {
437 // new GCBeep();
438 sw.Start();
439 swlist = new List<double>( 8192 );
440 if( this.listトップレベルActivities != null )
441 {
442 foreach (CActivity activity in this.listトップレベルActivities)
443 {
444 activity.OnManagedリソスの作成();
445 }
446 }
447
448 foreach( STPlugin st in this.listプラグイン )
449 {
450 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
451 st.plugin.OnManagedリソスの作成();
452 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
453 }
454 #if GPUFlushAfterPresent
455 FrameEnd += dtxmania_FrameEnd;
456 #endif
457 }
458 #if GPUFlushAfterPresent
459 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
460 { // → Present()直後にGPUをFlushする
461 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
462 actFlushGPU.On進行描画(); // Flush GPU
463 }
464 #endif
465 protected override void LoadContent()
466 {
467 if ( ConfigIni.bウィンドウモ )
468 {
469 if( !this.bマウスカソル表示中 )
470 {
471 Cursor.Show();
472 this.bマウスカソル表示中 = true;
473 }
474 }
475 else if( this.bマウスカソル表示中 )
476 {
477 Cursor.Hide();
478 this.bマウスカソル表示中 = false;
479 }
480 this.Device.SetTransform(TransformState.View, Matrix.LookAtLH(new Vector3(0f, 0f, (float)(-SampleFramework.GameWindowSize.Height / 2 * Math.Sqrt(3.0))), new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f)));
481 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
482 this.Device.SetRenderState( RenderState.Lighting, false );
483 this.Device.SetRenderState( RenderState.ZEnable, false );
484 this.Device.SetRenderState( RenderState.AntialiasedLineEnable, false );
485 this.Device.SetRenderState( RenderState.AlphaTestEnable, true );
486 this.Device.SetRenderState( RenderState.AlphaRef, 10 );
487
488 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
489 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
490 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
491
492 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
493 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
494 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
495 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
496 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
497 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
498 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
499
500 if( this.listトップレベルActivities != null )
501 {
502 foreach( CActivity activity in this.listトップレベルActivities )
503 activity.OnUnmanagedリソスの作成();
504 }
505
506 foreach( STPlugin st in this.listプラグイン )
507 {
508 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
509 st.plugin.OnUnmanagedリソスの作成();
510 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
511 }
512
513 }
514 protected override void UnloadContent()
515 {
516 if( this.listトップレベルActivities != null )
517 {
518 foreach( CActivity activity in this.listトップレベルActivities )
519 activity.OnUnmanagedリソスの解放();
520 }
521
522 foreach( STPlugin st in this.listプラグイン )
523 {
524 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
525 st.plugin.OnUnmanagedリソスの解放();
526 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
527 }
528 }
529 protected override void OnExiting( EventArgs e )
530 {
531 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
532 this.t終了処理();
533 base.OnExiting( e );
534 }
535 protected override void Update( GameTime gameTime )
536 {
537 }
538 protected override void Draw( GameTime gameTime )
539 {
540 Sound管理.t再生中の処理をする();
541
542 if( Timer != null )
543 Timer.t更新();
544
545 if ( CSound管理.rc演奏用タイマ != null )
546 CSound管理.rc演奏用タイマ.t更新();
547
548 if( Input管理 != null )
549 Input管理.tリング( this.bApplicationActive, CDTXMania.ConfigIni.bバッファ入力を行う );
550
551 if( FPS != null )
552 FPS.tカウンタ更新();
553
554 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
555 // Pad.st検知したデバイス.Clear();
556
557 if( this.Device == null )
558 return;
559
560 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
561 CPowerManagement.tDisableMonitorSuspend();
562
563 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
564 #region [ スリープ ]
565 if ( ConfigIni.nフレム毎スリms >= 0 ) // #xxxxx 2011.11.27 yyagi
566 {
567 Thread.Sleep( ConfigIni.nフレム毎スリms );
568 }
569 #endregion
570
571 #region [ DTXCreatorからの指示 ]
572 if ( this.Window.IsReceivedMessage ) // ウインドウメッセージで、
573 {
574 string strMes = this.Window.strMessage;
575 this.Window.IsReceivedMessage = false;
576
577 if ( strMes != null )
578 {
579 DTXVmode.ParseArguments( strMes );
580
581 if ( DTXVmode.Enabled )
582 {
583 bコンパクトモ = true;
584 strコンパクトモドファイル = DTXVmode.filename;
585 if ( DTXVmode.Command == CDTXVmode.ECommand.Preview )
586 {
587 // preview soundの再生
588 string strPreviewFilename = DTXVmode.previewFilename;
589 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
590 try
591 {
592 if ( this.previewSound != null )
593 {
594 this.previewSound.tサウンドを停止する();
595 this.previewSound.Dispose();
596 this.previewSound = null;
597 }
598 this.previewSound = CDTXMania.Sound管理.tサウンドを生成する( strPreviewFilename );
599 this.previewSound.n音量 = DTXVmode.previewVolume;
600 this.previewSound.n位置 = DTXVmode.previewPan;
601 this.previewSound.t再生を開始する();
602 Trace.TraceInformation( "DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename );
603 }
604 catch
605 {
606 Trace.TraceError( "DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename );
607 if ( this.previewSound != null )
608 {
609 this.previewSound.Dispose();
610 }
611 this.previewSound = null;
612 }
613 }
614 }
615 }
616 }
617 #endregion
618
619 this.Device.BeginScene();
620 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, Color.Black, 1f, 0);
621
622 if( r現在のステ != null )
623 {
624 this.n進行描画の戻り値 = ( r現在のステ != null ) ? r現在のステ.On進行描画() : 0;
625
626 #region [ プラグインの進行描画 ]
627 //---------------------
628 foreach( STPlugin sp in this.listプラグイン )
629 {
630 Directory.SetCurrentDirectory( sp.strプラグインフォルダ );
631
632 if( CDTXMania.act現在入力を占有中のプラグイン == null || CDTXMania.act現在入力を占有中のプラグイン == sp.plugin )
633 sp.plugin.On進行描画( CDTXMania.Pad, CDTXMania.Input管理.Keyboard );
634 else
635 sp.plugin.On進行描画( null, null );
636
637 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
638 }
639 //---------------------
640 #endregion
641
642
643 CScoreIni scoreIni = null;
644
645 if( Control.IsKeyLocked( Keys.CapsLock ) ) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
646 { // → songs.db等の書き込み時だと音切れするっぽい
647 actEnumSongs.On非活性化();
648 EnumSongs.SongListEnumCompletelyDone();
649 CDTXMania.stage選曲.bIsEnumeratingSongs = false;
650 }
651 #region [ 曲検索スレッドの起動/終了 ] // ここに"Enumerating Songs..."表示を集約
652 if (!CDTXMania.bコンパクトモ)
653 {
654 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
655 } // "Enumerating Songs..."アイコンの描画
656 switch ( r現在のステ.eステID )
657 {
658 case CStage.Eステ.タイトル:
659 case CStage.Eステ.コンフィグ:
660 case CStage.Eステ.オプション:
661 case CStage.Eステ.選曲:
662 case CStage.Eステ.曲読み込み:
663 if ( EnumSongs != null )
664 {
665 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
666 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
667 if ( r現在のステ.eステID == CStage.Eステ.タイトル &&
668 r直前のステ.eステID == CStage.Eステ.起動 &&
669 this.n進行描画の戻り値 == (int) CStageタイトル.E戻り値.継続 &&
670 !EnumSongs.IsSongListEnumStarted )
671 {
672 actEnumSongs.On活性化();
673 CDTXMania.stage選曲.bIsEnumeratingSongs = true;
674 EnumSongs.Init( CDTXMania.Songs管理.listSongsDB, CDTXMania.Songs管理.nSongsDBから取得できたスコア数 ); // songs.db情報と、取得した曲数を、新インスタンスにも与える
675 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
676 if ( CDTXMania.Songs管理.nSongsDBから取得できたスコア数 == 0 ) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
677 {
678 EnumSongs.ChangeEnumeratePriority( ThreadPriority.Normal );
679 }
680 }
681 #endregion
682
683 #region [ 曲検索の中断と再開 ]
684 if ( r現在のステ.eステID == CStage.Eステ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone )
685 {
686 switch ( this.n進行描画の戻り値 )
687 {
688 case 0: // 何もない
689 //if ( CDTXMania.stage選曲.bIsEnumeratingSongs )
690 if ( !CDTXMania.stage選曲.bIsPlayingPremovie || CDTXMania.Skin.ds選曲画面背景動画 != null )
691 {
692 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
693 EnumSongs.IsSlowdown = false;
694 }
695 else
696 {
697 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
698 EnumSongs.IsSlowdown = true;
699 }
700 actEnumSongs.On活性化();
701 break;
702
703 case 2: // 曲決定
704 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
705 actEnumSongs.On非活性化();
706 break;
707 }
708 }
709 #endregion
710
711 #region [ 曲探索中断待ち待機 ]
712 if ( r現在のステ.eステID == CStage.Eステ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
713 EnumSongs.thDTXFileEnumerate != null ) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
714 {
715 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
716 }
717 #endregion
718
719 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
720 // CStage選曲.On活性化() に回した方がいいかな?
721 if ( EnumSongs.IsSongListEnumerated )
722 {
723 actEnumSongs.On非活性化();
724 CDTXMania.stage選曲.bIsEnumeratingSongs = false;
725
726 bool bRemakeSongTitleBar = ( r現在のステ.eステID == CStage.Eステ.選曲 ) ? true : false;
727 CDTXMania.stage選曲.Refresh( EnumSongs.Songs管理, bRemakeSongTitleBar );
728 EnumSongs.SongListEnumCompletelyDone();
729 }
730 #endregion
731 }
732 break;
733 }
734 #endregion
735
736 switch ( r現在のステ.eステID )
737 {
738 case CStage.Eステ.何もしない:
739 break;
740
741 case CStage.Eステ.起動:
742 #region [ *** ]
743 //-----------------------------
744 if( this.n進行描画の戻り値 != 0 )
745 {
746 if( !bコンパクトモ )
747 {
748 r現在のステ.On非活性化();
749 Trace.TraceInformation( "----------------------" );
750 Trace.TraceInformation( "■ タイトル" );
751 stageタイトル.On活性化();
752 r直前のステ = r現在のステ;
753 r現在のステ = stageタイトル;
754 }
755 else
756 {
757 r現在のステ.On非活性化();
758 Trace.TraceInformation( "----------------------" );
759 Trace.TraceInformation( "■ 曲読み込み" );
760 stage曲読み込み.On活性化();
761 r直前のステ = r現在のステ;
762 r現在のステ = stage曲読み込み;
763
764 }
765 foreach( STPlugin pg in this.listプラグイン )
766 {
767 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
768 pg.plugin.Onステジ変更();
769 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
770 }
771
772 this.tガベジコレクションを実行する();
773 }
774 //-----------------------------
775 #endregion
776 break;
777
778 case CStage.Eステ.タイトル:
779 #region [ *** ]
780 //-----------------------------
781 switch( this.n進行描画の戻り値 )
782 {
783 case (int)CStageタイトル.E戻り値.GAMESTART:
784 #region [ 選曲処理へ ]
785 //-----------------------------
786 r現在のステ.On非活性化();
787 Trace.TraceInformation( "----------------------" );
788 Trace.TraceInformation( "■ 選曲" );
789 stage選曲.On活性化();
790 r直前のステ = r現在のステ;
791 r現在のステ = stage選曲;
792 //-----------------------------
793 #endregion
794 break;
795
796 #region [ OPTION: 廃止済 ]
797 /*
798 case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
799 #region [ *** ]
800 //-----------------------------
801 r現在のステージ.On非活性化();
802 Trace.TraceInformation( "----------------------" );
803 Trace.TraceInformation( "■ オプション" );
804 stageオプション.On活性化();
805 r直前のステージ = r現在のステージ;
806 r現在のステージ = stageオプション;
807 //-----------------------------
808 #endregion
809 break;
810 */
811 #endregion
812
813 case (int)CStageタイトル.E戻り値.CONFIG:
814 #region [ *** ]
815 //-----------------------------
816 r現在のステ.On非活性化();
817 Trace.TraceInformation( "----------------------" );
818 Trace.TraceInformation( "■ コンフィグ" );
819 stageコンフィグ.On活性化();
820 r直前のステ = r現在のステ;
821 r現在のステ = stageコンフィグ;
822 //-----------------------------
823 #endregion
824 break;
825
826 case (int)CStageタイトル.E戻り値.EXIT:
827 #region [ *** ]
828 //-----------------------------
829 r現在のステ.On非活性化();
830 Trace.TraceInformation( "----------------------" );
831 Trace.TraceInformation( "■ 終了" );
832 stage終了.On活性化();
833 r直前のステ = r現在のステ;
834 r現在のステ = stage終了;
835 //-----------------------------
836 #endregion
837 break;
838 }
839
840 foreach( STPlugin pg in this.listプラグイン )
841 {
842 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
843 pg.plugin.Onステジ変更();
844 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
845 }
846
847 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
848 //-----------------------------
849 #endregion
850 break;
851
852
853 case CStage.Eステ.オプション:
854 #region [ *** ]
855 //-----------------------------
856 if( this.n進行描画の戻り値 != 0 )
857 {
858 switch( r直前のステ.eステID )
859 {
860 case CStage.Eステ.タイトル:
861 #region [ *** ]
862 //-----------------------------
863 r現在のステ.On非活性化();
864 Trace.TraceInformation( "----------------------" );
865 Trace.TraceInformation( "■ タイトル" );
866 stageタイトル.On活性化();
867 r直前のステ = r現在のステ;
868 r現在のステ = stageタイトル;
869
870 foreach( STPlugin pg in this.listプラグイン )
871 {
872 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
873 pg.plugin.Onステジ変更();
874 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
875 }
876
877 this.tガベジコレクションを実行する();
878 break;
879 //-----------------------------
880 #endregion
881
882 case CStage.Eステ.選曲:
883 #region [ *** ]
884 //-----------------------------
885 r現在のステ.On非活性化();
886 Trace.TraceInformation( "----------------------" );
887 Trace.TraceInformation( "■ 選曲" );
888 stage選曲.On活性化();
889 r直前のステ = r現在のステ;
890 r現在のステ = stage選曲;
891
892 foreach( STPlugin pg in this.listプラグイン )
893 {
894 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
895 pg.plugin.Onステジ変更();
896 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
897 }
898
899 this.tガベジコレクションを実行する();
900 break;
901 //-----------------------------
902 #endregion
903 }
904 }
905 //-----------------------------
906 #endregion
907 break;
908
909
910 case CStage.Eステ.コンフィグ:
911 #region [ *** ]
912 //-----------------------------
913 if( this.n進行描画の戻り値 != 0 )
914 {
915 switch( r直前のステ.eステID )
916 {
917 case CStage.Eステ.タイトル:
918 #region [ *** ]
919 //-----------------------------
920 r現在のステ.On非活性化();
921 Trace.TraceInformation( "----------------------" );
922 Trace.TraceInformation( "■ タイトル" );
923 stageタイトル.On活性化();
924 r直前のステ = r現在のステ;
925 r現在のステ = stageタイトル;
926
927 foreach( STPlugin pg in this.listプラグイン )
928 {
929 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
930 pg.plugin.Onステジ変更();
931 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
932 }
933
934 this.tガベジコレクションを実行する();
935 break;
936 //-----------------------------
937 #endregion
938
939 case CStage.Eステ.選曲:
940 #region [ *** ]
941 //-----------------------------
942 r現在のステ.On非活性化();
943 Trace.TraceInformation( "----------------------" );
944 Trace.TraceInformation( "■ 選曲" );
945 stage選曲.On活性化();
946 r直前のステ = r現在のステ;
947 r現在のステ = stage選曲;
948
949 foreach( STPlugin pg in this.listプラグイン )
950 {
951 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
952 pg.plugin.Onステジ変更();
953 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
954 }
955
956 this.tガベジコレクションを実行する();
957 break;
958 //-----------------------------
959 #endregion
960 }
961 }
962 //-----------------------------
963 #endregion
964 break;
965
966 case CStage.Eステ.選曲:
967 #region [ *** ]
968 //-----------------------------
969 switch( this.n進行描画の戻り値 )
970 {
971 case (int) CStage選曲.E戻り値.タイトルに戻る:
972 #region [ *** ]
973 //-----------------------------
974 r現在のステ.On非活性化();
975 Trace.TraceInformation( "----------------------" );
976 Trace.TraceInformation( "■ タイトル" );
977 stageタイトル.On活性化();
978 r直前のステ = r現在のステ;
979 r現在のステ = stageタイトル;
980
981 foreach( STPlugin pg in this.listプラグイン )
982 {
983 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
984 pg.plugin.Onステジ変更();
985 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
986 }
987
988 this.tガベジコレクションを実行する();
989 break;
990 //-----------------------------
991 #endregion
992
993 case (int) CStage選曲.E戻り値.選曲した:
994 #region [ *** ]
995 //-----------------------------
996 r現在のステ.On非活性化();
997 Trace.TraceInformation( "----------------------" );
998 Trace.TraceInformation( "■ 曲読み込み" );
999 stage曲読み込み.On活性化();
1000 r直前のステ = r現在のステ;
1001 r現在のステ = stage曲読み込み;
1002
1003 foreach( STPlugin pg in this.listプラグイン )
1004 {
1005 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1006 pg.plugin.Onステジ変更();
1007 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1008 }
1009
1010 this.tガベジコレクションを実行する();
1011 break;
1012 //-----------------------------
1013 #endregion
1014
1015
1016 case (int) CStage選曲.E戻り値.オプション呼び出し:
1017 #region [ *** ]
1018 //-----------------------------
1019
1020 r現在のステ.On非活性化();
1021 Trace.TraceInformation( "----------------------" );
1022 Trace.TraceInformation( "■ オプション" );
1023 stageオプション.On活性化();
1024 r直前のステ = r現在のステ;
1025 r現在のステ = stageオプション;
1026
1027 foreach( STPlugin pg in this.listプラグイン )
1028 {
1029 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1030 pg.plugin.Onステジ変更();
1031 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1032 }
1033
1034 this.tガベジコレクションを実行する();
1035 break;
1036 //-----------------------------
1037 #endregion
1038
1039 case (int) CStage選曲.E戻り値.コンフィグ呼び出し:
1040 #region [ *** ]
1041 //-----------------------------
1042 r現在のステ.On非活性化();
1043 Trace.TraceInformation( "----------------------" );
1044 Trace.TraceInformation( "■ コンフィグ" );
1045 stageコンフィグ.On活性化();
1046 r直前のステ = r現在のステ;
1047 r現在のステ = stageコンフィグ;
1048
1049 foreach( STPlugin pg in this.listプラグイン )
1050 {
1051 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1052 pg.plugin.Onステジ変更();
1053 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1054 }
1055
1056 this.tガベジコレクションを実行する();
1057 break;
1058 //-----------------------------
1059 #endregion
1060
1061 case (int) CStage選曲.E戻り値.スキン変更:
1062
1063 #region [ *** ]
1064 //-----------------------------
1065 r現在のステ.On非活性化();
1066 Trace.TraceInformation( "----------------------" );
1067 Trace.TraceInformation( "■ スキン切り替え" );
1068 stageChangeSkin.On活性化();
1069 r直前のステ = r現在のステ;
1070 r現在のステ = stageChangeSkin;
1071 break;
1072 //-----------------------------
1073 #endregion
1074 }
1075 //-----------------------------
1076 #endregion
1077 break;
1078
1079 case CStage.Eステ.曲読み込み:
1080 #region [ *** ]
1081 //-----------------------------
1082 if( this.n進行描画の戻り値 != 0 )
1083 {
1084 CDTXMania.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1085
1086 r現在のステ.On非活性化();
1087
1088 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1089 if ( this.n進行描画の戻り値 == (int) E曲読込画面の戻り値.読込中止 )
1090 {
1091 //DTX.t全チップの再生停止();
1092 DTX.On非活性化();
1093 Trace.TraceInformation( "曲の読み込みを中止しました。" );
1094 this.tガベジコレクションを実行する();
1095 Trace.TraceInformation( "----------------------" );
1096 Trace.TraceInformation( "■ 選曲" );
1097 stage選曲.On活性化();
1098 r直前のステ = r現在のステ;
1099 r現在のステ = stage選曲;
1100 foreach ( STPlugin pg in this.listプラグイン )
1101 {
1102 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1103 pg.plugin.Onステジ変更();
1104 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1105 }
1106 break;
1107 }
1108 #endregion
1109
1110
1111 if( !ConfigIni.bギタレボモ )
1112 {
1113 Trace.TraceInformation( "----------------------" );
1114 Trace.TraceInformation( "■ 演奏(ドラム画面)" );
1115 #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1116 for (int i = 0; i < 5; i++)
1117 {
1118 for (int j = 0; j < 2; j++)
1119 {
1120 stage演奏ドラム画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1121 }
1122 }
1123 for (int i = 0; i < 3; i++) {
1124 stage演奏ドラム画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1125 }
1126 #endif
1127 r直前のステ = r現在のステ;
1128 r現在のステ = stage演奏ドラム画面;
1129 }
1130 else
1131 {
1132 Trace.TraceInformation( "----------------------" );
1133 Trace.TraceInformation( "■ 演奏(ギター画面)" );
1134 #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1135 for (int i = 0; i < 5; i++)
1136 {
1137 for (int j = 0; j < 2; j++)
1138 {
1139 stage演奏ギタ画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1140 }
1141 }
1142 for (int i = 0; i < 3; i++) {
1143 stage演奏ギタ画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1144 }
1145 #endif
1146 r直前のステ = r現在のステ;
1147 r現在のステ = stage演奏ギタ画面;
1148 }
1149
1150 foreach( STPlugin pg in this.listプラグイン )
1151 {
1152 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1153 pg.plugin.Onステジ変更();
1154 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1155 }
1156
1157 this.tガベジコレクションを実行する();
1158 }
1159 //-----------------------------
1160 #endregion
1161 break;
1162
1163 case CStage.Eステ.演奏:
1164 #region [ *** ]
1165 //-----------------------------
1166
1167 double n = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
1168 swlist.Add(n);
1169
1170 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1171 if ( DTXVmode.Enabled && DTXVmode.Refreshed )
1172 {
1173 DTXVmode.Refreshed = false;
1174
1175 if ( DTXVmode.Command == CDTXVmode.ECommand.Stop )
1176 {
1177 if ( !ConfigIni.bギタレボモ )
1178 {
1179 CDTXMania.stage演奏ドラム画面.t停止();
1180 }
1181 else
1182 {
1183 CDTXMania.stage演奏ギタ画面.t停止();
1184 }
1185 if ( previewSound != null )
1186 {
1187 this.previewSound.tサウンドを停止する();
1188 this.previewSound.Dispose();
1189 this.previewSound = null;
1190 }
1191 }
1192 else if ( DTXVmode.Command == CDTXVmode.ECommand.Play )
1193 {
1194 if ( DTXVmode.NeedReload )
1195 {
1196 if ( !ConfigIni.bギタレボモ )
1197 {
1198 CDTXMania.stage演奏ドラム画面.t再読込();
1199 }
1200 else
1201 {
1202 CDTXMania.stage演奏ギタ画面.t再読込();
1203 }
1204
1205 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1206 CDTXMania.ConfigIni.bGuitar有効 = true;
1207 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1208 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1209 if ( CDTXMania.ConfigIni.b垂直帰線待ちを行う != DTXVmode.VSyncWait )
1210 {
1211 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1212 CDTXMania.app.b次のタイミングで垂直帰線同期切り替えを行う = true;
1213 }
1214 }
1215 else
1216 {
1217 if ( !ConfigIni.bギタレボモ )
1218 {
1219 CDTXMania.stage演奏ドラム画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
1220 }
1221 else
1222 {
1223 CDTXMania.stage演奏ギタ画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
1224 }
1225 }
1226 }
1227 }
1228 #endregion
1229
1230 switch( this.n進行描画の戻り値 )
1231 {
1232 case (int) E演奏画面の戻り値.再読込・再演奏:
1233 #region [ DTXファイルを再読み込みして、再演奏 ]
1234 DTX.t全チップの再生停止();
1235 DTX.On非活性化();
1236 r現在のステ.On非活性化();
1237 stage曲読み込み.On活性化();
1238 r直前のステ = r現在のステ;
1239 r現在のステ = stage曲読み込み;
1240 this.tガベジコレクションを実行する();
1241 break;
1242 #endregion
1243
1244 //case (int) E演奏画面の戻り値.再演奏:
1245 #region [ 再読み込み無しで、再演奏 ]
1246 #endregion
1247 // break;
1248
1249 case (int) E演奏画面の戻り値.継続:
1250 break;
1251
1252 case (int) E演奏画面の戻り値.演奏中断:
1253 #region [ 演奏キャンセル ]
1254 //-----------------------------
1255 scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Play canceled" );
1256
1257 double lastd = 0f;
1258 int f = 0;
1259 foreach ( double d in swlist )
1260 {
1261 double dif = d - lastd;
1262 string s = "";
1263 if ( 0.016 < dif && dif < 0.017 )
1264 {
1265 }
1266 else
1267 {
1268 s = "★";
1269 }
1270 //Trace.TraceInformation( "frame " + f + ": " + d + " (" + dif + ")" + s );
1271 lastd = d;
1272 f++;
1273 }
1274 swlist.Clear();
1275
1276 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1277 //---------------------
1278 foreach( STPlugin pg in this.listプラグイン )
1279 {
1280 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1281 pg.plugin.On演奏キャンセル( scoreIni );
1282 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1283 }
1284 //---------------------
1285 #endregion
1286
1287 DTX.t全チップの再生停止();
1288 DTX.On非活性化();
1289 r現在のステ.On非活性化();
1290 if( bコンパクトモ )
1291 {
1292 base.Window.Close();
1293 }
1294 else
1295 {
1296 Trace.TraceInformation( "----------------------" );
1297 Trace.TraceInformation( "■ 選曲" );
1298 stage選曲.On活性化();
1299 r直前のステ = r現在のステ;
1300 r現在のステ = stage選曲;
1301
1302 #region [ プラグイン Onステージ変更() の呼び出し ]
1303 //---------------------
1304 foreach( STPlugin pg in this.listプラグイン )
1305 {
1306 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1307 pg.plugin.Onステジ変更();
1308 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1309 }
1310 //---------------------
1311 #endregion
1312
1313 this.tガベジコレクションを実行する();
1314 }
1315 break;
1316 //-----------------------------
1317 #endregion
1318
1319 case (int) E演奏画面の戻り値.ステジ失敗:
1320 #region [ 演奏失敗(StageFailed) ]
1321 //-----------------------------
1322 scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Stage failed" );
1323
1324 #region [ プラグイン On演奏失敗() の呼び出し ]
1325 //---------------------
1326 foreach( STPlugin pg in this.listプラグイン )
1327 {
1328 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1329 pg.plugin.On演奏失敗( scoreIni );
1330 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1331 }
1332 //---------------------
1333 #endregion
1334
1335 DTX.t全チップの再生停止();
1336 DTX.On非活性化();
1337 r現在のステ.On非活性化();
1338 if( bコンパクトモ )
1339 {
1340 base.Window.Close();
1341 }
1342 else
1343 {
1344 Trace.TraceInformation( "----------------------" );
1345 Trace.TraceInformation( "■ 選曲" );
1346 stage選曲.On活性化();
1347 r直前のステ = r現在のステ;
1348 r現在のステ = stage選曲;
1349
1350 #region [ プラグイン Onステージ変更() の呼び出し ]
1351 //---------------------
1352 foreach( STPlugin pg in this.listプラグイン )
1353 {
1354 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1355 pg.plugin.Onステジ変更();
1356 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1357 }
1358 //---------------------
1359 #endregion
1360
1361 this.tガベジコレクションを実行する();
1362 }
1363 break;
1364 //-----------------------------
1365 #endregion
1366
1367 case (int) E演奏画面の戻り値.ステジクリア:
1368 #region [ 演奏クリア ]
1369 //-----------------------------
1370 CScoreIni.C演奏記録 c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass;
1371 CDTX.CChip[] chipArray = new CDTX.CChip[10];
1372 if( ConfigIni.bギタレボモ )
1373 {
1374 stage演奏ギタ画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass );
1375 }
1376 else
1377 {
1378 stage演奏ドラム画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass, out chipArray );
1379 }
1380
1381 if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.24 yyagi Gt/Bsを入れ替えていたなら、演奏結果も入れ替える
1382 {
1383 CScoreIni.C演奏記録 t;
1384 t = c演奏記録_Guitar;
1385 c演奏記録_Guitar = c演奏記録_Bass;
1386 c演奏記録_Bass = t;
1387
1388 CDTXMania.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す
1389 CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // #24415 2011.2.27 yyagi
1390 // リザルト集計時のみ、Auto系のフラグも元に戻す。
1391 // これを戻すのは、リザルト集計後。
1392 } // "case CStage.Eステージ.結果:"のところ。
1393
1394 double ps = 0.0, gs = 0.0;
1395 if ( !c演奏記録_Drums.bAUTOである && c演奏記録_Drums.n全チップ数 > 0) {
1396 ps = c演奏記録_Drums.db演奏型スキル値;
1397 gs = c演奏記録_Drums.dbム型スキル値;
1398 }
1399 else if ( !c演奏記録_Guitar.bAUTOである && c演奏記録_Guitar.n全チップ数 > 0) {
1400 ps = c演奏記録_Guitar.db演奏型スキル値;
1401 gs = c演奏記録_Guitar.dbム型スキル値;
1402 }
1403 else
1404 {
1405 ps = c演奏記録_Bass.db演奏型スキル値;
1406 gs = c演奏記録_Bass.dbム型スキル値;
1407 }
1408 string str = "Cleared";
1409 switch( CScoreIni.t総合ランク値を計算して返す( c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass ) )
1410 {
1411 case (int)CScoreIni.ERANK.SS:
1412 str = string.Format( "Cleared (SS: {0:F2})", ps );
1413 break;
1414
1415 case (int) CScoreIni.ERANK.S:
1416 str = string.Format( "Cleared (S: {0:F2})", ps );
1417 break;
1418
1419 case (int) CScoreIni.ERANK.A:
1420 str = string.Format( "Cleared (A: {0:F2})", ps );
1421 break;
1422
1423 case (int) CScoreIni.ERANK.B:
1424 str = string.Format( "Cleared (B: {0:F2})", ps );
1425 break;
1426
1427 case (int) CScoreIni.ERANK.C:
1428 str = string.Format( "Cleared (C: {0:F2})", ps );
1429 break;
1430
1431 case (int) CScoreIni.ERANK.D:
1432 str = string.Format( "Cleared (D: {0:F2})", ps );
1433 break;
1434
1435 case (int) CScoreIni.ERANK.E:
1436 str = string.Format( "Cleared (E: {0:F2})", ps );
1437 break;
1438
1439 case (int)CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1440 str = "Cleared (No chips)";
1441 break;
1442 }
1443
1444 scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( str );
1445
1446 #region [ プラグイン On演奏クリア() の呼び出し ]
1447 //---------------------
1448 foreach( STPlugin pg in this.listプラグイン )
1449 {
1450 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1451 pg.plugin.On演奏クリア( scoreIni );
1452 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1453 }
1454 //---------------------
1455 #endregion
1456
1457 r現在のステ.On非活性化();
1458 Trace.TraceInformation( "----------------------" );
1459 Trace.TraceInformation( "■ 結果" );
1460 stage結果.st演奏記録.Drums = c演奏記録_Drums;
1461 stage結果.st演奏記録.Guitar = c演奏記録_Guitar;
1462 stage結果.st演奏記録.Bass = c演奏記録_Bass;
1463 stage結果.r空うちドラムチップ = chipArray;
1464 stage結果.On活性化();
1465 r直前のステ = r現在のステ;
1466 r現在のステ = stage結果;
1467
1468 #region [ プラグイン Onステージ変更() の呼び出し ]
1469 //---------------------
1470 foreach( STPlugin pg in this.listプラグイン )
1471 {
1472 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1473 pg.plugin.Onステジ変更();
1474 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1475 }
1476 //---------------------
1477 #endregion
1478
1479 break;
1480 //-----------------------------
1481 #endregion
1482 }
1483 //-----------------------------
1484 #endregion
1485 break;
1486
1487 case CStage.Eステ.結果:
1488 #region [ *** ]
1489 //-----------------------------
1490 if( this.n進行描画の戻り値 != 0 )
1491 {
1492 if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1493 {
1494 CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
1495 }
1496
1497 DTX.t全チップの再生一時停止();
1498 DTX.On非活性化();
1499 r現在のステ.On非活性化();
1500 if( !bコンパクトモ )
1501 {
1502 Trace.TraceInformation( "----------------------" );
1503 Trace.TraceInformation( "■ 選曲" );
1504 stage選曲.On活性化();
1505 r直前のステ = r現在のステ;
1506 r現在のステ = stage選曲;
1507
1508 foreach( STPlugin pg in this.listプラグイン )
1509 {
1510 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1511 pg.plugin.Onステジ変更();
1512 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1513 }
1514
1515 this.tガベジコレクションを実行する();
1516 }
1517 else
1518 {
1519 base.Window.Close();
1520 }
1521 }
1522 //-----------------------------
1523 #endregion
1524 break;
1525
1526 case CStage.Eステ.ChangeSkin:
1527 #region [ *** ]
1528 //-----------------------------
1529 if ( this.n進行描画の戻り値 != 0 )
1530 {
1531 r現在のステ.On非活性化();
1532 Trace.TraceInformation( "----------------------" );
1533 Trace.TraceInformation( "■ 選曲" );
1534 stage選曲.On活性化();
1535 r直前のステ = r現在のステ;
1536 r現在のステ = stage選曲;
1537 this.tガベジコレクションを実行する();
1538 }
1539 //-----------------------------
1540 #endregion
1541 break;
1542
1543 case CStage.Eステ.終了:
1544 #region [ *** ]
1545 //-----------------------------
1546 if( this.n進行描画の戻り値 != 0 )
1547 {
1548 base.Exit();
1549 }
1550 //-----------------------------
1551 #endregion
1552 break;
1553 }
1554 }
1555 this.Device.EndScene(); // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
1556 // (つまり、Present()は、Draw()完了後に実行される)
1557 #if !GPUFlushAfterPresent
1558 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
1559 #endif
1560 if ( Sound管理.GetCurrentSoundDeviceType() != "DirectSound" )
1561 {
1562 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
1563 }
1564
1565
1566 #region [ 全画面・ウインドウ切り替え ]
1567 if ( this.b次のタイミングで全画面・ウィンドウ切り替えを行う )
1568 {
1569 ConfigIni.b全画面モ = !ConfigIni.b全画面モ;
1570 app.t全画面・ウィンドウモド切り替え();
1571 this.b次のタイミングで全画面・ウィンドウ切り替えを行う = false;
1572 }
1573 #endregion
1574 #region [ 垂直基線同期切り替え ]
1575 if ( this.b次のタイミングで垂直帰線同期切り替えを行う )
1576 {
1577 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
1578 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
1579 DeviceSettings currentSettings = app.GraphicsDeviceManager.CurrentSettings;
1580 currentSettings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1581 app.GraphicsDeviceManager.ChangeDevice( currentSettings );
1582 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
1583 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
1584 if (bIsMaximized)
1585 {
1586 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
1587 }
1588 }
1589 #endregion
1590 }
1591
1592
1593 // その他
1594
1595 #region [ 汎用ヘルパー ]
1596 //-----------------
1597 public static CTexture tテクスチャの生成( string fileName )
1598 {
1599 return tテクスチャの生成( fileName, false );
1600 }
1601 public static CTexture tテクスチャの生成( string fileName, bool b黒を透過する )
1602 {
1603 if ( app == null )
1604 {
1605 return null;
1606 }
1607 try
1608 {
1609 return new CTexture( app.Device, fileName, TextureFormat, b黒を透過する );
1610 }
1611 catch ( CTextureCreateFailedException )
1612 {
1613 Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1614 return null;
1615 }
1616 catch ( FileNotFoundException )
1617 {
1618 Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1619 return null;
1620 }
1621 }
1622 public static void tテクスチャの解放( ref CTexture tx )
1623 {
1624 if( tx != null )
1625 CDTXMania.t安全にDisposeする( ref tx );
1626 }
1627 public static void tテクスチャの解放( ref CTextureAf tx )
1628 {
1629 CDTXMania.t安全にDisposeする( ref tx );
1630 }
1631 public static CTexture tテクスチャの生成( byte[] txData )
1632 {
1633 return tテクスチャの生成( txData, false );
1634 }
1635 public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
1636 {
1637 if ( app == null )
1638 {
1639 return null;
1640 }
1641 try
1642 {
1643 return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
1644 }
1645 catch ( CTextureCreateFailedException )
1646 {
1647 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1648 return null;
1649 }
1650 }
1651
1652 public static CTexture tテクスチャの生成( Bitmap bitmap )
1653 {
1654 return tテクスチャの生成( bitmap, false );
1655 }
1656 public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
1657 {
1658 if ( app == null )
1659 {
1660 return null;
1661 }
1662 try
1663 {
1664 return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
1665 }
1666 catch ( CTextureCreateFailedException )
1667 {
1668 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1669 return null;
1670 }
1671 }
1672
1673 public static CTexture tテクスチャを生成する(int width, int height)
1674 {
1675 try
1676 {
1677 return new CTexture(CDTXMania.App.D3D9Device, width, height, CDTXMania.TextureFormat);
1678 }
1679 catch
1680 {
1681 Trace.TraceError("空のテクスチャ({0}x{1})の生成に失敗しました。", width, height);
1682 return null;
1683 }
1684 }
1685 public static CTextureAf tテクスチャの生成Af( string fileName )
1686 {
1687 return tテクスチャの生成Af( fileName, false );
1688 }
1689 public static CTextureAf tテクスチャの生成Af( string fileName, bool b黒を透過する )
1690 {
1691 if ( app == null )
1692 {
1693 return null;
1694 }
1695 try
1696 {
1697 return new CTextureAf( app.Device, fileName, TextureFormat, b黒を透過する );
1698 }
1699 catch ( CTextureCreateFailedException )
1700 {
1701 Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1702 return null;
1703 }
1704 catch ( FileNotFoundException )
1705 {
1706 Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1707 return null;
1708 }
1709 }
1710
1711 public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する(string fileName, IntPtr hWnd, bool bディオレンダラなし)
1712 {
1713 CDirectShow ds = null;
1714 if( File.Exists( fileName ) )
1715 {
1716 try
1717 {
1718 ds = new CDirectShow(fileName, hWnd, bディオレンダラなし);
1719 }
1720 catch (FileNotFoundException)
1721 {
1722 Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1723 ds = null; // Dispose はコンストラクタ内で実施済み
1724 }
1725 catch
1726 {
1727 Trace.TraceError("DirectShow の生成に失敗しました。[{0}]", fileName);
1728 ds = null; // Dispose はコンストラクタ内で実施済み
1729 }
1730 }
1731 else
1732 {
1733 Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1734 return null;
1735 }
1736
1737 return ds;
1738 }
1739
1740 /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
1741 public static void t安全にDisposeする<T>( ref T obj )
1742 {
1743 if ( obj == null )
1744 return;
1745
1746 var d = obj as IDisposable;
1747
1748 if ( d != null )
1749 d.Dispose();
1750
1751 obj = default( T );
1752 }
1753 //-----------------
1754 #endregion
1755 #region [ private ]
1756 //-----------------
1757 private bool bマウスカソル表示中 = true;
1758 public bool bウィンドウがアクティブである = true;
1759 private bool b終了処理完了済み;
1760 private static CDTX dtx;
1761 private List<CActivity> listトップレベルActivities;
1762 public int n進行描画の戻り値;
1763 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
1764 private string strWindowTitle
1765 {
1766 get
1767 {
1768 if ( DTXVmode.Enabled )
1769 {
1770 return "DTXViewer release " + VERSION;
1771 }
1772 else
1773 {
1774 return "DTXMania .NET style release " + VERSION;
1775 }
1776 }
1777 }
1778 private CSound previewSound;
1779
1780 private void t起動処理()
1781 {
1782 #region [ strEXEのあるフォルダを決定する ]
1783 //-----------------
1784 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
1785 #if DEBUG
1786 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
1787 #else
1788 strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
1789 #endif
1790 // END #23629 2010.11.13 from
1791 //-----------------
1792 #endregion
1793
1794 #region [ Config.ini の読込み ]
1795 //---------------------
1796 ConfigIni = new CConfigIni();
1797 string path = strEXEのあるフォルダ + "Config.ini";
1798 if( File.Exists( path ) )
1799 {
1800 try
1801 {
1802 ConfigIni.tファイルから読み込み( path );
1803 }
1804 catch
1805 {
1806 //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
1807 }
1808 }
1809 this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
1810 // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
1811
1812 //---------------------
1813 #endregion
1814 #region [ ログ出力開始 ]
1815 //---------------------
1816 Trace.AutoFlush = true;
1817 if( ConfigIni.bログ出力 )
1818 {
1819 try
1820 {
1821 Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( strEXEのあるフォルダ + "DTXManiaLog.txt", false, Encoding.GetEncoding( "shift-jis" ) ) ) );
1822 }
1823 catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
1824 {
1825 int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
1826 string[] mes_writeErr = {
1827 "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
1828 "Failed to write DTXManiaLog.txt. Please set it writable and try again."
1829 };
1830 MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
1831 Environment.Exit(1);
1832 }
1833 }
1834 Trace.WriteLine("");
1835 Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
1836 Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
1837 Trace.WriteLine( "" );
1838 Trace.TraceInformation( "----------------------" );
1839 Trace.TraceInformation( "■ アプリケーションの初期化" );
1840 Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
1841 Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
1842 Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
1843 //---------------------
1844 #endregion
1845 #region [ DTXVmodeクラス の初期化 ]
1846 //---------------------
1847 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
1848 //Trace.Indent();
1849 try
1850 {
1851 DTXVmode = new CDTXVmode();
1852 DTXVmode.Enabled = false;
1853 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
1854 }
1855 finally
1856 {
1857 //Trace.Unindent();
1858 }
1859 //---------------------
1860 #endregion
1861 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
1862 //---------------------
1863 bコンパクトモ = false;
1864 strコンパクトモドファイル = "";
1865 string[] commandLineArgs = Environment.GetCommandLineArgs();
1866 if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
1867 {
1868 bコンパクトモ = true;
1869 string arg = "";
1870
1871 for ( int i = 1; i < commandLineArgs.Length; i++ )
1872 {
1873 if ( i != 1 )
1874 {
1875 arg += " " + "\"" + commandLineArgs[ i ] + "\"";
1876 }
1877 else
1878 {
1879 arg += commandLineArgs[ i ];
1880 }
1881 }
1882 DTXVmode.ParseArguments( arg );
1883
1884 if ( DTXVmode.Enabled )
1885 {
1886 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
1887 strコンパクトモドファイル = DTXVmode.filename;
1888 switch( DTXVmode.soundDeviceType )
1889 {
1890 case ESoundDeviceType.DirectSound:
1891 ConfigIni.nSoundDeviceType = 0;
1892 break;
1893 case ESoundDeviceType.ExclusiveWASAPI:
1894 ConfigIni.nSoundDeviceType = 2;
1895 break;
1896 case ESoundDeviceType.ASIO:
1897 ConfigIni.nSoundDeviceType = 1;
1898 ConfigIni.nASIODevice = DTXVmode.nASIOdevice;
1899 break;
1900 }
1901
1902 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1903 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1904 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1905 CDTXMania.ConfigIni.bGuitar有効 = true;
1906 }
1907 else // 通常のコンパクトモード
1908 {
1909 strコンパクトモドファイル = commandLineArgs[ 1 ];
1910 }
1911
1912 if ( !File.Exists( strコンパクトモドファイル ) ) // #32985 2014.1.23 yyagi
1913 {
1914 Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモドファイル );
1915 #if DEBUG
1916 Environment.Exit( -1 );
1917 #else
1918 throw new FileNotFoundException( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモドファイル );
1919 #endif
1920 }
1921 if ( DTXVmode.Enabled )
1922 {
1923 Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモドファイル );
1924 }
1925 else
1926 {
1927 Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモドファイル );
1928 }
1929 }
1930 //---------------------
1931 #endregion
1932
1933 #region [ ウィンドウ初期化 ]
1934 //---------------------
1935 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1936 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1937
1938 base.Window.Text = this.strWindowTitle; // 事前にDTXVmodeの実体を作っておくこと
1939
1940
1941 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1942 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1943
1944 base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #34510 yyagi 2010.10.31 to change window size got from Config.ini
1945 #if !WindowedFullscreen
1946 if (!ConfigIni.bウィンドウモ) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
1947 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
1948 #endif
1949 currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );
1950 #if !WindowedFullscreen
1951 }
1952 #endif
1953 base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
1954 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
1955 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
1956 base.Window.ShowIcon = true;
1957 base.Window.Icon = Properties.Resources.dtx;
1958 base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
1959 base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
1960 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
1961 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
1962 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
1963 base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
1964 //---------------------
1965 #endregion
1966 #region [ Direct3D9Exを使うかどうか判定 ]
1967 #endregion
1968 #region [ Direct3D9 デバイスの生成 ]
1969 //---------------------
1970 DeviceSettings settings = new DeviceSettings();
1971 #if WindowedFullscreen
1972 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
1973 #else
1974 settings.Windowed = ConfigIni.bウィンドウモ;
1975 #endif
1976 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
1977 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
1978 // settings.BackBufferCount = 3;
1979 settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1980 // settings.BackBufferFormat = Format.A8R8G8B8;
1981 // settings.MultisampleType = MultisampleType.FourSamples;
1982 // settings.MultisampleQuality = 4;
1983 // settings.MultisampleType = MultisampleType.None;
1984 // settings.MultisampleQuality = 0;
1985
1986 try
1987 {
1988 base.GraphicsDeviceManager.ChangeDevice(settings);
1989 }
1990 catch (DeviceCreationException e)
1991 {
1992 Trace.TraceError(e.ToString());
1993 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1994 Environment.Exit(-1);
1995 }
1996
1997 base.IsFixedTimeStep = false;
1998 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
1999 base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
2000 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォカス時スリms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
2001 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
2002 #if WindowedFullscreen
2003 this.t全画面・ウィンドウモド切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
2004 #endif
2005 actFlushGPU = new CActFlushGPU();
2006 //---------------------
2007 #endregion
2008
2009 DTX = null;
2010
2011 #region [ Skin の初期化 ]
2012 //---------------------
2013 Trace.TraceInformation( "スキンの初期化を行います。" );
2014 Trace.Indent();
2015 try
2016 {
2017 Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
2018 CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
2019 Trace.TraceInformation( "スキンの初期化を完了しました。" );
2020 }
2021 catch
2022 {
2023 Trace.TraceInformation( "スキンの初期化に失敗しました。" );
2024 throw;
2025 }
2026 finally
2027 {
2028 Trace.Unindent();
2029 }
2030 //---------------------
2031 #endregion
2032 #region [ Timer の初期化 ]
2033 //---------------------
2034 Trace.TraceInformation( "タイマの初期化を行います。" );
2035 Trace.Indent();
2036 try
2037 {
2038 Timer = new CTimer( CTimer.E種別.MultiMedia );
2039 Trace.TraceInformation( "タイマの初期化を完了しました。" );
2040 }
2041 finally
2042 {
2043 Trace.Unindent();
2044 }
2045 //---------------------
2046 #endregion
2047 #region [ FPS カウンタの初期化 ]
2048 //---------------------
2049 Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
2050 Trace.Indent();
2051 try
2052 {
2053 FPS = new CFPS();
2054 Trace.TraceInformation( "FPSカウンタを生成しました。" );
2055 }
2056 finally
2057 {
2058 Trace.Unindent();
2059 }
2060 //---------------------
2061 #endregion
2062 #region [ act文字コンソールの初期化 ]
2063 //---------------------
2064 Trace.TraceInformation( "文字コンソールの初期化を行います。" );
2065 Trace.Indent();
2066 try
2067 {
2068 act文字コンソ = new C文字コンソ();
2069 Trace.TraceInformation( "文字コンソールを生成しました。" );
2070 act文字コンソ.On活性化();
2071 Trace.TraceInformation( "文字コンソールを活性化しました。" );
2072 Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
2073 }
2074 catch( Exception exception )
2075 {
2076 Trace.TraceError( exception.Message );
2077 Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
2078 }
2079 finally
2080 {
2081 Trace.Unindent();
2082 }
2083 //---------------------
2084 #endregion
2085 #region [ Input管理 の初期化 ]
2086 //---------------------
2087 Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
2088 Trace.Indent();
2089 try
2090 {
2091 Input管理 = new CInput管理( base.Window.Handle );
2092 foreach( IInputDevice device in Input管理.list入力デバイス )
2093 {
2094 if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
2095 {
2096 int key = 0;
2097 while( ConfigIni.dicJoystick.ContainsKey( key ) )
2098 {
2099 key++;
2100 }
2101 ConfigIni.dicJoystick.Add( key, device.GUID );
2102 }
2103 }
2104 foreach( IInputDevice device2 in Input管理.list入力デバイス )
2105 {
2106 if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
2107 {
2108 foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
2109 {
2110 if( device2.GUID.Equals( pair.Value ) )
2111 {
2112 ( (CInputJoystick) device2 ).SetID( pair.Key );
2113 break;
2114 }
2115 }
2116 continue;
2117 }
2118 }
2119 Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
2120 }
2121 catch( Exception exception2 )
2122 {
2123 Trace.TraceError( exception2.Message );
2124 Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
2125 throw;
2126 }
2127 finally
2128 {
2129 Trace.Unindent();
2130 }
2131 //---------------------
2132 #endregion
2133 #region [ Pad の初期化 ]
2134 //---------------------
2135 Trace.TraceInformation( "パッドの初期化を行います。" );
2136 Trace.Indent();
2137 try
2138 {
2139 Pad = new CPad( ConfigIni, Input管理 );
2140 Trace.TraceInformation( "パッドの初期化を完了しました。" );
2141 }
2142 catch( Exception exception3 )
2143 {
2144 Trace.TraceError( exception3.Message );
2145 Trace.TraceError( "パッドの初期化に失敗しました。" );
2146 }
2147 finally
2148 {
2149 Trace.Unindent();
2150 }
2151 //---------------------
2152 #endregion
2153 #region [ Sound管理 の初期化 ]
2154 //---------------------
2155 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
2156 Trace.Indent();
2157 try
2158 {
2159 {
2160 ESoundDeviceType soundDeviceType;
2161 switch (CDTXMania.ConfigIni.nSoundDeviceType)
2162 {
2163 case 0:
2164 soundDeviceType = ESoundDeviceType.DirectSound;
2165 break;
2166 case 1:
2167 soundDeviceType = ESoundDeviceType.ASIO;
2168 break;
2169 case 2:
2170 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
2171 break;
2172 default:
2173 soundDeviceType = ESoundDeviceType.Unknown;
2174 break;
2175 }
2176 Sound管理 = new CSound管理( base.Window.Handle,
2177 soundDeviceType,
2178 CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
2179 //CDTXMania.ConfigIni.nASIOBufferSizeMs,
2180 0,
2181 CDTXMania.ConfigIni.nASIODevice
2182 );
2183 ShowWindowTitleWithSoundType();
2184 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
2185 Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;
2186 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;
2187 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
2188 }
2189 }
2190 catch (Exception e)
2191 {
2192 Trace.TraceError(e.Message);
2193 throw;
2194 }
2195 finally
2196 {
2197 Trace.Unindent();
2198 }
2199 //---------------------
2200 #endregion
2201 #region [ Songs管理 の初期化 ]
2202 //---------------------
2203 Trace.TraceInformation( "曲リストの初期化を行います。" );
2204 Trace.Indent();
2205 try
2206 {
2207 Songs管理 = new CSongs管理();
2208 // Songs管理_裏読 = new CSongs管理();
2209 EnumSongs = new CEnumSongs();
2210 actEnumSongs = new CActEnumSongs();
2211 Trace.TraceInformation( "曲リストの初期化を完了しました。" );
2212 }
2213 catch( Exception e )
2214 {
2215 Trace.TraceError( e.Message );
2216 Trace.TraceError( "曲リストの初期化に失敗しました。" );
2217 }
2218 finally
2219 {
2220 Trace.Unindent();
2221 }
2222 //---------------------
2223 #endregion
2224 #region [ CAvi の初期化 ]
2225 //---------------------
2226 CAvi.t初期化();
2227 //---------------------
2228 #endregion
2229 #region [ Random の初期化 ]
2230 //---------------------
2231 Random = new Random( (int) Timer.nシステム時刻 );
2232 //---------------------
2233 #endregion
2234 #region [ ステージの初期化 ]
2235 //---------------------
2236 r現在のステ = null;
2237 r直前のステ = null;
2238 stage起動 = new CStage起動();
2239 stageタイトル = new CStageタイトル();
2240 stageオプション = new CStageオプション();
2241 stageコンフィグ = new CStageコンフィグ();
2242 stage選曲 = new CStage選曲();
2243 stage曲読み込み = new CStage曲読み込み();
2244 stage演奏ドラム画面 = new CStage演奏ドラム画面();
2245 stage演奏ギタ画面 = new CStage演奏ギタ画面();
2246 stage結果 = new CStage結果();
2247 stageChangeSkin = new CStageChangeSkin();
2248 stage終了 = new CStage終了();
2249 this.listトップレベルActivities = new List<CActivity>();
2250 this.listトップレベルActivities.Add( actEnumSongs );
2251 this.listトップレベルActivities.Add( act文字コンソ );
2252 this.listトップレベルActivities.Add( stage起動 );
2253 this.listトップレベルActivities.Add( stageタイトル );
2254 this.listトップレベルActivities.Add( stageオプション );
2255 this.listトップレベルActivities.Add( stageコンフィグ );
2256 this.listトップレベルActivities.Add( stage選曲 );
2257 this.listトップレベルActivities.Add( stage曲読み込み );
2258 this.listトップレベルActivities.Add( stage演奏ドラム画面 );
2259 this.listトップレベルActivities.Add( stage演奏ギタ画面 );
2260 this.listトップレベルActivities.Add( stage結果 );
2261 this.listトップレベルActivities.Add( stageChangeSkin );
2262 this.listトップレベルActivities.Add( stage終了 );
2263 this.listトップレベルActivities.Add( actFlushGPU);
2264 //---------------------
2265 #endregion
2266 #region [ プラグインの検索と生成 ]
2267 //---------------------
2268 PluginHost = new CPluginHost();
2269
2270 Trace.TraceInformation( "プラグインの検索と生成を行います。" );
2271 Trace.Indent();
2272 try
2273 {
2274 this.tプラグイン検索と生成();
2275 Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
2276 }
2277 finally
2278 {
2279 Trace.Unindent();
2280 }
2281 //---------------------
2282 #endregion
2283 #region [ プラグインの初期化 ]
2284 //---------------------
2285 if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
2286 {
2287 Trace.TraceInformation( "プラグインの初期化を行います。" );
2288 Trace.Indent();
2289 try
2290 {
2291 foreach( STPlugin st in this.listプラグイン )
2292 {
2293 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2294 st.plugin.On初期化( this.PluginHost );
2295 st.plugin.OnManagedリソスの作成();
2296 st.plugin.OnUnmanagedリソスの作成();
2297 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2298 }
2299 Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
2300 }
2301 catch
2302 {
2303 Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
2304 throw;
2305 }
2306 finally
2307 {
2308 Trace.Unindent();
2309 }
2310 }
2311
2312 //---------------------
2313 #endregion
2314
2315
2316 Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );
2317
2318 #region [ 最初のステージの起動 ]
2319 //---------------------
2320 Trace.TraceInformation("----------------------");
2321 Trace.TraceInformation("■ 起動");
2322
2323 if (CDTXMania.bコンパクトモ)
2324 {
2325 r現在のステ = stage曲読み込み;
2326 }
2327 else
2328 {
2329 r現在のステ = stage起動;
2330 }
2331 r現在のステ.On活性化();
2332 //---------------------
2333 #endregion
2334 }
2335 public void ShowWindowTitleWithSoundType()
2336 {
2337 string delay = "";
2338 if (Sound管理.GetCurrentSoundDeviceType() != "DirectSound")
2339 {
2340 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2341 }
2342 base.Window.Text = strWindowTitle + " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2343 }
2344
2345 private void t終了処理()
2346 {
2347 if( !this.b終了処理完了済み )
2348 {
2349 Trace.TraceInformation( "----------------------" );
2350 Trace.TraceInformation( "■ アプリケーションの終了" );
2351 #region [ 曲検索の終了処理 ]
2352 //---------------------
2353 if ( actEnumSongs != null )
2354 {
2355 Trace.TraceInformation( "曲検索actの終了処理を行います。" );
2356 Trace.Indent();
2357 try
2358 {
2359 actEnumSongs.On非活性化();
2360 actEnumSongs= null;
2361 Trace.TraceInformation( "曲検索actの終了処理を完了しました。" );
2362 }
2363 catch ( Exception e )
2364 {
2365 Trace.TraceError( e.Message );
2366 Trace.TraceError( "曲検索actの終了処理に失敗しました。" );
2367 }
2368 finally
2369 {
2370 Trace.Unindent();
2371 }
2372 }
2373 //---------------------
2374 #endregion
2375 #region [ 現在のステージの終了処理 ]
2376 //---------------------
2377 if( CDTXMania.r現在のステ != null && CDTXMania.r現在のステ.b活性化してる ) // #25398 2011.06.07 MODIFY FROM
2378 {
2379 Trace.TraceInformation( "現在のステージを終了します。" );
2380 Trace.Indent();
2381 try
2382 {
2383 r現在のステ.On非活性化();
2384 Trace.TraceInformation( "現在のステージの終了処理を完了しました。" );
2385 }
2386 finally
2387 {
2388 Trace.Unindent();
2389 }
2390 }
2391 //---------------------
2392 #endregion
2393 #region [ プラグインの終了処理 ]
2394 //---------------------
2395 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2396 {
2397 Trace.TraceInformation( "すべてのプラグインを終了します。" );
2398 Trace.Indent();
2399 try
2400 {
2401 foreach( STPlugin st in this.listプラグイン )
2402 {
2403 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2404 st.plugin.OnUnmanagedリソスの解放();
2405 st.plugin.OnManagedリソスの解放();
2406 st.plugin.On終了();
2407 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2408 }
2409 PluginHost = null;
2410 Trace.TraceInformation( "すべてのプラグインの終了処理を完了しました。" );
2411 }
2412 finally
2413 {
2414 Trace.Unindent();
2415 }
2416 }
2417 //---------------------
2418 #endregion
2419 #region [ 曲リストの終了処理 ]
2420 //---------------------
2421 if (Songs管理 != null)
2422 {
2423 Trace.TraceInformation( "曲リストの終了処理を行います。" );
2424 Trace.Indent();
2425 try
2426 {
2427 Songs管理 = null;
2428 Trace.TraceInformation( "曲リストの終了処理を完了しました。" );
2429 }
2430 catch( Exception exception )
2431 {
2432 Trace.TraceError( exception.Message );
2433 Trace.TraceError( "曲リストの終了処理に失敗しました。" );
2434 }
2435 finally
2436 {
2437 Trace.Unindent();
2438 }
2439 }
2440 CAvi.t終了();
2441 //---------------------
2442 #endregion
2443 #region [ スキンの終了処理 ]
2444 //---------------------
2445 if (Skin != null)
2446 {
2447 Trace.TraceInformation( "スキンの終了処理を行います。" );
2448 Trace.Indent();
2449 try
2450 {
2451 Skin.Dispose();
2452 Skin = null;
2453 Trace.TraceInformation( "スキンの終了処理を完了しました。" );
2454 }
2455 catch( Exception exception2 )
2456 {
2457 Trace.TraceError( exception2.Message );
2458 Trace.TraceError( "スキンの終了処理に失敗しました。" );
2459 }
2460 finally
2461 {
2462 Trace.Unindent();
2463 }
2464 }
2465 //---------------------
2466 #endregion
2467 #region [ DirectSoundの終了処理 ]
2468 //---------------------
2469 if (Sound管理 != null)
2470 {
2471 Trace.TraceInformation( "DirectSound の終了処理を行います。" );
2472 Trace.Indent();
2473 try
2474 {
2475 Sound管理.Dispose();
2476 Sound管理 = null;
2477 Trace.TraceInformation( "DirectSound の終了処理を完了しました。" );
2478 }
2479 catch( Exception exception3 )
2480 {
2481 Trace.TraceError( exception3.Message );
2482 Trace.TraceError( "DirectSound の終了処理に失敗しました。" );
2483 }
2484 finally
2485 {
2486 Trace.Unindent();
2487 }
2488 }
2489 //---------------------
2490 #endregion
2491 #region [ パッドの終了処理 ]
2492 //---------------------
2493 if (Pad != null)
2494 {
2495 Trace.TraceInformation( "パッドの終了処理を行います。" );
2496 Trace.Indent();
2497 try
2498 {
2499 Pad = null;
2500 Trace.TraceInformation( "パッドの終了処理を完了しました。" );
2501 }
2502 catch( Exception exception4 )
2503 {
2504 Trace.TraceError( exception4.Message );
2505 Trace.TraceError( "パッドの終了処理に失敗しました。" );
2506 }
2507 finally
2508 {
2509 Trace.Unindent();
2510 }
2511 }
2512 //---------------------
2513 #endregion
2514 #region [ DirectInput, MIDI入力の終了処理 ]
2515 //---------------------
2516 if (Input管理 != null)
2517 {
2518 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を行います。" );
2519 Trace.Indent();
2520 try
2521 {
2522 Input管理.Dispose();
2523 Input管理 = null;
2524 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を完了しました。" );
2525 }
2526 catch( Exception exception5 )
2527 {
2528 Trace.TraceError( exception5.Message );
2529 Trace.TraceError( "DirectInput, MIDI入力の終了処理に失敗しました。" );
2530 }
2531 finally
2532 {
2533 Trace.Unindent();
2534 }
2535 }
2536 //---------------------
2537 #endregion
2538 #region [ 文字コンソールの終了処理 ]
2539 //---------------------
2540 if (act文字コンソ != null)
2541 {
2542 Trace.TraceInformation( "文字コンソールの終了処理を行います。" );
2543 Trace.Indent();
2544 try
2545 {
2546 act文字コンソ.On非活性化();
2547 act文字コンソ = null;
2548 Trace.TraceInformation( "文字コンソールの終了処理を完了しました。" );
2549 }
2550 catch( Exception exception6 )
2551 {
2552 Trace.TraceError( exception6.Message );
2553 Trace.TraceError( "文字コンソールの終了処理に失敗しました。" );
2554 }
2555 finally
2556 {
2557 Trace.Unindent();
2558 }
2559 }
2560 //---------------------
2561 #endregion
2562 #region [ FPSカウンタの終了処理 ]
2563 //---------------------
2564 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2565 Trace.Indent();
2566 try
2567 {
2568 if( FPS != null )
2569 {
2570 FPS = null;
2571 }
2572 Trace.TraceInformation( "FPSカウンタの終了処理を完了しました。" );
2573 }
2574 finally
2575 {
2576 Trace.Unindent();
2577 }
2578 //---------------------
2579 #endregion
2580
2581 // ct.Dispose();
2582
2583 #region [ タイマの終了処理 ]
2584 //---------------------
2585 Trace.TraceInformation("タイマの終了処理を行います。");
2586 Trace.Indent();
2587 try
2588 {
2589 if( Timer != null )
2590 {
2591 Timer.Dispose();
2592 Timer = null;
2593
2594 Trace.TraceInformation( "タイマの終了処理を完了しました。" );
2595 }
2596 else
2597 {
2598 Trace.TraceInformation( "タイマは使用されていません。" );
2599 }
2600 }
2601 finally
2602 {
2603 Trace.Unindent();
2604 }
2605 //---------------------
2606 #endregion
2607 #region [ Config.iniの出力 ]
2608 //---------------------
2609 Trace.TraceInformation("Config.ini を出力します。");
2610 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2611 if ( ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped ) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2612 {
2613 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2614 }
2615 string str = strEXEのあるフォルダ + "Config.ini";
2616 Trace.Indent();
2617 try
2618 {
2619 if ( DTXVmode.Enabled )
2620 {
2621 DTXVmode.tUpdateConfigIni();
2622 Trace.TraceInformation( "DTXVモードの設定情報を、Config.iniに保存しました。" );
2623 }
2624 else
2625 {
2626 ConfigIni.t書き出し( str );
2627 Trace.TraceInformation( "保存しました。({0})", str );
2628 }
2629 }
2630 catch( Exception e )
2631 {
2632 Trace.TraceError( e.Message );
2633 Trace.TraceError( "Config.ini の出力に失敗しました。({0})", str );
2634 }
2635 finally
2636 {
2637 Trace.Unindent();
2638 }
2639 //---------------------
2640 #endregion
2641 #region [ DTXVmodeの終了処理 ]
2642 //---------------------
2643 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2644 //Trace.Indent();
2645 try
2646 {
2647 if ( DTXVmode != null )
2648 {
2649 DTXVmode = null;
2650 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2651 }
2652 else
2653 {
2654 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2655 }
2656 }
2657 finally
2658 {
2659 //Trace.Unindent();
2660 }
2661 //---------------------
2662 #endregion
2663 Trace.TraceInformation("アプリケーションの終了処理を完了しました。");
2664
2665
2666 this.b終了処理完了済み = true;
2667 }
2668 }
2669
2670 private CScoreIni tScoreIniBGMAdjustHistoryPlayCountを更新(string str新ヒストリ行)
2671 {
2672 bool bIsUpdatedDrums, bIsUpdatedGuitar, bIsUpdatedBass;
2673 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2674 CScoreIni ini = new CScoreIni( strFilename );
2675 if( !File.Exists( strFilename ) )
2676 {
2677 ini.stファイル.Title = DTX.TITLE;
2678 ini.stファイル.Name = DTX.strファイル名;
2679 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す( DTX.strファイル名の絶対パス );
2680 for( int i = 0; i < 6; i++ )
2681 {
2682 ini.stセクション[ i ].nPerfectになる範囲ms = nPerfect範囲ms;
2683 ini.stセクション[ i ].nGreatになる範囲ms = nGreat範囲ms;
2684 ini.stセクション[ i ].nGoodになる範囲ms = nGood範囲ms;
2685 ini.stセクション[ i ].nPoorになる範囲ms = nPoor範囲ms;
2686 }
2687 }
2688 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2689 CScoreIni.t更新条件を取得する( out bIsUpdatedDrums, out bIsUpdatedGuitar, out bIsUpdatedBass );
2690 if( bIsUpdatedDrums || bIsUpdatedGuitar || bIsUpdatedBass )
2691 {
2692 if( bIsUpdatedDrums )
2693 {
2694 ini.stファイル.PlayCountDrums++;
2695 }
2696 if( bIsUpdatedGuitar )
2697 {
2698 ini.stファイル.PlayCountGuitar++;
2699 }
2700 if( bIsUpdatedBass )
2701 {
2702 ini.stファイル.PlayCountBass++;
2703 }
2704 ini.tヒストリを追加する( str新ヒストリ行 );
2705 if( !bコンパクトモ )
2706 {
2707 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2708 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2709 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2710 for( int j = 0; j < ini.stファイル.History.Length; j++ )
2711 {
2712 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[ j ] = ini.stファイル.History[ j ];
2713 }
2714 }
2715 }
2716 if( ConfigIni.bScoreIniを出力する )
2717 {
2718 ini.t書き出し( strFilename );
2719 }
2720
2721 return ini;
2722 }
2723 private void tガベジコレクションを実行する()
2724 {
2725 GC.Collect();
2726 GC.WaitForPendingFinalizers();
2727 GC.Collect();
2728 GC.WaitForPendingFinalizers();
2729 }
2730 private void tプラグイン検索と生成()
2731 {
2732 this.listプラグイン = new List<STPlugin>();
2733
2734 string strIPluginActivityの名前 = typeof( IPluginActivity ).FullName;
2735 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2736
2737 this.t指定フォルダ内でのプラグイン検索と生成( strプラグインフォルダパス, strIPluginActivityの名前 );
2738
2739 if( this.listプラグイン.Count > 0 )
2740 Trace.TraceInformation( this.listプラグイン.Count + " 個のプラグインを読み込みました。" );
2741 }
2742 #region [ Windowイベント処理 ]
2743 private void t指定フォルダ内でのプラグイン検索と生成( string strプラグインフォルダパス, string strプラグイン型名 )
2744 {
2745 // 指定されたパスが存在しないとエラー
2746 if( !Directory.Exists( strプラグインフォルダパス ) )
2747 {
2748 Trace.TraceWarning( "プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")" );
2749 return;
2750 }
2751
2752 // (1) すべての *.dll について…
2753 string[] strDLLs = System.IO.Directory.GetFiles( strプラグインフォルダパス, "*.dll" );
2754 foreach( string dllName in strDLLs )
2755 {
2756 try
2757 {
2758 // (1-1) dll をアセンブリとして読み込む。
2759 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom( dllName );
2760
2761 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2762 foreach( Type t in asm.GetTypes() )
2763 {
2764 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2765 if( t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface( strプラグイン型名 ) != null )
2766 {
2767 // (1-4) クラス名からインスタンスを作成する
2768 var st = new STPlugin() {
2769 plugin = (IPluginActivity) asm.CreateInstance( t.FullName ),
2770 strプラグインフォルダ = Path.GetDirectoryName( dllName ),
2771 strアセンブリ簡易名 = asm.GetName().Name,
2772 Version = asm.GetName().Version,
2773 };
2774
2775 // (1-5) プラグインリストへ登録
2776 this.listプラグイン.Add( st );
2777 Trace.TraceInformation( "プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName( dllName ), st.strアセンブリ簡易名, st.Version.ToString() );
2778 }
2779 }
2780 }
2781 catch
2782 {
2783 Trace.TraceInformation( dllName + " からプラグインを生成することに失敗しました。スキップします。" );
2784 }
2785 }
2786
2787 // (2) サブフォルダがあれば再帰する
2788 string[] strDirs = Directory.GetDirectories( strプラグインフォルダパス, "*" );
2789 foreach( string dir in strDirs )
2790 this.t指定フォルダ内でのプラグイン検索と生成( dir + "\\", strプラグイン型名 );
2791 }
2792 //-----------------
2793 private void Window_ApplicationActivated(object sender, EventArgs e)
2794 {
2795 this.bApplicationActive = true;
2796 }
2797 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2798 {
2799 this.bApplicationActive = false;
2800 }
2801 private void Window_KeyDown(object sender, KeyEventArgs e)
2802 {
2803 if (e.KeyCode == Keys.Menu)
2804 {
2805 e.Handled = true;
2806 e.SuppressKeyPress = true;
2807 }
2808 else if ((e.KeyCode == Keys.Return) && e.Alt)
2809 {
2810 if (ConfigIni != null)
2811 {
2812 ConfigIni.bウィンドウモ = !ConfigIni.bウィンドウモ;
2813 this.t全画面・ウィンドウモド切り替え();
2814 }
2815 e.Handled = true;
2816 e.SuppressKeyPress = true;
2817 }
2818 else
2819 {
2820 for (int i = 0; i < 0x10; i++)
2821 {
2822 if (ConfigIni.KeyAssign.System.Capture[i]. > 0 &&
2823 e.KeyCode == DeviceConstantConverter.KeyToKeyCode((SlimDX.DirectInput.Key)ConfigIni.KeyAssign.System.Capture[i].))
2824 {
2825 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2826 string strFullPath =
2827 Path.Combine(CDTXMania.strEXEのあるフォルダ, "Capture_img");
2828 strFullPath = Path.Combine(strFullPath, DateTime.Now.ToString("yyyyMMddHHmmss") + ".png");
2829 SaveResultScreen(strFullPath);
2830 }
2831 }
2832 }
2833 }
2834 private void Window_MouseUp(object sender, MouseEventArgs e)
2835 {
2836 mb = e.Button;
2837 }
2838
2839 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
2840 {
2841 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
2842 {
2843 ConfigIni.bウィンドウモ = false;
2844 this.t全画面・ウィンドウモド切り替え();
2845 }
2846 }
2847 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
2848 {
2849 if (ConfigIni.bウィンドウモ)
2850 {
2851 ConfigIni.n初期ウィンドウ開始位置X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2852 ConfigIni.n初期ウィンドウ開始位置Y = base.Window.Location.Y; //
2853 }
2854
2855 ConfigIni.nウインドウwidth = (ConfigIni.bウィンドウモ) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
2856 ConfigIni.nウインドウheight = (ConfigIni.bウィンドウモ) ? base.Window.ClientSize.Height : currentClientSize.Height;
2857 }
2858 #endregion
2859
2860 //internal sealed class GCBeep // GC発生の度にbeep
2861 //{
2862 // ~GCBeep()
2863 // {
2864 // Console.Beep();
2865 // if ( !AppDomain.CurrentDomain.IsFinalizingForUnload()
2866 // && !Environment.HasShutdownStarted )
2867 // {
2868 // new GCBeep();
2869 // }
2870 // }
2871 //}
2872
2873 //-----------------
2874
2875 Stopwatch sw = new Stopwatch();
2876 List<double> swlist;
2877
2878 #endregion
2879 }
2880 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26