Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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