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 = "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();
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("■ アプリケーションの初期化");
266 CPutSystemLog.PutSystemLog();
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);
278 #region [ DTXVmodeクラス, DTX2WAVmodeクラス, CommandParseクラス の初期化 ]
279 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
283 DTXVmode = new CDTXVmode();
284 DTXVmode.Enabled = false;
285 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
287 DTX2WAVmode = new CDTX2WAVmode();
288 //Trace.TraceInformation( "DTX2WAVモードの初期化を完了しました。" );
290 CommandParse = new CCommandParse();
291 //Trace.TraceInformation( "CommandParseの初期化を完了しました。" );
298 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewer/DTX2WAVとしての起動 ]
300 strコンパクトモードファイル = "";
301 string[] commandLineArgs = Environment.GetCommandLineArgs();
302 if ((commandLineArgs != null) && (commandLineArgs.Length > 1))
307 for (int i = 1; i < commandLineArgs.Length; i++)
311 arg += " " + "\"" + commandLineArgs[i] + "\"";
315 arg += commandLineArgs[i];
318 CommandParse.ParseArguments(arg, ref DTXVmode, ref DTX2WAVmode);
319 if (DTXVmode.Enabled)
321 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
322 strコンパクトモードファイル = DTXVmode.filename;
323 switch (DTXVmode.soundDeviceType) // サウンド再生方式の設定
325 case ESoundDeviceType.DirectSound:
326 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.DSound;
328 case ESoundDeviceType.ExclusiveWASAPI:
329 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
331 case ESoundDeviceType.SharedWASAPI:
332 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
334 case ESoundDeviceType.ASIO:
335 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.ASIO;
336 ConfigIni.strASIODevice.Index = DTXVmode.nASIOdevice;
340 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
341 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
344 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
348 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
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;
358 else if (DTX2WAVmode.Enabled)
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++)
368 FDK.CSound管理.nMixerVolume[ i ] = DTX2WAVmode.nMixerVolume[ i ];
370 ConfigIni.nMasterVolume.Value = DTX2WAVmode.nMixerVolume[(int)FDK.CSound.EInstType.Unknown]; // [5](Unknown)のところにMasterVolumeが入ってくるので注意
371 // CSound管理.nMixerVolume[5]は、結局ここからは変更しないため、
376 // 本体プロセスの優先度を少し上げる (最小化状態で動作させると、処理性能が落ちるようなので
377 // → ほとんど効果がなかったので止めます
378 //Process thisProcess = System.Diagnostics.Process.GetCurrentProcess();
379 //thisProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
381 // エンコーダーのパス設定 (=DLLフォルダ)
382 FDK.CSound管理.strEncoderPath = Path.Combine(strEXEのあるフォルダ, "DLL");
384 CDTXMania.instance.ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
385 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI.Value = false;
387 CDTXMania.instance.ConfigIni.bVSyncWait.Value = false;
388 CDTXMania.instance.ConfigIni.bTimeStretch.Value = false;
389 CDTXMania.instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
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;
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;
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;
422 CDTXMania.instance.ConfigIni.bFillin.Value = false;
423 CDTXMania.instance.ConfigIni.bAudience.Value = false;
425 CDTXMania.instance.ConfigIni.bStoicMode.Value = false;
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;
432 CDTXMania.instance.ConfigIni.eDark.Value = EDark.Full;
435 CDTXMania.instance.ConfigIni.nPolyphonicSounds.Value = 4;
438 CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
441 CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
442 CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
443 CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
446 CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
447 CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
450 //CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100; // DTX2WAV側から設定するので、ここでは触らない
453 CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
456 CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
457 CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
458 CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
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;
470 //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
471 CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
474 CDTXMania.instance.ConfigIni.bBGA.Value = false;
475 CDTXMania.instance.ConfigIni.bAVI.Value = false;
478 CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
479 CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
482 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Drums.Value = false;
483 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Guitar.Value = false;
484 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Bass.Value = false;
486 // パッド入力等、基本操作の無効化 (ESCを除く)
487 //CDTXMania.Instance.ConfigIni.KeyAssign[][];
493 strコンパクトモードファイル = commandLineArgs[1];
496 if (!File.Exists(strコンパクトモードファイル)) // #32985 2014.1.23 yyagi
498 Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
500 Environment.Exit(-1);
502 if (strコンパクトモードファイル == "") // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
504 Environment.Exit(-1);
508 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
512 if (DTXVmode.Enabled)
514 Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
516 else if (DTX2WAVmode.Enabled)
518 Trace.TraceInformation("DTX2WAVモードで起動します。[{0}]", strコンパクトモードファイル);
519 DTX2WAVmode.SendMessage2DTX2WAV("BOOT");
523 Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
528 Trace.TraceInformation("通常モードで起動します。");
532 #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
533 CPowerPlan.BackupCurrentPowerPlan();
534 if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
536 CPowerPlan.ChangeHighPerformance();
540 #region [ Input管理 の初期化 ]
541 Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
545 bool bUseMIDIIn = !DTXVmode.Enabled;
546 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
548 // If the users uses MIDI2.0-USB cable, then warn it
549 if (bUseMIDIIn && CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value)
551 foreach (IInputDevice device in Input管理.list入力デバイス)
553 if ((device.e入力デバイス種別 == E入力デバイス種別.MidiIn) && (device.strDeviceName == "USB2.0-MIDI"))
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)
559 CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value = false;
567 foreach (IInputDevice device in Input管理.list入力デバイス)
569 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
572 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
576 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
579 foreach (IInputDevice device2 in Input管理.list入力デバイス)
581 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
583 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
585 if (device2.GUID.Equals(pair.Value))
587 ((CInputJoystick)device2).SetID(pair.Key);
594 Trace.TraceInformation("DirectInput の初期化を完了しました。");
596 catch (Exception exception2)
598 Trace.TraceError(exception2.Message);
599 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
601 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
602 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
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);
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
626 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
627 #if !WindowedFullscreen
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);
649 #region [ Direct3D9Exを使うかどうか判定 ]
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;
658 settings.Windowed = ConfigIni.bウィンドウモード;
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;
671 base.GraphicsDeviceManager.ChangeDevice(settings);
673 catch (DeviceCreationException e)
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);
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());
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全画面_ウィンドウモード切り替え();
698 actFlushGPU = new CActFlushGPU();
701 if (DTX2WAVmode.Enabled)
703 this.Window.WindowState = FormWindowState.Minimized; //DTX2WAVモード時は自動的に最小化
708 #region [ Skin の初期化 ]
709 Trace.TraceInformation("スキンの初期化を行います。");
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("スキンの初期化を完了しました。");
722 Trace.TraceInformation("スキンの初期化に失敗しました。");
730 #region [ Skin配下にある言語リソースの確認と初期化 ]
731 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
735 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
736 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
738 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
741 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
745 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
757 #region [ Timer の初期化 ]
758 Trace.TraceInformation("タイマの初期化を行います。");
762 Timer = new CTimer(CTimer.E種別.MultiMedia);
763 Trace.TraceInformation("タイマの初期化を完了しました。");
771 #region [ マウス消去用のクラスを初期化 ]
772 cMouseHideControl = new CMouseHideControl();
775 #region [ FPS カウンタの初期化 ]
776 Trace.TraceInformation("FPSカウンタの初期化を行います。");
781 Trace.TraceInformation("FPSカウンタを生成しました。");
789 #region [ act文字コンソールの初期化 ]
790 Trace.TraceInformation("文字コンソールの初期化を行います。");
794 act文字コンソール = new C文字コンソール();
795 Trace.TraceInformation("文字コンソールを生成しました。");
797 Trace.TraceInformation("文字コンソールを活性化しました。");
798 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
800 catch (Exception exception)
802 Trace.TraceError(exception.Message);
803 Trace.TraceError("文字コンソールの初期化に失敗しました。");
812 Trace.TraceInformation("パッドの初期化を行います。");
817 Trace.TraceInformation("パッドの初期化を完了しました。");
819 catch (Exception exception3)
821 Trace.TraceError(exception3.Message);
822 Trace.TraceError("パッドの初期化に失敗しました。");
830 #region [ Sound管理 の初期化 ]
831 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
835 ESoundDeviceType soundDeviceType;
836 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
838 case ESoundDeviceTypeForConfig.DSound:
839 soundDeviceType = ESoundDeviceType.DirectSound;
841 case ESoundDeviceTypeForConfig.ASIO:
842 soundDeviceType = ESoundDeviceType.ASIO;
844 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
845 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
847 case ESoundDeviceTypeForConfig.WASAPI_Shared:
848 soundDeviceType = ESoundDeviceType.SharedWASAPI;
851 soundDeviceType = ESoundDeviceType.Unknown;
854 Sound管理 = new CSound管理(base.Window.Handle,
856 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
857 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
859 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
860 CDTXMania.Instance.ConfigIni.bUseOSTimer
862 //Sound管理 = FDK.CSound管理.Instance;
863 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
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;
871 string strDefaultSoundDeviceBusType = CSound管理.strDefaultDeviceBusType;
872 Trace.TraceInformation($"Bus type of the default sound device = {strDefaultSoundDeviceBusType}");
874 if (strDefaultSoundDeviceBusType.ToUpper().Equals("USB"))
876 if (CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value)
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)
882 CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value = false;
887 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
889 catch (NullReferenceException) // No audio output found
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);
898 Trace.TraceError(e.Message);
907 #region [ Songs管理 の初期化 ]
908 //---------------------
909 Trace.TraceInformation("曲リストの初期化を行います。");
913 Songs管理 = new CSongs管理();
914 // Songs管理_裏読 = new CSongs管理();
915 EnumSongs = new CEnumSongs();
916 actEnumSongs = new CActEnumSongs();
917 Trace.TraceInformation("曲リストの初期化を完了しました。");
921 Trace.TraceError(e.Message);
922 Trace.TraceError("曲リストの初期化に失敗しました。");
928 //---------------------
931 #region [ CAvi の初期化 ]
935 #region [ Random の初期化 ]
936 Random = new Random((int)Timer.nシステム時刻);
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終了();
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);
967 #region [ プラグインの検索と生成 ]
968 PluginHost = new CPluginHost();
970 Trace.TraceInformation("プラグインの検索と生成を行います。");
975 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
983 #region [ プラグインの初期化 ]
984 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
986 Trace.TraceInformation("プラグインの初期化を行います。");
990 foreach (STPlugin st in this.listプラグイン)
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のあるフォルダ);
998 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
1002 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
1013 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
1015 #region [ 最初のステージの起動 ]
1016 Trace.TraceInformation("----------------------");
1017 Trace.TraceInformation("■ 起動");
1019 if (CDTXMania.Instance.bコンパクトモード)
1021 r現在のステージ = stage曲読み込み;
1028 this.Window.Activate(); // #41300 workaround to avoid SharpDX exception
1033 public void t全画面_ウィンドウモード切り替え()
1035 #if WindowedFullscreen
1036 if (ConfigIni != null)
1038 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
1039 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
1042 #if !WindowedFullscreen
1043 settings.Windowed = ConfigIni.bウィンドウモード;
1045 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
1047 currentClientSize = this.Window.ClientSize;
1048 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
1049 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
1050 // FDK.CTaskBar.ShowTaskBar( false );
1052 #if !WindowedFullscreen
1053 base.GraphicsDeviceManager.ChangeDevice( settings );
1055 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
1057 #if WindowedFullscreen
1058 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
1059 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
1060 // instead of using fullscreen mode.
1061 Instance.Window.WindowState = FormWindowState.Normal;
1062 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1063 Instance.Window.WindowState = FormWindowState.Normal;
1065 base.Window.ClientSize =
1066 new Size(currentClientSize.Width, currentClientSize.Height);
1067 // FDK.CTaskBar.ShowTaskBar( true );
1069 #if WindowedFullscreen
1072 Instance.Window.WindowState = FormWindowState.Normal;
1073 Instance.Window.FormBorderStyle = FormBorderStyle.None;
1074 Instance.Window.WindowState = FormWindowState.Maximized;
1076 if (cMouseHideControl != null)
1078 if (ConfigIni.bウィンドウモード)
1080 cMouseHideControl.Show();
1084 cMouseHideControl.Hide();
1091 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1093 /// リザルト画像のキャプチャと保存。
1095 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1096 public bool SaveResultScreen(string strFullPath)
1098 string strSavePath = Path.GetDirectoryName(strFullPath);
1099 if (!Directory.Exists(strSavePath))
1103 Directory.CreateDirectory(strSavePath);
1111 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1112 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1114 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1122 protected override void Initialize()
1126 //swlist1 = new List<int>( 8192 );
1127 //swlist2 = new List<int>( 8192 );
1128 //swlist3 = new List<int>( 8192 );
1129 //swlist4 = new List<int>( 8192 );
1130 //swlist5 = new List<int>( 8192 );
1131 if (this.listトップレベルActivities != null)
1133 foreach (CActivity activity in this.listトップレベルActivities)
1134 activity.OnManagedリソースの作成();
1137 foreach (STPlugin st in this.listプラグイン)
1139 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1140 st.plugin.OnManagedリソースの作成();
1141 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1143 #if GPUFlushAfterPresent
1144 FrameEnd += dtxmania_FrameEnd;
1147 #if GPUFlushAfterPresent
1148 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1149 { // → Present()直後にGPUをFlushする
1150 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1151 actFlushGPU.On進行描画(); // Flush GPU
1154 protected override void LoadContent()
1156 if (cMouseHideControl != null)
1158 if (ConfigIni.bウィンドウモード)
1160 cMouseHideControl.Show();
1164 cMouseHideControl.Hide();
1167 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)));
1168 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1169 this.Device.SetRenderState(RenderState.Lighting, false);
1170 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1171 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1172 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1173 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1175 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1176 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1177 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1179 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1180 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1181 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1182 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1183 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1184 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1185 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1187 if (this.listトップレベルActivities != null)
1189 foreach (CActivity activity in this.listトップレベルActivities)
1190 activity.OnUnmanagedリソースの作成();
1193 foreach (STPlugin st in this.listプラグイン)
1195 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1196 st.plugin.OnUnmanagedリソースの作成();
1197 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1200 protected override void UnloadContent()
1202 if (this.listトップレベルActivities != null)
1204 foreach (CActivity activity in this.listトップレベルActivities)
1205 activity.OnUnmanagedリソースの解放();
1208 foreach (STPlugin st in this.listプラグイン)
1210 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1211 st.plugin.OnUnmanagedリソースの解放();
1212 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1215 protected override void OnExiting(EventArgs e)
1217 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1221 protected override void Update(GameTime gameTime)
1224 protected override void Draw(GameTime gameTime)
1226 if (Sound管理 == null)
1230 //Sound管理.t再生中の処理をする();
1234 if (CSound管理.rc演奏用タイマ != null)
1235 CSound管理.rc演奏用タイマ.t更新();
1237 if (Input管理 != null)
1238 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1243 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1244 // Pad.st検知したデバイス.Clear();
1246 if (this.Device == null)
1249 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1250 CPowerManagement.tDisableMonitorSuspend();
1252 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1254 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1256 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1260 #region [ DTXCreator/DTX2WAVからの指示 ]
1261 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1263 string strMes = this.Window.strMessage;
1264 this.Window.IsReceivedMessage = false;
1267 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1269 if (DTXVmode.Enabled)
1272 strコンパクトモードファイル = DTXVmode.filename;
1273 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1276 string strPreviewFilename = DTXVmode.previewFilename;
1277 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1280 if (this.previewSound != null)
1282 this.previewSound.tサウンドを停止する();
1283 this.previewSound.Dispose();
1284 this.previewSound = null;
1286 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1287 this.previewSound.n音量 = DTXVmode.previewVolume;
1288 this.previewSound.n位置 = DTXVmode.previewPan;
1289 this.previewSound.t再生を開始する();
1290 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1294 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1295 if (this.previewSound != null)
1297 this.previewSound.Dispose();
1299 this.previewSound = null;
1303 if (DTX2WAVmode.Enabled)
1305 if (DTX2WAVmode.Command == CDTX2WAVmode.ECommand.Cancel)
1307 Trace.TraceInformation("録音のCancelコマンドをDTXMania本体が受信しました。");
1308 //Microsoft.VisualBasic.Interaction.AppActivate("メモ帳");
1309 //SendKeys.Send("{ESC}");
1310 //SendKeys.SendWait("%{F4}");
1311 //Application.Exit();
1312 if (DTX != null) // 曲読み込みの前に録音Cancelされると、DTXがnullのままここにきてでGPFとなる→nullチェック追加
1319 //Environment.ExitCode = 10010; // この組み合わせではダメ、返り値が反映されない
1320 //base.Window.Close();
1321 Environment.Exit(10010); // このやり方ならばOK
1328 this.Device.BeginScene();
1329 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1331 if (r現在のステージ != null)
1333 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1335 #region [ プラグインの進行描画 ]
1336 //---------------------
1337 foreach (STPlugin sp in this.listプラグイン)
1339 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1341 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1342 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1344 sp.plugin.On進行描画(null, null);
1346 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1348 //---------------------
1351 #region [ DTX2WAVモード時、ステージが変わるたびに、そのことをDTX2WAVアプリ側に通知する ]
1352 if (DTX2WAVmode.Enabled && r現在のステージ != r1フレーム前のステージ)
1354 r1フレーム前のステージ = r現在のステージ;
1355 //Trace.TraceInformation("Stage変更 to : " + r現在のステージ.eステージID.ToString());
1356 switch (r現在のステージ.eステージID)
1358 case CStage.Eステージ.曲読み込み:
1359 DTX2WAVmode.SendMessage2DTX2WAV("LOAD");
1361 case CStage.Eステージ.演奏:
1362 DTX2WAVmode.SendMessage2DTX2WAV("PLAY");
1370 CScoreIni scoreIni = null;
1372 //if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1373 if (!CDTXMania.instance.ConfigIni.bEnumerateSongsInBoot) // #40772 2020.10.12 yyagi
1375 // → songs.db等の書き込み時だと音切れするっぽい
1376 actEnumSongs.On非活性化();
1377 EnumSongs.SongListEnumCompletelyDone();
1378 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1380 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1381 if (!CDTXMania.Instance.bコンパクトモード)
1383 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1385 switch (r現在のステージ.eステージID)
1387 case CStage.Eステージ.タイトル:
1388 case CStage.Eステージ.コンフィグ:
1389 case CStage.Eステージ.選曲:
1390 case CStage.Eステージ.曲読み込み:
1391 if (EnumSongs != null)
1393 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1394 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1395 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1396 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1397 !EnumSongs.IsSongListEnumStarted)
1399 actEnumSongs.On活性化();
1400 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1401 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1402 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1403 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1405 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1410 #region [ 曲検索の中断と再開 ]
1411 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1413 switch (this.n進行描画の戻り値)
1416 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1417 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1419 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1420 EnumSongs.IsSlowdown = false;
1424 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1425 EnumSongs.IsSlowdown = true;
1427 actEnumSongs.On活性化();
1431 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1432 actEnumSongs.On非活性化();
1438 #region [ 曲探索中断待ち待機 ]
1439 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1440 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1442 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1446 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1447 // CStage選曲.On活性化() に回した方がいいかな?
1448 if (EnumSongs.IsSongListEnumerated)
1450 actEnumSongs.On非活性化();
1451 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1453 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1454 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1455 EnumSongs.SongListEnumCompletelyDone();
1463 switch (r現在のステージ.eステージID)
1465 case CStage.Eステージ.何もしない:
1468 case CStage.Eステージ.起動:
1470 //-----------------------------
1471 if (this.n進行描画の戻り値 != 0)
1476 Trace.TraceInformation("----------------------");
1477 Trace.TraceInformation("■ タイトル");
1479 r直前のステージ = r現在のステージ;
1480 r現在のステージ = stageタイトル;
1485 Trace.TraceInformation("----------------------");
1486 Trace.TraceInformation("■ 曲読み込み");
1488 r直前のステージ = r現在のステージ;
1489 r現在のステージ = stage曲読み込み;
1492 foreach (STPlugin pg in this.listプラグイン)
1494 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1495 pg.plugin.Onステージ変更();
1496 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1499 this.tガベージコレクションを実行する();
1501 //-----------------------------
1505 case CStage.Eステージ.タイトル:
1507 //-----------------------------
1508 switch (this.n進行描画の戻り値)
1510 case (int)CStageタイトル.E戻り値.GAMESTART:
1512 //-----------------------------
1514 Trace.TraceInformation("----------------------");
1515 Trace.TraceInformation("■ 選曲");
1517 r直前のステージ = r現在のステージ;
1519 //-----------------------------
1523 #region [ OPTION: 廃止済 ]
1524 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1526 // //-----------------------------
1527 // r現在のステージ.On非活性化();
1528 // Trace.TraceInformation( "----------------------" );
1529 // Trace.TraceInformation( "■ オプション" );
1530 // stageオプション.On活性化();
1531 // r直前のステージ = r現在のステージ;
1532 // r現在のステージ = stageオプション;
1533 // //-----------------------------
1538 case (int)CStageタイトル.E戻り値.CONFIG:
1540 //-----------------------------
1542 Trace.TraceInformation("----------------------");
1543 Trace.TraceInformation("■ コンフィグ");
1545 r直前のステージ = r現在のステージ;
1546 r現在のステージ = stageコンフィグ;
1547 //-----------------------------
1551 case (int)CStageタイトル.E戻り値.EXIT:
1553 //-----------------------------
1555 Trace.TraceInformation("----------------------");
1556 Trace.TraceInformation("■ 終了");
1558 r直前のステージ = r現在のステージ;
1560 //-----------------------------
1565 foreach (STPlugin pg in this.listプラグイン)
1567 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1568 pg.plugin.Onステージ変更();
1569 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1572 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1573 //-----------------------------
1577 case CStage.Eステージ.コンフィグ:
1579 //-----------------------------
1580 if (this.n進行描画の戻り値 != 0)
1582 switch (r直前のステージ.eステージID)
1584 case CStage.Eステージ.タイトル:
1586 //-----------------------------
1588 Trace.TraceInformation("----------------------");
1589 Trace.TraceInformation("■ タイトル");
1591 r直前のステージ = r現在のステージ;
1592 r現在のステージ = stageタイトル;
1594 foreach (STPlugin pg in this.listプラグイン)
1596 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1597 pg.plugin.Onステージ変更();
1598 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1601 this.tガベージコレクションを実行する();
1603 //-----------------------------
1606 case CStage.Eステージ.選曲:
1608 //-----------------------------
1610 Trace.TraceInformation("----------------------");
1611 Trace.TraceInformation("■ 選曲");
1613 r直前のステージ = r現在のステージ;
1616 foreach (STPlugin pg in this.listプラグイン)
1618 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1619 pg.plugin.Onステージ変更();
1620 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1623 this.tガベージコレクションを実行する();
1625 //-----------------------------
1629 //-----------------------------
1633 case CStage.Eステージ.選曲:
1635 //-----------------------------
1636 switch (this.n進行描画の戻り値)
1638 case (int)CStage選曲.E戻り値.タイトルに戻る:
1640 //-----------------------------
1642 Trace.TraceInformation("----------------------");
1643 Trace.TraceInformation("■ タイトル");
1645 r直前のステージ = r現在のステージ;
1646 r現在のステージ = stageタイトル;
1648 foreach (STPlugin pg in this.listプラグイン)
1650 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1651 pg.plugin.Onステージ変更();
1652 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1655 this.tガベージコレクションを実行する();
1657 //-----------------------------
1660 case (int)CStage選曲.E戻り値.選曲した:
1662 //-----------------------------
1664 Trace.TraceInformation("----------------------");
1665 Trace.TraceInformation("■ 曲読み込み");
1667 r直前のステージ = r現在のステージ;
1668 r現在のステージ = stage曲読み込み;
1670 foreach (STPlugin pg in this.listプラグイン)
1672 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1673 pg.plugin.Onステージ変更();
1674 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1677 this.tガベージコレクションを実行する();
1679 //-----------------------------
1682 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1684 //-----------------------------
1686 Trace.TraceInformation("----------------------");
1687 Trace.TraceInformation("■ コンフィグ");
1689 r直前のステージ = r現在のステージ;
1690 r現在のステージ = stageコンフィグ;
1692 foreach (STPlugin pg in this.listプラグイン)
1694 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1695 pg.plugin.Onステージ変更();
1696 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1699 this.tガベージコレクションを実行する();
1701 //-----------------------------
1704 case (int)CStage選曲.E戻り値.スキン変更:
1707 //-----------------------------
1709 Trace.TraceInformation("----------------------");
1710 Trace.TraceInformation("■ スキン切り替え");
1711 stageChangeSkin.On活性化();
1712 r直前のステージ = r現在のステージ;
1713 r現在のステージ = stageChangeSkin;
1715 //-----------------------------
1718 //-----------------------------
1722 case CStage.Eステージ.曲読み込み:
1724 //-----------------------------
1725 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1726 if (this.n進行描画の戻り値 != 0)
1728 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1730 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1731 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1735 Trace.TraceInformation("曲の読み込みを中止しました。");
1736 this.tガベージコレクションを実行する();
1737 Trace.TraceInformation("----------------------");
1738 Trace.TraceInformation("■ 選曲");
1740 r直前のステージ = r現在のステージ;
1742 foreach (STPlugin pg in this.listプラグイン)
1744 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1745 pg.plugin.Onステージ変更();
1746 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1752 Trace.TraceInformation("----------------------");
1753 Trace.TraceInformation("■ 演奏(ドラム画面)");
1754 r直前のステージ = r現在のステージ;
1755 r現在のステージ = stage演奏画面;
1757 foreach (STPlugin pg in this.listプラグイン)
1759 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1760 pg.plugin.Onステージ変更();
1761 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1764 this.tガベージコレクションを実行する();
1766 //-----------------------------
1770 case CStage.Eステージ.演奏:
1772 //-----------------------------
1773 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1774 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1775 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1776 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1777 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1779 //swlist1.Add( Convert.ToInt32(n1) );
1780 //swlist2.Add( Convert.ToInt32(n2) );
1781 //swlist3.Add( Convert.ToInt32( n3 ) );
1782 //swlist4.Add( Convert.ToInt32( n4 ) );
1783 //swlist5.Add( Convert.ToInt32( n5 ) );
1785 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1786 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1788 DTXVmode.Refreshed = false;
1790 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1792 CDTXMania.Instance.stage演奏画面.t停止();
1794 if (previewSound != null)
1796 this.previewSound.tサウンドを停止する();
1797 this.previewSound.Dispose();
1798 this.previewSound = null;
1803 // for ( int i = 0; i < swlist1.Count; i++ )
1805 // int d1 = swlist1[ i ];
1806 // int d2 = swlist2[ i ];
1807 // int d3 = swlist3[ i ];
1808 // int d4 = swlist4[ i ];
1809 // int d5 = swlist5[ i ];
1811 // int dif = d1 - lastd;
1813 // if ( 16 <= dif && dif <= 17 )
1820 // 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 );
1832 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1834 if (DTXVmode.NeedReload)
1836 CDTXMania.Instance.stage演奏画面.t再読込();
1837 if (DTXVmode.GRmode)
1839 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1843 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1845 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1846 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1847 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1849 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1850 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1855 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1861 switch (this.n進行描画の戻り値)
1863 case (int)E演奏画面の戻り値.再読込_再演奏:
1864 #region [ DTXファイルを再読み込みして、再演奏 ]
1869 r直前のステージ = r現在のステージ;
1870 r現在のステージ = stage曲読み込み;
1871 this.tガベージコレクションを実行する();
1875 //case (int) E演奏画面の戻り値.再演奏:
1876 #region [ 再読み込み無しで、再演奏 ]
1880 case (int)E演奏画面の戻り値.継続:
1883 case (int)E演奏画面の戻り値.演奏中断:
1885 //-----------------------------
1886 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1887 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1889 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1894 //for (int i = 0; i < swlist1.Count; i++)
1896 // int d1 = swlist1[ i ];
1897 // int d2 = swlist2[ i ];
1898 // int d3 = swlist3[ i ];
1899 // int d4 = swlist4[ i ];
1901 // int dif = d1 - lastd;
1903 // if ( 16 <= dif && dif <= 17 )
1910 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1919 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1920 //---------------------
1921 foreach (STPlugin pg in this.listプラグイン)
1923 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1924 pg.plugin.On演奏キャンセル(scoreIni);
1925 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1927 //---------------------
1933 if (DTX2WAVmode.Enabled)
1935 Environment.Exit(0);
1939 base.Window.Close();
1943 Trace.TraceInformation("----------------------");
1944 Trace.TraceInformation("■ 選曲");
1946 r直前のステージ = r現在のステージ;
1949 #region [ プラグイン Onステージ変更() の呼び出し ]
1950 //---------------------
1951 foreach (STPlugin pg in this.listプラグイン)
1953 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1954 pg.plugin.Onステージ変更();
1955 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1957 //---------------------
1960 this.tガベージコレクションを実行する();
1963 //-----------------------------
1966 case (int)E演奏画面の戻り値.ステージ失敗:
1967 #region [ 演奏失敗(StageFailed) ]
1968 //-----------------------------
1969 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1971 #region [ プラグイン On演奏失敗() の呼び出し ]
1972 //---------------------
1973 foreach (STPlugin pg in this.listプラグイン)
1975 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1976 pg.plugin.On演奏失敗(scoreIni);
1977 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1979 //---------------------
1987 base.Window.Close();
1991 Trace.TraceInformation("----------------------");
1992 Trace.TraceInformation("■ 選曲");
1994 r直前のステージ = r現在のステージ;
1997 #region [ プラグイン Onステージ変更() の呼び出し ]
1998 //---------------------
1999 foreach (STPlugin pg in this.listプラグイン)
2001 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2002 pg.plugin.Onステージ変更();
2003 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2005 //---------------------
2008 this.tガベージコレクションを実行する();
2011 //-----------------------------
2014 case (int)E演奏画面の戻り値.ステージクリア:
2016 //-----------------------------
2017 STDGBSValue<CScoreIni.C演奏記録> record;
2018 record = stage演奏画面.Record;
2020 double playskill = 0.0;
2022 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
2024 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
2026 playskill = record[inst].db演奏型スキル値;
2030 string str = "Cleared";
2031 switch (CScoreIni.t総合ランク値を計算して返す(record))
2033 case CScoreIni.ERANK.SS:
2034 str = string.Format("Cleared (SS: {0:F2})", playskill);
2037 case CScoreIni.ERANK.S:
2038 str = string.Format("Cleared (S: {0:F2})", playskill);
2041 case CScoreIni.ERANK.A:
2042 str = string.Format("Cleared (A: {0:F2})", playskill);
2045 case CScoreIni.ERANK.B:
2046 str = string.Format("Cleared (B: {0:F2})", playskill);
2049 case CScoreIni.ERANK.C:
2050 str = string.Format("Cleared (C: {0:F2})", playskill);
2053 case CScoreIni.ERANK.D:
2054 str = string.Format("Cleared (D: {0:F2})", playskill);
2057 case CScoreIni.ERANK.E:
2058 str = string.Format("Cleared (E: {0:F2})", playskill);
2061 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
2062 str = "Cleared (No chips)";
2066 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
2068 #region [ プラグイン On演奏クリア() の呼び出し ]
2069 //---------------------
2070 foreach (STPlugin pg in this.listプラグイン)
2072 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2073 pg.plugin.On演奏クリア(scoreIni);
2074 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2076 //---------------------
2080 Trace.TraceInformation("----------------------");
2081 Trace.TraceInformation("■ 結果");
2082 stage結果.st演奏記録 = record;
2083 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
2085 r直前のステージ = r現在のステージ;
2088 #region [ プラグイン Onステージ変更() の呼び出し ]
2089 //---------------------
2090 foreach (STPlugin pg in this.listプラグイン)
2092 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2093 pg.plugin.Onステージ変更();
2094 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2096 //---------------------
2100 //-----------------------------
2103 //-----------------------------
2107 case CStage.Eステージ.結果:
2109 //-----------------------------
2110 if (this.n進行描画の戻り値 != 0)
2112 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2113 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2114 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2116 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
2124 Trace.TraceInformation("----------------------");
2125 Trace.TraceInformation("■ 選曲");
2127 r直前のステージ = r現在のステージ;
2130 foreach (STPlugin pg in this.listプラグイン)
2132 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2133 pg.plugin.Onステージ変更();
2134 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2137 this.tガベージコレクションを実行する();
2141 base.Window.Close();
2144 //-----------------------------
2148 case CStage.Eステージ.ChangeSkin:
2150 //-----------------------------
2151 if (this.n進行描画の戻り値 != 0)
2154 Trace.TraceInformation("----------------------");
2155 Trace.TraceInformation("■ 選曲");
2157 r直前のステージ = r現在のステージ;
2159 this.tガベージコレクションを実行する();
2161 //-----------------------------
2165 case CStage.Eステージ.終了:
2167 //-----------------------------
2168 if (this.n進行描画の戻り値 != 0)
2172 //-----------------------------
2177 this.Device.EndScene();
2178 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2179 // (つまり、Present()は、Draw()完了後に実行される)
2180 #if !GPUFlushAfterPresent
2181 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2183 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2185 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2188 #region [ マウスカーソル消去制御 ]
2189 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2191 #region [ 全画面・ウインドウ切り替え ]
2192 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2194 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2195 Instance.t全画面_ウィンドウモード切り替え();
2196 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2199 #region [ 垂直基線同期切り替え ]
2200 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2202 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2203 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2204 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2205 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2206 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2207 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2208 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2211 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2216 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2217 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2222 /// XML ファイルからオブジェクトを生成します。
2224 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2225 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2226 public static object DeserializeXML(string xmlpath, Type t)
2231 if (File.Exists(xmlpath))
2233 using (StreamReader reader = new StreamReader(xmlpath, Encoding.GetEncoding("shift_jis")))
2234 using (XmlReader xr = XmlReader.Create(reader))
2236 DataContractSerializer serializer = new DataContractSerializer(t);
2237 ret = serializer.ReadObject(xr);
2243 Trace.TraceWarning( e.Message );
2250 /// オブジェクトから XML ファイルを生成します。
2252 /// <param name="xmlfile">XML ファイルのパス。</param>
2253 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2254 public static void SerializeXML(string xmlpath, object obj)
2256 XmlWriterSettings settings = new XmlWriterSettings();
2257 settings.IndentChars = " ";
2258 settings.Indent = true;
2259 settings.NewLineChars = Environment.NewLine;
2260 settings.Encoding = new System.Text.UTF8Encoding(false);
2261 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2263 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2265 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2266 serializer.WriteObject(xw, obj);
2271 public void SaveConfig()
2273 #region [ Skinパスの絶対パス→相対パス変換 ]
2274 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2275 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2276 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2278 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2279 // → 初期値として Default/ を設定する。
2280 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2283 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2284 // そのため、以下の処理を通すために、いったん絶対パスに変換
2285 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2287 ConfigIni.strSystemSkinSubfolderPath.Value =
2288 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2291 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2292 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2293 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2294 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2295 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2297 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2299 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2302 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2305 public void LoadConfig()
2307 string path = strEXEのあるフォルダ + "Config.xml";
2309 if (!File.Exists(path))
2313 if (File.Exists(path))
2315 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2316 if (ConfigIni == null)
2318 ConfigIni = new CConfigXml();
2321 // Skinパスの相対パスを、絶対パスに変換
2322 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2324 ConfigIni.strSystemSkinSubfolderPath.Value =
2325 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2329 ConfigIni.UpgradeConfig(); // 本体version upに伴ってConfig.xmlの定義が更新される場合の、最低限のフォローアップ
2332 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2334 public void UpdateCoordinates()
2336 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2339 if (File.Exists(coordXml))
2341 using (XmlReader xr = XmlReader.Create(coordXml))
2343 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2346 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2348 catch (SerializationException e)
2350 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2355 XmlWriterSettings settings = new XmlWriterSettings();
2356 settings.IndentChars = " ";
2357 settings.Indent = true;
2358 settings.NewLineChars = Environment.NewLine;
2359 settings.Encoding = new System.Text.UTF8Encoding( false );
2360 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2362 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2363 //ns.Add( String.Empty, String.Empty );
2365 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2366 //serializer.Serialize( sw, item, ns );
2369 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2370 serializer.WriteObject( xw, Coordinates );
2371 //serializer.WriteStartObject( xw, Coordinates );
2372 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2373 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2374 //serializer.WriteObjectContent( xw, Coordinates );
2375 //serializer.WriteEndObject( xw );
2379 if (File.Exists(coordXml))
2381 using (XmlReader xr = XmlReader.Create(coordXml))
2383 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2384 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2391 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2393 //public class MyXmlTextWriter : XmlTextWriter
2395 // private bool _ignoreAttr = false;
2397 // public MyXmlTextWriter( TextWriter w )
2400 // Debug.WriteLine( "create" );
2403 // public override string LookupPrefix( string ns )
2405 // Debug.WriteLine( "luprefix" );
2406 // return string.Empty;
2409 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2411 // Debug.WriteLine( "writestartattribute" );
2412 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2414 // Debug.WriteLine( "[!]" );
2415 // this._ignoreAttr = true;
2420 // public override void WriteEndAttribute()
2422 // if ( this._ignoreAttr )
2424 // this._ignoreAttr = false;
2427 // base.WriteEndAttribute();
2430 // public override void WriteString( string text )
2432 // Debug.WriteLine( "ws" );
2433 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2437 // base.WriteString( text );
2440 // public override void WriteStartElement( string prefix, string localName, string ns )
2442 // Debug.WriteLine( "wse" );
2443 // base.WriteStartElement( null, localName, null );
2447 public void ShowWindowTitleWithSoundType()
2450 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2452 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2454 base.Window.Text = strWindowTitle;
2455 if (!this.DTX2WAVmode.Enabled)
2457 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2463 private bool b終了処理完了済み;
2464 private static CDTX dtx;
2465 private List<CActivity> listトップレベルActivities;
2466 private int n進行描画の戻り値;
2467 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2468 private string strWindowTitle
2472 string strCPUmode = (Environment.Is64BitProcess) ? " [x64]" : " [x86]";
2474 if (DTXVmode.Enabled)
2476 return "DTXMViewer release " + VERSION + strCPUmode;
2478 else if (DTX2WAVmode.Enabled)
2480 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename) + strCPUmode;
2484 return "DTXMania .NET style release " + VERSION + strCPUmode;
2488 private CSound previewSound;
2489 private CMouseHideControl cMouseHideControl = null;
2491 private void t終了処理()
2493 if (!this.b終了処理完了済み)
2495 Trace.TraceInformation("----------------------");
2496 Trace.TraceInformation("■ アプリケーションの終了");
2498 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2500 #region [ 曲検索の終了処理 ]
2501 //---------------------
2502 if (actEnumSongs != null)
2504 Trace.TraceInformation("曲検索actの終了処理を行います。");
2508 actEnumSongs.On非活性化();
2509 actEnumSongs = null;
2510 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2514 Trace.TraceError(e.Message);
2515 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2522 //---------------------
2524 #region [ 現在のステージの終了処理 ]
2525 //---------------------
2526 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2528 Trace.TraceInformation("現在のステージを終了します。");
2533 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2540 //---------------------
2543 #region [ 選曲ステージの終了処理 ]
2547 #region [ プラグインの終了処理 ]
2548 //---------------------
2549 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2551 Trace.TraceInformation("すべてのプラグインを終了します。");
2555 foreach (STPlugin st in this.listプラグイン)
2557 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2558 st.plugin.OnUnmanagedリソースの解放();
2559 st.plugin.OnManagedリソースの解放();
2561 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2564 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2571 //---------------------
2573 #region [ 曲リストの終了処理 ]
2574 //---------------------
2575 if (Songs管理 != null)
2577 Trace.TraceInformation("曲リストの終了処理を行います。");
2582 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2584 catch (Exception exception)
2586 Trace.TraceError(exception.Message);
2587 Trace.TraceError("曲リストの終了処理に失敗しました。");
2595 //---------------------
2597 #region [ スキンの終了処理 ]
2598 //---------------------
2601 Trace.TraceInformation("スキンの終了処理を行います。");
2607 Trace.TraceInformation("スキンの終了処理を完了しました。");
2609 catch (Exception exception2)
2611 Trace.TraceError(exception2.Message);
2612 Trace.TraceError("スキンの終了処理に失敗しました。");
2619 //---------------------
2621 #region [ DirectSoundの終了処理 ]
2622 //---------------------
2623 if (Sound管理 != null)
2625 Trace.TraceInformation("DirectSound の終了処理を行います。");
2631 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2633 catch (Exception exception3)
2635 Trace.TraceError(exception3.Message);
2636 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2643 //---------------------
2645 #region [ パッドの終了処理 ]
2646 //---------------------
2649 Trace.TraceInformation("パッドの終了処理を行います。");
2654 Trace.TraceInformation("パッドの終了処理を完了しました。");
2656 catch (Exception exception4)
2658 Trace.TraceError(exception4.Message);
2659 Trace.TraceError("パッドの終了処理に失敗しました。");
2666 //---------------------
2668 #region [ DirectInput, MIDI入力の終了処理 ]
2669 //---------------------
2670 if (Input管理 != null)
2672 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2678 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2680 catch (Exception exception5)
2682 Trace.TraceError(exception5.Message);
2683 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2690 //---------------------
2692 #region [ 文字コンソールの終了処理 ]
2693 //---------------------
2694 if (act文字コンソール != null)
2696 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2700 act文字コンソール.On非活性化();
2702 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2704 catch (Exception exception6)
2706 Trace.TraceError(exception6.Message);
2707 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2714 //---------------------
2716 #region [ FPSカウンタの終了処理 ]
2717 //---------------------
2718 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2726 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2732 //---------------------
2734 #region [ タイマの終了処理 ]
2735 //---------------------
2736 Trace.TraceInformation("タイマの終了処理を行います。");
2744 Trace.TraceInformation("タイマの終了処理を完了しました。");
2748 Trace.TraceInformation("タイマは使用されていません。");
2755 //---------------------
2757 #region [ Config.iniの出力 ]
2758 //---------------------
2759 Trace.TraceInformation("Config.xml を出力します。");
2760 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2761 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2763 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2766 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2768 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2771 string str = strEXEのあるフォルダ + "Config.xml";
2775 if (DTXVmode.Enabled)
2777 DTXVmode.tUpdateConfigIni();
2778 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2780 else if (DTX2WAVmode.Enabled)
2782 DTX2WAVmode.tUpdateConfigIni();
2783 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2784 DTX2WAVmode.SendMessage2DTX2WAV("TERM");
2788 CDTXMania.Instance.SaveConfig();
2789 Trace.TraceInformation("保存しました。({0})", str);
2794 Trace.TraceError(e.Message);
2795 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2801 //---------------------
2803 #region [ DTXVmodeの終了処理 ]
2804 //---------------------
2805 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2809 if (DTXVmode != null)
2812 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2816 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2823 //---------------------
2825 #region [ DirectXの終了処理 ]
2826 //---------------------
2827 base.GraphicsDeviceManager.Dispose();
2828 //---------------------
2830 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2833 this.b終了処理完了済み = true;
2836 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2838 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2839 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2840 CScoreIni ini = new CScoreIni(strFilename);
2841 if (!File.Exists(strFilename))
2843 ini.stファイル.Title = DTX.TITLE;
2844 ini.stファイル.Name = DTX.strファイル名;
2845 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2846 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2848 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2849 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2850 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2851 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2853 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2854 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2855 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2856 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2858 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2859 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2860 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2861 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2864 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2865 isUpdated = CScoreIni.t更新条件を取得する();
2866 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2868 if (isUpdated.Drums)
2870 ini.stファイル.PlayCountDrums++;
2872 if (isUpdated.Guitar)
2874 ini.stファイル.PlayCountGuitar++;
2878 ini.stファイル.PlayCountBass++;
2880 ini.tヒストリを追加する(str新ヒストリ行);
2883 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2884 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2885 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2886 for (int j = 0; j < ini.stファイル.History.Length; j++)
2888 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2892 if (ConfigIni.bScoreIni)
2894 ini.t書き出し(strFilename);
2899 private void tガベージコレクションを実行する()
2901 // LOHに対するコンパクションを要求
2902 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
2904 GC.Collect(0, GCCollectionMode.Optimized, true );
2905 GC.WaitForPendingFinalizers();
2906 GC.Collect(0, GCCollectionMode.Forced, true );
2907 GC.WaitForPendingFinalizers();
2910 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default;
2912 private void tプラグイン検索と生成()
2914 this.listプラグイン = new List<STPlugin>();
2916 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2917 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2919 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2921 if (this.listプラグイン.Count > 0)
2922 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2925 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2927 var domain = (AppDomain)sender;
2929 foreach (var assembly in domain.GetAssemblies())
2931 if (assembly.FullName == args.Name)
2936 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2938 // 指定されたパスが存在しないとエラー
2939 if (!Directory.Exists(strプラグインフォルダパス))
2941 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2945 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2948 // (1) すべての *.dll について…
2949 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2950 foreach (string dllName in strDLLs)
2952 if (Path.GetExtension(dllName).ToLower() != ".dll")
2958 // (1-1) dll をアセンブリとして読み込む。
2959 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2961 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2962 foreach (Type t in asm.GetTypes())
2964 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2965 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2967 // (1-4) クラス名からインスタンスを作成する
2968 var st = new STPlugin()
2970 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2971 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2972 strアセンブリ簡易名 = asm.GetName().Name,
2973 Version = asm.GetName().Version,
2976 // (1-5) プラグインリストへ登録
2977 this.listプラグイン.Add(st);
2978 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2982 catch (System.Reflection.ReflectionTypeLoadException e)
2984 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2985 Trace.TraceInformation(e.ToString());
2986 Trace.TraceInformation(e.Message);
2988 StringBuilder sb = new StringBuilder();
2989 foreach (Exception exSub in e.LoaderExceptions)
2991 sb.AppendLine(exSub.Message);
2992 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2993 if (exFileNotFound != null)
2995 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2997 sb.AppendLine("Fusion Log:");
2998 sb.AppendLine(exFileNotFound.FusionLog);
3003 string errorMessage = sb.ToString();
3004 //Display or log the error based on your application.
3005 Trace.TraceInformation(errorMessage);
3010 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
3011 Trace.TraceInformation(e.ToString());
3012 Trace.TraceInformation(e.Message);
3016 // (2) サブフォルダがあれば再帰する
3017 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
3018 foreach (string dir in strDirs)
3019 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
3022 #region [ Windowイベント処理 ]
3023 private void Window_ApplicationActivated( object sender, EventArgs e )
3025 this.bApplicationActive = true;
3027 private void Window_ApplicationDeactivated(object sender, EventArgs e)
3029 this.bApplicationActive = false;
3030 if (cMouseHideControl != null) cMouseHideControl.Show();
3032 private void Window_KeyDown(object sender, KeyEventArgs e)
3034 if (e.KeyCode == Keys.Menu)
3037 e.SuppressKeyPress = true;
3039 else if ((e.KeyCode == Keys.Return) && e.Alt)
3041 if (ConfigIni != null)
3043 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3044 this.t全画面_ウィンドウモード切り替え();
3047 e.SuppressKeyPress = true;
3051 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
3053 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
3055 if( (int) captureCode > 0 &&
3056 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
3058 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
3059 string strFullPath =
3060 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
3061 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
3062 SaveResultScreen( strFullPath );
3067 private void Window_MouseUp(object sender, MouseEventArgs e)
3071 private void Window_MouseDown(object sender, MouseEventArgs e)
3073 currentMousePosition.X = Control.MousePosition.X;
3074 currentMousePosition.Y = Control.MousePosition.Y;
3077 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
3079 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
3081 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3082 this.t全画面_ウィンドウモード切り替え();
3085 private Point currentMousePosition = new Point(-1,-1);
3086 private void Window_MouseMove(object sender, MouseEventArgs e)
3088 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
3089 if (Control.MouseButtons.HasFlag(MouseButtons.Left))
3091 int X = base.Window.Location.X;
3092 X += (Control.MousePosition.X - currentMousePosition.X);
3093 int Y = base.Window.Location.Y;
3094 Y += (Control.MousePosition.Y - currentMousePosition.Y);
3096 base.Window.Location = new Point(X, Y);
3098 currentMousePosition.X = Control.MousePosition.X;
3099 currentMousePosition.Y = Control.MousePosition.Y;
3102 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
3104 if (ConfigIni.bウィンドウモード)
3106 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
3107 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
3110 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
3111 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
3115 //Stopwatch sw = new Stopwatch();
3116 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
3120 private class CMouseHideControl
3122 private Point lastPosition;
3123 private CCounter ccMouseShow;
3124 private bool bマウスカーソル表示中;
3129 public CMouseHideControl()
3131 ccMouseShow = new CCounter();
3132 lastPosition = Cursor.Position;
3139 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3142 public void tHideCursorIfNeed()
3145 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3146 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3148 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3149 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
3157 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3159 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3160 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3162 Point currentPosition = Cursor.Position;
3163 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3164 if (lastPosition != currentPosition)
3166 //Trace.TraceInformation("移動発生");
3167 lastPosition = currentPosition;
3182 bマウスカーソル表示中 = false;