Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 116 - (hide annotations) (download)
Mon Jun 10 08:47:03 2013 UTC (10 years, 9 months ago) by kairera0467
File size: 96314 byte(s)
ver2.60a
#xxxxx XG風難易度パネルのままリリースしていたのを修正。
1 kairera0467 2 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 kairera0467 30 using DirectShowLib;
19 kairera0467 2
20     namespace DTXMania
21     {
22 kairera0467 32 internal class CDTXMania : Game
23 kairera0467 2 {
24     // プロパティ
25    
26 kairera0467 116 public static readonly string VERSION = "Ver2.60a(130610)";
27 kairera0467 2 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 kairera0467 32 private set;
46 kairera0467 2 }
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     public static string strSongDifficulyName
99     {
100     get;
101     set;
102     }
103     public static int nPerfect範囲ms
104     {
105     get
106     {
107     if( stage選曲.r確定された曲 != null )
108     {
109     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
110     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nPerfect範囲ms >= 0 ) )
111     {
112     return c曲リストノ.nPerfect範囲ms;
113     }
114     }
115     return ConfigIni.nヒット範囲ms.Perfect;
116     }
117     }
118     public static int nGreat範囲ms
119     {
120     get
121     {
122     if( stage選曲.r確定された曲 != null )
123     {
124     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
125     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nGreat範囲ms >= 0 ) )
126     {
127     return c曲リストノ.nGreat範囲ms;
128     }
129     }
130     return ConfigIni.nヒット範囲ms.Great;
131     }
132     }
133     public static int nGood範囲ms
134     {
135     get
136     {
137     if( stage選曲.r確定された曲 != null )
138     {
139     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
140     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nGood範囲ms >= 0 ) )
141     {
142     return c曲リストノ.nGood範囲ms;
143     }
144     }
145     return ConfigIni.nヒット範囲ms.Good;
146     }
147     }
148     public static int nPoor範囲ms
149     {
150     get
151     {
152     if( stage選曲.r確定された曲 != null )
153     {
154     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
155     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nPoor範囲ms >= 0 ) )
156     {
157     return c曲リストノ.nPoor範囲ms;
158     }
159     }
160     return ConfigIni.nヒット範囲ms.Poor;
161     }
162     }
163     public static CPad Pad
164     {
165     get;
166     private set;
167     }
168     public static Random Random
169     {
170     get;
171     private set;
172     }
173     public static CSkin Skin
174     {
175     get;
176     private set;
177     }
178     public static CSongs管理 Songs管理
179     {
180     get;
181     set; // 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
182     }
183     public static CEnumSongs EnumSongs
184     {
185     get;
186     private set;
187     }
188     public static CActEnumSongs actEnumSongs
189     {
190     get;
191     private set;
192     }
193     public static CActFlushGPU actFlushGPU
194     {
195     get;
196     private set;
197     }
198     public static CSound管理 Sound管理
199     {
200     get;
201     private set;
202     }
203     public static CStage起動 stage起動
204     {
205     get;
206     private set;
207     }
208     public static CStageタイトル stageタイトル
209     {
210     get;
211     private set;
212     }
213     public static CStageオプション stageオプション
214     {
215     get;
216     private set;
217     }
218     public static CStageコンフィグ stageコンフィグ
219     {
220     get;
221     private set;
222     }
223     public static CStage選曲 stage選曲
224     {
225     get;
226     private set;
227     }
228     public static CStage曲読み込み stage曲読み込み
229     {
230     get;
231     private set;
232     }
233     public static CStage演奏ギタ画面 stage演奏ギタ画面
234     {
235     get;
236     private set;
237     }
238     public static CStage演奏ドラム画面 stage演奏ドラム画面
239     {
240     get;
241     private set;
242     }
243     public static CStage演奏画面共通 stage演奏画面共通
244     {
245     get;
246     private set;
247     }
248     public static CStage結果 stage結果
249     {
250     get;
251     private set;
252     }
253     public static CStageChangeSkin stageChangeSkin
254     {
255     get;
256     private set;
257     }
258     public static CStage終了 stage終了
259     {
260     get;
261     private set;
262     }
263     public static CStage r現在のステ = null;
264     public static CStage r直前のステ = null;
265 kairera0467 45 public bool b汎用ムである = false;
266 kairera0467 2 public static string strEXEのあるフォルダ
267     {
268     get;
269     private set;
270     }
271     public static string strコンパクトモドファイル
272     {
273     get;
274     private set;
275     }
276     public static CTimer Timer
277     {
278     get;
279     private set;
280     }
281     public static Format TextureFormat = Format.A8R8G8B8;
282     internal static IPluginActivity act現在入力を占有中のプラグイン = null;
283     public bool bApplicationActive
284     {
285     get;
286     private set;
287     }
288     public bool b次のタイミングで垂直帰線同期切り替えを行う
289     {
290     get;
291     set;
292     }
293     public bool b次のタイミングで全画面・ウィンドウ切り替えを行う
294     {
295     get;
296     set;
297     }
298    
299     public Device Device
300     {
301     get { return base.GraphicsDeviceManager.Direct3D9.Device; }
302     }
303     public CPluginHost PluginHost
304     {
305     get;
306     private set;
307     }
308     public List<STPlugin> listプラグイン = new List<STPlugin>();
309     public struct STPlugin
310     {
311     public IPluginActivity plugin;
312     public string strプラグインフォルダ;
313     public string strアセンブリ簡易名;
314     public Version Version;
315     }
316     private static Size currentClientSize // #23510 2010.10.27 add yyagi to keep current window size
317     {
318     get;
319     set;
320     }
321 kairera0467 49 // public static CTimer ct;
322 kairera0467 2 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
323     {
324     get { return base.Window.Handle; }
325     }
326    
327     // コンストラクタ
328    
329     public CDTXMania()
330     {
331     CDTXMania.app = this;
332     this.t起動処理();
333     }
334    
335    
336     // メソッド
337    
338     public void t全画面・ウィンドウモド切り替え()
339     {
340 kairera0467 21 #if WindowedFullscreen
341     if ( ConfigIni != null )
342     #else
343 kairera0467 2 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
344     if ((ConfigIni != null) && (ConfigIni.bウィンドウモ != settings.Windowed))
345 kairera0467 21 #endif
346 kairera0467 2 {
347 kairera0467 21 #if !WindowedFullscreen
348 kairera0467 2 settings.Windowed = ConfigIni.bウィンドウモ;
349 kairera0467 21 #endif
350 kairera0467 2 if (ConfigIni.bウィンドウモ == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
351     {
352     currentClientSize = this.Window.ClientSize;
353     ConfigIni.nウインドウwidth = this.Window.ClientSize.Width;
354     ConfigIni.nウインドウheight = this.Window.ClientSize.Height;
355 kairera0467 49 // FDK.CTaskBar.ShowTaskBar( false );
356 kairera0467 2 }
357 kairera0467 21 #if !WindowedFullscreen
358 kairera0467 2 base.GraphicsDeviceManager.ChangeDevice(settings);
359 kairera0467 21 #endif
360 kairera0467 2 if (ConfigIni.bウィンドウモ == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
361     {
362 kairera0467 21 #if WindowedFullscreen
363 kairera0467 2 base.Window.ClientSize =
364     new Size(currentClientSize.Width, currentClientSize.Height);
365     }
366     }
367     if ( ConfigIni.bウィンドウモ == true ) // #23510 2010.10.27 yyagi: to resume window size from backuped value
368     {
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 kairera0467 21 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 kairera0467 49 // FDK.CTaskBar.ShowTaskBar( true );
379 kairera0467 21 }
380     #if WindowedFullscreen
381 kairera0467 2 else
382     {
383 kairera0467 21 app.Window.WindowState = FormWindowState.Normal;
384     app.Window.FormBorderStyle = FormBorderStyle.None;
385     app.Window.WindowState = FormWindowState.Maximized;
386 kairera0467 2 }
387 kairera0467 21 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 kairera0467 2 }
404    
405    
406     #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
407     /// <summary>
408     /// リザルト画像のキャプチャと保存。
409     /// </summary>
410     /// <param name="strFilename">保存するファイル名(フルパス)</param>
411     public bool SaveResultScreen( string strFullPath )
412     {
413     string strSavePath = Path.GetDirectoryName( strFullPath );
414     if ( !Directory.Exists( strSavePath ) )
415     {
416     try
417     {
418     Directory.CreateDirectory( strSavePath );
419     }
420     catch
421     {
422     return false;
423     }
424     }
425    
426     // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
427     using ( Surface pSurface = CDTXMania.app.Device.GetRenderTarget( 0 ) )
428     {
429     Surface.ToFile( pSurface, strFullPath, ImageFileFormat.Png );
430     }
431     return true;
432     }
433     #endregion
434    
435     // Game 実装
436     protected override void Initialize()
437     {
438     // new GCBeep();
439     if( this.listトップレベルActivities != null )
440     {
441     foreach (CActivity activity in this.listトップレベルActivities)
442     {
443     activity.OnManagedリソスの作成();
444     }
445     }
446    
447     foreach( STPlugin st in this.listプラグイン )
448     {
449     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
450     st.plugin.OnManagedリソスの作成();
451     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
452     }
453 kairera0467 82 #if GPUFlushAfterPresent
454     FrameEnd += dtxmania_FrameEnd;
455     #endif
456     }
457     #if GPUFlushAfterPresent
458     void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
459     { // → Present()直後にGPUをFlushする
460     // → 画面のカクツキが頻発したため、ここでのFlushは行わない
461     actFlushGPU.On進行描画(); // Flush GPU
462     }
463     #endif
464     protected override void LoadContent()
465 kairera0467 2 {
466     if ( ConfigIni.bウィンドウモ )
467     {
468     if( !this.bマウスカソル表示中 )
469     {
470     Cursor.Show();
471     this.bマウスカソル表示中 = true;
472     }
473     }
474     else if( this.bマウスカソル表示中 )
475     {
476     Cursor.Hide();
477     this.bマウスカソル表示中 = false;
478     }
479 kairera0467 39 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)));
480     this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
481     this.Device.SetRenderState(RenderState.Lighting, false);
482     this.Device.SetRenderState(RenderState.ZEnable, false);
483     this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false);
484     this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
485     this.Device.SetRenderState(RenderState.AlphaRef, 10);
486 kairera0467 2
487 kairera0467 50 if (CDTXMania.ConfigIni.b縮小文字のアンチエイリアスを有効にする == true)
488     {
489     this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
490     this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
491     this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
492     }
493 kairera0467 2
494 kairera0467 39 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
495     this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
496     this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
497     this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
498     this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
499     this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
500     this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
501 kairera0467 2
502     if( this.listトップレベルActivities != null )
503     {
504     foreach( CActivity activity in this.listトップレベルActivities )
505     activity.OnUnmanagedリソスの作成();
506     }
507    
508     foreach( STPlugin st in this.listプラグイン )
509     {
510     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
511     st.plugin.OnUnmanagedリソスの作成();
512     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
513 kairera0467 81 }
514 kairera0467 2
515 kairera0467 81 #region[ クレジット表記 ]
516 kairera0467 2 if (ConfigIni.クレジットを表示する == true)
517     {
518     this.ftDeclaration = new System.Drawing.Font("Arial", 13f, FontStyle.Regular, GraphicsUnit.Pixel);
519     Bitmap image = new Bitmap(1, 1);
520     Graphics graphics = Graphics.FromImage(image);
521     graphics.PageUnit = GraphicsUnit.Pixel;
522 kairera0467 115 int width = (int)graphics.MeasureString("DTXManiaXG(verK) ver 2.60 based on DTXMania", this.ftDeclaration).Width;
523 kairera0467 2 graphics.Dispose();
524     Bitmap bitmap2 = new Bitmap(width, this.ftDeclaration.Height);
525     graphics = Graphics.FromImage(bitmap2);
526 kairera0467 115 graphics.DrawString("DTXManiaXG(verK) ver 2.60 based on DTXMania", this.ftDeclaration, Brushes.White, (float)0f, (float)0f);
527 kairera0467 2 graphics.Dispose();
528     this.txCredit = new CTexture(app.Device, bitmap2, TextureFormat);
529     bitmap2.Dispose();
530     graphics = Graphics.FromImage(image);
531     graphics.PageUnit = GraphicsUnit.Pixel;
532     width = (int)graphics.MeasureString("CREDIT 0", this.ftDeclaration).Width;
533     graphics.Dispose();
534     bitmap2 = new Bitmap(width, this.ftDeclaration.Height);
535     graphics = Graphics.FromImage(bitmap2);
536     graphics.DrawString("CREDIT 0", this.ftDeclaration, Brushes.White, (float)0f, (float)0f);
537     graphics.Dispose();
538     this.txDeclaration = new CTexture(app.Device, bitmap2, TextureFormat);
539     bitmap2.Dispose();
540     }
541 kairera0467 81 #endregion
542     }
543 kairera0467 2 protected override void UnloadContent()
544     {
545     if( this.listトップレベルActivities != null )
546     {
547     foreach( CActivity activity in this.listトップレベルActivities )
548     activity.OnUnmanagedリソスの解放();
549     }
550    
551     foreach( STPlugin st in this.listプラグイン )
552     {
553     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
554     st.plugin.OnUnmanagedリソスの解放();
555     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
556     }
557     }
558     protected override void OnExiting( EventArgs e )
559     {
560     CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
561     this.t終了処理();
562     base.OnExiting( e );
563     }
564     protected override void Update( GameTime gameTime )
565     {
566     }
567     protected override void Draw( GameTime gameTime )
568     {
569     Sound管理.t再生中の処理をする();
570    
571     if( Timer != null )
572     Timer.t更新();
573     if (CSound管理.rc演奏用タイマ != null)
574     CSound管理.rc演奏用タイマ.t更新();
575    
576     if( Input管理 != null )
577     Input管理.tリング( this.bApplicationActive, CDTXMania.ConfigIni.bバッファ入力を行う );
578    
579     if( FPS != null )
580     FPS.tカウンタ更新();
581    
582     //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
583     // Pad.st検知したデバイス.Clear();
584    
585     if( this.Device == null )
586     return;
587    
588     if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
589     CPowerManagement.tDisableMonitorSuspend();
590    
591 kairera0467 82 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
592     #region [ スリープ ]
593     if ( ConfigIni.nフレム毎スリms >= 0 ) // #xxxxx 2011.11.27 yyagi
594     {
595     Thread.Sleep( ConfigIni.nフレム毎スリms );
596     }
597     #endregion
598    
599 kairera0467 2 this.Device.BeginScene();
600     this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, Color.Black, 1f, 0);
601    
602     if( r現在のステ != null )
603     {
604     this.n進行描画の戻り値 = ( r現在のステ != null ) ? r現在のステ.On進行描画() : 0;
605    
606     #region [ プラグインの進行描画 ]
607     //---------------------
608     foreach( STPlugin sp in this.listプラグイン )
609     {
610     Directory.SetCurrentDirectory( sp.strプラグインフォルダ );
611    
612     if( CDTXMania.act現在入力を占有中のプラグイン == null || CDTXMania.act現在入力を占有中のプラグイン == sp.plugin )
613     sp.plugin.On進行描画( CDTXMania.Pad, CDTXMania.Input管理.Keyboard );
614     else
615     sp.plugin.On進行描画( null, null );
616    
617     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
618     }
619     //---------------------
620     #endregion
621    
622    
623     CScoreIni scoreIni = null;
624    
625 kairera0467 49 //if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
626     //{ // → songs.db等の書き込み時だと音切れするっぽい
627     // CDTXMania.stage選曲.bIsEnumeratingSongs = false;
628     // actEnumSongs.On非活性化();
629     // EnumSongs.SongListEnumCompletelyDone();
630     //}
631 kairera0467 2 #region [ 曲検索スレッドの起動/終了 ] // ここに"Enumerating Songs..."表示を集約
632     if (!CDTXMania.bコンパクトモ)
633     {
634     actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
635     } // "Enumerating Songs..."アイコンの描画
636     switch ( r現在のステ.eステID )
637     {
638     case CStage.Eステ.タイトル:
639     case CStage.Eステ.コンフィグ:
640     case CStage.Eステ.オプション:
641     case CStage.Eステ.選曲:
642     case CStage.Eステ.曲読み込み:
643     if ( EnumSongs != null )
644     {
645     #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
646     if ( r現在のステ.eステID == CStage.Eステ.タイトル &&
647     r直前のステ.eステID == CStage.Eステ.起動 &&
648     this.n進行描画の戻り値 == (int) CStageタイトル.E戻り値.継続 &&
649     !EnumSongs.IsSongListEnumStarted )
650     {
651     actEnumSongs.On活性化();
652     CDTXMania.stage選曲.bIsEnumeratingSongs = true;
653     EnumSongs.Init( CDTXMania.Songs管理.listSongsDB, CDTXMania.Songs管理.nSongsDBから取得できたスコア数 ); // songs.db情報と、取得した曲数を、新インスタンスにも与える
654     EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
655     if ( CDTXMania.Songs管理.nSongsDBから取得できたスコア数 == 0 ) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
656     {
657     EnumSongs.ChangeEnumeratePriority( ThreadPriority.Normal );
658     }
659     }
660     #endregion
661    
662     #region [ 曲検索の中断と再開 ]
663     if ( r現在のステ.eステID == CStage.Eステ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone )
664     {
665     switch ( this.n進行描画の戻り値 )
666     {
667     case 0: // 何もない
668     //if ( CDTXMania.stage選曲.bIsEnumeratingSongs )
669     if ( !CDTXMania.stage選曲.bIsPlayingPremovie )
670     {
671     EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
672     EnumSongs.IsSlowdown = false;
673     }
674     else
675     {
676     // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
677     EnumSongs.IsSlowdown = true;
678     }
679     actEnumSongs.On活性化();
680     break;
681    
682     case 2: // 曲決定
683     EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
684     actEnumSongs.On非活性化();
685     break;
686     }
687     }
688     #endregion
689    
690     #region [ 曲探索中断待ち待機 ]
691     if ( r現在のステ.eステID == CStage.Eステ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
692     EnumSongs.thDTXFileEnumerate != null ) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
693     {
694     EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
695     }
696     #endregion
697    
698     #region [ 曲検索が完了したら、実際の曲リストに反映する ]
699     // CStage選曲.On活性化() に回した方がいいかな?
700     if ( EnumSongs.IsSongListEnumerated )
701     {
702     actEnumSongs.On非活性化();
703     CDTXMania.stage選曲.bIsEnumeratingSongs = false;
704    
705     bool bRemakeSongTitleBar = ( r現在のステ.eステID == CStage.Eステ.選曲 ) ? true : false;
706     CDTXMania.stage選曲.Refresh( EnumSongs.Songs管理, bRemakeSongTitleBar );
707     EnumSongs.SongListEnumCompletelyDone();
708     }
709     #endregion
710     }
711     break;
712     }
713     #endregion
714    
715     switch ( r現在のステ.eステID )
716     {
717     case CStage.Eステ.何もしない:
718     break;
719    
720     case CStage.Eステ.起動:
721     #region [ *** ]
722     //-----------------------------
723     if( this.n進行描画の戻り値 != 0 )
724     {
725     if( !bコンパクトモ )
726     {
727     r現在のステ.On非活性化();
728     Trace.TraceInformation( "----------------------" );
729     Trace.TraceInformation( "■ タイトル" );
730     stageタイトル.On活性化();
731     r直前のステ = r現在のステ;
732     r現在のステ = stageタイトル;
733     }
734     else
735     {
736     r現在のステ.On非活性化();
737     Trace.TraceInformation( "----------------------" );
738     Trace.TraceInformation( "■ 曲読み込み" );
739     stage曲読み込み.On活性化();
740     r直前のステ = r現在のステ;
741     r現在のステ = stage曲読み込み;
742    
743     }
744     foreach( STPlugin pg in this.listプラグイン )
745     {
746     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
747     pg.plugin.Onステジ変更();
748     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
749     }
750    
751     this.tガベジコレクションを実行する();
752     }
753     //-----------------------------
754     #endregion
755     break;
756    
757     case CStage.Eステ.タイトル:
758     #region [ *** ]
759     //-----------------------------
760     switch( this.n進行描画の戻り値 )
761     {
762     case (int)CStageタイトル.E戻り値.GAMESTART:
763     #region [ 選曲処理へ ]
764     //-----------------------------
765     r現在のステ.On非活性化();
766     Trace.TraceInformation( "----------------------" );
767     Trace.TraceInformation( "■ 選曲" );
768     stage選曲.On活性化();
769     r直前のステ = r現在のステ;
770     r現在のステ = stage選曲;
771     //-----------------------------
772     #endregion
773     break;
774    
775     #region [ OPTION: 廃止済 ]
776     /*
777     case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
778     #region [ *** ]
779     //-----------------------------
780     r現在のステージ.On非活性化();
781     Trace.TraceInformation( "----------------------" );
782     Trace.TraceInformation( "■ オプション" );
783     stageオプション.On活性化();
784     r直前のステージ = r現在のステージ;
785     r現在のステージ = stageオプション;
786     //-----------------------------
787     #endregion
788     break;
789     */
790     #endregion
791    
792     case (int)CStageタイトル.E戻り値.CONFIG:
793     #region [ *** ]
794     //-----------------------------
795     r現在のステ.On非活性化();
796     Trace.TraceInformation( "----------------------" );
797     Trace.TraceInformation( "■ コンフィグ" );
798     stageコンフィグ.On活性化();
799     r直前のステ = r現在のステ;
800     r現在のステ = stageコンフィグ;
801     //-----------------------------
802     #endregion
803     break;
804    
805     case (int)CStageタイトル.E戻り値.EXIT:
806     #region [ *** ]
807     //-----------------------------
808     r現在のステ.On非活性化();
809     Trace.TraceInformation( "----------------------" );
810     Trace.TraceInformation( "■ 終了" );
811     stage終了.On活性化();
812     r直前のステ = r現在のステ;
813     r現在のステ = stage終了;
814     //-----------------------------
815     #endregion
816     break;
817     }
818    
819     foreach( STPlugin pg in this.listプラグイン )
820     {
821     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
822     pg.plugin.Onステジ変更();
823     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
824     }
825    
826     this.tガベジコレクションを実行する();
827     //-----------------------------
828     #endregion
829     break;
830    
831    
832     case CStage.Eステ.オプション:
833     #region [ *** ]
834     //-----------------------------
835     if( this.n進行描画の戻り値 != 0 )
836     {
837     switch( r直前のステ.eステID )
838     {
839     case CStage.Eステ.タイトル:
840     #region [ *** ]
841     //-----------------------------
842     r現在のステ.On非活性化();
843     Trace.TraceInformation( "----------------------" );
844     Trace.TraceInformation( "■ タイトル" );
845     stageタイトル.On活性化();
846     r直前のステ = r現在のステ;
847     r現在のステ = stageタイトル;
848    
849     foreach( STPlugin pg in this.listプラグイン )
850     {
851     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
852     pg.plugin.Onステジ変更();
853     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
854     }
855    
856     this.tガベジコレクションを実行する();
857     break;
858     //-----------------------------
859     #endregion
860    
861     case CStage.Eステ.選曲:
862     #region [ *** ]
863     //-----------------------------
864     r現在のステ.On非活性化();
865     Trace.TraceInformation( "----------------------" );
866     Trace.TraceInformation( "■ 選曲" );
867     stage選曲.On活性化();
868     r直前のステ = r現在のステ;
869     r現在のステ = stage選曲;
870    
871     foreach( STPlugin pg in this.listプラグイン )
872     {
873     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
874     pg.plugin.Onステジ変更();
875     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
876     }
877    
878     this.tガベジコレクションを実行する();
879     break;
880     //-----------------------------
881     #endregion
882     }
883     }
884     //-----------------------------
885     #endregion
886     break;
887    
888    
889     case CStage.Eステ.コンフィグ:
890     #region [ *** ]
891     //-----------------------------
892     if( this.n進行描画の戻り値 != 0 )
893     {
894     switch( r直前のステ.eステID )
895     {
896     case CStage.Eステ.タイトル:
897     #region [ *** ]
898     //-----------------------------
899     r現在のステ.On非活性化();
900     Trace.TraceInformation( "----------------------" );
901     Trace.TraceInformation( "■ タイトル" );
902     stageタイトル.On活性化();
903     r直前のステ = r現在のステ;
904     r現在のステ = stageタイトル;
905    
906     foreach( STPlugin pg in this.listプラグイン )
907     {
908     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
909     pg.plugin.Onステジ変更();
910     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
911     }
912    
913     this.tガベジコレクションを実行する();
914     break;
915     //-----------------------------
916     #endregion
917    
918     case CStage.Eステ.選曲:
919     #region [ *** ]
920     //-----------------------------
921     r現在のステ.On非活性化();
922     Trace.TraceInformation( "----------------------" );
923     Trace.TraceInformation( "■ 選曲" );
924     stage選曲.On活性化();
925     r直前のステ = r現在のステ;
926     r現在のステ = stage選曲;
927    
928     foreach( STPlugin pg in this.listプラグイン )
929     {
930     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
931     pg.plugin.Onステジ変更();
932     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
933     }
934    
935     this.tガベジコレクションを実行する();
936     break;
937     //-----------------------------
938     #endregion
939     }
940     }
941     //-----------------------------
942     #endregion
943     break;
944    
945     case CStage.Eステ.選曲:
946     #region [ *** ]
947     //-----------------------------
948     switch( this.n進行描画の戻り値 )
949     {
950     case (int) CStage選曲.E戻り値.タイトルに戻る:
951     #region [ *** ]
952     //-----------------------------
953     r現在のステ.On非活性化();
954     Trace.TraceInformation( "----------------------" );
955     Trace.TraceInformation( "■ タイトル" );
956     stageタイトル.On活性化();
957     r直前のステ = r現在のステ;
958     r現在のステ = stageタイトル;
959    
960     foreach( STPlugin pg in this.listプラグイン )
961     {
962     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
963     pg.plugin.Onステジ変更();
964     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
965     }
966    
967     this.tガベジコレクションを実行する();
968     break;
969     //-----------------------------
970     #endregion
971    
972     case (int) CStage選曲.E戻り値.選曲した:
973     #region [ *** ]
974     //-----------------------------
975     r現在のステ.On非活性化();
976     Trace.TraceInformation( "----------------------" );
977     Trace.TraceInformation( "■ 曲読み込み" );
978     stage曲読み込み.On活性化();
979     r直前のステ = r現在のステ;
980     r現在のステ = stage曲読み込み;
981    
982     foreach( STPlugin pg in this.listプラグイン )
983     {
984     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
985     pg.plugin.Onステジ変更();
986     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
987     }
988    
989     this.tガベジコレクションを実行する();
990     break;
991     //-----------------------------
992     #endregion
993    
994    
995     case (int) CStage選曲.E戻り値.オプション呼び出し:
996     #region [ *** ]
997     //-----------------------------
998    
999     r現在のステ.On非活性化();
1000     Trace.TraceInformation( "----------------------" );
1001     Trace.TraceInformation( "■ オプション" );
1002     stageオプション.On活性化();
1003     r直前のステ = r現在のステ;
1004     r現在のステ = stageオプション;
1005    
1006     foreach( STPlugin pg in this.listプラグイン )
1007     {
1008     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1009     pg.plugin.Onステジ変更();
1010     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1011     }
1012    
1013     this.tガベジコレクションを実行する();
1014     break;
1015     //-----------------------------
1016     #endregion
1017    
1018     case (int) CStage選曲.E戻り値.コンフィグ呼び出し:
1019     #region [ *** ]
1020     //-----------------------------
1021     r現在のステ.On非活性化();
1022     Trace.TraceInformation( "----------------------" );
1023     Trace.TraceInformation( "■ コンフィグ" );
1024     stageコンフィグ.On活性化();
1025     r直前のステ = r現在のステ;
1026     r現在のステ = stageコンフィグ;
1027    
1028     foreach( STPlugin pg in this.listプラグイン )
1029     {
1030     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1031     pg.plugin.Onステジ変更();
1032     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1033     }
1034    
1035     this.tガベジコレクションを実行する();
1036     break;
1037     //-----------------------------
1038     #endregion
1039    
1040     case (int) CStage選曲.E戻り値.スキン変更:
1041    
1042     #region [ *** ]
1043     //-----------------------------
1044     r現在のステ.On非活性化();
1045     Trace.TraceInformation( "----------------------" );
1046     Trace.TraceInformation( "■ スキン切り替え" );
1047     stageChangeSkin.On活性化();
1048     r直前のステ = r現在のステ;
1049     r現在のステ = stageChangeSkin;
1050     break;
1051     //-----------------------------
1052     #endregion
1053     }
1054     //-----------------------------
1055     #endregion
1056     break;
1057    
1058     case CStage.Eステ.曲読み込み:
1059     #region [ *** ]
1060     //-----------------------------
1061     if( this.n進行描画の戻り値 != 0 )
1062     {
1063     CDTXMania.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1064    
1065     r現在のステ.On非活性化();
1066 kairera0467 61
1067 kairera0467 65 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1068 kairera0467 61 if ( this.n進行描画の戻り値 == (int) E曲読込画面の戻り値.読込中止 )
1069     {
1070     //DTX.t全チップの再生停止();
1071     DTX.On非活性化();
1072     Trace.TraceInformation( "曲の読み込みを中止しました。" );
1073     this.tガベジコレクションを実行する();
1074     Trace.TraceInformation( "----------------------" );
1075     Trace.TraceInformation( "■ 選曲" );
1076     stage選曲.On活性化();
1077     r直前のステ = r現在のステ;
1078     r現在のステ = stage選曲;
1079     foreach ( STPlugin pg in this.listプラグイン )
1080     {
1081     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1082     pg.plugin.Onステジ変更();
1083     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1084     }
1085     break;
1086     }
1087     #endregion
1088    
1089 kairera0467 65
1090 kairera0467 2 if( !ConfigIni.bギタレボモ )
1091     {
1092     Trace.TraceInformation( "----------------------" );
1093     Trace.TraceInformation( "■ 演奏(ドラム画面)" );
1094     #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1095     for (int i = 0; i < 5; i++)
1096     {
1097     for (int j = 0; j < 2; j++)
1098     {
1099     stage演奏ドラム画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1100     }
1101     }
1102     for (int i = 0; i < 3; i++) {
1103     stage演奏ドラム画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1104     }
1105     #endif
1106     r直前のステ = r現在のステ;
1107     r現在のステ = stage演奏ドラム画面;
1108     }
1109     else
1110     {
1111     Trace.TraceInformation( "----------------------" );
1112     Trace.TraceInformation( "■ 演奏(ギター画面)" );
1113     #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1114     for (int i = 0; i < 5; i++)
1115     {
1116     for (int j = 0; j < 2; j++)
1117     {
1118     stage演奏ギタ画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1119     }
1120     }
1121     for (int i = 0; i < 3; i++) {
1122     stage演奏ギタ画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1123     }
1124     #endif
1125     r直前のステ = r現在のステ;
1126     r現在のステ = stage演奏ギタ画面;
1127     }
1128    
1129     foreach( STPlugin pg in this.listプラグイン )
1130     {
1131     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1132     pg.plugin.Onステジ変更();
1133     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1134     }
1135    
1136     this.tガベジコレクションを実行する();
1137     }
1138     //-----------------------------
1139     #endregion
1140     break;
1141    
1142     case CStage.Eステ.演奏:
1143     #region [ *** ]
1144     //-----------------------------
1145     switch( this.n進行描画の戻り値 )
1146     {
1147     case (int) E演奏画面の戻り値.継続:
1148     break;
1149    
1150     case (int) E演奏画面の戻り値.演奏中断:
1151     #region [ 演奏キャンセル ]
1152     //-----------------------------
1153     scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Play canceled" );
1154    
1155     #region [ プラグイン On演奏キャンセル() の呼び出し ]
1156     //---------------------
1157     foreach( STPlugin pg in this.listプラグイン )
1158     {
1159     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1160     pg.plugin.On演奏キャンセル( scoreIni );
1161     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1162     }
1163     //---------------------
1164     #endregion
1165    
1166     DTX.t全チップの再生停止();
1167     DTX.On非活性化();
1168     r現在のステ.On非活性化();
1169     if( bコンパクトモ )
1170     {
1171     base.Window.Close();
1172     }
1173     else
1174     {
1175     Trace.TraceInformation( "----------------------" );
1176     Trace.TraceInformation( "■ 選曲" );
1177     stage選曲.On活性化();
1178     r直前のステ = r現在のステ;
1179     r現在のステ = stage選曲;
1180    
1181     #region [ プラグイン Onステージ変更() の呼び出し ]
1182     //---------------------
1183     foreach( STPlugin pg in this.listプラグイン )
1184     {
1185     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1186     pg.plugin.Onステジ変更();
1187     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1188     }
1189     //---------------------
1190     #endregion
1191    
1192     this.tガベジコレクションを実行する();
1193     }
1194     break;
1195     //-----------------------------
1196     #endregion
1197    
1198     case (int) E演奏画面の戻り値.ステジ失敗:
1199     #region [ 演奏失敗(StageFailed) ]
1200     //-----------------------------
1201     scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Stage failed" );
1202    
1203     #region [ プラグイン On演奏失敗() の呼び出し ]
1204     //---------------------
1205     foreach( STPlugin pg in this.listプラグイン )
1206     {
1207     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1208     pg.plugin.On演奏失敗( scoreIni );
1209     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1210     }
1211     //---------------------
1212     #endregion
1213    
1214     DTX.t全チップの再生停止();
1215     DTX.On非活性化();
1216     r現在のステ.On非活性化();
1217     if( bコンパクトモ )
1218     {
1219     base.Window.Close();
1220     }
1221     else
1222     {
1223     Trace.TraceInformation( "----------------------" );
1224     Trace.TraceInformation( "■ 選曲" );
1225     stage選曲.On活性化();
1226     r直前のステ = r現在のステ;
1227     r現在のステ = stage選曲;
1228    
1229     #region [ プラグイン Onステージ変更() の呼び出し ]
1230     //---------------------
1231     foreach( STPlugin pg in this.listプラグイン )
1232     {
1233     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1234     pg.plugin.Onステジ変更();
1235     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1236     }
1237     //---------------------
1238     #endregion
1239    
1240     this.tガベジコレクションを実行する();
1241     }
1242     break;
1243     //-----------------------------
1244     #endregion
1245    
1246     case (int) E演奏画面の戻り値.ステジクリア:
1247     #region [ 演奏クリア ]
1248     //-----------------------------
1249     CScoreIni.C演奏記録 c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass;
1250     CDTX.CChip[] chipArray = new CDTX.CChip[10];
1251     if( ConfigIni.bギタレボモ )
1252     {
1253     stage演奏ギタ画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass );
1254     }
1255     else
1256     {
1257     stage演奏ドラム画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass, out chipArray );
1258     }
1259    
1260     if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.24 yyagi Gt/Bsを入れ替えていたなら、演奏結果も入れ替える
1261     {
1262     CScoreIni.C演奏記録 t;
1263     t = c演奏記録_Guitar;
1264     c演奏記録_Guitar = c演奏記録_Bass;
1265     c演奏記録_Bass = t;
1266    
1267     CDTXMania.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す
1268     CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // #24415 2011.2.27 yyagi
1269     // リザルト集計時のみ、Auto系のフラグも元に戻す。
1270     // これを戻すのは、リザルト集計後。
1271     } // "case CStage.Eステージ.結果:"のところ。
1272    
1273     double ps = 0.0, gs = 0.0;
1274     if ( !c演奏記録_Drums.bAUTOである && c演奏記録_Drums.n全チップ数 > 0) {
1275     ps = c演奏記録_Drums.db演奏型スキル値;
1276     gs = c演奏記録_Drums.dbム型スキル値;
1277     }
1278     else if ( !c演奏記録_Guitar.bAUTOである && c演奏記録_Guitar.n全チップ数 > 0) {
1279     ps = c演奏記録_Guitar.db演奏型スキル値;
1280     gs = c演奏記録_Guitar.dbム型スキル値;
1281     }
1282     else
1283     {
1284     ps = c演奏記録_Bass.db演奏型スキル値;
1285     gs = c演奏記録_Bass.dbム型スキル値;
1286     }
1287     string str = "Cleared";
1288     switch( CScoreIni.t総合ランク値を計算して返す( c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass ) )
1289     {
1290     case (int)CScoreIni.ERANK.SS:
1291     str = string.Format( "Cleared (SS: {0:F2})", ps );
1292     break;
1293    
1294     case (int) CScoreIni.ERANK.S:
1295     str = string.Format( "Cleared (S: {0:F2})", ps );
1296     break;
1297    
1298     case (int) CScoreIni.ERANK.A:
1299     str = string.Format( "Cleared (A: {0:F2})", ps );
1300     break;
1301    
1302     case (int) CScoreIni.ERANK.B:
1303     str = string.Format( "Cleared (B: {0:F2})", ps );
1304     break;
1305    
1306     case (int) CScoreIni.ERANK.C:
1307     str = string.Format( "Cleared (C: {0:F2})", ps );
1308     break;
1309    
1310     case (int) CScoreIni.ERANK.D:
1311     str = string.Format( "Cleared (D: {0:F2})", ps );
1312     break;
1313    
1314     case (int) CScoreIni.ERANK.E:
1315     str = string.Format( "Cleared (E: {0:F2})", ps );
1316     break;
1317    
1318     case (int)CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1319     str = "Cleared (No chips)";
1320     break;
1321     }
1322    
1323     scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( str );
1324    
1325     #region [ プラグイン On演奏クリア() の呼び出し ]
1326     //---------------------
1327     foreach( STPlugin pg in this.listプラグイン )
1328     {
1329     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1330     pg.plugin.On演奏クリア( scoreIni );
1331     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1332     }
1333     //---------------------
1334     #endregion
1335    
1336     r現在のステ.On非活性化();
1337     Trace.TraceInformation( "----------------------" );
1338     Trace.TraceInformation( "■ 結果" );
1339     stage結果.st演奏記録.Drums = c演奏記録_Drums;
1340     stage結果.st演奏記録.Guitar = c演奏記録_Guitar;
1341     stage結果.st演奏記録.Bass = c演奏記録_Bass;
1342     stage結果.r空うちドラムチップ = chipArray;
1343     stage結果.On活性化();
1344     r直前のステ = r現在のステ;
1345     r現在のステ = stage結果;
1346    
1347     #region [ プラグイン Onステージ変更() の呼び出し ]
1348     //---------------------
1349     foreach( STPlugin pg in this.listプラグイン )
1350     {
1351     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1352     pg.plugin.Onステジ変更();
1353     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1354     }
1355     //---------------------
1356     #endregion
1357    
1358     break;
1359     //-----------------------------
1360     #endregion
1361     }
1362     //-----------------------------
1363     #endregion
1364     break;
1365    
1366     case CStage.Eステ.結果:
1367     #region [ *** ]
1368     //-----------------------------
1369     if( this.n進行描画の戻り値 != 0 )
1370     {
1371     if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1372     {
1373     CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
1374     }
1375    
1376     DTX.t全チップの再生一時停止();
1377     DTX.On非活性化();
1378     r現在のステ.On非活性化();
1379     if( !bコンパクトモ )
1380     {
1381     Trace.TraceInformation( "----------------------" );
1382     Trace.TraceInformation( "■ 選曲" );
1383     stage選曲.On活性化();
1384     r直前のステ = r現在のステ;
1385     r現在のステ = stage選曲;
1386    
1387     foreach( STPlugin pg in this.listプラグイン )
1388     {
1389     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1390     pg.plugin.Onステジ変更();
1391     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1392     }
1393    
1394     this.tガベジコレクションを実行する();
1395     }
1396     else
1397     {
1398     base.Window.Close();
1399     }
1400     }
1401     //-----------------------------
1402     #endregion
1403     break;
1404    
1405     case CStage.Eステ.ChangeSkin:
1406     #region [ *** ]
1407     //-----------------------------
1408     if ( this.n進行描画の戻り値 != 0 )
1409     {
1410     r現在のステ.On非活性化();
1411     Trace.TraceInformation( "----------------------" );
1412     Trace.TraceInformation( "■ 選曲" );
1413     stage選曲.On活性化();
1414     r直前のステ = r現在のステ;
1415     r現在のステ = stage選曲;
1416     this.tガベジコレクションを実行する();
1417     }
1418     //-----------------------------
1419     #endregion
1420     break;
1421    
1422     case CStage.Eステ.終了:
1423     #region [ *** ]
1424     //-----------------------------
1425     if( this.n進行描画の戻り値 != 0 )
1426     {
1427     base.Exit();
1428     }
1429     //-----------------------------
1430     #endregion
1431     break;
1432     }
1433     }
1434     if (ConfigIni.クレジットを表示する == true)
1435     {
1436     this.txDeclaration.t2D描画(this.Device, 472, 694);
1437     if ((r現在のステ.eステID == CStage.Eステ.タイトル) || (r現在のステ.eステID == CStage.Eステ.終了))
1438     {
1439     this.txCredit.t2D描画(this.Device, (1280 - this.txCredit.sz画像サイズ.Width) - 20, 700);
1440     }
1441     }
1442 kairera0467 82 this.Device.EndScene(); // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
1443     // (つまり、Present()は、Draw()完了後に実行される)
1444     #if !GPUFlushAfterPresent
1445     actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
1446     #endif
1447 kairera0467 2 #region [ 全画面・ウインドウ切り替え ]
1448     if ( this.b次のタイミングで全画面・ウィンドウ切り替えを行う )
1449     {
1450     ConfigIni.b全画面モ = !ConfigIni.b全画面モ;
1451     app.t全画面・ウィンドウモド切り替え();
1452     this.b次のタイミングで全画面・ウィンドウ切り替えを行う = false;
1453     }
1454     #endregion
1455     #region [ 垂直基線同期切り替え ]
1456     if ( this.b次のタイミングで垂直帰線同期切り替えを行う )
1457     {
1458     bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
1459     currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
1460     DeviceSettings currentSettings = app.GraphicsDeviceManager.CurrentSettings;
1461     currentSettings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1462     app.GraphicsDeviceManager.ChangeDevice( currentSettings );
1463     this.b次のタイミングで垂直帰線同期切り替えを行う = false;
1464     base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
1465     if (bIsMaximized)
1466     {
1467     this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
1468     }
1469     }
1470     #endregion
1471     }
1472    
1473    
1474     // その他
1475    
1476     #region [ 汎用ヘルパー ]
1477     //-----------------
1478     public static CTexture tテクスチャの生成( string fileName )
1479     {
1480     return tテクスチャの生成( fileName, false );
1481     }
1482     public static CTexture tテクスチャの生成( string fileName, bool b黒を透過する )
1483     {
1484     if ( app == null )
1485     {
1486     return null;
1487     }
1488     try
1489     {
1490     return new CTexture( app.Device, fileName, TextureFormat, b黒を透過する );
1491     }
1492     catch ( CTextureCreateFailedException )
1493     {
1494     Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1495     return null;
1496     }
1497     catch ( FileNotFoundException )
1498     {
1499     Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1500     return null;
1501     }
1502     }
1503     public static void tテクスチャの解放( ref CTexture tx )
1504     {
1505 kairera0467 90 if( tx != null )
1506     CDTXMania.t安全にDisposeする( ref tx );
1507 kairera0467 2 }
1508    
1509     public static CTexture tテクスチャの生成( byte[] txData )
1510     {
1511     return tテクスチャの生成( txData, false );
1512     }
1513     public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
1514     {
1515     if ( app == null )
1516     {
1517     return null;
1518     }
1519     try
1520     {
1521     return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
1522     }
1523     catch ( CTextureCreateFailedException )
1524     {
1525     Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1526     return null;
1527     }
1528     }
1529    
1530     public static CTexture tテクスチャの生成( Bitmap bitmap )
1531     {
1532     return tテクスチャの生成( bitmap, false );
1533     }
1534     public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
1535     {
1536     if ( app == null )
1537     {
1538     return null;
1539     }
1540     try
1541     {
1542     return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
1543     }
1544     catch ( CTextureCreateFailedException )
1545     {
1546     Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1547     return null;
1548     }
1549     }
1550    
1551     public static CTexture tテクスチャを生成する(int width, int height)
1552     {
1553     try
1554     {
1555     return new CTexture(CDTXMania.App.D3D9Device, width, height, CDTXMania.TextureFormat);
1556     }
1557     catch
1558     {
1559     Trace.TraceError("空のテクスチャ({0}x{1})の生成に失敗しました。", width, height);
1560     return null;
1561     }
1562     }
1563    
1564    
1565     public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する(string fileName, IntPtr hWnd, bool bディオレンダラなし)
1566     {
1567     CDirectShow ds = null;
1568     try
1569     {
1570     ds = new CDirectShow(fileName, hWnd, bディオレンダラなし);
1571     }
1572     catch (FileNotFoundException)
1573     {
1574     Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1575     ds = null; // Dispose はコンストラクタ内で実施済み
1576     }
1577     catch
1578     {
1579     Trace.TraceError("DirectShow の生成に失敗しました。[{0}]", fileName);
1580     ds = null; // Dispose はコンストラクタ内で実施済み
1581     }
1582    
1583     return ds;
1584     }
1585    
1586     /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
1587     public static void t安全にDisposeする<T>( ref T obj )
1588     {
1589     if ( obj == null )
1590     return;
1591    
1592     var d = obj as IDisposable;
1593    
1594     if ( d != null )
1595     d.Dispose();
1596    
1597     obj = default( T );
1598     }
1599     //-----------------
1600     #endregion
1601     #region [ private ]
1602     //-----------------
1603     private bool bマウスカソル表示中 = true;
1604     public bool bウィンドウがアクティブである = true;
1605     private bool b終了処理完了済み;
1606     private static CDTX dtx;
1607     private List<CActivity> listトップレベルActivities;
1608 kairera0467 24 public int n進行描画の戻り値;
1609 kairera0467 2 private CTexture txCredit;
1610     private CTexture txDeclaration;
1611     private System.Drawing.Font ftDeclaration;
1612     private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
1613     private string strWindowTitle = "";
1614    
1615     private void t起動処理()
1616     {
1617     #region [ strEXEのあるフォルダを決定する ]
1618     //-----------------
1619     // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
1620     #if DEBUG
1621     strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
1622     #else
1623     strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
1624     #endif
1625     // END #23629 2010.11.13 from
1626     //-----------------
1627     #endregion
1628    
1629     #region [ Config.ini の読込み ]
1630     //---------------------
1631     ConfigIni = new CConfigIni();
1632     string path = strEXEのあるフォルダ + "Config.ini";
1633     if( File.Exists( path ) )
1634     {
1635     try
1636     {
1637     ConfigIni.tファイルから読み込み( path );
1638     }
1639     catch
1640     {
1641     //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
1642     }
1643     }
1644     this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
1645     // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
1646    
1647     //---------------------
1648     #endregion
1649     #region [ ログ出力開始 ]
1650     //---------------------
1651     Trace.AutoFlush = true;
1652     if( ConfigIni.bログ出力 )
1653     {
1654     try
1655     {
1656     Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( "DTXManiaLog.txt", false, Encoding.GetEncoding( "shift-jis" ) ) ) );
1657     }
1658     catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
1659     {
1660     int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
1661     string[] mes_writeErr = {
1662     "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
1663     "Failed to write DTXManiaLog.txt. Please set it writable and try again."
1664     };
1665     MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
1666     Environment.Exit(1);
1667     }
1668     }
1669     Trace.WriteLine("");
1670     Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
1671     Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
1672     Trace.WriteLine( "" );
1673     Trace.TraceInformation( "----------------------" );
1674     Trace.TraceInformation( "■ アプリケーションの初期化" );
1675     Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
1676     Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
1677     Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
1678     //---------------------
1679     #endregion
1680     #region [ コンパクトモードスイッチの有無 ]
1681     //---------------------
1682     bコンパクトモ = false;
1683     strコンパクトモドファイル = "";
1684     string[] commandLineArgs = Environment.GetCommandLineArgs();
1685     if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
1686     {
1687     bコンパクトモ = true;
1688     strコンパクトモドファイル = commandLineArgs[ 1 ];
1689     Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモドファイル );
1690     }
1691     //---------------------
1692     #endregion
1693    
1694     #region [ ウィンドウ初期化 ]
1695     //---------------------
1696     this.strWindowTitle = "DTXMania .NET style release " + VERSION;
1697     base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1698     base.Window.Location = new Point(ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y); // #30675 2013.02.04 ikanick add
1699    
1700     base.Window.Text = this.strWindowTitle;
1701     base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #34510 yyagi 2010.10.31 to change window size got from Config.ini
1702 kairera0467 21 #if !WindowedFullscreen
1703 kairera0467 2 if (!ConfigIni.bウィンドウモ) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
1704     {
1705 kairera0467 21 #endif
1706 kairera0467 2 currentClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight);
1707 kairera0467 21 #if !WindowedFullscreen
1708     }
1709     #endif
1710     base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
1711 kairera0467 2 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
1712     base.Window.ShowIcon = true;
1713     base.Window.Icon = Properties.Resources.dtx;
1714     base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
1715     base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
1716     base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
1717     base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
1718     base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
1719     base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
1720     //---------------------
1721     #endregion
1722     #region [ Direct3D9Exを使うかどうか判定 ]
1723     #endregion
1724     #region [ Direct3D9 デバイスの生成 ]
1725     //---------------------
1726     DeviceSettings settings = new DeviceSettings();
1727 kairera0467 21 #if WindowedFullscreen
1728 kairera0467 49 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
1729 kairera0467 21 #else
1730 kairera0467 2 settings.Windowed = ConfigIni.bウィンドウモ;
1731 kairera0467 21 #endif
1732 kairera0467 2 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
1733     settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
1734     // settings.BackBufferCount = 3;
1735     settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1736 kairera0467 49 // settings.BackBufferFormat = Format.A8R8G8B8;
1737     // settings.MultisampleType = MultisampleType.FourSamples;
1738     // settings.MultisampleQuality = 4;
1739     // settings.MultisampleType = MultisampleType.None;
1740     // settings.MultisampleQuality = 0;
1741    
1742 kairera0467 2 try
1743     {
1744     base.GraphicsDeviceManager.ChangeDevice(settings);
1745     }
1746     catch (DeviceCreationException e)
1747     {
1748     Trace.TraceError(e.ToString());
1749     MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1750     Environment.Exit(-1);
1751     }
1752 kairera0467 49
1753 kairera0467 2 base.IsFixedTimeStep = false;
1754     // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
1755     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.
1756     base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォカス時スリms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
1757 kairera0467 49 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
1758 kairera0467 21 #if WindowedFullscreen
1759 kairera0467 49 this.t全画面・ウィンドウモド切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
1760 kairera0467 21 #endif
1761 kairera0467 49 actFlushGPU = new CActFlushGPU();
1762 kairera0467 2 //---------------------
1763     #endregion
1764    
1765     DTX = null;
1766    
1767     #region [ Skin の初期化 ]
1768     //---------------------
1769     Trace.TraceInformation( "スキンの初期化を行います。" );
1770     Trace.Indent();
1771     try
1772     {
1773     Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
1774     CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
1775     Trace.TraceInformation( "スキンの初期化を完了しました。" );
1776     }
1777     catch
1778     {
1779     Trace.TraceInformation( "スキンの初期化に失敗しました。" );
1780     throw;
1781     }
1782     finally
1783     {
1784     Trace.Unindent();
1785     }
1786     //---------------------
1787     #endregion
1788     #region [ Timer の初期化 ]
1789     //---------------------
1790     Trace.TraceInformation( "タイマの初期化を行います。" );
1791     Trace.Indent();
1792     try
1793     {
1794     Timer = new CTimer( CTimer.E種別.MultiMedia );
1795     Trace.TraceInformation( "タイマの初期化を完了しました。" );
1796     }
1797     finally
1798     {
1799     Trace.Unindent();
1800     }
1801     //---------------------
1802     #endregion
1803     #region [ FPS カウンタの初期化 ]
1804     //---------------------
1805     Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
1806     Trace.Indent();
1807     try
1808     {
1809     FPS = new CFPS();
1810     Trace.TraceInformation( "FPSカウンタを生成しました。" );
1811     }
1812     finally
1813     {
1814     Trace.Unindent();
1815     }
1816     //---------------------
1817     #endregion
1818     #region [ act文字コンソールの初期化 ]
1819     //---------------------
1820     Trace.TraceInformation( "文字コンソールの初期化を行います。" );
1821     Trace.Indent();
1822     try
1823     {
1824     act文字コンソ = new C文字コンソ();
1825     Trace.TraceInformation( "文字コンソールを生成しました。" );
1826     act文字コンソ.On活性化();
1827     Trace.TraceInformation( "文字コンソールを活性化しました。" );
1828     Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
1829     }
1830     catch( Exception exception )
1831     {
1832     Trace.TraceError( exception.Message );
1833     Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
1834     }
1835     finally
1836     {
1837     Trace.Unindent();
1838     }
1839     //---------------------
1840     #endregion
1841     #region [ Input管理 の初期化 ]
1842     //---------------------
1843     Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
1844     Trace.Indent();
1845     try
1846     {
1847     Input管理 = new CInput管理( base.Window.Handle );
1848     foreach( IInputDevice device in Input管理.list入力デバイス )
1849     {
1850     if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
1851     {
1852     int key = 0;
1853     while( ConfigIni.dicJoystick.ContainsKey( key ) )
1854     {
1855     key++;
1856     }
1857     ConfigIni.dicJoystick.Add( key, device.GUID );
1858     }
1859     }
1860     foreach( IInputDevice device2 in Input管理.list入力デバイス )
1861     {
1862     if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
1863     {
1864     foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
1865     {
1866     if( device2.GUID.Equals( pair.Value ) )
1867     {
1868     ( (CInputJoystick) device2 ).SetID( pair.Key );
1869     break;
1870     }
1871     }
1872     continue;
1873     }
1874     }
1875     Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
1876     }
1877     catch( Exception exception2 )
1878     {
1879     Trace.TraceError( exception2.Message );
1880     Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
1881     throw;
1882     }
1883     finally
1884     {
1885     Trace.Unindent();
1886     }
1887     //---------------------
1888     #endregion
1889     #region [ Pad の初期化 ]
1890     //---------------------
1891     Trace.TraceInformation( "パッドの初期化を行います。" );
1892     Trace.Indent();
1893     try
1894     {
1895     Pad = new CPad( ConfigIni, Input管理 );
1896     Trace.TraceInformation( "パッドの初期化を完了しました。" );
1897     }
1898     catch( Exception exception3 )
1899     {
1900     Trace.TraceError( exception3.Message );
1901     Trace.TraceError( "パッドの初期化に失敗しました。" );
1902     }
1903     finally
1904     {
1905     Trace.Unindent();
1906     }
1907     //---------------------
1908     #endregion
1909     #region [ Sound管理 の初期化 ]
1910     //---------------------
1911     Trace.TraceInformation("サウンドデバイスの初期化を行います。");
1912     Trace.Indent();
1913     try
1914     {
1915     {
1916     ESoundDeviceType soundDeviceType;
1917     switch (CDTXMania.ConfigIni.nSoundDeviceType)
1918     {
1919     case 0:
1920     soundDeviceType = ESoundDeviceType.DirectSound;
1921     break;
1922     case 1:
1923     soundDeviceType = ESoundDeviceType.ASIO;
1924     break;
1925     case 2:
1926     soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
1927     break;
1928     default:
1929     soundDeviceType = ESoundDeviceType.Unknown;
1930     break;
1931     }
1932 kairera0467 49 Sound管理 = new CSound管理( base.Window.Handle,
1933 kairera0467 2 soundDeviceType,
1934     CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
1935     CDTXMania.ConfigIni.nASIOBufferSizeMs,
1936     CDTXMania.ConfigIni.nASIODevice
1937     );
1938     AddSoundTypeToWindowTitle();
1939 kairera0467 25 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
1940 kairera0467 2 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
1941     }
1942     }
1943     catch (Exception e)
1944 kairera0467 49 {
1945     Trace.TraceError(e.Message);
1946     throw;
1947     }
1948     finally
1949     {
1950     Trace.Unindent();
1951     }
1952 kairera0467 2 //---------------------
1953     #endregion
1954     #region [ Songs管理 の初期化 ]
1955     //---------------------
1956     Trace.TraceInformation( "曲リストの初期化を行います。" );
1957     Trace.Indent();
1958     try
1959     {
1960     Songs管理 = new CSongs管理();
1961     // Songs管理_裏読 = new CSongs管理();
1962     EnumSongs = new CEnumSongs();
1963     actEnumSongs = new CActEnumSongs();
1964     Trace.TraceInformation( "曲リストの初期化を完了しました。" );
1965     }
1966     catch( Exception e )
1967     {
1968     Trace.TraceError( e.Message );
1969     Trace.TraceError( "曲リストの初期化に失敗しました。" );
1970     }
1971     finally
1972     {
1973     Trace.Unindent();
1974     }
1975     //---------------------
1976     #endregion
1977     #region [ CAvi の初期化 ]
1978     //---------------------
1979     CAvi.t初期化();
1980     //---------------------
1981     #endregion
1982     #region [ Random の初期化 ]
1983     //---------------------
1984     Random = new Random( (int) Timer.nシステム時刻 );
1985     //---------------------
1986     #endregion
1987     #region [ ステージの初期化 ]
1988     //---------------------
1989     r現在のステ = null;
1990     r直前のステ = null;
1991     stage起動 = new CStage起動();
1992     stageタイトル = new CStageタイトル();
1993     stageオプション = new CStageオプション();
1994     stageコンフィグ = new CStageコンフィグ();
1995     stage選曲 = new CStage選曲();
1996     stage曲読み込み = new CStage曲読み込み();
1997     stage演奏ドラム画面 = new CStage演奏ドラム画面();
1998     stage演奏ギタ画面 = new CStage演奏ギタ画面();
1999     stage結果 = new CStage結果();
2000     stageChangeSkin = new CStageChangeSkin();
2001     stage終了 = new CStage終了();
2002     this.listトップレベルActivities = new List<CActivity>();
2003     this.listトップレベルActivities.Add( actEnumSongs );
2004     this.listトップレベルActivities.Add( act文字コンソ );
2005     this.listトップレベルActivities.Add( stage起動 );
2006     this.listトップレベルActivities.Add( stageタイトル );
2007     this.listトップレベルActivities.Add( stageオプション );
2008     this.listトップレベルActivities.Add( stageコンフィグ );
2009     this.listトップレベルActivities.Add( stage選曲 );
2010     this.listトップレベルActivities.Add( stage曲読み込み );
2011     this.listトップレベルActivities.Add( stage演奏ドラム画面 );
2012     this.listトップレベルActivities.Add( stage演奏ギタ画面 );
2013     this.listトップレベルActivities.Add( stage結果 );
2014     this.listトップレベルActivities.Add( stageChangeSkin );
2015     this.listトップレベルActivities.Add( stage終了 );
2016     this.listトップレベルActivities.Add( actFlushGPU);
2017     //---------------------
2018     #endregion
2019     #region [ プラグインの検索と生成 ]
2020     //---------------------
2021     PluginHost = new CPluginHost();
2022    
2023     Trace.TraceInformation( "プラグインの検索と生成を行います。" );
2024     Trace.Indent();
2025     try
2026     {
2027     this.tプラグイン検索と生成();
2028     Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
2029     }
2030     finally
2031     {
2032     Trace.Unindent();
2033     }
2034     //---------------------
2035     #endregion
2036     #region [ プラグインの初期化 ]
2037     //---------------------
2038     if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
2039     {
2040     Trace.TraceInformation( "プラグインの初期化を行います。" );
2041     Trace.Indent();
2042     try
2043     {
2044     foreach( STPlugin st in this.listプラグイン )
2045     {
2046     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2047     st.plugin.On初期化( this.PluginHost );
2048     st.plugin.OnManagedリソスの作成();
2049     st.plugin.OnUnmanagedリソスの作成();
2050     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2051     }
2052     Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
2053     }
2054     catch
2055     {
2056     Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
2057     throw;
2058     }
2059     finally
2060     {
2061     Trace.Unindent();
2062     }
2063     }
2064    
2065     //---------------------
2066     #endregion
2067    
2068    
2069     Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );
2070    
2071     #region [ 最初のステージの起動 ]
2072     //---------------------
2073     Trace.TraceInformation("----------------------");
2074     Trace.TraceInformation("■ 起動");
2075    
2076     if (CDTXMania.bコンパクトモ)
2077     {
2078     r現在のステ = stage曲読み込み;
2079     }
2080     else
2081     {
2082     r現在のステ = stage起動;
2083     }
2084     r現在のステ.On活性化();
2085     //---------------------
2086     #endregion
2087     }
2088     public void AddSoundTypeToWindowTitle()
2089     {
2090     string delay = "";
2091     if (Sound管理.GetCurrentSoundDeviceType() != "DirectSound")
2092     {
2093     delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2094     }
2095     base.Window.Text = strWindowTitle + " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2096     }
2097    
2098     private void t終了処理()
2099     {
2100     if( !this.b終了処理完了済み )
2101     {
2102     Trace.TraceInformation( "----------------------" );
2103     Trace.TraceInformation( "■ アプリケーションの終了" );
2104     #region [ 曲検索の終了処理 ]
2105     //---------------------
2106     if ( actEnumSongs != null )
2107     {
2108     Trace.TraceInformation( "曲検索actの終了処理を行います。" );
2109     Trace.Indent();
2110     try
2111     {
2112     actEnumSongs.On非活性化();
2113     actEnumSongs= null;
2114     Trace.TraceInformation( "曲検索actの終了処理を完了しました。" );
2115     }
2116     catch ( Exception e )
2117     {
2118     Trace.TraceError( e.Message );
2119     Trace.TraceError( "曲検索actの終了処理に失敗しました。" );
2120     }
2121     finally
2122     {
2123     Trace.Unindent();
2124     }
2125     }
2126     //---------------------
2127     #endregion
2128     #region [ 現在のステージの終了処理 ]
2129     //---------------------
2130     if( CDTXMania.r現在のステ != null && CDTXMania.r現在のステ.b活性化してる ) // #25398 2011.06.07 MODIFY FROM
2131     {
2132     Trace.TraceInformation( "現在のステージを終了します。" );
2133     Trace.Indent();
2134     try
2135     {
2136     r現在のステ.On非活性化();
2137     Trace.TraceInformation( "現在のステージの終了処理を完了しました。" );
2138     }
2139     finally
2140     {
2141     Trace.Unindent();
2142     }
2143     }
2144     //---------------------
2145     #endregion
2146     #region [ プラグインの終了処理 ]
2147     //---------------------
2148     if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2149     {
2150     Trace.TraceInformation( "すべてのプラグインを終了します。" );
2151     Trace.Indent();
2152     try
2153     {
2154     foreach( STPlugin st in this.listプラグイン )
2155     {
2156     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2157     st.plugin.OnUnmanagedリソスの解放();
2158     st.plugin.OnManagedリソスの解放();
2159     st.plugin.On終了();
2160     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2161     }
2162     PluginHost = null;
2163     Trace.TraceInformation( "すべてのプラグインの終了処理を完了しました。" );
2164     }
2165     finally
2166     {
2167     Trace.Unindent();
2168     }
2169     }
2170     //---------------------
2171     #endregion
2172     #region [ 曲リストの終了処理 ]
2173     //---------------------
2174     if (Songs管理 != null)
2175     {
2176     Trace.TraceInformation( "曲リストの終了処理を行います。" );
2177     Trace.Indent();
2178     try
2179     {
2180     Songs管理 = null;
2181     Trace.TraceInformation( "曲リストの終了処理を完了しました。" );
2182     }
2183     catch( Exception exception )
2184     {
2185     Trace.TraceError( exception.Message );
2186     Trace.TraceError( "曲リストの終了処理に失敗しました。" );
2187     }
2188     finally
2189     {
2190     Trace.Unindent();
2191     }
2192     }
2193     CAvi.t終了();
2194     //---------------------
2195     #endregion
2196     #region [ スキンの終了処理 ]
2197     //---------------------
2198     if (Skin != null)
2199     {
2200     Trace.TraceInformation( "スキンの終了処理を行います。" );
2201     Trace.Indent();
2202     try
2203     {
2204     Skin.Dispose();
2205     Skin = null;
2206     Trace.TraceInformation( "スキンの終了処理を完了しました。" );
2207     }
2208     catch( Exception exception2 )
2209     {
2210     Trace.TraceError( exception2.Message );
2211     Trace.TraceError( "スキンの終了処理に失敗しました。" );
2212     }
2213     finally
2214     {
2215     Trace.Unindent();
2216     }
2217     }
2218     //---------------------
2219     #endregion
2220     #region [ DirectSoundの終了処理 ]
2221     //---------------------
2222     if (Sound管理 != null)
2223     {
2224     Trace.TraceInformation( "DirectSound の終了処理を行います。" );
2225     Trace.Indent();
2226     try
2227     {
2228     Sound管理.Dispose();
2229     Sound管理 = null;
2230     Trace.TraceInformation( "DirectSound の終了処理を完了しました。" );
2231     }
2232     catch( Exception exception3 )
2233     {
2234     Trace.TraceError( exception3.Message );
2235     Trace.TraceError( "DirectSound の終了処理に失敗しました。" );
2236     }
2237     finally
2238     {
2239     Trace.Unindent();
2240     }
2241     }
2242     //---------------------
2243     #endregion
2244     #region [ パッドの終了処理 ]
2245     //---------------------
2246     if (Pad != null)
2247     {
2248     Trace.TraceInformation( "パッドの終了処理を行います。" );
2249     Trace.Indent();
2250     try
2251     {
2252     Pad = null;
2253     Trace.TraceInformation( "パッドの終了処理を完了しました。" );
2254     }
2255     catch( Exception exception4 )
2256     {
2257     Trace.TraceError( exception4.Message );
2258     Trace.TraceError( "パッドの終了処理に失敗しました。" );
2259     }
2260     finally
2261     {
2262     Trace.Unindent();
2263     }
2264     }
2265     //---------------------
2266     #endregion
2267     #region [ DirectInput, MIDI入力の終了処理 ]
2268     //---------------------
2269     if (Input管理 != null)
2270     {
2271     Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を行います。" );
2272     Trace.Indent();
2273     try
2274     {
2275     Input管理.Dispose();
2276     Input管理 = null;
2277     Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を完了しました。" );
2278     }
2279     catch( Exception exception5 )
2280     {
2281     Trace.TraceError( exception5.Message );
2282     Trace.TraceError( "DirectInput, MIDI入力の終了処理に失敗しました。" );
2283     }
2284     finally
2285     {
2286     Trace.Unindent();
2287     }
2288     }
2289     //---------------------
2290     #endregion
2291     #region [ 文字コンソールの終了処理 ]
2292     //---------------------
2293     if (act文字コンソ != null)
2294     {
2295     Trace.TraceInformation( "文字コンソールの終了処理を行います。" );
2296     Trace.Indent();
2297     try
2298     {
2299     act文字コンソ.On非活性化();
2300     act文字コンソ = null;
2301     Trace.TraceInformation( "文字コンソールの終了処理を完了しました。" );
2302     }
2303     catch( Exception exception6 )
2304     {
2305     Trace.TraceError( exception6.Message );
2306     Trace.TraceError( "文字コンソールの終了処理に失敗しました。" );
2307     }
2308     finally
2309     {
2310     Trace.Unindent();
2311     }
2312     }
2313     //---------------------
2314     #endregion
2315     #region [ FPSカウンタの終了処理 ]
2316     //---------------------
2317     Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2318     Trace.Indent();
2319     try
2320     {
2321     if( FPS != null )
2322     {
2323     FPS = null;
2324     }
2325     Trace.TraceInformation( "FPSカウンタの終了処理を完了しました。" );
2326     }
2327     finally
2328     {
2329     Trace.Unindent();
2330     }
2331     //---------------------
2332     #endregion
2333    
2334     // ct.Dispose();
2335    
2336     #region [ タイマの終了処理 ]
2337     //---------------------
2338     Trace.TraceInformation("タイマの終了処理を行います。");
2339     Trace.Indent();
2340     try
2341     {
2342     if( Timer != null )
2343     {
2344     Timer.Dispose();
2345     Timer = null;
2346     Trace.TraceInformation( "タイマの終了処理を完了しました。" );
2347     }
2348     else
2349     {
2350     Trace.TraceInformation( "タイマは使用されていません。" );
2351     }
2352     }
2353     finally
2354     {
2355     Trace.Unindent();
2356     }
2357     //---------------------
2358     #endregion
2359     #region [ Config.iniの出力 ]
2360     //---------------------
2361     Trace.TraceInformation("Config.ini を出力します。");
2362     // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2363     if ( ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped ) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2364     {
2365     ConfigIni.SwapGuitarBassInfos_AutoFlags();
2366     }
2367     string str = strEXEのあるフォルダ + "Config.ini";
2368     Trace.Indent();
2369     try
2370     {
2371     ConfigIni.t書き出し( str );
2372     Trace.TraceInformation( "保存しました。({0})", new object[] { str } );
2373     }
2374     catch( Exception e )
2375     {
2376     Trace.TraceError( e.Message );
2377     Trace.TraceError( "Config.ini の出力に失敗しました。({0})",