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曲読み込み;
1032 public void t全画面_ウィンドウモード切り替え()
1034 #if WindowedFullscreen
1035 if (ConfigIni != null)
1037 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
1038 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
1041 #if !WindowedFullscreen
1042 settings.Windowed = ConfigIni.bウィンドウモード;
1044 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
1046 currentClientSize = this.Window.ClientSize;
1047 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
1048 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
1049 // FDK.CTaskBar.ShowTaskBar( false );
1051 #if !WindowedFullscreen
1052 base.GraphicsDeviceManager.ChangeDevice( settings );
1054 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
1056 #if WindowedFullscreen
1057 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
1058 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
1059 // in spite of using fullscreen mode.
1060 Instance.Window.WindowState = FormWindowState.Normal;
1061 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1062 Instance.Window.WindowState = FormWindowState.Normal;
1064 base.Window.ClientSize =
1065 new Size(currentClientSize.Width, currentClientSize.Height);
1066 // FDK.CTaskBar.ShowTaskBar( true );
1068 #if WindowedFullscreen
1071 Instance.Window.WindowState = FormWindowState.Normal;
1072 Instance.Window.FormBorderStyle = FormBorderStyle.None;
1073 Instance.Window.WindowState = FormWindowState.Maximized;
1075 if (cMouseHideControl != null)
1077 if (ConfigIni.bウィンドウモード)
1079 cMouseHideControl.Show();
1083 cMouseHideControl.Hide();
1090 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1092 /// リザルト画像のキャプチャと保存。
1094 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1095 public bool SaveResultScreen(string strFullPath)
1097 string strSavePath = Path.GetDirectoryName(strFullPath);
1098 if (!Directory.Exists(strSavePath))
1102 Directory.CreateDirectory(strSavePath);
1110 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1111 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1113 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1121 protected override void Initialize()
1125 //swlist1 = new List<int>( 8192 );
1126 //swlist2 = new List<int>( 8192 );
1127 //swlist3 = new List<int>( 8192 );
1128 //swlist4 = new List<int>( 8192 );
1129 //swlist5 = new List<int>( 8192 );
1130 if (this.listトップレベルActivities != null)
1132 foreach (CActivity activity in this.listトップレベルActivities)
1133 activity.OnManagedリソースの作成();
1136 foreach (STPlugin st in this.listプラグイン)
1138 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1139 st.plugin.OnManagedリソースの作成();
1140 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1142 #if GPUFlushAfterPresent
1143 FrameEnd += dtxmania_FrameEnd;
1146 #if GPUFlushAfterPresent
1147 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1148 { // → Present()直後にGPUをFlushする
1149 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1150 actFlushGPU.On進行描画(); // Flush GPU
1153 protected override void LoadContent()
1155 if (cMouseHideControl != null)
1157 if (ConfigIni.bウィンドウモード)
1159 cMouseHideControl.Show();
1163 cMouseHideControl.Hide();
1166 this.Device.SetTransform(TransformState.View, Matrix.LookAtLH(new Vector3(0f, 0f, (float)(-SampleFramework.GameWindowSize.Height / 2 * Math.Sqrt(3.0))), new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f)));
1167 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1168 this.Device.SetRenderState(RenderState.Lighting, false);
1169 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1170 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1171 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1172 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1174 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1175 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1176 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1178 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1179 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1180 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1181 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1182 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1183 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1184 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1186 if (this.listトップレベルActivities != null)
1188 foreach (CActivity activity in this.listトップレベルActivities)
1189 activity.OnUnmanagedリソースの作成();
1192 foreach (STPlugin st in this.listプラグイン)
1194 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1195 st.plugin.OnUnmanagedリソースの作成();
1196 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1199 protected override void UnloadContent()
1201 if (this.listトップレベルActivities != null)
1203 foreach (CActivity activity in this.listトップレベルActivities)
1204 activity.OnUnmanagedリソースの解放();
1207 foreach (STPlugin st in this.listプラグイン)
1209 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1210 st.plugin.OnUnmanagedリソースの解放();
1211 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1214 protected override void OnExiting(EventArgs e)
1216 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1220 protected override void Update(GameTime gameTime)
1223 protected override void Draw(GameTime gameTime)
1225 if (Sound管理 == null)
1229 //Sound管理.t再生中の処理をする();
1233 if (CSound管理.rc演奏用タイマ != null)
1234 CSound管理.rc演奏用タイマ.t更新();
1236 if (Input管理 != null)
1237 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1242 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1243 // Pad.st検知したデバイス.Clear();
1245 if (this.Device == null)
1248 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1249 CPowerManagement.tDisableMonitorSuspend();
1251 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1253 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1255 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1259 #region [ DTXCreator/DTX2WAVからの指示 ]
1260 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1262 string strMes = this.Window.strMessage;
1263 this.Window.IsReceivedMessage = false;
1266 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1268 if (DTXVmode.Enabled)
1271 strコンパクトモードファイル = DTXVmode.filename;
1272 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1275 string strPreviewFilename = DTXVmode.previewFilename;
1276 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1279 if (this.previewSound != null)
1281 this.previewSound.tサウンドを停止する();
1282 this.previewSound.Dispose();
1283 this.previewSound = null;
1285 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1286 this.previewSound.n音量 = DTXVmode.previewVolume;
1287 this.previewSound.n位置 = DTXVmode.previewPan;
1288 this.previewSound.t再生を開始する();
1289 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1293 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1294 if (this.previewSound != null)
1296 this.previewSound.Dispose();
1298 this.previewSound = null;
1302 if (DTX2WAVmode.Enabled)
1304 if (DTX2WAVmode.Command == CDTX2WAVmode.ECommand.Cancel)
1306 Trace.TraceInformation("録音のCancelコマンドをDTXMania本体が受信しました。");
1307 //Microsoft.VisualBasic.Interaction.AppActivate("メモ帳");
1308 //SendKeys.Send("{ESC}");
1309 //SendKeys.SendWait("%{F4}");
1310 //Application.Exit();
1311 if (DTX != null) // 曲読み込みの前に録音Cancelされると、DTXがnullのままここにきてでGPFとなる→nullチェック追加
1318 //Environment.ExitCode = 10010; // この組み合わせではダメ、返り値が反映されない
1319 //base.Window.Close();
1320 Environment.Exit(10010); // このやり方ならばOK
1327 this.Device.BeginScene();
1328 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1330 if (r現在のステージ != null)
1332 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1334 #region [ プラグインの進行描画 ]
1335 //---------------------
1336 foreach (STPlugin sp in this.listプラグイン)
1338 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1340 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1341 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1343 sp.plugin.On進行描画(null, null);
1345 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1347 //---------------------
1350 #region [ DTX2WAVモード時、ステージが変わるたびに、そのことをDTX2WAVアプリ側に通知する ]
1351 if (DTX2WAVmode.Enabled && r現在のステージ != r1フレーム前のステージ)
1353 r1フレーム前のステージ = r現在のステージ;
1354 //Trace.TraceInformation("Stage変更 to : " + r現在のステージ.eステージID.ToString());
1355 switch (r現在のステージ.eステージID)
1357 case CStage.Eステージ.曲読み込み:
1358 DTX2WAVmode.SendMessage2DTX2WAV("LOAD");
1360 case CStage.Eステージ.演奏:
1361 DTX2WAVmode.SendMessage2DTX2WAV("PLAY");
1369 CScoreIni scoreIni = null;
1371 //if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1372 if (!CDTXMania.instance.ConfigIni.bEnumerateSongsInBoot) // #40772 2020.10.12 yyagi
1374 // → songs.db等の書き込み時だと音切れするっぽい
1375 actEnumSongs.On非活性化();
1376 EnumSongs.SongListEnumCompletelyDone();
1377 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1379 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1380 if (!CDTXMania.Instance.bコンパクトモード)
1382 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1384 switch (r現在のステージ.eステージID)
1386 case CStage.Eステージ.タイトル:
1387 case CStage.Eステージ.コンフィグ:
1388 case CStage.Eステージ.選曲:
1389 case CStage.Eステージ.曲読み込み:
1390 if (EnumSongs != null)
1392 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1393 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1394 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1395 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1396 !EnumSongs.IsSongListEnumStarted)
1398 actEnumSongs.On活性化();
1399 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1400 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1401 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1402 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1404 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1409 #region [ 曲検索の中断と再開 ]
1410 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1412 switch (this.n進行描画の戻り値)
1415 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1416 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1418 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1419 EnumSongs.IsSlowdown = false;
1423 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1424 EnumSongs.IsSlowdown = true;
1426 actEnumSongs.On活性化();
1430 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1431 actEnumSongs.On非活性化();
1437 #region [ 曲探索中断待ち待機 ]
1438 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1439 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1441 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1445 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1446 // CStage選曲.On活性化() に回した方がいいかな?
1447 if (EnumSongs.IsSongListEnumerated)
1449 actEnumSongs.On非活性化();
1450 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1452 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1453 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1454 EnumSongs.SongListEnumCompletelyDone();
1462 switch (r現在のステージ.eステージID)
1464 case CStage.Eステージ.何もしない:
1467 case CStage.Eステージ.起動:
1469 //-----------------------------
1470 if (this.n進行描画の戻り値 != 0)
1475 Trace.TraceInformation("----------------------");
1476 Trace.TraceInformation("■ タイトル");
1478 r直前のステージ = r現在のステージ;
1479 r現在のステージ = stageタイトル;
1484 Trace.TraceInformation("----------------------");
1485 Trace.TraceInformation("■ 曲読み込み");
1487 r直前のステージ = r現在のステージ;
1488 r現在のステージ = stage曲読み込み;
1491 foreach (STPlugin pg in this.listプラグイン)
1493 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1494 pg.plugin.Onステージ変更();
1495 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1498 this.tガベージコレクションを実行する();
1500 //-----------------------------
1504 case CStage.Eステージ.タイトル:
1506 //-----------------------------
1507 switch (this.n進行描画の戻り値)
1509 case (int)CStageタイトル.E戻り値.GAMESTART:
1511 //-----------------------------
1513 Trace.TraceInformation("----------------------");
1514 Trace.TraceInformation("■ 選曲");
1516 r直前のステージ = r現在のステージ;
1518 //-----------------------------
1522 #region [ OPTION: 廃止済 ]
1523 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1525 // //-----------------------------
1526 // r現在のステージ.On非活性化();
1527 // Trace.TraceInformation( "----------------------" );
1528 // Trace.TraceInformation( "■ オプション" );
1529 // stageオプション.On活性化();
1530 // r直前のステージ = r現在のステージ;
1531 // r現在のステージ = stageオプション;
1532 // //-----------------------------
1537 case (int)CStageタイトル.E戻り値.CONFIG:
1539 //-----------------------------
1541 Trace.TraceInformation("----------------------");
1542 Trace.TraceInformation("■ コンフィグ");
1544 r直前のステージ = r現在のステージ;
1545 r現在のステージ = stageコンフィグ;
1546 //-----------------------------
1550 case (int)CStageタイトル.E戻り値.EXIT:
1552 //-----------------------------
1554 Trace.TraceInformation("----------------------");
1555 Trace.TraceInformation("■ 終了");
1557 r直前のステージ = r現在のステージ;
1559 //-----------------------------
1564 foreach (STPlugin pg in this.listプラグイン)
1566 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1567 pg.plugin.Onステージ変更();
1568 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1571 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1572 //-----------------------------
1576 case CStage.Eステージ.コンフィグ:
1578 //-----------------------------
1579 if (this.n進行描画の戻り値 != 0)
1581 switch (r直前のステージ.eステージID)
1583 case CStage.Eステージ.タイトル:
1585 //-----------------------------
1587 Trace.TraceInformation("----------------------");
1588 Trace.TraceInformation("■ タイトル");
1590 r直前のステージ = r現在のステージ;
1591 r現在のステージ = stageタイトル;
1593 foreach (STPlugin pg in this.listプラグイン)
1595 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1596 pg.plugin.Onステージ変更();
1597 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1600 this.tガベージコレクションを実行する();
1602 //-----------------------------
1605 case CStage.Eステージ.選曲:
1607 //-----------------------------
1609 Trace.TraceInformation("----------------------");
1610 Trace.TraceInformation("■ 選曲");
1612 r直前のステージ = r現在のステージ;
1615 foreach (STPlugin pg in this.listプラグイン)
1617 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1618 pg.plugin.Onステージ変更();
1619 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1622 this.tガベージコレクションを実行する();
1624 //-----------------------------
1628 //-----------------------------
1632 case CStage.Eステージ.選曲:
1634 //-----------------------------
1635 switch (this.n進行描画の戻り値)
1637 case (int)CStage選曲.E戻り値.タイトルに戻る:
1639 //-----------------------------
1641 Trace.TraceInformation("----------------------");
1642 Trace.TraceInformation("■ タイトル");
1644 r直前のステージ = r現在のステージ;
1645 r現在のステージ = stageタイトル;
1647 foreach (STPlugin pg in this.listプラグイン)
1649 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1650 pg.plugin.Onステージ変更();
1651 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1654 this.tガベージコレクションを実行する();
1656 //-----------------------------
1659 case (int)CStage選曲.E戻り値.選曲した:
1661 //-----------------------------
1663 Trace.TraceInformation("----------------------");
1664 Trace.TraceInformation("■ 曲読み込み");
1666 r直前のステージ = r現在のステージ;
1667 r現在のステージ = stage曲読み込み;
1669 foreach (STPlugin pg in this.listプラグイン)
1671 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1672 pg.plugin.Onステージ変更();
1673 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1676 this.tガベージコレクションを実行する();
1678 //-----------------------------
1681 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1683 //-----------------------------
1685 Trace.TraceInformation("----------------------");
1686 Trace.TraceInformation("■ コンフィグ");
1688 r直前のステージ = r現在のステージ;
1689 r現在のステージ = stageコンフィグ;
1691 foreach (STPlugin pg in this.listプラグイン)
1693 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1694 pg.plugin.Onステージ変更();
1695 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1698 this.tガベージコレクションを実行する();
1700 //-----------------------------
1703 case (int)CStage選曲.E戻り値.スキン変更:
1706 //-----------------------------
1708 Trace.TraceInformation("----------------------");
1709 Trace.TraceInformation("■ スキン切り替え");
1710 stageChangeSkin.On活性化();
1711 r直前のステージ = r現在のステージ;
1712 r現在のステージ = stageChangeSkin;
1714 //-----------------------------
1717 //-----------------------------
1721 case CStage.Eステージ.曲読み込み:
1723 //-----------------------------
1724 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1725 if (this.n進行描画の戻り値 != 0)
1727 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1729 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1730 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1734 Trace.TraceInformation("曲の読み込みを中止しました。");
1735 this.tガベージコレクションを実行する();
1736 Trace.TraceInformation("----------------------");
1737 Trace.TraceInformation("■ 選曲");
1739 r直前のステージ = r現在のステージ;
1741 foreach (STPlugin pg in this.listプラグイン)
1743 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1744 pg.plugin.Onステージ変更();
1745 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1751 Trace.TraceInformation("----------------------");
1752 Trace.TraceInformation("■ 演奏(ドラム画面)");
1753 r直前のステージ = r現在のステージ;
1754 r現在のステージ = stage演奏画面;
1756 foreach (STPlugin pg in this.listプラグイン)
1758 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1759 pg.plugin.Onステージ変更();
1760 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1763 this.tガベージコレクションを実行する();
1765 //-----------------------------
1769 case CStage.Eステージ.演奏:
1771 //-----------------------------
1772 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1773 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1774 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1775 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1776 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1778 //swlist1.Add( Convert.ToInt32(n1) );
1779 //swlist2.Add( Convert.ToInt32(n2) );
1780 //swlist3.Add( Convert.ToInt32( n3 ) );
1781 //swlist4.Add( Convert.ToInt32( n4 ) );
1782 //swlist5.Add( Convert.ToInt32( n5 ) );
1784 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1785 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1787 DTXVmode.Refreshed = false;
1789 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1791 CDTXMania.Instance.stage演奏画面.t停止();
1793 if (previewSound != null)
1795 this.previewSound.tサウンドを停止する();
1796 this.previewSound.Dispose();
1797 this.previewSound = null;
1802 // for ( int i = 0; i < swlist1.Count; i++ )
1804 // int d1 = swlist1[ i ];
1805 // int d2 = swlist2[ i ];
1806 // int d3 = swlist3[ i ];
1807 // int d4 = swlist4[ i ];
1808 // int d5 = swlist5[ i ];
1810 // int dif = d1 - lastd;
1812 // if ( 16 <= dif && dif <= 17 )
1819 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3} - {7:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4, d5 );
1831 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1833 if (DTXVmode.NeedReload)
1835 CDTXMania.Instance.stage演奏画面.t再読込();
1836 if (DTXVmode.GRmode)
1838 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1842 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1844 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1845 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1846 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1848 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1849 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1854 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1860 switch (this.n進行描画の戻り値)
1862 case (int)E演奏画面の戻り値.再読込_再演奏:
1863 #region [ DTXファイルを再読み込みして、再演奏 ]
1868 r直前のステージ = r現在のステージ;
1869 r現在のステージ = stage曲読み込み;
1870 this.tガベージコレクションを実行する();
1874 //case (int) E演奏画面の戻り値.再演奏:
1875 #region [ 再読み込み無しで、再演奏 ]
1879 case (int)E演奏画面の戻り値.継続:
1882 case (int)E演奏画面の戻り値.演奏中断:
1884 //-----------------------------
1885 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1886 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1888 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1893 //for (int i = 0; i < swlist1.Count; i++)
1895 // int d1 = swlist1[ i ];
1896 // int d2 = swlist2[ i ];
1897 // int d3 = swlist3[ i ];
1898 // int d4 = swlist4[ i ];
1900 // int dif = d1 - lastd;
1902 // if ( 16 <= dif && dif <= 17 )
1909 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1918 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1919 //---------------------
1920 foreach (STPlugin pg in this.listプラグイン)
1922 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1923 pg.plugin.On演奏キャンセル(scoreIni);
1924 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1926 //---------------------
1932 if (DTX2WAVmode.Enabled)
1934 Environment.Exit(0);
1938 base.Window.Close();
1942 Trace.TraceInformation("----------------------");
1943 Trace.TraceInformation("■ 選曲");
1945 r直前のステージ = r現在のステージ;
1948 #region [ プラグイン Onステージ変更() の呼び出し ]
1949 //---------------------
1950 foreach (STPlugin pg in this.listプラグイン)
1952 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1953 pg.plugin.Onステージ変更();
1954 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1956 //---------------------
1959 this.tガベージコレクションを実行する();
1962 //-----------------------------
1965 case (int)E演奏画面の戻り値.ステージ失敗:
1966 #region [ 演奏失敗(StageFailed) ]
1967 //-----------------------------
1968 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1970 #region [ プラグイン On演奏失敗() の呼び出し ]
1971 //---------------------
1972 foreach (STPlugin pg in this.listプラグイン)
1974 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1975 pg.plugin.On演奏失敗(scoreIni);
1976 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1978 //---------------------
1986 base.Window.Close();
1990 Trace.TraceInformation("----------------------");
1991 Trace.TraceInformation("■ 選曲");
1993 r直前のステージ = r現在のステージ;
1996 #region [ プラグイン Onステージ変更() の呼び出し ]
1997 //---------------------
1998 foreach (STPlugin pg in this.listプラグイン)
2000 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2001 pg.plugin.Onステージ変更();
2002 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2004 //---------------------
2007 this.tガベージコレクションを実行する();
2010 //-----------------------------
2013 case (int)E演奏画面の戻り値.ステージクリア:
2015 //-----------------------------
2016 STDGBSValue<CScoreIni.C演奏記録> record;
2017 record = stage演奏画面.Record;
2019 double playskill = 0.0;
2021 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
2023 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
2025 playskill = record[inst].db演奏型スキル値;
2029 string str = "Cleared";
2030 switch (CScoreIni.t総合ランク値を計算して返す(record))
2032 case CScoreIni.ERANK.SS:
2033 str = string.Format("Cleared (SS: {0:F2})", playskill);
2036 case CScoreIni.ERANK.S:
2037 str = string.Format("Cleared (S: {0:F2})", playskill);
2040 case CScoreIni.ERANK.A:
2041 str = string.Format("Cleared (A: {0:F2})", playskill);
2044 case CScoreIni.ERANK.B:
2045 str = string.Format("Cleared (B: {0:F2})", playskill);
2048 case CScoreIni.ERANK.C:
2049 str = string.Format("Cleared (C: {0:F2})", playskill);
2052 case CScoreIni.ERANK.D:
2053 str = string.Format("Cleared (D: {0:F2})", playskill);
2056 case CScoreIni.ERANK.E:
2057 str = string.Format("Cleared (E: {0:F2})", playskill);
2060 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
2061 str = "Cleared (No chips)";
2065 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
2067 #region [ プラグイン On演奏クリア() の呼び出し ]
2068 //---------------------
2069 foreach (STPlugin pg in this.listプラグイン)
2071 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2072 pg.plugin.On演奏クリア(scoreIni);
2073 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2075 //---------------------
2079 Trace.TraceInformation("----------------------");
2080 Trace.TraceInformation("■ 結果");
2081 stage結果.st演奏記録 = record;
2082 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
2084 r直前のステージ = r現在のステージ;
2087 #region [ プラグイン Onステージ変更() の呼び出し ]
2088 //---------------------
2089 foreach (STPlugin pg in this.listプラグイン)
2091 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2092 pg.plugin.Onステージ変更();
2093 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2095 //---------------------
2099 //-----------------------------
2102 //-----------------------------
2106 case CStage.Eステージ.結果:
2108 //-----------------------------
2109 if (this.n進行描画の戻り値 != 0)
2111 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2112 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2113 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2115 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
2123 Trace.TraceInformation("----------------------");
2124 Trace.TraceInformation("■ 選曲");
2126 r直前のステージ = r現在のステージ;
2129 foreach (STPlugin pg in this.listプラグイン)
2131 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2132 pg.plugin.Onステージ変更();
2133 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2136 this.tガベージコレクションを実行する();
2140 base.Window.Close();
2143 //-----------------------------
2147 case CStage.Eステージ.ChangeSkin:
2149 //-----------------------------
2150 if (this.n進行描画の戻り値 != 0)
2153 Trace.TraceInformation("----------------------");
2154 Trace.TraceInformation("■ 選曲");
2156 r直前のステージ = r現在のステージ;
2158 this.tガベージコレクションを実行する();
2160 //-----------------------------
2164 case CStage.Eステージ.終了:
2166 //-----------------------------
2167 if (this.n進行描画の戻り値 != 0)
2171 //-----------------------------
2176 this.Device.EndScene();
2177 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2178 // (つまり、Present()は、Draw()完了後に実行される)
2179 #if !GPUFlushAfterPresent
2180 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2182 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2184 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2187 #region [ マウスカーソル消去制御 ]
2188 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2190 #region [ 全画面・ウインドウ切り替え ]
2191 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2193 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2194 Instance.t全画面_ウィンドウモード切り替え();
2195 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2198 #region [ 垂直基線同期切り替え ]
2199 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2201 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2202 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2203 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2204 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2205 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2206 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2207 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2210 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2215 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2216 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2221 /// XML ファイルからオブジェクトを生成します。
2223 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2224 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2225 public static object DeserializeXML(string xmlpath, Type t)
2230 if (File.Exists(xmlpath))
2232 using (StreamReader reader = new StreamReader(xmlpath, Encoding.GetEncoding("shift_jis")))
2233 using (XmlReader xr = XmlReader.Create(reader))
2235 DataContractSerializer serializer = new DataContractSerializer(t);
2236 ret = serializer.ReadObject(xr);
2242 Trace.TraceWarning( e.Message );
2249 /// オブジェクトから XML ファイルを生成します。
2251 /// <param name="xmlfile">XML ファイルのパス。</param>
2252 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2253 public static void SerializeXML(string xmlpath, object obj)
2255 XmlWriterSettings settings = new XmlWriterSettings();
2256 settings.IndentChars = " ";
2257 settings.Indent = true;
2258 settings.NewLineChars = Environment.NewLine;
2259 settings.Encoding = new System.Text.UTF8Encoding(false);
2260 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2262 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2264 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2265 serializer.WriteObject(xw, obj);
2270 public void SaveConfig()
2272 #region [ Skinパスの絶対パス→相対パス変換 ]
2273 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2274 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2275 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2277 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2278 // → 初期値として Default/ を設定する。
2279 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2282 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2283 // そのため、以下の処理を通すために、いったん絶対パスに変換
2284 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2286 ConfigIni.strSystemSkinSubfolderPath.Value =
2287 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2290 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2291 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2292 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2293 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2294 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2296 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2298 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2301 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2304 public void LoadConfig()
2306 string path = strEXEのあるフォルダ + "Config.xml";
2308 if (!File.Exists(path))
2312 if (File.Exists(path))
2314 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2315 if (ConfigIni == null)
2317 ConfigIni = new CConfigXml();
2320 // Skinパスの相対パスを、絶対パスに変換
2321 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2323 ConfigIni.strSystemSkinSubfolderPath.Value =
2324 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2328 ConfigIni.UpgradeConfig(); // 本体version upに伴ってConfig.xmlの定義が更新される場合の、最低限のフォローアップ
2331 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2333 public void UpdateCoordinates()
2335 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2338 if (File.Exists(coordXml))
2340 using (XmlReader xr = XmlReader.Create(coordXml))
2342 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2345 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2347 catch (SerializationException e)
2349 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2354 XmlWriterSettings settings = new XmlWriterSettings();
2355 settings.IndentChars = " ";
2356 settings.Indent = true;
2357 settings.NewLineChars = Environment.NewLine;
2358 settings.Encoding = new System.Text.UTF8Encoding( false );
2359 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2361 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2362 //ns.Add( String.Empty, String.Empty );
2364 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2365 //serializer.Serialize( sw, item, ns );
2368 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2369 serializer.WriteObject( xw, Coordinates );
2370 //serializer.WriteStartObject( xw, Coordinates );
2371 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2372 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2373 //serializer.WriteObjectContent( xw, Coordinates );
2374 //serializer.WriteEndObject( xw );
2378 if (File.Exists(coordXml))
2380 using (XmlReader xr = XmlReader.Create(coordXml))
2382 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2383 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2390 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2392 //public class MyXmlTextWriter : XmlTextWriter
2394 // private bool _ignoreAttr = false;
2396 // public MyXmlTextWriter( TextWriter w )
2399 // Debug.WriteLine( "create" );
2402 // public override string LookupPrefix( string ns )
2404 // Debug.WriteLine( "luprefix" );
2405 // return string.Empty;
2408 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2410 // Debug.WriteLine( "writestartattribute" );
2411 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2413 // Debug.WriteLine( "[!]" );
2414 // this._ignoreAttr = true;
2419 // public override void WriteEndAttribute()
2421 // if ( this._ignoreAttr )
2423 // this._ignoreAttr = false;
2426 // base.WriteEndAttribute();
2429 // public override void WriteString( string text )
2431 // Debug.WriteLine( "ws" );
2432 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2436 // base.WriteString( text );
2439 // public override void WriteStartElement( string prefix, string localName, string ns )
2441 // Debug.WriteLine( "wse" );
2442 // base.WriteStartElement( null, localName, null );
2446 public void ShowWindowTitleWithSoundType()
2449 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2451 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2453 base.Window.Text = strWindowTitle;
2454 if (!this.DTX2WAVmode.Enabled)
2456 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2462 private bool b終了処理完了済み;
2463 private static CDTX dtx;
2464 private List<CActivity> listトップレベルActivities;
2465 private int n進行描画の戻り値;
2466 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2467 private string strWindowTitle
2471 string strCPUmode = (Environment.Is64BitProcess) ? " [x64]" : " [x86]";
2473 if (DTXVmode.Enabled)
2475 return "DTXMViewer release " + VERSION + strCPUmode;
2477 else if (DTX2WAVmode.Enabled)
2479 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename) + strCPUmode;
2483 return "DTXMania .NET style release " + VERSION + strCPUmode;
2487 private CSound previewSound;
2488 private CMouseHideControl cMouseHideControl = null;
2490 private void t終了処理()
2492 if (!this.b終了処理完了済み)
2494 Trace.TraceInformation("----------------------");
2495 Trace.TraceInformation("■ アプリケーションの終了");
2497 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2499 #region [ 曲検索の終了処理 ]
2500 //---------------------
2501 if (actEnumSongs != null)
2503 Trace.TraceInformation("曲検索actの終了処理を行います。");
2507 actEnumSongs.On非活性化();
2508 actEnumSongs = null;
2509 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2513 Trace.TraceError(e.Message);
2514 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2521 //---------------------
2523 #region [ 現在のステージの終了処理 ]
2524 //---------------------
2525 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2527 Trace.TraceInformation("現在のステージを終了します。");
2532 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2539 //---------------------
2542 #region [ 選曲ステージの終了処理 ]
2546 #region [ プラグインの終了処理 ]
2547 //---------------------
2548 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2550 Trace.TraceInformation("すべてのプラグインを終了します。");
2554 foreach (STPlugin st in this.listプラグイン)
2556 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2557 st.plugin.OnUnmanagedリソースの解放();
2558 st.plugin.OnManagedリソースの解放();
2560 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2563 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2570 //---------------------
2572 #region [ 曲リストの終了処理 ]
2573 //---------------------
2574 if (Songs管理 != null)
2576 Trace.TraceInformation("曲リストの終了処理を行います。");
2581 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2583 catch (Exception exception)
2585 Trace.TraceError(exception.Message);
2586 Trace.TraceError("曲リストの終了処理に失敗しました。");
2594 //---------------------
2596 #region [ スキンの終了処理 ]
2597 //---------------------
2600 Trace.TraceInformation("スキンの終了処理を行います。");
2606 Trace.TraceInformation("スキンの終了処理を完了しました。");
2608 catch (Exception exception2)
2610 Trace.TraceError(exception2.Message);
2611 Trace.TraceError("スキンの終了処理に失敗しました。");
2618 //---------------------
2620 #region [ DirectSoundの終了処理 ]
2621 //---------------------
2622 if (Sound管理 != null)
2624 Trace.TraceInformation("DirectSound の終了処理を行います。");
2630 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2632 catch (Exception exception3)
2634 Trace.TraceError(exception3.Message);
2635 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2642 //---------------------
2644 #region [ パッドの終了処理 ]
2645 //---------------------
2648 Trace.TraceInformation("パッドの終了処理を行います。");
2653 Trace.TraceInformation("パッドの終了処理を完了しました。");
2655 catch (Exception exception4)
2657 Trace.TraceError(exception4.Message);
2658 Trace.TraceError("パッドの終了処理に失敗しました。");
2665 //---------------------
2667 #region [ DirectInput, MIDI入力の終了処理 ]
2668 //---------------------
2669 if (Input管理 != null)
2671 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2677 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2679 catch (Exception exception5)
2681 Trace.TraceError(exception5.Message);
2682 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2689 //---------------------
2691 #region [ 文字コンソールの終了処理 ]
2692 //---------------------
2693 if (act文字コンソール != null)
2695 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2699 act文字コンソール.On非活性化();
2701 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2703 catch (Exception exception6)
2705 Trace.TraceError(exception6.Message);
2706 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2713 //---------------------
2715 #region [ FPSカウンタの終了処理 ]
2716 //---------------------
2717 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2725 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2731 //---------------------
2733 #region [ タイマの終了処理 ]
2734 //---------------------
2735 Trace.TraceInformation("タイマの終了処理を行います。");
2743 Trace.TraceInformation("タイマの終了処理を完了しました。");
2747 Trace.TraceInformation("タイマは使用されていません。");
2754 //---------------------
2756 #region [ Config.iniの出力 ]
2757 //---------------------
2758 Trace.TraceInformation("Config.xml を出力します。");
2759 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2760 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2762 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2765 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2767 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2770 string str = strEXEのあるフォルダ + "Config.xml";
2774 if (DTXVmode.Enabled)
2776 DTXVmode.tUpdateConfigIni();
2777 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2779 else if (DTX2WAVmode.Enabled)
2781 DTX2WAVmode.tUpdateConfigIni();
2782 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2783 DTX2WAVmode.SendMessage2DTX2WAV("TERM");
2787 CDTXMania.Instance.SaveConfig();
2788 Trace.TraceInformation("保存しました。({0})", str);
2793 Trace.TraceError(e.Message);
2794 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2800 //---------------------
2802 #region [ DTXVmodeの終了処理 ]
2803 //---------------------
2804 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2808 if (DTXVmode != null)
2811 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2815 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2822 //---------------------
2824 #region [ DirectXの終了処理 ]
2825 //---------------------
2826 base.GraphicsDeviceManager.Dispose();
2827 //---------------------
2829 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2832 this.b終了処理完了済み = true;
2835 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2837 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2838 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2839 CScoreIni ini = new CScoreIni(strFilename);
2840 if (!File.Exists(strFilename))
2842 ini.stファイル.Title = DTX.TITLE;
2843 ini.stファイル.Name = DTX.strファイル名;
2844 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2845 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2847 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2848 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2849 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2850 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2852 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2853 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2854 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2855 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2857 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2858 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2859 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2860 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2863 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2864 isUpdated = CScoreIni.t更新条件を取得する();
2865 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2867 if (isUpdated.Drums)
2869 ini.stファイル.PlayCountDrums++;
2871 if (isUpdated.Guitar)
2873 ini.stファイル.PlayCountGuitar++;
2877 ini.stファイル.PlayCountBass++;
2879 ini.tヒストリを追加する(str新ヒストリ行);
2882 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2883 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2884 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2885 for (int j = 0; j < ini.stファイル.History.Length; j++)
2887 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2891 if (ConfigIni.bScoreIni)
2893 ini.t書き出し(strFilename);
2898 private void tガベージコレクションを実行する()
2900 // LOHに対するコンパクションを要求
2901 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
2903 GC.Collect(0, GCCollectionMode.Optimized, true );
2904 GC.WaitForPendingFinalizers();
2905 GC.Collect(0, GCCollectionMode.Forced, true );
2906 GC.WaitForPendingFinalizers();
2909 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default;
2911 private void tプラグイン検索と生成()
2913 this.listプラグイン = new List<STPlugin>();
2915 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2916 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2918 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2920 if (this.listプラグイン.Count > 0)
2921 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2924 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2926 var domain = (AppDomain)sender;
2928 foreach (var assembly in domain.GetAssemblies())
2930 if (assembly.FullName == args.Name)
2935 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2937 // 指定されたパスが存在しないとエラー
2938 if (!Directory.Exists(strプラグインフォルダパス))
2940 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2944 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2947 // (1) すべての *.dll について…
2948 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2949 foreach (string dllName in strDLLs)
2951 if (Path.GetExtension(dllName).ToLower() != ".dll")
2957 // (1-1) dll をアセンブリとして読み込む。
2958 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2960 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2961 foreach (Type t in asm.GetTypes())
2963 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2964 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2966 // (1-4) クラス名からインスタンスを作成する
2967 var st = new STPlugin()
2969 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2970 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2971 strアセンブリ簡易名 = asm.GetName().Name,
2972 Version = asm.GetName().Version,
2975 // (1-5) プラグインリストへ登録
2976 this.listプラグイン.Add(st);
2977 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2981 catch (System.Reflection.ReflectionTypeLoadException e)
2983 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2984 Trace.TraceInformation(e.ToString());
2985 Trace.TraceInformation(e.Message);
2987 StringBuilder sb = new StringBuilder();
2988 foreach (Exception exSub in e.LoaderExceptions)
2990 sb.AppendLine(exSub.Message);
2991 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2992 if (exFileNotFound != null)
2994 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2996 sb.AppendLine("Fusion Log:");
2997 sb.AppendLine(exFileNotFound.FusionLog);
3002 string errorMessage = sb.ToString();
3003 //Display or log the error based on your application.
3004 Trace.TraceInformation(errorMessage);
3009 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
3010 Trace.TraceInformation(e.ToString());
3011 Trace.TraceInformation(e.Message);
3015 // (2) サブフォルダがあれば再帰する
3016 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
3017 foreach (string dir in strDirs)
3018 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
3021 #region [ Windowイベント処理 ]
3022 private void Window_ApplicationActivated( object sender, EventArgs e )
3024 this.bApplicationActive = true;
3026 private void Window_ApplicationDeactivated(object sender, EventArgs e)
3028 this.bApplicationActive = false;
3029 if (cMouseHideControl != null) cMouseHideControl.Show();
3031 private void Window_KeyDown(object sender, KeyEventArgs e)
3033 if (e.KeyCode == Keys.Menu)
3036 e.SuppressKeyPress = true;
3038 else if ((e.KeyCode == Keys.Return) && e.Alt)
3040 if (ConfigIni != null)
3042 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3043 this.t全画面_ウィンドウモード切り替え();
3046 e.SuppressKeyPress = true;
3050 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
3052 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
3054 if( (int) captureCode > 0 &&
3055 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
3057 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
3058 string strFullPath =
3059 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
3060 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
3061 SaveResultScreen( strFullPath );
3066 private void Window_MouseUp(object sender, MouseEventArgs e)
3070 private void Window_MouseDown(object sender, MouseEventArgs e)
3072 currentMousePosition.X = Control.MousePosition.X;
3073 currentMousePosition.Y = Control.MousePosition.Y;
3076 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
3078 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
3080 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3081 this.t全画面_ウィンドウモード切り替え();
3084 private Point currentMousePosition = new Point(-1,-1);
3085 private void Window_MouseMove(object sender, MouseEventArgs e)
3087 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
3088 if (Control.MouseButtons.HasFlag(MouseButtons.Left))
3090 int X = base.Window.Location.X;
3091 X += (Control.MousePosition.X - currentMousePosition.X);
3092 int Y = base.Window.Location.Y;
3093 Y += (Control.MousePosition.Y - currentMousePosition.Y);
3095 base.Window.Location = new Point(X, Y);
3097 currentMousePosition.X = Control.MousePosition.X;
3098 currentMousePosition.Y = Control.MousePosition.Y;
3101 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
3103 if (ConfigIni.bウィンドウモード)
3105 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
3106 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
3109 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
3110 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
3114 //Stopwatch sw = new Stopwatch();
3115 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
3119 private class CMouseHideControl
3121 private Point lastPosition;
3122 private CCounter ccMouseShow;
3123 private bool bマウスカーソル表示中;
3128 public CMouseHideControl()
3130 ccMouseShow = new CCounter();
3131 lastPosition = Cursor.Position;
3138 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3141 public void tHideCursorIfNeed()
3144 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3145 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3147 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3148 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
3156 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3158 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3159 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3161 Point currentPosition = Cursor.Position;
3162 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3163 if (lastPosition != currentPosition)
3165 //Trace.TraceInformation("移動発生");
3166 lastPosition = currentPosition;
3181 bマウスカーソル表示中 = false;