OSDN Git Service

#39698 099fで起動時に例外が出る問題を修正。
[dtxmania/dtxmania.git] / DTXManiaプロジェクト / コード / 全体 / CDTXMania.cs
index 9fdecb6..be07237 100644 (file)
@@ -20,7 +20,7 @@ namespace DTXMania
        {\r
                // プロパティ\r
                #region [ properties ]\r
-               public static readonly string VERSION = "101(150101)";\r
+               public static readonly string VERSION = "099g(191022)";\r
                public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";\r
                public static readonly string D3DXDLL = "d3dx9_43.dll";         // June 2010\r
         //public static readonly string D3DXDLL = "d3dx9_42.dll";      // February 2010\r
@@ -510,6 +510,10 @@ namespace DTXMania
                }\r
                protected override void Draw( GameTime gameTime )\r
                {\r
+                       if (Sound管理 == null)\r
+                       {\r
+                               return;\r
+                       }\r
                        Sound管理.t再生中の処理をする();\r
 \r
                        if( Timer != null )\r
@@ -1602,7 +1606,6 @@ for (int i = 0; i < 3; i++) {
 \r
                #region [ 汎用ヘルパー ]\r
                //-----------------\r
-               #region [ tテクスチャの生成 ]\r
                public static CTexture tテクスチャの生成( string fileName )\r
                {\r
                        return tテクスチャの生成( fileName, false );\r
@@ -1628,39 +1631,11 @@ for (int i = 0; i < 3; i++) {
                                return null;\r
                        }\r
                }\r
-               public static CTextureAf tテクスチャの生成Af( string fileName )\r
-               {\r
-                       return tテクスチャの生成Af( fileName, false );\r
-               }\r
-               public static CTextureAf tテクスチャの生成Af( string fileName, bool b黒を透過する )\r
-               {\r
-                       if ( app == null )\r
-                       {\r
-                               return null;\r
-                       }\r
-                       try\r
-                       {\r
-                               return new CTextureAf( app.Device, fileName, TextureFormat, b黒を透過する );\r
-                       }\r
-                       catch ( CTextureCreateFailedException )\r
-                       {\r
-                               Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );\r
-                               return null;\r
-                       }\r
-                       catch ( FileNotFoundException )\r
-                       {\r
-                               Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );\r
-                               return null;\r
-                       }\r
-               }\r
                public static void tテクスチャの解放( ref CTexture tx )\r
                {\r
                        CDTXMania.t安全にDisposeする( ref tx );\r
                }\r
-               public static void tテクスチャの解放( ref CTextureAf tx )\r
-               {\r
-                       CDTXMania.t安全にDisposeする( ref tx );\r
-               }\r
+\r
                public static CTexture tテクスチャの生成( byte[] txData )\r
                {\r
                        return tテクスチャの生成( txData, false );\r
@@ -1671,11 +1646,6 @@ for (int i = 0; i < 3; i++) {
                        {\r
                                return null;\r
                        }\r
-                       if ( txData == null )\r
-                       {\r
-                               Trace.TraceError( "テクスチャの生成に失敗しました。(txData==null)" );\r
-                               return null;\r
-                       }\r
                        try\r
                        {\r
                                return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );\r
@@ -1697,22 +1667,16 @@ for (int i = 0; i < 3; i++) {
                        {\r
                                return null;\r
                        }\r
-                       if ( bitmap == null )\r
-                       {\r
-                               Trace.TraceError( "テクスチャの生成に失敗しました。(bitmap==null)" );\r
-                               return null;\r
-                       }\r
                        try\r
                        {\r
                                return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );\r
                        }\r
                        catch ( CTextureCreateFailedException )\r
                        {\r
-                               Trace.TraceError( "テクスチャの生成に失敗しました。(bitmap)" );\r
+                               Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );\r
                                return null;\r
                        }\r
                }\r
-               #endregion\r
 \r
                /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>\r
                public static void t安全にDisposeする<T>( ref T obj )\r
