Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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