Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations) (download)
Tue Feb 26 10:55:18 2013 UTC (11 years, 1 month ago) by kairera0467
File size: 93458 byte(s)
#30763 現在選択中の曲以外の画像のY軸回転をSTマトリックス座標から読み出すようにした。
本家rev536までの更新を適用。

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