@@ -1758,14 +1722,14 @@ for (int i = 0; i < 3; i++) {
                {\r
                        #region [ strEXEのあるフォルダを決定する ]\r
                        //-----------------\r
-                       // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)\r
+// BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)\r
 #if DEBUG\r
                        strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";\r
                        //strEXEのあるフォルダ = Path.GetDirectoryName( Environment.GetCommandLineArgs()[ 0 ] ) + @"\";\r
 #else\r
                        strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\";       // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.\r
 #endif\r
-                       // END #23629 2010.11.13 from\r
+// END #23629 2010.11.13 from\r
                        //-----------------\r
                        #endregion\r
 \r
@@ -1773,11 +1737,11 @@ for (int i = 0; i < 3; i++) {
                        //---------------------\r
                        ConfigIni = new CConfigIni();\r
                        string path = strEXEのあるフォルダ + "Config.ini";\r
-                       if (File.Exists(path))\r
+                       if( File.Exists( path ) )\r
                        {\r
                                try\r
                                {\r
-                                       ConfigIni.tファイルから読み込み(path);\r
+                                       ConfigIni.tファイルから読み込み( path );\r
                                }\r
                                catch\r
                                {\r
@@ -1792,32 +1756,32 @@ for (int i = 0; i < 3; i++) {
                        #region [ ログ出力開始 ]\r
                        //---------------------\r
                        Trace.AutoFlush = true;\r
-                       if (ConfigIni.bログ出力)\r
+                       if( ConfigIni.bログ出力 )\r
                        {\r
                                try\r
                                {\r
-                                       Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "DTXManiaLog.txt"), false, Encoding.GetEncoding("utf-16"))));\r
+                                       Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( System.IO.Path.Combine( strEXEのあるフォルダ, "DTXManiaLog.txt" ), false, Encoding.GetEncoding( "Shift_JIS" ) ) ) );\r
                                }\r
-                               catch (System.UnauthorizedAccessException)                      // #24481 2011.2.20 yyagi\r
+                               catch ( System.UnauthorizedAccessException )                    // #24481 2011.2.20 yyagi\r
                                {\r
-                                       int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja") ? 0 : 1;\r
+                                       int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;\r
                                        string[] mes_writeErr = {\r
                                                "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",\r
                                                "Failed to write DTXManiaLog.txt. Please set it writable and try again."\r
                                        };\r
-                                       MessageBox.Show(mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                                       MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );\r
                                        Environment.Exit(1);\r
                                }\r
                        }\r
                        Trace.WriteLine("");\r
-                       Trace.WriteLine("DTXMania powered by YAMAHA Silent Session Drums");\r
-                       Trace.WriteLine(string.Format("Release: {0}", VERSION));\r
-                       Trace.WriteLine("");\r
-                       Trace.TraceInformation("----------------------");\r
-                       Trace.TraceInformation("■ アプリケーションの初期化");\r
-                       Trace.TraceInformation("OS Version: " + Environment.OSVersion);\r
-                       Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());\r
-                       Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());\r
+                       Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );\r
+                       Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );\r
+                       Trace.WriteLine( "" );\r
+                       Trace.TraceInformation( "----------------------" );\r
+                       Trace.TraceInformation( "■ アプリケーションの初期化" );\r
+                       Trace.TraceInformation( "OS Version: " + Environment.OSVersion );\r
+                       Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );\r
+                       Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );\r
                        //---------------------\r
                        #endregion\r
                        #region [ DTXVmodeクラス の初期化 ]\r
