2 using System.Collections.Generic;
3 using System.Globalization;
5 using System.Windows.Forms;
7 using System.Diagnostics;
9 using System.Threading;
10 using System.Management;
12 using SharpDX.Direct3D9;
14 using SampleFramework;
15 using System.Runtime.Serialization;
19 using Point = System.Drawing.Point;
20 using Color = System.Drawing.Color;
24 internal class CDTXMania : Game
27 #region [ properties ]
28 public static readonly string VERSION = "115(190901)";
29 //public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
30 public static readonly string D3DXDLL = "d3dx9_43.dll"; // June 2010
31 //public static readonly string D3DXDLL = "d3dx9_42.dll"; // February 2010
32 //public static readonly string D3DXDLL = "d3dx9_41.dll"; // March 2009
33 private static CDTXMania instance = new CDTXMania();
35 public static CDTXMania Instance
42 public C文字コンソール act文字コンソール { get; private set; }
43 public bool bコンパクトモード { get; private set; }
44 public CConfigXml ConfigIni;
45 public CResources Resources;
55 if ((dtx != null) && (Instance != null))
58 Instance.listトップレベルActivities.Remove(dtx);
61 if ((dtx != null) && (Instance != null))
63 Instance.listトップレベルActivities.Add(dtx);
67 public CFPS FPS { get; private set; }
68 public CInput管理 Input管理 { get; private set; }
70 public int nPerfect範囲ms
74 if (stage選曲.r確定された曲 != null)
76 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
77 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPerfect範囲ms >= 0))
79 return c曲リストノード.nPerfect範囲ms;
82 return ConfigIni.nHitRange.Perfect;
89 if (stage選曲.r確定された曲 != null)
91 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
92 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGreat範囲ms >= 0))
94 return c曲リストノード.nGreat範囲ms;
97 return ConfigIni.nHitRange.Great;
104 if (stage選曲.r確定された曲 != null)
106 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
107 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGood範囲ms >= 0))
109 return c曲リストノード.nGood範囲ms;
112 return ConfigIni.nHitRange.Good;
119 if (stage選曲.r確定された曲 != null)
121 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
122 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPoor範囲ms >= 0))
124 return c曲リストノード.nPoor範囲ms;
127 return ConfigIni.nHitRange.Poor;
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; }
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;
165 return base.GraphicsDeviceManager.Direct3D9.Device;
168 public CPluginHost PluginHost { get; private set; }
169 public List<STPlugin> listプラグイン = new List<STPlugin>();
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
177 return base.Window.Handle;
180 public CDTXVmode DTXVmode; // #28821 2014.1.23 yyagi
181 public CDTX2WAVmode DTX2WAVmode;
182 public CCommandParse CommandParse;
191 public void InitializeInstance()
193 #region [ strEXEのあるフォルダを決定する ]
194 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
196 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
197 //strEXEのあるフォルダ = Path.GetDirectoryName( Environment.GetCommandLineArgs()[ 0 ] ) + @"\";
199 strEXEのあるフォルダ = Path.GetDirectoryName(Application.ExecutablePath) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
201 // END #23629 2010.11.13 from
204 #region [ 言語リソースの初期化 ]
205 Trace.TraceInformation("言語リソースの初期化を行います。");
209 Resources = new CResources();
210 Resources.LoadResources("");
211 Trace.TraceInformation("言語リソースの初期化を完了しました。");
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ブロック外に移動
229 Coordinates = new Coordinates.CCoordinates();
231 //Coordinates = (DTXMania.Coordinates.CCoordinates) CDTXMania.DeserializeXML( strEXEのあるフォルダ + "Coordinates.xml", typeof( DTXMania.Coordinates.CCoordinates ) );
232 //if ( Coordinates == null )
234 // if ( File.Exists( strEXEのあるフォルダ + "Coordinates.xml" ) )
236 // Trace.TraceInformation( "Coordinates.xmlファイルは存在します。" );
238 // Trace.TraceInformation( "Coordiantes.xmlファイルの読み込みができませんでした。無視して進めます。" );
239 // Coordinates = new Coordinates.CCoordinates();
244 Trace.AutoFlush = true;
249 Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "DTXManiaLog.txt"), false, Encoding.GetEncoding("utf-16"))));
251 catch (System.UnauthorizedAccessException) // #24481 2011.2.20 yyagi
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);
260 Trace.WriteLine("DTXMania powered by YAMAHA Silent Session Drums");
261 Trace.WriteLine(string.Format("Release: {0} {1} mode.", VERSION, (Environment.Is64BitProcess)? "x64":"x86" ));
263 Trace.TraceInformation("----------------------");
264 Trace.TraceInformation("■ アプリケーションの初期化");
272 Trace.TraceInformation("言語情報の読み込みを開始します。");
273 //Debug.WriteLine( "language=" + Resources.Language );
274 //Debug.WriteLine( "settings=" + instance.ConfigIni.strLanguage );
275 Resources.Language = instance.ConfigIni.strLanguage;
276 Trace.TraceInformation("言語を{0}に設定しました。", Resources.Language);
280 #region [ DTXVmodeクラス, DTX2WAVmodeクラス, CommandParseクラス の初期化 ]
281 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
285 DTXVmode = new CDTXVmode();
286 DTXVmode.Enabled = false;
287 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
289 DTX2WAVmode = new CDTX2WAVmode();
290 //Trace.TraceInformation( "DTX2WAVモードの初期化を完了しました。" );
292 CommandParse = new CCommandParse();
293 //Trace.TraceInformation( "CommandParseの初期化を完了しました。" );
300 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewer/DTX2WAVとしての起動 ]
302 strコンパクトモードファイル = "";
303 string[] commandLineArgs = Environment.GetCommandLineArgs();
304 if ((commandLineArgs != null) && (commandLineArgs.Length > 1))
309 for (int i = 1; i < commandLineArgs.Length; i++)
313 arg += " " + "\"" + commandLineArgs[i] + "\"";
317 arg += commandLineArgs[i];
320 CommandParse.ParseArguments(arg, ref DTXVmode, ref DTX2WAVmode);
321 if (DTXVmode.Enabled)
323 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
324 strコンパクトモードファイル = DTXVmode.filename;
325 switch (DTXVmode.soundDeviceType) // サウンド再生方式の設定
327 case ESoundDeviceType.DirectSound:
328 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.DSound;
330 case ESoundDeviceType.ExclusiveWASAPI:
331 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
333 case ESoundDeviceType.SharedWASAPI:
334 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
336 case ESoundDeviceType.ASIO:
337 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.ASIO;
338 ConfigIni.strASIODevice.Index = DTXVmode.nASIOdevice;
342 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
343 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
346 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
350 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
353 CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
354 CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow; // #36612 2016.9.12 yyagi
355 CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
356 CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
357 CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
358 CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
360 else if (DTX2WAVmode.Enabled)
362 strコンパクトモードファイル = DTX2WAVmode.dtxfilename;
363 #region [ FDKへの録音設定 ]
364 FDK.CSound管理.strRecordInputDTXfilename = DTX2WAVmode.dtxfilename;
365 FDK.CSound管理.strRecordOutFilename = DTX2WAVmode.outfilename;
366 FDK.CSound管理.strRecordFileType = DTX2WAVmode.Format.ToString();
367 FDK.CSound管理.nBitrate = DTX2WAVmode.bitrate;
368 for (int i = 0; i < (int)FDK.CSound.EInstType.Unknown; i++)
370 FDK.CSound管理.nMixerVolume[ i ] = DTX2WAVmode.nMixerVolume[ i ];
372 ConfigIni.nMasterVolume.Value = DTX2WAVmode.nMixerVolume[(int)FDK.CSound.EInstType.Unknown]; // [5](Unknown)のところにMasterVolumeが入ってくるので注意
373 // CSound管理.nMixerVolume[5]は、結局ここからは変更しないため、
378 // 本体プロセスの優先度を少し上げる (最小化状態で動作させると、処理性能が落ちるようなので
379 // → ほとんど効果がなかったので止めます
380 //Process thisProcess = System.Diagnostics.Process.GetCurrentProcess();
381 //thisProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
383 // エンコーダーのパス設定 (=DLLフォルダ)
384 FDK.CSound管理.strEncoderPath = Path.Combine(strEXEのあるフォルダ, "DLL");
386 CDTXMania.instance.ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
387 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI.Value = false;
389 CDTXMania.instance.ConfigIni.bVSyncWait.Value = false;
390 CDTXMania.instance.ConfigIni.bTimeStretch.Value = false;
391 CDTXMania.instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
393 CDTXMania.instance.ConfigIni.bFullScreen.Value = false;
394 CDTXMania.instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;
395 CDTXMania.instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
396 CDTXMania.instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
397 CDTXMania.instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
398 CDTXMania.instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
401 CDTXMania.instance.ConfigIni.bAutoPlay.LC.Value = true;
402 CDTXMania.instance.ConfigIni.bAutoPlay.HH.Value = true;
403 CDTXMania.instance.ConfigIni.bAutoPlay.HHO.Value = true;
404 CDTXMania.instance.ConfigIni.bAutoPlay.SD.Value = true;
405 CDTXMania.instance.ConfigIni.bAutoPlay.BD.Value = true;
406 CDTXMania.instance.ConfigIni.bAutoPlay.HT.Value = true;
407 CDTXMania.instance.ConfigIni.bAutoPlay.LT.Value = true;
408 CDTXMania.instance.ConfigIni.bAutoPlay.FT.Value = true;
409 CDTXMania.instance.ConfigIni.bAutoPlay.CY.Value = true;
410 CDTXMania.instance.ConfigIni.bAutoPlay.RD.Value = true;
412 CDTXMania.instance.ConfigIni.bAutoPlay.GtR.Value = true;
413 CDTXMania.instance.ConfigIni.bAutoPlay.GtG.Value = true;
414 CDTXMania.instance.ConfigIni.bAutoPlay.GtB.Value = true;
415 CDTXMania.instance.ConfigIni.bAutoPlay.GtPick.Value = true;
416 //CDTXMania.instance.ConfigIni.bAutoPlay.GtWail.Value = true; // 無くてもよい 処理不可削減のため、敢えてWailはAutoにしない
417 CDTXMania.instance.ConfigIni.bAutoPlay.BsR.Value = true;
418 CDTXMania.instance.ConfigIni.bAutoPlay.BsG.Value = true;
419 CDTXMania.instance.ConfigIni.bAutoPlay.BsB.Value = true;
420 CDTXMania.instance.ConfigIni.bAutoPlay.BsPick.Value = true;
421 //CDTXMania.instance.ConfigIni.bAutoPlay.BsWail.Value = true;
424 CDTXMania.instance.ConfigIni.bFillin.Value = false;
425 CDTXMania.instance.ConfigIni.bAudience.Value = false;
427 CDTXMania.instance.ConfigIni.bStoicMode.Value = false;
429 CDTXMania.instance.ConfigIni.eSudHidInv.Drums.Value = ESudHidInv.FullInv;
430 CDTXMania.instance.ConfigIni.eSudHidInv.Guitar.Value = ESudHidInv.FullInv;
431 CDTXMania.instance.ConfigIni.eSudHidInv.Bass.Value = ESudHidInv.FullInv;
434 CDTXMania.instance.ConfigIni.eDark.Value = EDark.Full;
437 CDTXMania.instance.ConfigIni.nPolyphonicSounds.Value = 4;
440 CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
443 CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
444 CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
445 CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
448 CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
449 CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
452 //CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100; // DTX2WAV側から設定するので、ここでは触らない
455 CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
458 CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
459 CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
460 CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
463 CDTXMania.instance.ConfigIni.bDisplayCombo.Drums.Value = false;
464 CDTXMania.instance.ConfigIni.bDisplayCombo.Guitar.Value = false;
465 CDTXMania.instance.ConfigIni.bDisplayCombo.Bass.Value = false;
466 CDTXMania.instance.ConfigIni.bDisplayJudge.Drums.Value = false;
467 CDTXMania.instance.ConfigIni.bDisplayJudge.Guitar.Value = false;
468 CDTXMania.instance.ConfigIni.bDisplayJudge.Bass.Value = false;
472 //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
473 CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
476 CDTXMania.instance.ConfigIni.bBGA.Value = false;
477 CDTXMania.instance.ConfigIni.bAVI.Value = false;
480 CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
481 CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
484 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Drums.Value = false;
485 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Guitar.Value = false;
486 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Bass.Value = false;
488 // パッド入力等、基本操作の無効化 (ESCを除く)
489 //CDTXMania.Instance.ConfigIni.KeyAssign[][];
495 strコンパクトモードファイル = commandLineArgs[1];
498 if (!File.Exists(strコンパクトモードファイル)) // #32985 2014.1.23 yyagi
500 Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
502 Environment.Exit(-1);
504 if (strコンパクトモードファイル == "") // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
506 Environment.Exit(-1);
510 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
514 if (DTXVmode.Enabled)
516 Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
518 else if (DTX2WAVmode.Enabled)
520 Trace.TraceInformation("DTX2WAVモードで起動します。[{0}]", strコンパクトモードファイル);
521 DTX2WAVmode.SendMessage2DTX2WAV("BOOT");
525 Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
530 Trace.TraceInformation("通常モードで起動します。");
534 #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
535 CPowerPlan.BackupCurrentPowerPlan();
536 if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
538 CPowerPlan.ChangeHighPerformance();
542 #region [ Input管理 の初期化 ]
543 Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
547 bool bUseMIDIIn = !DTXVmode.Enabled;
548 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
550 // If the users uses MIDI2.0-USB cable, then warn it
551 if (bUseMIDIIn && CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value)
553 foreach (IInputDevice device in Input管理.list入力デバイス)
555 if ((device.e入力デバイス種別 == E入力デバイス種別.MidiIn) && (device.strDeviceName == "USB2.0-MIDI"))
557 string strWarnMes = CDTXMania.Instance.Resources.Explanation("strWarnMIDI20USB");
558 var ret = MessageBox.Show(strWarnMes, "DTXMania Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
559 if (ret == DialogResult.OK)
561 CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value = false;
569 foreach (IInputDevice device in Input管理.list入力デバイス)
571 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
574 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
578 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
581 foreach (IInputDevice device2 in Input管理.list入力デバイス)
583 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
585 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
587 if (device2.GUID.Equals(pair.Value))
589 ((CInputJoystick)device2).SetID(pair.Key);
596 Trace.TraceInformation("DirectInput の初期化を完了しました。");
598 catch (Exception exception2)
600 Trace.TraceError(exception2.Message);
601 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
603 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
604 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
614 // #30675 2013.02.04 ikanick add
615 base.Window.StartPosition = FormStartPosition.Manual;
616 base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
617 // 事前にDTXVmodeの実体を作っておくこと
618 base.Window.Text = this.strWindowTitle;
619 //base.Window.StartPosition = FormStartPosition.Manual;
620 //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
622 // #34510 yyagi 2010.10.31 to change window size got from Config.ini
623 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
624 #if !WindowedFullscreen
625 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
626 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
628 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
629 #if !WindowedFullscreen
632 // #23510 2010.11.04 yyagi: to support maximizing window
633 base.Window.MaximizeBox = true;
634 // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
635 base.Window.FormBorderStyle = FormBorderStyle.Sizable;
636 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
637 base.Window.ShowIcon = true;
638 base.Window.Icon = Properties.Resources.dtx;
639 base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
640 base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
641 // #23510 2010.11.13 yyagi: to go fullscreen mode
642 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
643 // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
644 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
645 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
646 base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
647 base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
650 #region [ Direct3D9Exを使うかどうか判定 ]
653 #region [ Direct3D9 デバイスの生成 ]
654 DeviceSettings settings = new DeviceSettings();
655 #if WindowedFullscreen
656 // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
657 settings.Windowed = true;
659 settings.Windowed = ConfigIni.bウィンドウモード;
661 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
662 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
663 settings.EnableVSync = ConfigIni.bVSyncWait;
664 //settings.MultisampleType = MultisampleType.FourSamples;
665 //settings.MultisampleQuality = 3;
666 //settings.MultisampleType = MultisampleType.NonMaskable;
667 //settings.Multithreaded = true;
672 base.GraphicsDeviceManager.ChangeDevice(settings);
674 catch (DeviceCreationException e)
676 Trace.TraceError(e.ToString());
677 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
678 Environment.Exit(-1);
680 Trace.TraceInformation("DeviceCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
681 Trace.TraceInformation("DeviceCaps2 = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
682 Trace.TraceInformation("MaxTextureWidth = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
683 Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
684 Trace.TraceInformation("TextureCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
685 Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
686 Trace.TraceInformation("DeviceStatics = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
688 base.IsFixedTimeStep = false;
689 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
690 // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
691 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
692 // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
693 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
694 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
695 #if WindowedFullscreen
696 // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
697 this.t全画面_ウィンドウモード切り替え();
699 actFlushGPU = new CActFlushGPU();
702 if (DTX2WAVmode.Enabled)
704 this.Window.WindowState = FormWindowState.Minimized; //DTX2WAVモード時は自動的に最小化
709 #region [ Skin の初期化 ]
710 Trace.TraceInformation("スキンの初期化を行います。");
715 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
716 CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
717 // 旧指定のSkinフォルダが消滅していた場合に備える
718 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
719 Trace.TraceInformation("スキンの初期化を完了しました。");
723 Trace.TraceInformation("スキンの初期化に失敗しました。");
731 #region [ Skin配下にある言語リソースの確認と初期化 ]
732 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
736 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
737 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
739 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
742 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
746 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
758 #region [ Timer の初期化 ]
759 Trace.TraceInformation("タイマの初期化を行います。");
763 Timer = new CTimer(CTimer.E種別.MultiMedia);
764 Trace.TraceInformation("タイマの初期化を完了しました。");
772 #region [ マウス消去用のクラスを初期化 ]
773 cMouseHideControl = new CMouseHideControl();
776 #region [ FPS カウンタの初期化 ]
777 Trace.TraceInformation("FPSカウンタの初期化を行います。");
782 Trace.TraceInformation("FPSカウンタを生成しました。");
790 #region [ act文字コンソールの初期化 ]
791 Trace.TraceInformation("文字コンソールの初期化を行います。");
795 act文字コンソール = new C文字コンソール();
796 Trace.TraceInformation("文字コンソールを生成しました。");
798 Trace.TraceInformation("文字コンソールを活性化しました。");
799 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
801 catch (Exception exception)
803 Trace.TraceError(exception.Message);
804 Trace.TraceError("文字コンソールの初期化に失敗しました。");
813 Trace.TraceInformation("パッドの初期化を行います。");
818 Trace.TraceInformation("パッドの初期化を完了しました。");
820 catch (Exception exception3)
822 Trace.TraceError(exception3.Message);
823 Trace.TraceError("パッドの初期化に失敗しました。");
831 #region [ Sound管理 の初期化 ]
832 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
836 ESoundDeviceType soundDeviceType;
837 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
839 case ESoundDeviceTypeForConfig.DSound:
840 soundDeviceType = ESoundDeviceType.DirectSound;
842 case ESoundDeviceTypeForConfig.ASIO:
843 soundDeviceType = ESoundDeviceType.ASIO;
845 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
846 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
848 case ESoundDeviceTypeForConfig.WASAPI_Shared:
849 soundDeviceType = ESoundDeviceType.SharedWASAPI;
852 soundDeviceType = ESoundDeviceType.Unknown;
855 Sound管理 = new CSound管理(base.Window.Handle,
857 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
858 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
860 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
861 CDTXMania.Instance.ConfigIni.bUseOSTimer
863 //Sound管理 = FDK.CSound管理.Instance;
864 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
866 ShowWindowTitleWithSoundType();
867 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
868 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
869 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
872 string strDefaultSoundDeviceBusType = CSound管理.strDefaultDeviceBusType;
873 Trace.TraceInformation($"Bus type of the default sound device = {strDefaultSoundDeviceBusType}");
875 if (strDefaultSoundDeviceBusType.ToUpper().Equals("USB"))
877 if (CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value)
879 string strWarnMes = CDTXMania.Instance.Resources.Explanation("strWarnSoundDeviceOnUSB");
880 var ret = MessageBox.Show(strWarnMes, "DTXMania Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
881 if (ret == DialogResult.OK)
883 CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value = false;
888 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
892 Trace.TraceError(e.Message);
901 #region [ Songs管理 の初期化 ]
902 //---------------------
903 Trace.TraceInformation("曲リストの初期化を行います。");
907 Songs管理 = new CSongs管理();
908 // Songs管理_裏読 = new CSongs管理();
909 EnumSongs = new CEnumSongs();
910 actEnumSongs = new CActEnumSongs();
911 Trace.TraceInformation("曲リストの初期化を完了しました。");
915 Trace.TraceError(e.Message);
916 Trace.TraceError("曲リストの初期化に失敗しました。");
922 //---------------------
925 #region [ CAvi の初期化 ]
929 #region [ Random の初期化 ]
930 Random = new Random((int)Timer.nシステム時刻);
936 stage起動 = new CStage起動();
937 stageタイトル = new CStageタイトル();
938 stageコンフィグ = new CStageコンフィグ();
939 stage選曲 = new CStage選曲();
940 stage曲読み込み = new CStage曲読み込み();
941 stage演奏画面 = new CStage演奏画面共通();
942 stage結果 = new CStage結果();
943 stageChangeSkin = new CStageChangeSkin();
944 stage終了 = new CStage終了();
946 this.listトップレベルActivities = new List<CActivity>();
947 this.listトップレベルActivities.Add(actEnumSongs);
948 this.listトップレベルActivities.Add(act文字コンソール);
949 this.listトップレベルActivities.Add(stage起動);
950 this.listトップレベルActivities.Add(stageタイトル);
951 this.listトップレベルActivities.Add(stageコンフィグ);
952 this.listトップレベルActivities.Add(stage選曲);
953 this.listトップレベルActivities.Add(stage曲読み込み);
954 this.listトップレベルActivities.Add(stage演奏画面);
955 this.listトップレベルActivities.Add(stage結果);
956 this.listトップレベルActivities.Add(stageChangeSkin);
957 this.listトップレベルActivities.Add(stage終了);
958 this.listトップレベルActivities.Add(actFlushGPU);
961 #region [ プラグインの検索と生成 ]
962 PluginHost = new CPluginHost();
964 Trace.TraceInformation("プラグインの検索と生成を行います。");
969 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
977 #region [ プラグインの初期化 ]
978 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
980 Trace.TraceInformation("プラグインの初期化を行います。");
984 foreach (STPlugin st in this.listプラグイン)
986 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
987 st.plugin.On初期化(this.PluginHost);
988 st.plugin.OnManagedリソースの作成();
989 st.plugin.OnUnmanagedリソースの作成();
990 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
992 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
996 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
1007 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
1009 #region [ 最初のステージの起動 ]
1010 Trace.TraceInformation("----------------------");
1011 Trace.TraceInformation("■ 起動");
1013 if (CDTXMania.Instance.bコンパクトモード)
1015 r現在のステージ = stage曲読み込み;
1026 public void t全画面_ウィンドウモード切り替え()
1028 #if WindowedFullscreen
1029 if (ConfigIni != null)
1031 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
1032 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
1035 #if !WindowedFullscreen
1036 settings.Windowed = ConfigIni.bウィンドウモード;
1038 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
1040 currentClientSize = this.Window.ClientSize;
1041 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
1042 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
1043 // FDK.CTaskBar.ShowTaskBar( false );
1045 #if !WindowedFullscreen
1046 base.GraphicsDeviceManager.ChangeDevice( settings );
1048 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
1050 #if WindowedFullscreen
1051 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
1052 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
1053 // in spite of using fullscreen mode.
1054 Instance.Window.WindowState = FormWindowState.Normal;
1055 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1056 Instance.Window.WindowState = FormWindowState.Normal;
1058 base.Window.ClientSize =
1059 new Size(currentClientSize.Width, currentClientSize.Height);
1060 // FDK.CTaskBar.ShowTaskBar( true );
1062 #if WindowedFullscreen
1065 Instance.Window.WindowState = FormWindowState.Normal;
1066 Instance.Window.FormBorderStyle = FormBorderStyle.None;
1067 Instance.Window.WindowState = FormWindowState.Maximized;
1069 if (cMouseHideControl != null)
1071 if (ConfigIni.bウィンドウモード)
1073 cMouseHideControl.Show();
1077 cMouseHideControl.Hide();
1084 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1086 /// リザルト画像のキャプチャと保存。
1088 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1089 public bool SaveResultScreen(string strFullPath)
1091 string strSavePath = Path.GetDirectoryName(strFullPath);
1092 if (!Directory.Exists(strSavePath))
1096 Directory.CreateDirectory(strSavePath);
1104 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1105 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1107 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1115 protected override void Initialize()
1119 //swlist1 = new List<int>( 8192 );
1120 //swlist2 = new List<int>( 8192 );
1121 //swlist3 = new List<int>( 8192 );
1122 //swlist4 = new List<int>( 8192 );
1123 //swlist5 = new List<int>( 8192 );
1124 if (this.listトップレベルActivities != null)
1126 foreach (CActivity activity in this.listトップレベルActivities)
1127 activity.OnManagedリソースの作成();
1130 foreach (STPlugin st in this.listプラグイン)
1132 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1133 st.plugin.OnManagedリソースの作成();
1134 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1136 #if GPUFlushAfterPresent
1137 FrameEnd += dtxmania_FrameEnd;
1140 #if GPUFlushAfterPresent
1141 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1142 { // → Present()直後にGPUをFlushする
1143 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1144 actFlushGPU.On進行描画(); // Flush GPU
1147 protected override void LoadContent()
1149 if (cMouseHideControl != null)
1151 if (ConfigIni.bウィンドウモード)
1153 cMouseHideControl.Show();
1157 cMouseHideControl.Hide();
1160 this.Device.SetTransform(TransformState.View, Matrix.LookAtLH(new Vector3(0f, 0f, (float)(-SampleFramework.GameWindowSize.Height / 2 * Math.Sqrt(3.0))), new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f)));
1161 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1162 this.Device.SetRenderState(RenderState.Lighting, false);
1163 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1164 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1165 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1166 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1168 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1169 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1170 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1172 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1173 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1174 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1175 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1176 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1177 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1178 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1180 if (this.listトップレベルActivities != null)
1182 foreach (CActivity activity in this.listトップレベルActivities)
1183 activity.OnUnmanagedリソースの作成();
1186 foreach (STPlugin st in this.listプラグイン)
1188 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1189 st.plugin.OnUnmanagedリソースの作成();
1190 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1193 protected override void UnloadContent()
1195 if (this.listトップレベルActivities != null)
1197 foreach (CActivity activity in this.listトップレベルActivities)
1198 activity.OnUnmanagedリソースの解放();
1201 foreach (STPlugin st in this.listプラグイン)
1203 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1204 st.plugin.OnUnmanagedリソースの解放();
1205 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1208 protected override void OnExiting(EventArgs e)
1210 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1214 protected override void Update(GameTime gameTime)
1217 protected override void Draw(GameTime gameTime)
1219 if (Sound管理 == null)
1223 //Sound管理.t再生中の処理をする();
1227 if (CSound管理.rc演奏用タイマ != null)
1228 CSound管理.rc演奏用タイマ.t更新();
1230 if (Input管理 != null)
1231 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1236 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1237 // Pad.st検知したデバイス.Clear();
1239 if (this.Device == null)
1242 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1243 CPowerManagement.tDisableMonitorSuspend();
1245 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1247 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1249 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1253 #region [ DTXCreator/DTX2WAVからの指示 ]
1254 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1256 string strMes = this.Window.strMessage;
1257 this.Window.IsReceivedMessage = false;
1260 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1262 if (DTXVmode.Enabled)
1265 strコンパクトモードファイル = DTXVmode.filename;
1266 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1269 string strPreviewFilename = DTXVmode.previewFilename;
1270 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1273 if (this.previewSound != null)
1275 this.previewSound.tサウンドを停止する();
1276 this.previewSound.Dispose();
1277 this.previewSound = null;
1279 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1280 this.previewSound.n音量 = DTXVmode.previewVolume;
1281 this.previewSound.n位置 = DTXVmode.previewPan;
1282 this.previewSound.t再生を開始する();
1283 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1287 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1288 if (this.previewSound != null)
1290 this.previewSound.Dispose();
1292 this.previewSound = null;
1296 if (DTX2WAVmode.Enabled)
1298 if (DTX2WAVmode.Command == CDTX2WAVmode.ECommand.Cancel)
1300 Trace.TraceInformation("録音のCancelコマンドをDTXMania本体が受信しました。");
1301 //Microsoft.VisualBasic.Interaction.AppActivate("メモ帳");
1302 //SendKeys.Send("{ESC}");
1303 //SendKeys.SendWait("%{F4}");
1304 //Application.Exit();
1305 if (DTX != null) // 曲読み込みの前に録音Cancelされると、DTXがnullのままここにきてでGPFとなる→nullチェック追加
1312 //Environment.ExitCode = 10010; // この組み合わせではダメ、返り値が反映されない
1313 //base.Window.Close();
1314 Environment.Exit(10010); // このやり方ならばOK
1321 this.Device.BeginScene();
1322 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1324 if (r現在のステージ != null)
1326 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1328 #region [ プラグインの進行描画 ]
1329 //---------------------
1330 foreach (STPlugin sp in this.listプラグイン)
1332 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1334 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1335 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1337 sp.plugin.On進行描画(null, null);
1339 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1341 //---------------------
1344 #region [ DTX2WAVモード時、ステージが変わるたびに、そのことをDTX2WAVアプリ側に通知する ]
1345 if (DTX2WAVmode.Enabled && r現在のステージ != r1フレーム前のステージ)
1347 r1フレーム前のステージ = r現在のステージ;
1348 //Trace.TraceInformation("Stage変更 to : " + r現在のステージ.eステージID.ToString());
1349 switch (r現在のステージ.eステージID)
1351 case CStage.Eステージ.曲読み込み:
1352 DTX2WAVmode.SendMessage2DTX2WAV("LOAD");
1354 case CStage.Eステージ.演奏:
1355 DTX2WAVmode.SendMessage2DTX2WAV("PLAY");
1363 CScoreIni scoreIni = null;
1365 if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1367 // → songs.db等の書き込み時だと音切れするっぽい
1368 actEnumSongs.On非活性化();
1369 EnumSongs.SongListEnumCompletelyDone();
1370 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1372 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1373 if (!CDTXMania.Instance.bコンパクトモード)
1375 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1377 switch (r現在のステージ.eステージID)
1379 case CStage.Eステージ.タイトル:
1380 case CStage.Eステージ.コンフィグ:
1381 case CStage.Eステージ.選曲:
1382 case CStage.Eステージ.曲読み込み:
1383 if (EnumSongs != null)
1385 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1386 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1387 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1388 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1389 !EnumSongs.IsSongListEnumStarted)
1391 actEnumSongs.On活性化();
1392 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1393 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1394 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1395 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1397 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1402 #region [ 曲検索の中断と再開 ]
1403 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1405 switch (this.n進行描画の戻り値)
1408 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1409 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1411 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1412 EnumSongs.IsSlowdown = false;
1416 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1417 EnumSongs.IsSlowdown = true;
1419 actEnumSongs.On活性化();
1423 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1424 actEnumSongs.On非活性化();
1430 #region [ 曲探索中断待ち待機 ]
1431 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1432 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1434 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1438 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1439 // CStage選曲.On活性化() に回した方がいいかな?
1440 if (EnumSongs.IsSongListEnumerated)
1442 actEnumSongs.On非活性化();
1443 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1445 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1446 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1447 EnumSongs.SongListEnumCompletelyDone();
1455 switch (r現在のステージ.eステージID)
1457 case CStage.Eステージ.何もしない:
1460 case CStage.Eステージ.起動:
1462 //-----------------------------
1463 if (this.n進行描画の戻り値 != 0)
1468 Trace.TraceInformation("----------------------");
1469 Trace.TraceInformation("■ タイトル");
1471 r直前のステージ = r現在のステージ;
1472 r現在のステージ = stageタイトル;
1477 Trace.TraceInformation("----------------------");
1478 Trace.TraceInformation("■ 曲読み込み");
1480 r直前のステージ = r現在のステージ;
1481 r現在のステージ = stage曲読み込み;
1484 foreach (STPlugin pg in this.listプラグイン)
1486 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1487 pg.plugin.Onステージ変更();
1488 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1491 this.tガベージコレクションを実行する();
1493 //-----------------------------
1497 case CStage.Eステージ.タイトル:
1499 //-----------------------------
1500 switch (this.n進行描画の戻り値)
1502 case (int)CStageタイトル.E戻り値.GAMESTART:
1504 //-----------------------------
1506 Trace.TraceInformation("----------------------");
1507 Trace.TraceInformation("■ 選曲");
1509 r直前のステージ = r現在のステージ;
1511 //-----------------------------
1515 #region [ OPTION: 廃止済 ]
1516 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1518 // //-----------------------------
1519 // r現在のステージ.On非活性化();
1520 // Trace.TraceInformation( "----------------------" );
1521 // Trace.TraceInformation( "■ オプション" );
1522 // stageオプション.On活性化();
1523 // r直前のステージ = r現在のステージ;
1524 // r現在のステージ = stageオプション;
1525 // //-----------------------------
1530 case (int)CStageタイトル.E戻り値.CONFIG:
1532 //-----------------------------
1534 Trace.TraceInformation("----------------------");
1535 Trace.TraceInformation("■ コンフィグ");
1537 r直前のステージ = r現在のステージ;
1538 r現在のステージ = stageコンフィグ;
1539 //-----------------------------
1543 case (int)CStageタイトル.E戻り値.EXIT:
1545 //-----------------------------
1547 Trace.TraceInformation("----------------------");
1548 Trace.TraceInformation("■ 終了");
1550 r直前のステージ = r現在のステージ;
1552 //-----------------------------
1557 foreach (STPlugin pg in this.listプラグイン)
1559 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1560 pg.plugin.Onステージ変更();
1561 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1564 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1565 //-----------------------------
1569 case CStage.Eステージ.コンフィグ:
1571 //-----------------------------
1572 if (this.n進行描画の戻り値 != 0)
1574 switch (r直前のステージ.eステージID)
1576 case CStage.Eステージ.タイトル:
1578 //-----------------------------
1580 Trace.TraceInformation("----------------------");
1581 Trace.TraceInformation("■ タイトル");
1583 r直前のステージ = r現在のステージ;
1584 r現在のステージ = stageタイトル;
1586 foreach (STPlugin pg in this.listプラグイン)
1588 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1589 pg.plugin.Onステージ変更();
1590 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1593 this.tガベージコレクションを実行する();
1595 //-----------------------------
1598 case CStage.Eステージ.選曲:
1600 //-----------------------------
1602 Trace.TraceInformation("----------------------");
1603 Trace.TraceInformation("■ 選曲");
1605 r直前のステージ = r現在のステージ;
1608 foreach (STPlugin pg in this.listプラグイン)
1610 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1611 pg.plugin.Onステージ変更();
1612 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1615 this.tガベージコレクションを実行する();
1617 //-----------------------------
1621 //-----------------------------
1625 case CStage.Eステージ.選曲:
1627 //-----------------------------
1628 switch (this.n進行描画の戻り値)
1630 case (int)CStage選曲.E戻り値.タイトルに戻る:
1632 //-----------------------------
1634 Trace.TraceInformation("----------------------");
1635 Trace.TraceInformation("■ タイトル");
1637 r直前のステージ = r現在のステージ;
1638 r現在のステージ = stageタイトル;
1640 foreach (STPlugin pg in this.listプラグイン)
1642 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1643 pg.plugin.Onステージ変更();
1644 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1647 this.tガベージコレクションを実行する();
1649 //-----------------------------
1652 case (int)CStage選曲.E戻り値.選曲した:
1654 //-----------------------------
1656 Trace.TraceInformation("----------------------");
1657 Trace.TraceInformation("■ 曲読み込み");
1659 r直前のステージ = r現在のステージ;
1660 r現在のステージ = stage曲読み込み;
1662 foreach (STPlugin pg in this.listプラグイン)
1664 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1665 pg.plugin.Onステージ変更();
1666 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1669 this.tガベージコレクションを実行する();
1671 //-----------------------------
1674 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1676 //-----------------------------
1678 Trace.TraceInformation("----------------------");
1679 Trace.TraceInformation("■ コンフィグ");
1681 r直前のステージ = r現在のステージ;
1682 r現在のステージ = stageコンフィグ;
1684 foreach (STPlugin pg in this.listプラグイン)
1686 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1687 pg.plugin.Onステージ変更();
1688 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1691 this.tガベージコレクションを実行する();
1693 //-----------------------------
1696 case (int)CStage選曲.E戻り値.スキン変更:
1699 //-----------------------------
1701 Trace.TraceInformation("----------------------");
1702 Trace.TraceInformation("■ スキン切り替え");
1703 stageChangeSkin.On活性化();
1704 r直前のステージ = r現在のステージ;
1705 r現在のステージ = stageChangeSkin;
1707 //-----------------------------
1710 //-----------------------------
1714 case CStage.Eステージ.曲読み込み:
1716 //-----------------------------
1717 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1718 if (this.n進行描画の戻り値 != 0)
1720 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1722 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1723 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1727 Trace.TraceInformation("曲の読み込みを中止しました。");
1728 this.tガベージコレクションを実行する();
1729 Trace.TraceInformation("----------------------");
1730 Trace.TraceInformation("■ 選曲");
1732 r直前のステージ = r現在のステージ;
1734 foreach (STPlugin pg in this.listプラグイン)
1736 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1737 pg.plugin.Onステージ変更();
1738 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1744 Trace.TraceInformation("----------------------");
1745 Trace.TraceInformation("■ 演奏(ドラム画面)");
1746 r直前のステージ = r現在のステージ;
1747 r現在のステージ = stage演奏画面;
1749 foreach (STPlugin pg in this.listプラグイン)
1751 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1752 pg.plugin.Onステージ変更();
1753 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1756 this.tガベージコレクションを実行する();
1758 //-----------------------------
1762 case CStage.Eステージ.演奏:
1764 //-----------------------------
1765 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1766 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1767 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1768 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1769 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1771 //swlist1.Add( Convert.ToInt32(n1) );
1772 //swlist2.Add( Convert.ToInt32(n2) );
1773 //swlist3.Add( Convert.ToInt32( n3 ) );
1774 //swlist4.Add( Convert.ToInt32( n4 ) );
1775 //swlist5.Add( Convert.ToInt32( n5 ) );
1777 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1778 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1780 DTXVmode.Refreshed = false;
1782 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1784 CDTXMania.Instance.stage演奏画面.t停止();
1786 if (previewSound != null)
1788 this.previewSound.tサウンドを停止する();
1789 this.previewSound.Dispose();
1790 this.previewSound = null;
1795 // for ( int i = 0; i < swlist1.Count; i++ )
1797 // int d1 = swlist1[ i ];
1798 // int d2 = swlist2[ i ];
1799 // int d3 = swlist3[ i ];
1800 // int d4 = swlist4[ i ];
1801 // int d5 = swlist5[ i ];
1803 // int dif = d1 - lastd;
1805 // if ( 16 <= dif && dif <= 17 )
1812 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3} - {7:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4, d5 );
1824 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1826 if (DTXVmode.NeedReload)
1828 CDTXMania.Instance.stage演奏画面.t再読込();
1829 if (DTXVmode.GRmode)
1831 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1835 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1837 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1838 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1839 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1841 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1842 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1847 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1853 switch (this.n進行描画の戻り値)
1855 case (int)E演奏画面の戻り値.再読込_再演奏:
1856 #region [ DTXファイルを再読み込みして、再演奏 ]
1861 r直前のステージ = r現在のステージ;
1862 r現在のステージ = stage曲読み込み;
1863 this.tガベージコレクションを実行する();
1867 //case (int) E演奏画面の戻り値.再演奏:
1868 #region [ 再読み込み無しで、再演奏 ]
1872 case (int)E演奏画面の戻り値.継続:
1875 case (int)E演奏画面の戻り値.演奏中断:
1877 //-----------------------------
1878 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1879 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1881 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1886 //for (int i = 0; i < swlist1.Count; i++)
1888 // int d1 = swlist1[ i ];
1889 // int d2 = swlist2[ i ];
1890 // int d3 = swlist3[ i ];
1891 // int d4 = swlist4[ i ];
1893 // int dif = d1 - lastd;
1895 // if ( 16 <= dif && dif <= 17 )
1902 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1911 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1912 //---------------------
1913 foreach (STPlugin pg in this.listプラグイン)
1915 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1916 pg.plugin.On演奏キャンセル(scoreIni);
1917 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1919 //---------------------
1925 if (DTX2WAVmode.Enabled)
1927 Environment.Exit(0);
1931 base.Window.Close();
1935 Trace.TraceInformation("----------------------");
1936 Trace.TraceInformation("■ 選曲");
1938 r直前のステージ = r現在のステージ;
1941 #region [ プラグイン Onステージ変更() の呼び出し ]
1942 //---------------------
1943 foreach (STPlugin pg in this.listプラグイン)
1945 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1946 pg.plugin.Onステージ変更();
1947 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1949 //---------------------
1952 this.tガベージコレクションを実行する();
1955 //-----------------------------
1958 case (int)E演奏画面の戻り値.ステージ失敗:
1959 #region [ 演奏失敗(StageFailed) ]
1960 //-----------------------------
1961 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1963 #region [ プラグイン On演奏失敗() の呼び出し ]
1964 //---------------------
1965 foreach (STPlugin pg in this.listプラグイン)
1967 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1968 pg.plugin.On演奏失敗(scoreIni);
1969 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1971 //---------------------
1979 base.Window.Close();
1983 Trace.TraceInformation("----------------------");
1984 Trace.TraceInformation("■ 選曲");
1986 r直前のステージ = r現在のステージ;
1989 #region [ プラグイン Onステージ変更() の呼び出し ]
1990 //---------------------
1991 foreach (STPlugin pg in this.listプラグイン)
1993 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1994 pg.plugin.Onステージ変更();
1995 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1997 //---------------------
2000 this.tガベージコレクションを実行する();
2003 //-----------------------------
2006 case (int)E演奏画面の戻り値.ステージクリア:
2008 //-----------------------------
2009 STDGBSValue<CScoreIni.C演奏記録> record;
2010 record = stage演奏画面.Record;
2012 double playskill = 0.0;
2014 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
2016 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
2018 playskill = record[inst].db演奏型スキル値;
2022 string str = "Cleared";
2023 switch (CScoreIni.t総合ランク値を計算して返す(record))
2025 case CScoreIni.ERANK.SS:
2026 str = string.Format("Cleared (SS: {0:F2})", playskill);
2029 case CScoreIni.ERANK.S:
2030 str = string.Format("Cleared (S: {0:F2})", playskill);
2033 case CScoreIni.ERANK.A:
2034 str = string.Format("Cleared (A: {0:F2})", playskill);
2037 case CScoreIni.ERANK.B:
2038 str = string.Format("Cleared (B: {0:F2})", playskill);
2041 case CScoreIni.ERANK.C:
2042 str = string.Format("Cleared (C: {0:F2})", playskill);
2045 case CScoreIni.ERANK.D:
2046 str = string.Format("Cleared (D: {0:F2})", playskill);
2049 case CScoreIni.ERANK.E:
2050 str = string.Format("Cleared (E: {0:F2})", playskill);
2053 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
2054 str = "Cleared (No chips)";
2058 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
2060 #region [ プラグイン On演奏クリア() の呼び出し ]
2061 //---------------------
2062 foreach (STPlugin pg in this.listプラグイン)
2064 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2065 pg.plugin.On演奏クリア(scoreIni);
2066 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2068 //---------------------
2072 Trace.TraceInformation("----------------------");
2073 Trace.TraceInformation("■ 結果");
2074 stage結果.st演奏記録 = record;
2075 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
2077 r直前のステージ = r現在のステージ;
2080 #region [ プラグイン Onステージ変更() の呼び出し ]
2081 //---------------------
2082 foreach (STPlugin pg in this.listプラグイン)
2084 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2085 pg.plugin.Onステージ変更();
2086 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2088 //---------------------
2092 //-----------------------------
2095 //-----------------------------
2099 case CStage.Eステージ.結果:
2101 //-----------------------------
2102 if (this.n進行描画の戻り値 != 0)
2104 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2105 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2106 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2108 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
2116 Trace.TraceInformation("----------------------");
2117 Trace.TraceInformation("■ 選曲");
2119 r直前のステージ = r現在のステージ;
2122 foreach (STPlugin pg in this.listプラグイン)
2124 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2125 pg.plugin.Onステージ変更();
2126 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2129 this.tガベージコレクションを実行する();
2133 base.Window.Close();
2136 //-----------------------------
2140 case CStage.Eステージ.ChangeSkin:
2142 //-----------------------------
2143 if (this.n進行描画の戻り値 != 0)
2146 Trace.TraceInformation("----------------------");
2147 Trace.TraceInformation("■ 選曲");
2149 r直前のステージ = r現在のステージ;
2151 this.tガベージコレクションを実行する();
2153 //-----------------------------
2157 case CStage.Eステージ.終了:
2159 //-----------------------------
2160 if (this.n進行描画の戻り値 != 0)
2164 //-----------------------------
2169 this.Device.EndScene();
2170 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2171 // (つまり、Present()は、Draw()完了後に実行される)
2172 #if !GPUFlushAfterPresent
2173 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2175 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2177 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2180 #region [ マウスカーソル消去制御 ]
2181 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2183 #region [ 全画面・ウインドウ切り替え ]
2184 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2186 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2187 Instance.t全画面_ウィンドウモード切り替え();
2188 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2191 #region [ 垂直基線同期切り替え ]
2192 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2194 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2195 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2196 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2197 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2198 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2199 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2200 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2203 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2208 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2209 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2214 /// XML ファイルからオブジェクトを生成します。
2216 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2217 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2218 public static object DeserializeXML(string xmlpath, Type t)
2223 if (File.Exists(xmlpath))
2225 using (StreamReader reader = new StreamReader(xmlpath, Encoding.GetEncoding("shift_jis")))
2226 using (XmlReader xr = XmlReader.Create(reader))
2228 DataContractSerializer serializer = new DataContractSerializer(t);
2229 ret = serializer.ReadObject(xr);
2235 Trace.TraceWarning( e.Message );
2242 /// オブジェクトから XML ファイルを生成します。
2244 /// <param name="xmlfile">XML ファイルのパス。</param>
2245 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2246 public static void SerializeXML(string xmlpath, object obj)
2248 XmlWriterSettings settings = new XmlWriterSettings();
2249 settings.IndentChars = " ";
2250 settings.Indent = true;
2251 settings.NewLineChars = Environment.NewLine;
2252 settings.Encoding = new System.Text.UTF8Encoding(false);
2253 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2255 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2257 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2258 serializer.WriteObject(xw, obj);
2263 public void SaveConfig()
2265 #region [ Skinパスの絶対パス→相対パス変換 ]
2266 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2267 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2268 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2270 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2271 // → 初期値として Default/ を設定する。
2272 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2275 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2276 // そのため、以下の処理を通すために、いったん絶対パスに変換
2277 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2279 ConfigIni.strSystemSkinSubfolderPath.Value =
2280 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2283 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2284 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2285 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2286 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2287 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2289 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2291 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2294 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2297 public void LoadConfig()
2299 string path = strEXEのあるフォルダ + "Config.xml";
2301 if (!File.Exists(path))
2305 if (File.Exists(path))
2307 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2308 if (ConfigIni == null)
2310 ConfigIni = new CConfigXml();
2313 // Skinパスの相対パスを、絶対パスに変換
2314 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2316 ConfigIni.strSystemSkinSubfolderPath.Value =
2317 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2322 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2324 public void UpdateCoordinates()
2326 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2329 if (File.Exists(coordXml))
2331 using (XmlReader xr = XmlReader.Create(coordXml))
2333 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2336 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2338 catch (SerializationException e)
2340 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2345 XmlWriterSettings settings = new XmlWriterSettings();
2346 settings.IndentChars = " ";
2347 settings.Indent = true;
2348 settings.NewLineChars = Environment.NewLine;
2349 settings.Encoding = new System.Text.UTF8Encoding( false );
2350 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2352 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2353 //ns.Add( String.Empty, String.Empty );
2355 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2356 //serializer.Serialize( sw, item, ns );
2359 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2360 serializer.WriteObject( xw, Coordinates );
2361 //serializer.WriteStartObject( xw, Coordinates );
2362 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2363 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2364 //serializer.WriteObjectContent( xw, Coordinates );
2365 //serializer.WriteEndObject( xw );
2369 if (File.Exists(coordXml))
2371 using (XmlReader xr = XmlReader.Create(coordXml))
2373 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2374 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2381 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2383 //public class MyXmlTextWriter : XmlTextWriter
2385 // private bool _ignoreAttr = false;
2387 // public MyXmlTextWriter( TextWriter w )
2390 // Debug.WriteLine( "create" );
2393 // public override string LookupPrefix( string ns )
2395 // Debug.WriteLine( "luprefix" );
2396 // return string.Empty;
2399 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2401 // Debug.WriteLine( "writestartattribute" );
2402 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2404 // Debug.WriteLine( "[!]" );
2405 // this._ignoreAttr = true;
2410 // public override void WriteEndAttribute()
2412 // if ( this._ignoreAttr )
2414 // this._ignoreAttr = false;
2417 // base.WriteEndAttribute();
2420 // public override void WriteString( string text )
2422 // Debug.WriteLine( "ws" );
2423 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2427 // base.WriteString( text );
2430 // public override void WriteStartElement( string prefix, string localName, string ns )
2432 // Debug.WriteLine( "wse" );
2433 // base.WriteStartElement( null, localName, null );
2437 public void ShowWindowTitleWithSoundType()
2440 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2442 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2444 base.Window.Text = strWindowTitle;
2445 if (!this.DTX2WAVmode.Enabled)
2447 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2453 private bool b終了処理完了済み;
2454 private static CDTX dtx;
2455 private List<CActivity> listトップレベルActivities;
2456 private int n進行描画の戻り値;
2457 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2458 private string strWindowTitle
2462 string strCPUmode = (Environment.Is64BitProcess) ? " [x64]" : " [x86]";
2464 if (DTXVmode.Enabled)
2466 return "DTXMViewer release " + VERSION + strCPUmode;
2468 else if (DTX2WAVmode.Enabled)
2470 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename) + strCPUmode;
2474 return "DTXMania .NET style release " + VERSION + strCPUmode;
2478 private CSound previewSound;
2479 private CMouseHideControl cMouseHideControl = null;
2481 private void t終了処理()
2483 if (!this.b終了処理完了済み)
2485 Trace.TraceInformation("----------------------");
2486 Trace.TraceInformation("■ アプリケーションの終了");
2488 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2490 #region [ 曲検索の終了処理 ]
2491 //---------------------
2492 if (actEnumSongs != null)
2494 Trace.TraceInformation("曲検索actの終了処理を行います。");
2498 actEnumSongs.On非活性化();
2499 actEnumSongs = null;
2500 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2504 Trace.TraceError(e.Message);
2505 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2512 //---------------------
2514 #region [ 現在のステージの終了処理 ]
2515 //---------------------
2516 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2518 Trace.TraceInformation("現在のステージを終了します。");
2523 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2530 //---------------------
2533 #region [ 選曲ステージの終了処理 ]
2537 #region [ プラグインの終了処理 ]
2538 //---------------------
2539 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2541 Trace.TraceInformation("すべてのプラグインを終了します。");
2545 foreach (STPlugin st in this.listプラグイン)
2547 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2548 st.plugin.OnUnmanagedリソースの解放();
2549 st.plugin.OnManagedリソースの解放();
2551 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2554 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2561 //---------------------
2563 #region [ 曲リストの終了処理 ]
2564 //---------------------
2565 if (Songs管理 != null)
2567 Trace.TraceInformation("曲リストの終了処理を行います。");
2572 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2574 catch (Exception exception)
2576 Trace.TraceError(exception.Message);
2577 Trace.TraceError("曲リストの終了処理に失敗しました。");
2585 //---------------------
2587 #region [ スキンの終了処理 ]
2588 //---------------------
2591 Trace.TraceInformation("スキンの終了処理を行います。");
2597 Trace.TraceInformation("スキンの終了処理を完了しました。");
2599 catch (Exception exception2)
2601 Trace.TraceError(exception2.Message);
2602 Trace.TraceError("スキンの終了処理に失敗しました。");
2609 //---------------------
2611 #region [ DirectSoundの終了処理 ]
2612 //---------------------
2613 if (Sound管理 != null)
2615 Trace.TraceInformation("DirectSound の終了処理を行います。");
2621 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2623 catch (Exception exception3)
2625 Trace.TraceError(exception3.Message);
2626 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2633 //---------------------
2635 #region [ パッドの終了処理 ]
2636 //---------------------
2639 Trace.TraceInformation("パッドの終了処理を行います。");
2644 Trace.TraceInformation("パッドの終了処理を完了しました。");
2646 catch (Exception exception4)
2648 Trace.TraceError(exception4.Message);
2649 Trace.TraceError("パッドの終了処理に失敗しました。");
2656 //---------------------
2658 #region [ DirectInput, MIDI入力の終了処理 ]
2659 //---------------------
2660 if (Input管理 != null)
2662 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2668 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2670 catch (Exception exception5)
2672 Trace.TraceError(exception5.Message);
2673 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2680 //---------------------
2682 #region [ 文字コンソールの終了処理 ]
2683 //---------------------
2684 if (act文字コンソール != null)
2686 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2690 act文字コンソール.On非活性化();
2692 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2694 catch (Exception exception6)
2696 Trace.TraceError(exception6.Message);
2697 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2704 //---------------------
2706 #region [ FPSカウンタの終了処理 ]
2707 //---------------------
2708 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2716 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2722 //---------------------
2724 #region [ タイマの終了処理 ]
2725 //---------------------
2726 Trace.TraceInformation("タイマの終了処理を行います。");
2734 Trace.TraceInformation("タイマの終了処理を完了しました。");
2738 Trace.TraceInformation("タイマは使用されていません。");
2745 //---------------------
2747 #region [ Config.iniの出力 ]
2748 //---------------------
2749 Trace.TraceInformation("Config.xml を出力します。");
2750 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2751 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2753 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2756 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2758 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2761 string str = strEXEのあるフォルダ + "Config.xml";
2765 if (DTXVmode.Enabled)
2767 DTXVmode.tUpdateConfigIni();
2768 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2770 else if (DTX2WAVmode.Enabled)
2772 DTX2WAVmode.tUpdateConfigIni();
2773 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2774 DTX2WAVmode.SendMessage2DTX2WAV("TERM");
2778 CDTXMania.Instance.SaveConfig();
2779 Trace.TraceInformation("保存しました。({0})", str);
2784 Trace.TraceError(e.Message);
2785 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2791 //---------------------
2793 #region [ DTXVmodeの終了処理 ]
2794 //---------------------
2795 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2799 if (DTXVmode != null)
2802 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2806 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2813 //---------------------
2815 #region [ DirectXの終了処理 ]
2816 //---------------------
2817 base.GraphicsDeviceManager.Dispose();
2818 //---------------------
2820 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2823 this.b終了処理完了済み = true;
2826 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2828 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2829 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2830 CScoreIni ini = new CScoreIni(strFilename);
2831 if (!File.Exists(strFilename))
2833 ini.stファイル.Title = DTX.TITLE;
2834 ini.stファイル.Name = DTX.strファイル名;
2835 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2836 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2838 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2839 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2840 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2841 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2843 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2844 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2845 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2846 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2848 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2849 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2850 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2851 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2854 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2855 isUpdated = CScoreIni.t更新条件を取得する();
2856 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2858 if (isUpdated.Drums)
2860 ini.stファイル.PlayCountDrums++;
2862 if (isUpdated.Guitar)
2864 ini.stファイル.PlayCountGuitar++;
2868 ini.stファイル.PlayCountBass++;
2870 ini.tヒストリを追加する(str新ヒストリ行);
2873 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2874 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2875 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2876 for (int j = 0; j < ini.stファイル.History.Length; j++)
2878 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2882 if (ConfigIni.bScoreIni)
2884 ini.t書き出し(strFilename);
2889 private void tガベージコレクションを実行する()
2891 // LOHに対するコンパクションを要求
2892 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
2894 GC.Collect(0, GCCollectionMode.Optimized, true );
2895 GC.WaitForPendingFinalizers();
2896 GC.Collect(0, GCCollectionMode.Forced, true );
2897 GC.WaitForPendingFinalizers();
2900 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default;
2902 private void tプラグイン検索と生成()
2904 this.listプラグイン = new List<STPlugin>();
2906 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2907 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2909 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2911 if (this.listプラグイン.Count > 0)
2912 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2915 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2917 var domain = (AppDomain)sender;
2919 foreach (var assembly in domain.GetAssemblies())
2921 if (assembly.FullName == args.Name)
2926 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2928 // 指定されたパスが存在しないとエラー
2929 if (!Directory.Exists(strプラグインフォルダパス))
2931 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2935 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2938 // (1) すべての *.dll について…
2939 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2940 foreach (string dllName in strDLLs)
2942 if (Path.GetExtension(dllName).ToLower() != ".dll")
2948 // (1-1) dll をアセンブリとして読み込む。
2949 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2951 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2952 foreach (Type t in asm.GetTypes())
2954 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2955 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2957 // (1-4) クラス名からインスタンスを作成する
2958 var st = new STPlugin()
2960 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2961 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2962 strアセンブリ簡易名 = asm.GetName().Name,
2963 Version = asm.GetName().Version,
2966 // (1-5) プラグインリストへ登録
2967 this.listプラグイン.Add(st);
2968 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2972 catch (System.Reflection.ReflectionTypeLoadException e)
2974 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2975 Trace.TraceInformation(e.ToString());
2976 Trace.TraceInformation(e.Message);
2978 StringBuilder sb = new StringBuilder();
2979 foreach (Exception exSub in e.LoaderExceptions)
2981 sb.AppendLine(exSub.Message);
2982 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2983 if (exFileNotFound != null)
2985 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2987 sb.AppendLine("Fusion Log:");
2988 sb.AppendLine(exFileNotFound.FusionLog);
2993 string errorMessage = sb.ToString();
2994 //Display or log the error based on your application.
2995 Trace.TraceInformation(errorMessage);
3000 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
3001 Trace.TraceInformation(e.ToString());
3002 Trace.TraceInformation(e.Message);
3006 // (2) サブフォルダがあれば再帰する
3007 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
3008 foreach (string dir in strDirs)
3009 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
3012 #region [ Windowイベント処理 ]
3013 private void Window_ApplicationActivated( object sender, EventArgs e )
3015 this.bApplicationActive = true;
3017 private void Window_ApplicationDeactivated(object sender, EventArgs e)
3019 this.bApplicationActive = false;
3020 if (cMouseHideControl != null) cMouseHideControl.Show();
3022 private void Window_KeyDown(object sender, KeyEventArgs e)
3024 if (e.KeyCode == Keys.Menu)
3027 e.SuppressKeyPress = true;
3029 else if ((e.KeyCode == Keys.Return) && e.Alt)
3031 if (ConfigIni != null)
3033 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3034 this.t全画面_ウィンドウモード切り替え();
3037 e.SuppressKeyPress = true;
3041 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
3043 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
3045 if( (int) captureCode > 0 &&
3046 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
3048 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
3049 string strFullPath =
3050 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
3051 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
3052 SaveResultScreen( strFullPath );
3057 private void Window_MouseUp(object sender, MouseEventArgs e)
3062 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
3064 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
3066 ConfigIni.bウィンドウモード = false;
3067 this.t全画面_ウィンドウモード切り替え();
3070 private void Window_MouseMove(object sender, MouseEventArgs e)
3072 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
3075 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
3077 if (ConfigIni.bウィンドウモード)
3079 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
3080 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
3083 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
3084 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
3088 //Stopwatch sw = new Stopwatch();
3089 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
3093 private class CMouseHideControl
3095 private Point lastPosition;
3096 private CCounter ccMouseShow;
3097 private bool bマウスカーソル表示中;
3102 public CMouseHideControl()
3104 ccMouseShow = new CCounter();
3105 lastPosition = Cursor.Position;
3112 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3115 public void tHideCursorIfNeed()
3118 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3119 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3121 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3122 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
3130 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3132 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3133 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3135 Point currentPosition = Cursor.Position;
3136 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3137 if (lastPosition != currentPosition)
3139 //Trace.TraceInformation("移動発生");
3140 lastPosition = currentPosition;
3155 bマウスカーソル表示中 = false;
3162 private void PutSystemLog()
3164 System.Management.ManagementClass mc =
3165 new System.Management.ManagementClass("Win32_Processor");
3166 System.Management.ManagementObjectCollection moc = mc.GetInstances();
3167 foreach (System.Management.ManagementObject mo in moc)
3169 Trace.TraceInformation("-------------------------");
3170 Trace.TraceInformation("CPU Information:");
3171 //Trace.TraceInformation("DeviceID = {0}", mo["DeviceID"]);
3172 Trace.TraceInformation("Name = {0}", mo["Name"]);
3173 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
3174 Trace.TraceInformation("L2CacheSize = {0}KB", mo["L2CacheSize"]);
3175 Trace.TraceInformation("L3CacheSize = {0}KB", mo["L3CacheSize"]);
3176 Trace.TraceInformation("NumberOfCores = {0}", mo["NumberOfCores"]);
3177 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
3182 //System.Management.ManagementClass mc =
3183 // new System.Management.ManagementClass("Win32_OperatingSystem");
3184 //System.Management.ManagementObjectCollection moc = mc.GetInstances();
3186 new System.Management.ManagementClass("Win32_OperatingSystem");
3187 moc = mc.GetInstances();
3188 foreach (System.Management.ManagementObject mo in moc)
3190 Trace.TraceInformation("-------------------------");
3191 Trace.TraceInformation("OS Information:");
3192 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
3193 Trace.TraceInformation("OS: " + mo["Caption"]);
3194 //バージョン(Windows 8.1では、「6.3.9600」)
3195 Trace.TraceInformation("Version: " + mo["Version"]);
3196 //ビルド番号(Windows 8.1では「9600」)
3197 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
3199 //サービスパック(Windows 8.1ではNULL)
3200 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
3202 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
3204 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
3206 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
3211 Trace.TraceInformation("-------------------------");
3212 Trace.TraceInformation("General Environment Information:");
3213 //Trace.TraceInformation("OS Version: " + Environment.OSVersion); // fake version will be returned (due to the lack of manifest settings)
3214 //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
3215 Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
3216 Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
3218 var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
3219 Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
3220 Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
3221 Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
3222 Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
3223 //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
3225 mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
3226 moc = mc.GetInstances();
3227 Trace.TraceInformation("-------------------------");
3228 Trace.TraceInformation("Physical Memory Information:");
3229 foreach (System.Management.ManagementObject mo in moc)
3231 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
3236 mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
3237 moc = mc.GetInstances();
3238 foreach (System.Management.ManagementObject mo in moc)
3240 Trace.TraceInformation("-------------------------");
3241 Trace.TraceInformation("Display Adapter Information:");
3242 Trace.TraceInformation("Name: " + mo["Name"]);
3243 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
3244 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
3245 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
3246 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3251 mc = new System.Management.ManagementClass("Win32_VideoController");
3252 moc = mc.GetInstances();
3253 foreach (System.Management.ManagementObject mo in moc)
3255 Trace.TraceInformation("-------------------------");
3256 Trace.TraceInformation("Video Controller Information:");
3257 Trace.TraceInformation("Description: " + mo["Description"]);
3258 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3259 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3264 mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3265 moc = mc.GetInstances();
3266 foreach (System.Management.ManagementObject mo in moc)
3268 Trace.TraceInformation("-------------------------");
3269 Trace.TraceInformation("Display Information:");
3270 Trace.TraceInformation("Description: " + mo["Description"]);
3271 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3272 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3273 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3274 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3279 mc = new System.Management.ManagementClass("Win32_SoundDevice");
3280 moc = mc.GetInstances();
3281 foreach (System.Management.ManagementObject mo in moc)
3283 Trace.TraceInformation("-------------------------");
3284 Trace.TraceInformation("Audio Information:");
3285 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3286 //Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3287 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3289 foreach (PropertyData property in mo.Properties)
3291 Trace.TraceInformation("{0}:{1}", property.Name, property.Value);
3297 Trace.TraceInformation("----------------------");
3298 Trace.TraceInformation("DTXMania settings:");
3299 Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3300 Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3301 Trace.TraceInformation("----------------------");