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;
436 CDTXMania.instance.ConfigIni.nPolyphonicSoundsGB.Value = 2;
439 CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
442 CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
443 CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
444 CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
447 CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
448 CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
451 //CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100; // DTX2WAV側から設定するので、ここでは触らない
454 CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
457 CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
458 CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
459 CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
462 CDTXMania.instance.ConfigIni.bDisplayCombo.Drums.Value = false;
463 CDTXMania.instance.ConfigIni.bDisplayCombo.Guitar.Value = false;
464 CDTXMania.instance.ConfigIni.bDisplayCombo.Bass.Value = false;
465 CDTXMania.instance.ConfigIni.bDisplayJudge.Drums.Value = false;
466 CDTXMania.instance.ConfigIni.bDisplayJudge.Guitar.Value = false;
467 CDTXMania.instance.ConfigIni.bDisplayJudge.Bass.Value = false;
471 //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
472 CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
475 CDTXMania.instance.ConfigIni.bBGA.Value = false;
476 CDTXMania.instance.ConfigIni.bAVI.Value = false;
479 CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
480 CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
483 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Drums.Value = false;
484 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Guitar.Value = false;
485 CDTXMania.instance.ConfigIni.bEmphasizePlaySound.Bass.Value = false;
487 // パッド入力等、基本操作の無効化 (ESCを除く)
488 //CDTXMania.Instance.ConfigIni.KeyAssign[][];
494 strコンパクトモードファイル = commandLineArgs[1];
497 if (!File.Exists(strコンパクトモードファイル)) // #32985 2014.1.23 yyagi
499 Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
501 Environment.Exit(-1);
503 if (strコンパクトモードファイル == "") // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
505 Environment.Exit(-1);
509 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
513 if (DTXVmode.Enabled)
515 Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
517 else if (DTX2WAVmode.Enabled)
519 Trace.TraceInformation("DTX2WAVモードで起動します。[{0}]", strコンパクトモードファイル);
520 DTX2WAVmode.SendMessage2DTX2WAV("BOOT");
524 Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
529 Trace.TraceInformation("通常モードで起動します。");
533 #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
534 if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
536 CPowerPlan.BackupCurrentPowerPlan();
537 CPowerPlan.ChangeHighPerformance();
541 #region [ Input管理 の初期化 ]
542 Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
546 bool bUseMIDIIn = !DTXVmode.Enabled;
547 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
549 // If the users uses MIDI2.0-USB cable, then warn it
550 if (bUseMIDIIn && CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value)
552 foreach (IInputDevice device in Input管理.list入力デバイス)
554 if ((device.e入力デバイス種別 == E入力デバイス種別.MidiIn) && (device.strDeviceName == "USB2.0-MIDI"))
556 string strWarnMes = CDTXMania.Instance.Resources.Explanation("strWarnMIDI20USB");
557 var ret = MessageBox.Show(strWarnMes, "DTXMania Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
558 if (ret == DialogResult.OK)
560 CDTXMania.Instance.ConfigIni.bWarnMIDI20USB.Value = false;
568 foreach (IInputDevice device in Input管理.list入力デバイス)
570 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
573 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
577 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
580 foreach (IInputDevice device2 in Input管理.list入力デバイス)
582 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
584 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
586 if (device2.GUID.Equals(pair.Value))
588 ((CInputJoystick)device2).SetID(pair.Key);
595 Trace.TraceInformation("DirectInput の初期化を完了しました。");
597 catch (Exception exception2)
599 Trace.TraceError(exception2.Message);
600 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
602 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
603 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
613 // #30675 2013.02.04 ikanick add
614 base.Window.StartPosition = FormStartPosition.Manual;
615 base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
616 // 事前にDTXVmodeの実体を作っておくこと
617 base.Window.Text = this.strWindowTitle;
618 //base.Window.StartPosition = FormStartPosition.Manual;
619 //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
621 // #34510 yyagi 2010.10.31 to change window size got from Config.ini
622 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
623 #if !WindowedFullscreen
624 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
625 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
627 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
628 #if !WindowedFullscreen
631 // #23510 2010.11.04 yyagi: to support maximizing window
632 base.Window.MaximizeBox = true;
633 // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
634 base.Window.FormBorderStyle = FormBorderStyle.Sizable;
635 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
636 base.Window.ShowIcon = true;
637 base.Window.Icon = Properties.Resources.dtx;
638 base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
639 base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
640 base.Window.MouseDown += new MouseEventHandler(this.Window_MouseDown);
641 // #23510 2010.11.13 yyagi: to go fullscreen mode
642 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
643 // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
644 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
645 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
646 base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
647 base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
650 #region [ Direct3D9Exを使うかどうか判定 ]
653 #region [ Direct3D9 デバイスの生成 ]
654 DeviceSettings settings = new DeviceSettings();
655 #if WindowedFullscreen
656 // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
657 settings.Windowed = true;
659 settings.Windowed = ConfigIni.bウィンドウモード;
661 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
662 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
663 settings.EnableVSync = ConfigIni.bVSyncWait;
664 //settings.MultisampleType = MultisampleType.FourSamples;
665 //settings.MultisampleQuality = 3;
666 //settings.MultisampleType = MultisampleType.NonMaskable;
667 //settings.Multithreaded = true;
672 base.GraphicsDeviceManager.ChangeDevice(settings);
674 catch (DeviceCreationException e)
676 Trace.TraceError(e.ToString());
677 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
678 Environment.Exit(-1);
680 Trace.TraceInformation("DeviceCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
681 Trace.TraceInformation("DeviceCaps2 = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
682 Trace.TraceInformation("MaxTextureWidth = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
683 Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
684 Trace.TraceInformation("TextureCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
685 Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
686 Trace.TraceInformation("DeviceStatics = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
688 base.IsFixedTimeStep = false;
689 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
690 // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
691 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
692 // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
693 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
694 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
695 #if WindowedFullscreen
696 // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
697 this.t全画面_ウィンドウモード切り替え();
699 actFlushGPU = new CActFlushGPU();
702 if (DTX2WAVmode.Enabled)
704 this.Window.WindowState = FormWindowState.Minimized; //DTX2WAVモード時は自動的に最小化
709 #region [ Skin の初期化 ]
710 Trace.TraceInformation("スキンの初期化を行います。");
715 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
716 CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
717 // 旧指定のSkinフォルダが消滅していた場合に備える
718 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
719 Trace.TraceInformation("スキンの初期化を完了しました。");
723 Trace.TraceInformation("スキンの初期化に失敗しました。");
731 #region [ Skin配下にある言語リソースの確認と初期化 ]
732 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
736 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
737 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
739 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
742 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
746 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
758 #region [ Timer の初期化 ]
759 Trace.TraceInformation("タイマの初期化を行います。");
763 Timer = new CTimer(CTimer.E種別.MultiMedia);
764 Trace.TraceInformation("タイマの初期化を完了しました。");
772 #region [ マウス消去用のクラスを初期化 ]
773 cMouseHideControl = new CMouseHideControl();
776 #region [ FPS カウンタの初期化 ]
777 Trace.TraceInformation("FPSカウンタの初期化を行います。");
782 Trace.TraceInformation("FPSカウンタを生成しました。");
790 #region [ act文字コンソールの初期化 ]
791 Trace.TraceInformation("文字コンソールの初期化を行います。");
795 act文字コンソール = new C文字コンソール();
796 Trace.TraceInformation("文字コンソールを生成しました。");
798 Trace.TraceInformation("文字コンソールを活性化しました。");
799 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
801 catch (Exception exception)
803 Trace.TraceError(exception.Message);
804 Trace.TraceError("文字コンソールの初期化に失敗しました。");
813 Trace.TraceInformation("パッドの初期化を行います。");
818 Trace.TraceInformation("パッドの初期化を完了しました。");
820 catch (Exception exception3)
822 Trace.TraceError(exception3.Message);
823 Trace.TraceError("パッドの初期化に失敗しました。");
831 #region [ Sound管理 の初期化 ]
832 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
836 ESoundDeviceType soundDeviceType;
837 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
839 case ESoundDeviceTypeForConfig.DSound:
840 soundDeviceType = ESoundDeviceType.DirectSound;
842 case ESoundDeviceTypeForConfig.ASIO:
843 soundDeviceType = ESoundDeviceType.ASIO;
845 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
846 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
848 case ESoundDeviceTypeForConfig.WASAPI_Shared:
849 soundDeviceType = ESoundDeviceType.SharedWASAPI;
852 soundDeviceType = ESoundDeviceType.Unknown;
855 Sound管理 = new CSound管理(base.Window.Handle,
857 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
858 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
860 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
861 CDTXMania.Instance.ConfigIni.bUseOSTimer
863 //Sound管理 = FDK.CSound管理.Instance;
864 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
866 ShowWindowTitleWithSoundType();
867 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
868 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
869 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
872 string strDefaultSoundDeviceBusType = CSound管理.strDefaultDeviceBusType;
873 Trace.TraceInformation($"Bus type of the default sound device = {strDefaultSoundDeviceBusType}");
875 if (strDefaultSoundDeviceBusType.ToUpper().Equals("USB"))
877 if (CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value)
879 string strWarnMes = CDTXMania.Instance.Resources.Explanation("strWarnSoundDeviceOnUSB");
880 var ret = MessageBox.Show(strWarnMes, "DTXMania Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
881 if (ret == DialogResult.OK)
883 CDTXMania.Instance.ConfigIni.bWarnSoundDeviceOnUSB.Value = false;
888 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
890 catch (NullReferenceException) // No audio output found
892 Trace.TraceError("Error: No sound output devices are ready.");
893 string strWarnMes = CDTXMania.Instance.Resources.Explanation("strErrorNoActiveSoundDevice");
894 MessageBox.Show(strWarnMes, "DTXMania Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
895 Environment.Exit(-1);
899 Trace.TraceError(e.Message);
908 #region [ Songs管理 の初期化 ]
909 //---------------------
910 Trace.TraceInformation("曲リストの初期化を行います。");
914 Songs管理 = new CSongs管理();
915 // Songs管理_裏読 = new CSongs管理();
916 EnumSongs = new CEnumSongs();
917 actEnumSongs = new CActEnumSongs();
918 Trace.TraceInformation("曲リストの初期化を完了しました。");
922 Trace.TraceError(e.Message);
923 Trace.TraceError("曲リストの初期化に失敗しました。");
929 //---------------------
932 #region [ CAvi の初期化 ]
936 #region [ Random の初期化 ]
937 Random = new Random((int)Timer.nシステム時刻);
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 stage結果 = new CStage結果();
950 stageChangeSkin = new CStageChangeSkin();
951 stage終了 = new CStage終了();
953 this.listトップレベルActivities = new List<CActivity>();
954 this.listトップレベルActivities.Add(actEnumSongs);
955 this.listトップレベルActivities.Add(act文字コンソール);
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(stage結果);
963 this.listトップレベルActivities.Add(stageChangeSkin);
964 this.listトップレベルActivities.Add(stage終了);
965 this.listトップレベルActivities.Add(actFlushGPU);
968 #region [ プラグインの検索と生成 ]
969 PluginHost = new CPluginHost();
971 Trace.TraceInformation("プラグインの検索と生成を行います。");
976 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
984 #region [ プラグインの初期化 ]
985 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
987 Trace.TraceInformation("プラグインの初期化を行います。");
991 foreach (STPlugin st in this.listプラグイン)
993 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
994 st.plugin.On初期化(this.PluginHost);
995 st.plugin.OnManagedリソースの作成();
996 st.plugin.OnUnmanagedリソースの作成();
997 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
999 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
1003 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
1014 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
1016 #region [ 最初のステージの起動 ]
1017 Trace.TraceInformation("----------------------");
1018 Trace.TraceInformation("■ 起動");
1020 if (CDTXMania.Instance.bコンパクトモード)
1022 r現在のステージ = stage曲読み込み;
1029 this.Window.Activate(); // #41300 workaround to avoid SharpDX exception
1034 public void t全画面_ウィンドウモード切り替え()
1036 #if WindowedFullscreen
1037 if (ConfigIni != null)
1039 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
1040 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
1043 #if !WindowedFullscreen
1044 settings.Windowed = ConfigIni.bウィンドウモード;
1046 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
1048 currentClientSize = this.Window.ClientSize;
1049 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
1050 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
1051 // FDK.CTaskBar.ShowTaskBar( false );
1053 #if !WindowedFullscreen
1054 base.GraphicsDeviceManager.ChangeDevice( settings );
1056 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
1058 #if WindowedFullscreen
1059 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
1060 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
1061 // instead of using fullscreen mode.
1062 Instance.Window.WindowState = FormWindowState.Normal;
1063 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1064 Instance.Window.WindowState = FormWindowState.Normal;
1066 base.Window.ClientSize =
1067 new Size(currentClientSize.Width, currentClientSize.Height);
1068 // FDK.CTaskBar.ShowTaskBar( true );
1070 #if WindowedFullscreen
1073 Instance.Window.WindowState = FormWindowState.Normal;
1074 Instance.Window.FormBorderStyle = FormBorderStyle.None;
1075 Instance.Window.WindowState = FormWindowState.Maximized;
1077 if (cMouseHideControl != null)
1079 if (ConfigIni.bウィンドウモード)
1081 cMouseHideControl.Show();
1085 cMouseHideControl.Hide();
1092 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1094 /// リザルト画像のキャプチャと保存。
1096 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1097 public bool SaveResultScreen(string strFullPath)
1099 string strSavePath = Path.GetDirectoryName(strFullPath);
1100 if (!Directory.Exists(strSavePath))
1104 Directory.CreateDirectory(strSavePath);
1112 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1113 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1115 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1123 protected override void Initialize()
1127 //swlist1 = new List<int>( 8192 );
1128 //swlist2 = new List<int>( 8192 );
1129 //swlist3 = new List<int>( 8192 );
1130 //swlist4 = new List<int>( 8192 );
1131 //swlist5 = new List<int>( 8192 );
1132 if (this.listトップレベルActivities != null)
1134 foreach (CActivity activity in this.listトップレベルActivities)
1135 activity.OnManagedリソースの作成();
1138 foreach (STPlugin st in this.listプラグイン)
1140 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1141 st.plugin.OnManagedリソースの作成();
1142 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1144 #if GPUFlushAfterPresent
1145 FrameEnd += dtxmania_FrameEnd;
1148 #if GPUFlushAfterPresent
1149 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1150 { // → Present()直後にGPUをFlushする
1151 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1152 actFlushGPU.On進行描画(); // Flush GPU
1155 protected override void LoadContent()
1157 if (cMouseHideControl != null)
1159 if (ConfigIni.bウィンドウモード)
1161 cMouseHideControl.Show();
1165 cMouseHideControl.Hide();
1168 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)));
1169 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1170 this.Device.SetRenderState(RenderState.Lighting, false);
1171 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1172 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1173 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1174 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1176 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1177 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1178 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1180 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1181 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1182 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1183 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1184 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1185 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1186 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1188 if (this.listトップレベルActivities != null)
1190 foreach (CActivity activity in this.listトップレベルActivities)
1191 activity.OnUnmanagedリソースの作成();
1194 foreach (STPlugin st in this.listプラグイン)
1196 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1197 st.plugin.OnUnmanagedリソースの作成();
1198 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1201 protected override void UnloadContent()
1203 if (this.listトップレベルActivities != null)
1205 foreach (CActivity activity in this.listトップレベルActivities)
1206 activity.OnUnmanagedリソースの解放();
1209 foreach (STPlugin st in this.listプラグイン)
1211 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1212 st.plugin.OnUnmanagedリソースの解放();
1213 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1216 protected override void OnExiting(EventArgs e)
1218 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1222 protected override void Update(GameTime gameTime)
1225 protected override void Draw(GameTime gameTime)
1227 if (Sound管理 == null)
1231 //Sound管理.t再生中の処理をする();
1235 if (CSound管理.rc演奏用タイマ != null)
1236 CSound管理.rc演奏用タイマ.t更新();
1238 if (Input管理 != null)
1239 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1244 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1245 // Pad.st検知したデバイス.Clear();
1247 if (this.Device == null)
1250 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1251 CPowerManagement.tDisableMonitorSuspend();
1253 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1255 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1257 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1261 #region [ DTXCreator/DTX2WAVからの指示 ]
1262 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1264 string strMes = this.Window.strMessage;
1265 this.Window.IsReceivedMessage = false;
1268 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1270 if (DTXVmode.Enabled)
1273 strコンパクトモードファイル = DTXVmode.filename;
1274 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1277 string strPreviewFilename = DTXVmode.previewFilename;
1278 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1281 if (this.previewSound != null)
1283 this.previewSound.tサウンドを停止する();
1284 this.previewSound.Dispose();
1285 this.previewSound = null;
1287 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1288 this.previewSound.n音量 = DTXVmode.previewVolume;
1289 this.previewSound.n位置 = DTXVmode.previewPan;
1290 this.previewSound.t再生を開始する();
1291 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1295 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1296 if (this.previewSound != null)
1298 this.previewSound.Dispose();
1300 this.previewSound = null;
1304 if (DTX2WAVmode.Enabled)
1306 if (DTX2WAVmode.Command == CDTX2WAVmode.ECommand.Cancel)
1308 Trace.TraceInformation("録音のCancelコマンドをDTXMania本体が受信しました。");
1309 //Microsoft.VisualBasic.Interaction.AppActivate("メモ帳");
1310 //SendKeys.Send("{ESC}");
1311 //SendKeys.SendWait("%{F4}");
1312 //Application.Exit();
1313 if (DTX != null) // 曲読み込みの前に録音Cancelされると、DTXがnullのままここにきてでGPFとなる→nullチェック追加
1320 //Environment.ExitCode = 10010; // この組み合わせではダメ、返り値が反映されない
1321 //base.Window.Close();
1322 Environment.Exit(10010); // このやり方ならばOK
1329 this.Device.BeginScene();
1330 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1332 if (r現在のステージ != null)
1334 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1336 #region [ プラグインの進行描画 ]
1337 //---------------------
1338 foreach (STPlugin sp in this.listプラグイン)
1340 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1342 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1343 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1345 sp.plugin.On進行描画(null, null);
1347 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1349 //---------------------
1352 #region [ DTX2WAVモード時、ステージが変わるたびに、そのことをDTX2WAVアプリ側に通知する ]
1353 if (DTX2WAVmode.Enabled && r現在のステージ != r1フレーム前のステージ)
1355 r1フレーム前のステージ = r現在のステージ;
1356 //Trace.TraceInformation("Stage変更 to : " + r現在のステージ.eステージID.ToString());
1357 switch (r現在のステージ.eステージID)
1359 case CStage.Eステージ.曲読み込み:
1360 DTX2WAVmode.SendMessage2DTX2WAV("LOAD");
1362 case CStage.Eステージ.演奏:
1363 DTX2WAVmode.SendMessage2DTX2WAV("PLAY");
1371 CScoreIni scoreIni = null;
1373 //if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1374 if (!CDTXMania.instance.ConfigIni.bEnumerateSongsInBoot) // #40772 2020.10.12 yyagi
1376 // → songs.db等の書き込み時だと音切れするっぽい
1377 actEnumSongs.On非活性化();
1378 EnumSongs.SongListEnumCompletelyDone();
1379 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1381 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1382 if (!CDTXMania.Instance.bコンパクトモード)
1384 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1386 switch (r現在のステージ.eステージID)
1388 case CStage.Eステージ.タイトル:
1389 case CStage.Eステージ.コンフィグ:
1390 case CStage.Eステージ.選曲:
1391 case CStage.Eステージ.曲読み込み:
1392 if (EnumSongs != null)
1394 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1395 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1396 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1397 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1398 !EnumSongs.IsSongListEnumStarted)
1400 actEnumSongs.On活性化();
1401 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1402 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1403 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1404 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1406 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1411 #region [ 曲検索の中断と再開 ]
1412 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1414 switch (this.n進行描画の戻り値)
1417 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1418 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1420 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1421 EnumSongs.IsSlowdown = false;
1425 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1426 EnumSongs.IsSlowdown = true;
1428 actEnumSongs.On活性化();
1432 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1433 actEnumSongs.On非活性化();
1439 #region [ 曲探索中断待ち待機 ]
1440 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1441 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1443 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1447 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1448 // CStage選曲.On活性化() に回した方がいいかな?
1449 if (EnumSongs.IsSongListEnumerated)
1451 actEnumSongs.On非活性化();
1452 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1454 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1455 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1456 EnumSongs.SongListEnumCompletelyDone();
1464 switch (r現在のステージ.eステージID)
1466 case CStage.Eステージ.何もしない:
1469 case CStage.Eステージ.起動:
1471 //-----------------------------
1472 if (this.n進行描画の戻り値 != 0)
1477 Trace.TraceInformation("----------------------");
1478 Trace.TraceInformation("■ タイトル");
1480 r直前のステージ = r現在のステージ;
1481 r現在のステージ = stageタイトル;
1486 Trace.TraceInformation("----------------------");
1487 Trace.TraceInformation("■ 曲読み込み");
1489 r直前のステージ = r現在のステージ;
1490 r現在のステージ = stage曲読み込み;
1493 foreach (STPlugin pg in this.listプラグイン)
1495 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1496 pg.plugin.Onステージ変更();
1497 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1500 this.tガベージコレクションを実行する();
1502 //-----------------------------
1506 case CStage.Eステージ.タイトル:
1508 //-----------------------------
1509 switch (this.n進行描画の戻り値)
1511 case (int)CStageタイトル.E戻り値.GAMESTART:
1513 //-----------------------------
1515 Trace.TraceInformation("----------------------");
1516 Trace.TraceInformation("■ 選曲");
1518 r直前のステージ = r現在のステージ;
1520 //-----------------------------
1524 #region [ OPTION: 廃止済 ]
1525 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1527 // //-----------------------------
1528 // r現在のステージ.On非活性化();
1529 // Trace.TraceInformation( "----------------------" );
1530 // Trace.TraceInformation( "■ オプション" );
1531 // stageオプション.On活性化();
1532 // r直前のステージ = r現在のステージ;
1533 // r現在のステージ = stageオプション;
1534 // //-----------------------------
1539 case (int)CStageタイトル.E戻り値.CONFIG:
1541 //-----------------------------
1543 Trace.TraceInformation("----------------------");
1544 Trace.TraceInformation("■ コンフィグ");
1546 r直前のステージ = r現在のステージ;
1547 r現在のステージ = stageコンフィグ;
1548 //-----------------------------
1552 case (int)CStageタイトル.E戻り値.EXIT:
1554 //-----------------------------
1556 Trace.TraceInformation("----------------------");
1557 Trace.TraceInformation("■ 終了");
1559 r直前のステージ = r現在のステージ;
1561 //-----------------------------
1566 foreach (STPlugin pg in this.listプラグイン)
1568 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1569 pg.plugin.Onステージ変更();
1570 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1573 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1574 //-----------------------------
1578 case CStage.Eステージ.コンフィグ:
1580 //-----------------------------
1581 if (this.n進行描画の戻り値 != 0)
1583 switch (r直前のステージ.eステージID)
1585 case CStage.Eステージ.タイトル:
1587 //-----------------------------
1589 Trace.TraceInformation("----------------------");
1590 Trace.TraceInformation("■ タイトル");
1592 r直前のステージ = r現在のステージ;
1593 r現在のステージ = stageタイトル;
1595 foreach (STPlugin pg in this.listプラグイン)
1597 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1598 pg.plugin.Onステージ変更();
1599 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1602 this.tガベージコレクションを実行する();
1604 //-----------------------------
1607 case CStage.Eステージ.選曲:
1609 //-----------------------------
1611 Trace.TraceInformation("----------------------");
1612 Trace.TraceInformation("■ 選曲");
1614 r直前のステージ = r現在のステージ;
1617 foreach (STPlugin pg in this.listプラグイン)
1619 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1620 pg.plugin.Onステージ変更();
1621 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1624 this.tガベージコレクションを実行する();
1626 //-----------------------------
1630 //-----------------------------
1634 case CStage.Eステージ.選曲:
1636 //-----------------------------
1637 switch (this.n進行描画の戻り値)
1639 case (int)CStage選曲.E戻り値.タイトルに戻る:
1641 //-----------------------------
1643 Trace.TraceInformation("----------------------");
1644 Trace.TraceInformation("■ タイトル");
1646 r直前のステージ = r現在のステージ;
1647 r現在のステージ = stageタイトル;
1649 foreach (STPlugin pg in this.listプラグイン)
1651 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1652 pg.plugin.Onステージ変更();
1653 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1656 this.tガベージコレクションを実行する();
1658 //-----------------------------
1661 case (int)CStage選曲.E戻り値.選曲した:
1663 //-----------------------------
1665 Trace.TraceInformation("----------------------");
1666 Trace.TraceInformation("■ 曲読み込み");
1668 r直前のステージ = r現在のステージ;
1669 r現在のステージ = stage曲読み込み;
1671 foreach (STPlugin pg in this.listプラグイン)
1673 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1674 pg.plugin.Onステージ変更();
1675 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1678 this.tガベージコレクションを実行する();
1680 //-----------------------------
1683 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1685 //-----------------------------
1687 Trace.TraceInformation("----------------------");
1688 Trace.TraceInformation("■ コンフィグ");
1690 r直前のステージ = r現在のステージ;
1691 r現在のステージ = stageコンフィグ;
1693 foreach (STPlugin pg in this.listプラグイン)
1695 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1696 pg.plugin.Onステージ変更();
1697 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1700 this.tガベージコレクションを実行する();
1702 //-----------------------------
1705 case (int)CStage選曲.E戻り値.スキン変更:
1708 //-----------------------------
1710 Trace.TraceInformation("----------------------");
1711 Trace.TraceInformation("■ スキン切り替え");
1712 stageChangeSkin.On活性化();
1713 r直前のステージ = r現在のステージ;
1714 r現在のステージ = stageChangeSkin;
1716 //-----------------------------
1719 //-----------------------------
1723 case CStage.Eステージ.曲読み込み:
1725 //-----------------------------
1726 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1727 if (this.n進行描画の戻り値 != 0)
1729 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1731 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1732 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1736 Trace.TraceInformation("曲の読み込みを中止しました。");
1737 this.tガベージコレクションを実行する();
1738 Trace.TraceInformation("----------------------");
1739 Trace.TraceInformation("■ 選曲");
1741 r直前のステージ = r現在のステージ;
1743 foreach (STPlugin pg in this.listプラグイン)
1745 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1746 pg.plugin.Onステージ変更();
1747 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1753 Trace.TraceInformation("----------------------");
1754 Trace.TraceInformation("■ 演奏(ドラム画面)");
1755 r直前のステージ = r現在のステージ;
1756 r現在のステージ = stage演奏画面;
1758 foreach (STPlugin pg in this.listプラグイン)
1760 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1761 pg.plugin.Onステージ変更();
1762 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1765 this.tガベージコレクションを実行する();
1767 //-----------------------------
1771 case CStage.Eステージ.演奏:
1773 //-----------------------------
1774 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1775 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1776 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1777 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1778 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1780 //swlist1.Add( Convert.ToInt32(n1) );
1781 //swlist2.Add( Convert.ToInt32(n2) );
1782 //swlist3.Add( Convert.ToInt32( n3 ) );
1783 //swlist4.Add( Convert.ToInt32( n4 ) );
1784 //swlist5.Add( Convert.ToInt32( n5 ) );
1786 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1787 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1789 DTXVmode.Refreshed = false;
1791 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1793 CDTXMania.Instance.stage演奏画面.t停止();
1795 if (previewSound != null)
1797 this.previewSound.tサウンドを停止する();
1798 this.previewSound.Dispose();
1799 this.previewSound = null;
1804 // for ( int i = 0; i < swlist1.Count; i++ )
1806 // int d1 = swlist1[ i ];
1807 // int d2 = swlist2[ i ];
1808 // int d3 = swlist3[ i ];
1809 // int d4 = swlist4[ i ];
1810 // int d5 = swlist5[ i ];
1812 // int dif = d1 - lastd;
1814 // if ( 16 <= dif && dif <= 17 )
1821 // 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 );
1833 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1835 if (DTXVmode.NeedReload)
1837 CDTXMania.Instance.stage演奏画面.t再読込();
1838 if (DTXVmode.GRmode)
1840 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1844 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1846 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1847 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1848 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1850 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1851 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1856 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1862 switch (this.n進行描画の戻り値)
1864 case (int)E演奏画面の戻り値.再読込_再演奏:
1865 #region [ DTXファイルを再読み込みして、再演奏 ]
1870 r直前のステージ = r現在のステージ;
1871 r現在のステージ = stage曲読み込み;
1872 this.tガベージコレクションを実行する();
1876 //case (int) E演奏画面の戻り値.再演奏:
1877 #region [ 再読み込み無しで、再演奏 ]
1881 case (int)E演奏画面の戻り値.継続:
1884 case (int)E演奏画面の戻り値.演奏中断:
1886 //-----------------------------
1887 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1888 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1890 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1895 //for (int i = 0; i < swlist1.Count; i++)
1897 // int d1 = swlist1[ i ];
1898 // int d2 = swlist2[ i ];
1899 // int d3 = swlist3[ i ];
1900 // int d4 = swlist4[ i ];
1902 // int dif = d1 - lastd;
1904 // if ( 16 <= dif && dif <= 17 )
1911 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1920 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1921 //---------------------
1922 foreach (STPlugin pg in this.listプラグイン)
1924 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1925 pg.plugin.On演奏キャンセル(scoreIni);
1926 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1928 //---------------------
1934 if (DTX2WAVmode.Enabled)
1936 Environment.Exit(0);
1940 base.Window.Close();
1944 Trace.TraceInformation("----------------------");
1945 Trace.TraceInformation("■ 選曲");
1947 r直前のステージ = r現在のステージ;
1950 #region [ プラグイン Onステージ変更() の呼び出し ]
1951 //---------------------
1952 foreach (STPlugin pg in this.listプラグイン)
1954 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1955 pg.plugin.Onステージ変更();
1956 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1958 //---------------------
1961 this.tガベージコレクションを実行する();
1964 //-----------------------------
1967 case (int)E演奏画面の戻り値.ステージ失敗:
1968 #region [ 演奏失敗(StageFailed) ]
1969 //-----------------------------
1970 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1972 #region [ プラグイン On演奏失敗() の呼び出し ]
1973 //---------------------
1974 foreach (STPlugin pg in this.listプラグイン)
1976 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1977 pg.plugin.On演奏失敗(scoreIni);
1978 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1980 //---------------------
1988 base.Window.Close();
1992 Trace.TraceInformation("----------------------");
1993 Trace.TraceInformation("■ 選曲");
1995 r直前のステージ = r現在のステージ;
1998 #region [ プラグイン Onステージ変更() の呼び出し ]
1999 //---------------------
2000 foreach (STPlugin pg in this.listプラグイン)
2002 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2003 pg.plugin.Onステージ変更();
2004 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2006 //---------------------
2009 this.tガベージコレクションを実行する();
2012 //-----------------------------
2015 case (int)E演奏画面の戻り値.ステージクリア:
2017 //-----------------------------
2018 STDGBSValue<CScoreIni.C演奏記録> record;
2019 record = stage演奏画面.Record;
2021 double playskill = 0.0;
2023 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
2025 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
2027 playskill = record[inst].db演奏型スキル値;
2031 string str = "Cleared";
2032 switch (CScoreIni.t総合ランク値を計算して返す(record))
2034 case CScoreIni.ERANK.SS:
2035 str = string.Format("Cleared (SS: {0:F2})", playskill);
2038 case CScoreIni.ERANK.S:
2039 str = string.Format("Cleared (S: {0:F2})", playskill);
2042 case CScoreIni.ERANK.A:
2043 str = string.Format("Cleared (A: {0:F2})", playskill);
2046 case CScoreIni.ERANK.B:
2047 str = string.Format("Cleared (B: {0:F2})", playskill);
2050 case CScoreIni.ERANK.C:
2051 str = string.Format("Cleared (C: {0:F2})", playskill);
2054 case CScoreIni.ERANK.D:
2055 str = string.Format("Cleared (D: {0:F2})", playskill);
2058 case CScoreIni.ERANK.E:
2059 str = string.Format("Cleared (E: {0:F2})", playskill);
2062 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
2063 str = "Cleared (No chips)";
2067 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
2069 #region [ プラグイン On演奏クリア() の呼び出し ]
2070 //---------------------
2071 foreach (STPlugin pg in this.listプラグイン)
2073 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2074 pg.plugin.On演奏クリア(scoreIni);
2075 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2077 //---------------------
2081 Trace.TraceInformation("----------------------");
2082 Trace.TraceInformation("■ 結果");
2083 stage結果.st演奏記録 = record;
2084 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
2086 r直前のステージ = r現在のステージ;
2089 #region [ プラグイン Onステージ変更() の呼び出し ]
2090 //---------------------
2091 foreach (STPlugin pg in this.listプラグイン)
2093 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2094 pg.plugin.Onステージ変更();
2095 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2097 //---------------------
2101 //-----------------------------
2104 //-----------------------------
2108 case CStage.Eステージ.結果:
2110 //-----------------------------
2111 if (this.n進行描画の戻り値 != 0)
2113 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2114 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2115 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2117 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
2125 Trace.TraceInformation("----------------------");
2126 Trace.TraceInformation("■ 選曲");
2128 r直前のステージ = r現在のステージ;
2131 foreach (STPlugin pg in this.listプラグイン)
2133 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2134 pg.plugin.Onステージ変更();
2135 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2138 this.tガベージコレクションを実行する();
2142 base.Window.Close();
2145 //-----------------------------
2149 case CStage.Eステージ.ChangeSkin:
2151 //-----------------------------
2152 if (this.n進行描画の戻り値 != 0)
2155 Trace.TraceInformation("----------------------");
2156 Trace.TraceInformation("■ 選曲");
2158 r直前のステージ = r現在のステージ;
2160 this.tガベージコレクションを実行する();
2162 //-----------------------------
2166 case CStage.Eステージ.終了:
2168 //-----------------------------
2169 if (this.n進行描画の戻り値 != 0)
2173 //-----------------------------
2178 this.Device.EndScene();
2179 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2180 // (つまり、Present()は、Draw()完了後に実行される)
2181 #if !GPUFlushAfterPresent
2182 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2184 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2186 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2189 #region [ マウスカーソル消去制御 ]
2190 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2192 #region [ 全画面・ウインドウ切り替え ]
2193 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2195 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2196 Instance.t全画面_ウィンドウモード切り替え();
2197 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2200 #region [ 垂直基線同期切り替え ]
2201 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2203 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2204 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2205 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2206 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2207 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2208 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2209 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2212 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2217 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2218 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2223 /// XML ファイルからオブジェクトを生成します。
2225 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2226 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2227 public static object DeserializeXML(string xmlpath, Type t)
2232 if (File.Exists(xmlpath))
2234 using (StreamReader reader = new StreamReader(xmlpath, Encoding.GetEncoding("shift_jis")))
2235 using (XmlReader xr = XmlReader.Create(reader))
2237 DataContractSerializer serializer = new DataContractSerializer(t);
2238 ret = serializer.ReadObject(xr);
2244 Trace.TraceWarning( e.Message );
2251 /// オブジェクトから XML ファイルを生成します。
2253 /// <param name="xmlfile">XML ファイルのパス。</param>
2254 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2255 public static void SerializeXML(string xmlpath, object obj)
2257 XmlWriterSettings settings = new XmlWriterSettings();
2258 settings.IndentChars = " ";
2259 settings.Indent = true;
2260 settings.NewLineChars = Environment.NewLine;
2261 settings.Encoding = new System.Text.UTF8Encoding(false);
2262 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2264 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2266 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2267 serializer.WriteObject(xw, obj);
2272 public void SaveConfig()
2274 #region [ Skinパスの絶対パス→相対パス変換 ]
2275 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2276 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2277 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2279 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2280 // → 初期値として Default/ を設定する。
2281 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2284 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2285 // そのため、以下の処理を通すために、いったん絶対パスに変換
2286 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2288 ConfigIni.strSystemSkinSubfolderPath.Value =
2289 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2292 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2293 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2294 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2295 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2296 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2298 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2300 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2303 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2306 public void LoadConfig()
2308 string path = strEXEのあるフォルダ + "Config.xml";
2310 if (!File.Exists(path))
2314 if (File.Exists(path))
2316 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2317 if (ConfigIni == null)
2319 ConfigIni = new CConfigXml();
2322 // Skinパスの相対パスを、絶対パスに変換
2323 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2325 ConfigIni.strSystemSkinSubfolderPath.Value =
2326 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2330 ConfigIni.UpgradeConfig(); // 本体version upに伴ってConfig.xmlの定義が更新される場合の、最低限のフォローアップ
2333 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2335 public void UpdateCoordinates()
2337 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2340 if (File.Exists(coordXml))
2342 using (XmlReader xr = XmlReader.Create(coordXml))
2344 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2347 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2349 catch (SerializationException e)
2351 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2356 XmlWriterSettings settings = new XmlWriterSettings();
2357 settings.IndentChars = " ";
2358 settings.Indent = true;
2359 settings.NewLineChars = Environment.NewLine;
2360 settings.Encoding = new System.Text.UTF8Encoding( false );
2361 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2363 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2364 //ns.Add( String.Empty, String.Empty );
2366 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2367 //serializer.Serialize( sw, item, ns );
2370 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2371 serializer.WriteObject( xw, Coordinates );
2372 //serializer.WriteStartObject( xw, Coordinates );
2373 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2374 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2375 //serializer.WriteObjectContent( xw, Coordinates );
2376 //serializer.WriteEndObject( xw );
2380 if (File.Exists(coordXml))
2382 using (XmlReader xr = XmlReader.Create(coordXml))
2384 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2385 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2392 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2394 //public class MyXmlTextWriter : XmlTextWriter
2396 // private bool _ignoreAttr = false;
2398 // public MyXmlTextWriter( TextWriter w )
2401 // Debug.WriteLine( "create" );
2404 // public override string LookupPrefix( string ns )
2406 // Debug.WriteLine( "luprefix" );
2407 // return string.Empty;
2410 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2412 // Debug.WriteLine( "writestartattribute" );
2413 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2415 // Debug.WriteLine( "[!]" );
2416 // this._ignoreAttr = true;
2421 // public override void WriteEndAttribute()
2423 // if ( this._ignoreAttr )
2425 // this._ignoreAttr = false;
2428 // base.WriteEndAttribute();
2431 // public override void WriteString( string text )
2433 // Debug.WriteLine( "ws" );
2434 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2438 // base.WriteString( text );
2441 // public override void WriteStartElement( string prefix, string localName, string ns )
2443 // Debug.WriteLine( "wse" );
2444 // base.WriteStartElement( null, localName, null );
2448 public void ShowWindowTitleWithSoundType()
2451 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2453 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2455 base.Window.Text = strWindowTitle;
2456 if (!this.DTX2WAVmode.Enabled)
2458 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2464 private bool b終了処理完了済み;
2465 private static CDTX dtx;
2466 private List<CActivity> listトップレベルActivities;
2467 private int n進行描画の戻り値;
2468 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2469 private string strWindowTitle
2473 string strCPUmode = (Environment.Is64BitProcess) ? " [x64]" : " [x86]";
2475 if (DTXVmode.Enabled)
2477 return "DTXMViewer release " + VERSION + strCPUmode;
2479 else if (DTX2WAVmode.Enabled)
2481 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename) + strCPUmode;
2485 return "DTXMania .NET style release " + VERSION + strCPUmode;
2489 private CSound previewSound;
2490 private CMouseHideControl cMouseHideControl = null;
2492 private void t終了処理()
2494 if (!this.b終了処理完了済み)
2496 Trace.TraceInformation("----------------------");
2497 Trace.TraceInformation("■ アプリケーションの終了");
2499 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2501 #region [ 曲検索の終了処理 ]
2502 //---------------------
2503 if (actEnumSongs != null)
2505 Trace.TraceInformation("曲検索actの終了処理を行います。");
2509 actEnumSongs.On非活性化();
2510 actEnumSongs = null;
2511 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2515 Trace.TraceError(e.Message);
2516 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2523 //---------------------
2525 #region [ 現在のステージの終了処理 ]
2526 //---------------------
2527 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2529 Trace.TraceInformation("現在のステージを終了します。");
2534 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2541 //---------------------
2544 #region [ 選曲ステージの終了処理 ]
2548 #region [ プラグインの終了処理 ]
2549 //---------------------
2550 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2552 Trace.TraceInformation("すべてのプラグインを終了します。");
2556 foreach (STPlugin st in this.listプラグイン)
2558 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2559 st.plugin.OnUnmanagedリソースの解放();
2560 st.plugin.OnManagedリソースの解放();
2562 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2565 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2572 //---------------------
2574 #region [ 曲リストの終了処理 ]
2575 //---------------------
2576 if (Songs管理 != null)
2578 Trace.TraceInformation("曲リストの終了処理を行います。");
2583 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2585 catch (Exception exception)
2587 Trace.TraceError(exception.Message);
2588 Trace.TraceError("曲リストの終了処理に失敗しました。");
2596 //---------------------
2598 #region [ スキンの終了処理 ]
2599 //---------------------
2602 Trace.TraceInformation("スキンの終了処理を行います。");
2608 Trace.TraceInformation("スキンの終了処理を完了しました。");
2610 catch (Exception exception2)
2612 Trace.TraceError(exception2.Message);
2613 Trace.TraceError("スキンの終了処理に失敗しました。");
2620 //---------------------
2622 #region [ DirectSoundの終了処理 ]
2623 //---------------------
2624 if (Sound管理 != null)
2626 Trace.TraceInformation("DirectSound の終了処理を行います。");
2632 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2634 catch (Exception exception3)
2636 Trace.TraceError(exception3.Message);
2637 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2644 //---------------------
2646 #region [ パッドの終了処理 ]
2647 //---------------------
2650 Trace.TraceInformation("パッドの終了処理を行います。");
2655 Trace.TraceInformation("パッドの終了処理を完了しました。");
2657 catch (Exception exception4)
2659 Trace.TraceError(exception4.Message);
2660 Trace.TraceError("パッドの終了処理に失敗しました。");
2667 //---------------------
2669 #region [ DirectInput, MIDI入力の終了処理 ]
2670 //---------------------
2671 if (Input管理 != null)
2673 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2679 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2681 catch (Exception exception5)
2683 Trace.TraceError(exception5.Message);
2684 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2691 //---------------------
2693 #region [ 文字コンソールの終了処理 ]
2694 //---------------------
2695 if (act文字コンソール != null)
2697 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2701 act文字コンソール.On非活性化();
2703 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2705 catch (Exception exception6)
2707 Trace.TraceError(exception6.Message);
2708 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2715 //---------------------
2717 #region [ FPSカウンタの終了処理 ]
2718 //---------------------
2719 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2727 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2733 //---------------------
2735 #region [ タイマの終了処理 ]
2736 //---------------------
2737 Trace.TraceInformation("タイマの終了処理を行います。");
2745 Trace.TraceInformation("タイマの終了処理を完了しました。");
2749 Trace.TraceInformation("タイマは使用されていません。");
2756 //---------------------
2758 #region [ Config.iniの出力 ]
2759 //---------------------
2760 Trace.TraceInformation("Config.xml を出力します。");
2761 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2762 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2764 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2767 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2769 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2772 string str = strEXEのあるフォルダ + "Config.xml";
2776 if (DTXVmode.Enabled)
2778 DTXVmode.tUpdateConfigIni();
2779 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2781 else if (DTX2WAVmode.Enabled)
2783 DTX2WAVmode.tUpdateConfigIni();
2784 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2785 DTX2WAVmode.SendMessage2DTX2WAV("TERM");
2789 CDTXMania.Instance.SaveConfig();
2790 Trace.TraceInformation("保存しました。({0})", str);
2795 Trace.TraceError(e.Message);
2796 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2802 //---------------------
2804 #region [ DTXVmodeの終了処理 ]
2805 //---------------------
2806 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2810 if (DTXVmode != null)
2813 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2817 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2824 //---------------------
2826 #region [ DirectXの終了処理 ]
2827 //---------------------
2828 base.GraphicsDeviceManager.Dispose();
2829 //---------------------
2831 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2834 this.b終了処理完了済み = true;
2837 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2839 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2840 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2841 CScoreIni ini = new CScoreIni(strFilename);
2842 if (!File.Exists(strFilename))
2844 ini.stファイル.Title = DTX.TITLE;
2845 ini.stファイル.Name = DTX.strファイル名;
2846 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2847 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2849 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2850 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2851 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2852 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2854 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2855 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2856 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2857 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2859 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2860 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2861 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2862 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2865 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2866 isUpdated = CScoreIni.t更新条件を取得する();
2867 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2869 if (isUpdated.Drums)
2871 ini.stファイル.PlayCountDrums++;
2873 if (isUpdated.Guitar)
2875 ini.stファイル.PlayCountGuitar++;
2879 ini.stファイル.PlayCountBass++;
2881 ini.tヒストリを追加する(str新ヒストリ行);
2884 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2885 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2886 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2887 for (int j = 0; j < ini.stファイル.History.Length; j++)
2889 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2893 if (ConfigIni.bScoreIni)
2895 ini.t書き出し(strFilename);
2900 private void tガベージコレクションを実行する()
2902 // LOHに対するコンパクションを要求
2903 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
2905 GC.Collect(0, GCCollectionMode.Optimized, true );
2906 GC.WaitForPendingFinalizers();
2907 GC.Collect(0, GCCollectionMode.Forced, true );
2908 GC.WaitForPendingFinalizers();
2911 GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default;
2913 private void tプラグイン検索と生成()
2915 this.listプラグイン = new List<STPlugin>();
2917 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2918 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2920 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2922 if (this.listプラグイン.Count > 0)
2923 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2926 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2928 var domain = (AppDomain)sender;
2930 foreach (var assembly in domain.GetAssemblies())
2932 if (assembly.FullName == args.Name)
2937 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2939 // 指定されたパスが存在しないとエラー
2940 if (!Directory.Exists(strプラグインフォルダパス))
2942 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2946 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2949 // (1) すべての *.dll について…
2950 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2951 foreach (string dllName in strDLLs)
2953 if (Path.GetExtension(dllName).ToLower() != ".dll")
2959 // (1-1) dll をアセンブリとして読み込む。
2960 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2962 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2963 foreach (Type t in asm.GetTypes())
2965 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2966 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2968 // (1-4) クラス名からインスタンスを作成する
2969 var st = new STPlugin()
2971 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2972 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2973 strアセンブリ簡易名 = asm.GetName().Name,
2974 Version = asm.GetName().Version,
2977 // (1-5) プラグインリストへ登録
2978 this.listプラグイン.Add(st);
2979 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2983 catch (System.Reflection.ReflectionTypeLoadException e)
2985 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2986 Trace.TraceInformation(e.ToString());
2987 Trace.TraceInformation(e.Message);
2989 StringBuilder sb = new StringBuilder();
2990 foreach (Exception exSub in e.LoaderExceptions)
2992 sb.AppendLine(exSub.Message);
2993 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2994 if (exFileNotFound != null)
2996 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2998 sb.AppendLine("Fusion Log:");
2999 sb.AppendLine(exFileNotFound.FusionLog);
3004 string errorMessage = sb.ToString();
3005 //Display or log the error based on your application.
3006 Trace.TraceInformation(errorMessage);
3011 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
3012 Trace.TraceInformation(e.ToString());
3013 Trace.TraceInformation(e.Message);
3017 // (2) サブフォルダがあれば再帰する
3018 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
3019 foreach (string dir in strDirs)
3020 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
3023 #region [ Windowイベント処理 ]
3024 private void Window_ApplicationActivated( object sender, EventArgs e )
3026 this.bApplicationActive = true;
3028 private void Window_ApplicationDeactivated(object sender, EventArgs e)
3030 this.bApplicationActive = false;
3031 if (cMouseHideControl != null) cMouseHideControl.Show();
3033 private void Window_KeyDown(object sender, KeyEventArgs e)
3035 if (e.KeyCode == Keys.Menu)
3038 e.SuppressKeyPress = true;
3040 else if ((e.KeyCode == Keys.Return) && e.Alt)
3042 if (ConfigIni != null)
3044 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3045 this.t全画面_ウィンドウモード切り替え();
3048 e.SuppressKeyPress = true;
3052 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
3054 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
3056 if( (int) captureCode > 0 &&
3057 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
3059 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
3060 string strFullPath =
3061 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
3062 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
3063 SaveResultScreen( strFullPath );
3068 private void Window_MouseUp(object sender, MouseEventArgs e)
3072 private void Window_MouseDown(object sender, MouseEventArgs e)
3074 currentMousePosition.X = Control.MousePosition.X;
3075 currentMousePosition.Y = Control.MousePosition.Y;
3078 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
3080 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
3082 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
3083 this.t全画面_ウィンドウモード切り替え();
3086 private Point currentMousePosition = new Point(-1,-1);
3087 private void Window_MouseMove(object sender, MouseEventArgs e)
3089 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
3090 if (Control.MouseButtons.HasFlag(MouseButtons.Left))
3092 int X = base.Window.Location.X;
3093 X += (Control.MousePosition.X - currentMousePosition.X);
3094 int Y = base.Window.Location.Y;
3095 Y += (Control.MousePosition.Y - currentMousePosition.Y);
3097 base.Window.Location = new Point(X, Y);
3099 currentMousePosition.X = Control.MousePosition.X;
3100 currentMousePosition.Y = Control.MousePosition.Y;
3103 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
3105 if (ConfigIni.bウィンドウモード)
3107 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
3108 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
3111 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
3112 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
3116 //Stopwatch sw = new Stopwatch();
3117 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
3121 private class CMouseHideControl
3123 private Point lastPosition;
3124 private CCounter ccMouseShow;
3125 private bool bマウスカーソル表示中;
3130 public CMouseHideControl()
3132 ccMouseShow = new CCounter();
3133 lastPosition = Cursor.Position;
3140 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3143 public void tHideCursorIfNeed()
3146 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3147 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3149 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3150 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
3158 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3160 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3161 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3163 Point currentPosition = Cursor.Position;
3164 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3165 if (lastPosition != currentPosition)
3167 //Trace.TraceInformation("移動発生");
3168 lastPosition = currentPosition;
3183 bマウスカーソル表示中 = false;