@@ -1841,28 +1805,29 @@ for (int i = 0; i < 3; i++) {
                        bコンパクトモード = false;\r
                        strコンパクトモードファイル = "";\r
                        string[] commandLineArgs = Environment.GetCommandLineArgs();\r
-                       if ((commandLineArgs != null) && (commandLineArgs.Length > 1))\r
+                       if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )\r
                        {\r
                                bコンパクトモード = true;\r
                                string arg = "";\r
 \r
-                               for (int i = 1; i < commandLineArgs.Length; i++)\r
+                               for ( int i = 1; i < commandLineArgs.Length; i++ )\r
                                {\r
-                                       if (i != 1)\r
+                                       if ( i != 1 )\r
                                        {\r
-                                               arg += " " + "\"" + commandLineArgs[i] + "\"";\r
+                                               arg += " " + "\"" + commandLineArgs[ i ] + "\"";\r
                                        }\r
                                        else\r
                                        {\r
-                                               arg += commandLineArgs[i];\r
+                                               arg += commandLineArgs[ i ];\r
                                        }\r
                                }\r
-                               DTXVmode.ParseArguments(arg);\r
-                               if (DTXVmode.Enabled)\r
+                               DTXVmode.ParseArguments( arg );\r
+                               \r
+                               if ( DTXVmode.Enabled )\r
                                {\r
                                        DTXVmode.Refreshed = false;                                                             // 初回起動時は再読み込みに走らせない\r
                                        strコンパクトモードファイル = DTXVmode.filename;\r
-                                       switch (DTXVmode.soundDeviceType)                                               // サウンド再生方式の設定\r
+                                       switch ( DTXVmode.soundDeviceType )                                             // サウンド再生方式の設定\r
                                        {\r
                                                case ESoundDeviceType.DirectSound:\r
                                                        ConfigIni.nSoundDeviceType = 0;\r
@@ -1880,22 +1845,17 @@ for (int i = 0; i < 3; i++) {
                                        CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;\r
                                        CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;\r
                                        CDTXMania.ConfigIni.bGuitar有効 = true;\r
-\r
-                                       CDTXMania.ConfigIni.nウインドウwidth = CDTXMania.ConfigIni.nViewerウインドウwidth;\r
-                                       CDTXMania.ConfigIni.nウインドウheight = CDTXMania.ConfigIni.nViewerウインドウheight;\r
-                                       CDTXMania.ConfigIni.n初期ウィンドウ開始位置X = CDTXMania.ConfigIni.nViewer初期ウィンドウ開始位置X;\r
-                                       CDTXMania.ConfigIni.n初期ウィンドウ開始位置Y = CDTXMania.ConfigIni.nViewer初期ウィンドウ開始位置Y;\r
                                }\r
                                else                                                                                                            // 通常のコンパクトモード\r
                                {\r
-                                       strコンパクトモードファイル = commandLineArgs[1];\r
+                                       strコンパクトモードファイル = commandLineArgs[ 1 ];\r
                                }\r
 \r
-                               if (!File.Exists(strコンパクトモードファイル))              // #32985 2014.1.23 yyagi \r
+                               if ( !File.Exists( strコンパクトモードファイル ) )          // #32985 2014.1.23 yyagi \r
                                {\r
-                                       Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);\r
+                                       Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル );\r
 #if DEBUG\r
-                                       Environment.Exit(-1);\r
+                                       Environment.Exit( -1 );\r
 #else\r
                                        if ( strコンパクトモードファイル == "" )    // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了\r
                                        {\r
@@ -1907,118 +1867,48 @@ for (int i = 0; i < 3; i++) {
                                        }\r
 #endif\r
                                }\r
-                               if (DTXVmode.Enabled)\r
+                               if ( DTXVmode.Enabled )\r
                                {\r
-                                       Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);\r
+                                       Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモードファイル );\r
                                }\r
                                else\r
                                {\r
-                                       Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);\r
+                                       Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモードファイル );\r
                                }\r
                        }\r
                        //---------------------\r
                        #endregion\r
 \r
-\r
-                       #region [ Input管理 の初期化 ]\r
-                       //---------------------\r
-                       Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");\r
-                       Trace.Indent();\r
-                       try\r
-                       {\r
-                               bool bUseMIDIIn = !DTXVmode.Enabled;\r
-                               Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);\r
-                               foreach (IInputDevice device in Input管理.list入力デバイス)\r
-                               {\r
-                                       if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.ContainsValue(device.GUID))\r
-                                       {\r
-                                               int key = 0;\r
-                                               while (ConfigIni.dicJoystick.ContainsKey(key))\r
-                                               {\r
-                                                       key++;\r
-                                               }\r
-                                               ConfigIni.dicJoystick.Add(key, device.GUID);\r
-                                       }\r
-                               }\r
-                               foreach (IInputDevice device2 in Input管理.list入力デバイス)\r
-                               {\r
-                                       if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)\r
-                                       {\r
-                                               foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick)\r
-                                               {\r
-                                                       if (device2.GUID.Equals(pair.Value))\r
-                                                       {\r
-                                                               ((CInputJoystick)device2).SetID(pair.Key);\r
-                                                               break;\r
-                                                       }\r
-                                               }\r
-                                               continue;\r
-                                       }\r
-                               }\r
-                               Trace.TraceInformation("DirectInput の初期化を完了しました。");\r
-                       }\r
-                       catch (Exception exception2)\r
-                       {\r
-                               Trace.TraceError(exception2.Message);\r
-                               Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");\r
-\r
-                               int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja") ? 0 : 1;\r
-                               string[] mes_writeErr = {\r
-                                               "DirectInputまたはMIDI入力の初期化に失敗しました。DTXManiaGRを終了します。",\r
-                                               "Failed to initialize DirectInput (or MIDI-IN)."\r
-                               };\r
-                               MessageBox.Show(mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                               Environment.Exit(1);\r
-                       }\r
-                       finally\r
-                       {\r
-                               Trace.Unindent();\r
-                       }\r
-                       //---------------------\r
-                       #endregion\r
-\r
                        #region [ ウィンドウ初期化 ]\r
                        //---------------------\r
                        base.Window.StartPosition = FormStartPosition.Manual;                                                       // #30675 2013.02.04 ikanick add\r
-                       base.Window.Location = new Point(ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y);   // #30675 2013.02.04 ikanick add\r
+                       base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y );   // #30675 2013.02.04 ikanick add\r
 \r
                        base.Window.Text = this.strWindowTitle;         // 事前にDTXVmodeの実体を作っておくこと\r
 \r
                        base.Window.StartPosition = FormStartPosition.Manual;                                                       // #30675 2013.02.04 ikanick add\r
