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/DTX2WAVとしての起動 ]
300 strコンパクトモードファイル = "";
301 string[] commandLineArgs = Environment.GetCommandLineArgs();
302 if ((commandLineArgs != null) && (commandLineArgs.Length > 1))
307 for (int i = 1; i < commandLineArgs.Length; i++)
311 arg += " " + "\"" + commandLineArgs[i] + "\"";
315 arg += commandLineArgs[i];
318 CommandParse.ParseArguments(arg, ref DTXVmode, ref DTX2WAVmode);
319 if (DTXVmode.Enabled)
321 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
322 strコンパクトモードファイル = DTXVmode.filename;
323 switch (DTXVmode.soundDeviceType) // サウンド再生方式の設定
325 case ESoundDeviceType.DirectSound:
326 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.DSound;
328 case ESoundDeviceType.ExclusiveWASAPI:
329 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
331 case ESoundDeviceType.SharedWASAPI:
332 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
334 case ESoundDeviceType.ASIO:
335 ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.ASIO;
336 ConfigIni.strASIODevice.Index = DTXVmode.nASIOdevice;
340 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
341 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
344 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
348 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
351 CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
352 CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow; // #36612 2016.9.12 yyagi
353 CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
354 CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
355 CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
356 CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
358 else if (DTX2WAVmode.Enabled)
360 strコンパクトモードファイル = DTX2WAVmode.dtxfilename;
361 #region [ FDKへの録音設定 ]
362 FDK.CSound管理.strRecordInputDTXfilename = DTX2WAVmode.dtxfilename;
363 FDK.CSound管理.strRecordOutFilename = DTX2WAVmode.outfilename;
364 FDK.CSound管理.strRecordFileType = DTX2WAVmode.Format.ToString();
365 for (int i = 0; i < (int)FDK.CSound.EInstType.Unknown; i++)
367 FDK.CSound管理.nMixerVolume[ i ] = DTX2WAVmode.nMixerVolume[ i ];
369 ConfigIni.nMasterVolume.Value = DTX2WAVmode.nMixerVolume[(int)FDK.CSound.EInstType.Unknown]; // [5](Unknown)のところにMasterVolumeが入ってくるので注意
372 CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
373 CDTXMania.Instance.ConfigIni.bEventDrivenWASAPI.Value = false;
375 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = false;
376 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = false;
377 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
379 CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
380 CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;
381 CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
382 CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
383 CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
384 CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
387 CDTXMania.instance.ConfigIni.bAutoPlay.LC.Value = true;
388 CDTXMania.instance.ConfigIni.bAutoPlay.HH.Value = true;
389 CDTXMania.instance.ConfigIni.bAutoPlay.HHO.Value = true;
390 CDTXMania.instance.ConfigIni.bAutoPlay.SD.Value = true;
391 CDTXMania.instance.ConfigIni.bAutoPlay.BD.Value = true;
392 CDTXMania.instance.ConfigIni.bAutoPlay.HT.Value = true;
393 CDTXMania.instance.ConfigIni.bAutoPlay.LT.Value = true;
394 CDTXMania.instance.ConfigIni.bAutoPlay.FT.Value = true;
395 CDTXMania.instance.ConfigIni.bAutoPlay.CY.Value = true;
396 CDTXMania.instance.ConfigIni.bAutoPlay.RD.Value = true;
398 CDTXMania.instance.ConfigIni.bAutoPlay.GtR.Value = true;
399 CDTXMania.instance.ConfigIni.bAutoPlay.GtG.Value = true;
400 CDTXMania.instance.ConfigIni.bAutoPlay.GtB.Value = true;
401 CDTXMania.instance.ConfigIni.bAutoPlay.GtPick.Value = true;
402 //CDTXMania.instance.ConfigIni.bAutoPlay.GtWail.Value = true; // 無くてもよい 処理不可削減のため、敢えてWailはAutoにしない
403 CDTXMania.instance.ConfigIni.bAutoPlay.BsR.Value = true;
404 CDTXMania.instance.ConfigIni.bAutoPlay.BsG.Value = true;
405 CDTXMania.instance.ConfigIni.bAutoPlay.BsB.Value = true;
406 CDTXMania.instance.ConfigIni.bAutoPlay.BsPick.Value = true;
407 //CDTXMania.instance.ConfigIni.bAutoPlay.BsWail.Value = true;
410 CDTXMania.instance.ConfigIni.bFillin.Value = false;
411 CDTXMania.instance.ConfigIni.bAudience.Value = false;
413 CDTXMania.instance.ConfigIni.bStoicMode.Value = false;
415 CDTXMania.instance.ConfigIni.eSudHidInv.Drums.Value = ESudHidInv.FullInv;
416 CDTXMania.instance.ConfigIni.eSudHidInv.Guitar.Value = ESudHidInv.FullInv;
417 CDTXMania.instance.ConfigIni.eSudHidInv.Bass.Value = ESudHidInv.FullInv;
420 CDTXMania.instance.ConfigIni.eDark.Value = EDark.Full;
423 CDTXMania.instance.ConfigIni.nPolyphonicSounds.Value = 4;
426 CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
429 CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
430 CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
431 CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
434 CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
435 CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
438 CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100;
441 CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
444 CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
445 CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
446 CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
449 CDTXMania.instance.ConfigIni.bDisplayCombo.Drums.Value = false;
450 CDTXMania.instance.ConfigIni.bDisplayCombo.Guitar.Value = false;
451 CDTXMania.instance.ConfigIni.bDisplayCombo.Bass.Value = false;
452 CDTXMania.instance.ConfigIni.bDisplayJudge.Drums.Value = false;
453 CDTXMania.instance.ConfigIni.bDisplayJudge.Guitar.Value = false;
454 CDTXMania.instance.ConfigIni.bDisplayJudge.Bass.Value = false;
458 //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
459 CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
462 CDTXMania.instance.ConfigIni.bBGA.Value = false;
463 CDTXMania.instance.ConfigIni.bAVI.Value = false;
466 CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
467 CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
470 CDTXMania.Instance.ConfigIni.bEmphasizePlaySound.Drums.Value = false;
471 CDTXMania.Instance.ConfigIni.bEmphasizePlaySound.Guitar.Value = false;
472 CDTXMania.Instance.ConfigIni.bEmphasizePlaySound.Bass.Value = false;
478 strコンパクトモードファイル = commandLineArgs[1];
481 if (!File.Exists(strコンパクトモードファイル)) // #32985 2014.1.23 yyagi
483 Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
485 Environment.Exit(-1);
487 if (strコンパクトモードファイル == "") // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
489 Environment.Exit(-1);
493 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
497 if (DTXVmode.Enabled)
499 Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
501 else if (DTX2WAVmode.Enabled)
503 Trace.TraceInformation("DTX2WAVモードで起動します。[{0}]", strコンパクトモードファイル);
507 Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
512 Trace.TraceInformation("通常モードで起動します。");
516 #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
517 CPowerPlan.BackupCurrentPowerPlan();
518 if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
520 CPowerPlan.ChangeHighPerformance();
524 #region [ Input管理 の初期化 ]
525 Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
529 bool bUseMIDIIn = !DTXVmode.Enabled;
530 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
531 foreach (IInputDevice device in Input管理.list入力デバイス)
533 if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
536 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
540 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
543 foreach (IInputDevice device2 in Input管理.list入力デバイス)
545 if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
547 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
549 if (device2.GUID.Equals(pair.Value))
551 ((CInputJoystick)device2).SetID(pair.Key);
558 Trace.TraceInformation("DirectInput の初期化を完了しました。");
560 catch (Exception exception2)
562 Trace.TraceError(exception2.Message);
563 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
565 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
566 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
576 // #30675 2013.02.04 ikanick add
577 base.Window.StartPosition = FormStartPosition.Manual;
578 base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
579 // 事前にDTXVmodeの実体を作っておくこと
580 base.Window.Text = this.strWindowTitle;
581 //base.Window.StartPosition = FormStartPosition.Manual;
582 //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
584 // #34510 yyagi 2010.10.31 to change window size got from Config.ini
585 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
586 #if !WindowedFullscreen
587 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
588 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
590 currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
591 #if !WindowedFullscreen
594 // #23510 2010.11.04 yyagi: to support maximizing window
595 base.Window.MaximizeBox = true;
596 // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
597 base.Window.FormBorderStyle = FormBorderStyle.Sizable;
598 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
599 base.Window.ShowIcon = true;
600 base.Window.Icon = Properties.Resources.dtx;
601 base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
602 base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
603 // #23510 2010.11.13 yyagi: to go fullscreen mode
604 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
605 // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
606 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
607 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
608 base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
609 base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
612 #region [ Direct3D9Exを使うかどうか判定 ]
615 #region [ Direct3D9 デバイスの生成 ]
616 DeviceSettings settings = new DeviceSettings();
617 #if WindowedFullscreen
618 // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
619 settings.Windowed = true;
621 settings.Windowed = ConfigIni.bウィンドウモード;
623 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
624 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
625 settings.EnableVSync = ConfigIni.bVSyncWait;
626 //settings.MultisampleType = MultisampleType.FourSamples;
627 //settings.MultisampleQuality = 3;
628 //settings.MultisampleType = MultisampleType.NonMaskable;
629 //settings.Multithreaded = true;
634 base.GraphicsDeviceManager.ChangeDevice(settings);
636 catch (DeviceCreationException e)
638 Trace.TraceError(e.ToString());
639 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
640 Environment.Exit(-1);
642 Trace.TraceInformation("DeviceCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
643 Trace.TraceInformation("DeviceCaps2 = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
644 Trace.TraceInformation("MaxTextureWidth = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
645 Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
646 Trace.TraceInformation("TextureCaps = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
647 Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
648 Trace.TraceInformation("DeviceStatics = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
650 base.IsFixedTimeStep = false;
651 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
652 // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
653 base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
654 // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
655 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
656 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
657 #if WindowedFullscreen
658 // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
659 this.t全画面_ウィンドウモード切り替え();
661 actFlushGPU = new CActFlushGPU();
664 if (DTX2WAVmode.Enabled)
666 this.Window.WindowState = FormWindowState.Minimized; //DTX2WAVモード時は自動的に最小化したいが、まだうまくいかない
671 #region [ Skin の初期化 ]
672 Trace.TraceInformation("スキンの初期化を行います。");
677 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
678 CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
679 // 旧指定のSkinフォルダが消滅していた場合に備える
680 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
681 Trace.TraceInformation("スキンの初期化を完了しました。");
685 Trace.TraceInformation("スキンの初期化に失敗しました。");
693 #region [ Skin配下にある言語リソースの確認と初期化 ]
694 Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
698 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
699 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
701 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
704 Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
708 Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
720 #region [ Timer の初期化 ]
721 Trace.TraceInformation("タイマの初期化を行います。");
725 Timer = new CTimer(CTimer.E種別.MultiMedia);
726 Trace.TraceInformation("タイマの初期化を完了しました。");
734 #region [ マウス消去用のクラスを初期化 ]
735 cMouseHideControl = new CMouseHideControl();
738 #region [ FPS カウンタの初期化 ]
739 Trace.TraceInformation("FPSカウンタの初期化を行います。");
744 Trace.TraceInformation("FPSカウンタを生成しました。");
752 #region [ act文字コンソールの初期化 ]
753 Trace.TraceInformation("文字コンソールの初期化を行います。");
757 act文字コンソール = new C文字コンソール();
758 Trace.TraceInformation("文字コンソールを生成しました。");
760 Trace.TraceInformation("文字コンソールを活性化しました。");
761 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
763 catch (Exception exception)
765 Trace.TraceError(exception.Message);
766 Trace.TraceError("文字コンソールの初期化に失敗しました。");
775 Trace.TraceInformation("パッドの初期化を行います。");
780 Trace.TraceInformation("パッドの初期化を完了しました。");
782 catch (Exception exception3)
784 Trace.TraceError(exception3.Message);
785 Trace.TraceError("パッドの初期化に失敗しました。");
793 #region [ Sound管理 の初期化 ]
794 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
798 ESoundDeviceType soundDeviceType;
799 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
801 case ESoundDeviceTypeForConfig.DSound:
802 soundDeviceType = ESoundDeviceType.DirectSound;
804 case ESoundDeviceTypeForConfig.ASIO:
805 soundDeviceType = ESoundDeviceType.ASIO;
807 case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
808 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
810 case ESoundDeviceTypeForConfig.WASAPI_Shared:
811 soundDeviceType = ESoundDeviceType.SharedWASAPI;
814 soundDeviceType = ESoundDeviceType.Unknown;
817 Sound管理 = new CSound管理(base.Window.Handle,
819 CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
820 CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
822 CDTXMania.Instance.ConfigIni.strASIODevice.Index,
823 CDTXMania.Instance.ConfigIni.bUseOSTimer
825 //Sound管理 = FDK.CSound管理.Instance;
826 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
828 ShowWindowTitleWithSoundType();
829 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
830 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
831 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
832 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
836 Trace.TraceError(e.Message);
845 #region [ Songs管理 の初期化 ]
846 //---------------------
847 Trace.TraceInformation("曲リストの初期化を行います。");
851 Songs管理 = new CSongs管理();
852 // Songs管理_裏読 = new CSongs管理();
853 EnumSongs = new CEnumSongs();
854 actEnumSongs = new CActEnumSongs();
855 Trace.TraceInformation("曲リストの初期化を完了しました。");
859 Trace.TraceError(e.Message);
860 Trace.TraceError("曲リストの初期化に失敗しました。");
866 //---------------------
869 #region [ CAvi の初期化 ]
873 #region [ Random の初期化 ]
874 Random = new Random((int)Timer.nシステム時刻);
880 stage起動 = new CStage起動();
881 stageタイトル = new CStageタイトル();
882 stageコンフィグ = new CStageコンフィグ();
883 stage選曲 = new CStage選曲();
884 stage曲読み込み = new CStage曲読み込み();
885 stage演奏画面 = new CStage演奏画面共通();
886 stage結果 = new CStage結果();
887 stageChangeSkin = new CStageChangeSkin();
888 stage終了 = new CStage終了();
890 this.listトップレベルActivities = new List<CActivity>();
891 this.listトップレベルActivities.Add(actEnumSongs);
892 this.listトップレベルActivities.Add(act文字コンソール);
893 this.listトップレベルActivities.Add(stage起動);
894 this.listトップレベルActivities.Add(stageタイトル);
895 this.listトップレベルActivities.Add(stageコンフィグ);
896 this.listトップレベルActivities.Add(stage選曲);
897 this.listトップレベルActivities.Add(stage曲読み込み);
898 this.listトップレベルActivities.Add(stage演奏画面);
899 this.listトップレベルActivities.Add(stage結果);
900 this.listトップレベルActivities.Add(stageChangeSkin);
901 this.listトップレベルActivities.Add(stage終了);
902 this.listトップレベルActivities.Add(actFlushGPU);
905 #region [ プラグインの検索と生成 ]
906 PluginHost = new CPluginHost();
908 Trace.TraceInformation("プラグインの検索と生成を行います。");
913 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
921 #region [ プラグインの初期化 ]
922 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
924 Trace.TraceInformation("プラグインの初期化を行います。");
928 foreach (STPlugin st in this.listプラグイン)
930 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
931 st.plugin.On初期化(this.PluginHost);
932 st.plugin.OnManagedリソースの作成();
933 st.plugin.OnUnmanagedリソースの作成();
934 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
936 Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
940 Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
951 Trace.TraceInformation("アプリケーションの初期化を完了しました。");
953 #region [ 最初のステージの起動 ]
954 Trace.TraceInformation("----------------------");
955 Trace.TraceInformation("■ 起動");
957 if (CDTXMania.Instance.bコンパクトモード)
959 r現在のステージ = stage曲読み込み;
970 public void t全画面_ウィンドウモード切り替え()
972 #if WindowedFullscreen
973 if (ConfigIni != null)
975 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
976 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
979 #if !WindowedFullscreen
980 settings.Windowed = ConfigIni.bウィンドウモード;
982 if (ConfigIni.bウィンドウモード == false) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
984 currentClientSize = this.Window.ClientSize;
985 ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
986 ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
987 // FDK.CTaskBar.ShowTaskBar( false );
989 #if !WindowedFullscreen
990 base.GraphicsDeviceManager.ChangeDevice( settings );
992 if (ConfigIni.bウィンドウモード == true) // #23510 2010.10.27 yyagi: to resume window size from backuped value
994 #if WindowedFullscreen
995 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
996 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
997 // in spite of using fullscreen mode.
998 Instance.Window.WindowState = FormWindowState.Normal;
999 Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
1000 Instance.Window.WindowState = FormWindowState.Normal;
1002 base.Window.ClientSize =
1003 new Size(currentClientSize.Width, currentClientSize.Height);
1004 // FDK.CTaskBar.ShowTaskBar( true );
1006 #if WindowedFullscreen
1009 Instance.Window.WindowState = FormWindowState.Normal;
1010 Instance.Window.FormBorderStyle = FormBorderStyle.None;
1011 Instance.Window.WindowState = FormWindowState.Maximized;
1013 if (cMouseHideControl != null)
1015 if (ConfigIni.bウィンドウモード)
1017 cMouseHideControl.Show();
1021 cMouseHideControl.Hide();
1028 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1030 /// リザルト画像のキャプチャと保存。
1032 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1033 public bool SaveResultScreen(string strFullPath)
1035 string strSavePath = Path.GetDirectoryName(strFullPath);
1036 if (!Directory.Exists(strSavePath))
1040 Directory.CreateDirectory(strSavePath);
1048 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1049 using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1051 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1059 protected override void Initialize()
1063 //swlist1 = new List<int>( 8192 );
1064 //swlist2 = new List<int>( 8192 );
1065 //swlist3 = new List<int>( 8192 );
1066 //swlist4 = new List<int>( 8192 );
1067 //swlist5 = new List<int>( 8192 );
1068 if (this.listトップレベルActivities != null)
1070 foreach (CActivity activity in this.listトップレベルActivities)
1071 activity.OnManagedリソースの作成();
1074 foreach (STPlugin st in this.listプラグイン)
1076 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1077 st.plugin.OnManagedリソースの作成();
1078 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1080 #if GPUFlushAfterPresent
1081 FrameEnd += dtxmania_FrameEnd;
1084 #if GPUFlushAfterPresent
1085 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
1086 { // → Present()直後にGPUをFlushする
1087 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1088 actFlushGPU.On進行描画(); // Flush GPU
1091 protected override void LoadContent()
1093 if (cMouseHideControl != null)
1095 if (ConfigIni.bウィンドウモード)
1097 cMouseHideControl.Show();
1101 cMouseHideControl.Hide();
1104 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)));
1105 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1106 this.Device.SetRenderState(RenderState.Lighting, false);
1107 this.Device.SetRenderState(RenderState.ZEnable, false); // trueにすると、一部システムで画面表示できなくなる
1108 this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false); // trueにすると、一部システムで画面表示できなくなる
1109 this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1110 this.Device.SetRenderState(RenderState.AlphaRef, 10);
1112 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1113 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1114 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1116 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1117 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1118 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1119 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1120 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1121 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1122 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1124 if (this.listトップレベルActivities != null)
1126 foreach (CActivity activity in this.listトップレベルActivities)
1127 activity.OnUnmanagedリソースの作成();
1130 foreach (STPlugin st in this.listプラグイン)
1132 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1133 st.plugin.OnUnmanagedリソースの作成();
1134 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1137 protected override void UnloadContent()
1139 if (this.listトップレベルActivities != null)
1141 foreach (CActivity activity in this.listトップレベルActivities)
1142 activity.OnUnmanagedリソースの解放();
1145 foreach (STPlugin st in this.listプラグイン)
1147 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1148 st.plugin.OnUnmanagedリソースの解放();
1149 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1152 protected override void OnExiting(EventArgs e)
1154 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
1158 protected override void Update(GameTime gameTime)
1161 protected override void Draw(GameTime gameTime)
1163 if (Sound管理 == null)
1167 Sound管理.t再生中の処理をする();
1171 if (CSound管理.rc演奏用タイマ != null)
1172 CSound管理.rc演奏用タイマ.t更新();
1174 if (Input管理 != null)
1175 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1180 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1181 // Pad.st検知したデバイス.Clear();
1183 if (this.Device == null)
1186 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1187 CPowerManagement.tDisableMonitorSuspend();
1189 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1191 if (ConfigIni.nSleepPerFrameMs >= 0) // #xxxxx 2011.11.27 yyagi
1193 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1197 #region [ DTXCreatorからの指示 ]
1198 if (this.Window.IsReceivedMessage) // ウインドウメッセージで、
1200 string strMes = this.Window.strMessage;
1201 this.Window.IsReceivedMessage = false;
1205 CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1207 if (DTXVmode.Enabled)
1210 strコンパクトモードファイル = DTXVmode.filename;
1211 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1214 string strPreviewFilename = DTXVmode.previewFilename;
1215 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1218 if (this.previewSound != null)
1220 this.previewSound.tサウンドを停止する();
1221 this.previewSound.Dispose();
1222 this.previewSound = null;
1224 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1225 this.previewSound.n音量 = DTXVmode.previewVolume;
1226 this.previewSound.n位置 = DTXVmode.previewPan;
1227 this.previewSound.t再生を開始する();
1228 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1232 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1233 if (this.previewSound != null)
1235 this.previewSound.Dispose();
1237 this.previewSound = null;
1245 this.Device.BeginScene();
1246 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1248 if (r現在のステージ != null)
1250 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1252 #region [ プラグインの進行描画 ]
1253 //---------------------
1254 foreach (STPlugin sp in this.listプラグイン)
1256 Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1258 if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1259 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1261 sp.plugin.On進行描画(null, null);
1263 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1265 //---------------------
1269 CScoreIni scoreIni = null;
1271 if (Control.IsKeyLocked(Keys.CapsLock)) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1273 // → songs.db等の書き込み時だと音切れするっぽい
1274 actEnumSongs.On非活性化();
1275 EnumSongs.SongListEnumCompletelyDone();
1276 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1278 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1279 if (!CDTXMania.Instance.bコンパクトモード)
1281 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
1283 switch (r現在のステージ.eステージID)
1285 case CStage.Eステージ.タイトル:
1286 case CStage.Eステージ.コンフィグ:
1287 case CStage.Eステージ.選曲:
1288 case CStage.Eステージ.曲読み込み:
1289 if (EnumSongs != null)
1291 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1292 if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1293 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1294 this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1295 !EnumSongs.IsSongListEnumStarted)
1297 actEnumSongs.On活性化();
1298 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1299 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1300 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
1301 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1303 EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1308 #region [ 曲検索の中断と再開 ]
1309 if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1311 switch (this.n進行描画の戻り値)
1314 //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1315 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1317 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1318 EnumSongs.IsSlowdown = false;
1322 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1323 EnumSongs.IsSlowdown = true;
1325 actEnumSongs.On活性化();
1329 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
1330 actEnumSongs.On非活性化();
1336 #region [ 曲探索中断待ち待機 ]
1337 if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1338 EnumSongs.thDTXFileEnumerate != null) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1340 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
1344 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1345 // CStage選曲.On活性化() に回した方がいいかな?
1346 if (EnumSongs.IsSongListEnumerated)
1348 actEnumSongs.On非活性化();
1349 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1351 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1352 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1353 EnumSongs.SongListEnumCompletelyDone();
1361 switch (r現在のステージ.eステージID)
1363 case CStage.Eステージ.何もしない:
1366 case CStage.Eステージ.起動:
1368 //-----------------------------
1369 if (this.n進行描画の戻り値 != 0)
1374 Trace.TraceInformation("----------------------");
1375 Trace.TraceInformation("■ タイトル");
1377 r直前のステージ = r現在のステージ;
1378 r現在のステージ = stageタイトル;
1383 Trace.TraceInformation("----------------------");
1384 Trace.TraceInformation("■ 曲読み込み");
1386 r直前のステージ = r現在のステージ;
1387 r現在のステージ = stage曲読み込み;
1390 foreach (STPlugin pg in this.listプラグイン)
1392 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1393 pg.plugin.Onステージ変更();
1394 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1397 this.tガベージコレクションを実行する();
1399 //-----------------------------
1403 case CStage.Eステージ.タイトル:
1405 //-----------------------------
1406 switch (this.n進行描画の戻り値)
1408 case (int)CStageタイトル.E戻り値.GAMESTART:
1410 //-----------------------------
1412 Trace.TraceInformation("----------------------");
1413 Trace.TraceInformation("■ 選曲");
1415 r直前のステージ = r現在のステージ;
1417 //-----------------------------
1421 #region [ OPTION: 廃止済 ]
1422 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1424 // //-----------------------------
1425 // r現在のステージ.On非活性化();
1426 // Trace.TraceInformation( "----------------------" );
1427 // Trace.TraceInformation( "■ オプション" );
1428 // stageオプション.On活性化();
1429 // r直前のステージ = r現在のステージ;
1430 // r現在のステージ = stageオプション;
1431 // //-----------------------------
1436 case (int)CStageタイトル.E戻り値.CONFIG:
1438 //-----------------------------
1440 Trace.TraceInformation("----------------------");
1441 Trace.TraceInformation("■ コンフィグ");
1443 r直前のステージ = r現在のステージ;
1444 r現在のステージ = stageコンフィグ;
1445 //-----------------------------
1449 case (int)CStageタイトル.E戻り値.EXIT:
1451 //-----------------------------
1453 Trace.TraceInformation("----------------------");
1454 Trace.TraceInformation("■ 終了");
1456 r直前のステージ = r現在のステージ;
1458 //-----------------------------
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ガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1471 //-----------------------------
1475 case CStage.Eステージ.コンフィグ:
1477 //-----------------------------
1478 if (this.n進行描画の戻り値 != 0)
1480 switch (r直前のステージ.eステージID)
1482 case CStage.Eステージ.タイトル:
1484 //-----------------------------
1486 Trace.TraceInformation("----------------------");
1487 Trace.TraceInformation("■ タイトル");
1489 r直前のステージ = r現在のステージ;
1490 r現在のステージ = stageタイトル;
1492 foreach (STPlugin pg in this.listプラグイン)
1494 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1495 pg.plugin.Onステージ変更();
1496 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1499 this.tガベージコレクションを実行する();
1501 //-----------------------------
1504 case CStage.Eステージ.選曲:
1506 //-----------------------------
1508 Trace.TraceInformation("----------------------");
1509 Trace.TraceInformation("■ 選曲");
1511 r直前のステージ = r現在のステージ;
1514 foreach (STPlugin pg in this.listプラグイン)
1516 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1517 pg.plugin.Onステージ変更();
1518 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1521 this.tガベージコレクションを実行する();
1523 //-----------------------------
1527 //-----------------------------
1531 case CStage.Eステージ.選曲:
1533 //-----------------------------
1534 switch (this.n進行描画の戻り値)
1536 case (int)CStage選曲.E戻り値.タイトルに戻る:
1538 //-----------------------------
1540 Trace.TraceInformation("----------------------");
1541 Trace.TraceInformation("■ タイトル");
1543 r直前のステージ = r現在のステージ;
1544 r現在のステージ = stageタイトル;
1546 foreach (STPlugin pg in this.listプラグイン)
1548 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1549 pg.plugin.Onステージ変更();
1550 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1553 this.tガベージコレクションを実行する();
1555 //-----------------------------
1558 case (int)CStage選曲.E戻り値.選曲した:
1560 //-----------------------------
1562 Trace.TraceInformation("----------------------");
1563 Trace.TraceInformation("■ 曲読み込み");
1565 r直前のステージ = r現在のステージ;
1566 r現在のステージ = stage曲読み込み;
1568 foreach (STPlugin pg in this.listプラグイン)
1570 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1571 pg.plugin.Onステージ変更();
1572 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1575 this.tガベージコレクションを実行する();
1577 //-----------------------------
1580 case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1582 //-----------------------------
1584 Trace.TraceInformation("----------------------");
1585 Trace.TraceInformation("■ コンフィグ");
1587 r直前のステージ = r現在のステージ;
1588 r現在のステージ = stageコンフィグ;
1590 foreach (STPlugin pg in this.listプラグイン)
1592 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1593 pg.plugin.Onステージ変更();
1594 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1597 this.tガベージコレクションを実行する();
1599 //-----------------------------
1602 case (int)CStage選曲.E戻り値.スキン変更:
1605 //-----------------------------
1607 Trace.TraceInformation("----------------------");
1608 Trace.TraceInformation("■ スキン切り替え");
1609 stageChangeSkin.On活性化();
1610 r直前のステージ = r現在のステージ;
1611 r現在のステージ = stageChangeSkin;
1613 //-----------------------------
1616 //-----------------------------
1620 case CStage.Eステージ.曲読み込み:
1622 //-----------------------------
1623 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
1624 if (this.n進行描画の戻り値 != 0)
1626 CDTXMania.Instance.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1628 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1629 if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1633 Trace.TraceInformation("曲の読み込みを中止しました。");
1634 this.tガベージコレクションを実行する();
1635 Trace.TraceInformation("----------------------");
1636 Trace.TraceInformation("■ 選曲");
1638 r直前のステージ = r現在のステージ;
1640 foreach (STPlugin pg in this.listプラグイン)
1642 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1643 pg.plugin.Onステージ変更();
1644 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1650 Trace.TraceInformation("----------------------");
1651 Trace.TraceInformation("■ 演奏(ドラム画面)");
1652 r直前のステージ = r現在のステージ;
1653 r現在のステージ = stage演奏画面;
1655 foreach (STPlugin pg in this.listプラグイン)
1657 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1658 pg.plugin.Onステージ変更();
1659 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1662 this.tガベージコレクションを実行する();
1664 //-----------------------------
1668 case CStage.Eステージ.演奏:
1670 //-----------------------------
1671 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1672 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1673 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1674 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1675 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1677 //swlist1.Add( Convert.ToInt32(n1) );
1678 //swlist2.Add( Convert.ToInt32(n2) );
1679 //swlist3.Add( Convert.ToInt32( n3 ) );
1680 //swlist4.Add( Convert.ToInt32( n4 ) );
1681 //swlist5.Add( Convert.ToInt32( n5 ) );
1683 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1684 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1686 DTXVmode.Refreshed = false;
1688 if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1690 CDTXMania.Instance.stage演奏画面.t停止();
1692 if (previewSound != null)
1694 this.previewSound.tサウンドを停止する();
1695 this.previewSound.Dispose();
1696 this.previewSound = null;
1701 // for ( int i = 0; i < swlist1.Count; i++ )
1703 // int d1 = swlist1[ i ];
1704 // int d2 = swlist2[ i ];
1705 // int d3 = swlist3[ i ];
1706 // int d4 = swlist4[ i ];
1707 // int d5 = swlist5[ i ];
1709 // int dif = d1 - lastd;
1711 // if ( 16 <= dif && dif <= 17 )
1718 // 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 );
1730 else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1732 if (DTXVmode.NeedReload)
1734 CDTXMania.Instance.stage演奏画面.t再読込();
1735 if (DTXVmode.GRmode)
1737 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1741 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1743 CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1744 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1745 if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1747 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1748 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1753 CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1759 switch (this.n進行描画の戻り値)
1761 case (int)E演奏画面の戻り値.再読込_再演奏:
1762 #region [ DTXファイルを再読み込みして、再演奏 ]
1767 r直前のステージ = r現在のステージ;
1768 r現在のステージ = stage曲読み込み;
1769 this.tガベージコレクションを実行する();
1773 //case (int) E演奏画面の戻り値.再演奏:
1774 #region [ 再読み込み無しで、再演奏 ]
1778 case (int)E演奏画面の戻り値.継続:
1781 case (int)E演奏画面の戻り値.演奏中断:
1783 //-----------------------------
1784 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1785 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1787 //CDTXMania.Instance.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1792 //for (int i = 0; i < swlist1.Count; i++)
1794 // int d1 = swlist1[ i ];
1795 // int d2 = swlist2[ i ];
1796 // int d3 = swlist3[ i ];
1797 // int d4 = swlist4[ i ];
1799 // int dif = d1 - lastd;
1801 // if ( 16 <= dif && dif <= 17 )
1808 // Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1817 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1818 //---------------------
1819 foreach (STPlugin pg in this.listプラグイン)
1821 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1822 pg.plugin.On演奏キャンセル(scoreIni);
1823 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1825 //---------------------
1833 base.Window.Close();
1837 Trace.TraceInformation("----------------------");
1838 Trace.TraceInformation("■ 選曲");
1840 r直前のステージ = r現在のステージ;
1843 #region [ プラグイン Onステージ変更() の呼び出し ]
1844 //---------------------
1845 foreach (STPlugin pg in this.listプラグイン)
1847 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1848 pg.plugin.Onステージ変更();
1849 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1851 //---------------------
1854 this.tガベージコレクションを実行する();
1857 //-----------------------------
1860 case (int)E演奏画面の戻り値.ステージ失敗:
1861 #region [ 演奏失敗(StageFailed) ]
1862 //-----------------------------
1863 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1865 #region [ プラグイン On演奏失敗() の呼び出し ]
1866 //---------------------
1867 foreach (STPlugin pg in this.listプラグイン)
1869 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1870 pg.plugin.On演奏失敗(scoreIni);
1871 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1873 //---------------------
1881 base.Window.Close();
1885 Trace.TraceInformation("----------------------");
1886 Trace.TraceInformation("■ 選曲");
1888 r直前のステージ = r現在のステージ;
1891 #region [ プラグイン Onステージ変更() の呼び出し ]
1892 //---------------------
1893 foreach (STPlugin pg in this.listプラグイン)
1895 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1896 pg.plugin.Onステージ変更();
1897 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1899 //---------------------
1902 this.tガベージコレクションを実行する();
1905 //-----------------------------
1908 case (int)E演奏画面の戻り値.ステージクリア:
1910 //-----------------------------
1911 STDGBSValue<CScoreIni.C演奏記録> record;
1912 record = stage演奏画面.Record;
1914 double playskill = 0.0;
1916 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
1918 if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
1920 playskill = record[inst].db演奏型スキル値;
1924 string str = "Cleared";
1925 switch (CScoreIni.t総合ランク値を計算して返す(record))
1927 case CScoreIni.ERANK.SS:
1928 str = string.Format("Cleared (SS: {0:F2})", playskill);
1931 case CScoreIni.ERANK.S:
1932 str = string.Format("Cleared (S: {0:F2})", playskill);
1935 case CScoreIni.ERANK.A:
1936 str = string.Format("Cleared (A: {0:F2})", playskill);
1939 case CScoreIni.ERANK.B:
1940 str = string.Format("Cleared (B: {0:F2})", playskill);
1943 case CScoreIni.ERANK.C:
1944 str = string.Format("Cleared (C: {0:F2})", playskill);
1947 case CScoreIni.ERANK.D:
1948 str = string.Format("Cleared (D: {0:F2})", playskill);
1951 case CScoreIni.ERANK.E:
1952 str = string.Format("Cleared (E: {0:F2})", playskill);
1955 case CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1956 str = "Cleared (No chips)";
1960 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
1962 #region [ プラグイン On演奏クリア() の呼び出し ]
1963 //---------------------
1964 foreach (STPlugin pg in this.listプラグイン)
1966 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1967 pg.plugin.On演奏クリア(scoreIni);
1968 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1970 //---------------------
1974 Trace.TraceInformation("----------------------");
1975 Trace.TraceInformation("■ 結果");
1976 stage結果.st演奏記録 = record;
1977 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
1979 r直前のステージ = r現在のステージ;
1982 #region [ プラグイン Onステージ変更() の呼び出し ]
1983 //---------------------
1984 foreach (STPlugin pg in this.listプラグイン)
1986 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1987 pg.plugin.Onステージ変更();
1988 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1990 //---------------------
1994 //-----------------------------
1997 //-----------------------------
2001 case CStage.Eステージ.結果:
2003 //-----------------------------
2004 if (this.n進行描画の戻り値 != 0)
2006 // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
2007 // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
2008 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
2010 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
2018 Trace.TraceInformation("----------------------");
2019 Trace.TraceInformation("■ 選曲");
2021 r直前のステージ = r現在のステージ;
2024 foreach (STPlugin pg in this.listプラグイン)
2026 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2027 pg.plugin.Onステージ変更();
2028 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2031 this.tガベージコレクションを実行する();
2035 base.Window.Close();
2038 //-----------------------------
2042 case CStage.Eステージ.ChangeSkin:
2044 //-----------------------------
2045 if (this.n進行描画の戻り値 != 0)
2048 Trace.TraceInformation("----------------------");
2049 Trace.TraceInformation("■ 選曲");
2051 r直前のステージ = r現在のステージ;
2053 this.tガベージコレクションを実行する();
2055 //-----------------------------
2059 case CStage.Eステージ.終了:
2061 //-----------------------------
2062 if (this.n進行描画の戻り値 != 0)
2066 //-----------------------------
2071 this.Device.EndScene();
2072 // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2073 // (つまり、Present()は、Draw()完了後に実行される)
2074 #if !GPUFlushAfterPresent
2075 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
2077 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2079 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2082 #region [ マウスカーソル消去制御 ]
2083 if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2085 #region [ 全画面・ウインドウ切り替え ]
2086 if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2088 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2089 Instance.t全画面_ウィンドウモード切り替え();
2090 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2093 #region [ 垂直基線同期切り替え ]
2094 if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2096 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2097 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2098 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2099 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2100 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2101 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2102 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2105 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2110 GC.Collect( 0, GCCollectionMode.Optimized, false ); // Rel105で処理が重くなっていることに対する、暫定処置。
2111 // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2116 /// XML ファイルからオブジェクトを生成します。
2118 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2119 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2120 public static object DeserializeXML(string xmlpath, Type t)
2125 if (File.Exists(xmlpath))
2127 using (XmlReader xr = XmlReader.Create(xmlpath))
2129 DataContractSerializer serializer = new DataContractSerializer(t);
2130 ret = serializer.ReadObject(xr);
2136 Trace.TraceWarning( e.Message );
2143 /// オブジェクトから XML ファイルを生成します。
2145 /// <param name="xmlfile">XML ファイルのパス。</param>
2146 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2147 public static void SerializeXML(string xmlpath, object obj)
2149 XmlWriterSettings settings = new XmlWriterSettings();
2150 settings.IndentChars = " ";
2151 settings.Indent = true;
2152 settings.NewLineChars = Environment.NewLine;
2153 settings.Encoding = new System.Text.UTF8Encoding(false);
2154 using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2156 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2158 DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2159 serializer.WriteObject(xw, obj);
2164 public void SaveConfig()
2166 #region [ Skinパスの絶対パス→相対パス変換 ]
2167 string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2168 Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2169 if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2171 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2172 // → 初期値として Default/ を設定する。
2173 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2176 // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2177 // そのため、以下の処理を通すために、いったん絶対パスに変換
2178 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2180 ConfigIni.strSystemSkinSubfolderPath.Value =
2181 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2184 Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2185 string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得
2186 relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする
2187 relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する
2188 ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2190 ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2192 CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2195 ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2198 public void LoadConfig()
2200 string path = strEXEのあるフォルダ + "Config.xml";
2202 if (!File.Exists(path))
2206 if (File.Exists(path))
2208 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2209 if (ConfigIni == null)
2211 ConfigIni = new CConfigXml();
2214 // Skinパスの相対パスを、絶対パスに変換
2215 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2217 ConfigIni.strSystemSkinSubfolderPath.Value =
2218 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2223 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2225 public void UpdateCoordinates()
2227 string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2230 if (File.Exists(coordXml))
2232 using (XmlReader xr = XmlReader.Create(coordXml))
2234 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2237 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2239 catch (SerializationException e)
2241 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2246 XmlWriterSettings settings = new XmlWriterSettings();
2247 settings.IndentChars = " ";
2248 settings.Indent = true;
2249 settings.NewLineChars = Environment.NewLine;
2250 settings.Encoding = new System.Text.UTF8Encoding( false );
2251 using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2253 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2254 //ns.Add( String.Empty, String.Empty );
2256 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2257 //serializer.Serialize( sw, item, ns );
2260 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2261 serializer.WriteObject( xw, Coordinates );
2262 //serializer.WriteStartObject( xw, Coordinates );
2263 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2264 // "http://schemas.microsoft.com/2003/10/Serialization/" );
2265 //serializer.WriteObjectContent( xw, Coordinates );
2266 //serializer.WriteEndObject( xw );
2270 if (File.Exists(coordXml))
2272 using (XmlReader xr = XmlReader.Create(coordXml))
2274 DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2275 Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2282 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2284 //public class MyXmlTextWriter : XmlTextWriter
2286 // private bool _ignoreAttr = false;
2288 // public MyXmlTextWriter( TextWriter w )
2291 // Debug.WriteLine( "create" );
2294 // public override string LookupPrefix( string ns )
2296 // Debug.WriteLine( "luprefix" );
2297 // return string.Empty;
2300 // public override void WriteStartAttribute( string prefix, string localName, string ns )
2302 // Debug.WriteLine( "writestartattribute" );
2303 // if ( String.Compare( prefix, "xmlns", true ) == 0 )
2305 // Debug.WriteLine( "[!]" );
2306 // this._ignoreAttr = true;
2311 // public override void WriteEndAttribute()
2313 // if ( this._ignoreAttr )
2315 // this._ignoreAttr = false;
2318 // base.WriteEndAttribute();
2321 // public override void WriteString( string text )
2323 // Debug.WriteLine( "ws" );
2324 // if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2328 // base.WriteString( text );
2331 // public override void WriteStartElement( string prefix, string localName, string ns )
2333 // Debug.WriteLine( "wse" );
2334 // base.WriteStartElement( null, localName, null );
2338 public void ShowWindowTitleWithSoundType()
2341 if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2343 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2345 base.Window.Text = strWindowTitle;
2346 if (!this.DTX2WAVmode.Enabled)
2348 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2354 private bool b終了処理完了済み;
2355 private static CDTX dtx;
2356 private List<CActivity> listトップレベルActivities;
2357 private int n進行描画の戻り値;
2358 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2359 private string strWindowTitle
2363 if (DTXVmode.Enabled)
2365 return "DTXMViewer release " + VERSION;
2367 else if (DTX2WAVmode.Enabled)
2369 return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename);
2373 return "DTXMania .NET style release " + VERSION;
2377 private CSound previewSound;
2378 private CMouseHideControl cMouseHideControl = null;
2380 private void t終了処理()
2382 if (!this.b終了処理完了済み)
2384 Trace.TraceInformation("----------------------");
2385 Trace.TraceInformation("■ アプリケーションの終了");
2387 CPowerPlan.RestoreCurrentPowerPlan(); // 電源プランを元のものに戻す
2389 #region [ 曲検索の終了処理 ]
2390 //---------------------
2391 if (actEnumSongs != null)
2393 Trace.TraceInformation("曲検索actの終了処理を行います。");
2397 actEnumSongs.On非活性化();
2398 actEnumSongs = null;
2399 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2403 Trace.TraceError(e.Message);
2404 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2411 //---------------------
2413 #region [ 現在のステージの終了処理 ]
2414 //---------------------
2415 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる) // #25398 2011.06.07 MODIFY FROM
2417 Trace.TraceInformation("現在のステージを終了します。");
2422 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2429 //---------------------
2432 #region [ 選曲ステージの終了処理 ]
2436 #region [ プラグインの終了処理 ]
2437 //---------------------
2438 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2440 Trace.TraceInformation("すべてのプラグインを終了します。");
2444 foreach (STPlugin st in this.listプラグイン)
2446 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2447 st.plugin.OnUnmanagedリソースの解放();
2448 st.plugin.OnManagedリソースの解放();
2450 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2453 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2460 //---------------------
2462 #region [ 曲リストの終了処理 ]
2463 //---------------------
2464 if (Songs管理 != null)
2466 Trace.TraceInformation("曲リストの終了処理を行います。");
2471 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2473 catch (Exception exception)
2475 Trace.TraceError(exception.Message);
2476 Trace.TraceError("曲リストの終了処理に失敗しました。");
2484 //---------------------
2486 #region [ スキンの終了処理 ]
2487 //---------------------
2490 Trace.TraceInformation("スキンの終了処理を行います。");
2496 Trace.TraceInformation("スキンの終了処理を完了しました。");
2498 catch (Exception exception2)
2500 Trace.TraceError(exception2.Message);
2501 Trace.TraceError("スキンの終了処理に失敗しました。");
2508 //---------------------
2510 #region [ DirectSoundの終了処理 ]
2511 //---------------------
2512 if (Sound管理 != null)
2514 Trace.TraceInformation("DirectSound の終了処理を行います。");
2520 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2522 catch (Exception exception3)
2524 Trace.TraceError(exception3.Message);
2525 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2532 //---------------------
2534 #region [ パッドの終了処理 ]
2535 //---------------------
2538 Trace.TraceInformation("パッドの終了処理を行います。");
2543 Trace.TraceInformation("パッドの終了処理を完了しました。");
2545 catch (Exception exception4)
2547 Trace.TraceError(exception4.Message);
2548 Trace.TraceError("パッドの終了処理に失敗しました。");
2555 //---------------------
2557 #region [ DirectInput, MIDI入力の終了処理 ]
2558 //---------------------
2559 if (Input管理 != null)
2561 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2567 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2569 catch (Exception exception5)
2571 Trace.TraceError(exception5.Message);
2572 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2579 //---------------------
2581 #region [ 文字コンソールの終了処理 ]
2582 //---------------------
2583 if (act文字コンソール != null)
2585 Trace.TraceInformation("文字コンソールの終了処理を行います。");
2589 act文字コンソール.On非活性化();
2591 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2593 catch (Exception exception6)
2595 Trace.TraceError(exception6.Message);
2596 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2603 //---------------------
2605 #region [ FPSカウンタの終了処理 ]
2606 //---------------------
2607 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2615 Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2621 //---------------------
2623 #region [ タイマの終了処理 ]
2624 //---------------------
2625 Trace.TraceInformation("タイマの終了処理を行います。");
2633 Trace.TraceInformation("タイマの終了処理を完了しました。");
2637 Trace.TraceInformation("タイマは使用されていません。");
2644 //---------------------
2646 #region [ Config.iniの出力 ]
2647 //---------------------
2648 Trace.TraceInformation("Config.xml を出力します。");
2649 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2650 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2652 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2655 if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped) // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2657 ConfigIni.SwapGuitarBassInfos_PlaySettings();
2660 string str = strEXEのあるフォルダ + "Config.xml";
2664 if (DTXVmode.Enabled)
2666 DTXVmode.tUpdateConfigIni();
2667 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2669 else if (DTX2WAVmode.Enabled)
2671 DTX2WAVmode.tUpdateConfigIni();
2672 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2676 CDTXMania.Instance.SaveConfig();
2677 Trace.TraceInformation("保存しました。({0})", str);
2682 Trace.TraceError(e.Message);
2683 Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2689 //---------------------
2691 #region [ DTXVmodeの終了処理 ]
2692 //---------------------
2693 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2697 if (DTXVmode != null)
2700 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2704 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2711 //---------------------
2713 #region [ DirectXの終了処理 ]
2714 //---------------------
2715 base.GraphicsDeviceManager.Dispose();
2716 //---------------------
2718 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2721 this.b終了処理完了済み = true;
2724 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2726 STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2727 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2728 CScoreIni ini = new CScoreIni(strFilename);
2729 if (!File.Exists(strFilename))
2731 ini.stファイル.Title = DTX.TITLE;
2732 ini.stファイル.Name = DTX.strファイル名;
2733 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2734 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2736 ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2737 ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2738 ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2739 ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2741 ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2742 ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2743 ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2744 ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2746 ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2747 ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2748 ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2749 ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2752 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2753 isUpdated = CScoreIni.t更新条件を取得する();
2754 if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2756 if (isUpdated.Drums)
2758 ini.stファイル.PlayCountDrums++;
2760 if (isUpdated.Guitar)
2762 ini.stファイル.PlayCountGuitar++;
2766 ini.stファイル.PlayCountBass++;
2768 ini.tヒストリを追加する(str新ヒストリ行);
2771 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2772 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2773 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2774 for (int j = 0; j < ini.stファイル.History.Length; j++)
2776 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2780 if (ConfigIni.bScoreIni)
2782 ini.t書き出し(strFilename);
2787 private void tガベージコレクションを実行する()
2789 GC.Collect(0, GCCollectionMode.Optimized, true );
2790 GC.WaitForPendingFinalizers();
2791 GC.Collect(0, GCCollectionMode.Forced, true );
2792 GC.WaitForPendingFinalizers();
2794 private void tプラグイン検索と生成()
2796 this.listプラグイン = new List<STPlugin>();
2798 string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2799 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2801 this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2803 if (this.listプラグイン.Count > 0)
2804 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2807 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2809 var domain = (AppDomain)sender;
2811 foreach (var assembly in domain.GetAssemblies())
2813 if (assembly.FullName == args.Name)
2818 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2820 // 指定されたパスが存在しないとエラー
2821 if (!Directory.Exists(strプラグインフォルダパス))
2823 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2827 AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2830 // (1) すべての *.dll について…
2831 string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2832 foreach (string dllName in strDLLs)
2834 if (Path.GetExtension(dllName).ToLower() != ".dll")
2840 // (1-1) dll をアセンブリとして読み込む。
2841 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2843 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2844 foreach (Type t in asm.GetTypes())
2846 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2847 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2849 // (1-4) クラス名からインスタンスを作成する
2850 var st = new STPlugin()
2852 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2853 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2854 strアセンブリ簡易名 = asm.GetName().Name,
2855 Version = asm.GetName().Version,
2858 // (1-5) プラグインリストへ登録
2859 this.listプラグイン.Add(st);
2860 Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2864 catch (System.Reflection.ReflectionTypeLoadException e)
2866 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2867 Trace.TraceInformation(e.ToString());
2868 Trace.TraceInformation(e.Message);
2870 StringBuilder sb = new StringBuilder();
2871 foreach (Exception exSub in e.LoaderExceptions)
2873 sb.AppendLine(exSub.Message);
2874 FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2875 if (exFileNotFound != null)
2877 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2879 sb.AppendLine("Fusion Log:");
2880 sb.AppendLine(exFileNotFound.FusionLog);
2885 string errorMessage = sb.ToString();
2886 //Display or log the error based on your application.
2887 Trace.TraceInformation(errorMessage);
2892 Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2893 Trace.TraceInformation(e.ToString());
2894 Trace.TraceInformation(e.Message);
2898 // (2) サブフォルダがあれば再帰する
2899 string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
2900 foreach (string dir in strDirs)
2901 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
2904 #region [ Windowイベント処理 ]
2905 private void Window_ApplicationActivated( object sender, EventArgs e )
2907 this.bApplicationActive = true;
2909 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2911 this.bApplicationActive = false;
2912 if (cMouseHideControl != null) cMouseHideControl.Show();
2914 private void Window_KeyDown(object sender, KeyEventArgs e)
2916 if (e.KeyCode == Keys.Menu)
2919 e.SuppressKeyPress = true;
2921 else if ((e.KeyCode == Keys.Return) && e.Alt)
2923 if (ConfigIni != null)
2925 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
2926 this.t全画面_ウィンドウモード切り替え();
2929 e.SuppressKeyPress = true;
2933 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
2935 var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
2937 if( (int) captureCode > 0 &&
2938 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
2940 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2941 string strFullPath =
2942 Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
2943 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
2944 SaveResultScreen( strFullPath );
2949 private void Window_MouseUp(object sender, MouseEventArgs e)
2954 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
2956 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
2958 ConfigIni.bウィンドウモード = false;
2959 this.t全画面_ウィンドウモード切り替え();
2962 private void Window_MouseMove(object sender, MouseEventArgs e)
2964 if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
2967 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
2969 if (ConfigIni.bウィンドウモード)
2971 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2972 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
2975 ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
2976 ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
2980 //Stopwatch sw = new Stopwatch();
2981 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
2985 private class CMouseHideControl
2987 private Point lastPosition;
2988 private CCounter ccMouseShow;
2989 private bool bマウスカーソル表示中;
2994 public CMouseHideControl()
2996 ccMouseShow = new CCounter();
2997 lastPosition = Cursor.Position;
3004 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
3007 public void tHideCursorIfNeed()
3010 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
3011 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
3013 Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
3014 if (client_point.Y >= 0) // タイトルバー上にマウスカーソルがある場合は、隠さない
3022 public void tResetCursorState(bool bWindowed, bool bApplicationActive)
3024 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3025 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false) // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3027 Point currentPosition = Cursor.Position;
3028 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3029 if (lastPosition != currentPosition)
3031 //Trace.TraceInformation("移動発生");
3032 lastPosition = currentPosition;
3047 bマウスカーソル表示中 = false;
3054 private void PutSystemLog()
3056 System.Management.ManagementClass mc =
3057 new System.Management.ManagementClass("Win32_Processor");
3058 System.Management.ManagementObjectCollection moc = mc.GetInstances();
3059 foreach (System.Management.ManagementObject mo in moc)
3061 Trace.TraceInformation("-------------------------");
3062 Trace.TraceInformation("CPU Information:");
3063 //Trace.TraceInformation("DeviceID = {0}", mo["DeviceID"]);
3064 Trace.TraceInformation("Name = {0}", mo["Name"]);
3065 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
3066 Trace.TraceInformation("L2CacheSize = {0}KB", mo["L2CacheSize"]);
3067 Trace.TraceInformation("L3CacheSize = {0}KB", mo["L3CacheSize"]);
3068 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
3073 //System.Management.ManagementClass mc =
3074 // new System.Management.ManagementClass("Win32_OperatingSystem");
3075 //System.Management.ManagementObjectCollection moc = mc.GetInstances();
3077 new System.Management.ManagementClass("Win32_OperatingSystem");
3078 moc = mc.GetInstances();
3079 foreach (System.Management.ManagementObject mo in moc)
3081 Trace.TraceInformation("-------------------------");
3082 Trace.TraceInformation("OS Information:");
3083 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
3084 Trace.TraceInformation("OS: " + mo["Caption"]);
3085 //バージョン(Windows 8.1では、「6.3.9600」)
3086 Trace.TraceInformation("Version: " + mo["Version"]);
3087 //ビルド番号(Windows 8.1では「9600」)
3088 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
3090 //サービスパック(Windows 8.1ではNULL)
3091 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
3093 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
3095 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
3097 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
3102 Trace.TraceInformation("-------------------------");
3103 Trace.TraceInformation("General Environment Information:");
3104 //Trace.TraceInformation("OS Version: " + Environment.OSVersion); // fake version will be returned (due to the lack of manifest settings)
3105 //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
3106 Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
3107 Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
3109 var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
3110 Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
3111 Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
3112 Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
3113 Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
3114 //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
3116 mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
3117 moc = mc.GetInstances();
3118 Trace.TraceInformation("-------------------------");
3119 Trace.TraceInformation("Physical Memory Information:");
3120 foreach (System.Management.ManagementObject mo in moc)
3122 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
3127 mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
3128 moc = mc.GetInstances();
3129 foreach (System.Management.ManagementObject mo in moc)
3131 Trace.TraceInformation("-------------------------");
3132 Trace.TraceInformation("Display Adapter Information:");
3133 Trace.TraceInformation("Name: " + mo["Name"]);
3134 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
3135 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
3136 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
3137 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3142 mc = new System.Management.ManagementClass("Win32_VideoController");
3143 moc = mc.GetInstances();
3144 foreach (System.Management.ManagementObject mo in moc)
3146 Trace.TraceInformation("-------------------------");
3147 Trace.TraceInformation("Video Controller Information:");
3148 Trace.TraceInformation("Description: " + mo["Description"]);
3149 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3150 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3155 mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3156 moc = mc.GetInstances();
3157 foreach (System.Management.ManagementObject mo in moc)
3159 Trace.TraceInformation("-------------------------");
3160 Trace.TraceInformation("Display Information:");
3161 Trace.TraceInformation("Description: " + mo["Description"]);
3162 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3163 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3164 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3165 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3170 mc = new System.Management.ManagementClass("Win32_SoundDevice");
3171 moc = mc.GetInstances();
3172 foreach (System.Management.ManagementObject mo in moc)
3174 Trace.TraceInformation("-------------------------");
3175 Trace.TraceInformation("Sound Information:");
3176 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3177 Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3178 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3183 Trace.TraceInformation("----------------------");
3184 Trace.TraceInformation("DTXMania settings:");
3185 Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3186 Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3187 Trace.TraceInformation("----------------------");