OSDN Git Service

09bba10b1aef19056343004c9feba620b66eba89
[dtxmania/dtxmania.git] / DTXMania / コード / 全体 / CDTXMania.cs
1 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.IO;
9 using System.Threading;
10 using System.Management;
11 using SharpDX;
12 using SharpDX.Direct3D9;
13 using FDK;
14 using SampleFramework;
15 using System.Runtime.Serialization;
16 using System.Runtime;
17 using System.Xml;
18
19 using Point = System.Drawing.Point;
20 using Color = System.Drawing.Color;
21
22 namespace DTXMania
23 {
24         internal class CDTXMania : Game
25         {
26                 // プロパティ
27                 #region [ properties ]
28                 public static readonly string VERSION = "115(190901)";
29                 //public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
30                 public static readonly string D3DXDLL = "d3dx9_43.dll";     // June 2010
31                 //public static readonly string D3DXDLL = "d3dx9_42.dll";       // February 2010
32                 //public static readonly string D3DXDLL = "d3dx9_41.dll";       // March 2009
33                 private static CDTXMania instance = new CDTXMania();
34
35                 public static CDTXMania Instance
36                 {
37                         get
38                         {
39                                 return instance;
40                         }
41                 }
42                 public C文字コンソール act文字コンソール { get; private set; }
43                 public bool bコンパクトモード { get; private set; }
44                 public CConfigXml ConfigIni;
45                 public CResources Resources;
46
47                 public CDTX DTX
48                 {
49                         get
50                         {
51                                 return dtx;
52                         }
53                         set
54                         {
55                                 if ((dtx != null) && (Instance != null))
56                                 {
57                                         dtx.On非活性化();
58                                         Instance.listトップレベルActivities.Remove(dtx);
59                                 }
60                                 dtx = value;
61                                 if ((dtx != null) && (Instance != null))
62                                 {
63                                         Instance.listトップレベルActivities.Add(dtx);
64                                 }
65                         }
66                 }
67                 public CFPS FPS { get; private set; }
68                 public CInput管理 Input管理 { get; private set; }
69                 #region [ 入力範囲ms ]
70                 public int nPerfect範囲ms
71                 {
72                         get
73                         {
74                                 if (stage選曲.r確定された曲 != null)
75                                 {
76                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
77                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPerfect範囲ms >= 0))
78                                         {
79                                                 return c曲リストノード.nPerfect範囲ms;
80                                         }
81                                 }
82                                 return ConfigIni.nHitRange.Perfect;
83                         }
84                 }
85                 public int nGreat範囲ms
86                 {
87                         get
88                         {
89                                 if (stage選曲.r確定された曲 != null)
90                                 {
91                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
92                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGreat範囲ms >= 0))
93                                         {
94                                                 return c曲リストノード.nGreat範囲ms;
95                                         }
96                                 }
97                                 return ConfigIni.nHitRange.Great;
98                         }
99                 }
100                 public int nGood範囲ms
101                 {
102                         get
103                         {
104                                 if (stage選曲.r確定された曲 != null)
105                                 {
106                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
107                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGood範囲ms >= 0))
108                                         {
109                                                 return c曲リストノード.nGood範囲ms;
110                                         }
111                                 }
112                                 return ConfigIni.nHitRange.Good;
113                         }
114                 }
115                 public int nPoor範囲ms
116                 {
117                         get
118                         {
119                                 if (stage選曲.r確定された曲 != null)
120                                 {
121                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
122                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPoor範囲ms >= 0))
123                                         {
124                                                 return c曲リストノード.nPoor範囲ms;
125                                         }
126                                 }
127                                 return ConfigIni.nHitRange.Poor;
128                         }
129                 }
130                 #endregion
131                 public CPad Pad { get; private set; }
132                 public Random Random { get; private set; }
133                 public CSkin Skin { get; private set; }
134                 public CSongs管理 Songs管理 { get; set; }// 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
135                 public CEnumSongs EnumSongs { get; private set; }
136                 public CActEnumSongs actEnumSongs { get; private set; }
137                 public CActFlushGPU actFlushGPU { get; private set; }
138
139                 public CSound管理 Sound管理 { get; private set; }
140                 public CStage起動 stage起動 { get; private set; }
141                 public CStageタイトル stageタイトル { get; private set; }
142                 public CStageコンフィグ stageコンフィグ { get; private set; }
143                 public CStage選曲 stage選曲 { get; private set; }
144                 public CStage曲読み込み stage曲読み込み { get; private set; }
145                 public CStage演奏画面共通 stage演奏画面 { get; private set; }
146                 public CStage結果 stage結果 { get; private set; }
147                 public CStageChangeSkin stageChangeSkin { get; private set; }
148                 public CStage終了 stage終了 { get; private set; }
149                 public CStage r現在のステージ = null;
150                 public CStage r直前のステージ = null;
151                 public CStage r1フレーム前のステージ = null;
152                 public string strEXEのあるフォルダ { get; private set; }
153                 public string strコンパクトモードファイル { get; private set; }
154                 public CTimer Timer { get; private set; }
155                 public Format TextureFormat = Format.A8R8G8B8;
156                 internal IPluginActivity act現在入力を占有中のプラグイン = null;
157                 public bool bApplicationActive { get; private set; }
158                 public bool b次のタイミングで垂直帰線同期切り替えを行う { get; set; }
159                 public bool b次のタイミングで全画面_ウィンドウ切り替えを行う { get; set; }
160                 public Coordinates.CCoordinates Coordinates;
161                 public Device Device
162                 {
163                         get
164                         {
165                                 return base.GraphicsDeviceManager.Direct3D9.Device;
166                         }
167                 }
168                 public CPluginHost PluginHost { get; private set; }
169                 public List<STPlugin> listプラグイン = new List<STPlugin>();
170
171                 private Size currentClientSize { get; set; }    // #23510 2010.10.27 add yyagi to keep current window size
172                                                                                                                                                                                                                 //              public static CTimer ct;
173                 public IntPtr WindowHandle                  // 2012.10.24 yyagi; to add ASIO support
174                 {
175                         get
176                         {
177                                 return base.Window.Handle;
178                         }
179                 }
180         public CDTXVmode DTXVmode;                       // #28821 2014.1.23 yyagi
181         public CDTX2WAVmode DTX2WAVmode;
182         public CCommandParse CommandParse;
183         #endregion
184
185         // コンストラクタ
186
187         private CDTXMania()
188                 {
189                 }
190
191                 public void InitializeInstance()
192                 {
193                         #region [ strEXEのあるフォルダを決定する ]
194                         // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
195 #if DEBUG
196                         strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
197                         //strEXEのあるフォルダ = Path.GetDirectoryName( Environment.GetCommandLineArgs()[ 0 ] ) + @"\";
198 #else
199                         strEXEのあるフォルダ = Path.GetDirectoryName(Application.ExecutablePath) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
200 #endif
201                         // END #23629 2010.11.13 from
202                         #endregion
203
204                         #region [ 言語リソースの初期化 ]
205                         Trace.TraceInformation("言語リソースの初期化を行います。");
206                         Trace.Indent();
207                         try
208                         {
209                                 Resources = new CResources();
210                                 Resources.LoadResources("");
211                                 Trace.TraceInformation("言語リソースの初期化を完了しました。");
212                         }
213                         finally
214                         {
215                                 Trace.Unindent();
216                         }
217                         #endregion
218
219                         #region [ Config.ini の読込み ]
220                         ConfigIni = new CConfigXml();
221                         CDTXMania.Instance.LoadConfig();
222                         // #28200 2011.5.1 yyagi
223                         this.Window.EnableSystemMenu = CDTXMania.Instance.ConfigIni.bIsEnabledSystemMenu;
224                         // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
225                         #endregion
226
227
228                         #region[座標値読み込み]
229                         Coordinates = new Coordinates.CCoordinates();
230                         UpdateCoordinates();
231                         //Coordinates = (DTXMania.Coordinates.CCoordinates) CDTXMania.DeserializeXML( strEXEのあるフォルダ + "Coordinates.xml", typeof( DTXMania.Coordinates.CCoordinates ) );
232                         //if ( Coordinates == null )
233                         //{
234                         //      if ( File.Exists( strEXEのあるフォルダ + "Coordinates.xml" ) )
235                         //      {
236                         //              Trace.TraceInformation( "Coordinates.xmlファイルは存在します。" );
237                         //      }
238                         //      Trace.TraceInformation( "Coordiantes.xmlファイルの読み込みができませんでした。無視して進めます。" );
239                         //      Coordinates = new Coordinates.CCoordinates();
240                         //}
241                         #endregion
242
243                         #region [ ログ出力開始 ]
244                         Trace.AutoFlush = true;
245                         if (ConfigIni.bLog)
246                         {
247                                 try
248                                 {
249                                         Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "DTXManiaLog.txt"), false, Encoding.GetEncoding("utf-16"))));
250                                 }
251                                 catch (System.UnauthorizedAccessException)          // #24481 2011.2.20 yyagi
252                                 {
253                                         Resources.Language = instance.ConfigIni.strLanguage;
254                                         string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
255                                         MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
256                                         Environment.Exit(1);
257                                 }
258                         }
259                         Trace.WriteLine("");
260                         Trace.WriteLine("DTXMania powered by YAMAHA Silent Session Drums");
261                         Trace.WriteLine(string.Format("Release: {0} {1} mode.", VERSION, (Environment.Is64BitProcess)? "x64":"x86" ));
262                         Trace.WriteLine("");
263                         Trace.TraceInformation("----------------------");
264                         Trace.TraceInformation("■ アプリケーションの初期化");
265
266                         PutSystemLog();
267
268
269                         #endregion
270
271                         #region [ 言語の設定 ]
272                         Trace.TraceInformation("言語情報の読み込みを開始します。");
273                         //Debug.WriteLine( "language=" + Resources.Language );
274                         //Debug.WriteLine( "settings=" + instance.ConfigIni.strLanguage );
275                         Resources.Language = instance.ConfigIni.strLanguage;
276                         Trace.TraceInformation("言語を{0}に設定しました。", Resources.Language);
277
278                         #endregion
279
280                         #region [ DTXVmodeクラス, DTX2WAVmodeクラス, CommandParseクラス の初期化 ]
281                         //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
282                         //Trace.Indent();
283                         try
284                         {
285                                 DTXVmode = new CDTXVmode();
286                                 DTXVmode.Enabled = false;
287                 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
288
289                 DTX2WAVmode = new CDTX2WAVmode();
290                 //Trace.TraceInformation( "DTX2WAVモードの初期化を完了しました。" );
291
292                 CommandParse = new CCommandParse();
293                 //Trace.TraceInformation( "CommandParseの初期化を完了しました。" );
294             }
295             finally
296                         {
297                                 //Trace.Unindent();
298                         }
299                         #endregion
300                         #region [ コンパクトモードスイッチの有無、もしくは、DTXViewer/DTX2WAVとしての起動 ]
301                         bコンパクトモード = false;
302                         strコンパクトモードファイル = "";
303                         string[] commandLineArgs = Environment.GetCommandLineArgs();
304                         if ((commandLineArgs != null) && (commandLineArgs.Length > 1))
305                         {
306                                 bコンパクトモード = true;
307                                 string arg = "";
308
309                                 for (int i = 1; i < commandLineArgs.Length; i++)
310                                 {
311                                         if (i != 1)
312                                         {
313                                                 arg += " " + "\"" + commandLineArgs[i] + "\"";
314                                         }
315                                         else
316                                         {
317                                                 arg += commandLineArgs[i];
318                                         }
319                                 }
320                                 CommandParse.ParseArguments(arg, ref DTXVmode, ref DTX2WAVmode);
321                                 if (DTXVmode.Enabled)
322                                 {
323                                         DTXVmode.Refreshed = false;                             // 初回起動時は再読み込みに走らせない
324                                         strコンパクトモードファイル = DTXVmode.filename;
325                                         switch (DTXVmode.soundDeviceType)                       // サウンド再生方式の設定
326                                         {
327                                                 case ESoundDeviceType.DirectSound:
328                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.DSound;
329                                                         break;
330                                                 case ESoundDeviceType.ExclusiveWASAPI:
331                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
332                                                         break;
333                                                 case ESoundDeviceType.SharedWASAPI:
334                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
335                                                         break;
336                                                 case ESoundDeviceType.ASIO:
337                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.ASIO;
338                                                         ConfigIni.strASIODevice.Index = DTXVmode.nASIOdevice;
339                                                         break;
340                                         }
341
342                                         CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
343                                         CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
344                                         if (DTXVmode.GRmode)
345                                         {
346                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
347                                         }
348                                         else
349                                         {
350                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
351                                         }
352
353                                         CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
354                                         CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;       // #36612 2016.9.12 yyagi
355                                         CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
356                                         CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
357                                         CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
358                                         CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
359                                 }
360                                 else if (DTX2WAVmode.Enabled)
361                                 {
362                                         strコンパクトモードファイル = DTX2WAVmode.dtxfilename;
363                                         #region [ FDKへの録音設定 ]
364                                         FDK.CSound管理.strRecordInputDTXfilename = DTX2WAVmode.dtxfilename;
365                                         FDK.CSound管理.strRecordOutFilename = DTX2WAVmode.outfilename;
366                                         FDK.CSound管理.strRecordFileType = DTX2WAVmode.Format.ToString();
367                                         FDK.CSound管理.nBitrate = DTX2WAVmode.bitrate;
368                                         for (int i = 0; i < (int)FDK.CSound.EInstType.Unknown; i++)
369                                         {
370                                                 FDK.CSound管理.nMixerVolume[ i ] = DTX2WAVmode.nMixerVolume[ i ];
371                                         }
372                                         ConfigIni.nMasterVolume.Value = DTX2WAVmode.nMixerVolume[(int)FDK.CSound.EInstType.Unknown];    // [5](Unknown)のところにMasterVolumeが入ってくるので注意
373                                                                                                                                                                                                                                         // CSound管理.nMixerVolume[5]は、結局ここからは変更しないため、
374                                                                                                                                                                                                                                         // 事実上初期値=100で固定。
375                                         #endregion
376                                         #region [ 録音用の本体設定 ]
377
378                                         // 本体プロセスの優先度を少し上げる (最小化状態で動作させると、処理性能が落ちるようなので
379                                         // → ほとんど効果がなかったので止めます
380                                         //Process thisProcess = System.Diagnostics.Process.GetCurrentProcess();
381                                         //thisProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
382
383                                         // エンコーダーのパス設定 (=DLLフォルダ)
384                                         FDK.CSound管理.strEncoderPath = Path.Combine(strEXEのあるフォルダ, "DLL");
385
386                                         CDTXMania.instance.ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
387                                         CDTXMania.instance.ConfigIni.bEventDrivenWASAPI.Value = false;
388
389                                         CDTXMania.instance.ConfigIni.bVSyncWait.Value = false;
390                                         CDTXMania.instance.ConfigIni.bTimeStretch.Value = false;
391                                         CDTXMania.instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
392
393                                         CDTXMania.instance.ConfigIni.bFullScreen.Value = false;
394                                         CDTXMania.instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;
395                                         CDTXMania.instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
396                                         CDTXMania.instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
397                                         CDTXMania.instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
398                                         CDTXMania.instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
399
400                                         //全オート
401                                         CDTXMania.instance.ConfigIni.bAutoPlay.LC.Value = true;
402                                         CDTXMania.instance.ConfigIni.bAutoPlay.HH.Value = true;
403                                         CDTXMania.instance.ConfigIni.bAutoPlay.HHO.Value = true;
404                                         CDTXMania.instance.ConfigIni.bAutoPlay.SD.Value = true;
405                                         CDTXMania.instance.ConfigIni.bAutoPlay.BD.Value = true;
406                                         CDTXMania.instance.ConfigIni.bAutoPlay.HT.Value = true;
407                                         CDTXMania.instance.ConfigIni.bAutoPlay.LT.Value = true;
408                                         CDTXMania.instance.ConfigIni.bAutoPlay.FT.Value = true;
409                                         CDTXMania.instance.ConfigIni.bAutoPlay.CY.Value = true;
410                                         CDTXMania.instance.ConfigIni.bAutoPlay.RD.Value = true;
411
412                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtR.Value = true;
413                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtG.Value = true;
414                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtB.Value = true;
415                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtPick.Value = true;
416                                         //CDTXMania.instance.ConfigIni.bAutoPlay.GtWail.Value = true;  // 無くてもよい 処理不可削減のため、敢えてWailはAutoにしない
417                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsR.Value = true;
418                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsG.Value = true;
419                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsB.Value = true;
420                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsPick.Value = true;
421                                         //CDTXMania.instance.ConfigIni.bAutoPlay.BsWail.Value = true;
422
423                                         //FillInオフ, 歓声オフ
424                                         CDTXMania.instance.ConfigIni.bFillin.Value = false;
425                                         CDTXMania.instance.ConfigIni.bAudience.Value = false;
426                                         //ストイックモード
427                                         CDTXMania.instance.ConfigIni.bStoicMode.Value = false;
428                                         //チップ非表示
429                                         CDTXMania.instance.ConfigIni.eSudHidInv.Drums.Value = ESudHidInv.FullInv;
430                                         CDTXMania.instance.ConfigIni.eSudHidInv.Guitar.Value = ESudHidInv.FullInv;
431                                         CDTXMania.instance.ConfigIni.eSudHidInv.Bass.Value = ESudHidInv.FullInv;
432
433                                         // Dark=Full
434                                         CDTXMania.instance.ConfigIni.eDark.Value = EDark.Full;
435
436                                         //多重再生数=4
437                                         CDTXMania.instance.ConfigIni.nPolyphonicSounds.Value = 4;
438
439                                         //再生速度x1
440                                         CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
441
442                                         //メトロノーム音量0
443                                         CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
444                                         CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
445                                         CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
446
447                                         //自動再生音量=100
448                                         CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
449                                         CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
450
451                                         //マスターボリューム100
452                                         //CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100;       // DTX2WAV側から設定するので、ここでは触らない
453
454                                         //StageFailedオフ
455                                         CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
456
457                                         //グラフ無効
458                                         CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
459                                         CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
460                                         CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
461
462                                         //コンボ非表示,判定非表示
463                                         CDTXMania.instance.ConfigIni.bDisplayCombo.Drums.Value = false;
464                                         CDTXMania.instance.ConfigIni.bDisplayCombo.Guitar.Value = false;
465                                         CDTXMania.instance.ConfigIni.bDisplayCombo.Bass.Value = false;
466                                         CDTXMania.instance.ConfigIni.bDisplayJudge.Drums.Value = false;
467                                         CDTXMania.instance.ConfigIni.bDisplayJudge.Guitar.Value = false;
468                                         CDTXMania.instance.ConfigIni.bDisplayJudge.Bass.Value = false;
469
470
471                                         //デバッグ表示オフ
472                                         //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
473                                         CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
474
475                                         //BGAオフ, AVIオフ
476                                         CDTXMania.instance.ConfigIni.bBGA.Value = false;
477                                         CDTXMania.instance.ConfigIni.bAVI.Value = false;
478
479                                         //BGMオン、チップ音オン
480                                         CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
481                                         CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
482
483                                         //パート強調オフ
484                                         CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Drums.Value = false;
485                                         CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Guitar.Value = false;
486                                         CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Bass.Value = false;
487
488                                         // パッド入力等、基本操作の無効化 (ESCを除く)
489                                         //CDTXMania.Instance.ConfigIni.KeyAssign[][];
490                                         
491                                         #endregion
492                                 }
493                                 else                                                        // 通常のコンパクトモード
494                                 {
495                                         strコンパクトモードファイル = commandLineArgs[1];
496                                 }
497
498                                 if (!File.Exists(strコンパクトモードファイル))      // #32985 2014.1.23 yyagi 
499                                 {
500                                         Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
501 #if DEBUG
502                                         Environment.Exit(-1);
503 #else
504                                         if (strコンパクトモードファイル == "")      // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
505                                         {
506                                                 Environment.Exit(-1);
507                                         }
508                                         else
509                                         {
510                                                 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
511                                         }
512 #endif
513                                 }
514                                 if (DTXVmode.Enabled)
515                                 {
516                                         Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
517                                 }
518                                 else if (DTX2WAVmode.Enabled)
519                                 {
520                                         Trace.TraceInformation("DTX2WAVモードで起動します。[{0}]", strコンパクトモードファイル);
521                                         DTX2WAVmode.SendMessage2DTX2WAV("BOOT");
522                                 }
523                                 else
524                                 {
525                                         Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
526                                 }
527                         }
528                         else
529                         {
530                                 Trace.TraceInformation("通常モードで起動します。");
531                         }
532                         #endregion
533
534                         #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
535                         CPowerPlan.BackupCurrentPowerPlan();
536                         if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
537                         {
538                                 CPowerPlan.ChangeHighPerformance();
539                         }
540                         #endregion
541
542                         #region [ Input管理 の初期化 ]
543                         Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
544                         Trace.Indent();
545                         try
546                         {
547                                 bool bUseMIDIIn = !DTXVmode.Enabled;
548                                 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
549
550                                 // If the users uses MIDI2.0-USB cable, then warn it
551                                 if (bUseMIDIIn && CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value)
552                                 {
553                                         foreach (IInputDevice device in Input管理.list入力デバイス)
554                                         {
555                                                 if ((device.e入力デバイス種別 == E入力デバイス種別.MidiIn) && (device.strDeviceName == "USB2.0-MIDI"))
556                                                 {
557                                                         string strWarnMes = CDTXMania.Instance.Resources.Explanation("strWarnMIDI20USB");
558                                                         var ret = MessageBox.Show(strWarnMes, "DTXMania Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
559                                                         if (ret == DialogResult.OK)
560                                                         {
561                                                                 CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value = false;
562                                                         }
563                                                 }
564                                         }
565                                 }
566
567
568
569                                 foreach (IInputDevice device in Input管理.list入力デバイス)
570                                 {
571                                         if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
572                                         {
573                                                 int key = 0;
574                                                 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
575                                                 {
576                                                         key++;
577                                                 }
578                                                 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
579                                         }
580                                 }
581                                 foreach (IInputDevice device2 in Input管理.list入力デバイス)
582                                 {
583                                         if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
584                                         {
585                                                 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
586                                                 {
587                                                         if (device2.GUID.Equals(pair.Value))
588                                                         {
589                                                                 ((CInputJoystick)device2).SetID(pair.Key);
590                                                                 break;
591                                                         }
592                                                 }
593                                                 continue;
594                                         }
595                                 }
596                                 Trace.TraceInformation("DirectInput の初期化を完了しました。");
597                         }
598                         catch (Exception exception2)
599                         {
600                                 Trace.TraceError(exception2.Message);
601                                 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
602
603                                 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
604                                 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
605                                 Environment.Exit(1);
606                         }
607                         finally
608                         {
609                                 Trace.Unindent();
610                         }
611                         #endregion
612
613                         #region [ ウィンドウ初期化 ]
614                         // #30675 2013.02.04 ikanick add
615                         base.Window.StartPosition = FormStartPosition.Manual;
616                         base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
617                         // 事前にDTXVmodeの実体を作っておくこと
618                         base.Window.Text = this.strWindowTitle;
619                         //base.Window.StartPosition = FormStartPosition.Manual;
620                         //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
621
622                         // #34510 yyagi 2010.10.31 to change window size got from Config.ini
623                         base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
624 #if !WindowedFullscreen
625                         if (!ConfigIni.bウィンドウモード)                                               // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
626                         {                                                                                                               // #30666 2013.02.02 yyagi: currentClientSize should be always made
627 #endif
628                         currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
629 #if !WindowedFullscreen
630                         }
631 #endif
632                         // #23510 2010.11.04 yyagi: to support maximizing window
633                         base.Window.MaximizeBox = true;
634                         // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
635                         base.Window.FormBorderStyle = FormBorderStyle.Sizable;
636                         // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
637                         base.Window.ShowIcon = true;
638                         base.Window.Icon = Properties.Resources.dtx;
639                         base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
640                         base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
641                         // #23510 2010.11.13 yyagi: to go fullscreen mode
642                         base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
643                         // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
644                         base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
645                         base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
646                         base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
647                         base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
648                         #endregion
649
650                         #region [ Direct3D9Exを使うかどうか判定 ]
651                         #endregion
652
653                         #region [ Direct3D9 デバイスの生成 ]
654                         DeviceSettings settings = new DeviceSettings();
655 #if WindowedFullscreen
656                         // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
657                         settings.Windowed = true;
658 #else
659                         settings.Windowed = ConfigIni.bウィンドウモード;
660 #endif
661                         settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
662                         settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
663                         settings.EnableVSync = ConfigIni.bVSyncWait;
664                         //settings.MultisampleType = MultisampleType.FourSamples;
665                         //settings.MultisampleQuality = 3;
666                         //settings.MultisampleType = MultisampleType.NonMaskable;
667                         //settings.Multithreaded = true;
668
669
670                         try
671                         {
672                                 base.GraphicsDeviceManager.ChangeDevice(settings);
673                         }
674                         catch (DeviceCreationException e)
675                         {
676                                 Trace.TraceError(e.ToString());
677                                 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
678                                 Environment.Exit(-1);
679                         }
680                         Trace.TraceInformation("DeviceCaps       = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
681                         Trace.TraceInformation("DeviceCaps2      = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
682                         Trace.TraceInformation("MaxTextureWidth  = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
683                         Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
684                         Trace.TraceInformation("TextureCaps      = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
685                         Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
686                         Trace.TraceInformation("DeviceStatics    = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
687
688                         base.IsFixedTimeStep = false;
689                         //                      base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
690                         // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
691                         base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
692                         // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
693                         base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
694                         // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
695 #if WindowedFullscreen
696                         // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
697                         this.t全画面_ウィンドウモード切り替え();
698 #endif
699                         actFlushGPU = new CActFlushGPU();
700                         #endregion
701
702                         if (DTX2WAVmode.Enabled)
703                         {
704                                 this.Window.WindowState = FormWindowState.Minimized;            //DTX2WAVモード時は自動的に最小化
705                         }
706
707                         DTX = null;
708
709                         #region [ Skin の初期化 ]
710                         Trace.TraceInformation("スキンの初期化を行います。");
711                         Trace.Indent();
712                         try
713                         {
714                                 Skin = new CSkin(
715                                         CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
716                                         CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
717                                 // 旧指定のSkinフォルダが消滅していた場合に備える
718                                 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
719                                 Trace.TraceInformation("スキンの初期化を完了しました。");
720                         }
721                         catch
722                         {
723                                 Trace.TraceInformation("スキンの初期化に失敗しました。");
724                                 throw;
725                         }
726                         finally
727                         {
728                                 Trace.Unindent();
729                         }
730
731                         #region [ Skin配下にある言語リソースの確認と初期化 ]
732                         Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
733                         Trace.Indent();
734                         try
735                         {
736                                 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
737                                 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
738
739                                 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
740                                 if (ret)
741                                 {
742                                         Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
743                                 }
744                                 else
745                                 {
746                                         Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
747
748                                 }
749                         }
750                         finally
751                         {
752                                 Trace.Unindent();
753                         }
754                         #endregion
755
756                         #endregion
757
758                         #region [ Timer の初期化 ]
759                         Trace.TraceInformation("タイマの初期化を行います。");
760                         Trace.Indent();
761                         try
762                         {
763                                 Timer = new CTimer(CTimer.E種別.MultiMedia);
764                                 Trace.TraceInformation("タイマの初期化を完了しました。");
765                         }
766                         finally
767                         {
768                                 Trace.Unindent();
769                         }
770                         #endregion
771
772                         #region [ マウス消去用のクラスを初期化 ]
773                         cMouseHideControl = new CMouseHideControl();
774                         #endregion
775
776                         #region [ FPS カウンタの初期化 ]
777                         Trace.TraceInformation("FPSカウンタの初期化を行います。");
778                         Trace.Indent();
779                         try
780                         {
781                                 FPS = new CFPS();
782                                 Trace.TraceInformation("FPSカウンタを生成しました。");
783                         }
784                         finally
785                         {
786                                 Trace.Unindent();
787                         }
788                         #endregion
789
790                         #region [ act文字コンソールの初期化 ]
791                         Trace.TraceInformation("文字コンソールの初期化を行います。");
792                         Trace.Indent();
793                         try
794                         {
795                                 act文字コンソール = new C文字コンソール();
796                                 Trace.TraceInformation("文字コンソールを生成しました。");
797                                 act文字コンソール.On活性化();
798                                 Trace.TraceInformation("文字コンソールを活性化しました。");
799                                 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
800                         }
801                         catch (Exception exception)
802                         {
803                                 Trace.TraceError(exception.Message);
804                                 Trace.TraceError("文字コンソールの初期化に失敗しました。");
805                         }
806                         finally
807                         {
808                                 Trace.Unindent();
809                         }
810                         #endregion
811
812                         #region [ Pad の初期化 ]
813                         Trace.TraceInformation("パッドの初期化を行います。");
814                         Trace.Indent();
815                         try
816                         {
817                                 Pad = new CPad();
818                                 Trace.TraceInformation("パッドの初期化を完了しました。");
819                         }
820                         catch (Exception exception3)
821                         {
822                                 Trace.TraceError(exception3.Message);
823                                 Trace.TraceError("パッドの初期化に失敗しました。");
824                         }
825                         finally
826                         {
827                                 Trace.Unindent();
828                         }
829                         #endregion
830
831                         #region [ Sound管理 の初期化 ]
832                         Trace.TraceInformation("サウンドデバイスの初期化を行います。");
833                         Trace.Indent();
834                         try
835                         {
836                                 ESoundDeviceType soundDeviceType;
837                                 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
838                                 {
839                                         case ESoundDeviceTypeForConfig.DSound:
840                                                 soundDeviceType = ESoundDeviceType.DirectSound;
841                                                 break;
842                                         case ESoundDeviceTypeForConfig.ASIO:
843                                                 soundDeviceType = ESoundDeviceType.ASIO;
844                                                 break;
845                                         case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
846                                                 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
847                                                 break;
848                                         case ESoundDeviceTypeForConfig.WASAPI_Shared:
849                                                 soundDeviceType = ESoundDeviceType.SharedWASAPI;
850                                                 break;
851                                         default:
852                                                 soundDeviceType = ESoundDeviceType.Unknown;
853                                                 break;
854                                 }
855                                 Sound管理 = new CSound管理(base.Window.Handle,
856                                                                                         soundDeviceType,
857                                                                                         CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
858                                                                                         CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
859                                                                                         0,
860                                                                                         CDTXMania.Instance.ConfigIni.strASIODevice.Index,
861                                                                                         CDTXMania.Instance.ConfigIni.bUseOSTimer
862                                 );
863                                 //Sound管理 = FDK.CSound管理.Instance;
864                                 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
865
866                                 ShowWindowTitleWithSoundType();
867                                 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
868                                 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
869                                 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
870
871
872                                 string strDefaultSoundDeviceBusType = CSound管理.strDefaultDeviceBusType;
873                                 Trace.TraceInformation($"Bus type of the default sound device = {strDefaultSoundDeviceBusType}");
874
875                                 if (strDefaultSoundDeviceBusType.ToUpper().Equals("USB"))
876                                 {
877                                         if (CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value)
878                                         {
879                                                 string strWarnMes = CDTXMania.Instance.Resources.Explanation("strWarnSoundDeviceOnUSB");
880                                                 var ret = MessageBox.Show(strWarnMes, "DTXMania Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
881                                                 if (ret == DialogResult.OK)
882                                                 {
883                                                         CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value = false;
884                                                 }
885                                         }
886                                 }
887
888                                 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
889                         }
890                         catch (Exception e)
891                         {
892                                 Trace.TraceError(e.Message);
893                                 throw;
894                         }
895                         finally
896                         {
897                                 Trace.Unindent();
898                         }
899                         #endregion
900
901                         #region [ Songs管理 の初期化 ]
902                         //---------------------
903                         Trace.TraceInformation("曲リストの初期化を行います。");
904                         Trace.Indent();
905                         try
906                         {
907                                 Songs管理 = new CSongs管理();
908                                 //                              Songs管理_裏読 = new CSongs管理();
909                                 EnumSongs = new CEnumSongs();
910                                 actEnumSongs = new CActEnumSongs();
911                                 Trace.TraceInformation("曲リストの初期化を完了しました。");
912                         }
913                         catch (Exception e)
914                         {
915                                 Trace.TraceError(e.Message);
916                                 Trace.TraceError("曲リストの初期化に失敗しました。");
917                         }
918                         finally
919                         {
920                                 Trace.Unindent();
921                         }
922                         //---------------------
923                         #endregion
924
925                         #region [ CAvi の初期化 ]
926                         CAvi.t初期化();
927                         #endregion
928
929                         #region [ Random の初期化 ]
930                         Random = new Random((int)Timer.nシステム時刻);
931                         #endregion
932
933                         #region [ ステージの初期化 ]
934                         r現在のステージ = null;
935                         r直前のステージ = null;
936                         stage起動 = new CStage起動();
937                         stageタイトル = new CStageタイトル();
938                         stageコンフィグ = new CStageコンフィグ();
939                         stage選曲 = new CStage選曲();
940                         stage曲読み込み = new CStage曲読み込み();
941                         stage演奏画面 = new CStage演奏画面共通();
942                         stage結果 = new CStage結果();
943                         stageChangeSkin = new CStageChangeSkin();
944                         stage終了 = new CStage終了();
945
946                         this.listトップレベルActivities = new List<CActivity>();
947                         this.listトップレベルActivities.Add(actEnumSongs);
948                         this.listトップレベルActivities.Add(act文字コンソール);
949                         this.listトップレベルActivities.Add(stage起動);
950                         this.listトップレベルActivities.Add(stageタイトル);
951                         this.listトップレベルActivities.Add(stageコンフィグ);
952                         this.listトップレベルActivities.Add(stage選曲);
953                         this.listトップレベルActivities.Add(stage曲読み込み);
954                         this.listトップレベルActivities.Add(stage演奏画面);
955                         this.listトップレベルActivities.Add(stage結果);
956                         this.listトップレベルActivities.Add(stageChangeSkin);
957                         this.listトップレベルActivities.Add(stage終了);
958                         this.listトップレベルActivities.Add(actFlushGPU);
959                         #endregion
960
961                         #region [ プラグインの検索と生成 ]
962                         PluginHost = new CPluginHost();
963
964                         Trace.TraceInformation("プラグインの検索と生成を行います。");
965                         Trace.Indent();
966                         try
967                         {
968                                 this.tプラグイン検索と生成();
969                                 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
970                         }
971                         finally
972                         {
973                                 Trace.Unindent();
974                         }
975                         #endregion
976
977                         #region [ プラグインの初期化 ]
978                         if (this.listプラグイン != null && this.listプラグイン.Count > 0)
979                         {
980                                 Trace.TraceInformation("プラグインの初期化を行います。");
981                                 Trace.Indent();
982                                 try
983                                 {
984                                         foreach (STPlugin st in this.listプラグイン)
985                                         {
986                                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
987                                                 st.plugin.On初期化(this.PluginHost);
988                                                 st.plugin.OnManagedリソースの作成();
989                                                 st.plugin.OnUnmanagedリソースの作成();
990                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
991                                         }
992                                         Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
993                                 }
994                                 catch
995                                 {
996                                         Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
997                                         throw;
998                                 }
999                                 finally
1000                                 {
1001                                         Trace.Unindent();
1002                                 }
1003                         }
1004                         #endregion
1005
1006
1007                         Trace.TraceInformation("アプリケーションの初期化を完了しました。");
1008
1009                         #region [ 最初のステージの起動 ]
1010                         Trace.TraceInformation("----------------------");
1011                         Trace.TraceInformation("■ 起動");
1012
1013                         if (CDTXMania.Instance.bコンパクトモード)
1014                         {
1015                                 r現在のステージ = stage曲読み込み;
1016                         }
1017                         else
1018                         {
1019                                 r現在のステージ = stage起動;
1020                         }
1021                         r現在のステージ.On活性化();
1022                         #endregion
1023                 }
1024
1025
1026                 public void t全画面_ウィンドウモード切り替え()
1027                 {
1028 #if WindowedFullscreen
1029                         if (ConfigIni != null)
1030 #else
1031                         DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
1032                         if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
1033 #endif
1034                         {
1035 #if !WindowedFullscreen
1036                                 settings.Windowed = ConfigIni.bウィンドウモード;
1037 #endif
1038                                 if (ConfigIni.bウィンドウモード == false)   // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
1039                                 {
1040                                         currentClientSize = this.Window.ClientSize;
1041                                         ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
1042                                         ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
1043                                         //                                      FDK.CTaskBar.ShowTaskBar( false );
1044                                 }
1045 #if !WindowedFullscreen
1046                                 base.GraphicsDeviceManager.ChangeDevice( settings );
1047 #endif
1048                                 if (ConfigIni.bウィンドウモード == true)    // #23510 2010.10.27 yyagi: to resume window size from backuped value
1049                                 {
1050 #if WindowedFullscreen
1051                                         // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
1052                                         // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
1053                                         // in spite of using fullscreen mode.
1054                                         Instance.Window.WindowState = FormWindowState.Normal;
1055                                         Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1056                                         Instance.Window.WindowState = FormWindowState.Normal;
1057 #endif
1058                                         base.Window.ClientSize =
1059                                                         new Size(currentClientSize.Width, currentClientSize.Height);
1060                                         //                                      FDK.CTaskBar.ShowTaskBar( true );
1061                                 }
1062 #if WindowedFullscreen
1063                                 else
1064                                 {
1065                                         Instance.Window.WindowState = FormWindowState.Normal;
1066                                         Instance.Window.FormBorderStyle = FormBorderStyle.None;
1067                                         Instance.Window.WindowState = FormWindowState.Maximized;
1068                                 }
1069                                 if (cMouseHideControl != null)
1070                                 {
1071                                         if (ConfigIni.bウィンドウモード)
1072                                         {
1073                                                 cMouseHideControl.Show();
1074                                         }
1075                                         else
1076                                         {
1077                                                 cMouseHideControl.Hide();
1078                                         }
1079                                 }
1080 #endif
1081                         }
1082                 }
1083
1084                 #region [ #24609 リザルト画像をpngで保存する ]              // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1085                 /// <summary>
1086                 /// リザルト画像のキャプチャと保存。
1087                 /// </summary>
1088                 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1089                 public bool SaveResultScreen(string strFullPath)
1090                 {
1091                         string strSavePath = Path.GetDirectoryName(strFullPath);
1092                         if (!Directory.Exists(strSavePath))
1093                         {
1094                                 try
1095                                 {
1096                                         Directory.CreateDirectory(strSavePath);
1097                                 }
1098                                 catch
1099                                 {
1100                                         return false;
1101                                 }
1102                         }
1103
1104                         // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1105                         using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1106                         {
1107                                 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1108                         }
1109                         return true;
1110                 }
1111                 #endregion
1112
1113                 // Game 実装
1114
1115                 protected override void Initialize()
1116                 {
1117                         //                      new GCBeep();
1118                         //sw.Start();
1119                         //swlist1 = new List<int>( 8192 );
1120                         //swlist2 = new List<int>( 8192 );
1121                         //swlist3 = new List<int>( 8192 );
1122                         //swlist4 = new List<int>( 8192 );
1123                         //swlist5 = new List<int>( 8192 );
1124                         if (this.listトップレベルActivities != null)
1125                         {
1126                                 foreach (CActivity activity in this.listトップレベルActivities)
1127                                         activity.OnManagedリソースの作成();
1128                         }
1129
1130                         foreach (STPlugin st in this.listプラグイン)
1131                         {
1132                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1133                                 st.plugin.OnManagedリソースの作成();
1134                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1135                         }
1136 #if GPUFlushAfterPresent
1137                         FrameEnd += dtxmania_FrameEnd;
1138 #endif
1139                 }
1140 #if GPUFlushAfterPresent
1141                 void dtxmania_FrameEnd( object sender, EventArgs e )    // GraphicsDeviceManager.game_FrameEnd()後に実行される
1142                 {                                                                                                               // → Present()直後にGPUをFlushする
1143                                                                                                                                 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1144                         actFlushGPU.On進行描画();           // Flush GPU
1145                 }
1146 #endif
1147                 protected override void LoadContent()
1148                 {
1149                         if (cMouseHideControl != null)
1150                         {
1151                                 if (ConfigIni.bウィンドウモード)
1152                                 {
1153                                         cMouseHideControl.Show();
1154                                 }
1155                                 else
1156                                 {
1157                                         cMouseHideControl.Hide();
1158                                 }
1159                         }
1160                         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)));
1161                         this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1162                         this.Device.SetRenderState(RenderState.Lighting, false);
1163                         this.Device.SetRenderState(RenderState.ZEnable, false);                                         // trueにすると、一部システムで画面表示できなくなる
1164                         this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false);       // trueにすると、一部システムで画面表示できなくなる 
1165                         this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1166                         this.Device.SetRenderState(RenderState.AlphaRef, 10);
1167
1168                         this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1169                         this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1170                         this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1171
1172                         this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1173                         this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1174                         this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1175                         this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1176                         this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1177                         this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1178                         this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1179
1180                         if (this.listトップレベルActivities != null)
1181                         {
1182                                 foreach (CActivity activity in this.listトップレベルActivities)
1183                                         activity.OnUnmanagedリソースの作成();
1184                         }
1185
1186                         foreach (STPlugin st in this.listプラグイン)
1187                         {
1188                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1189                                 st.plugin.OnUnmanagedリソースの作成();
1190                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1191                         }
1192                 }
1193                 protected override void UnloadContent()
1194                 {
1195                         if (this.listトップレベルActivities != null)
1196                         {
1197                                 foreach (CActivity activity in this.listトップレベルActivities)
1198                                         activity.OnUnmanagedリソースの解放();
1199                         }
1200
1201                         foreach (STPlugin st in this.listプラグイン)
1202                         {
1203                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1204                                 st.plugin.OnUnmanagedリソースの解放();
1205                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1206                         }
1207                 }
1208                 protected override void OnExiting(EventArgs e)
1209                 {
1210                         CPowerManagement.tEnableMonitorSuspend();       // スリープ抑止状態を解除
1211                         this.t終了処理();
1212                         base.OnExiting(e);
1213                 }
1214                 protected override void Update(GameTime gameTime)
1215                 {
1216                 }
1217                 protected override void Draw(GameTime gameTime)
1218                 {
1219                         if (Sound管理 == null)
1220                         {
1221                                 return;
1222                         }
1223                         //Sound管理.t再生中の処理をする();
1224
1225                         if (Timer != null)
1226                                 Timer.t更新();
1227                         if (CSound管理.rc演奏用タイマ != null)
1228                                 CSound管理.rc演奏用タイマ.t更新();
1229
1230                         if (Input管理 != null)
1231                                 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1232
1233                         if (FPS != null)
1234                                 FPS.tカウンタ更新();
1235
1236                         //if( Pad != null )                                     ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1237                         //      Pad.st検知したデバイス.Clear();
1238
1239                         if (this.Device == null)
1240                                 return;
1241
1242                         if (this.bApplicationActive)    // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1243                                 CPowerManagement.tDisableMonitorSuspend();
1244
1245                         // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1246                         #region [ スリープ ]
1247                         if (ConfigIni.nSleepPerFrameMs >= 0)            // #xxxxx 2011.11.27 yyagi
1248                         {
1249                                 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1250                         }
1251                         #endregion
1252
1253                         #region [ DTXCreator/DTX2WAVからの指示 ]
1254                         if (this.Window.IsReceivedMessage)  // ウインドウメッセージで、
1255                         {
1256                                 string strMes = this.Window.strMessage;
1257                                 this.Window.IsReceivedMessage = false;
1258                                 if (strMes != null)
1259                                 {
1260                                         CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1261
1262                                         if (DTXVmode.Enabled)
1263                                         {
1264                                                 bコンパクトモード = true;
1265                                                 strコンパクトモードファイル = DTXVmode.filename;
1266                                                 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1267                                                 {
1268                                                         // preview soundの再生
1269                                                         string strPreviewFilename = DTXVmode.previewFilename;
1270                                                         //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1271                                                         try
1272                                                         {
1273                                                                 if (this.previewSound != null)
1274                                                                 {
1275                                                                         this.previewSound.tサウンドを停止する();
1276                                                                         this.previewSound.Dispose();
1277                                                                         this.previewSound = null;
1278                                                                 }
1279                                                                 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1280                                                                 this.previewSound.n音量 = DTXVmode.previewVolume;
1281                                                                 this.previewSound.n位置 = DTXVmode.previewPan;
1282                                                                 this.previewSound.t再生を開始する();
1283                                                                 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1284                                                         }
1285                                                         catch
1286                                                         {
1287                                                                 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1288                                                                 if (this.previewSound != null)
1289                                                                 {
1290                                                                         this.previewSound.Dispose();
1291                                                                 }
1292                                                                 this.previewSound = null;
1293                                                         }
1294                                                 }
1295                                         }
1296                                         if (DTX2WAVmode.Enabled)
1297                                         {
1298                                                 if (DTX2WAVmode.Command == CDTX2WAVmode.ECommand.Cancel)
1299                                                 {
1300                                                         Trace.TraceInformation("録音のCancelコマンドをDTXMania本体が受信しました。");
1301                                                         //Microsoft.VisualBasic.Interaction.AppActivate("メモ帳");
1302                                                         //SendKeys.Send("{ESC}");
1303                                                         //SendKeys.SendWait("%{F4}");
1304                                                         //Application.Exit();
1305                                                         if (DTX != null)        // 曲読み込みの前に録音Cancelされると、DTXがnullのままここにきてでGPFとなる→nullチェック追加
1306                                                         {
1307                                                                 DTX.t全チップの再生停止();
1308                                                                 DTX.On非活性化();
1309                                                         }
1310                                                         r現在のステージ.On非活性化();
1311
1312                                                         //Environment.ExitCode = 10010;         // この組み合わせではダメ、返り値が反映されない
1313                                                         //base.Window.Close();
1314                                                         Environment.Exit(10010);                        // このやり方ならばOK
1315                                                 }
1316                                         }
1317                                 }
1318                         }
1319                         #endregion
1320
1321                         this.Device.BeginScene();
1322                         this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1323
1324                         if (r現在のステージ != null)
1325                         {
1326                                 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1327
1328                                 #region [ プラグインの進行描画 ]
1329                                 //---------------------
1330                                 foreach (STPlugin sp in this.listプラグイン)
1331                                 {
1332                                         Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1333
1334                                         if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1335                                                 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1336                                         else
1337                                                 sp.plugin.On進行描画(null, null);
1338
1339                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1340                                 }
1341                                 //---------------------
1342                                 #endregion
1343
1344                                 #region [ DTX2WAVモード時、ステージが変わるたびに、そのことをDTX2WAVアプリ側に通知する ]
1345                                 if (DTX2WAVmode.Enabled && r現在のステージ != r1フレーム前のステージ)
1346                                 {
1347                                         r1フレーム前のステージ = r現在のステージ;
1348                                         //Trace.TraceInformation("Stage変更 to : " + r現在のステージ.eステージID.ToString());
1349                                         switch (r現在のステージ.eステージID)
1350                                         {
1351                                                 case CStage.Eステージ.曲読み込み:
1352                                                         DTX2WAVmode.SendMessage2DTX2WAV("LOAD");
1353                                                         break;
1354                                                 case CStage.Eステージ.演奏:
1355                                                         DTX2WAVmode.SendMessage2DTX2WAV("PLAY");
1356                                                         break;
1357                                                 default:
1358                                                         break;
1359                                         }
1360                                 }
1361                                 #endregion
1362
1363                                 CScoreIni scoreIni = null;
1364
1365                                 if (Control.IsKeyLocked(Keys.CapsLock))             // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1366                                 {
1367                                         // → songs.db等の書き込み時だと音切れするっぽい
1368                                         actEnumSongs.On非活性化();
1369                                         EnumSongs.SongListEnumCompletelyDone();
1370                                         CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1371                                 }
1372                                 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1373                                 if (!CDTXMania.Instance.bコンパクトモード)
1374                                 {
1375                                         actEnumSongs.On進行描画();                          // "Enumerating Songs..."アイコンの描画
1376                                 }
1377                                 switch (r現在のステージ.eステージID)
1378                                 {
1379                                         case CStage.Eステージ.タイトル:
1380                                         case CStage.Eステージ.コンフィグ:
1381                                         case CStage.Eステージ.選曲:
1382                                         case CStage.Eステージ.曲読み込み:
1383                                                 if (EnumSongs != null)
1384                                                 {
1385                             #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1386                                                         if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1387                                                                          r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1388                                                                          this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1389                                                                          !EnumSongs.IsSongListEnumStarted)
1390                                                         {
1391                                                                 actEnumSongs.On活性化();
1392                                                                 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1393                                                                 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1394                                                                 EnumSongs.StartEnumFromDisk();      // 曲検索スレッドの起動・開始
1395                                                                 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0)    // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1396                                                                 {
1397                                                                         EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1398                                                                 }
1399                                                         }
1400                                                         #endregion
1401
1402                                                         #region [ 曲検索の中断と再開 ]
1403                                                         if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1404                                                         {
1405                                                                 switch (this.n進行描画の戻り値)
1406                                                                 {
1407                                                                         case 0:     // 何もない
1408                                                                                                                         //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1409                                                                                 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1410                                                                                 {
1411                                                                                         EnumSongs.Resume();                     // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1412                                                                                         EnumSongs.IsSlowdown = false;
1413                                                                                 }
1414                                                                                 else
1415                                                                                 {
1416                                                                                         // EnumSongs.Suspend();                                 // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1417                                                                                         EnumSongs.IsSlowdown = true;
1418                                                                                 }
1419                                                                                 actEnumSongs.On活性化();
1420                                                                                 break;
1421
1422                                                                         case 2:     // 曲決定
1423                                                                                 EnumSongs.Suspend();                        // #27060 バックグラウンドの曲検索を一時停止
1424                                                                                 actEnumSongs.On非活性化();
1425                                                                                 break;
1426                                                                 }
1427                                                         }
1428                                                         #endregion
1429
1430                                                         #region [ 曲探索中断待ち待機 ]
1431                                                         if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1432                                                                         EnumSongs.thDTXFileEnumerate != null)                           // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1433                                                         {
1434                                                                 EnumSongs.WaitUntilSuspended();                                 // 念のため、曲検索が一時中断されるまで待機
1435                                                         }
1436                                                         #endregion
1437
1438                                                         #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1439                                                         // CStage選曲.On活性化() に回した方がいいかな?
1440                                                         if (EnumSongs.IsSongListEnumerated)
1441                                                         {
1442                                                                 actEnumSongs.On非活性化();
1443                                                                 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1444
1445                                                                 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1446                                                                 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1447                                                                 EnumSongs.SongListEnumCompletelyDone();
1448                                                         }
1449                                                         #endregion
1450                                                 }
1451                                                 break;
1452                                 }
1453                                 #endregion
1454
1455                                 switch (r現在のステージ.eステージID)
1456                                 {
1457                                         case CStage.Eステージ.何もしない:
1458                                                 break;
1459
1460                                         case CStage.Eステージ.起動:
1461                                                 #region [ *** ]
1462                                                 //-----------------------------
1463                                                 if (this.n進行描画の戻り値 != 0)
1464                                                 {
1465                                                         if (!bコンパクトモード)
1466                                                         {
1467                                                                 r現在のステージ.On非活性化();
1468                                                                 Trace.TraceInformation("----------------------");
1469                                                                 Trace.TraceInformation("■ タイトル");
1470                                                                 stageタイトル.On活性化();
1471                                                                 r直前のステージ = r現在のステージ;
1472                                                                 r現在のステージ = stageタイトル;
1473                                                         }
1474                                                         else
1475                                                         {
1476                                                                 r現在のステージ.On非活性化();
1477                                                                 Trace.TraceInformation("----------------------");
1478                                                                 Trace.TraceInformation("■ 曲読み込み");
1479                                                                 stage曲読み込み.On活性化();
1480                                                                 r直前のステージ = r現在のステージ;
1481                                                                 r現在のステージ = stage曲読み込み;
1482
1483                                                         }
1484                                                         foreach (STPlugin pg in this.listプラグイン)
1485                                                         {
1486                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1487                                                                 pg.plugin.Onステージ変更();
1488                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1489                                                         }
1490
1491                                                         this.tガベージコレクションを実行する();
1492                                                 }
1493                                                 //-----------------------------
1494                                                 #endregion
1495                                                 break;
1496
1497                                         case CStage.Eステージ.タイトル:
1498                         #region [ *** ]
1499                         //-----------------------------
1500                         switch (this.n進行描画の戻り値)
1501                                                 {
1502                                                         case (int)CStageタイトル.E戻り値.GAMESTART:
1503                                                                 #region [ 選曲処理へ ]
1504                                                                 //-----------------------------
1505                                                                 r現在のステージ.On非活性化();
1506                                                                 Trace.TraceInformation("----------------------");
1507                                                                 Trace.TraceInformation("■ 選曲");
1508                                                                 stage選曲.On活性化();
1509                                                                 r直前のステージ = r現在のステージ;
1510                                                                 r現在のステージ = stage選曲;
1511                                                                 //-----------------------------
1512                                                                 #endregion
1513                                                                 break;
1514
1515                                                         #region [ OPTION: 廃止済 ]
1516                                                         //                                                      case 2:                                                                 // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1517                                                         //                                                              #region [ *** ]
1518                                                         //                                                              //-----------------------------
1519                                                         //                                                              r現在のステージ.On非活性化();
1520                                                         //                                                              Trace.TraceInformation( "----------------------" );
1521                                                         //                                                              Trace.TraceInformation( "■ オプション" );
1522                                                         //                                                              stageオプション.On活性化();
1523                                                         //                                                              r直前のステージ = r現在のステージ;
1524                                                         //                                                              r現在のステージ = stageオプション;
1525                                                         //                                                              //-----------------------------
1526                                                         //                                                              #endregion
1527                                                         //                                                              break;
1528                                                         #endregion
1529
1530                                                         case (int)CStageタイトル.E戻り値.CONFIG:
1531                                                                 #region [ *** ]
1532                                                                 //-----------------------------
1533                                                                 r現在のステージ.On非活性化();
1534                                                                 Trace.TraceInformation("----------------------");
1535                                                                 Trace.TraceInformation("■ コンフィグ");
1536                                                                 stageコンフィグ.On活性化();
1537                                                                 r直前のステージ = r現在のステージ;
1538                                                                 r現在のステージ = stageコンフィグ;
1539                                                                 //-----------------------------
1540                                                                 #endregion
1541                                                                 break;
1542
1543                                                         case (int)CStageタイトル.E戻り値.EXIT:
1544                                                                 #region [ *** ]
1545                                                                 //-----------------------------
1546                                                                 r現在のステージ.On非活性化();
1547                                                                 Trace.TraceInformation("----------------------");
1548                                                                 Trace.TraceInformation("■ 終了");
1549                                                                 stage終了.On活性化();
1550                                                                 r直前のステージ = r現在のステージ;
1551                                                                 r現在のステージ = stage終了;
1552                                                                 //-----------------------------
1553                                                                 #endregion
1554                                                                 break;
1555                                                 }
1556
1557                                                 foreach (STPlugin pg in this.listプラグイン)
1558                                                 {
1559                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1560                                                         pg.plugin.Onステージ変更();
1561                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1562                                                 }
1563
1564                                                 //this.tガベージコレクションを実行する();                // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1565                                                 //-----------------------------
1566                                                 #endregion
1567                                                 break;
1568
1569                                         case CStage.Eステージ.コンフィグ:
1570                                                 #region [ *** ]
1571                                                 //-----------------------------
1572                                                 if (this.n進行描画の戻り値 != 0)
1573                                                 {
1574                                                         switch (r直前のステージ.eステージID)
1575                                                         {
1576                                                                 case CStage.Eステージ.タイトル:
1577                                                                         #region [ *** ]
1578                                                                         //-----------------------------
1579                                                                         r現在のステージ.On非活性化();
1580                                                                         Trace.TraceInformation("----------------------");
1581                                                                         Trace.TraceInformation("■ タイトル");
1582                                                                         stageタイトル.On活性化();
1583                                                                         r直前のステージ = r現在のステージ;
1584                                                                         r現在のステージ = stageタイトル;
1585
1586                                                                         foreach (STPlugin pg in this.listプラグイン)
1587                                                                         {
1588                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1589                                                                                 pg.plugin.Onステージ変更();
1590                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1591                                                                         }
1592
1593                                                                         this.tガベージコレクションを実行する();
1594                                                                         break;
1595                                                                 //-----------------------------
1596                                                                 #endregion
1597
1598                                                                 case CStage.Eステージ.選曲:
1599                                                                         #region [ *** ]
1600                                                                         //-----------------------------
1601                                                                         r現在のステージ.On非活性化();
1602                                                                         Trace.TraceInformation("----------------------");
1603                                                                         Trace.TraceInformation("■ 選曲");
1604                                                                         stage選曲.On活性化();
1605                                                                         r直前のステージ = r現在のステージ;
1606                                                                         r現在のステージ = stage選曲;
1607
1608                                                                         foreach (STPlugin pg in this.listプラグイン)
1609                                                                         {
1610                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1611                                                                                 pg.plugin.Onステージ変更();
1612                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1613                                                                         }
1614
1615                                                                         this.tガベージコレクションを実行する();
1616                                                                         break;
1617                                                                         //-----------------------------
1618                                                                         #endregion
1619                                                         }
1620                                                 }
1621                                                 //-----------------------------
1622                                                 #endregion
1623                                                 break;
1624
1625                                         case CStage.Eステージ.選曲:
1626                                                 #region [ *** ]
1627                                                 //-----------------------------
1628                                                 switch (this.n進行描画の戻り値)
1629                                                 {
1630                                                         case (int)CStage選曲.E戻り値.タイトルに戻る:
1631                                                                 #region [ *** ]
1632                                                                 //-----------------------------
1633                                                                 r現在のステージ.On非活性化();
1634                                                                 Trace.TraceInformation("----------------------");
1635                                                                 Trace.TraceInformation("■ タイトル");
1636                                                                 stageタイトル.On活性化();
1637                                                                 r直前のステージ = r現在のステージ;
1638                                                                 r現在のステージ = stageタイトル;
1639
1640                                                                 foreach (STPlugin pg in this.listプラグイン)
1641                                                                 {
1642                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1643                                                                         pg.plugin.Onステージ変更();
1644                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1645                                                                 }
1646
1647                                                                 this.tガベージコレクションを実行する();
1648                                                                 break;
1649                                                         //-----------------------------
1650                                                         #endregion
1651
1652                                                         case (int)CStage選曲.E戻り値.選曲した:
1653                                                                 #region [ *** ]
1654                                                                 //-----------------------------
1655                                                                 r現在のステージ.On非活性化();
1656                                                                 Trace.TraceInformation("----------------------");
1657                                                                 Trace.TraceInformation("■ 曲読み込み");
1658                                                                 stage曲読み込み.On活性化();
1659                                                                 r直前のステージ = r現在のステージ;
1660                                                                 r現在のステージ = stage曲読み込み;
1661
1662                                                                 foreach (STPlugin pg in this.listプラグイン)
1663                                                                 {
1664                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1665                                                                         pg.plugin.Onステージ変更();
1666                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1667                                                                 }
1668
1669                                                                 this.tガベージコレクションを実行する();
1670                                                                 break;
1671                                                         //-----------------------------
1672                                                         #endregion
1673
1674                                                         case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1675                                                                 #region [ *** ]
1676                                                                 //-----------------------------
1677                                                                 r現在のステージ.On非活性化();
1678                                                                 Trace.TraceInformation("----------------------");
1679                                                                 Trace.TraceInformation("■ コンフィグ");
1680                                                                 stageコンフィグ.On活性化();
1681                                                                 r直前のステージ = r現在のステージ;
1682                                                                 r現在のステージ = stageコンフィグ;
1683
1684                                                                 foreach (STPlugin pg in this.listプラグイン)
1685                                                                 {
1686                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1687                                                                         pg.plugin.Onステージ変更();
1688                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1689                                                                 }
1690
1691                                                                 this.tガベージコレクションを実行する();
1692                                                                 break;
1693                                                         //-----------------------------
1694                                                         #endregion
1695
1696                                                         case (int)CStage選曲.E戻り値.スキン変更:
1697
1698                                                                 #region [ *** ]
1699                                                                 //-----------------------------
1700                                                                 r現在のステージ.On非活性化();
1701                                                                 Trace.TraceInformation("----------------------");
1702                                                                 Trace.TraceInformation("■ スキン切り替え");
1703                                                                 stageChangeSkin.On活性化();
1704                                                                 r直前のステージ = r現在のステージ;
1705                                                                 r現在のステージ = stageChangeSkin;
1706                                                                 break;
1707                                                                 //-----------------------------
1708                                                                 #endregion
1709                                                 }
1710                                                 //-----------------------------
1711                                                 #endregion
1712                                                 break;
1713
1714                                         case CStage.Eステージ.曲読み込み:
1715                                                 #region [ *** ]
1716                                                 //-----------------------------
1717                                                 DTXVmode.Refreshed = false;     // 曲のリロード中に発生した再リロードは、無視する。
1718                                                 if (this.n進行描画の戻り値 != 0)
1719                                                 {
1720                                                         CDTXMania.Instance.Pad.st検知したデバイス.Clear();  // 入力デバイスフラグクリア(2010.9.11)
1721                                                         r現在のステージ.On非活性化();
1722                                                         #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1723                                                         if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1724                                                         {
1725                                                                 //DTX.t全チップの再生停止();
1726                                                                 DTX.On非活性化();
1727                                                                 Trace.TraceInformation("曲の読み込みを中止しました。");
1728                                                                 this.tガベージコレクションを実行する();
1729                                                                 Trace.TraceInformation("----------------------");
1730                                                                 Trace.TraceInformation("■ 選曲");
1731                                                                 stage選曲.On活性化();
1732                                                                 r直前のステージ = r現在のステージ;
1733                                                                 r現在のステージ = stage選曲;
1734                                                                 foreach (STPlugin pg in this.listプラグイン)
1735                                                                 {
1736                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1737                                                                         pg.plugin.Onステージ変更();
1738                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1739                                                                 }
1740                                                                 break;
1741                                                         }
1742                                                         #endregion
1743
1744                                                         Trace.TraceInformation("----------------------");
1745                                                         Trace.TraceInformation("■ 演奏(ドラム画面)");
1746                                                         r直前のステージ = r現在のステージ;
1747                                                         r現在のステージ = stage演奏画面;
1748
1749                                                         foreach (STPlugin pg in this.listプラグイン)
1750                                                         {
1751                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1752                                                                 pg.plugin.Onステージ変更();
1753                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1754                                                         }
1755
1756                                                         this.tガベージコレクションを実行する();
1757                                                 }
1758                                                 //-----------------------------
1759                                                 #endregion
1760                                                 break;
1761
1762                                         case CStage.Eステージ.演奏:
1763                                                 #region [ *** ]
1764                                                 //-----------------------------
1765                                                 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1766                                                 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1767                                                 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1768                                                 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1769                                                 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1770
1771                                                 //swlist1.Add( Convert.ToInt32(n1) );
1772                                                 //swlist2.Add( Convert.ToInt32(n2) );
1773                                                 //swlist3.Add( Convert.ToInt32( n3 ) );
1774                                                 //swlist4.Add( Convert.ToInt32( n4 ) );
1775                                                 //swlist5.Add( Convert.ToInt32( n5 ) );
1776
1777                                                 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1778                                                 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1779                                                 {
1780                                                         DTXVmode.Refreshed = false;
1781
1782                                                         if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1783                                                         {
1784                                                                 CDTXMania.Instance.stage演奏画面.t停止();
1785
1786                                                                 if (previewSound != null)
1787                                                                 {
1788                                                                         this.previewSound.tサウンドを停止する();
1789                                                                         this.previewSound.Dispose();
1790                                                                         this.previewSound = null;
1791                                                                 }
1792                                                                 //{
1793                                                                 //    int lastd = 0;
1794                                                                 //    int f = 0;
1795                                                                 //    for ( int i = 0; i < swlist1.Count; i++ )
1796                                                                 //    {
1797                                                                 //        int d1 = swlist1[ i ];
1798                                                                 //        int d2 = swlist2[ i ];
1799                                                                 //        int d3 = swlist3[ i ];
1800                                                                 //        int d4 = swlist4[ i ];
1801                                                                 //        int d5 = swlist5[ i ];
1802
1803                                                                 //        int dif = d1 - lastd;
1804                                                                 //        string s = "";
1805                                                                 //        if ( 16 <= dif && dif <= 17 )
1806                                                                 //        {
1807                                                                 //        }
1808                                                                 //        else
1809                                                                 //        {
1810                                                                 //            s = "★";
1811                                                                 //        }
1812                                                                 //        Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3} - {7:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4, d5 );
1813                                                                 //        lastd = d1;
1814                                                                 //        f++;
1815                                                                 //    }
1816                                                                 //    swlist1.Clear();
1817                                                                 //    swlist2.Clear();
1818                                                                 //    swlist3.Clear();
1819                                                                 //    swlist4.Clear();
1820                                                                 //    swlist5.Clear();
1821
1822                                                                 //}
1823                                                         }
1824                                                         else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1825                                                         {
1826                                                                 if (DTXVmode.NeedReload)
1827                                                                 {
1828                                                                         CDTXMania.Instance.stage演奏画面.t再読込();
1829                                                                         if (DTXVmode.GRmode)
1830                                                                         {
1831                                                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1832                                                                         }
1833                                                                         else
1834                                                                         {
1835                                                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1836                                                                         }
1837                                                                         CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1838                                                                         CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1839                                                                         if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1840                                                                         {
1841                                                                                 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1842                                                                                 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1843                                                                         }
1844                                                                 }
1845                                                                 else
1846                                                                 {
1847                                                                         CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1848                                                                 }
1849                                                         }
1850                                                 }
1851                                                 #endregion
1852
1853                                                 switch (this.n進行描画の戻り値)
1854                                                 {
1855                                                         case (int)E演奏画面の戻り値.再読込_再演奏:
1856                                                                 #region [ DTXファイルを再読み込みして、再演奏 ]
1857                                                                 DTX.t全チップの再生停止();
1858                                                                 DTX.On非活性化();
1859                                                                 r現在のステージ.On非活性化();
1860                                                                 stage曲読み込み.On活性化();
1861                                                                 r直前のステージ = r現在のステージ;
1862                                                                 r現在のステージ = stage曲読み込み;
1863                                                                 this.tガベージコレクションを実行する();
1864                                                                 break;
1865                                                         #endregion
1866
1867                                                         //case (int) E演奏画面の戻り値.再演奏:
1868                                                         #region [ 再読み込み無しで、再演奏 ]
1869                                                         #endregion
1870                                                         //      break;
1871
1872                                                         case (int)E演奏画面の戻り値.継続:
1873                                                                 break;
1874
1875                                                         case (int)E演奏画面の戻り値.演奏中断:
1876                                                                 #region [ 演奏キャンセル ]
1877                                                                 //-----------------------------
1878                                                                 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1879                                                                 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass)      // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1880                                                                 {
1881                                                                         //CDTXMania.Instance.DTX.SwapGuitarBassInfos();                                         // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1882                                                                 }
1883
1884                                                                 //int lastd = 0;
1885                                                                 //int f = 0;
1886                                                                 //for (int i = 0; i < swlist1.Count; i++)
1887                                                                 //{
1888                                                                 //    int d1 = swlist1[ i ];
1889                                                                 //    int d2 = swlist2[ i ];
1890                                                                 //    int d3 = swlist3[ i ];
1891                                                                 //    int d4 = swlist4[ i ];
1892
1893                                                                 //    int dif = d1 - lastd;
1894                                                                 //    string s = "";
1895                                                                 //    if ( 16 <= dif && dif <= 17 )
1896                                                                 //    {
1897                                                                 //    }
1898                                                                 //    else
1899                                                                 //    {
1900                                                                 //        s = "★";
1901                                                                 //    }
1902                                                                 //    Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1903                                                                 //    lastd = d1;
1904                                                                 //    f++;
1905                                                                 //}
1906                                                                 //swlist1.Clear();
1907                                                                 //swlist2.Clear();
1908                                                                 //swlist3.Clear();
1909                                                                 //swlist4.Clear();
1910
1911                                                                 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1912                                                                 //---------------------
1913                                                                 foreach (STPlugin pg in this.listプラグイン)
1914                                                                 {
1915                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1916                                                                         pg.plugin.On演奏キャンセル(scoreIni);
1917                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1918                                                                 }
1919                                                                 //---------------------
1920                                                                 #endregion
1921
1922                                                                 DTX.t全チップの再生停止();
1923                                                                 DTX.On非活性化();
1924                                                                 r現在のステージ.On非活性化();
1925                                                                 if (DTX2WAVmode.Enabled)
1926                                                                 {
1927                                                                         Environment.Exit(0);
1928                                                                 }
1929                                                                 if (bコンパクトモード)
1930                                                                 {
1931                                                                         base.Window.Close();
1932                                                                 }
1933                                                                 else
1934                                                                 {
1935                                                                         Trace.TraceInformation("----------------------");
1936                                                                         Trace.TraceInformation("■ 選曲");
1937                                                                         stage選曲.On活性化();
1938                                                                         r直前のステージ = r現在のステージ;
1939                                                                         r現在のステージ = stage選曲;
1940
1941                                                                         #region [ プラグイン Onステージ変更() の呼び出し ]
1942                                                                         //---------------------
1943                                                                         foreach (STPlugin pg in this.listプラグイン)
1944                                                                         {
1945                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1946                                                                                 pg.plugin.Onステージ変更();
1947                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1948                                                                         }
1949                                                                         //---------------------
1950                                                                         #endregion
1951
1952                                                                         this.tガベージコレクションを実行する();
1953                                                                 }
1954                                                                 break;
1955                                                         //-----------------------------
1956                                                         #endregion
1957
1958                                                         case (int)E演奏画面の戻り値.ステージ失敗:
1959                                                                 #region [ 演奏失敗(StageFailed) ]
1960                                                                 //-----------------------------
1961                                                                 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1962
1963                                                                 #region [ プラグイン On演奏失敗() の呼び出し ]
1964                                                                 //---------------------
1965                                                                 foreach (STPlugin pg in this.listプラグイン)
1966                                                                 {
1967                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1968                                                                         pg.plugin.On演奏失敗(scoreIni);
1969                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1970                                                                 }
1971                                                                 //---------------------
1972                                                                 #endregion
1973
1974                                                                 DTX.t全チップの再生停止();
1975                                                                 DTX.On非活性化();
1976                                                                 r現在のステージ.On非活性化();
1977                                                                 if (bコンパクトモード)
1978                                                                 {
1979                                                                         base.Window.Close();
1980                                                                 }
1981                                                                 else
1982                                                                 {
1983                                                                         Trace.TraceInformation("----------------------");
1984                                                                         Trace.TraceInformation("■ 選曲");
1985                                                                         stage選曲.On活性化();
1986                                                                         r直前のステージ = r現在のステージ;
1987                                                                         r現在のステージ = stage選曲;
1988
1989                                                                         #region [ プラグイン Onステージ変更() の呼び出し ]
1990                                                                         //---------------------
1991                                                                         foreach (STPlugin pg in this.listプラグイン)
1992                                                                         {
1993                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1994                                                                                 pg.plugin.Onステージ変更();
1995                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1996                                                                         }
1997                                                                         //---------------------
1998                                                                         #endregion
1999
2000                                                                         this.tガベージコレクションを実行する();
2001                                                                 }
2002                                                                 break;
2003                                                         //-----------------------------
2004                                                         #endregion
2005
2006                                                         case (int)E演奏画面の戻り値.ステージクリア:
2007                                                                 #region [ 演奏クリア ]
2008                                                                 //-----------------------------
2009                                                                 STDGBSValue<CScoreIni.C演奏記録> record;
2010                                                                 record = stage演奏画面.Record;
2011
2012                                                                 double playskill = 0.0;
2013
2014                                                                 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
2015                                                                 {
2016                                                                         if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
2017                                                                         {
2018                                                                                 playskill = record[inst].db演奏型スキル値;
2019                                                                         }
2020                                                                 }
2021
2022                                                                 string str = "Cleared";
2023                                                                 switch (CScoreIni.t総合ランク値を計算して返す(record))
2024                                                                 {
2025                                                                         case CScoreIni.ERANK.SS:
2026                                                                                 str = string.Format("Cleared (SS: {0:F2})", playskill);
2027                                                                                 break;
2028
2029                                                                         case CScoreIni.ERANK.S:
2030                                                                                 str = string.Format("Cleared (S: {0:F2})", playskill);
2031                                                                                 break;
2032
2033                                                                         case CScoreIni.ERANK.A:
2034                                                                                 str = string.Format("Cleared (A: {0:F2})", playskill);
2035                                                                                 break;
2036
2037                                                                         case CScoreIni.ERANK.B:
2038                                                                                 str = string.Format("Cleared (B: {0:F2})", playskill);
2039                                                                                 break;
2040
2041                                                                         case CScoreIni.ERANK.C:
2042                                                                                 str = string.Format("Cleared (C: {0:F2})", playskill);
2043                                                                                 break;
2044
2045                                                                         case CScoreIni.ERANK.D:
2046                                                                                 str = string.Format("Cleared (D: {0:F2})", playskill);
2047                                                                                 break;
2048
2049                                                                         case CScoreIni.ERANK.E:
2050                                                                                 str = string.Format("Cleared (E: {0:F2})", playskill);
2051                                                                                 break;
2052
2053                                                                         case CScoreIni.ERANK.UNKNOWN:   // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
2054                                                                                 str = "Cleared (No chips)";
2055                                                                                 break;
2056                                                                 }
2057
2058                                                                 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
2059
2060                                                                 #region [ プラグイン On演奏クリア() の呼び出し ]
2061                                                                 //---------------------
2062                                                                 foreach (STPlugin pg in this.listプラグイン)
2063                                                                 {
2064                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2065                                                                         pg.plugin.On演奏クリア(scoreIni);
2066                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2067                                                                 }
2068                                                                 //---------------------
2069                                                                 #endregion
2070
2071                                                                 r現在のステージ.On非活性化();
2072                                                                 Trace.TraceInformation("----------------------");
2073                                                                 Trace.TraceInformation("■ 結果");
2074                                                                 stage結果.st演奏記録 = record;
2075                                                                 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
2076                                                                 stage結果.On活性化();
2077                                                                 r直前のステージ = r現在のステージ;
2078                                                                 r現在のステージ = stage結果;
2079
2080                                                                 #region [ プラグイン Onステージ変更() の呼び出し ]
2081                                                                 //---------------------
2082                                                                 foreach (STPlugin pg in this.listプラグイン)
2083                                                                 {
2084                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2085                                                                         pg.plugin.Onステージ変更();
2086                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2087                                                                 }
2088                                                                 //---------------------
2089                                                                 #endregion
2090
2091                                                                 break;
2092                                                                 //-----------------------------
2093                                                                 #endregion
2094                                                 }
2095                                                 //-----------------------------
2096                                                 #endregion
2097                                                 break;
2098
2099                                         case CStage.Eステージ.結果:
2100                                                 #region [ *** ]
2101                                                 //-----------------------------
2102                                                 if (this.n進行描画の戻り値 != 0)
2103                                                 {
2104                                                         // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2105                                                         // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2106                                                         if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass)      // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2107                                                         {
2108                                                                 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags();   // Auto入れ替え
2109                                                         }
2110
2111                                                         DTX.t全チップの再生一時停止();
2112                                                         DTX.On非活性化();
2113                                                         r現在のステージ.On非活性化();
2114                                                         if (!bコンパクトモード)
2115                                                         {
2116                                                                 Trace.TraceInformation("----------------------");
2117                                                                 Trace.TraceInformation("■ 選曲");
2118                                                                 stage選曲.On活性化();
2119                                                                 r直前のステージ = r現在のステージ;
2120                                                                 r現在のステージ = stage選曲;
2121
2122                                                                 foreach (STPlugin pg in this.listプラグイン)
2123                                                                 {
2124                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2125                                                                         pg.plugin.Onステージ変更();
2126                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2127                                                                 }
2128
2129                                                                 this.tガベージコレクションを実行する();
2130                                                         }
2131                                                         else
2132                                                         {
2133                                                                 base.Window.Close();
2134                                                         }
2135                                                 }
2136                                                 //-----------------------------
2137                                                 #endregion
2138                                                 break;
2139
2140                                         case CStage.Eステージ.ChangeSkin:
2141                                                 #region [ *** ]
2142                                                 //-----------------------------
2143                                                 if (this.n進行描画の戻り値 != 0)
2144                                                 {
2145                                                         r現在のステージ.On非活性化();
2146                                                         Trace.TraceInformation("----------------------");
2147                                                         Trace.TraceInformation("■ 選曲");
2148                                                         stage選曲.On活性化();
2149                                                         r直前のステージ = r現在のステージ;
2150                                                         r現在のステージ = stage選曲;
2151                                                         this.tガベージコレクションを実行する();
2152                                                 }
2153                                                 //-----------------------------
2154                                                 #endregion
2155                                                 break;
2156
2157                                         case CStage.Eステージ.終了:
2158                                                 #region [ *** ]
2159                                                 //-----------------------------
2160                                                 if (this.n進行描画の戻り値 != 0)
2161                                                 {
2162                                                         base.Exit();
2163                                                 }
2164                                                 //-----------------------------
2165                                                 #endregion
2166                                                 break;
2167                                 }
2168                         }
2169                         this.Device.EndScene();
2170                         // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2171                         // (つまり、Present()は、Draw()完了後に実行される)
2172 #if !GPUFlushAfterPresent
2173                         actFlushGPU.On進行描画();       // Flush GPU        // EndScene()~Present()間 (つまりVSync前) でFlush実行
2174 #endif
2175                         if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2176                         {
2177                                 Sound管理.t再生中の処理をする();   // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2178                         }
2179
2180                         #region [ マウスカーソル消去制御 ]
2181                         if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2182                         #endregion
2183                         #region [ 全画面・ウインドウ切り替え ]
2184                         if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2185                         {
2186                                 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2187                                 Instance.t全画面_ウィンドウモード切り替え();
2188                                 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2189                         }
2190                         #endregion
2191                         #region [ 垂直基線同期切り替え ]
2192                         if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2193                         {
2194                                 bool bIsMaximized = this.Window.IsMaximized;                                            // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2195                                 currentClientSize = this.Window.ClientSize;                                             // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2196                                 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2197                                 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2198                                 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2199                                 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2200                                 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height);   // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2201                                 if (bIsMaximized)
2202                                 {
2203                                         this.Window.WindowState = FormWindowState.Maximized;                                // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2204                                 }
2205                         }
2206                         #endregion
2207
2208                         GC.Collect( 0, GCCollectionMode.Optimized, false );             // Rel105で処理が重くなっていることに対する、暫定処置。
2209                                                                                                                                         // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2210                                                                                                                                         // この暫定処置は削除します。
2211                 }
2212
2213                 /// <summary>
2214                 /// XML ファイルからオブジェクトを生成します。
2215                 /// </summary>
2216                 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2217                 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2218                 public static object DeserializeXML(string xmlpath, Type t)
2219                 {
2220                         object ret = null;
2221                         try
2222                         {
2223                                 if (File.Exists(xmlpath))
2224                                 {
2225                                         using (StreamReader reader = new StreamReader(xmlpath, Encoding.GetEncoding("shift_jis")))
2226                                         using (XmlReader xr = XmlReader.Create(reader))
2227                                         {
2228                                                 DataContractSerializer serializer = new DataContractSerializer(t);
2229                                                 ret = serializer.ReadObject(xr);
2230                                         }
2231                                 }
2232                         }
2233                         catch (Exception e)
2234                         {
2235                                 Trace.TraceWarning( e.Message );
2236                                 ret = null;
2237                         }
2238                         return ret;
2239                 }
2240
2241                 /// <summary>
2242                 /// オブジェクトから XML ファイルを生成します。
2243                 /// </summary>
2244                 /// <param name="xmlfile">XML ファイルのパス。</param>
2245                 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2246                 public static void SerializeXML(string xmlpath, object obj)
2247                 {
2248                         XmlWriterSettings settings = new XmlWriterSettings();
2249                         settings.IndentChars = "  ";
2250                         settings.Indent = true;
2251                         settings.NewLineChars = Environment.NewLine;
2252                         settings.Encoding = new System.Text.UTF8Encoding(false);
2253             using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2254             {
2255                 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2256                 {
2257                     DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2258                     serializer.WriteObject(xw, obj);
2259                 }
2260             }
2261                 }
2262
2263                 public void SaveConfig()
2264                 {
2265                         #region [ Skinパスの絶対パス→相対パス変換 ]
2266                         string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2267                         Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2268                         if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2269                         {
2270                                 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2271                                 // → 初期値として Default/ を設定する。
2272                                 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2273                         }
2274
2275                         // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2276                         // そのため、以下の処理を通すために、いったん絶対パスに変換
2277                         if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2278                         {
2279                                 ConfigIni.strSystemSkinSubfolderPath.Value =
2280                                         Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2281                         }
2282
2283                         Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2284                         string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString();                         // 相対パスを取得
2285                         relPath = System.Web.HttpUtility.UrlDecode( relPath );                                          // デコードする
2286                         relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar );        // 区切り文字が\ではなく/なので置換する
2287                         ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2288                         #endregion
2289                         ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2290
2291                         CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2292
2293                         // 元の絶対パスに戻す
2294                         ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2295                 }
2296
2297                 public void LoadConfig()
2298                 {
2299                         string path = strEXEのあるフォルダ + "Config.xml";
2300
2301                         if (!File.Exists(path))
2302                         {
2303                                 SaveConfig();
2304                         }
2305                         if (File.Exists(path))
2306                         {
2307                                 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2308                                 if (ConfigIni == null)
2309                                 {
2310                                         ConfigIni = new CConfigXml();
2311                                         SaveConfig();
2312                                 }
2313                                 // Skinパスの相対パスを、絶対パスに変換
2314                                 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2315                                 {
2316                                         ConfigIni.strSystemSkinSubfolderPath.Value =
2317                                                 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2318                                 }
2319                         }
2320                 }
2321                 /// <summary>
2322                 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2323                 /// </summary>
2324                 public void UpdateCoordinates()
2325                 {
2326                         string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2327  
2328                         // デシリアライズ
2329                         if (File.Exists(coordXml))
2330                         {
2331                                 using (XmlReader xr = XmlReader.Create(coordXml))
2332                                 {
2333                                         DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2334                                         try
2335                                         {
2336                                                 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2337                                         }
2338                                         catch (SerializationException e)
2339                                         {
2340                                                 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2341                                         }
2342                                 }
2343                         }
2344                         // シリアライズ
2345                         XmlWriterSettings settings = new XmlWriterSettings();
2346                         settings.IndentChars = "  ";
2347                         settings.Indent = true;
2348                         settings.NewLineChars = Environment.NewLine;
2349                         settings.Encoding = new System.Text.UTF8Encoding( false );
2350                         using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2351                         {
2352                                 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2353                                 //ns.Add( String.Empty, String.Empty );
2354
2355                                 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2356                                 //serializer.Serialize( sw, item, ns );
2357                                 //sw.Close
2358
2359                                 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2360                                 serializer.WriteObject( xw, Coordinates );
2361                                 //serializer.WriteStartObject( xw, Coordinates );
2362                                 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2363                                 //      "http://schemas.microsoft.com/2003/10/Serialization/" );
2364                                 //serializer.WriteObjectContent( xw, Coordinates );
2365                                 //serializer.WriteEndObject( xw );
2366                         }
2367
2368                         // もう一度デシリアライズ
2369                         if (File.Exists(coordXml))
2370                         {
2371                                 using (XmlReader xr = XmlReader.Create(coordXml))
2372                                 {
2373                                         DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2374                                         Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2375                                 }
2376                         }
2377                 }
2378
2379
2380                 /// <summary>
2381                 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2382                 /// </summary>
2383                 //public class MyXmlTextWriter : XmlTextWriter
2384                 //{
2385                 //      private bool _ignoreAttr = false;
2386
2387                 //      public MyXmlTextWriter( TextWriter w  )
2388                 //              : base( w )
2389                 //      {
2390                 //              Debug.WriteLine( "create" );
2391                 //      }
2392
2393                 //      public override string LookupPrefix( string ns )
2394                 //      {
2395                 //              Debug.WriteLine( "luprefix" );
2396                 //              return string.Empty;
2397                 //      }
2398
2399                 //      public override void WriteStartAttribute( string prefix, string localName, string ns )
2400                 //      {
2401                 //              Debug.WriteLine( "writestartattribute" );
2402                 //              if ( String.Compare( prefix, "xmlns", true ) == 0 )
2403                 //              {
2404                 //                      Debug.WriteLine( "[!]" );
2405                 //                      this._ignoreAttr = true;
2406                 //                      return;
2407                 //              }
2408                 //      }
2409
2410                 //      public override void WriteEndAttribute()
2411                 //      {
2412                 //              if ( this._ignoreAttr )
2413                 //              {
2414                 //                      this._ignoreAttr = false;
2415                 //                      return;
2416                 //              }
2417                 //              base.WriteEndAttribute();
2418                 //      }
2419
2420                 //      public override void WriteString( string text )
2421                 //      {
2422                 //              Debug.WriteLine( "ws" );
2423                 //              if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2424                 //              {
2425                 //                      return;
2426                 //              }
2427                 //              base.WriteString( text );
2428                 //      }
2429
2430                 //      public override void WriteStartElement( string prefix, string localName, string ns )
2431                 //      {
2432                 //              Debug.WriteLine( "wse" );
2433                 //              base.WriteStartElement( null, localName, null );
2434                 //      }
2435                 //}
2436
2437                 public void ShowWindowTitleWithSoundType()
2438                 {
2439                         string delay = "";
2440                         if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2441                         {
2442                                 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2443                         }
2444                         base.Window.Text = strWindowTitle;
2445                         if (!this.DTX2WAVmode.Enabled)
2446                         {
2447                                 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2448                         }
2449                 }
2450
2451                 #region [ private ]
2452                 //-----------------
2453                 private bool b終了処理完了済み;
2454                 private static CDTX dtx;
2455                 private List<CActivity> listトップレベルActivities;
2456                 private int n進行描画の戻り値;
2457                 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2458                 private string strWindowTitle
2459                 {
2460                         get
2461                         {
2462                                 string strCPUmode = (Environment.Is64BitProcess) ? " [x64]" : " [x86]";
2463
2464                                         if (DTXVmode.Enabled)
2465                                 {
2466                                         return "DTXMViewer release " + VERSION + strCPUmode;
2467                                 }
2468                                 else if (DTX2WAVmode.Enabled)
2469                                 {
2470                                         return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename) + strCPUmode;
2471                                 }
2472                                 else
2473                                 {
2474                                         return "DTXMania .NET style release " + VERSION + strCPUmode;
2475                                 }
2476                         }
2477                 }
2478                 private CSound previewSound;
2479                 private CMouseHideControl cMouseHideControl = null;
2480
2481                 private void t終了処理()
2482                 {
2483                         if (!this.b終了処理完了済み)
2484                         {
2485                                 Trace.TraceInformation("----------------------");
2486                                 Trace.TraceInformation("■ アプリケーションの終了");
2487                                 #region[ 電源プランの復元 ]
2488                                 CPowerPlan.RestoreCurrentPowerPlan();           // 電源プランを元のものに戻す
2489                                 #endregion
2490                                 #region [ 曲検索の終了処理 ]
2491                                 //---------------------
2492                                 if (actEnumSongs != null)
2493                                 {
2494                                         Trace.TraceInformation("曲検索actの終了処理を行います。");
2495                                         Trace.Indent();
2496                                         try
2497                                         {
2498                                                 actEnumSongs.On非活性化();
2499                                                 actEnumSongs = null;
2500                                                 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2501                                         }
2502                                         catch (Exception e)
2503                                         {
2504                                                 Trace.TraceError(e.Message);
2505                                                 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2506                                         }
2507                                         finally
2508                                         {
2509                                                 Trace.Unindent();
2510                                         }
2511                                 }
2512                                 //---------------------
2513                                 #endregion
2514                                 #region [ 現在のステージの終了処理 ]
2515                                 //---------------------
2516                                 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる)     // #25398 2011.06.07 MODIFY FROM
2517                                 {
2518                                         Trace.TraceInformation("現在のステージを終了します。");
2519                                         Trace.Indent();
2520                                         try
2521                                         {
2522                                                 r現在のステージ.On非活性化();
2523                                                 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2524                                         }
2525                                         finally
2526                                         {
2527                                                 Trace.Unindent();
2528                                         }
2529                                 }
2530                                 //---------------------
2531                                 #endregion
2532
2533                                 #region [ 選曲ステージの終了処理 ]
2534                                 stage選曲.On非活性化();
2535                                 #endregion
2536
2537                                 #region [ プラグインの終了処理 ]
2538                                 //---------------------
2539                                 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2540                                 {
2541                                         Trace.TraceInformation("すべてのプラグインを終了します。");
2542                                         Trace.Indent();
2543                                         try
2544                                         {
2545                                                 foreach (STPlugin st in this.listプラグイン)
2546                                                 {
2547                                                         Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2548                                                         st.plugin.OnUnmanagedリソースの解放();
2549                                                         st.plugin.OnManagedリソースの解放();
2550                                                         st.plugin.On終了();
2551                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2552                                                 }
2553                                                 PluginHost = null;
2554                                                 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2555                                         }
2556                                         finally
2557                                         {
2558                                                 Trace.Unindent();
2559                                         }
2560                                 }
2561                                 //---------------------
2562                                 #endregion
2563                                 #region [ 曲リストの終了処理 ]
2564                                 //---------------------
2565                                 if (Songs管理 != null)
2566                                 {
2567                                         Trace.TraceInformation("曲リストの終了処理を行います。");
2568                                         Trace.Indent();
2569                                         try
2570                                         {
2571                                                 Songs管理 = null;
2572                                                 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2573                                         }
2574                                         catch (Exception exception)
2575                                         {
2576                                                 Trace.TraceError(exception.Message);
2577                                                 Trace.TraceError("曲リストの終了処理に失敗しました。");
2578                                         }
2579                                         finally
2580                                         {
2581                                                 Trace.Unindent();
2582                                         }
2583                                 }
2584                                 CAvi.t終了();
2585                                 //---------------------
2586                                 #endregion
2587                                 #region [ スキンの終了処理 ]
2588                                 //---------------------
2589                                 if (Skin != null)
2590                                 {
2591                                         Trace.TraceInformation("スキンの終了処理を行います。");
2592                                         Trace.Indent();
2593                                         try
2594                                         {
2595                                                 Skin.Dispose();
2596                                                 Skin = null;
2597                                                 Trace.TraceInformation("スキンの終了処理を完了しました。");
2598                                         }
2599                                         catch (Exception exception2)
2600                                         {
2601                                                 Trace.TraceError(exception2.Message);
2602                                                 Trace.TraceError("スキンの終了処理に失敗しました。");
2603                                         }
2604                                         finally
2605                                         {
2606                                                 Trace.Unindent();
2607                                         }
2608                                 }
2609                                 //---------------------
2610                                 #endregion
2611                                 #region [ DirectSoundの終了処理 ]
2612                                 //---------------------
2613                                 if (Sound管理 != null)
2614                                 {
2615                                         Trace.TraceInformation("DirectSound の終了処理を行います。");
2616                                         Trace.Indent();
2617                                         try
2618                                         {
2619                                                 Sound管理.Dispose();
2620                                                 Sound管理 = null;
2621                                                 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2622                                         }
2623                                         catch (Exception exception3)
2624                                         {
2625                                                 Trace.TraceError(exception3.Message);
2626                                                 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2627                                         }
2628                                         finally
2629                                         {
2630                                                 Trace.Unindent();
2631                                         }
2632                                 }
2633                                 //---------------------
2634                                 #endregion
2635                                 #region [ パッドの終了処理 ]
2636                                 //---------------------
2637                                 if (Pad != null)
2638                                 {
2639                                         Trace.TraceInformation("パッドの終了処理を行います。");
2640                                         Trace.Indent();
2641                                         try
2642                                         {
2643                                                 Pad = null;
2644                                                 Trace.TraceInformation("パッドの終了処理を完了しました。");
2645                                         }
2646                                         catch (Exception exception4)
2647                                         {
2648                                                 Trace.TraceError(exception4.Message);
2649                                                 Trace.TraceError("パッドの終了処理に失敗しました。");
2650                                         }
2651                                         finally
2652                                         {
2653                                                 Trace.Unindent();
2654                                         }
2655                                 }
2656                                 //---------------------
2657                                 #endregion
2658                                 #region [ DirectInput, MIDI入力の終了処理 ]
2659                                 //---------------------
2660                                 if (Input管理 != null)
2661                                 {
2662                                         Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2663                                         Trace.Indent();
2664                                         try
2665                                         {
2666                                                 Input管理.Dispose();
2667                                                 Input管理 = null;
2668                                                 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2669                                         }
2670                                         catch (Exception exception5)
2671                                         {
2672                                                 Trace.TraceError(exception5.Message);
2673                                                 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2674                                         }
2675                                         finally
2676                                         {
2677                                                 Trace.Unindent();
2678                                         }
2679                                 }
2680                                 //---------------------
2681                                 #endregion
2682                                 #region [ 文字コンソールの終了処理 ]
2683                                 //---------------------
2684                                 if (act文字コンソール != null)
2685                                 {
2686                                         Trace.TraceInformation("文字コンソールの終了処理を行います。");
2687                                         Trace.Indent();
2688                                         try
2689                                         {
2690                                                 act文字コンソール.On非活性化();
2691                                                 act文字コンソール = null;
2692                                                 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2693                                         }
2694                                         catch (Exception exception6)
2695                                         {
2696                                                 Trace.TraceError(exception6.Message);
2697                                                 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2698                                         }
2699                                         finally
2700                                         {
2701                                                 Trace.Unindent();
2702                                         }
2703                                 }
2704                                 //---------------------
2705                                 #endregion
2706                                 #region [ FPSカウンタの終了処理 ]
2707                                 //---------------------
2708                                 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2709                                 Trace.Indent();
2710                                 try
2711                                 {
2712                                         if (FPS != null)
2713                                         {
2714                                                 FPS = null;
2715                                         }
2716                                         Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2717                                 }
2718                                 finally
2719                                 {
2720                                         Trace.Unindent();
2721                                 }
2722                                 //---------------------
2723                                 #endregion
2724                                 #region [ タイマの終了処理 ]
2725                                 //---------------------
2726                                 Trace.TraceInformation("タイマの終了処理を行います。");
2727                                 Trace.Indent();
2728                                 try
2729                                 {
2730                                         if (Timer != null)
2731                                         {
2732                                                 Timer.Dispose();
2733                                                 Timer = null;
2734                                                 Trace.TraceInformation("タイマの終了処理を完了しました。");
2735                                         }
2736                                         else
2737                                         {
2738                                                 Trace.TraceInformation("タイマは使用されていません。");
2739                                         }
2740                                 }
2741                                 finally
2742                                 {
2743                                         Trace.Unindent();
2744                                 }
2745                                 //---------------------
2746                                 #endregion
2747                                 #region [ Config.iniの出力 ]
2748                                 //---------------------
2749                                 Trace.TraceInformation("Config.xml を出力します。");
2750                                 //                              if ( ConfigIni.bIsSwappedGuitarBass )                   // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2751                                 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2752                                 {
2753                                         ConfigIni.SwapGuitarBassInfos_AutoFlags();
2754                                 }
2755                                 /*
2756                                         if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped)  // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2757                                         {
2758                                                         ConfigIni.SwapGuitarBassInfos_PlaySettings();
2759                                         }
2760                                  */
2761                                 string str = strEXEのあるフォルダ + "Config.xml";
2762                                 Trace.Indent();
2763                                 try
2764                                 {
2765                                         if (DTXVmode.Enabled)
2766                                         {
2767                                                 DTXVmode.tUpdateConfigIni();
2768                                                 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2769                                         }
2770                                         else if (DTX2WAVmode.Enabled)
2771                                         {
2772                                                 DTX2WAVmode.tUpdateConfigIni();
2773                                                 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2774                                                 DTX2WAVmode.SendMessage2DTX2WAV("TERM");
2775                                         }
2776                                         else
2777                                         {
2778                                                 CDTXMania.Instance.SaveConfig();
2779                                                 Trace.TraceInformation("保存しました。({0})", str);
2780                                         }
2781                                 }
2782                                 catch (Exception e)
2783                                 {
2784                                         Trace.TraceError(e.Message);
2785                                         Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2786                                 }
2787                                 finally
2788                                 {
2789                                         Trace.Unindent();
2790                                 }
2791                                 //---------------------
2792                                 #endregion
2793                                 #region [ DTXVmodeの終了処理 ]
2794                                 //---------------------
2795                                 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2796                                 //Trace.Indent();
2797                                 try
2798                                 {
2799                                         if (DTXVmode != null)
2800                                         {
2801                                                 DTXVmode = null;
2802                                                 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2803                                         }
2804                                         else
2805                                         {
2806                                                 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2807                                         }
2808                                 }
2809                                 finally
2810                                 {
2811                                         //Trace.Unindent();
2812                                 }
2813                                 //---------------------
2814                                 #endregion
2815                                 #region [ DirectXの終了処理 ]
2816                                 //---------------------
2817                                 base.GraphicsDeviceManager.Dispose();
2818                                 //---------------------
2819                                 #endregion
2820                                 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2821
2822
2823                                 this.b終了処理完了済み = true;
2824                         }
2825                 }
2826                 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2827                 {
2828                         STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2829                         string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2830                         CScoreIni ini = new CScoreIni(strFilename);
2831                         if (!File.Exists(strFilename))
2832                         {
2833                                 ini.stファイル.Title = DTX.TITLE;
2834                                 ini.stファイル.Name = DTX.strファイル名;
2835                                 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2836                                 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2837                                 {
2838                                         ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2839                                         ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2840                                         ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2841                                         ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2842
2843                                         ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2844                                         ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2845                                         ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2846                                         ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2847
2848                                         ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2849                                         ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2850                                         ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2851                                         ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2852                                 }
2853                         }
2854                         ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2855                         isUpdated = CScoreIni.t更新条件を取得する();
2856                         if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2857                         {
2858                                 if (isUpdated.Drums)
2859                                 {
2860                                         ini.stファイル.PlayCountDrums++;
2861                                 }
2862                                 if (isUpdated.Guitar)
2863                                 {
2864                                         ini.stファイル.PlayCountGuitar++;
2865                                 }
2866                                 if (isUpdated.Bass)
2867                                 {
2868                                         ini.stファイル.PlayCountBass++;
2869                                 }
2870                                 ini.tヒストリを追加する(str新ヒストリ行);
2871                                 if (!bコンパクトモード)
2872                                 {
2873                                         stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2874                                         stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2875                                         stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2876                                         for (int j = 0; j < ini.stファイル.History.Length; j++)
2877                                         {
2878                                                 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2879                                         }
2880                                 }
2881                         }
2882                         if (ConfigIni.bScoreIni)
2883                         {
2884                                 ini.t書き出し(strFilename);
2885                         }
2886
2887                         return ini;
2888                 }
2889                 private void tガベージコレクションを実行する()
2890                 {
2891                         // LOHに対するコンパクションを要求
2892                         GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
2893
2894                         GC.Collect(0, GCCollectionMode.Optimized, true );
2895                         GC.WaitForPendingFinalizers();
2896                         GC.Collect(0, GCCollectionMode.Forced, true );
2897                         GC.WaitForPendingFinalizers();
2898
2899                         // 通常通り、LOHへのGCを抑制
2900                         GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default;
2901                 }
2902                 private void tプラグイン検索と生成()
2903                 {
2904                         this.listプラグイン = new List<STPlugin>();
2905
2906                         string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2907                         string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2908
2909                         this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2910
2911                         if (this.listプラグイン.Count > 0)
2912                                 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2913                 }
2914
2915                 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2916                 {
2917                         var domain = (AppDomain)sender;
2918
2919                         foreach (var assembly in domain.GetAssemblies())
2920                         {
2921                                 if (assembly.FullName == args.Name)
2922                                         return assembly;
2923                         }
2924                         return null;
2925                 }
2926                 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2927                 {
2928                         // 指定されたパスが存在しないとエラー
2929                         if (!Directory.Exists(strプラグインフォルダパス))
2930                         {
2931                                 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2932                                 return;
2933                         }
2934
2935                         AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2936
2937
2938                         // (1) すべての *.dll について…
2939                         string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2940                         foreach (string dllName in strDLLs)
2941                         {
2942                                 if (Path.GetExtension(dllName).ToLower() != ".dll")
2943                                 {
2944                                         continue;
2945                                 }
2946                                 try
2947                                 {
2948                                         // (1-1) dll をアセンブリとして読み込む。
2949                                         System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2950
2951                                         // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2952                                         foreach (Type t in asm.GetTypes())
2953                                         {
2954                                                 //  (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2955                                                 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2956                                                 {
2957                                                         // (1-4) クラス名からインスタンスを作成する
2958                                                         var st = new STPlugin()
2959                                                         {
2960                                                                 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2961                                                                 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2962                                                                 strアセンブリ簡易名 = asm.GetName().Name,
2963                                                                 Version = asm.GetName().Version,
2964                                                         };
2965
2966                                                         // (1-5) プラグインリストへ登録
2967                                                         this.listプラグイン.Add(st);
2968                                                         Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2969                                                 }
2970                                         }
2971                                 }
2972                                 catch (System.Reflection.ReflectionTypeLoadException e)
2973                                 {
2974                                         Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2975                                         Trace.TraceInformation(e.ToString());
2976                                         Trace.TraceInformation(e.Message);
2977                                         {
2978                                                 StringBuilder sb = new StringBuilder();
2979                                                 foreach (Exception exSub in e.LoaderExceptions)
2980                                                 {
2981                                                         sb.AppendLine(exSub.Message);
2982                                                         FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2983                                                         if (exFileNotFound != null)
2984                                                         {
2985                                                                 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2986                                                                 {
2987                                                                         sb.AppendLine("Fusion Log:");
2988                                                                         sb.AppendLine(exFileNotFound.FusionLog);
2989                                                                 }
2990                                                         }
2991                                                         sb.AppendLine();
2992                                                 }
2993                                                 string errorMessage = sb.ToString();
2994                                                 //Display or log the error based on your application.
2995                                                 Trace.TraceInformation(errorMessage);
2996                                         }
2997                                 }
2998                                 catch (Exception e)
2999                                 {
3000                                         Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
3001                                         Trace.TraceInformation(e.ToString());
3002                                         Trace.TraceInformation(e.Message);
3003                                 }
3004                         }
3005
3006                         // (2) サブフォルダがあれば再帰する
3007                         string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
3008                         foreach (string dir in strDirs)
3009                                 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
3010                 }
3011                 //-----------------
3012                 #region [ Windowイベント処理 ]
3013                 private void Window_ApplicationActivated( object sender, EventArgs e )
3014                 {
3015                         this.bApplicationActive = true;
3016                 }
3017                 private void Window_ApplicationDeactivated(object sender, EventArgs e)
3018                 {
3019                         this.bApplicationActive = false;
3020                         if (cMouseHideControl != null) cMouseHideControl.Show();
3021                 }
3022                 private void Window_KeyDown(object sender, KeyEventArgs e)
3023                 {
3024                         if (e.KeyCode == Keys.Menu)
3025                         {
3026                                 e.Handled = true;
3027                                 e.SuppressKeyPress = true;
3028                         }
3029                         else if ((e.KeyCode == Keys.Return) && e.Alt)
3030                         {
3031                                 if (ConfigIni != null)
3032                                 {
3033                                         ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3034                                         this.t全画面_ウィンドウモード切り替え();
3035                                 }
3036                                 e.Handled = true;
3037                                 e.SuppressKeyPress = true;
3038                         }
3039                         else
3040                         {
3041                                 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
3042                                 {
3043                                         var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
3044
3045                                         if( (int) captureCode > 0 &&
3046                                                 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
3047                                         {
3048                                                 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
3049                                                 string strFullPath =
3050                                                                  Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
3051                                                 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
3052                                                 SaveResultScreen( strFullPath );
3053                                         }
3054                                 }
3055                         }
3056                 }
3057                 private void Window_MouseUp(object sender, MouseEventArgs e)
3058                 {
3059                         mb = e.Button;
3060                 }
3061
3062                 private void Window_MouseDoubleClick(object sender, MouseEventArgs e)   // #23510 2010.11.13 yyagi: to go full screen mode
3063                 {
3064                         if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen)  // #26752 2011.11.27 yyagi
3065                         {
3066                                 ConfigIni.bウィンドウモード = false;
3067                                 this.t全画面_ウィンドウモード切り替え();
3068                         }
3069                 }
3070                 private void Window_MouseMove(object sender, MouseEventArgs e)
3071                 {
3072                         if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
3073                 }
3074
3075                 private void Window_ResizeEnd(object sender, EventArgs e)               // #23510 2010.11.20 yyagi: to get resized window size
3076                 {
3077                         if (ConfigIni.bウィンドウモード)
3078                         {
3079                                 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
3080                                 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
3081                         }
3082
3083                         ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width;   // #23510 2010.10.31 yyagi add
3084                         ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
3085                 }
3086                 #endregion
3087
3088                 //Stopwatch sw = new Stopwatch();
3089                 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
3090
3091                 #endregion
3092
3093                 private class CMouseHideControl
3094                 {
3095                         private Point lastPosition;
3096                         private CCounter ccMouseShow;
3097                         private bool bマウスカーソル表示中;
3098
3099                         /// <summary>
3100                         /// コンストラクタ
3101                         /// </summary>
3102                         public CMouseHideControl()
3103                         {
3104                                 ccMouseShow = new CCounter();
3105                                 lastPosition = Cursor.Position;
3106                                 bマウスカーソル表示中 = true;
3107                                 t開始();
3108                         }
3109
3110                         public void t開始()
3111                         {
3112                                 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3113                         }
3114
3115                         public void tHideCursorIfNeed()
3116                         {
3117                                 ccMouseShow.t進行();
3118 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3119                                 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3120                                 {
3121                                         Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3122                                         if (client_point.Y >= 0)        // タイトルバー上にマウスカーソルがある場合は、隠さない
3123                                         {
3124                                                 Hide();
3125                                         }
3126                                 }
3127
3128                         }
3129
3130                         public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3131                         {
3132 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3133                                 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false)   // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3134                                 {
3135                                         Point currentPosition = Cursor.Position;
3136 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3137                                         if (lastPosition != currentPosition)
3138                                         {
3139 //Trace.TraceInformation("移動発生");
3140                                                 lastPosition = currentPosition;
3141                                                 Show();
3142                                                 t開始();
3143                                         }
3144                                 }
3145                         }
3146
3147                         public void Show()
3148                         {
3149                                 Cursor.Show();
3150                                 bマウスカーソル表示中 = true;
3151                         }
3152                         public void Hide()
3153                         {
3154                                 Cursor.Hide();
3155                                 bマウスカーソル表示中 = false;
3156                         }
3157                 }
3158
3159                 /// <summary>
3160                 /// システム環境のログを出力する
3161                 /// </summary>
3162                 private void PutSystemLog()
3163                 {
3164                         System.Management.ManagementClass mc =
3165                                 new System.Management.ManagementClass("Win32_Processor");
3166                         System.Management.ManagementObjectCollection moc = mc.GetInstances();
3167                         foreach (System.Management.ManagementObject mo in moc)
3168                         {
3169                                 Trace.TraceInformation("-------------------------");
3170                                 Trace.TraceInformation("CPU Information:");
3171                                 //Trace.TraceInformation("DeviceID      = {0}", mo["DeviceID"]);
3172                                 Trace.TraceInformation("Name          = {0}", mo["Name"]);
3173                                 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
3174                                 Trace.TraceInformation("L2CacheSize   = {0}KB", mo["L2CacheSize"]);
3175                                 Trace.TraceInformation("L3CacheSize   = {0}KB", mo["L3CacheSize"]);
3176                                 Trace.TraceInformation("NumberOfCores = {0}", mo["NumberOfCores"]);
3177                                 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
3178                         }
3179                         moc.Dispose();
3180                         mc.Dispose();
3181
3182                         //System.Management.ManagementClass mc =
3183                         //      new System.Management.ManagementClass("Win32_OperatingSystem");
3184                         //System.Management.ManagementObjectCollection moc = mc.GetInstances();
3185                         mc =
3186                                 new System.Management.ManagementClass("Win32_OperatingSystem");
3187                         moc = mc.GetInstances();
3188                         foreach (System.Management.ManagementObject mo in moc)
3189                         {
3190                                 Trace.TraceInformation("-------------------------");
3191                                 Trace.TraceInformation("OS Information:");
3192                                 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
3193                                 Trace.TraceInformation("OS: " + mo["Caption"]);
3194                                 //バージョン(Windows 8.1では、「6.3.9600」)
3195                                 Trace.TraceInformation("Version: " + mo["Version"]);
3196                                 //ビルド番号(Windows 8.1では「9600」)
3197                                 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
3198
3199                                 //サービスパック(Windows 8.1ではNULL)
3200                                 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
3201                                 //言語(日本語は「1041」)
3202                                 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
3203
3204                                 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
3205
3206                                 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
3207                         }
3208                         moc.Dispose();
3209                         mc.Dispose();
3210
3211                         Trace.TraceInformation("-------------------------");
3212                         Trace.TraceInformation("General Environment Information:");
3213                         //Trace.TraceInformation("OS Version: " + Environment.OSVersion);       // fake version will be returned (due to the lack of manifest settings)
3214                         //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
3215                         Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
3216                         Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
3217
3218                         var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
3219                         Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
3220                         Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
3221                         Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
3222                         Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
3223                         //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
3224
3225                         mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
3226                         moc = mc.GetInstances();
3227                         Trace.TraceInformation("-------------------------");
3228                         Trace.TraceInformation("Physical Memory Information:");
3229                         foreach (System.Management.ManagementObject mo in moc)
3230                         {
3231                                 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
3232                         }
3233                         moc.Dispose();
3234                         mc.Dispose();
3235
3236                         mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
3237                         moc = mc.GetInstances();
3238                         foreach (System.Management.ManagementObject mo in moc)
3239                         {
3240                                 Trace.TraceInformation("-------------------------");
3241                                 Trace.TraceInformation("Display Adapter Information:");
3242                                 Trace.TraceInformation("Name: " + mo["Name"]);
3243                                 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
3244                                 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
3245                                 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
3246                                 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3247                         }
3248                         moc.Dispose();
3249                         mc.Dispose();
3250
3251                         mc = new System.Management.ManagementClass("Win32_VideoController");
3252                         moc = mc.GetInstances();
3253                         foreach (System.Management.ManagementObject mo in moc)
3254                         {
3255                                 Trace.TraceInformation("-------------------------");
3256                                 Trace.TraceInformation("Video Controller Information:");
3257                                 Trace.TraceInformation("Description: " + mo["Description"]);
3258                                 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3259                                 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3260                         }
3261                         moc.Dispose();
3262                         mc.Dispose();
3263
3264                         mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3265                         moc = mc.GetInstances();
3266                         foreach (System.Management.ManagementObject mo in moc)
3267                         {
3268                                 Trace.TraceInformation("-------------------------");
3269                                 Trace.TraceInformation("Display Information:");
3270                                 Trace.TraceInformation("Description: " + mo["Description"]);
3271                                 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3272                                 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3273                                 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3274                                 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3275                         }
3276                         moc.Dispose();
3277                         mc.Dispose();
3278
3279                         mc = new System.Management.ManagementClass("Win32_SoundDevice");
3280                         moc = mc.GetInstances();
3281                         foreach (System.Management.ManagementObject mo in moc)
3282                         {
3283                                 Trace.TraceInformation("-------------------------");
3284                                 Trace.TraceInformation("Audio Information:");
3285                                 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3286                                 //Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3287                                 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3288
3289                                 foreach (PropertyData property in mo.Properties)
3290                                 {
3291                                         Trace.TraceInformation("{0}:{1}", property.Name, property.Value);
3292                                 }
3293                         }
3294                         moc.Dispose();
3295                         mc.Dispose();
3296
3297                         Trace.TraceInformation("----------------------");
3298                         Trace.TraceInformation("DTXMania settings:");
3299                         Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3300                         Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3301                         Trace.TraceInformation("----------------------");
3302                 }
3303
3304         }
3305 }