-                       base.Window.Location = new Point(ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y);   // #30675 2013.02.04 ikanick add\r
-\r
-                       if (ConfigIni.nウインドウwidth <= 0 && ConfigIni.nウインドウheight <= 0)              // #34069 2014.7.24 yyagi 初回起動時は1280x720にする\r
-                       {\r
-                               ConfigIni.nウインドウwidth = 1280;\r
-                               ConfigIni.nウインドウheight = 720;\r
-                               //w = this.Window.Screen.WorkingArea.Width;\r
-                               //h = this.Window.Screen.WorkingArea.Height;\r
-                               //w = base.Window.Screen.Bounds.Width;\r
-                               //h = base.Window.Screen.Bounds.Height;\r
-                               //ConfigIni.nウインドウwidth = SampleFramework.GameWindowSize.Width;\r
-                               //ConfigIni.nウインドウheight = SampleFramework.GameWindowSize.Height;\r
-                       }\r
+            base.Window.Location = new Point(ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y);   // #30675 2013.02.04 ikanick add\r
 \r
                        base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight);   // #34510 yyagi 2010.10.31 to change window size got from Config.ini\r
 #if !WindowedFullscreen\r
                        if (!ConfigIni.bウィンドウモード)                                               // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode\r
                        {                                                                                                               // #30666 2013.02.02 yyagi: currentClientSize should be always made\r
 #endif\r
-                       currentClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight);\r
+                               currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );\r
 #if !WindowedFullscreen\r
                        }\r
 #endif\r
                        base.Window.MaximizeBox = true;                                                 // #23510 2010.11.04 yyagi: to support maximizing window\r
                        base.Window.FormBorderStyle = FormBorderStyle.Sizable;  // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize\r
-                       // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()\r
+                                                                                                                                               // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()\r
                        base.Window.ShowIcon = true;\r
                        base.Window.Icon = Properties.Resources.dtx;\r
-                       base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);\r
-                       base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);\r
+                       base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );\r
+                       base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);\r
                        base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);    // #23510 2010.11.13 yyagi: to go fullscreen mode\r
                        base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);                                               // #23510 2010.11.20 yyagi: to set resized window size in Config.ini\r
                        base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);\r
-                       base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);\r
+                       base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );\r
                        //---------------------\r
                        #endregion\r
                        #region [ Direct3D9Exを使うかどうか判定 ]\r
@@ -2033,14 +1923,14 @@ for (int i = 0; i < 3; i++) {
 #endif\r
                        settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;\r
                        settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;\r
-                       //                      settings.BackBufferCount = 3;\r
+//                     settings.BackBufferCount = 3;\r
                        settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;\r
-                       //                      settings.BackBufferFormat = Format.A8R8G8B8;\r
-                       //                      settings.MultisampleType = MultisampleType.FourSamples;\r
-                       //                      settings.MultisampleQuality = 4;\r
-                       //                      settings.MultisampleType = MultisampleType.None;\r
-                       //                      settings.MultisampleQuality = 0;\r
-\r
+//                     settings.BackBufferFormat = Format.A8R8G8B8;\r
+//                     settings.MultisampleType = MultisampleType.FourSamples;\r
+//                     settings.MultisampleQuality = 4;\r
+//                     settings.MultisampleType = MultisampleType.None;\r
+//                     settings.MultisampleQuality = 0;\r
+                       \r
                        try\r
                        {\r
                                base.GraphicsDeviceManager.ChangeDevice(settings);\r
@@ -2051,12 +1941,12 @@ for (int i = 0; i < 3; i++) {
                                MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                                Environment.Exit(-1);\r
                        }\r
-\r
+                       \r
                        base.IsFixedTimeStep = false;\r
-                       //                      base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );\r
+//                     base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );\r
                        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.\r
                        base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォーカス時スリープms));    // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive\r
