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 = "111(180101)";
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 string strEXEのあるフォルダ { get; private set; }
151 public string strコンパクトモードファイル { get; private set; }
152 public CTimer Timer { get; private set; }
153 public Format TextureFormat = Format.A8R8G8B8;
154 internal IPluginActivity act現在入力を占有中のプラグイン = null;
155 public bool bApplicationActive { get; private set; }
156 public bool b次のタイミングで垂直帰線同期切り替えを行う { get; set; }
157 public bool b次のタイミングで全画面_ウィンドウ切り替えを行う { get; set; }
158 public Coordinates.CCoordinates Coordinates;
163 return base.GraphicsDeviceManager.Direct3D9.Device;
166 public CPluginHost PluginHost { get; private set; }
167 public List<STPlugin> listプラグイン = new List<STPlugin>();
169 private Size currentClientSize { get; set; } // #23510 2010.10.27 add yyagi to keep current window size
170 // public static CTimer ct;
171 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
175 return base.Window.Handle;
178 public CDTXVmode DTXVmode; // #28821 2014.1.23 yyagi
179 public CDTX2WAVmode DTX2WAVmode;
180 public CCommandParse CommandParse;
189 public void InitializeInstance()
191 #region [ strEXEのあるフォルダを決定する ]
192 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
194 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
195 //strEXEのあるフォルダ = Path.GetDirectoryName( Environment.GetCommandLineArgs()[ 0 ] ) + @"\";
197 strEXEのあるフォルダ = Path.GetDirectoryName(Application.ExecutablePath) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
199 // END #23629 2010.11.13 from
202 #region [ 言語リソースの初期化 ]
203 Trace.TraceInformation("言語リソースの初期化を行います。");
207 Resources = new CResources();
208 Resources.LoadResources("");
209 Trace.TraceInformation("言語リソースの初期化を完了しました。");
217 #region [ Config.ini の読込み ]
218 ConfigIni = new CConfigXml();
219 CDTXMania.Instance.LoadConfig();
220 // #28200 2011.5.1 yyagi
221 this.Window.EnableSystemMenu = CDTXMania.Instance.ConfigIni.bIsEnabledSystemMenu;
222 // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
227 Coordinates = new Coordinates.CCoordinates();
229 //Coordinates = (DTXMania.Coordinates.CCoordinates) CDTXMania.DeserializeXML( strEXEのあるフォルダ + "Coordinates.xml", typeof( DTXMania.Coordinates.CCoordinates ) );
230 //if ( Coordinates == null )
232 // if ( File.Exists( strEXEのあるフォルダ + "Coordinates.xml" ) )
234 // Trace.TraceInformation( "Coordinates.xmlファイルは存在します。" );
236 // Trace.TraceInformation( "Coordiantes.xmlファイルの読み込みができませんでした。無視して進めます。" );
237 // Coordinates = new Coordinates.CCoordinates();
242 Trace.AutoFlush = true;
247 Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "DTXManiaLog.txt"), false, Encoding.GetEncoding("utf-16"))));
249 catch (System.UnauthorizedAccessException) // #24481 2011.2.20 yyagi
251 Resources.Language = instance.ConfigIni.strLanguage;
252 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
253 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
258 Trace.WriteLine("DTXMania powered by YAMAHA Silent Session Drums");
259 Trace.WriteLine(string.Format("Release: {0}", VERSION));
261 Trace.TraceInformation("----------------------");
262 Trace.TraceInformation("■ アプリケーションの初期化");
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としての起動 ]
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;
360 strコンパクトモードファイル = commandLineArgs[1];
363 if (!File.Exists(strコンパクトモードファイル)) // #32985 2014.1.23 yyagi
365 Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
367 Environment.Exit(-1);
369 if (strコンパクトモードファイル == "") // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
371 Environment.Exit(-1);
375 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
379 if (DTXVmode.Enabled)
381 Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
385 Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
390 Trace.TraceInformation("通常モードで起動します。");
394 #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
395 CPowerPlan.BackupCurrentPowerPlan();
396 if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
398 CPowerPlan.ChangeHighPerformance();
402 #region [ Input管理 の初期化 ]
403 Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
407 bool bUseMIDIIn = !DTXVmode.Enabled;
408 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
409 foreach (IInputDevice device in Input管理.list入力デバイス)
411 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
414 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
418 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
421 foreach (IInputDevice device2 in Input管理.list入力デバイス)
423 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
425 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
427 if (device2.GUID.Equals(pair.Value))
429 ((CInputJoystick)device2).SetID(pair.Key);
436 Trace.TraceInformation("DirectInput の初期化を完了しました。");
438 catch (Exception exception2)
440 Trace.TraceError(exception2.Message);
441 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
443 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
444 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
454 // #30675 2013.02.04 ikanick add
455 base.Window.StartPosition = FormStartPosition.Manual;
456 base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
457 // 事前にDTXVmodeの実体を作っておくこと
458 base.Window.Text = this.strWindowTitle;
459 //base.Window.StartPosition = FormStartPosition.Manual;
460 //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
462 // #34510 yyagi 2010.10.31 to change window size got from Config.ini
463 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
464 #if !WindowedFullscreen
465 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
466 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
468 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
469 #if !WindowedFullscreen
472 // #23510 2010.11.04 yyagi: to support maximizing window
473 base.Window.MaximizeBox = true;
474 // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
475 base.Window.FormBorderStyle = FormBorderStyle.Sizable;
476 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
477 base.Window.ShowIcon = true;
478 base.Window.Icon = Properties.Resources.dtx;
479 base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
480 base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
481 // #23510 2010.11.13 yyagi: to go fullscreen mode
482 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
483 // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
484 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
485 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
486 base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
487 base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
490 #region [ Direct3D9Exを使うかどうか判定 ]
493 #region [ Direct3D9 デバイスの生成 ]
494 DeviceSettings settings = new DeviceSettings();
495 #if WindowedFullscreen
496 // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
497 settings.Windowed = true;
499 settings.Windowed = ConfigIni.bウィンドウモード;
501 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
502 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
503 settings.EnableVSync = ConfigIni.bVSyncWait;
504 //settings.MultisampleType = MultisampleType.FourSamples;
505 //settings.MultisampleQuality = 3;
506 //settings.MultisampleType = MultisampleType.NonMaskable;
507 //settings.Multithreaded = true;
512 base.GraphicsDeviceManager.ChangeDevice(settings);
514 catch (DeviceCreationException e)
516 Trace.TraceError(e.ToString());
517 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
518 Environment.Exit(-1);
520 Trace.TraceInformation("DeviceCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
521 Trace.TraceInformation("DeviceCaps2 = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
522 Trace.TraceInformation("MaxTextureWidth = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
523 Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
524 Trace.TraceInformation("TextureCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
525 Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
526 Trace.TraceInformation("DeviceStatics = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
528 base.IsFixedTimeStep = false;
529 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
530 // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
531 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
532 // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
533 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
534 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
535 #if WindowedFullscreen
536 // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
537 this.t全画面_ウィンドウモード切り替え();
539 actFlushGPU = new CActFlushGPU();
544 #region [ Skin の初期化 ]
545 Trace.TraceInformation("スキンの初期化を行います。");
550 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
551 CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
552 // 旧指定のSkinフォルダが消滅していた場合に備える
553 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
554 Trace.TraceInformation("スキンの初期化を完了しました。");
558 Trace.TraceInformation("スキンの初期化に失敗しました。");
566 #region [ Skin配下にある言語リソースの確認と初期化 ]
567 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
571 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
572 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
574 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
577 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
581 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
593 #region [ Timer の初期化 ]
594 Trace.TraceInformation("タイマの初期化を行います。");
598 Timer = new CTimer(CTimer.E種別.MultiMedia);
599 Trace.TraceInformation("タイマの初期化を完了しました。");
607 #region [ マウス消去用のクラスを初期化 ]
608 cMouseHideControl = new CMouseHideControl();
611 #region [ FPS カウンタの初期化 ]
612 Trace.TraceInformation("FPSカウンタの初期化を行います。");
617 Trace.TraceInformation("FPSカウンタを生成しました。");
625 #region [ act文字コンソールの初期化 ]
626 Trace.TraceInformation("文字コンソールの初期化を行います。");
630 act文字コンソール = new C文字コンソール();
631 Trace.TraceInformation("文字コンソールを生成しました。");
633 Trace.TraceInformation("文字コンソールを活性化しました。");
634 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
636 catch (Exception exception)
638 Trace.TraceError(exception.Message);
639 Trace.TraceError("文字コンソールの初期化に失敗しました。");
648 Trace.TraceInformation("パッドの初期化を行います。");
653 Trace.TraceInformation("パッドの初期化を完了しました。");
655 catch (Exception exception3)
657 Trace.TraceError(exception3.Message);
658 Trace.TraceError("パッドの初期化に失敗しました。");
666 #region [ Sound管理 の初期化 ]
667 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
671 ESoundDeviceType soundDeviceType;
672 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
674 case ESoundDeviceTypeForConfig.DSound:
675 soundDeviceType = ESoundDeviceType.DirectSound;
677 case ESoundDeviceTypeForConfig.ASIO:
678 soundDeviceType = ESoundDeviceType.ASIO;
680 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
681 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
683 case ESoundDeviceTypeForConfig.WASAPI_Shared:
684 soundDeviceType = ESoundDeviceType.SharedWASAPI;
687 soundDeviceType = ESoundDeviceType.Unknown;
690 Sound管理 = new CSound管理(base.Window.Handle,
692 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
693 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
695 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
696 CDTXMania.Instance.ConfigIni.bUseOSTimer
698 //Sound管理 = FDK.CSound管理.Instance;
699 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
701 ShowWindowTitleWithSoundType();
702 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
703 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
704 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
705 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
709 Trace.TraceError(e.Message);
718 #region [ Songs管理 の初期化 ]
719 //---------------------
720 Trace.TraceInformation("曲リストの初期化を行います。");
724 Songs管理 = new CSongs管理();
725 // Songs管理_裏読 = new CSongs管理();
726 EnumSongs = new CEnumSongs();
727 actEnumSongs = new CActEnumSongs();
728 Trace.TraceInformation("曲リストの初期化を完了しました。");
732 Trace.TraceError(e.Message);
733 Trace.TraceError("曲リストの初期化に失敗しました。");
739 //---------------------
742 #region [ CAvi の初期化 ]
746 #region [ Random の初期化 ]
747 Random = new Random((int)Timer.nシステム時刻);
753 stage起動 = new CStage起動();
754 stageタイトル = new CStageタイトル();
755 stageコンフィグ = new CStageコンフィグ();
756 stage選曲 = new CStage選曲();
757 stage曲読み込み = new CStage曲読み込み();
758 stage演奏画面 = new CStage演奏画面共通();
759 stage結果 = new CStage結果();
760 stageChangeSkin = new CStageChangeSkin();
761 stage終了 = new CStage終了();
763 this.listトップレベルActivities = new List<CActivity>();
764 this.listトップレベルActivities.Add(actEnumSongs);
765 this.listトップレベルActivities.Add(act文字コンソール);
766 this.listトップレベルActivities.Add(stage起動);
767 this.listトップレベルActivities.Add(stageタイトル);
768 this.listトップレベルActivities.Add(stageコンフィグ);
769 this.listトップレベルActivities.Add(stage選曲);
770 this.listトップレベルActivities.Add(stage曲読み込み);
771 this.listトップレベルActivities.Add(stage演奏画面);
772 this.listトップレベルActivities.Add(stage結果);
773 this.listトップレベルActivities.Add(stageChangeSkin);
774 this.listトップレベルActivities.Add(stage終了);
775 this.listトップレベルActivities.Add(actFlushGPU);
778 #region [ プラグインの検索と生成 ]
779 PluginHost = new CPluginHost();
781 Trace.TraceInformation("プラグインの検索と生成を行います。");
786 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
794 #region [ プラグインの初期化 ]
795 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
797 Trace.TraceInformation("プラグインの初期化を行います。");
801 foreach (STPlugin st in this.listプラグイン)
803 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
804 st.plugin.On初期化(this.PluginHost);
805 st.plugin.OnManagedリソースの作成();
806 st.plugin.OnUnmanagedリソースの作成();
807 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
809 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
813 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
824 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
826 #region [ 最初のステージの起動 ]
827 Trace.TraceInformation("----------------------");
828 Trace.TraceInformation("■ 起動");
830 if (CDTXMania.Instance.bコンパクトモード)
832 r現在のステージ = stage曲読み込み;
843 public void t全画面_ウィンドウモード切り替え()
845 #if WindowedFullscreen
846 if (ConfigIni != null)
848 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
849 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
852 #if !WindowedFullscreen
853 settings.Windowed = ConfigIni.bウィンドウモード;
855 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
857 currentClientSize = this.Window.ClientSize;
858 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
859 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
860 // FDK.CTaskBar.ShowTaskBar( false );
862 #if !WindowedFullscreen
863 base.GraphicsDeviceManager.ChangeDevice( settings );
865 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
867 #if WindowedFullscreen
868 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
869 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
870 // in spite of using fullscreen mode.
871 Instance.Window.WindowState = FormWindowState.Normal;
872 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
873 Instance.Window.WindowState = FormWindowState.Normal;
875 base.Window.ClientSize =
876 new Size(currentClientSize.Width, currentClientSize.Height);
877 // FDK.CTaskBar.ShowTaskBar( true );
879 #if WindowedFullscreen
882 Instance.Window.WindowState = FormWindowState.Normal;
883 Instance.Window.FormBorderStyle = FormBorderStyle.None;
884 Instance.Window.WindowState = FormWindowState.Maximized;
886 if (cMouseHideControl != null)
888 if (ConfigIni.bウィンドウモード)
890 cMouseHideControl.Show();
894 cMouseHideControl.Hide();
901 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
905 /// <param name="strFilename">保存するファイル名(フルパス)</param>
906 public bool SaveResultScreen(string strFullPath)
908 string strSavePath = Path.GetDirectoryName(strFullPath);
909 if (!Directory.Exists(strSavePath))
913 Directory.CreateDirectory(strSavePath);
921 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
922 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
924 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
932 protected override void Initialize()
936 //swlist1 = new List<int>( 8192 );
937 //swlist2 = new List<int>( 8192 );
938 //swlist3 = new List<int>( 8192 );
939 //swlist4 = new List<int>( 8192 );
940 //swlist5 = new List<int>( 8192 );
941 if (this.listトップレベルActivities != null)
943 foreach (CActivity activity in this.listトップレベルActivities)
944 activity.OnManagedリソースの作成();
947 foreach (STPlugin st in this.listプラグイン)
949 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
950 st.plugin.OnManagedリソースの作成();
951 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
953 #if GPUFlushAfterPresent
954 FrameEnd += dtxmania_FrameEnd;
957 #if GPUFlushAfterPresent
958 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
959 { // → Present()直後にGPUをFlushする
960 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
961 actFlushGPU.On進行描画(); // Flush GPU
964 protected override void LoadContent()
966 if (cMouseHideControl != null)
968 if (ConfigIni.bウィンドウモード)
970 cMouseHideControl.Show();
974 cMouseHideControl.Hide();
977 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)));
978 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
979 this.Device.SetRenderState(RenderState.Lighting, false);
980 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
981 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
982 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
983 this.Device.SetRenderState(RenderState.AlphaRef, 10);
985 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
986 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
987 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
989 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
990 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
991 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
992 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
993 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
994 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
995 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
997 if (this.listトップレベルActivities != null)
999 foreach (CActivity activity in this.listトップレベルActivities)
1000 activity.OnUnmanagedリソースの作成();
1003 foreach (STPlugin st in this.listプラグイン)
1005 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1006 st.plugin.OnUnmanagedリソースの作成();
1007 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1010 protected override void UnloadContent()
1012 if (this.listトップレベルActivities != null)
1014 foreach (CActivity activity in this.listトップレベルActivities)
1015 activity.OnUnmanagedリソースの解放();
1018 foreach (STPlugin st in this.listプラグイン)
1020 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1021 st.plugin.OnUnmanagedリソースの解放();
1022 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1025 protected override void OnExiting(EventArgs e)
1027 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1031 protected override void Update(GameTime gameTime)
1034 protected override void Draw(GameTime gameTime)
1036 if (Sound管理 == null)
1040 Sound管理.t再生中の処理をする();
1044 if (CSound管理.rc演奏用タイマ != null)
1045 CSound管理.rc演奏用タイマ.t更新();
1047 if (Input管理 != null)
1048 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1053 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1054 // Pad.st検知したデバイス.Clear();
1056 if (this.Device == null)
1059 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1060 CPowerManagement.tDisableMonitorSuspend();
1062 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1064 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1066 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1070 #region [ DTXCreatorからの指示 ]
1071 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1073 string strMes = this.Window.strMessage;
1074 this.Window.IsReceivedMessage = false;
1078 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1080 if (DTXVmode.Enabled)
1083 strコンパクトモードファイル = DTXVmode.filename;
1084 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1087 string strPreviewFilename = DTXVmode.previewFilename;
1088 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1091 if (this.previewSound != null)
1093 this.previewSound.tサウンドを停止する();
1094 this.previewSound.Dispose();
1095 this.previewSound = null;
1097 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1098 this.previewSound.n音量 = DTXVmode.previewVolume;
1099 this.previewSound.n位置 = DTXVmode.previewPan;
1100 this.previewSound.t再生を開始する();
1101 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1105 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1106 if (this.previewSound != null)
1108 this.previewSound.Dispose();
1110 this.previewSound = null;
1118 this.Device.BeginScene();
1119 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1121 if (r現在のステージ != null)
1123 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1125 #region [ プラグインの進行描画 ]
1126 //---------------------
1127 foreach (STPlugin sp in this.listプラグイン)
1129 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1131 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1132 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1134 sp.plugin.On進行描画(null, null);
1136 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1138 //---------------------
1142 CScoreIni scoreIni = null;
1144 if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1146 // → songs.db等の書き込み時だと音切れするっぽい
1147 actEnumSongs.On非活性化();
1148 EnumSongs.SongListEnumCompletelyDone();
1149 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1151 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1152 if (!CDTXMania.Instance.bコンパクトモード)
1154 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1156 switch (r現在のステージ.eステージID)
1158 case CStage.Eステージ.タイトル:
1159 case CStage.Eステージ.コンフィグ:
1160 case CStage.Eステージ.選曲:
1161 case CStage.Eステージ.曲読み込み:
1162 if (EnumSongs != null)
1164 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1165 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1166 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1167 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1168 !EnumSongs.IsSongListEnumStarted)
1170 actEnumSongs.On活性化();
1171 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1172 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1173 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1174 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1176 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1181 #region [ 曲検索の中断と再開 ]
1182 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1184 switch (this.n進行描画の戻り値)
1187 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1188 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1190 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1191 EnumSongs.IsSlowdown = false;
1195 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1196 EnumSongs.IsSlowdown = true;
1198 actEnumSongs.On活性化();
1202 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1203 actEnumSongs.On非活性化();
1209 #region [ 曲探索中断待ち待機 ]
1210 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1211 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1213 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1217 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1218 // CStage選曲.On活性化() に回した方がいいかな?
1219 if (EnumSongs.IsSongListEnumerated)
1221 actEnumSongs.On非活性化();
1222 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1224 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1225 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1226 EnumSongs.SongListEnumCompletelyDone();
1234 switch (r現在のステージ.eステージID)
1236 case CStage.Eステージ.何もしない:
1239 case CStage.Eステージ.起動:
1241 //-----------------------------
1242 if (this.n進行描画の戻り値 != 0)
1247 Trace.TraceInformation("----------------------");
1248 Trace.TraceInformation("■ タイトル");
1250 r直前のステージ = r現在のステージ;
1251 r現在のステージ = stageタイトル;
1256 Trace.TraceInformation("----------------------");
1257 Trace.TraceInformation("■ 曲読み込み");
1259 r直前のステージ = r現在のステージ;
1260 r現在のステージ = stage曲読み込み;
1263 foreach (STPlugin pg in this.listプラグイン)
1265 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1266 pg.plugin.Onステージ変更();
1267 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1270 this.tガベージコレクションを実行する();
1272 //-----------------------------
1276 case CStage.Eステージ.タイトル:
1278 //-----------------------------
1279 switch (this.n進行描画の戻り値)
1281 case (int)CStageタイトル.E戻り値.GAMESTART:
1283 //-----------------------------
1285 Trace.TraceInformation("----------------------");
1286 Trace.TraceInformation("■ 選曲");
1288 r直前のステージ = r現在のステージ;
1290 //-----------------------------
1294 #region [ OPTION: 廃止済 ]
1295 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1297 // //-----------------------------
1298 // r現在のステージ.On非活性化();
1299 // Trace.TraceInformation( "----------------------" );
1300 // Trace.TraceInformation( "■ オプション" );
1301 // stageオプション.On活性化();
1302 // r直前のステージ = r現在のステージ;
1303 // r現在のステージ = stageオプション;
1304 // //-----------------------------
1309 case (int)CStageタイトル.E戻り値.CONFIG:
1311 //-----------------------------
1313 Trace.TraceInformation("----------------------");
1314 Trace.TraceInformation("■ コンフィグ");
1316 r直前のステージ = r現在のステージ;
1317 r現在のステージ = stageコンフィグ;
1318 //-----------------------------
1322 case (int)CStageタイトル.E戻り値.EXIT:
1324 //-----------------------------
1326 Trace.TraceInformation("----------------------");
1327 Trace.TraceInformation("■ 終了");
1329 r直前のステージ = r現在のステージ;
1331 //-----------------------------
1336 foreach (STPlugin pg in this.listプラグイン)
1338 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1339 pg.plugin.Onステージ変更();
1340 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1343 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1344 //-----------------------------
1348 case CStage.Eステージ.コンフィグ:
1350 //-----------------------------
1351 if (this.n進行描画の戻り値 != 0)
1353 switch (r直前のステージ.eステージID)
1355 case CStage.Eステージ.タイトル:
1357 //-----------------------------
1359 Trace.TraceInformation("----------------------");
1360 Trace.TraceInformation("■ タイトル");
1362 r直前のステージ = r現在のステージ;
1363 r現在のステージ = stageタイトル;
1365 foreach (STPlugin pg in this.listプラグイン)
1367 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1368 pg.plugin.Onステージ変更();
1369 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1372 this.tガベージコレクションを実行する();
1374 //-----------------------------
1377 case CStage.Eステージ.選曲:
1379 //-----------------------------
1381 Trace.TraceInformation("----------------------");
1382 Trace.TraceInformation("■ 選曲");
1384 r直前のステージ = r現在のステージ;
1387 foreach (STPlugin pg in this.listプラグイン)
1389 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1390 pg.plugin.Onステージ変更();
1391 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1394 this.tガベージコレクションを実行する();
1396 //-----------------------------
1400 //-----------------------------
1404 case CStage.Eステージ.選曲:
1406 //-----------------------------
1407 switch (this.n進行描画の戻り値)
1409 case (int)CStage選曲.E戻り値.タイトルに戻る:
1411 //-----------------------------
1413 Trace.TraceInformation("----------------------");
1414 Trace.TraceInformation("■ タイトル");
1416 r直前のステージ = r現在のステージ;
1417 r現在のステージ = stageタイトル;
1419 foreach (STPlugin pg in this.listプラグイン)
1421 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1422 pg.plugin.Onステージ変更();
1423 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1426 this.tガベージコレクションを実行する();
1428 //-----------------------------
1431 case (int)CStage選曲.E戻り値.選曲した:
1433 //-----------------------------
1435 Trace.TraceInformation("----------------------");
1436 Trace.TraceInformation("■ 曲読み込み");
1438 r直前のステージ = r現在のステージ;
1439 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 //-----------------------------
1453 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1455 //-----------------------------
1457 Trace.TraceInformation("----------------------");
1458 Trace.TraceInformation("■ コンフィグ");
1460 r直前のステージ = r現在のステージ;
1461 r現在のステージ = stageコンフィグ;
1463 foreach (STPlugin pg in this.listプラグイン)
1465 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1466 pg.plugin.Onステージ変更();
1467 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1470 this.tガベージコレクションを実行する();
1472 //-----------------------------
1475 case (int)CStage選曲.E戻り値.スキン変更:
1478 //-----------------------------
1480 Trace.TraceInformation("----------------------");
1481 Trace.TraceInformation("■ スキン切り替え");
1482 stageChangeSkin.On活性化();
1483 r直前のステージ = r現在のステージ;
1484 r現在のステージ = stageChangeSkin;
1486 //-----------------------------
1489 //-----------------------------
1493 case CStage.Eステージ.曲読み込み:
1495 //-----------------------------
1496 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1497 if (this.n進行描画の戻り値 != 0)
1499 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1501 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1502 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1506 Trace.TraceInformation("曲の読み込みを中止しました。");
1507 this.tガベージコレクションを実行する();
1508 Trace.TraceInformation("----------------------");
1509 Trace.TraceInformation("■ 選曲");
1511 r直前のステージ = r現在のステージ;
1513 foreach (STPlugin pg in this.listプラグイン)
1515 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1516 pg.plugin.Onステージ変更();
1517 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1523 Trace.TraceInformation("----------------------");
1524 Trace.TraceInformation("■ 演奏(ドラム画面)");
1525 r直前のステージ = r現在のステージ;
1526 r現在のステージ = stage演奏画面;
1528 foreach (STPlugin pg in this.listプラグイン)
1530 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1531 pg.plugin.Onステージ変更();
1532 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1535 this.tガベージコレクションを実行する();
1537 //-----------------------------
1541 case CStage.Eステージ.演奏:
1543 //-----------------------------
1544 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1545 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1546 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1547 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1548 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1550 //swlist1.Add( Convert.ToInt32(n1) );
1551 //swlist2.Add( Convert.ToInt32(n2) );
1552 //swlist3.Add( Convert.ToInt32( n3 ) );
1553 //swlist4.Add( Convert.ToInt32( n4 ) );
1554 //swlist5.Add( Convert.ToInt32( n5 ) );
1556 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1557 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1559 DTXVmode.Refreshed = false;
1561 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1563 CDTXMania.Instance.stage演奏画面.t停止();
1565 if (previewSound != null)
1567 this.previewSound.tサウンドを停止する();
1568 this.previewSound.Dispose();
1569 this.previewSound = null;
1574 // for ( int i = 0; i < swlist1.Count; i++ )
1576 // int d1 = swlist1[ i ];
1577 // int d2 = swlist2[ i ];
1578 // int d3 = swlist3[ i ];
1579 // int d4 = swlist4[ i ];
1580 // int d5 = swlist5[ i ];
1582 // int dif = d1 - lastd;
1584 // if ( 16 <= dif && dif <= 17 )
1591 // 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 );
1603 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1605 if (DTXVmode.NeedReload)
1607 CDTXMania.Instance.stage演奏画面.t再読込();
1608 if (DTXVmode.GRmode)
1610 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1614 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1616 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1617 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1618 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1620 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1621 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1626 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1632 switch (this.n進行描画の戻り値)
1634 case (int)E演奏画面の戻り値.再読込_再演奏:
1635 #region [ DTXファイルを再読み込みして、再演奏 ]
1640 r直前のステージ = r現在のステージ;
1641 r現在のステージ = stage曲読み込み;
1642 this.tガベージコレクションを実行する();
1646 //case (int) E演奏画面の戻り値.再演奏:
1647 #region [ 再読み込み無しで、再演奏 ]
1651 case (int)E演奏画面の戻り値.継続:
1654 case (int)E演奏画面の戻り値.演奏中断:
1656 //-----------------------------
1657 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1658 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1660 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1665 //for (int i = 0; i < swlist1.Count; i++)
1667 // int d1 = swlist1[ i ];
1668 // int d2 = swlist2[ i ];
1669 // int d3 = swlist3[ i ];
1670 // int d4 = swlist4[ i ];
1672 // int dif = d1 - lastd;
1674 // if ( 16 <= dif && dif <= 17 )
1681 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1690 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1691 //---------------------
1692 foreach (STPlugin pg in this.listプラグイン)
1694 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1695 pg.plugin.On演奏キャンセル(scoreIni);
1696 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1698 //---------------------
1706 base.Window.Close();
1710 Trace.TraceInformation("----------------------");
1711 Trace.TraceInformation("■ 選曲");
1713 r直前のステージ = r現在のステージ;
1716 #region [ プラグイン Onステージ変更() の呼び出し ]
1717 //---------------------
1718 foreach (STPlugin pg in this.listプラグイン)
1720 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1721 pg.plugin.Onステージ変更();
1722 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1724 //---------------------
1727 this.tガベージコレクションを実行する();
1730 //-----------------------------
1733 case (int)E演奏画面の戻り値.ステージ失敗:
1734 #region [ 演奏失敗(StageFailed) ]
1735 //-----------------------------
1736 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1738 #region [ プラグイン On演奏失敗() の呼び出し ]
1739 //---------------------
1740 foreach (STPlugin pg in this.listプラグイン)
1742 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1743 pg.plugin.On演奏失敗(scoreIni);
1744 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1746 //---------------------
1754 base.Window.Close();
1758 Trace.TraceInformation("----------------------");
1759 Trace.TraceInformation("■ 選曲");
1761 r直前のステージ = r現在のステージ;
1764 #region [ プラグイン Onステージ変更() の呼び出し ]
1765 //---------------------
1766 foreach (STPlugin pg in this.listプラグイン)
1768 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1769 pg.plugin.Onステージ変更();
1770 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1772 //---------------------
1775 this.tガベージコレクションを実行する();
1778 //-----------------------------
1781 case (int)E演奏画面の戻り値.ステージクリア:
1783 //-----------------------------
1784 STDGBSValue<CScoreIni.C演奏記録> record;
1785 record = stage演奏画面.Record;
1787 double playskill = 0.0;
1789 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
1791 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
1793 playskill = record[inst].db演奏型スキル値;
1797 string str = "Cleared";
1798 switch (CScoreIni.t総合ランク値を計算して返す(record))
1800 case CScoreIni.ERANK.SS:
1801 str = string.Format("Cleared (SS: {0:F2})", playskill);
1804 case CScoreIni.ERANK.S:
1805 str = string.Format("Cleared (S: {0:F2})", playskill);
1808 case CScoreIni.ERANK.A:
1809 str = string.Format("Cleared (A: {0:F2})", playskill);
1812 case CScoreIni.ERANK.B:
1813 str = string.Format("Cleared (B: {0:F2})", playskill);
1816 case CScoreIni.ERANK.C:
1817 str = string.Format("Cleared (C: {0:F2})", playskill);
1820 case CScoreIni.ERANK.D:
1821 str = string.Format("Cleared (D: {0:F2})", playskill);
1824 case CScoreIni.ERANK.E:
1825 str = string.Format("Cleared (E: {0:F2})", playskill);
1828 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1829 str = "Cleared (No chips)";
1833 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
1835 #region [ プラグイン On演奏クリア() の呼び出し ]
1836 //---------------------
1837 foreach (STPlugin pg in this.listプラグイン)
1839 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1840 pg.plugin.On演奏クリア(scoreIni);
1841 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1843 //---------------------
1847 Trace.TraceInformation("----------------------");
1848 Trace.TraceInformation("■ 結果");
1849 stage結果.st演奏記録 = record;
1850 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
1852 r直前のステージ = r現在のステージ;
1855 #region [ プラグイン Onステージ変更() の呼び出し ]
1856 //---------------------
1857 foreach (STPlugin pg in this.listプラグイン)
1859 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1860 pg.plugin.Onステージ変更();
1861 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1863 //---------------------
1867 //-----------------------------
1870 //-----------------------------
1874 case CStage.Eステージ.結果:
1876 //-----------------------------
1877 if (this.n進行描画の戻り値 != 0)
1879 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
1880 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
1881 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1883 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
1891 Trace.TraceInformation("----------------------");
1892 Trace.TraceInformation("■ 選曲");
1894 r直前のステージ = r現在のステージ;
1897 foreach (STPlugin pg in this.listプラグイン)
1899 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1900 pg.plugin.Onステージ変更();
1901 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1904 this.tガベージコレクションを実行する();
1908 base.Window.Close();
1911 //-----------------------------
1915 case CStage.Eステージ.ChangeSkin:
1917 //-----------------------------
1918 if (this.n進行描画の戻り値 != 0)
1921 Trace.TraceInformation("----------------------");
1922 Trace.TraceInformation("■ 選曲");
1924 r直前のステージ = r現在のステージ;
1926 this.tガベージコレクションを実行する();
1928 //-----------------------------
1932 case CStage.Eステージ.終了:
1934 //-----------------------------
1935 if (this.n進行描画の戻り値 != 0)
1939 //-----------------------------
1944 this.Device.EndScene();
1945 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
1946 // (つまり、Present()は、Draw()完了後に実行される)
1947 #if !GPUFlushAfterPresent
1948 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
1950 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
1952 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
1955 #region [ マウスカーソル消去制御 ]
1956 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
1958 #region [ 全画面・ウインドウ切り替え ]
1959 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
1961 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
1962 Instance.t全画面_ウィンドウモード切り替え();
1963 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
1966 #region [ 垂直基線同期切り替え ]
1967 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
1969 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
1970 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
1971 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
1972 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
1973 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
1974 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
1975 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
1978 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
1983 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
1984 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
1989 /// XML ファイルからオブジェクトを生成します。
1991 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
1992 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
1993 public static object DeserializeXML(string xmlpath, Type t)
1998 if (File.Exists(xmlpath))
2000 using (XmlReader xr = XmlReader.Create(xmlpath))
2002 DataContractSerializer serializer = new DataContractSerializer(t);
2003 ret = serializer.ReadObject(xr);
2009 Trace.TraceWarning( e.Message );
2016 /// オブジェクトから XML ファイルを生成します。
2018 /// <param name="xmlfile">XML ファイルのパス。</param>
2019 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2020 public static void SerializeXML(string xmlpath, object obj)
2022 XmlWriterSettings settings = new XmlWriterSettings();
2023 settings.IndentChars = " ";
2024 settings.Indent = true;
2025 settings.NewLineChars = Environment.NewLine;
2026 settings.Encoding = new System.Text.UTF8Encoding(false);
2027 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2029 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2031 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2032 serializer.WriteObject(xw, obj);
2037 public void SaveConfig()
2039 #region [ Skinパスの絶対パス→相対パス変換 ]
2040 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2041 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2042 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2044 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2045 // → 初期値として Default/ を設定する。
2046 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2049 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2050 // そのため、以下の処理を通すために、いったん絶対パスに変換
2051 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2053 ConfigIni.strSystemSkinSubfolderPath.Value =
2054 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2057 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2058 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2059 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2060 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2061 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2063 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2065 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2068 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2071 public void LoadConfig()
2073 string path = strEXEのあるフォルダ + "Config.xml";
2075 if (!File.Exists(path))
2079 if (File.Exists(path))
2081 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2082 if (ConfigIni == null)
2084 ConfigIni = new CConfigXml();
2087 // Skinパスの相対パスを、絶対パスに変換
2088 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2090 ConfigIni.strSystemSkinSubfolderPath.Value =
2091 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2096 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2098 public void UpdateCoordinates()
2100 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2103 if (File.Exists(coordXml))
2105 using (XmlReader xr = XmlReader.Create(coordXml))
2107 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2110 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2112 catch (SerializationException e)
2114 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2119 XmlWriterSettings settings = new XmlWriterSettings();
2120 settings.IndentChars = " ";
2121 settings.Indent = true;
2122 settings.NewLineChars = Environment.NewLine;
2123 settings.Encoding = new System.Text.UTF8Encoding( false );
2124 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2126 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2127 //ns.Add( String.Empty, String.Empty );
2129 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2130 //serializer.Serialize( sw, item, ns );
2133 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2134 serializer.WriteObject( xw, Coordinates );
2135 //serializer.WriteStartObject( xw, Coordinates );
2136 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2137 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2138 //serializer.WriteObjectContent( xw, Coordinates );
2139 //serializer.WriteEndObject( xw );
2143 if (File.Exists(coordXml))
2145 using (XmlReader xr = XmlReader.Create(coordXml))
2147 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2148 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2155 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2157 //public class MyXmlTextWriter : XmlTextWriter
2159 // private bool _ignoreAttr = false;
2161 // public MyXmlTextWriter( TextWriter w )
2164 // Debug.WriteLine( "create" );
2167 // public override string LookupPrefix( string ns )
2169 // Debug.WriteLine( "luprefix" );
2170 // return string.Empty;
2173 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2175 // Debug.WriteLine( "writestartattribute" );
2176 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2178 // Debug.WriteLine( "[!]" );
2179 // this._ignoreAttr = true;
2184 // public override void WriteEndAttribute()
2186 // if ( this._ignoreAttr )
2188 // this._ignoreAttr = false;
2191 // base.WriteEndAttribute();
2194 // public override void WriteString( string text )
2196 // Debug.WriteLine( "ws" );
2197 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2201 // base.WriteString( text );
2204 // public override void WriteStartElement( string prefix, string localName, string ns )
2206 // Debug.WriteLine( "wse" );
2207 // base.WriteStartElement( null, localName, null );
2211 public void ShowWindowTitleWithSoundType()
2214 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2216 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2218 base.Window.Text = strWindowTitle + " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2223 private bool b終了処理完了済み;
2224 private static CDTX dtx;
2225 private List<CActivity> listトップレベルActivities;
2226 private int n進行描画の戻り値;
2227 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2228 private string strWindowTitle
2232 if (DTXVmode.Enabled)
2234 return "DTXMViewer release " + VERSION;
2238 return "DTXMania .NET style release " + VERSION;
2242 private CSound previewSound;
2243 private CMouseHideControl cMouseHideControl = null;
2245 private void t終了処理()
2247 if (!this.b終了処理完了済み)
2249 Trace.TraceInformation("----------------------");
2250 Trace.TraceInformation("■ アプリケーションの終了");
2252 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2254 #region [ 曲検索の終了処理 ]
2255 //---------------------
2256 if (actEnumSongs != null)
2258 Trace.TraceInformation("曲検索actの終了処理を行います。");
2262 actEnumSongs.On非活性化();
2263 actEnumSongs = null;
2264 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2268 Trace.TraceError(e.Message);
2269 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2276 //---------------------
2278 #region [ 現在のステージの終了処理 ]
2279 //---------------------
2280 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2282 Trace.TraceInformation("現在のステージを終了します。");
2287 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2294 //---------------------
2297 #region [ 選曲ステージの終了処理 ]
2301 #region [ プラグインの終了処理 ]
2302 //---------------------
2303 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2305 Trace.TraceInformation("すべてのプラグインを終了します。");
2309 foreach (STPlugin st in this.listプラグイン)
2311 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2312 st.plugin.OnUnmanagedリソースの解放();
2313 st.plugin.OnManagedリソースの解放();
2315 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2318 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2325 //---------------------
2327 #region [ 曲リストの終了処理 ]
2328 //---------------------
2329 if (Songs管理 != null)
2331 Trace.TraceInformation("曲リストの終了処理を行います。");
2336 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2338 catch (Exception exception)
2340 Trace.TraceError(exception.Message);
2341 Trace.TraceError("曲リストの終了処理に失敗しました。");
2349 //---------------------
2351 #region [ スキンの終了処理 ]
2352 //---------------------
2355 Trace.TraceInformation("スキンの終了処理を行います。");
2361 Trace.TraceInformation("スキンの終了処理を完了しました。");
2363 catch (Exception exception2)
2365 Trace.TraceError(exception2.Message);
2366 Trace.TraceError("スキンの終了処理に失敗しました。");
2373 //---------------------
2375 #region [ DirectSoundの終了処理 ]
2376 //---------------------
2377 if (Sound管理 != null)
2379 Trace.TraceInformation("DirectSound の終了処理を行います。");
2385 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2387 catch (Exception exception3)
2389 Trace.TraceError(exception3.Message);
2390 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2397 //---------------------
2399 #region [ パッドの終了処理 ]
2400 //---------------------
2403 Trace.TraceInformation("パッドの終了処理を行います。");
2408 Trace.TraceInformation("パッドの終了処理を完了しました。");
2410 catch (Exception exception4)
2412 Trace.TraceError(exception4.Message);
2413 Trace.TraceError("パッドの終了処理に失敗しました。");
2420 //---------------------
2422 #region [ DirectInput, MIDI入力の終了処理 ]
2423 //---------------------
2424 if (Input管理 != null)
2426 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2432 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2434 catch (Exception exception5)
2436 Trace.TraceError(exception5.Message);
2437 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2444 //---------------------
2446 #region [ 文字コンソールの終了処理 ]
2447 //---------------------
2448 if (act文字コンソール != null)
2450 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2454 act文字コンソール.On非活性化();
2456 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2458 catch (Exception exception6)
2460 Trace.TraceError(exception6.Message);
2461 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2468 //---------------------
2470 #region [ FPSカウンタの終了処理 ]
2471 //---------------------
2472 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2480 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2486 //---------------------
2488 #region [ タイマの終了処理 ]
2489 //---------------------
2490 Trace.TraceInformation("タイマの終了処理を行います。");
2498 Trace.TraceInformation("タイマの終了処理を完了しました。");
2502 Trace.TraceInformation("タイマは使用されていません。");
2509 //---------------------
2511 #region [ Config.iniの出力 ]
2512 //---------------------
2513 Trace.TraceInformation("Config.xml を出力します。");
2514 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2515 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2517 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2520 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2522 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2525 string str = strEXEのあるフォルダ + "Config.xml";
2529 if (DTXVmode.Enabled)
2531 DTXVmode.tUpdateConfigIni();
2532 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2536 CDTXMania.Instance.SaveConfig();
2537 Trace.TraceInformation("保存しました。({0})", str);
2542 Trace.TraceError(e.Message);
2543 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2549 //---------------------
2551 #region [ DTXVmodeの終了処理 ]
2552 //---------------------
2553 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2557 if (DTXVmode != null)
2560 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2564 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2571 //---------------------
2573 #region [ DirectXの終了処理 ]
2574 //---------------------
2575 base.GraphicsDeviceManager.Dispose();
2576 //---------------------
2578 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2581 this.b終了処理完了済み = true;
2584 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2586 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2587 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2588 CScoreIni ini = new CScoreIni(strFilename);
2589 if (!File.Exists(strFilename))
2591 ini.stファイル.Title = DTX.TITLE;
2592 ini.stファイル.Name = DTX.strファイル名;
2593 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2594 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2596 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2597 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2598 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2599 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2601 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2602 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2603 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2604 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2606 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2607 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2608 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2609 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2612 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2613 isUpdated = CScoreIni.t更新条件を取得する();
2614 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2616 if (isUpdated.Drums)
2618 ini.stファイル.PlayCountDrums++;
2620 if (isUpdated.Guitar)
2622 ini.stファイル.PlayCountGuitar++;
2626 ini.stファイル.PlayCountBass++;
2628 ini.tヒストリを追加する(str新ヒストリ行);
2631 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2632 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2633 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2634 for (int j = 0; j < ini.stファイル.History.Length; j++)
2636 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2640 if (ConfigIni.bScoreIni)
2642 ini.t書き出し(strFilename);
2647 private void tガベージコレクションを実行する()
2649 GC.Collect(0, GCCollectionMode.Optimized, true );
2650 GC.WaitForPendingFinalizers();
2651 GC.Collect(0, GCCollectionMode.Forced, true );
2652 GC.WaitForPendingFinalizers();
2654 private void tプラグイン検索と生成()
2656 this.listプラグイン = new List<STPlugin>();
2658 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2659 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2661 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2663 if (this.listプラグイン.Count > 0)
2664 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2667 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2669 var domain = (AppDomain)sender;
2671 foreach (var assembly in domain.GetAssemblies())
2673 if (assembly.FullName == args.Name)
2678 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2680 // 指定されたパスが存在しないとエラー
2681 if (!Directory.Exists(strプラグインフォルダパス))
2683 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2687 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2690 // (1) すべての *.dll について…
2691 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2692 foreach (string dllName in strDLLs)
2694 if (Path.GetExtension(dllName).ToLower() != ".dll")
2700 // (1-1) dll をアセンブリとして読み込む。
2701 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2703 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2704 foreach (Type t in asm.GetTypes())
2706 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2707 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2709 // (1-4) クラス名からインスタンスを作成する
2710 var st = new STPlugin()
2712 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2713 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2714 strアセンブリ簡易名 = asm.GetName().Name,
2715 Version = asm.GetName().Version,
2718 // (1-5) プラグインリストへ登録
2719 this.listプラグイン.Add(st);
2720 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2724 catch (System.Reflection.ReflectionTypeLoadException e)
2726 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2727 Trace.TraceInformation(e.ToString());
2728 Trace.TraceInformation(e.Message);
2730 StringBuilder sb = new StringBuilder();
2731 foreach (Exception exSub in e.LoaderExceptions)
2733 sb.AppendLine(exSub.Message);
2734 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2735 if (exFileNotFound != null)
2737 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2739 sb.AppendLine("Fusion Log:");
2740 sb.AppendLine(exFileNotFound.FusionLog);
2745 string errorMessage = sb.ToString();
2746 //Display or log the error based on your application.
2747 Trace.TraceInformation(errorMessage);
2752 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2753 Trace.TraceInformation(e.ToString());
2754 Trace.TraceInformation(e.Message);
2758 // (2) サブフォルダがあれば再帰する
2759 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
2760 foreach (string dir in strDirs)
2761 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
2764 #region [ Windowイベント処理 ]
2765 private void Window_ApplicationActivated( object sender, EventArgs e )
2767 this.bApplicationActive = true;
2769 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2771 this.bApplicationActive = false;
2772 if (cMouseHideControl != null) cMouseHideControl.Show();
2774 private void Window_KeyDown(object sender, KeyEventArgs e)
2776 if (e.KeyCode == Keys.Menu)
2779 e.SuppressKeyPress = true;
2781 else if ((e.KeyCode == Keys.Return) && e.Alt)
2783 if (ConfigIni != null)
2785 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
2786 this.t全画面_ウィンドウモード切り替え();
2789 e.SuppressKeyPress = true;
2793 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
2795 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
2797 if( (int) captureCode > 0 &&
2798 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
2800 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2801 string strFullPath =
2802 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
2803 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
2804 SaveResultScreen( strFullPath );
2809 private void Window_MouseUp(object sender, MouseEventArgs e)
2814 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
2816 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
2818 ConfigIni.bウィンドウモード = false;
2819 this.t全画面_ウィンドウモード切り替え();
2822 private void Window_MouseMove(object sender, MouseEventArgs e)
2824 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
2827 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
2829 if (ConfigIni.bウィンドウモード)
2831 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2832 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
2835 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
2836 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
2840 //Stopwatch sw = new Stopwatch();
2841 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
2845 private class CMouseHideControl
2847 private Point lastPosition;
2848 private CCounter ccMouseShow;
2849 private bool bマウスカーソル表示中;
2854 public CMouseHideControl()
2856 ccMouseShow = new CCounter();
2857 lastPosition = Cursor.Position;
2864 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
2867 public void tHideCursorIfNeed()
2870 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
2871 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
2873 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
2874 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
2882 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
2884 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
2885 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
2887 Point currentPosition = Cursor.Position;
2888 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
2889 if (lastPosition != currentPosition)
2891 //Trace.TraceInformation("移動発生");
2892 lastPosition = currentPosition;
2907 bマウスカーソル表示中 = false;
2914 private void PutSystemLog()
2916 System.Management.ManagementClass mc =
2917 new System.Management.ManagementClass("Win32_Processor");
2918 System.Management.ManagementObjectCollection moc = mc.GetInstances();
2919 foreach (System.Management.ManagementObject mo in moc)
2921 Trace.TraceInformation("-------------------------");
2922 Trace.TraceInformation("CPU Information:");
2923 //Trace.TraceInformation("DeviceID = {0}", mo["DeviceID"]);
2924 Trace.TraceInformation("Name = {0}", mo["Name"]);
2925 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
2926 Trace.TraceInformation("L2CacheSize = {0}KB", mo["L2CacheSize"]);
2927 Trace.TraceInformation("L3CacheSize = {0}KB", mo["L3CacheSize"]);
2928 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
2933 //System.Management.ManagementClass mc =
2934 // new System.Management.ManagementClass("Win32_OperatingSystem");
2935 //System.Management.ManagementObjectCollection moc = mc.GetInstances();
2937 new System.Management.ManagementClass("Win32_OperatingSystem");
2938 moc = mc.GetInstances();
2939 foreach (System.Management.ManagementObject mo in moc)
2941 Trace.TraceInformation("-------------------------");
2942 Trace.TraceInformation("OS Information:");
2943 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
2944 Trace.TraceInformation("OS: " + mo["Caption"]);
2945 //バージョン(Windows 8.1では、「6.3.9600」)
2946 Trace.TraceInformation("Version: " + mo["Version"]);
2947 //ビルド番号(Windows 8.1では「9600」)
2948 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
2950 //サービスパック(Windows 8.1ではNULL)
2951 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
2953 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
2955 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
2957 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
2962 Trace.TraceInformation("-------------------------");
2963 Trace.TraceInformation("General Environment Information:");
2964 //Trace.TraceInformation("OS Version: " + Environment.OSVersion); // fake version will be returned (due to the lack of manifest settings)
2965 //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
2966 Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
2967 Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
2969 var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
2970 Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
2971 Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
2972 Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
2973 Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
2974 //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
2976 mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
2977 moc = mc.GetInstances();
2978 Trace.TraceInformation("-------------------------");
2979 Trace.TraceInformation("Physical Memory Information:");
2980 foreach (System.Management.ManagementObject mo in moc)
2982 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
2987 mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
2988 moc = mc.GetInstances();
2989 foreach (System.Management.ManagementObject mo in moc)
2991 Trace.TraceInformation("-------------------------");
2992 Trace.TraceInformation("Display Adapter Information:");
2993 Trace.TraceInformation("Name: " + mo["Name"]);
2994 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
2995 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
2996 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
2997 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3002 mc = new System.Management.ManagementClass("Win32_VideoController");
3003 moc = mc.GetInstances();
3004 foreach (System.Management.ManagementObject mo in moc)
3006 Trace.TraceInformation("-------------------------");
3007 Trace.TraceInformation("Video Controller Information:");
3008 Trace.TraceInformation("Description: " + mo["Description"]);
3009 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3010 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3015 mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3016 moc = mc.GetInstances();
3017 foreach (System.Management.ManagementObject mo in moc)
3019 Trace.TraceInformation("-------------------------");
3020 Trace.TraceInformation("Display Information:");
3021 Trace.TraceInformation("Description: " + mo["Description"]);
3022 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3023 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3024 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3025 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3030 mc = new System.Management.ManagementClass("Win32_SoundDevice");
3031 moc = mc.GetInstances();
3032 foreach (System.Management.ManagementObject mo in moc)
3034 Trace.TraceInformation("-------------------------");
3035 Trace.TraceInformation("Sound Information:");
3036 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3037 Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3038 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3043 Trace.TraceInformation("----------------------");
3044 Trace.TraceInformation("DTXMania settings:");
3045 Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3046 Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3047 Trace.TraceInformation("----------------------");