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 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;
358 else if (DTX2WAVmode.Enabled)
360 strコンパクトモードファイル = DTX2WAVmode.dtxfilename;
361 FDK.CSound管理.strRecordInputDTXfilename = DTX2WAVmode.dtxfilename;
362 FDK.CSound管理.strRecordOutFilename = DTX2WAVmode.outfilename;
363 FDK.CSound管理.strRecordFileType = DTX2WAVmode.Format.ToString();
365 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
366 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = false;
367 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = false;
368 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
370 CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
371 CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;
372 CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
373 CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
374 CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
375 CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
378 CDTXMania.instance.ConfigIni.bAutoPlay.LC.Value = true;
379 CDTXMania.instance.ConfigIni.bAutoPlay.HH.Value = true;
380 CDTXMania.instance.ConfigIni.bAutoPlay.HHO.Value = true;
381 CDTXMania.instance.ConfigIni.bAutoPlay.SD.Value = true;
382 CDTXMania.instance.ConfigIni.bAutoPlay.BD.Value = true;
383 CDTXMania.instance.ConfigIni.bAutoPlay.HT.Value = true;
384 CDTXMania.instance.ConfigIni.bAutoPlay.LT.Value = true;
385 CDTXMania.instance.ConfigIni.bAutoPlay.FT.Value = true;
386 CDTXMania.instance.ConfigIni.bAutoPlay.CY.Value = true;
387 CDTXMania.instance.ConfigIni.bAutoPlay.RD.Value = true;
389 CDTXMania.instance.ConfigIni.bAutoPlay.GtR.Value = true;
390 CDTXMania.instance.ConfigIni.bAutoPlay.GtG.Value = true;
391 CDTXMania.instance.ConfigIni.bAutoPlay.GtB.Value = true;
392 CDTXMania.instance.ConfigIni.bAutoPlay.GtPick.Value = true;
393 //CDTXMania.instance.ConfigIni.bAutoPlay.GtWail.Value = true; // 無くてもよい 処理不可削減のため、敢えてWailはAutoにしない
394 CDTXMania.instance.ConfigIni.bAutoPlay.BsR.Value = true;
395 CDTXMania.instance.ConfigIni.bAutoPlay.BsG.Value = true;
396 CDTXMania.instance.ConfigIni.bAutoPlay.BsB.Value = true;
397 CDTXMania.instance.ConfigIni.bAutoPlay.BsPick.Value = true;
398 //CDTXMania.instance.ConfigIni.bAutoPlay.BsWail.Value = true;
401 CDTXMania.instance.ConfigIni.bFillin.Value = false;
402 CDTXMania.instance.ConfigIni.bAudience.Value = false;
404 CDTXMania.instance.ConfigIni.bStoicMode.Value = false;
406 CDTXMania.instance.ConfigIni.eSudHidInv.Drums.Value = ESudHidInv.FullInv;
407 CDTXMania.instance.ConfigIni.eSudHidInv.Guitar.Value = ESudHidInv.FullInv;
408 CDTXMania.instance.ConfigIni.eSudHidInv.Bass.Value = ESudHidInv.FullInv;
411 CDTXMania.instance.ConfigIni.eDark.Value = EDark.Full;
414 CDTXMania.instance.ConfigIni.nPolyphonicSounds.Value = 4;
417 CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
420 CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
421 CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
422 CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
425 CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
426 CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
429 CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100;
432 CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
435 CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
436 CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
437 CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
440 CDTXMania.instance.ConfigIni.bDisplayCombo.Drums.Value = false;
441 CDTXMania.instance.ConfigIni.bDisplayCombo.Guitar.Value = false;
442 CDTXMania.instance.ConfigIni.bDisplayCombo.Bass.Value = false;
443 CDTXMania.instance.ConfigIni.bDisplayJudge.Drums.Value = false;
444 CDTXMania.instance.ConfigIni.bDisplayJudge.Guitar.Value = false;
445 CDTXMania.instance.ConfigIni.bDisplayJudge.Bass.Value = false;
449 //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
450 CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
453 CDTXMania.instance.ConfigIni.bBGA.Value = false;
454 CDTXMania.instance.ConfigIni.bAVI.Value = false;
457 CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
458 CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
463 strコンパクトモードファイル = commandLineArgs[1];
466 if (!File.Exists(strコンパクトモードファイル)) // #32985 2014.1.23 yyagi
468 Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
470 Environment.Exit(-1);
472 if (strコンパクトモードファイル == "") // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
474 Environment.Exit(-1);
478 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
482 if (DTXVmode.Enabled)
484 Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
488 Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
493 Trace.TraceInformation("通常モードで起動します。");
497 #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
498 CPowerPlan.BackupCurrentPowerPlan();
499 if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
501 CPowerPlan.ChangeHighPerformance();
505 #region [ Input管理 の初期化 ]
506 Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
510 bool bUseMIDIIn = !DTXVmode.Enabled;
511 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
512 foreach (IInputDevice device in Input管理.list入力デバイス)
514 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
517 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
521 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
524 foreach (IInputDevice device2 in Input管理.list入力デバイス)
526 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
528 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
530 if (device2.GUID.Equals(pair.Value))
532 ((CInputJoystick)device2).SetID(pair.Key);
539 Trace.TraceInformation("DirectInput の初期化を完了しました。");
541 catch (Exception exception2)
543 Trace.TraceError(exception2.Message);
544 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
546 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
547 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
557 // #30675 2013.02.04 ikanick add
558 base.Window.StartPosition = FormStartPosition.Manual;
559 base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
560 // 事前にDTXVmodeの実体を作っておくこと
561 base.Window.Text = this.strWindowTitle;
562 //base.Window.StartPosition = FormStartPosition.Manual;
563 //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
565 // #34510 yyagi 2010.10.31 to change window size got from Config.ini
566 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
567 #if !WindowedFullscreen
568 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
569 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
571 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
572 #if !WindowedFullscreen
575 // #23510 2010.11.04 yyagi: to support maximizing window
576 base.Window.MaximizeBox = true;
577 // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
578 base.Window.FormBorderStyle = FormBorderStyle.Sizable;
579 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
580 base.Window.ShowIcon = true;
581 base.Window.Icon = Properties.Resources.dtx;
582 base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
583 base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
584 // #23510 2010.11.13 yyagi: to go fullscreen mode
585 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
586 // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
587 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
588 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
589 base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
590 base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
593 #region [ Direct3D9Exを使うかどうか判定 ]
596 #region [ Direct3D9 デバイスの生成 ]
597 DeviceSettings settings = new DeviceSettings();
598 #if WindowedFullscreen
599 // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
600 settings.Windowed = true;
602 settings.Windowed = ConfigIni.bウィンドウモード;
604 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
605 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
606 settings.EnableVSync = ConfigIni.bVSyncWait;
607 //settings.MultisampleType = MultisampleType.FourSamples;
608 //settings.MultisampleQuality = 3;
609 //settings.MultisampleType = MultisampleType.NonMaskable;
610 //settings.Multithreaded = true;
615 base.GraphicsDeviceManager.ChangeDevice(settings);
617 catch (DeviceCreationException e)
619 Trace.TraceError(e.ToString());
620 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
621 Environment.Exit(-1);
623 Trace.TraceInformation("DeviceCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
624 Trace.TraceInformation("DeviceCaps2 = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
625 Trace.TraceInformation("MaxTextureWidth = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
626 Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
627 Trace.TraceInformation("TextureCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
628 Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
629 Trace.TraceInformation("DeviceStatics = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
631 base.IsFixedTimeStep = false;
632 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
633 // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
634 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
635 // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
636 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
637 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
638 #if WindowedFullscreen
639 // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
640 this.t全画面_ウィンドウモード切り替え();
642 actFlushGPU = new CActFlushGPU();
647 #region [ Skin の初期化 ]
648 Trace.TraceInformation("スキンの初期化を行います。");
653 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
654 CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
655 // 旧指定のSkinフォルダが消滅していた場合に備える
656 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
657 Trace.TraceInformation("スキンの初期化を完了しました。");
661 Trace.TraceInformation("スキンの初期化に失敗しました。");
669 #region [ Skin配下にある言語リソースの確認と初期化 ]
670 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
674 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
675 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
677 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
680 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
684 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
696 #region [ Timer の初期化 ]
697 Trace.TraceInformation("タイマの初期化を行います。");
701 Timer = new CTimer(CTimer.E種別.MultiMedia);
702 Trace.TraceInformation("タイマの初期化を完了しました。");
710 #region [ マウス消去用のクラスを初期化 ]
711 cMouseHideControl = new CMouseHideControl();
714 #region [ FPS カウンタの初期化 ]
715 Trace.TraceInformation("FPSカウンタの初期化を行います。");
720 Trace.TraceInformation("FPSカウンタを生成しました。");
728 #region [ act文字コンソールの初期化 ]
729 Trace.TraceInformation("文字コンソールの初期化を行います。");
733 act文字コンソール = new C文字コンソール();
734 Trace.TraceInformation("文字コンソールを生成しました。");
736 Trace.TraceInformation("文字コンソールを活性化しました。");
737 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
739 catch (Exception exception)
741 Trace.TraceError(exception.Message);
742 Trace.TraceError("文字コンソールの初期化に失敗しました。");
751 Trace.TraceInformation("パッドの初期化を行います。");
756 Trace.TraceInformation("パッドの初期化を完了しました。");
758 catch (Exception exception3)
760 Trace.TraceError(exception3.Message);
761 Trace.TraceError("パッドの初期化に失敗しました。");
769 #region [ Sound管理 の初期化 ]
770 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
774 ESoundDeviceType soundDeviceType;
775 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
777 case ESoundDeviceTypeForConfig.DSound:
778 soundDeviceType = ESoundDeviceType.DirectSound;
780 case ESoundDeviceTypeForConfig.ASIO:
781 soundDeviceType = ESoundDeviceType.ASIO;
783 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
784 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
786 case ESoundDeviceTypeForConfig.WASAPI_Shared:
787 soundDeviceType = ESoundDeviceType.SharedWASAPI;
790 soundDeviceType = ESoundDeviceType.Unknown;
793 Sound管理 = new CSound管理(base.Window.Handle,
795 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
796 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
798 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
799 CDTXMania.Instance.ConfigIni.bUseOSTimer
801 //Sound管理 = FDK.CSound管理.Instance;
802 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
804 ShowWindowTitleWithSoundType();
805 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
806 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
807 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
808 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
812 Trace.TraceError(e.Message);
821 #region [ Songs管理 の初期化 ]
822 //---------------------
823 Trace.TraceInformation("曲リストの初期化を行います。");
827 Songs管理 = new CSongs管理();
828 // Songs管理_裏読 = new CSongs管理();
829 EnumSongs = new CEnumSongs();
830 actEnumSongs = new CActEnumSongs();
831 Trace.TraceInformation("曲リストの初期化を完了しました。");
835 Trace.TraceError(e.Message);
836 Trace.TraceError("曲リストの初期化に失敗しました。");
842 //---------------------
845 #region [ CAvi の初期化 ]
849 #region [ Random の初期化 ]
850 Random = new Random((int)Timer.nシステム時刻);
856 stage起動 = new CStage起動();
857 stageタイトル = new CStageタイトル();
858 stageコンフィグ = new CStageコンフィグ();
859 stage選曲 = new CStage選曲();
860 stage曲読み込み = new CStage曲読み込み();
861 stage演奏画面 = new CStage演奏画面共通();
862 stage結果 = new CStage結果();
863 stageChangeSkin = new CStageChangeSkin();
864 stage終了 = new CStage終了();
866 this.listトップレベルActivities = new List<CActivity>();
867 this.listトップレベルActivities.Add(actEnumSongs);
868 this.listトップレベルActivities.Add(act文字コンソール);
869 this.listトップレベルActivities.Add(stage起動);
870 this.listトップレベルActivities.Add(stageタイトル);
871 this.listトップレベルActivities.Add(stageコンフィグ);
872 this.listトップレベルActivities.Add(stage選曲);
873 this.listトップレベルActivities.Add(stage曲読み込み);
874 this.listトップレベルActivities.Add(stage演奏画面);
875 this.listトップレベルActivities.Add(stage結果);
876 this.listトップレベルActivities.Add(stageChangeSkin);
877 this.listトップレベルActivities.Add(stage終了);
878 this.listトップレベルActivities.Add(actFlushGPU);
881 #region [ プラグインの検索と生成 ]
882 PluginHost = new CPluginHost();
884 Trace.TraceInformation("プラグインの検索と生成を行います。");
889 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
897 #region [ プラグインの初期化 ]
898 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
900 Trace.TraceInformation("プラグインの初期化を行います。");
904 foreach (STPlugin st in this.listプラグイン)
906 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
907 st.plugin.On初期化(this.PluginHost);
908 st.plugin.OnManagedリソースの作成();
909 st.plugin.OnUnmanagedリソースの作成();
910 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
912 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
916 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
927 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
929 #region [ 最初のステージの起動 ]
930 Trace.TraceInformation("----------------------");
931 Trace.TraceInformation("■ 起動");
933 if (CDTXMania.Instance.bコンパクトモード)
935 r現在のステージ = stage曲読み込み;
946 public void t全画面_ウィンドウモード切り替え()
948 #if WindowedFullscreen
949 if (ConfigIni != null)
951 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
952 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
955 #if !WindowedFullscreen
956 settings.Windowed = ConfigIni.bウィンドウモード;
958 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
960 currentClientSize = this.Window.ClientSize;
961 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
962 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
963 // FDK.CTaskBar.ShowTaskBar( false );
965 #if !WindowedFullscreen
966 base.GraphicsDeviceManager.ChangeDevice( settings );
968 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
970 #if WindowedFullscreen
971 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
972 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
973 // in spite of using fullscreen mode.
974 Instance.Window.WindowState = FormWindowState.Normal;
975 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
976 Instance.Window.WindowState = FormWindowState.Normal;
978 base.Window.ClientSize =
979 new Size(currentClientSize.Width, currentClientSize.Height);
980 // FDK.CTaskBar.ShowTaskBar( true );
982 #if WindowedFullscreen
985 Instance.Window.WindowState = FormWindowState.Normal;
986 Instance.Window.FormBorderStyle = FormBorderStyle.None;
987 Instance.Window.WindowState = FormWindowState.Maximized;
989 if (cMouseHideControl != null)
991 if (ConfigIni.bウィンドウモード)
993 cMouseHideControl.Show();
997 cMouseHideControl.Hide();
1004 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1006 /// リザルト画像のキャプチャと保存。
1008 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1009 public bool SaveResultScreen(string strFullPath)
1011 string strSavePath = Path.GetDirectoryName(strFullPath);
1012 if (!Directory.Exists(strSavePath))
1016 Directory.CreateDirectory(strSavePath);
1024 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1025 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1027 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1035 protected override void Initialize()
1039 //swlist1 = new List<int>( 8192 );
1040 //swlist2 = new List<int>( 8192 );
1041 //swlist3 = new List<int>( 8192 );
1042 //swlist4 = new List<int>( 8192 );
1043 //swlist5 = new List<int>( 8192 );
1044 if (this.listトップレベルActivities != null)
1046 foreach (CActivity activity in this.listトップレベルActivities)
1047 activity.OnManagedリソースの作成();
1050 foreach (STPlugin st in this.listプラグイン)
1052 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1053 st.plugin.OnManagedリソースの作成();
1054 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1056 #if GPUFlushAfterPresent
1057 FrameEnd += dtxmania_FrameEnd;
1060 #if GPUFlushAfterPresent
1061 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1062 { // → Present()直後にGPUをFlushする
1063 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1064 actFlushGPU.On進行描画(); // Flush GPU
1067 protected override void LoadContent()
1069 if (cMouseHideControl != null)
1071 if (ConfigIni.bウィンドウモード)
1073 cMouseHideControl.Show();
1077 cMouseHideControl.Hide();
1080 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)));
1081 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1082 this.Device.SetRenderState(RenderState.Lighting, false);
1083 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1084 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1085 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1086 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1088 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1089 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1090 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1092 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1093 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1094 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1095 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1096 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1097 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1098 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1100 if (this.listトップレベルActivities != null)
1102 foreach (CActivity activity in this.listトップレベルActivities)
1103 activity.OnUnmanagedリソースの作成();
1106 foreach (STPlugin st in this.listプラグイン)
1108 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1109 st.plugin.OnUnmanagedリソースの作成();
1110 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1113 protected override void UnloadContent()
1115 if (this.listトップレベルActivities != null)
1117 foreach (CActivity activity in this.listトップレベルActivities)
1118 activity.OnUnmanagedリソースの解放();
1121 foreach (STPlugin st in this.listプラグイン)
1123 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1124 st.plugin.OnUnmanagedリソースの解放();
1125 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1128 protected override void OnExiting(EventArgs e)
1130 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1134 protected override void Update(GameTime gameTime)
1137 protected override void Draw(GameTime gameTime)
1139 if (Sound管理 == null)
1143 Sound管理.t再生中の処理をする();
1147 if (CSound管理.rc演奏用タイマ != null)
1148 CSound管理.rc演奏用タイマ.t更新();
1150 if (Input管理 != null)
1151 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1156 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1157 // Pad.st検知したデバイス.Clear();
1159 if (this.Device == null)
1162 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1163 CPowerManagement.tDisableMonitorSuspend();
1165 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1167 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1169 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1173 #region [ DTXCreatorからの指示 ]
1174 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1176 string strMes = this.Window.strMessage;
1177 this.Window.IsReceivedMessage = false;
1181 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1183 if (DTXVmode.Enabled)
1186 strコンパクトモードファイル = DTXVmode.filename;
1187 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1190 string strPreviewFilename = DTXVmode.previewFilename;
1191 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1194 if (this.previewSound != null)
1196 this.previewSound.tサウンドを停止する();
1197 this.previewSound.Dispose();
1198 this.previewSound = null;
1200 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1201 this.previewSound.n音量 = DTXVmode.previewVolume;
1202 this.previewSound.n位置 = DTXVmode.previewPan;
1203 this.previewSound.t再生を開始する();
1204 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1208 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1209 if (this.previewSound != null)
1211 this.previewSound.Dispose();
1213 this.previewSound = null;
1221 this.Device.BeginScene();
1222 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1224 if (r現在のステージ != null)
1226 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1228 #region [ プラグインの進行描画 ]
1229 //---------------------
1230 foreach (STPlugin sp in this.listプラグイン)
1232 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1234 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1235 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1237 sp.plugin.On進行描画(null, null);
1239 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1241 //---------------------
1245 CScoreIni scoreIni = null;
1247 if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1249 // → songs.db等の書き込み時だと音切れするっぽい
1250 actEnumSongs.On非活性化();
1251 EnumSongs.SongListEnumCompletelyDone();
1252 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1254 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1255 if (!CDTXMania.Instance.bコンパクトモード)
1257 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1259 switch (r現在のステージ.eステージID)
1261 case CStage.Eステージ.タイトル:
1262 case CStage.Eステージ.コンフィグ:
1263 case CStage.Eステージ.選曲:
1264 case CStage.Eステージ.曲読み込み:
1265 if (EnumSongs != null)
1267 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1268 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1269 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1270 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1271 !EnumSongs.IsSongListEnumStarted)
1273 actEnumSongs.On活性化();
1274 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1275 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1276 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1277 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1279 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1284 #region [ 曲検索の中断と再開 ]
1285 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1287 switch (this.n進行描画の戻り値)
1290 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1291 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1293 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1294 EnumSongs.IsSlowdown = false;
1298 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1299 EnumSongs.IsSlowdown = true;
1301 actEnumSongs.On活性化();
1305 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1306 actEnumSongs.On非活性化();
1312 #region [ 曲探索中断待ち待機 ]
1313 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1314 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1316 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1320 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1321 // CStage選曲.On活性化() に回した方がいいかな?
1322 if (EnumSongs.IsSongListEnumerated)
1324 actEnumSongs.On非活性化();
1325 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1327 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1328 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1329 EnumSongs.SongListEnumCompletelyDone();
1337 switch (r現在のステージ.eステージID)
1339 case CStage.Eステージ.何もしない:
1342 case CStage.Eステージ.起動:
1344 //-----------------------------
1345 if (this.n進行描画の戻り値 != 0)
1350 Trace.TraceInformation("----------------------");
1351 Trace.TraceInformation("■ タイトル");
1353 r直前のステージ = r現在のステージ;
1354 r現在のステージ = stageタイトル;
1359 Trace.TraceInformation("----------------------");
1360 Trace.TraceInformation("■ 曲読み込み");
1362 r直前のステージ = r現在のステージ;
1363 r現在のステージ = stage曲読み込み;
1366 foreach (STPlugin pg in this.listプラグイン)
1368 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1369 pg.plugin.Onステージ変更();
1370 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1373 this.tガベージコレクションを実行する();
1375 //-----------------------------
1379 case CStage.Eステージ.タイトル:
1381 //-----------------------------
1382 switch (this.n進行描画の戻り値)
1384 case (int)CStageタイトル.E戻り値.GAMESTART:
1386 //-----------------------------
1388 Trace.TraceInformation("----------------------");
1389 Trace.TraceInformation("■ 選曲");
1391 r直前のステージ = r現在のステージ;
1393 //-----------------------------
1397 #region [ OPTION: 廃止済 ]
1398 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1400 // //-----------------------------
1401 // r現在のステージ.On非活性化();
1402 // Trace.TraceInformation( "----------------------" );
1403 // Trace.TraceInformation( "■ オプション" );
1404 // stageオプション.On活性化();
1405 // r直前のステージ = r現在のステージ;
1406 // r現在のステージ = stageオプション;
1407 // //-----------------------------
1412 case (int)CStageタイトル.E戻り値.CONFIG:
1414 //-----------------------------
1416 Trace.TraceInformation("----------------------");
1417 Trace.TraceInformation("■ コンフィグ");
1419 r直前のステージ = r現在のステージ;
1420 r現在のステージ = stageコンフィグ;
1421 //-----------------------------
1425 case (int)CStageタイトル.E戻り値.EXIT:
1427 //-----------------------------
1429 Trace.TraceInformation("----------------------");
1430 Trace.TraceInformation("■ 終了");
1432 r直前のステージ = r現在のステージ;
1434 //-----------------------------
1439 foreach (STPlugin pg in this.listプラグイン)
1441 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1442 pg.plugin.Onステージ変更();
1443 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1446 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1447 //-----------------------------
1451 case CStage.Eステージ.コンフィグ:
1453 //-----------------------------
1454 if (this.n進行描画の戻り値 != 0)
1456 switch (r直前のステージ.eステージID)
1458 case CStage.Eステージ.タイトル:
1460 //-----------------------------
1462 Trace.TraceInformation("----------------------");
1463 Trace.TraceInformation("■ タイトル");
1465 r直前のステージ = r現在のステージ;
1466 r現在のステージ = stageタイトル;
1468 foreach (STPlugin pg in this.listプラグイン)
1470 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1471 pg.plugin.Onステージ変更();
1472 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1475 this.tガベージコレクションを実行する();
1477 //-----------------------------
1480 case CStage.Eステージ.選曲:
1482 //-----------------------------
1484 Trace.TraceInformation("----------------------");
1485 Trace.TraceInformation("■ 選曲");
1487 r直前のステージ = r現在のステージ;
1490 foreach (STPlugin pg in this.listプラグイン)
1492 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1493 pg.plugin.Onステージ変更();
1494 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1497 this.tガベージコレクションを実行する();
1499 //-----------------------------
1503 //-----------------------------
1507 case CStage.Eステージ.選曲:
1509 //-----------------------------
1510 switch (this.n進行描画の戻り値)
1512 case (int)CStage選曲.E戻り値.タイトルに戻る:
1514 //-----------------------------
1516 Trace.TraceInformation("----------------------");
1517 Trace.TraceInformation("■ タイトル");
1519 r直前のステージ = r現在のステージ;
1520 r現在のステージ = stageタイトル;
1522 foreach (STPlugin pg in this.listプラグイン)
1524 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1525 pg.plugin.Onステージ変更();
1526 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1529 this.tガベージコレクションを実行する();
1531 //-----------------------------
1534 case (int)CStage選曲.E戻り値.選曲した:
1536 //-----------------------------
1538 Trace.TraceInformation("----------------------");
1539 Trace.TraceInformation("■ 曲読み込み");
1541 r直前のステージ = r現在のステージ;
1542 r現在のステージ = stage曲読み込み;
1544 foreach (STPlugin pg in this.listプラグイン)
1546 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1547 pg.plugin.Onステージ変更();
1548 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1551 this.tガベージコレクションを実行する();
1553 //-----------------------------
1556 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1558 //-----------------------------
1560 Trace.TraceInformation("----------------------");
1561 Trace.TraceInformation("■ コンフィグ");
1563 r直前のステージ = r現在のステージ;
1564 r現在のステージ = stageコンフィグ;
1566 foreach (STPlugin pg in this.listプラグイン)
1568 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1569 pg.plugin.Onステージ変更();
1570 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1573 this.tガベージコレクションを実行する();
1575 //-----------------------------
1578 case (int)CStage選曲.E戻り値.スキン変更:
1581 //-----------------------------
1583 Trace.TraceInformation("----------------------");
1584 Trace.TraceInformation("■ スキン切り替え");
1585 stageChangeSkin.On活性化();
1586 r直前のステージ = r現在のステージ;
1587 r現在のステージ = stageChangeSkin;
1589 //-----------------------------
1592 //-----------------------------
1596 case CStage.Eステージ.曲読み込み:
1598 //-----------------------------
1599 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1600 if (this.n進行描画の戻り値 != 0)
1602 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1604 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1605 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1609 Trace.TraceInformation("曲の読み込みを中止しました。");
1610 this.tガベージコレクションを実行する();
1611 Trace.TraceInformation("----------------------");
1612 Trace.TraceInformation("■ 選曲");
1614 r直前のステージ = r現在のステージ;
1616 foreach (STPlugin pg in this.listプラグイン)
1618 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1619 pg.plugin.Onステージ変更();
1620 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1626 Trace.TraceInformation("----------------------");
1627 Trace.TraceInformation("■ 演奏(ドラム画面)");
1628 r直前のステージ = r現在のステージ;
1629 r現在のステージ = stage演奏画面;
1631 foreach (STPlugin pg in this.listプラグイン)
1633 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1634 pg.plugin.Onステージ変更();
1635 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1638 this.tガベージコレクションを実行する();
1640 //-----------------------------
1644 case CStage.Eステージ.演奏:
1646 //-----------------------------
1647 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1648 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1649 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1650 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1651 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1653 //swlist1.Add( Convert.ToInt32(n1) );
1654 //swlist2.Add( Convert.ToInt32(n2) );
1655 //swlist3.Add( Convert.ToInt32( n3 ) );
1656 //swlist4.Add( Convert.ToInt32( n4 ) );
1657 //swlist5.Add( Convert.ToInt32( n5 ) );
1659 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1660 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1662 DTXVmode.Refreshed = false;
1664 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1666 CDTXMania.Instance.stage演奏画面.t停止();
1668 if (previewSound != null)
1670 this.previewSound.tサウンドを停止する();
1671 this.previewSound.Dispose();
1672 this.previewSound = null;
1677 // for ( int i = 0; i < swlist1.Count; i++ )
1679 // int d1 = swlist1[ i ];
1680 // int d2 = swlist2[ i ];
1681 // int d3 = swlist3[ i ];
1682 // int d4 = swlist4[ i ];
1683 // int d5 = swlist5[ i ];
1685 // int dif = d1 - lastd;
1687 // if ( 16 <= dif && dif <= 17 )
1694 // 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 );
1706 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1708 if (DTXVmode.NeedReload)
1710 CDTXMania.Instance.stage演奏画面.t再読込();
1711 if (DTXVmode.GRmode)
1713 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1717 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1719 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1720 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1721 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1723 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1724 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1729 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1735 switch (this.n進行描画の戻り値)
1737 case (int)E演奏画面の戻り値.再読込_再演奏:
1738 #region [ DTXファイルを再読み込みして、再演奏 ]
1743 r直前のステージ = r現在のステージ;
1744 r現在のステージ = stage曲読み込み;
1745 this.tガベージコレクションを実行する();
1749 //case (int) E演奏画面の戻り値.再演奏:
1750 #region [ 再読み込み無しで、再演奏 ]
1754 case (int)E演奏画面の戻り値.継続:
1757 case (int)E演奏画面の戻り値.演奏中断:
1759 //-----------------------------
1760 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1761 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1763 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1768 //for (int i = 0; i < swlist1.Count; i++)
1770 // int d1 = swlist1[ i ];
1771 // int d2 = swlist2[ i ];
1772 // int d3 = swlist3[ i ];
1773 // int d4 = swlist4[ i ];
1775 // int dif = d1 - lastd;
1777 // if ( 16 <= dif && dif <= 17 )
1784 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1793 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1794 //---------------------
1795 foreach (STPlugin pg in this.listプラグイン)
1797 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1798 pg.plugin.On演奏キャンセル(scoreIni);
1799 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1801 //---------------------
1809 base.Window.Close();
1813 Trace.TraceInformation("----------------------");
1814 Trace.TraceInformation("■ 選曲");
1816 r直前のステージ = r現在のステージ;
1819 #region [ プラグイン Onステージ変更() の呼び出し ]
1820 //---------------------
1821 foreach (STPlugin pg in this.listプラグイン)
1823 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1824 pg.plugin.Onステージ変更();
1825 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1827 //---------------------
1830 this.tガベージコレクションを実行する();
1833 //-----------------------------
1836 case (int)E演奏画面の戻り値.ステージ失敗:
1837 #region [ 演奏失敗(StageFailed) ]
1838 //-----------------------------
1839 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1841 #region [ プラグイン On演奏失敗() の呼び出し ]
1842 //---------------------
1843 foreach (STPlugin pg in this.listプラグイン)
1845 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1846 pg.plugin.On演奏失敗(scoreIni);
1847 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1849 //---------------------
1857 base.Window.Close();
1861 Trace.TraceInformation("----------------------");
1862 Trace.TraceInformation("■ 選曲");
1864 r直前のステージ = r現在のステージ;
1867 #region [ プラグイン Onステージ変更() の呼び出し ]
1868 //---------------------
1869 foreach (STPlugin pg in this.listプラグイン)
1871 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1872 pg.plugin.Onステージ変更();
1873 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1875 //---------------------
1878 this.tガベージコレクションを実行する();
1881 //-----------------------------
1884 case (int)E演奏画面の戻り値.ステージクリア:
1886 //-----------------------------
1887 STDGBSValue<CScoreIni.C演奏記録> record;
1888 record = stage演奏画面.Record;
1890 double playskill = 0.0;
1892 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
1894 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
1896 playskill = record[inst].db演奏型スキル値;
1900 string str = "Cleared";
1901 switch (CScoreIni.t総合ランク値を計算して返す(record))
1903 case CScoreIni.ERANK.SS:
1904 str = string.Format("Cleared (SS: {0:F2})", playskill);
1907 case CScoreIni.ERANK.S:
1908 str = string.Format("Cleared (S: {0:F2})", playskill);
1911 case CScoreIni.ERANK.A:
1912 str = string.Format("Cleared (A: {0:F2})", playskill);
1915 case CScoreIni.ERANK.B:
1916 str = string.Format("Cleared (B: {0:F2})", playskill);
1919 case CScoreIni.ERANK.C:
1920 str = string.Format("Cleared (C: {0:F2})", playskill);
1923 case CScoreIni.ERANK.D:
1924 str = string.Format("Cleared (D: {0:F2})", playskill);
1927 case CScoreIni.ERANK.E:
1928 str = string.Format("Cleared (E: {0:F2})", playskill);
1931 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1932 str = "Cleared (No chips)";
1936 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
1938 #region [ プラグイン On演奏クリア() の呼び出し ]
1939 //---------------------
1940 foreach (STPlugin pg in this.listプラグイン)
1942 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1943 pg.plugin.On演奏クリア(scoreIni);
1944 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1946 //---------------------
1950 Trace.TraceInformation("----------------------");
1951 Trace.TraceInformation("■ 結果");
1952 stage結果.st演奏記録 = record;
1953 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
1955 r直前のステージ = r現在のステージ;
1958 #region [ プラグイン Onステージ変更() の呼び出し ]
1959 //---------------------
1960 foreach (STPlugin pg in this.listプラグイン)
1962 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1963 pg.plugin.Onステージ変更();
1964 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1966 //---------------------
1970 //-----------------------------
1973 //-----------------------------
1977 case CStage.Eステージ.結果:
1979 //-----------------------------
1980 if (this.n進行描画の戻り値 != 0)
1982 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
1983 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
1984 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1986 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
1994 Trace.TraceInformation("----------------------");
1995 Trace.TraceInformation("■ 選曲");
1997 r直前のステージ = r現在のステージ;
2000 foreach (STPlugin pg in this.listプラグイン)
2002 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2003 pg.plugin.Onステージ変更();
2004 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2007 this.tガベージコレクションを実行する();
2011 base.Window.Close();
2014 //-----------------------------
2018 case CStage.Eステージ.ChangeSkin:
2020 //-----------------------------
2021 if (this.n進行描画の戻り値 != 0)
2024 Trace.TraceInformation("----------------------");
2025 Trace.TraceInformation("■ 選曲");
2027 r直前のステージ = r現在のステージ;
2029 this.tガベージコレクションを実行する();
2031 //-----------------------------
2035 case CStage.Eステージ.終了:
2037 //-----------------------------
2038 if (this.n進行描画の戻り値 != 0)
2042 //-----------------------------
2047 this.Device.EndScene();
2048 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2049 // (つまり、Present()は、Draw()完了後に実行される)
2050 #if !GPUFlushAfterPresent
2051 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2053 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2055 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2058 #region [ マウスカーソル消去制御 ]
2059 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2061 #region [ 全画面・ウインドウ切り替え ]
2062 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2064 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2065 Instance.t全画面_ウィンドウモード切り替え();
2066 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2069 #region [ 垂直基線同期切り替え ]
2070 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2072 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2073 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2074 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2075 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2076 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2077 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2078 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2081 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2086 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2087 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2092 /// XML ファイルからオブジェクトを生成します。
2094 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2095 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2096 public static object DeserializeXML(string xmlpath, Type t)
2101 if (File.Exists(xmlpath))
2103 using (XmlReader xr = XmlReader.Create(xmlpath))
2105 DataContractSerializer serializer = new DataContractSerializer(t);
2106 ret = serializer.ReadObject(xr);
2112 Trace.TraceWarning( e.Message );
2119 /// オブジェクトから XML ファイルを生成します。
2121 /// <param name="xmlfile">XML ファイルのパス。</param>
2122 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2123 public static void SerializeXML(string xmlpath, object obj)
2125 XmlWriterSettings settings = new XmlWriterSettings();
2126 settings.IndentChars = " ";
2127 settings.Indent = true;
2128 settings.NewLineChars = Environment.NewLine;
2129 settings.Encoding = new System.Text.UTF8Encoding(false);
2130 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2132 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2134 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2135 serializer.WriteObject(xw, obj);
2140 public void SaveConfig()
2142 #region [ Skinパスの絶対パス→相対パス変換 ]
2143 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2144 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2145 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2147 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2148 // → 初期値として Default/ を設定する。
2149 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2152 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2153 // そのため、以下の処理を通すために、いったん絶対パスに変換
2154 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2156 ConfigIni.strSystemSkinSubfolderPath.Value =
2157 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2160 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2161 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2162 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2163 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2164 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2166 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2168 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2171 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2174 public void LoadConfig()
2176 string path = strEXEのあるフォルダ + "Config.xml";
2178 if (!File.Exists(path))
2182 if (File.Exists(path))
2184 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2185 if (ConfigIni == null)
2187 ConfigIni = new CConfigXml();
2190 // Skinパスの相対パスを、絶対パスに変換
2191 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2193 ConfigIni.strSystemSkinSubfolderPath.Value =
2194 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2199 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2201 public void UpdateCoordinates()
2203 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2206 if (File.Exists(coordXml))
2208 using (XmlReader xr = XmlReader.Create(coordXml))
2210 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2213 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2215 catch (SerializationException e)
2217 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2222 XmlWriterSettings settings = new XmlWriterSettings();
2223 settings.IndentChars = " ";
2224 settings.Indent = true;
2225 settings.NewLineChars = Environment.NewLine;
2226 settings.Encoding = new System.Text.UTF8Encoding( false );
2227 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2229 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2230 //ns.Add( String.Empty, String.Empty );
2232 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2233 //serializer.Serialize( sw, item, ns );
2236 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2237 serializer.WriteObject( xw, Coordinates );
2238 //serializer.WriteStartObject( xw, Coordinates );
2239 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2240 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2241 //serializer.WriteObjectContent( xw, Coordinates );
2242 //serializer.WriteEndObject( xw );
2246 if (File.Exists(coordXml))
2248 using (XmlReader xr = XmlReader.Create(coordXml))
2250 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2251 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2258 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2260 //public class MyXmlTextWriter : XmlTextWriter
2262 // private bool _ignoreAttr = false;
2264 // public MyXmlTextWriter( TextWriter w )
2267 // Debug.WriteLine( "create" );
2270 // public override string LookupPrefix( string ns )
2272 // Debug.WriteLine( "luprefix" );
2273 // return string.Empty;
2276 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2278 // Debug.WriteLine( "writestartattribute" );
2279 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2281 // Debug.WriteLine( "[!]" );
2282 // this._ignoreAttr = true;
2287 // public override void WriteEndAttribute()
2289 // if ( this._ignoreAttr )
2291 // this._ignoreAttr = false;
2294 // base.WriteEndAttribute();
2297 // public override void WriteString( string text )
2299 // Debug.WriteLine( "ws" );
2300 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2304 // base.WriteString( text );
2307 // public override void WriteStartElement( string prefix, string localName, string ns )
2309 // Debug.WriteLine( "wse" );
2310 // base.WriteStartElement( null, localName, null );
2314 public void ShowWindowTitleWithSoundType()
2317 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2319 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2321 base.Window.Text = strWindowTitle;
2322 if (!this.DTX2WAVmode.Enabled)
2324 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2330 private bool b終了処理完了済み;
2331 private static CDTX dtx;
2332 private List<CActivity> listトップレベルActivities;
2333 private int n進行描画の戻り値;
2334 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2335 private string strWindowTitle
2339 if (DTXVmode.Enabled)
2341 return "DTXMViewer release " + VERSION;
2343 else if (DTX2WAVmode.Enabled)
2345 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename);
2349 return "DTXMania .NET style release " + VERSION;
2353 private CSound previewSound;
2354 private CMouseHideControl cMouseHideControl = null;
2356 private void t終了処理()
2358 if (!this.b終了処理完了済み)
2360 Trace.TraceInformation("----------------------");
2361 Trace.TraceInformation("■ アプリケーションの終了");
2363 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2365 #region [ 曲検索の終了処理 ]
2366 //---------------------
2367 if (actEnumSongs != null)
2369 Trace.TraceInformation("曲検索actの終了処理を行います。");
2373 actEnumSongs.On非活性化();
2374 actEnumSongs = null;
2375 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2379 Trace.TraceError(e.Message);
2380 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2387 //---------------------
2389 #region [ 現在のステージの終了処理 ]
2390 //---------------------
2391 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2393 Trace.TraceInformation("現在のステージを終了します。");
2398 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2405 //---------------------
2408 #region [ 選曲ステージの終了処理 ]
2412 #region [ プラグインの終了処理 ]
2413 //---------------------
2414 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2416 Trace.TraceInformation("すべてのプラグインを終了します。");
2420 foreach (STPlugin st in this.listプラグイン)
2422 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2423 st.plugin.OnUnmanagedリソースの解放();
2424 st.plugin.OnManagedリソースの解放();
2426 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2429 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2436 //---------------------
2438 #region [ 曲リストの終了処理 ]
2439 //---------------------
2440 if (Songs管理 != null)
2442 Trace.TraceInformation("曲リストの終了処理を行います。");
2447 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2449 catch (Exception exception)
2451 Trace.TraceError(exception.Message);
2452 Trace.TraceError("曲リストの終了処理に失敗しました。");
2460 //---------------------
2462 #region [ スキンの終了処理 ]
2463 //---------------------
2466 Trace.TraceInformation("スキンの終了処理を行います。");
2472 Trace.TraceInformation("スキンの終了処理を完了しました。");
2474 catch (Exception exception2)
2476 Trace.TraceError(exception2.Message);
2477 Trace.TraceError("スキンの終了処理に失敗しました。");
2484 //---------------------
2486 #region [ DirectSoundの終了処理 ]
2487 //---------------------
2488 if (Sound管理 != null)
2490 Trace.TraceInformation("DirectSound の終了処理を行います。");
2496 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2498 catch (Exception exception3)
2500 Trace.TraceError(exception3.Message);
2501 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2508 //---------------------
2510 #region [ パッドの終了処理 ]
2511 //---------------------
2514 Trace.TraceInformation("パッドの終了処理を行います。");
2519 Trace.TraceInformation("パッドの終了処理を完了しました。");
2521 catch (Exception exception4)
2523 Trace.TraceError(exception4.Message);
2524 Trace.TraceError("パッドの終了処理に失敗しました。");
2531 //---------------------
2533 #region [ DirectInput, MIDI入力の終了処理 ]
2534 //---------------------
2535 if (Input管理 != null)
2537 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2543 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2545 catch (Exception exception5)
2547 Trace.TraceError(exception5.Message);
2548 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2555 //---------------------
2557 #region [ 文字コンソールの終了処理 ]
2558 //---------------------
2559 if (act文字コンソール != null)
2561 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2565 act文字コンソール.On非活性化();
2567 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2569 catch (Exception exception6)
2571 Trace.TraceError(exception6.Message);
2572 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2579 //---------------------
2581 #region [ FPSカウンタの終了処理 ]
2582 //---------------------
2583 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2591 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2597 //---------------------
2599 #region [ タイマの終了処理 ]
2600 //---------------------
2601 Trace.TraceInformation("タイマの終了処理を行います。");
2609 Trace.TraceInformation("タイマの終了処理を完了しました。");
2613 Trace.TraceInformation("タイマは使用されていません。");
2620 //---------------------
2622 #region [ Config.iniの出力 ]
2623 //---------------------
2624 Trace.TraceInformation("Config.xml を出力します。");
2625 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2626 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2628 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2631 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2633 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2636 string str = strEXEのあるフォルダ + "Config.xml";
2640 if (DTXVmode.Enabled)
2642 DTXVmode.tUpdateConfigIni();
2643 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2645 else if (DTX2WAVmode.Enabled)
2647 DTX2WAVmode.tUpdateConfigIni();
2648 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2652 CDTXMania.Instance.SaveConfig();
2653 Trace.TraceInformation("保存しました。({0})", str);
2658 Trace.TraceError(e.Message);
2659 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2665 //---------------------
2667 #region [ DTXVmodeの終了処理 ]
2668 //---------------------
2669 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2673 if (DTXVmode != null)
2676 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2680 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2687 //---------------------
2689 #region [ DirectXの終了処理 ]
2690 //---------------------
2691 base.GraphicsDeviceManager.Dispose();
2692 //---------------------
2694 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2697 this.b終了処理完了済み = true;
2700 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2702 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2703 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2704 CScoreIni ini = new CScoreIni(strFilename);
2705 if (!File.Exists(strFilename))
2707 ini.stファイル.Title = DTX.TITLE;
2708 ini.stファイル.Name = DTX.strファイル名;
2709 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2710 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2712 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2713 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2714 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2715 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2717 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2718 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2719 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2720 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2722 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2723 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2724 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2725 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2728 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2729 isUpdated = CScoreIni.t更新条件を取得する();
2730 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2732 if (isUpdated.Drums)
2734 ini.stファイル.PlayCountDrums++;
2736 if (isUpdated.Guitar)
2738 ini.stファイル.PlayCountGuitar++;
2742 ini.stファイル.PlayCountBass++;
2744 ini.tヒストリを追加する(str新ヒストリ行);
2747 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2748 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2749 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2750 for (int j = 0; j < ini.stファイル.History.Length; j++)
2752 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2756 if (ConfigIni.bScoreIni)
2758 ini.t書き出し(strFilename);
2763 private void tガベージコレクションを実行する()
2765 GC.Collect(0, GCCollectionMode.Optimized, true );
2766 GC.WaitForPendingFinalizers();
2767 GC.Collect(0, GCCollectionMode.Forced, true );
2768 GC.WaitForPendingFinalizers();
2770 private void tプラグイン検索と生成()
2772 this.listプラグイン = new List<STPlugin>();
2774 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2775 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2777 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2779 if (this.listプラグイン.Count > 0)
2780 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2783 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2785 var domain = (AppDomain)sender;
2787 foreach (var assembly in domain.GetAssemblies())
2789 if (assembly.FullName == args.Name)
2794 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2796 // 指定されたパスが存在しないとエラー
2797 if (!Directory.Exists(strプラグインフォルダパス))
2799 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2803 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2806 // (1) すべての *.dll について…
2807 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2808 foreach (string dllName in strDLLs)
2810 if (Path.GetExtension(dllName).ToLower() != ".dll")
2816 // (1-1) dll をアセンブリとして読み込む。
2817 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2819 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2820 foreach (Type t in asm.GetTypes())
2822 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2823 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2825 // (1-4) クラス名からインスタンスを作成する
2826 var st = new STPlugin()
2828 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2829 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2830 strアセンブリ簡易名 = asm.GetName().Name,
2831 Version = asm.GetName().Version,
2834 // (1-5) プラグインリストへ登録
2835 this.listプラグイン.Add(st);
2836 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2840 catch (System.Reflection.ReflectionTypeLoadException e)
2842 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2843 Trace.TraceInformation(e.ToString());
2844 Trace.TraceInformation(e.Message);
2846 StringBuilder sb = new StringBuilder();
2847 foreach (Exception exSub in e.LoaderExceptions)
2849 sb.AppendLine(exSub.Message);
2850 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2851 if (exFileNotFound != null)
2853 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2855 sb.AppendLine("Fusion Log:");
2856 sb.AppendLine(exFileNotFound.FusionLog);
2861 string errorMessage = sb.ToString();
2862 //Display or log the error based on your application.
2863 Trace.TraceInformation(errorMessage);
2868 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2869 Trace.TraceInformation(e.ToString());
2870 Trace.TraceInformation(e.Message);
2874 // (2) サブフォルダがあれば再帰する
2875 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
2876 foreach (string dir in strDirs)
2877 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
2880 #region [ Windowイベント処理 ]
2881 private void Window_ApplicationActivated( object sender, EventArgs e )
2883 this.bApplicationActive = true;
2885 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2887 this.bApplicationActive = false;
2888 if (cMouseHideControl != null) cMouseHideControl.Show();
2890 private void Window_KeyDown(object sender, KeyEventArgs e)
2892 if (e.KeyCode == Keys.Menu)
2895 e.SuppressKeyPress = true;
2897 else if ((e.KeyCode == Keys.Return) && e.Alt)
2899 if (ConfigIni != null)
2901 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
2902 this.t全画面_ウィンドウモード切り替え();
2905 e.SuppressKeyPress = true;
2909 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
2911 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
2913 if( (int) captureCode > 0 &&
2914 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
2916 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2917 string strFullPath =
2918 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
2919 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
2920 SaveResultScreen( strFullPath );
2925 private void Window_MouseUp(object sender, MouseEventArgs e)
2930 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
2932 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
2934 ConfigIni.bウィンドウモード = false;
2935 this.t全画面_ウィンドウモード切り替え();
2938 private void Window_MouseMove(object sender, MouseEventArgs e)
2940 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
2943 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
2945 if (ConfigIni.bウィンドウモード)
2947 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2948 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
2951 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
2952 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
2956 //Stopwatch sw = new Stopwatch();
2957 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
2961 private class CMouseHideControl
2963 private Point lastPosition;
2964 private CCounter ccMouseShow;
2965 private bool bマウスカーソル表示中;
2970 public CMouseHideControl()
2972 ccMouseShow = new CCounter();
2973 lastPosition = Cursor.Position;
2980 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
2983 public void tHideCursorIfNeed()
2986 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
2987 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
2989 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
2990 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
2998 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3000 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3001 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3003 Point currentPosition = Cursor.Position;
3004 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3005 if (lastPosition != currentPosition)
3007 //Trace.TraceInformation("移動発生");
3008 lastPosition = currentPosition;
3023 bマウスカーソル表示中 = false;
3030 private void PutSystemLog()
3032 System.Management.ManagementClass mc =
3033 new System.Management.ManagementClass("Win32_Processor");
3034 System.Management.ManagementObjectCollection moc = mc.GetInstances();
3035 foreach (System.Management.ManagementObject mo in moc)
3037 Trace.TraceInformation("-------------------------");
3038 Trace.TraceInformation("CPU Information:");
3039 //Trace.TraceInformation("DeviceID = {0}", mo["DeviceID"]);
3040 Trace.TraceInformation("Name = {0}", mo["Name"]);
3041 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
3042 Trace.TraceInformation("L2CacheSize = {0}KB", mo["L2CacheSize"]);
3043 Trace.TraceInformation("L3CacheSize = {0}KB", mo["L3CacheSize"]);
3044 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
3049 //System.Management.ManagementClass mc =
3050 // new System.Management.ManagementClass("Win32_OperatingSystem");
3051 //System.Management.ManagementObjectCollection moc = mc.GetInstances();
3053 new System.Management.ManagementClass("Win32_OperatingSystem");
3054 moc = mc.GetInstances();
3055 foreach (System.Management.ManagementObject mo in moc)
3057 Trace.TraceInformation("-------------------------");
3058 Trace.TraceInformation("OS Information:");
3059 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
3060 Trace.TraceInformation("OS: " + mo["Caption"]);
3061 //バージョン(Windows 8.1では、「6.3.9600」)
3062 Trace.TraceInformation("Version: " + mo["Version"]);
3063 //ビルド番号(Windows 8.1では「9600」)
3064 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
3066 //サービスパック(Windows 8.1ではNULL)
3067 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
3069 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
3071 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
3073 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
3078 Trace.TraceInformation("-------------------------");
3079 Trace.TraceInformation("General Environment Information:");
3080 //Trace.TraceInformation("OS Version: " + Environment.OSVersion); // fake version will be returned (due to the lack of manifest settings)
3081 //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
3082 Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
3083 Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
3085 var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
3086 Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
3087 Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
3088 Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
3089 Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
3090 //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
3092 mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
3093 moc = mc.GetInstances();
3094 Trace.TraceInformation("-------------------------");
3095 Trace.TraceInformation("Physical Memory Information:");
3096 foreach (System.Management.ManagementObject mo in moc)
3098 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
3103 mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
3104 moc = mc.GetInstances();
3105 foreach (System.Management.ManagementObject mo in moc)
3107 Trace.TraceInformation("-------------------------");
3108 Trace.TraceInformation("Display Adapter Information:");
3109 Trace.TraceInformation("Name: " + mo["Name"]);
3110 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
3111 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
3112 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
3113 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3118 mc = new System.Management.ManagementClass("Win32_VideoController");
3119 moc = mc.GetInstances();
3120 foreach (System.Management.ManagementObject mo in moc)
3122 Trace.TraceInformation("-------------------------");
3123 Trace.TraceInformation("Video Controller Information:");
3124 Trace.TraceInformation("Description: " + mo["Description"]);
3125 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3126 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3131 mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3132 moc = mc.GetInstances();
3133 foreach (System.Management.ManagementObject mo in moc)
3135 Trace.TraceInformation("-------------------------");
3136 Trace.TraceInformation("Display Information:");
3137 Trace.TraceInformation("Description: " + mo["Description"]);
3138 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3139 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3140 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3141 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3146 mc = new System.Management.ManagementClass("Win32_SoundDevice");
3147 moc = mc.GetInstances();
3148 foreach (System.Management.ManagementObject mo in moc)
3150 Trace.TraceInformation("-------------------------");
3151 Trace.TraceInformation("Sound Information:");
3152 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3153 Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3154 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3159 Trace.TraceInformation("----------------------");
3160 Trace.TraceInformation("DTXMania settings:");
3161 Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3162 Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3163 Trace.TraceInformation("----------------------");