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;
18 using Point = System.Drawing.Point;
19 using Color = System.Drawing.Color;
23 internal class CDTXMania : Game
26 #region [ properties ]
27 public static readonly string VERSION = "112(180201)";
28 public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
29 public static readonly string D3DXDLL = "d3dx9_43.dll"; // June 2010
30 //public static readonly string D3DXDLL = "d3dx9_42.dll"; // February 2010
31 //public static readonly string D3DXDLL = "d3dx9_41.dll"; // March 2009
32 private static CDTXMania instance = new CDTXMania();
34 public static CDTXMania Instance
41 public C文字コンソール act文字コンソール { get; private set; }
42 public bool bコンパクトモード { get; private set; }
43 public CConfigXml ConfigIni;
44 public CResources Resources;
54 if ((dtx != null) && (Instance != null))
57 Instance.listトップレベルActivities.Remove(dtx);
60 if ((dtx != null) && (Instance != null))
62 Instance.listトップレベルActivities.Add(dtx);
66 public CFPS FPS { get; private set; }
67 public CInput管理 Input管理 { get; private set; }
69 public int nPerfect範囲ms
73 if (stage選曲.r確定された曲 != null)
75 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
76 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPerfect範囲ms >= 0))
78 return c曲リストノード.nPerfect範囲ms;
81 return ConfigIni.nHitRange.Perfect;
88 if (stage選曲.r確定された曲 != null)
90 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
91 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGreat範囲ms >= 0))
93 return c曲リストノード.nGreat範囲ms;
96 return ConfigIni.nHitRange.Great;
103 if (stage選曲.r確定された曲 != null)
105 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
106 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGood範囲ms >= 0))
108 return c曲リストノード.nGood範囲ms;
111 return ConfigIni.nHitRange.Good;
118 if (stage選曲.r確定された曲 != null)
120 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
121 if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPoor範囲ms >= 0))
123 return c曲リストノード.nPoor範囲ms;
126 return ConfigIni.nHitRange.Poor;
130 public CPad Pad { get; private set; }
131 public Random Random { get; private set; }
132 public CSkin Skin { get; private set; }
133 public CSongs管理 Songs管理 { get; set; }// 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
134 public CEnumSongs EnumSongs { get; private set; }
135 public CActEnumSongs actEnumSongs { get; private set; }
136 public CActFlushGPU actFlushGPU { get; private set; }
138 public CSound管理 Sound管理 { get; private set; }
139 public CStage起動 stage起動 { 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 CStageChangeSkin stageChangeSkin { get; private set; }
147 public CStage終了 stage終了 { get; private set; }
148 public CStage r現在のステージ = null;
149 public CStage r直前のステージ = null;
150 public CStage r1フレーム前のステージ = null;
151 public string strEXEのあるフォルダ { get; private set; }
152 public string strコンパクトモードファイル { get; private set; }
153 public CTimer Timer { get; private set; }
154 public Format TextureFormat = Format.A8R8G8B8;
155 internal IPluginActivity act現在入力を占有中のプラグイン = null;
156 public bool bApplicationActive { get; private set; }
157 public bool b次のタイミングで垂直帰線同期切り替えを行う { get; set; }
158 public bool b次のタイミングで全画面_ウィンドウ切り替えを行う { get; set; }
159 public Coordinates.CCoordinates Coordinates;
164 return base.GraphicsDeviceManager.Direct3D9.Device;
167 public CPluginHost PluginHost { get; private set; }
168 public List<STPlugin> listプラグイン = new List<STPlugin>();
170 private Size currentClientSize { get; set; } // #23510 2010.10.27 add yyagi to keep current window size
171 // public static CTimer ct;
172 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
176 return base.Window.Handle;
179 public CDTXVmode DTXVmode; // #28821 2014.1.23 yyagi
180 public CDTX2WAVmode DTX2WAVmode;
181 public CCommandParse CommandParse;
190 public void InitializeInstance()
192 #region [ strEXEのあるフォルダを決定する ]
193 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
195 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
196 //strEXEのあるフォルダ = Path.GetDirectoryName( Environment.GetCommandLineArgs()[ 0 ] ) + @"\";
198 strEXEのあるフォルダ = Path.GetDirectoryName(Application.ExecutablePath) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
200 // END #23629 2010.11.13 from
203 #region [ 言語リソースの初期化 ]
204 Trace.TraceInformation("言語リソースの初期化を行います。");
208 Resources = new CResources();
209 Resources.LoadResources("");
210 Trace.TraceInformation("言語リソースの初期化を完了しました。");
218 #region [ Config.ini の読込み ]
219 ConfigIni = new CConfigXml();
220 CDTXMania.Instance.LoadConfig();
221 // #28200 2011.5.1 yyagi
222 this.Window.EnableSystemMenu = CDTXMania.Instance.ConfigIni.bIsEnabledSystemMenu;
223 // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
228 Coordinates = new Coordinates.CCoordinates();
230 //Coordinates = (DTXMania.Coordinates.CCoordinates) CDTXMania.DeserializeXML( strEXEのあるフォルダ + "Coordinates.xml", typeof( DTXMania.Coordinates.CCoordinates ) );
231 //if ( Coordinates == null )
233 // if ( File.Exists( strEXEのあるフォルダ + "Coordinates.xml" ) )
235 // Trace.TraceInformation( "Coordinates.xmlファイルは存在します。" );
237 // Trace.TraceInformation( "Coordiantes.xmlファイルの読み込みができませんでした。無視して進めます。" );
238 // Coordinates = new Coordinates.CCoordinates();
243 Trace.AutoFlush = true;
248 Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "DTXManiaLog.txt"), false, Encoding.GetEncoding("utf-16"))));
250 catch (System.UnauthorizedAccessException) // #24481 2011.2.20 yyagi
252 Resources.Language = instance.ConfigIni.strLanguage;
253 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
254 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
259 Trace.WriteLine("DTXMania powered by YAMAHA Silent Session Drums");
260 Trace.WriteLine(string.Format("Release: {0}", VERSION));
262 Trace.TraceInformation("----------------------");
263 Trace.TraceInformation("■ アプリケーションの初期化");
271 Trace.TraceInformation("言語情報の読み込みを開始します。");
272 //Debug.WriteLine( "language=" + Resources.Language );
273 //Debug.WriteLine( "settings=" + instance.ConfigIni.strLanguage );
274 Resources.Language = instance.ConfigIni.strLanguage;
275 Trace.TraceInformation("言語を{0}に設定しました。", Resources.Language);
279 #region [ DTXVmodeクラス, DTX2WAVmodeクラス, CommandParseクラス の初期化 ]
280 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
284 DTXVmode = new CDTXVmode();
285 DTXVmode.Enabled = false;
286 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
288 DTX2WAVmode = new CDTX2WAVmode();
289 //Trace.TraceInformation( "DTX2WAVモードの初期化を完了しました。" );
291 CommandParse = new CCommandParse();
292 //Trace.TraceInformation( "CommandParseの初期化を完了しました。" );
299 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewer/DTX2WAVとしての起動 ]
301 strコンパクトモードファイル = "";
302 string[] commandLineArgs = Environment.GetCommandLineArgs();
303 if ((commandLineArgs != null) && (commandLineArgs.Length > 1))
308 for (int i = 1; i < commandLineArgs.Length; i++)
312 arg += " " + "\"" + commandLineArgs[i] + "\"";
316 arg += commandLineArgs[i];
319 CommandParse.ParseArguments(arg, ref DTXVmode, ref DTX2WAVmode);
320 if (DTXVmode.Enabled)
322 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
323 strコンパクトモードファイル = DTXVmode.filename;
324 switch (DTXVmode.soundDeviceType) // サウンド再生方式の設定
326 case ESoundDeviceType.DirectSound:
327 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.DSound;
329 case ESoundDeviceType.ExclusiveWASAPI:
330 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
332 case ESoundDeviceType.SharedWASAPI:
333 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
335 case ESoundDeviceType.ASIO:
336 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.ASIO;
337 ConfigIni.strASIODevice.Index = DTXVmode.nASIOdevice;
341 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
342 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
345 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
349 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
352 CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
353 CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow; // #36612 2016.9.12 yyagi
354 CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
355 CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
356 CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
357 CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
359 else if (DTX2WAVmode.Enabled)
361 strコンパクトモードファイル = DTX2WAVmode.dtxfilename;
362 #region [ FDKへの録音設定 ]
363 FDK.CSound管理.strRecordInputDTXfilename = DTX2WAVmode.dtxfilename;
364 FDK.CSound管理.strRecordOutFilename = DTX2WAVmode.outfilename;
365 FDK.CSound管理.strRecordFileType = DTX2WAVmode.Format.ToString();
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);
547 foreach (IInputDevice device in Input管理.list入力デバイス)
549 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
552 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
556 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
559 foreach (IInputDevice device2 in Input管理.list入力デバイス)
561 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
563 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
565 if (device2.GUID.Equals(pair.Value))
567 ((CInputJoystick)device2).SetID(pair.Key);
574 Trace.TraceInformation("DirectInput の初期化を完了しました。");
576 catch (Exception exception2)
578 Trace.TraceError(exception2.Message);
579 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
581 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
582 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
592 // #30675 2013.02.04 ikanick add
593 base.Window.StartPosition = FormStartPosition.Manual;
594 base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
595 // 事前にDTXVmodeの実体を作っておくこと
596 base.Window.Text = this.strWindowTitle;
597 //base.Window.StartPosition = FormStartPosition.Manual;
598 //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
600 // #34510 yyagi 2010.10.31 to change window size got from Config.ini
601 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
602 #if !WindowedFullscreen
603 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
604 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
606 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
607 #if !WindowedFullscreen
610 // #23510 2010.11.04 yyagi: to support maximizing window
611 base.Window.MaximizeBox = true;
612 // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
613 base.Window.FormBorderStyle = FormBorderStyle.Sizable;
614 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
615 base.Window.ShowIcon = true;
616 base.Window.Icon = Properties.Resources.dtx;
617 base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
618 base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
619 // #23510 2010.11.13 yyagi: to go fullscreen mode
620 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
621 // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
622 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
623 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
624 base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
625 base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
628 #region [ Direct3D9Exを使うかどうか判定 ]
631 #region [ Direct3D9 デバイスの生成 ]
632 DeviceSettings settings = new DeviceSettings();
633 #if WindowedFullscreen
634 // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
635 settings.Windowed = true;
637 settings.Windowed = ConfigIni.bウィンドウモード;
639 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
640 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
641 settings.EnableVSync = ConfigIni.bVSyncWait;
642 //settings.MultisampleType = MultisampleType.FourSamples;
643 //settings.MultisampleQuality = 3;
644 //settings.MultisampleType = MultisampleType.NonMaskable;
645 //settings.Multithreaded = true;
650 base.GraphicsDeviceManager.ChangeDevice(settings);
652 catch (DeviceCreationException e)
654 Trace.TraceError(e.ToString());
655 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
656 Environment.Exit(-1);
658 Trace.TraceInformation("DeviceCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
659 Trace.TraceInformation("DeviceCaps2 = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
660 Trace.TraceInformation("MaxTextureWidth = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
661 Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
662 Trace.TraceInformation("TextureCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
663 Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
664 Trace.TraceInformation("DeviceStatics = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
666 base.IsFixedTimeStep = false;
667 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
668 // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
669 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
670 // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
671 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
672 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
673 #if WindowedFullscreen
674 // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
675 this.t全画面_ウィンドウモード切り替え();
677 actFlushGPU = new CActFlushGPU();
680 if (DTX2WAVmode.Enabled)
682 this.Window.WindowState = FormWindowState.Minimized; //DTX2WAVモード時は自動的に最小化
687 #region [ Skin の初期化 ]
688 Trace.TraceInformation("スキンの初期化を行います。");
693 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
694 CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
695 // 旧指定のSkinフォルダが消滅していた場合に備える
696 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
697 Trace.TraceInformation("スキンの初期化を完了しました。");
701 Trace.TraceInformation("スキンの初期化に失敗しました。");
709 #region [ Skin配下にある言語リソースの確認と初期化 ]
710 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
714 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
715 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
717 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
720 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
724 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
736 #region [ Timer の初期化 ]
737 Trace.TraceInformation("タイマの初期化を行います。");
741 Timer = new CTimer(CTimer.E種別.MultiMedia);
742 Trace.TraceInformation("タイマの初期化を完了しました。");
750 #region [ マウス消去用のクラスを初期化 ]
751 cMouseHideControl = new CMouseHideControl();
754 #region [ FPS カウンタの初期化 ]
755 Trace.TraceInformation("FPSカウンタの初期化を行います。");
760 Trace.TraceInformation("FPSカウンタを生成しました。");
768 #region [ act文字コンソールの初期化 ]
769 Trace.TraceInformation("文字コンソールの初期化を行います。");
773 act文字コンソール = new C文字コンソール();
774 Trace.TraceInformation("文字コンソールを生成しました。");
776 Trace.TraceInformation("文字コンソールを活性化しました。");
777 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
779 catch (Exception exception)
781 Trace.TraceError(exception.Message);
782 Trace.TraceError("文字コンソールの初期化に失敗しました。");
791 Trace.TraceInformation("パッドの初期化を行います。");
796 Trace.TraceInformation("パッドの初期化を完了しました。");
798 catch (Exception exception3)
800 Trace.TraceError(exception3.Message);
801 Trace.TraceError("パッドの初期化に失敗しました。");
809 #region [ Sound管理 の初期化 ]
810 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
814 ESoundDeviceType soundDeviceType;
815 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
817 case ESoundDeviceTypeForConfig.DSound:
818 soundDeviceType = ESoundDeviceType.DirectSound;
820 case ESoundDeviceTypeForConfig.ASIO:
821 soundDeviceType = ESoundDeviceType.ASIO;
823 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
824 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
826 case ESoundDeviceTypeForConfig.WASAPI_Shared:
827 soundDeviceType = ESoundDeviceType.SharedWASAPI;
830 soundDeviceType = ESoundDeviceType.Unknown;
833 Sound管理 = new CSound管理(base.Window.Handle,
835 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
836 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
838 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
839 CDTXMania.Instance.ConfigIni.bUseOSTimer
841 //Sound管理 = FDK.CSound管理.Instance;
842 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
844 ShowWindowTitleWithSoundType();
845 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
846 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
847 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
848 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
852 Trace.TraceError(e.Message);
861 #region [ Songs管理 の初期化 ]
862 //---------------------
863 Trace.TraceInformation("曲リストの初期化を行います。");
867 Songs管理 = new CSongs管理();
868 // Songs管理_裏読 = new CSongs管理();
869 EnumSongs = new CEnumSongs();
870 actEnumSongs = new CActEnumSongs();
871 Trace.TraceInformation("曲リストの初期化を完了しました。");
875 Trace.TraceError(e.Message);
876 Trace.TraceError("曲リストの初期化に失敗しました。");
882 //---------------------
885 #region [ CAvi の初期化 ]
889 #region [ Random の初期化 ]
890 Random = new Random((int)Timer.nシステム時刻);
896 stage起動 = new CStage起動();
897 stageタイトル = new CStageタイトル();
898 stageコンフィグ = new CStageコンフィグ();
899 stage選曲 = new CStage選曲();
900 stage曲読み込み = new CStage曲読み込み();
901 stage演奏画面 = new CStage演奏画面共通();
902 stage結果 = new CStage結果();
903 stageChangeSkin = new CStageChangeSkin();
904 stage終了 = new CStage終了();
906 this.listトップレベルActivities = new List<CActivity>();
907 this.listトップレベルActivities.Add(actEnumSongs);
908 this.listトップレベルActivities.Add(act文字コンソール);
909 this.listトップレベルActivities.Add(stage起動);
910 this.listトップレベルActivities.Add(stageタイトル);
911 this.listトップレベルActivities.Add(stageコンフィグ);
912 this.listトップレベルActivities.Add(stage選曲);
913 this.listトップレベルActivities.Add(stage曲読み込み);
914 this.listトップレベルActivities.Add(stage演奏画面);
915 this.listトップレベルActivities.Add(stage結果);
916 this.listトップレベルActivities.Add(stageChangeSkin);
917 this.listトップレベルActivities.Add(stage終了);
918 this.listトップレベルActivities.Add(actFlushGPU);
921 #region [ プラグインの検索と生成 ]
922 PluginHost = new CPluginHost();
924 Trace.TraceInformation("プラグインの検索と生成を行います。");
929 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
937 #region [ プラグインの初期化 ]
938 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
940 Trace.TraceInformation("プラグインの初期化を行います。");
944 foreach (STPlugin st in this.listプラグイン)
946 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
947 st.plugin.On初期化(this.PluginHost);
948 st.plugin.OnManagedリソースの作成();
949 st.plugin.OnUnmanagedリソースの作成();
950 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
952 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
956 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
967 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
969 #region [ 最初のステージの起動 ]
970 Trace.TraceInformation("----------------------");
971 Trace.TraceInformation("■ 起動");
973 if (CDTXMania.Instance.bコンパクトモード)
975 r現在のステージ = stage曲読み込み;
986 public void t全画面_ウィンドウモード切り替え()
988 #if WindowedFullscreen
989 if (ConfigIni != null)
991 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
992 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
995 #if !WindowedFullscreen
996 settings.Windowed = ConfigIni.bウィンドウモード;
998 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
1000 currentClientSize = this.Window.ClientSize;
1001 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
1002 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
1003 // FDK.CTaskBar.ShowTaskBar( false );
1005 #if !WindowedFullscreen
1006 base.GraphicsDeviceManager.ChangeDevice( settings );
1008 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
1010 #if WindowedFullscreen
1011 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
1012 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
1013 // in spite of using fullscreen mode.
1014 Instance.Window.WindowState = FormWindowState.Normal;
1015 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1016 Instance.Window.WindowState = FormWindowState.Normal;
1018 base.Window.ClientSize =
1019 new Size(currentClientSize.Width, currentClientSize.Height);
1020 // FDK.CTaskBar.ShowTaskBar( true );
1022 #if WindowedFullscreen
1025 Instance.Window.WindowState = FormWindowState.Normal;
1026 Instance.Window.FormBorderStyle = FormBorderStyle.None;
1027 Instance.Window.WindowState = FormWindowState.Maximized;
1029 if (cMouseHideControl != null)
1031 if (ConfigIni.bウィンドウモード)
1033 cMouseHideControl.Show();
1037 cMouseHideControl.Hide();
1044 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1046 /// リザルト画像のキャプチャと保存。
1048 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1049 public bool SaveResultScreen(string strFullPath)
1051 string strSavePath = Path.GetDirectoryName(strFullPath);
1052 if (!Directory.Exists(strSavePath))
1056 Directory.CreateDirectory(strSavePath);
1064 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1065 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1067 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1075 protected override void Initialize()
1079 //swlist1 = new List<int>( 8192 );
1080 //swlist2 = new List<int>( 8192 );
1081 //swlist3 = new List<int>( 8192 );
1082 //swlist4 = new List<int>( 8192 );
1083 //swlist5 = new List<int>( 8192 );
1084 if (this.listトップレベルActivities != null)
1086 foreach (CActivity activity in this.listトップレベルActivities)
1087 activity.OnManagedリソースの作成();
1090 foreach (STPlugin st in this.listプラグイン)
1092 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1093 st.plugin.OnManagedリソースの作成();
1094 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1096 #if GPUFlushAfterPresent
1097 FrameEnd += dtxmania_FrameEnd;
1100 #if GPUFlushAfterPresent
1101 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1102 { // → Present()直後にGPUをFlushする
1103 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1104 actFlushGPU.On進行描画(); // Flush GPU
1107 protected override void LoadContent()
1109 if (cMouseHideControl != null)
1111 if (ConfigIni.bウィンドウモード)
1113 cMouseHideControl.Show();
1117 cMouseHideControl.Hide();
1120 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)));
1121 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1122 this.Device.SetRenderState(RenderState.Lighting, false);
1123 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1124 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1125 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1126 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1128 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1129 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1130 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1132 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1133 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1134 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1135 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1136 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1137 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1138 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1140 if (this.listトップレベルActivities != null)
1142 foreach (CActivity activity in this.listトップレベルActivities)
1143 activity.OnUnmanagedリソースの作成();
1146 foreach (STPlugin st in this.listプラグイン)
1148 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1149 st.plugin.OnUnmanagedリソースの作成();
1150 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1153 protected override void UnloadContent()
1155 if (this.listトップレベルActivities != null)
1157 foreach (CActivity activity in this.listトップレベルActivities)
1158 activity.OnUnmanagedリソースの解放();
1161 foreach (STPlugin st in this.listプラグイン)
1163 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1164 st.plugin.OnUnmanagedリソースの解放();
1165 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1168 protected override void OnExiting(EventArgs e)
1170 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1174 protected override void Update(GameTime gameTime)
1177 protected override void Draw(GameTime gameTime)
1179 if (Sound管理 == null)
1183 Sound管理.t再生中の処理をする();
1187 if (CSound管理.rc演奏用タイマ != null)
1188 CSound管理.rc演奏用タイマ.t更新();
1190 if (Input管理 != null)
1191 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1196 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1197 // Pad.st検知したデバイス.Clear();
1199 if (this.Device == null)
1202 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1203 CPowerManagement.tDisableMonitorSuspend();
1205 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1207 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1209 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1213 #region [ DTXCreator/DTX2WAVからの指示 ]
1214 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1216 string strMes = this.Window.strMessage;
1217 this.Window.IsReceivedMessage = false;
1220 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1222 if (DTXVmode.Enabled)
1225 strコンパクトモードファイル = DTXVmode.filename;
1226 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1229 string strPreviewFilename = DTXVmode.previewFilename;
1230 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1233 if (this.previewSound != null)
1235 this.previewSound.tサウンドを停止する();
1236 this.previewSound.Dispose();
1237 this.previewSound = null;
1239 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1240 this.previewSound.n音量 = DTXVmode.previewVolume;
1241 this.previewSound.n位置 = DTXVmode.previewPan;
1242 this.previewSound.t再生を開始する();
1243 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1247 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1248 if (this.previewSound != null)
1250 this.previewSound.Dispose();
1252 this.previewSound = null;
1256 if (DTX2WAVmode.Enabled)
1258 if (DTX2WAVmode.Command == CDTX2WAVmode.ECommand.Cancel)
1260 Trace.TraceInformation("録音のCancelコマンドをDTXMania本体が受信しました。");
1261 //Microsoft.VisualBasic.Interaction.AppActivate("メモ帳");
1262 //SendKeys.Send("{ESC}");
1263 //SendKeys.SendWait("%{F4}");
1264 //Application.Exit();
1269 //Environment.ExitCode = 10010; // この組み合わせではダメ、返り値が反映されない
1270 //base.Window.Close();
1271 Environment.Exit(10010); // このやり方ならばOK
1278 this.Device.BeginScene();
1279 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1281 if (r現在のステージ != null)
1283 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1285 #region [ プラグインの進行描画 ]
1286 //---------------------
1287 foreach (STPlugin sp in this.listプラグイン)
1289 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1291 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1292 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1294 sp.plugin.On進行描画(null, null);
1296 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1298 //---------------------
1301 #region [ DTX2WAVモード時、ステージが変わるたびに、そのことをDTX2WAVアプリ側に通知する ]
1302 if (DTX2WAVmode.Enabled && r現在のステージ != r1フレーム前のステージ)
1304 r1フレーム前のステージ = r現在のステージ;
1305 //Trace.TraceInformation("Stage変更 to : " + r現在のステージ.eステージID.ToString());
1306 switch (r現在のステージ.eステージID)
1308 case CStage.Eステージ.曲読み込み:
1309 DTX2WAVmode.SendMessage2DTX2WAV("LOAD");
1311 case CStage.Eステージ.演奏:
1312 DTX2WAVmode.SendMessage2DTX2WAV("PLAY");
1320 CScoreIni scoreIni = null;
1322 if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1324 // → songs.db等の書き込み時だと音切れするっぽい
1325 actEnumSongs.On非活性化();
1326 EnumSongs.SongListEnumCompletelyDone();
1327 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1329 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1330 if (!CDTXMania.Instance.bコンパクトモード)
1332 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1334 switch (r現在のステージ.eステージID)
1336 case CStage.Eステージ.タイトル:
1337 case CStage.Eステージ.コンフィグ:
1338 case CStage.Eステージ.選曲:
1339 case CStage.Eステージ.曲読み込み:
1340 if (EnumSongs != null)
1342 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1343 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1344 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1345 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1346 !EnumSongs.IsSongListEnumStarted)
1348 actEnumSongs.On活性化();
1349 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1350 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1351 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1352 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1354 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1359 #region [ 曲検索の中断と再開 ]
1360 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1362 switch (this.n進行描画の戻り値)
1365 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1366 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1368 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1369 EnumSongs.IsSlowdown = false;
1373 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1374 EnumSongs.IsSlowdown = true;
1376 actEnumSongs.On活性化();
1380 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1381 actEnumSongs.On非活性化();
1387 #region [ 曲探索中断待ち待機 ]
1388 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1389 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1391 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1395 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1396 // CStage選曲.On活性化() に回した方がいいかな?
1397 if (EnumSongs.IsSongListEnumerated)
1399 actEnumSongs.On非活性化();
1400 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1402 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1403 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1404 EnumSongs.SongListEnumCompletelyDone();
1412 switch (r現在のステージ.eステージID)
1414 case CStage.Eステージ.何もしない:
1417 case CStage.Eステージ.起動:
1419 //-----------------------------
1420 if (this.n進行描画の戻り値 != 0)
1425 Trace.TraceInformation("----------------------");
1426 Trace.TraceInformation("■ タイトル");
1428 r直前のステージ = r現在のステージ;
1429 r現在のステージ = stageタイトル;
1434 Trace.TraceInformation("----------------------");
1435 Trace.TraceInformation("■ 曲読み込み");
1437 r直前のステージ = r現在のステージ;
1438 r現在のステージ = stage曲読み込み;
1441 foreach (STPlugin pg in this.listプラグイン)
1443 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1444 pg.plugin.Onステージ変更();
1445 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1448 this.tガベージコレクションを実行する();
1450 //-----------------------------
1454 case CStage.Eステージ.タイトル:
1456 //-----------------------------
1457 switch (this.n進行描画の戻り値)
1459 case (int)CStageタイトル.E戻り値.GAMESTART:
1461 //-----------------------------
1463 Trace.TraceInformation("----------------------");
1464 Trace.TraceInformation("■ 選曲");
1466 r直前のステージ = r現在のステージ;
1468 //-----------------------------
1472 #region [ OPTION: 廃止済 ]
1473 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1475 // //-----------------------------
1476 // r現在のステージ.On非活性化();
1477 // Trace.TraceInformation( "----------------------" );
1478 // Trace.TraceInformation( "■ オプション" );
1479 // stageオプション.On活性化();
1480 // r直前のステージ = r現在のステージ;
1481 // r現在のステージ = stageオプション;
1482 // //-----------------------------
1487 case (int)CStageタイトル.E戻り値.CONFIG:
1489 //-----------------------------
1491 Trace.TraceInformation("----------------------");
1492 Trace.TraceInformation("■ コンフィグ");
1494 r直前のステージ = r現在のステージ;
1495 r現在のステージ = stageコンフィグ;
1496 //-----------------------------
1500 case (int)CStageタイトル.E戻り値.EXIT:
1502 //-----------------------------
1504 Trace.TraceInformation("----------------------");
1505 Trace.TraceInformation("■ 終了");
1507 r直前のステージ = r現在のステージ;
1509 //-----------------------------
1514 foreach (STPlugin pg in this.listプラグイン)
1516 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1517 pg.plugin.Onステージ変更();
1518 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1521 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1522 //-----------------------------
1526 case CStage.Eステージ.コンフィグ:
1528 //-----------------------------
1529 if (this.n進行描画の戻り値 != 0)
1531 switch (r直前のステージ.eステージID)
1533 case CStage.Eステージ.タイトル:
1535 //-----------------------------
1537 Trace.TraceInformation("----------------------");
1538 Trace.TraceInformation("■ タイトル");
1540 r直前のステージ = r現在のステージ;
1541 r現在のステージ = stageタイトル;
1543 foreach (STPlugin pg in this.listプラグイン)
1545 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1546 pg.plugin.Onステージ変更();
1547 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1550 this.tガベージコレクションを実行する();
1552 //-----------------------------
1555 case CStage.Eステージ.選曲:
1557 //-----------------------------
1559 Trace.TraceInformation("----------------------");
1560 Trace.TraceInformation("■ 選曲");
1562 r直前のステージ = r現在のステージ;
1565 foreach (STPlugin pg in this.listプラグイン)
1567 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1568 pg.plugin.Onステージ変更();
1569 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1572 this.tガベージコレクションを実行する();
1574 //-----------------------------
1578 //-----------------------------
1582 case CStage.Eステージ.選曲:
1584 //-----------------------------
1585 switch (this.n進行描画の戻り値)
1587 case (int)CStage選曲.E戻り値.タイトルに戻る:
1589 //-----------------------------
1591 Trace.TraceInformation("----------------------");
1592 Trace.TraceInformation("■ タイトル");
1594 r直前のステージ = r現在のステージ;
1595 r現在のステージ = stageタイトル;
1597 foreach (STPlugin pg in this.listプラグイン)
1599 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1600 pg.plugin.Onステージ変更();
1601 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1604 this.tガベージコレクションを実行する();
1606 //-----------------------------
1609 case (int)CStage選曲.E戻り値.選曲した:
1611 //-----------------------------
1613 Trace.TraceInformation("----------------------");
1614 Trace.TraceInformation("■ 曲読み込み");
1616 r直前のステージ = r現在のステージ;
1617 r現在のステージ = stage曲読み込み;
1619 foreach (STPlugin pg in this.listプラグイン)
1621 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1622 pg.plugin.Onステージ変更();
1623 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1626 this.tガベージコレクションを実行する();
1628 //-----------------------------
1631 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1633 //-----------------------------
1635 Trace.TraceInformation("----------------------");
1636 Trace.TraceInformation("■ コンフィグ");
1638 r直前のステージ = r現在のステージ;
1639 r現在のステージ = stageコンフィグ;
1641 foreach (STPlugin pg in this.listプラグイン)
1643 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1644 pg.plugin.Onステージ変更();
1645 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1648 this.tガベージコレクションを実行する();
1650 //-----------------------------
1653 case (int)CStage選曲.E戻り値.スキン変更:
1656 //-----------------------------
1658 Trace.TraceInformation("----------------------");
1659 Trace.TraceInformation("■ スキン切り替え");
1660 stageChangeSkin.On活性化();
1661 r直前のステージ = r現在のステージ;
1662 r現在のステージ = stageChangeSkin;
1664 //-----------------------------
1667 //-----------------------------
1671 case CStage.Eステージ.曲読み込み:
1673 //-----------------------------
1674 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1675 if (this.n進行描画の戻り値 != 0)
1677 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1679 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1680 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1684 Trace.TraceInformation("曲の読み込みを中止しました。");
1685 this.tガベージコレクションを実行する();
1686 Trace.TraceInformation("----------------------");
1687 Trace.TraceInformation("■ 選曲");
1689 r直前のステージ = r現在のステージ;
1691 foreach (STPlugin pg in this.listプラグイン)
1693 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1694 pg.plugin.Onステージ変更();
1695 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1701 Trace.TraceInformation("----------------------");
1702 Trace.TraceInformation("■ 演奏(ドラム画面)");
1703 r直前のステージ = r現在のステージ;
1704 r現在のステージ = stage演奏画面;
1706 foreach (STPlugin pg in this.listプラグイン)
1708 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1709 pg.plugin.Onステージ変更();
1710 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1713 this.tガベージコレクションを実行する();
1715 //-----------------------------
1719 case CStage.Eステージ.演奏:
1721 //-----------------------------
1722 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1723 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1724 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1725 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1726 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1728 //swlist1.Add( Convert.ToInt32(n1) );
1729 //swlist2.Add( Convert.ToInt32(n2) );
1730 //swlist3.Add( Convert.ToInt32( n3 ) );
1731 //swlist4.Add( Convert.ToInt32( n4 ) );
1732 //swlist5.Add( Convert.ToInt32( n5 ) );
1734 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1735 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1737 DTXVmode.Refreshed = false;
1739 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1741 CDTXMania.Instance.stage演奏画面.t停止();
1743 if (previewSound != null)
1745 this.previewSound.tサウンドを停止する();
1746 this.previewSound.Dispose();
1747 this.previewSound = null;
1752 // for ( int i = 0; i < swlist1.Count; i++ )
1754 // int d1 = swlist1[ i ];
1755 // int d2 = swlist2[ i ];
1756 // int d3 = swlist3[ i ];
1757 // int d4 = swlist4[ i ];
1758 // int d5 = swlist5[ i ];
1760 // int dif = d1 - lastd;
1762 // if ( 16 <= dif && dif <= 17 )
1769 // 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 );
1781 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1783 if (DTXVmode.NeedReload)
1785 CDTXMania.Instance.stage演奏画面.t再読込();
1786 if (DTXVmode.GRmode)
1788 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1792 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1794 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1795 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1796 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1798 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1799 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1804 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1810 switch (this.n進行描画の戻り値)
1812 case (int)E演奏画面の戻り値.再読込_再演奏:
1813 #region [ DTXファイルを再読み込みして、再演奏 ]
1818 r直前のステージ = r現在のステージ;
1819 r現在のステージ = stage曲読み込み;
1820 this.tガベージコレクションを実行する();
1824 //case (int) E演奏画面の戻り値.再演奏:
1825 #region [ 再読み込み無しで、再演奏 ]
1829 case (int)E演奏画面の戻り値.継続:
1832 case (int)E演奏画面の戻り値.演奏中断:
1834 //-----------------------------
1835 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1836 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1838 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1843 //for (int i = 0; i < swlist1.Count; i++)
1845 // int d1 = swlist1[ i ];
1846 // int d2 = swlist2[ i ];
1847 // int d3 = swlist3[ i ];
1848 // int d4 = swlist4[ i ];
1850 // int dif = d1 - lastd;
1852 // if ( 16 <= dif && dif <= 17 )
1859 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1868 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1869 //---------------------
1870 foreach (STPlugin pg in this.listプラグイン)
1872 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1873 pg.plugin.On演奏キャンセル(scoreIni);
1874 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1876 //---------------------
1882 if (DTX2WAVmode.Enabled)
1884 Environment.Exit(0);
1888 base.Window.Close();
1892 Trace.TraceInformation("----------------------");
1893 Trace.TraceInformation("■ 選曲");
1895 r直前のステージ = r現在のステージ;
1898 #region [ プラグイン Onステージ変更() の呼び出し ]
1899 //---------------------
1900 foreach (STPlugin pg in this.listプラグイン)
1902 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1903 pg.plugin.Onステージ変更();
1904 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1906 //---------------------
1909 this.tガベージコレクションを実行する();
1912 //-----------------------------
1915 case (int)E演奏画面の戻り値.ステージ失敗:
1916 #region [ 演奏失敗(StageFailed) ]
1917 //-----------------------------
1918 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
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 //---------------------
1936 base.Window.Close();
1940 Trace.TraceInformation("----------------------");
1941 Trace.TraceInformation("■ 選曲");
1943 r直前のステージ = r現在のステージ;
1946 #region [ プラグイン Onステージ変更() の呼び出し ]
1947 //---------------------
1948 foreach (STPlugin pg in this.listプラグイン)
1950 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1951 pg.plugin.Onステージ変更();
1952 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1954 //---------------------
1957 this.tガベージコレクションを実行する();
1960 //-----------------------------
1963 case (int)E演奏画面の戻り値.ステージクリア:
1965 //-----------------------------
1966 STDGBSValue<CScoreIni.C演奏記録> record;
1967 record = stage演奏画面.Record;
1969 double playskill = 0.0;
1971 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
1973 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
1975 playskill = record[inst].db演奏型スキル値;
1979 string str = "Cleared";
1980 switch (CScoreIni.t総合ランク値を計算して返す(record))
1982 case CScoreIni.ERANK.SS:
1983 str = string.Format("Cleared (SS: {0:F2})", playskill);
1986 case CScoreIni.ERANK.S:
1987 str = string.Format("Cleared (S: {0:F2})", playskill);
1990 case CScoreIni.ERANK.A:
1991 str = string.Format("Cleared (A: {0:F2})", playskill);
1994 case CScoreIni.ERANK.B:
1995 str = string.Format("Cleared (B: {0:F2})", playskill);
1998 case CScoreIni.ERANK.C:
1999 str = string.Format("Cleared (C: {0:F2})", playskill);
2002 case CScoreIni.ERANK.D:
2003 str = string.Format("Cleared (D: {0:F2})", playskill);
2006 case CScoreIni.ERANK.E:
2007 str = string.Format("Cleared (E: {0:F2})", playskill);
2010 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
2011 str = "Cleared (No chips)";
2015 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
2017 #region [ プラグイン On演奏クリア() の呼び出し ]
2018 //---------------------
2019 foreach (STPlugin pg in this.listプラグイン)
2021 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2022 pg.plugin.On演奏クリア(scoreIni);
2023 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2025 //---------------------
2029 Trace.TraceInformation("----------------------");
2030 Trace.TraceInformation("■ 結果");
2031 stage結果.st演奏記録 = record;
2032 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
2034 r直前のステージ = r現在のステージ;
2037 #region [ プラグイン Onステージ変更() の呼び出し ]
2038 //---------------------
2039 foreach (STPlugin pg in this.listプラグイン)
2041 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2042 pg.plugin.Onステージ変更();
2043 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2045 //---------------------
2049 //-----------------------------
2052 //-----------------------------
2056 case CStage.Eステージ.結果:
2058 //-----------------------------
2059 if (this.n進行描画の戻り値 != 0)
2061 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2062 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2063 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2065 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
2073 Trace.TraceInformation("----------------------");
2074 Trace.TraceInformation("■ 選曲");
2076 r直前のステージ = r現在のステージ;
2079 foreach (STPlugin pg in this.listプラグイン)
2081 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2082 pg.plugin.Onステージ変更();
2083 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2086 this.tガベージコレクションを実行する();
2090 base.Window.Close();
2093 //-----------------------------
2097 case CStage.Eステージ.ChangeSkin:
2099 //-----------------------------
2100 if (this.n進行描画の戻り値 != 0)
2103 Trace.TraceInformation("----------------------");
2104 Trace.TraceInformation("■ 選曲");
2106 r直前のステージ = r現在のステージ;
2108 this.tガベージコレクションを実行する();
2110 //-----------------------------
2114 case CStage.Eステージ.終了:
2116 //-----------------------------
2117 if (this.n進行描画の戻り値 != 0)
2121 //-----------------------------
2126 this.Device.EndScene();
2127 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2128 // (つまり、Present()は、Draw()完了後に実行される)
2129 #if !GPUFlushAfterPresent
2130 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2132 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2134 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2137 #region [ マウスカーソル消去制御 ]
2138 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2140 #region [ 全画面・ウインドウ切り替え ]
2141 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2143 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2144 Instance.t全画面_ウィンドウモード切り替え();
2145 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2148 #region [ 垂直基線同期切り替え ]
2149 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2151 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2152 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2153 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2154 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2155 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2156 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2157 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2160 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2165 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2166 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2171 /// XML ファイルからオブジェクトを生成します。
2173 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2174 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2175 public static object DeserializeXML(string xmlpath, Type t)
2180 if (File.Exists(xmlpath))
2182 using (XmlReader xr = XmlReader.Create(xmlpath))
2184 DataContractSerializer serializer = new DataContractSerializer(t);
2185 ret = serializer.ReadObject(xr);
2191 Trace.TraceWarning( e.Message );
2198 /// オブジェクトから XML ファイルを生成します。
2200 /// <param name="xmlfile">XML ファイルのパス。</param>
2201 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2202 public static void SerializeXML(string xmlpath, object obj)
2204 XmlWriterSettings settings = new XmlWriterSettings();
2205 settings.IndentChars = " ";
2206 settings.Indent = true;
2207 settings.NewLineChars = Environment.NewLine;
2208 settings.Encoding = new System.Text.UTF8Encoding(false);
2209 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2211 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2213 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2214 serializer.WriteObject(xw, obj);
2219 public void SaveConfig()
2221 #region [ Skinパスの絶対パス→相対パス変換 ]
2222 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2223 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2224 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2226 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2227 // → 初期値として Default/ を設定する。
2228 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2231 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2232 // そのため、以下の処理を通すために、いったん絶対パスに変換
2233 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2235 ConfigIni.strSystemSkinSubfolderPath.Value =
2236 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2239 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2240 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2241 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2242 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2243 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2245 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2247 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2250 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2253 public void LoadConfig()
2255 string path = strEXEのあるフォルダ + "Config.xml";
2257 if (!File.Exists(path))
2261 if (File.Exists(path))
2263 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2264 if (ConfigIni == null)
2266 ConfigIni = new CConfigXml();
2269 // Skinパスの相対パスを、絶対パスに変換
2270 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2272 ConfigIni.strSystemSkinSubfolderPath.Value =
2273 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2278 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2280 public void UpdateCoordinates()
2282 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2285 if (File.Exists(coordXml))
2287 using (XmlReader xr = XmlReader.Create(coordXml))
2289 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2292 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2294 catch (SerializationException e)
2296 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2301 XmlWriterSettings settings = new XmlWriterSettings();
2302 settings.IndentChars = " ";
2303 settings.Indent = true;
2304 settings.NewLineChars = Environment.NewLine;
2305 settings.Encoding = new System.Text.UTF8Encoding( false );
2306 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2308 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2309 //ns.Add( String.Empty, String.Empty );
2311 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2312 //serializer.Serialize( sw, item, ns );
2315 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2316 serializer.WriteObject( xw, Coordinates );
2317 //serializer.WriteStartObject( xw, Coordinates );
2318 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2319 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2320 //serializer.WriteObjectContent( xw, Coordinates );
2321 //serializer.WriteEndObject( xw );
2325 if (File.Exists(coordXml))
2327 using (XmlReader xr = XmlReader.Create(coordXml))
2329 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2330 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2337 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2339 //public class MyXmlTextWriter : XmlTextWriter
2341 // private bool _ignoreAttr = false;
2343 // public MyXmlTextWriter( TextWriter w )
2346 // Debug.WriteLine( "create" );
2349 // public override string LookupPrefix( string ns )
2351 // Debug.WriteLine( "luprefix" );
2352 // return string.Empty;
2355 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2357 // Debug.WriteLine( "writestartattribute" );
2358 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2360 // Debug.WriteLine( "[!]" );
2361 // this._ignoreAttr = true;
2366 // public override void WriteEndAttribute()
2368 // if ( this._ignoreAttr )
2370 // this._ignoreAttr = false;
2373 // base.WriteEndAttribute();
2376 // public override void WriteString( string text )
2378 // Debug.WriteLine( "ws" );
2379 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2383 // base.WriteString( text );
2386 // public override void WriteStartElement( string prefix, string localName, string ns )
2388 // Debug.WriteLine( "wse" );
2389 // base.WriteStartElement( null, localName, null );
2393 public void ShowWindowTitleWithSoundType()
2396 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2398 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2400 base.Window.Text = strWindowTitle;
2401 if (!this.DTX2WAVmode.Enabled)
2403 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2409 private bool b終了処理完了済み;
2410 private static CDTX dtx;
2411 private List<CActivity> listトップレベルActivities;
2412 private int n進行描画の戻り値;
2413 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2414 private string strWindowTitle
2418 if (DTXVmode.Enabled)
2420 return "DTXMViewer release " + VERSION;
2422 else if (DTX2WAVmode.Enabled)
2424 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename);
2428 return "DTXMania .NET style release " + VERSION;
2432 private CSound previewSound;
2433 private CMouseHideControl cMouseHideControl = null;
2435 private void t終了処理()
2437 if (!this.b終了処理完了済み)
2439 Trace.TraceInformation("----------------------");
2440 Trace.TraceInformation("■ アプリケーションの終了");
2442 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2444 #region [ 曲検索の終了処理 ]
2445 //---------------------
2446 if (actEnumSongs != null)
2448 Trace.TraceInformation("曲検索actの終了処理を行います。");
2452 actEnumSongs.On非活性化();
2453 actEnumSongs = null;
2454 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2458 Trace.TraceError(e.Message);
2459 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2466 //---------------------
2468 #region [ 現在のステージの終了処理 ]
2469 //---------------------
2470 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2472 Trace.TraceInformation("現在のステージを終了します。");
2477 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2484 //---------------------
2487 #region [ 選曲ステージの終了処理 ]
2491 #region [ プラグインの終了処理 ]
2492 //---------------------
2493 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2495 Trace.TraceInformation("すべてのプラグインを終了します。");
2499 foreach (STPlugin st in this.listプラグイン)
2501 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2502 st.plugin.OnUnmanagedリソースの解放();
2503 st.plugin.OnManagedリソースの解放();
2505 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2508 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2515 //---------------------
2517 #region [ 曲リストの終了処理 ]
2518 //---------------------
2519 if (Songs管理 != null)
2521 Trace.TraceInformation("曲リストの終了処理を行います。");
2526 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2528 catch (Exception exception)
2530 Trace.TraceError(exception.Message);
2531 Trace.TraceError("曲リストの終了処理に失敗しました。");
2539 //---------------------
2541 #region [ スキンの終了処理 ]
2542 //---------------------
2545 Trace.TraceInformation("スキンの終了処理を行います。");
2551 Trace.TraceInformation("スキンの終了処理を完了しました。");
2553 catch (Exception exception2)
2555 Trace.TraceError(exception2.Message);
2556 Trace.TraceError("スキンの終了処理に失敗しました。");
2563 //---------------------
2565 #region [ DirectSoundの終了処理 ]
2566 //---------------------
2567 if (Sound管理 != null)
2569 Trace.TraceInformation("DirectSound の終了処理を行います。");
2575 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2577 catch (Exception exception3)
2579 Trace.TraceError(exception3.Message);
2580 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2587 //---------------------
2589 #region [ パッドの終了処理 ]
2590 //---------------------
2593 Trace.TraceInformation("パッドの終了処理を行います。");
2598 Trace.TraceInformation("パッドの終了処理を完了しました。");
2600 catch (Exception exception4)
2602 Trace.TraceError(exception4.Message);
2603 Trace.TraceError("パッドの終了処理に失敗しました。");
2610 //---------------------
2612 #region [ DirectInput, MIDI入力の終了処理 ]
2613 //---------------------
2614 if (Input管理 != null)
2616 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2622 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2624 catch (Exception exception5)
2626 Trace.TraceError(exception5.Message);
2627 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2634 //---------------------
2636 #region [ 文字コンソールの終了処理 ]
2637 //---------------------
2638 if (act文字コンソール != null)
2640 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2644 act文字コンソール.On非活性化();
2646 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2648 catch (Exception exception6)
2650 Trace.TraceError(exception6.Message);
2651 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2658 //---------------------
2660 #region [ FPSカウンタの終了処理 ]
2661 //---------------------
2662 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2670 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2676 //---------------------
2678 #region [ タイマの終了処理 ]
2679 //---------------------
2680 Trace.TraceInformation("タイマの終了処理を行います。");
2688 Trace.TraceInformation("タイマの終了処理を完了しました。");
2692 Trace.TraceInformation("タイマは使用されていません。");
2699 //---------------------
2701 #region [ Config.iniの出力 ]
2702 //---------------------
2703 Trace.TraceInformation("Config.xml を出力します。");
2704 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2705 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2707 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2710 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2712 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2715 string str = strEXEのあるフォルダ + "Config.xml";
2719 if (DTXVmode.Enabled)
2721 DTXVmode.tUpdateConfigIni();
2722 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2724 else if (DTX2WAVmode.Enabled)
2726 DTX2WAVmode.tUpdateConfigIni();
2727 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2728 DTX2WAVmode.SendMessage2DTX2WAV("TERM");
2732 CDTXMania.Instance.SaveConfig();
2733 Trace.TraceInformation("保存しました。({0})", str);
2738 Trace.TraceError(e.Message);
2739 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2745 //---------------------
2747 #region [ DTXVmodeの終了処理 ]
2748 //---------------------
2749 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2753 if (DTXVmode != null)
2756 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2760 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2767 //---------------------
2769 #region [ DirectXの終了処理 ]
2770 //---------------------
2771 base.GraphicsDeviceManager.Dispose();
2772 //---------------------
2774 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2777 this.b終了処理完了済み = true;
2780 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2782 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2783 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2784 CScoreIni ini = new CScoreIni(strFilename);
2785 if (!File.Exists(strFilename))
2787 ini.stファイル.Title = DTX.TITLE;
2788 ini.stファイル.Name = DTX.strファイル名;
2789 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2790 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2792 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2793 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2794 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2795 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2797 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2798 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2799 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2800 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2802 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2803 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2804 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2805 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2808 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2809 isUpdated = CScoreIni.t更新条件を取得する();
2810 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2812 if (isUpdated.Drums)
2814 ini.stファイル.PlayCountDrums++;
2816 if (isUpdated.Guitar)
2818 ini.stファイル.PlayCountGuitar++;
2822 ini.stファイル.PlayCountBass++;
2824 ini.tヒストリを追加する(str新ヒストリ行);
2827 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2828 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2829 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2830 for (int j = 0; j < ini.stファイル.History.Length; j++)
2832 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2836 if (ConfigIni.bScoreIni)
2838 ini.t書き出し(strFilename);
2843 private void tガベージコレクションを実行する()
2845 GC.Collect(0, GCCollectionMode.Optimized, true );
2846 GC.WaitForPendingFinalizers();
2847 GC.Collect(0, GCCollectionMode.Forced, true );
2848 GC.WaitForPendingFinalizers();
2850 private void tプラグイン検索と生成()
2852 this.listプラグイン = new List<STPlugin>();
2854 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2855 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2857 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2859 if (this.listプラグイン.Count > 0)
2860 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2863 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2865 var domain = (AppDomain)sender;
2867 foreach (var assembly in domain.GetAssemblies())
2869 if (assembly.FullName == args.Name)
2874 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2876 // 指定されたパスが存在しないとエラー
2877 if (!Directory.Exists(strプラグインフォルダパス))
2879 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2883 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2886 // (1) すべての *.dll について…
2887 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2888 foreach (string dllName in strDLLs)
2890 if (Path.GetExtension(dllName).ToLower() != ".dll")
2896 // (1-1) dll をアセンブリとして読み込む。
2897 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2899 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2900 foreach (Type t in asm.GetTypes())
2902 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2903 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2905 // (1-4) クラス名からインスタンスを作成する
2906 var st = new STPlugin()
2908 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2909 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2910 strアセンブリ簡易名 = asm.GetName().Name,
2911 Version = asm.GetName().Version,
2914 // (1-5) プラグインリストへ登録
2915 this.listプラグイン.Add(st);
2916 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2920 catch (System.Reflection.ReflectionTypeLoadException e)
2922 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2923 Trace.TraceInformation(e.ToString());
2924 Trace.TraceInformation(e.Message);
2926 StringBuilder sb = new StringBuilder();
2927 foreach (Exception exSub in e.LoaderExceptions)
2929 sb.AppendLine(exSub.Message);
2930 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2931 if (exFileNotFound != null)
2933 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2935 sb.AppendLine("Fusion Log:");
2936 sb.AppendLine(exFileNotFound.FusionLog);
2941 string errorMessage = sb.ToString();
2942 //Display or log the error based on your application.
2943 Trace.TraceInformation(errorMessage);
2948 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2949 Trace.TraceInformation(e.ToString());
2950 Trace.TraceInformation(e.Message);
2954 // (2) サブフォルダがあれば再帰する
2955 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
2956 foreach (string dir in strDirs)
2957 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
2960 #region [ Windowイベント処理 ]
2961 private void Window_ApplicationActivated( object sender, EventArgs e )
2963 this.bApplicationActive = true;
2965 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2967 this.bApplicationActive = false;
2968 if (cMouseHideControl != null) cMouseHideControl.Show();
2970 private void Window_KeyDown(object sender, KeyEventArgs e)
2972 if (e.KeyCode == Keys.Menu)
2975 e.SuppressKeyPress = true;
2977 else if ((e.KeyCode == Keys.Return) && e.Alt)
2979 if (ConfigIni != null)
2981 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
2982 this.t全画面_ウィンドウモード切り替え();
2985 e.SuppressKeyPress = true;
2989 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
2991 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
2993 if( (int) captureCode > 0 &&
2994 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
2996 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2997 string strFullPath =
2998 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
2999 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
3000 SaveResultScreen( strFullPath );
3005 private void Window_MouseUp(object sender, MouseEventArgs e)
3010 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
3012 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
3014 ConfigIni.bウィンドウモード = false;
3015 this.t全画面_ウィンドウモード切り替え();
3018 private void Window_MouseMove(object sender, MouseEventArgs e)
3020 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
3023 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
3025 if (ConfigIni.bウィンドウモード)
3027 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
3028 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
3031 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
3032 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
3036 //Stopwatch sw = new Stopwatch();
3037 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
3041 private class CMouseHideControl
3043 private Point lastPosition;
3044 private CCounter ccMouseShow;
3045 private bool bマウスカーソル表示中;
3050 public CMouseHideControl()
3052 ccMouseShow = new CCounter();
3053 lastPosition = Cursor.Position;
3060 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3063 public void tHideCursorIfNeed()
3066 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3067 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3069 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3070 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
3078 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3080 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3081 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3083 Point currentPosition = Cursor.Position;
3084 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3085 if (lastPosition != currentPosition)
3087 //Trace.TraceInformation("移動発生");
3088 lastPosition = currentPosition;
3103 bマウスカーソル表示中 = false;
3110 private void PutSystemLog()
3112 System.Management.ManagementClass mc =
3113 new System.Management.ManagementClass("Win32_Processor");
3114 System.Management.ManagementObjectCollection moc = mc.GetInstances();
3115 foreach (System.Management.ManagementObject mo in moc)
3117 Trace.TraceInformation("-------------------------");
3118 Trace.TraceInformation("CPU Information:");
3119 //Trace.TraceInformation("DeviceID = {0}", mo["DeviceID"]);
3120 Trace.TraceInformation("Name = {0}", mo["Name"]);
3121 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
3122 Trace.TraceInformation("L2CacheSize = {0}KB", mo["L2CacheSize"]);
3123 Trace.TraceInformation("L3CacheSize = {0}KB", mo["L3CacheSize"]);
3124 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
3129 //System.Management.ManagementClass mc =
3130 // new System.Management.ManagementClass("Win32_OperatingSystem");
3131 //System.Management.ManagementObjectCollection moc = mc.GetInstances();
3133 new System.Management.ManagementClass("Win32_OperatingSystem");
3134 moc = mc.GetInstances();
3135 foreach (System.Management.ManagementObject mo in moc)
3137 Trace.TraceInformation("-------------------------");
3138 Trace.TraceInformation("OS Information:");
3139 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
3140 Trace.TraceInformation("OS: " + mo["Caption"]);
3141 //バージョン(Windows 8.1では、「6.3.9600」)
3142 Trace.TraceInformation("Version: " + mo["Version"]);
3143 //ビルド番号(Windows 8.1では「9600」)
3144 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
3146 //サービスパック(Windows 8.1ではNULL)
3147 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
3149 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
3151 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
3153 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
3158 Trace.TraceInformation("-------------------------");
3159 Trace.TraceInformation("General Environment Information:");
3160 //Trace.TraceInformation("OS Version: " + Environment.OSVersion); // fake version will be returned (due to the lack of manifest settings)
3161 //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
3162 Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
3163 Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
3165 var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
3166 Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
3167 Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
3168 Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
3169 Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
3170 //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
3172 mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
3173 moc = mc.GetInstances();
3174 Trace.TraceInformation("-------------------------");
3175 Trace.TraceInformation("Physical Memory Information:");
3176 foreach (System.Management.ManagementObject mo in moc)
3178 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
3183 mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
3184 moc = mc.GetInstances();
3185 foreach (System.Management.ManagementObject mo in moc)
3187 Trace.TraceInformation("-------------------------");
3188 Trace.TraceInformation("Display Adapter Information:");
3189 Trace.TraceInformation("Name: " + mo["Name"]);
3190 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
3191 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
3192 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
3193 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3198 mc = new System.Management.ManagementClass("Win32_VideoController");
3199 moc = mc.GetInstances();
3200 foreach (System.Management.ManagementObject mo in moc)
3202 Trace.TraceInformation("-------------------------");
3203 Trace.TraceInformation("Video Controller Information:");
3204 Trace.TraceInformation("Description: " + mo["Description"]);
3205 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3206 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3211 mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3212 moc = mc.GetInstances();
3213 foreach (System.Management.ManagementObject mo in moc)
3215 Trace.TraceInformation("-------------------------");
3216 Trace.TraceInformation("Display Information:");
3217 Trace.TraceInformation("Description: " + mo["Description"]);
3218 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3219 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3220 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3221 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3226 mc = new System.Management.ManagementClass("Win32_SoundDevice");
3227 moc = mc.GetInstances();
3228 foreach (System.Management.ManagementObject mo in moc)
3230 Trace.TraceInformation("-------------------------");
3231 Trace.TraceInformation("Sound Information:");
3232 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3233 Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3234 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3239 Trace.TraceInformation("----------------------");
3240 Trace.TraceInformation("DTXMania settings:");
3241 Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3242 Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3243 Trace.TraceInformation("----------------------");