OSDN Git Service

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