-                       // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )\r
+                                                                                                                                                                                                                               // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )\r
 #if WindowedFullscreen\r
                        this.t全画面・ウィンドウモード切り替え();                               // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"\r
 #endif\r
@@ -2068,17 +1958,17 @@ for (int i = 0; i < 3; i++) {
 \r
                        #region [ Skin の初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("スキンの初期化を行います。");\r
+                       Trace.TraceInformation( "スキンの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
-                               Skin = new CSkin(CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin);\r
-                               CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName(true);      // 旧指定のSkinフォルダが消滅していた場合に備える\r
-                               Trace.TraceInformation("スキンの初期化を完了しました。");\r
+                               Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );\r
+                               CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true );    // 旧指定のSkinフォルダが消滅していた場合に備える\r
+                               Trace.TraceInformation( "スキンの初期化を完了しました。" );\r
                        }\r
                        catch\r
                        {\r
-                               Trace.TraceInformation("スキンの初期化に失敗しました。");\r
+                               Trace.TraceInformation( "スキンの初期化に失敗しました。" );\r
                                throw;\r
                        }\r
                        finally\r
@@ -2090,12 +1980,12 @@ for (int i = 0; i < 3; i++) {
                        //-----------\r
                        #region [ Timer の初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("タイマの初期化を行います。");\r
+                       Trace.TraceInformation( "タイマの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
-                               Timer = new CTimer(CTimer.E種別.MultiMedia);\r
-                               Trace.TraceInformation("タイマの初期化を完了しました。");\r
+                               Timer = new CTimer( CTimer.E種別.MultiMedia );\r
+                               Trace.TraceInformation( "タイマの初期化を完了しました。" );\r
                        }\r
                        finally\r
                        {\r
@@ -2107,12 +1997,12 @@ for (int i = 0; i < 3; i++) {
 \r
                        #region [ FPS カウンタの初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("FPSカウンタの初期化を行います。");\r
+                       Trace.TraceInformation( "FPSカウンタの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
                                FPS = new CFPS();\r
-                               Trace.TraceInformation("FPSカウンタを生成しました。");\r
+                               Trace.TraceInformation( "FPSカウンタを生成しました。" );\r
                        }\r
                        finally\r
                        {\r
@@ -2122,20 +2012,69 @@ for (int i = 0; i < 3; i++) {
                        #endregion\r
                        #region [ act文字コンソールの初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("文字コンソールの初期化を行います。");\r
+                       Trace.TraceInformation( "文字コンソールの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
                                act文字コンソール = new C文字コンソール();\r
-                               Trace.TraceInformation("文字コンソールを生成しました。");\r
+                               Trace.TraceInformation( "文字コンソールを生成しました。" );\r
                                act文字コンソール.On活性化();\r
-                               Trace.TraceInformation("文字コンソールを活性化しました。");\r
-                               Trace.TraceInformation("文字コンソールの初期化を完了しました。");\r
+                               Trace.TraceInformation( "文字コンソールを活性化しました。" );\r
+                               Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );\r
                        }\r
-                       catch (Exception exception)\r
+                       catch( Exception exception )\r
                        {\r
-                               Trace.TraceError(exception.Message);\r
-                               Trace.TraceError("文字コンソールの初期化に失敗しました。");\r
+                               Trace.TraceError( exception.Message );\r
+                               Trace.TraceError( "文字コンソールの初期化に失敗しました。" );\r
+                       }\r
+                       finally\r
+                       {\r
+                               Trace.Unindent();\r
+                       }\r
+                       //---------------------\r
+                       #endregion\r
+                       #region [ Input管理 の初期化 ]\r
+                       //---------------------\r
+                       Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );\r
+                       Trace.Indent();\r
+                       try\r
+                       {\r
+                               bool bUseMIDIIn = !DTXVmode.Enabled;\r
+                               Input管理 = new CInput管理( base.Window.Handle, bUseMIDIIn );\r
+                               foreach( IInputDevice device in Input管理.list入力デバイス )\r
+                               {\r
+                                       if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )\r
+                                       {\r
+                                               int key = 0;\r
+                                               while( ConfigIni.dicJoystick.ContainsKey( key ) )\r
+                                               {\r
+                                                       key++;\r
+                                               }\r
+                                               ConfigIni.dicJoystick.Add( key, device.GUID );\r
+                                       }\r
+                               }\r
+                               foreach( IInputDevice device2 in Input管理.list入力デバイス )\r
+                               {\r
+                                       if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )\r
+                                       {\r
+                                               foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )\r
+                                               {\r
+                                                       if( device2.GUID.Equals( pair.Value ) )\r
+                                                       {\r
+                                                               ( (CInputJoystick) device2 ).SetID( pair.Key );\r
+                                                               break;\r
+                                                       }\r
+                                               }\r
+                                               continue;\r
+                                       }\r
+                               }\r
+                               Trace.TraceInformation( "DirectInput の初期化を完了しました。" );\r
+                       }\r
+                       catch( Exception exception2 )\r
+                       {\r
+                               Trace.TraceError( exception2.Message );\r
+                               Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );\r
+                               throw;\r
                        }\r
                        finally\r
                        {\r
@@ -2145,32 +2084,32 @@ for (int i = 0; i < 3; i++) {
                        #endregion\r
                        #region [ Pad の初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("パッドの初期化を行います。");\r
+                       Trace.TraceInformation( "パッドの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
-                               Pad = new CPad(ConfigIni, Input管理);\r
-                               Trace.TraceInformation("パッドの初期化を完了しました。");\r
+                               Pad = new CPad( ConfigIni, Input管理 );\r
+                               Trace.TraceInformation( "パッドの初期化を完了しました。" );\r
                        }\r
-                       catch (Exception exception3)\r
+                       catch( Exception exception3 )\r
                        {\r
-                               Trace.TraceError(exception3.Message);\r
-                               Trace.TraceError("パッドの初期化に失敗しました。");\r
+                               Trace.TraceError( exception3.Message );\r
+                               Trace.TraceError( "パッドの初期化に失敗しました。" );\r
                        }\r
                        finally\r
                        {\r
                                Trace.Unindent();\r
                        }\r
-                        //---------------------\r
+                       //---------------------\r
                        #endregion\r
                        #region [ Sound管理 の初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("サウンドデバイスの初期化を行います。");\r
+                       Trace.TraceInformation( "サウンドデバイスの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
                                ESoundDeviceType soundDeviceType;\r
-                               switch (CDTXMania.ConfigIni.nSoundDeviceType)\r
+                               switch ( CDTXMania.ConfigIni.nSoundDeviceType )\r
                                {\r
                                        case 0:\r
                                                soundDeviceType = ESoundDeviceType.DirectSound;\r
@@ -2185,9 +2124,10 @@ for (int i = 0; i < 3; i++) {
                                                soundDeviceType = ESoundDeviceType.Unknown;\r
                                                break;\r
                                }\r
-                               Sound管理 = new CSound管理(base.Window.Handle,\r
+                               Sound管理 = new CSound管理( base.Window.Handle,\r
                                                                                        soundDeviceType,\r
                                                                                        CDTXMania.ConfigIni.nWASAPIBufferSizeMs,\r
+                                                                                       // 0,\r
                                        // CDTXMania.ConfigIni.nASIOBufferSizeMs,\r
                                                                                        0,\r
                                                                                        CDTXMania.ConfigIni.nASIODevice,\r
@@ -2195,16 +2135,16 @@ for (int i = 0; i < 3; i++) {
                                );\r
                                //Sound管理 = FDK.CSound管理.Instance;\r
                                //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.ConfigIni.nASIODevice, base.Window.Handle );\r
-\r
+       \r
                                ShowWindowTitleWithSoundType();\r
                                FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;\r
                                Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;\r
                                //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;\r
-                               Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");\r
+                               Trace.TraceInformation( "サウンドデバイスの初期化を完了しました。" );\r
                        }\r
                        catch (Exception e)\r
                        {\r
-                               Trace.TraceError(e.Message);\r
+                               Trace.TraceError( e.Message );\r
                                throw;\r
                        }\r
                        finally\r
@@ -2215,20 +2155,20 @@ for (int i = 0; i < 3; i++) {
                        #endregion\r
                        #region [ Songs管理 の初期化 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("曲リストの初期化を行います。");\r
+                       Trace.TraceInformation( "曲リストの初期化を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
                                Songs管理 = new CSongs管理();\r
-                               //                              Songs管理_裏読 = new CSongs管理();\r
+//                             Songs管理_裏読 = new CSongs管理();\r
                                EnumSongs = new CEnumSongs();\r
                                actEnumSongs = new CActEnumSongs();\r
-                               Trace.TraceInformation("曲リストの初期化を完了しました。");\r
+                               Trace.TraceInformation( "曲リストの初期化を完了しました。" );\r
                        }\r
-                       catch (Exception e)\r
+                       catch( Exception e )\r
                        {\r
-                               Trace.TraceError(e.Message);\r
-                               Trace.TraceError("曲リストの初期化に失敗しました。");\r
+                               Trace.TraceError( e.Message );\r
+                               Trace.TraceError( "曲リストの初期化に失敗しました。" );\r
                        }\r
                        finally\r
                        {\r
@@ -2243,7 +2183,7 @@ for (int i = 0; i < 3; i++) {
                        #endregion\r
                        #region [ Random の初期化 ]\r
                        //---------------------\r
-                       Random = new Random((int)Timer.nシステム時刻);\r
+                       Random = new Random( (int) Timer.nシステム時刻 );\r
                        //---------------------\r
                        #endregion\r
                        #region [ ステージの初期化 ]\r
@@ -2252,7 +2192,7 @@ for (int i = 0; i < 3; i++) {
                        r直前のステージ = null;\r
                        stage起動 = new CStage起動();\r
                        stageタイトル = new CStageタイトル();\r
-                       //                      stageオプション = new CStageオプション();\r
+//                     stageオプション = new CStageオプション();\r
                        stageコンフィグ = new CStageコンフィグ();\r
                        stage選曲 = new CStage選曲();\r
                        stage曲読み込み = new CStage曲読み込み();\r
@@ -2262,32 +2202,32 @@ for (int i = 0; i < 3; i++) {
                        stageChangeSkin = new CStageChangeSkin();\r
                        stage終了 = new CStage終了();\r
                        this.listトップレベルActivities = new List<CActivity>();\r
-                       this.listトップレベルActivities.Add(actEnumSongs);\r
-                       this.listトップレベルActivities.Add(act文字コンソール);\r
-                       this.listトップレベルActivities.Add(stage起動);\r
-                       this.listトップレベルActivities.Add(stageタイトル);\r
-                       //                      this.listトップレベルActivities.Add( stageオプション );\r
-                       this.listトップレベルActivities.Add(stageコンフィグ);\r
-                       this.listトップレベルActivities.Add(stage選曲);\r
-                       this.listトップレベルActivities.Add(stage曲読み込み);\r
-                       this.listトップレベルActivities.Add(stage演奏ドラム画面);\r
-                       this.listトップレベルActivities.Add(stage演奏ギター画面);\r
-                       this.listトップレベルActivities.Add(stage結果);\r
-                       this.listトップレベルActivities.Add(stageChangeSkin);\r
-                       this.listトップレベルActivities.Add(stage終了);\r
-                       this.listトップレベルActivities.Add(actFlushGPU);\r
+                       this.listトップレベルActivities.Add( actEnumSongs );\r
+                       this.listトップレベルActivities.Add( act文字コンソール );\r
+                       this.listトップレベルActivities.Add( stage起動 );\r
+                       this.listトップレベルActivities.Add( stageタイトル );\r
+//                     this.listトップレベルActivities.Add( stageオプション );\r
+                       this.listトップレベルActivities.Add( stageコンフィグ );\r
+                       this.listトップレベルActivities.Add( stage選曲 );\r
+                       this.listトップレベルActivities.Add( stage曲読み込み );\r
+                       this.listトップレベルActivities.Add( stage演奏ドラム画面 );\r
+                       this.listトップレベルActivities.Add( stage演奏ギター画面 );\r
+                       this.listトップレベルActivities.Add( stage結果 );\r
+                       this.listトップレベルActivities.Add( stageChangeSkin );\r
+                       this.listトップレベルActivities.Add( stage終了 );\r
+                       this.listトップレベルActivities.Add( actFlushGPU );\r
                        //---------------------\r
                        #endregion\r
                        #region [ プラグインの検索と生成 ]\r
                        //---------------------\r
                        PluginHost = new CPluginHost();\r
 \r
-                       Trace.TraceInformation("プラグインの検索と生成を行います。");\r
+                       Trace.TraceInformation( "プラグインの検索と生成を行います。" );\r
                        Trace.Indent();\r
                        try\r
                        {\r
                                this.tプラグイン検索と生成();\r
-                               Trace.TraceInformation("プラグインの検索と生成を完了しました。");\r
+                               Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );\r
                        }\r
                        finally\r
                        {\r
@@ -2297,25 +2237,25 @@ for (int i = 0; i < 3; i++) {
                        #endregion\r
                        #region [ プラグインの初期化 ]\r
                        //---------------------\r
-                       if (this.listプラグイン != null && this.listプラグイン.Count > 0)\r
+                       if( this.listプラグイン != null && this.listプラグイン.Count > 0 )\r
                        {\r
-                               Trace.TraceInformation("プラグインの初期化を行います。");\r
+                               Trace.TraceInformation( "プラグインの初期化を行います。" );\r
                                Trace.Indent();\r
                                try\r
                                {\r
-                                       foreach (STPlugin st in this.listプラグイン)\r
+                                       foreach( STPlugin st in this.listプラグイン )\r
                                        {\r
-                                               Directory.SetCurrentDirectory(st.strプラグインフォルダ);\r
-                                               st.plugin.On初期化(this.PluginHost);\r
+                                               Directory.SetCurrentDirectory( st.strプラグインフォルダ );\r
+                                               st.plugin.On初期化( this.PluginHost );\r
                                                st.plugin.OnManagedリソースの作成();\r
                                                st.plugin.OnUnmanagedリソースの作成();\r
-                                               Directory.SetCurrentDirectory(CDTXMania.strEXEのあるフォルダ);\r
+                                               Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );\r
                                        }\r
-                                       Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");\r
+                                       Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );\r
                                }\r
                                catch\r
                                {\r
-                                       Trace.TraceError("プラグインのどれかの初期化に失敗しました。");\r
+                                       Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );\r
                                        throw;\r
                                }\r
                                finally\r
@@ -2327,14 +2267,14 @@ for (int i = 0; i < 3; i++) {
                        //---------------------\r
                        #endregion\r
 \r
-                       Trace.TraceInformation("アプリケーションの初期化を完了しました。");\r
-\r
+                       Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );\r
+                       \r
                        #region [ 最初のステージの起動 ]\r
                        //---------------------\r
-                       Trace.TraceInformation("----------------------");\r
-                       Trace.TraceInformation("■ 起動");\r
+                       Trace.TraceInformation( "----------------------" );\r
+                       Trace.TraceInformation( "■ 起動" );\r
 \r
-                       if (CDTXMania.bコンパクトモード)\r
+                       if ( CDTXMania.bコンパクトモード )\r
                        {\r
                                r現在のステージ = stage曲読み込み;\r
                        }\r
@@ -2763,6 +2703,10 @@ for (int i = 0; i < 3; i++) {
                        string[] strDLLs = System.IO.Directory.GetFiles( strプラグインフォルダパス, "*.dll" );\r
                        foreach( string dllName in strDLLs )\r
                        {\r
+                               if (Path.GetExtension(dllName).ToLower() != ".dll")\r
+                               {\r
+                                       continue;\r
+                               }\r
                                try\r
                                {\r
                                        // (1-1) dll をアセンブリとして読み込む。\r
@@ -2788,11 +2732,9 @@ for (int i = 0; i < 3; i++) {
                                                }\r
                                        }\r
                                }\r
-                               catch (Exception e)\r
+                               catch\r
                                {\r
                                        Trace.TraceInformation( dllName + " からプラグインを生成することに失敗しました。スキップします。" );\r
-                                       Trace.TraceInformation( e.ToString() );\r
-                                       Trace.TraceInformation( e.Message );\r
                                }\r
                        }\r
 \r