Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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