Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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