Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (hide annotations) (download)
Sun Feb 17 05:00:51 2013 UTC (11 years, 1 month ago) by kairera0467
File size: 92903 byte(s)


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