Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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