Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/DTXManiaプロジェクト/コード/全体/CDTXMania.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 580 - (hide annotations) (download)
Fri Jan 17 15:52:38 2020 UTC (4 years, 2 months ago) by kairera0467
File size: 105029 byte(s)
#xxxxx trunkのみVisualStudio2019でのビルドに対応
1 kairera0467 2 using System;
2     using System.Collections.Generic;
3     using System.Globalization;
4     using System.Text;
5     using System.Windows.Forms;
6     using System.Drawing;
7     using System.Diagnostics;
8     using System.Runtime.InteropServices;
9     using System.IO;
10     using System.Threading;
11     using System.Runtime.Serialization.Formatters.Binary;
12     using SlimDX;
13     using SlimDX.Direct3D9;
14     using FDK;
15     using SampleFramework;
16     using DTXMania.Properties;
17     using System.Reflection;
18 kairera0467 30 using DirectShowLib;
19 kairera0467 2
20     namespace DTXMania
21     {
22 kairera0467 32 internal class CDTXMania : Game
23 kairera0467 2 {
24     // プロパティ
25    
26 kairera0467 576 public static readonly string VERSION = "Ver3.62aRC2(1906--)";
27 kairera0467 2 public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
28     public static readonly string D3DXDLL = "d3dx9_43.dll"; // June 2010
29     //public static readonly string D3DXDLL = "d3dx9_42.dll"; // February 2010
30     //public static readonly string D3DXDLL = "d3dx9_41.dll"; // March 2009
31    
32     public static CDTXMania app
33     {
34     get;
35     private set;
36     }
37     public static Folder Folder
38     {
39     get;
40     protected set;
41     }
42     public static CApp App
43     {
44     get;
45 kairera0467 32 private set;
46 kairera0467 2 }
47     public static C文字コンソ act文字コンソ
48     {
49     get;
50     private set;
51     }
52     public static bool bコンパクトモ
53     {
54     get;
55     private set;
56     }
57     public static CConfigIni ConfigIni
58     {
59     get;
60     private set;
61     }
62     public static CDTX DTX
63     {
64     get
65     {
66     return dtx;
67     }
68     set
69     {
70     if( ( dtx != null ) && ( app != null ) )
71     {
72     dtx.On非活性化();
73     app.listトップレベルActivities.Remove( dtx );
74     }
75     dtx = value;
76     if( ( dtx != null ) && ( app != null ) )
77     {
78     app.listトップレベルActivities.Add( dtx );
79     }
80     }
81     }
82     public static CFPS FPS
83     {
84     get;
85     private set;
86     }
87     public static CInput管理 Input管理
88     {
89     get;
90     private set;
91     }
92     public static int nSongDifficulty
93     {
94     get;
95     set;
96     }
97    
98 kairera0467 292 #region [ 入力範囲ms ]
99     public static int nPerfect範囲ms
100 kairera0467 2 {
101     get
102     {
103     if( stage選曲.r確定された曲 != null )
104     {
105     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
106     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nPerfect範囲ms >= 0 ) )
107     {
108     return c曲リストノ.nPerfect範囲ms;
109     }
110     }
111     return ConfigIni.nヒット範囲ms.Perfect;
112     }
113     }
114     public static int nGreat範囲ms
115     {
116     get
117     {
118     if( stage選曲.r確定された曲 != null )
119     {
120     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
121     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nGreat範囲ms >= 0 ) )
122     {
123     return c曲リストノ.nGreat範囲ms;
124     }
125     }
126     return ConfigIni.nヒット範囲ms.Great;
127     }
128     }
129     public static int nGood範囲ms
130     {
131     get
132     {
133     if( stage選曲.r確定された曲 != null )
134     {
135     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
136     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nGood範囲ms >= 0 ) )
137     {
138     return c曲リストノ.nGood範囲ms;
139     }
140     }
141     return ConfigIni.nヒット範囲ms.Good;
142     }
143     }
144     public static int nPoor範囲ms
145     {
146     get
147     {
148     if( stage選曲.r確定された曲 != null )
149     {
150     C曲リストノ c曲リストノ = stage選曲.r確定された曲.r親ノ;
151     if( ( ( c曲リストノ != null ) && ( c曲リストノ.eド種別 == C曲リストノ.Eド種別.BOX ) ) && ( c曲リストノ.nPoor範囲ms >= 0 ) )
152     {
153     return c曲リストノ.nPoor範囲ms;
154     }
155     }
156     return ConfigIni.nヒット範囲ms.Poor;
157     }
158 kairera0467 292 }
159     #endregion
160     public static CPad Pad
161 kairera0467 2 {
162     get;
163     private set;
164     }
165     public static Random Random
166     {
167     get;
168     private set;
169     }
170     public static CSkin Skin
171     {
172     get;
173     private set;
174     }
175     public static CSongs管理 Songs管理
176     {
177     get;
178     set; // 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
179     }
180     public static CEnumSongs EnumSongs
181     {
182     get;
183     private set;
184     }
185     public static CActEnumSongs actEnumSongs
186     {
187     get;
188     private set;
189     }
190     public static CActFlushGPU actFlushGPU
191     {
192     get;
193     private set;
194     }
195     public static CSound管理 Sound管理
196     {
197     get;
198     private set;
199     }
200     public static CStage起動 stage起動
201     {
202     get;
203     private set;
204     }
205     public static CStageタイトル stageタイトル
206     {
207     get;
208     private set;
209     }
210     public static CStageオプション stageオプション
211     {
212     get;
213     private set;
214     }
215     public static CStageコンフィグ stageコンフィグ
216     {
217     get;
218     private set;
219     }
220     public static CStage選曲 stage選曲
221     {
222     get;
223     private set;
224     }
225     public static CStage曲読み込み stage曲読み込み
226     {
227     get;
228     private set;
229     }
230     public static CStage演奏ギタ画面 stage演奏ギタ画面
231     {
232     get;
233     private set;
234     }
235     public static CStage演奏ドラム画面 stage演奏ドラム画面
236     {
237     get;
238     private set;
239     }
240     public static CStage演奏画面共通 stage演奏画面共通
241     {
242     get;
243     private set;
244     }
245     public static CStage結果 stage結果
246     {
247     get;
248     private set;
249     }
250     public static CStageChangeSkin stageChangeSkin
251     {
252     get;
253     private set;
254     }
255     public static CStage終了 stage終了
256     {
257     get;
258     private set;
259     }
260     public static CStage r現在のステ = null;
261     public static CStage r直前のステ = null;
262 kairera0467 45 public bool b汎用ムである = false;
263 kairera0467 2 public static string strEXEのあるフォルダ
264     {
265     get;
266     private set;
267     }
268     public static string strコンパクトモドファイル
269     {
270     get;
271     private set;
272     }
273     public static CTimer Timer
274     {
275     get;
276     private set;
277     }
278     public static Format TextureFormat = Format.A8R8G8B8;
279     internal static IPluginActivity act現在入力を占有中のプラグイン = null;
280     public bool bApplicationActive
281     {
282     get;
283     private set;
284     }
285     public bool b次のタイミングで垂直帰線同期切り替えを行う
286     {
287     get;
288     set;
289     }
290 kairera0467 580 public bool b次のタイミングで全画面_ウィンドウ切り替えを行う
291 kairera0467 2 {
292     get;
293     set;
294     }
295    
296     public Device Device
297     {
298     get { return base.GraphicsDeviceManager.Direct3D9.Device; }
299     }
300     public CPluginHost PluginHost
301     {
302     get;
303     private set;
304     }
305     public List<STPlugin> listプラグイン = new List<STPlugin>();
306     public struct STPlugin
307     {
308     public IPluginActivity plugin;
309     public string strプラグインフォルダ;
310     public string strアセンブリ簡易名;
311     public Version Version;
312     }
313     private static Size currentClientSize // #23510 2010.10.27 add yyagi to keep current window size
314     {
315     get;
316     set;
317     }
318 kairera0467 49 // public static CTimer ct;
319 kairera0467 2 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
320     {
321     get { return base.Window.Handle; }
322     }
323 kairera0467 292 public static CDTXVmode DTXVmode // #28821 2014.1.23 yyagi
324     {
325     get;
326     set;
327     }
328 kairera0467 510 //fork
329     public static STDGBVALUE< List<int> > listAutoGhostLag = new STDGBVALUE<List<int>>();
330     public static STDGBVALUE< List<int> > listTargetGhsotLag = new STDGBVALUE<List<int>>();
331 kairera0467 517 public static STDGBVALUE< CScoreIni.C演奏記録 > listTargetGhostScoreData = new STDGBVALUE< CScoreIni.C演奏記録 >();
332 kairera0467 2
333     // コンストラクタ
334    
335     public CDTXMania()
336     {
337     CDTXMania.app = this;
338     this.t起動処理();
339     }
340    
341    
342     // メソッド
343    
344 kairera0467 580 public void t全画面_ウィンドウモド切り替え()
345 kairera0467 153 {
346 kairera0467 21 #if WindowedFullscreen
347 kairera0467 153 if ( ConfigIni != null )
348 kairera0467 21 #else
349 kairera0467 153 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
350     if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモ != settings.Windowed ) )
351 kairera0467 21 #endif
352 kairera0467 153 {
353 kairera0467 21 #if !WindowedFullscreen
354 kairera0467 153 settings.Windowed = ConfigIni.bウィンドウモ;
355 kairera0467 21 #endif
356 kairera0467 153 if ( ConfigIni.bウィンドウモ == false ) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
357     {
358     currentClientSize = this.Window.ClientSize;
359     ConfigIni.nウインドウwidth = this.Window.ClientSize.Width;
360     ConfigIni.nウインドウheight = this.Window.ClientSize.Height;
361     // FDK.CTaskBar.ShowTaskBar( false );
362     }
363 kairera0467 21 #if !WindowedFullscreen
364 kairera0467 153 base.GraphicsDeviceManager.ChangeDevice( settings );
365 kairera0467 21 #endif
366 kairera0467 2 if ( ConfigIni.bウィンドウモ == true ) // #23510 2010.10.27 yyagi: to resume window size from backuped value
367     {
368 kairera0467 153 #if WindowedFullscreen
369 kairera0467 2 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
370     // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
371     // in spite of using fullscreen mode.
372 kairera0467 21 app.Window.WindowState = FormWindowState.Normal;
373     app.Window.FormBorderStyle = FormBorderStyle.Sizable;
374     app.Window.WindowState = FormWindowState.Normal;
375     #endif
376 kairera0467 153 base.Window.ClientSize =
377     new Size( currentClientSize.Width, currentClientSize.Height );
378     // FDK.CTaskBar.ShowTaskBar( true );
379     }
380 kairera0467 21 #if WindowedFullscreen
381 kairera0467 2 else
382     {
383 kairera0467 21 app.Window.WindowState = FormWindowState.Normal;
384     app.Window.FormBorderStyle = FormBorderStyle.None;
385     app.Window.WindowState = FormWindowState.Maximized;
386 kairera0467 2 }
387 kairera0467 153 if ( ConfigIni.bウィンドウモ )
388     {
389     if ( !this.bマウスカソル表示中 )
390     {
391     Cursor.Show();
392     this.bマウスカソル表示中 = true;
393     }
394     }
395     else if ( this.bマウスカソル表示中 )
396     {
397     Cursor.Hide();
398     this.bマウスカソル表示中 = false;
399     }
400 kairera0467 21 #endif
401 kairera0467 153 }
402     }
403 kairera0467 2
404    
405     #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
406     /// <summary>
407     /// リザルト画像のキャプチャと保存。
408     /// </summary>
409     /// <param name="strFilename">保存するファイル名(フルパス)</param>
410     public bool SaveResultScreen( string strFullPath )
411     {
412     string strSavePath = Path.GetDirectoryName( strFullPath );
413     if ( !Directory.Exists( strSavePath ) )
414     {
415     try
416     {
417     Directory.CreateDirectory( strSavePath );
418     }
419     catch
420     {
421     return false;
422     }
423     }
424    
425     // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
426     using ( Surface pSurface = CDTXMania.app.Device.GetRenderTarget( 0 ) )
427     {
428     Surface.ToFile( pSurface, strFullPath, ImageFileFormat.Png );
429     }
430     return true;
431     }
432     #endregion
433    
434     // Game 実装
435     protected override void Initialize()
436     {
437     // new GCBeep();
438 kairera0467 382 sw.Start();
439     swlist = new List<double>( 8192 );
440 kairera0467 2 if( this.listトップレベルActivities != null )
441     {
442     foreach (CActivity activity in this.listトップレベルActivities)
443     {
444     activity.OnManagedリソスの作成();
445     }
446     }
447    
448     foreach( STPlugin st in this.listプラグイン )
449     {
450     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
451     st.plugin.OnManagedリソスの作成();
452     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
453     }
454 kairera0467 82 #if GPUFlushAfterPresent
455     FrameEnd += dtxmania_FrameEnd;
456     #endif
457     }
458     #if GPUFlushAfterPresent
459     void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
460     { // → Present()直後にGPUをFlushする
461     // → 画面のカクツキが頻発したため、ここでのFlushは行わない
462     actFlushGPU.On進行描画(); // Flush GPU
463     }
464     #endif
465     protected override void LoadContent()
466 kairera0467 2 {
467     if ( ConfigIni.bウィンドウモ )
468     {
469     if( !this.bマウスカソル表示中 )
470     {
471     Cursor.Show();
472     this.bマウスカソル表示中 = true;
473     }
474     }
475     else if( this.bマウスカソル表示中 )
476     {
477     Cursor.Hide();
478     this.bマウスカソル表示中 = false;
479     }
480 kairera0467 153 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)));
481     this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
482     this.Device.SetRenderState( RenderState.Lighting, false );
483     this.Device.SetRenderState( RenderState.ZEnable, false );
484     this.Device.SetRenderState( RenderState.AntialiasedLineEnable, false );
485     this.Device.SetRenderState( RenderState.AlphaTestEnable, true );
486     this.Device.SetRenderState( RenderState.AlphaRef, 10 );
487 kairera0467 2
488 kairera0467 552 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
489     this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
490     this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
491 kairera0467 2
492 kairera0467 39 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
493     this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
494     this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
495     this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
496     this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
497     this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
498     this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
499 kairera0467 2
500     if( this.listトップレベルActivities != null )
501     {
502     foreach( CActivity activity in this.listトップレベルActivities )
503     activity.OnUnmanagedリソスの作成();
504     }
505    
506     foreach( STPlugin st in this.listプラグイン )
507     {
508     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
509     st.plugin.OnUnmanagedリソスの作成();
510     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
511 kairera0467 81 }
512 kairera0467 2
513 kairera0467 81 }
514 kairera0467 2 protected override void UnloadContent()
515     {
516     if( this.listトップレベルActivities != null )
517     {
518     foreach( CActivity activity in this.listトップレベルActivities )
519     activity.OnUnmanagedリソスの解放();
520     }
521    
522     foreach( STPlugin st in this.listプラグイン )
523     {
524     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
525     st.plugin.OnUnmanagedリソスの解放();
526     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
527     }
528     }
529     protected override void OnExiting( EventArgs e )
530     {
531     CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
532     this.t終了処理();
533     base.OnExiting( e );
534     }
535     protected override void Update( GameTime gameTime )
536     {
537     }
538     protected override void Draw( GameTime gameTime )
539     {
540     Sound管理.t再生中の処理をする();
541    
542     if( Timer != null )
543     Timer.t更新();
544 kairera0467 153
545     if ( CSound管理.rc演奏用タイマ != null )
546 kairera0467 2 CSound管理.rc演奏用タイマ.t更新();
547    
548     if( Input管理 != null )
549     Input管理.tリング( this.bApplicationActive, CDTXMania.ConfigIni.bバッファ入力を行う );
550    
551     if( FPS != null )
552     FPS.tカウンタ更新();
553    
554     //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
555     // Pad.st検知したデバイス.Clear();
556    
557     if( this.Device == null )
558     return;
559    
560     if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
561     CPowerManagement.tDisableMonitorSuspend();
562    
563 kairera0467 82 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
564     #region [ スリープ ]
565     if ( ConfigIni.nフレム毎スリms >= 0 ) // #xxxxx 2011.11.27 yyagi
566     {
567     Thread.Sleep( ConfigIni.nフレム毎スリms );
568     }
569     #endregion
570    
571 kairera0467 292 #region [ DTXCreatorからの指示 ]
572     if ( this.Window.IsReceivedMessage ) // ウインドウメッセージで、
573     {
574     string strMes = this.Window.strMessage;
575     this.Window.IsReceivedMessage = false;
576    
577     if ( strMes != null )
578     {
579     DTXVmode.ParseArguments( strMes );
580    
581     if ( DTXVmode.Enabled )
582     {
583     bコンパクトモ = true;
584     strコンパクトモドファイル = DTXVmode.filename;
585 kairera0467 380 if ( DTXVmode.Command == CDTXVmode.ECommand.Preview )
586     {
587     // preview soundの再生
588     string strPreviewFilename = DTXVmode.previewFilename;
589     //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
590     try
591     {
592     if ( this.previewSound != null )
593     {
594     this.previewSound.tサウンドを停止する();
595     this.previewSound.Dispose();
596     this.previewSound = null;
597     }
598     this.previewSound = CDTXMania.Sound管理.tサウンドを生成する( strPreviewFilename );
599     this.previewSound.n音量 = DTXVmode.previewVolume;
600     this.previewSound.n位置 = DTXVmode.previewPan;
601     this.previewSound.t再生を開始する();
602     Trace.TraceInformation( "DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename );
603     }
604     catch
605     {
606     Trace.TraceError( "DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename );
607     if ( this.previewSound != null )
608     {
609     this.previewSound.Dispose();
610     }
611     this.previewSound = null;
612     }
613     }
614 kairera0467 292 }
615     }
616     }
617     #endregion
618    
619 kairera0467 2 this.Device.BeginScene();
620     this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, Color.Black, 1f, 0);
621    
622     if( r現在のステ != null )
623     {
624     this.n進行描画の戻り値 = ( r現在のステ != null ) ? r現在のステ.On進行描画() : 0;
625    
626     #region [ プラグインの進行描画 ]
627     //---------------------
628     foreach( STPlugin sp in this.listプラグイン )
629     {
630     Directory.SetCurrentDirectory( sp.strプラグインフォルダ );
631    
632     if( CDTXMania.act現在入力を占有中のプラグイン == null || CDTXMania.act現在入力を占有中のプラグイン == sp.plugin )
633     sp.plugin.On進行描画( CDTXMania.Pad, CDTXMania.Input管理.Keyboard );
634     else
635     sp.plugin.On進行描画( null, null );
636    
637     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
638     }
639     //---------------------
640     #endregion
641    
642    
643     CScoreIni scoreIni = null;
644    
645 kairera0467 178 if( Control.IsKeyLocked( Keys.CapsLock ) ) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
646     { // → songs.db等の書き込み時だと音切れするっぽい
647     actEnumSongs.On非活性化();
648     EnumSongs.SongListEnumCompletelyDone();
649     CDTXMania.stage選曲.bIsEnumeratingSongs = false;
650     }
651 kairera0467 2 #region [ 曲検索スレッドの起動/終了 ] // ここに"Enumerating Songs..."表示を集約
652     if (!CDTXMania.bコンパクトモ)
653     {
654     actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
655     } // "Enumerating Songs..."アイコンの描画
656     switch ( r現在のステ.eステID )
657     {
658     case CStage.Eステ.タイトル:
659     case CStage.Eステ.コンフィグ:
660     case CStage.Eステ.オプション:
661     case CStage.Eステ.選曲:
662     case CStage.Eステ.曲読み込み:
663     if ( EnumSongs != null )
664     {
665 kairera0467 380 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
666 kairera0467 2 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
667     if ( r現在のステ.eステID == CStage.Eステ.タイトル &&
668     r直前のステ.eステID == CStage.Eステ.起動 &&
669     this.n進行描画の戻り値 == (int) CStageタイトル.E戻り値.継続 &&
670     !EnumSongs.IsSongListEnumStarted )
671     {
672     actEnumSongs.On活性化();
673     CDTXMania.stage選曲.bIsEnumeratingSongs = true;
674     EnumSongs.Init( CDTXMania.Songs管理.listSongsDB, CDTXMania.Songs管理.nSongsDBから取得できたスコア数 ); // songs.db情報と、取得した曲数を、新インスタンスにも与える
675     EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
676     if ( CDTXMania.Songs管理.nSongsDBから取得できたスコア数 == 0 ) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
677     {
678     EnumSongs.ChangeEnumeratePriority( ThreadPriority.Normal );
679     }
680     }
681     #endregion
682    
683     #region [ 曲検索の中断と再開 ]
684     if ( r現在のステ.eステID == CStage.Eステ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone )
685     {
686     switch ( this.n進行描画の戻り値 )
687     {
688     case 0: // 何もない
689     //if ( CDTXMania.stage選曲.bIsEnumeratingSongs )
690 kairera0467 374 if ( !CDTXMania.stage選曲.bIsPlayingPremovie || CDTXMania.Skin.ds選曲画面背景動画 != null )
691 kairera0467 2 {
692     EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
693     EnumSongs.IsSlowdown = false;
694     }
695     else
696     {
697     // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
698     EnumSongs.IsSlowdown = true;
699     }
700     actEnumSongs.On活性化();
701     break;
702    
703     case 2: // 曲決定
704     EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
705     actEnumSongs.On非活性化();
706     break;
707     }
708     }
709     #endregion
710    
711     #region [ 曲探索中断待ち待機 ]
712     if ( r現在のステ.eステID == CStage.Eステ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
713     EnumSongs.thDTXFileEnumerate != null ) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
714     {
715     EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
716     }
717     #endregion
718    
719     #region [ 曲検索が完了したら、実際の曲リストに反映する ]
720     // CStage選曲.On活性化() に回した方がいいかな?
721     if ( EnumSongs.IsSongListEnumerated )
722     {
723     actEnumSongs.On非活性化();
724     CDTXMania.stage選曲.bIsEnumeratingSongs = false;
725    
726     bool bRemakeSongTitleBar = ( r現在のステ.eステID == CStage.Eステ.選曲 ) ? true : false;
727     CDTXMania.stage選曲.Refresh( EnumSongs.Songs管理, bRemakeSongTitleBar );
728     EnumSongs.SongListEnumCompletelyDone();
729     }
730     #endregion
731     }
732     break;
733     }
734     #endregion
735    
736     switch ( r現在のステ.eステID )
737     {
738     case CStage.Eステ.何もしない:
739     break;
740    
741     case CStage.Eステ.起動:
742     #region [ *** ]
743     //-----------------------------
744     if( this.n進行描画の戻り値 != 0 )
745     {
746     if( !bコンパクトモ )
747     {
748     r現在のステ.On非活性化();
749     Trace.TraceInformation( "----------------------" );
750     Trace.TraceInformation( "■ タイトル" );
751     stageタイトル.On活性化();
752     r直前のステ = r現在のステ;
753     r現在のステ = stageタイトル;
754     }
755     else
756     {
757     r現在のステ.On非活性化();
758     Trace.TraceInformation( "----------------------" );
759     Trace.TraceInformation( "■ 曲読み込み" );
760     stage曲読み込み.On活性化();
761     r直前のステ = r現在のステ;
762     r現在のステ = stage曲読み込み;
763    
764     }
765     foreach( STPlugin pg in this.listプラグイン )
766     {
767     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
768     pg.plugin.Onステジ変更();
769     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
770     }
771    
772     this.tガベジコレクションを実行する();
773     }
774     //-----------------------------
775     #endregion
776     break;
777    
778     case CStage.Eステ.タイトル:
779     #region [ *** ]
780     //-----------------------------
781     switch( this.n進行描画の戻り値 )
782     {
783     case (int)CStageタイトル.E戻り値.GAMESTART:
784     #region [ 選曲処理へ ]
785     //-----------------------------
786     r現在のステ.On非活性化();
787     Trace.TraceInformation( "----------------------" );
788     Trace.TraceInformation( "■ 選曲" );
789     stage選曲.On活性化();
790     r直前のステ = r現在のステ;
791     r現在のステ = stage選曲;
792     //-----------------------------
793     #endregion
794     break;
795    
796     #region [ OPTION: 廃止済 ]
797     /*
798     case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
799     #region [ *** ]
800     //-----------------------------
801     r現在のステージ.On非活性化();
802     Trace.TraceInformation( "----------------------" );
803     Trace.TraceInformation( "■ オプション" );
804     stageオプション.On活性化();
805     r直前のステージ = r現在のステージ;
806     r現在のステージ = stageオプション;
807     //-----------------------------
808     #endregion
809     break;
810     */
811     #endregion
812    
813     case (int)CStageタイトル.E戻り値.CONFIG:
814     #region [ *** ]
815     //-----------------------------
816     r現在のステ.On非活性化();
817     Trace.TraceInformation( "----------------------" );
818     Trace.TraceInformation( "■ コンフィグ" );
819     stageコンフィグ.On活性化();
820     r直前のステ = r現在のステ;
821     r現在のステ = stageコンフィグ;
822     //-----------------------------
823     #endregion
824     break;
825    
826     case (int)CStageタイトル.E戻り値.EXIT:
827     #region [ *** ]
828     //-----------------------------
829     r現在のステ.On非活性化();
830     Trace.TraceInformation( "----------------------" );
831     Trace.TraceInformation( "■ 終了" );
832     stage終了.On活性化();
833     r直前のステ = r現在のステ;
834     r現在のステ = stage終了;
835     //-----------------------------
836     #endregion
837     break;
838     }
839    
840     foreach( STPlugin pg in this.listプラグイン )
841     {
842     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
843     pg.plugin.Onステジ変更();
844     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
845     }
846    
847 kairera0467 153 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
848 kairera0467 2 //-----------------------------
849     #endregion
850     break;
851    
852    
853     case CStage.Eステ.オプション:
854     #region [ *** ]
855     //-----------------------------
856     if( this.n進行描画の戻り値 != 0 )
857     {
858     switch( r直前のステ.eステID )
859     {
860     case CStage.Eステ.タイトル:
861     #region [ *** ]
862     //-----------------------------
863     r現在のステ.On非活性化();
864     Trace.TraceInformation( "----------------------" );
865     Trace.TraceInformation( "■ タイトル" );
866     stageタイトル.On活性化();
867     r直前のステ = r現在のステ;
868     r現在のステ = stageタイトル;
869    
870     foreach( STPlugin pg in this.listプラグイン )
871     {
872     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
873     pg.plugin.Onステジ変更();
874     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
875     }
876    
877     this.tガベジコレクションを実行する();
878     break;
879     //-----------------------------
880     #endregion
881    
882     case CStage.Eステ.選曲:
883     #region [ *** ]
884     //-----------------------------
885     r現在のステ.On非活性化();
886     Trace.TraceInformation( "----------------------" );
887     Trace.TraceInformation( "■ 選曲" );
888     stage選曲.On活性化();
889     r直前のステ = r現在のステ;
890     r現在のステ = stage選曲;
891    
892     foreach( STPlugin pg in this.listプラグイン )
893     {
894     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
895     pg.plugin.Onステジ変更();
896     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
897     }
898    
899     this.tガベジコレクションを実行する();
900     break;
901     //-----------------------------
902     #endregion
903     }
904     }
905     //-----------------------------
906     #endregion
907     break;
908    
909    
910     case CStage.Eステ.コンフィグ:
911     #region [ *** ]
912     //-----------------------------
913     if( this.n進行描画の戻り値 != 0 )
914     {
915     switch( r直前のステ.eステID )
916     {
917     case CStage.Eステ.タイトル:
918     #region [ *** ]
919     //-----------------------------
920     r現在のステ.On非活性化();
921     Trace.TraceInformation( "----------------------" );
922     Trace.TraceInformation( "■ タイトル" );
923     stageタイトル.On活性化();
924     r直前のステ = r現在のステ;
925     r現在のステ = stageタイトル;
926    
927     foreach( STPlugin pg in this.listプラグイン )
928     {
929     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
930     pg.plugin.Onステジ変更();
931     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
932     }
933    
934     this.tガベジコレクションを実行する();
935     break;
936     //-----------------------------
937     #endregion
938    
939     case CStage.Eステ.選曲:
940     #region [ *** ]
941     //-----------------------------
942     r現在のステ.On非活性化();
943     Trace.TraceInformation( "----------------------" );
944     Trace.TraceInformation( "■ 選曲" );
945     stage選曲.On活性化();
946     r直前のステ = r現在のステ;
947     r現在のステ = stage選曲;
948    
949     foreach( STPlugin pg in this.listプラグイン )
950     {
951     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
952     pg.plugin.Onステジ変更();
953     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
954     }
955    
956     this.tガベジコレクションを実行する();
957     break;
958     //-----------------------------
959     #endregion
960     }
961     }
962     //-----------------------------
963     #endregion
964     break;
965    
966     case CStage.Eステ.選曲:
967     #region [ *** ]
968     //-----------------------------
969     switch( this.n進行描画の戻り値 )
970     {
971     case (int) CStage選曲.E戻り値.タイトルに戻る:
972     #region [ *** ]
973     //-----------------------------
974     r現在のステ.On非活性化();
975     Trace.TraceInformation( "----------------------" );
976     Trace.TraceInformation( "■ タイトル" );
977     stageタイトル.On活性化();
978     r直前のステ = r現在のステ;
979     r現在のステ = stageタイトル;
980    
981     foreach( STPlugin pg in this.listプラグイン )
982     {
983     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
984     pg.plugin.Onステジ変更();
985     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
986     }
987    
988     this.tガベジコレクションを実行する();
989     break;
990     //-----------------------------
991     #endregion
992    
993     case (int) CStage選曲.E戻り値.選曲した:
994     #region [ *** ]
995     //-----------------------------
996     r現在のステ.On非活性化();
997     Trace.TraceInformation( "----------------------" );
998     Trace.TraceInformation( "■ 曲読み込み" );
999     stage曲読み込み.On活性化();
1000     r直前のステ = r現在のステ;
1001     r現在のステ = stage曲読み込み;
1002    
1003     foreach( STPlugin pg in this.listプラグイン )
1004     {
1005     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1006     pg.plugin.Onステジ変更();
1007     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1008     }
1009    
1010     this.tガベジコレクションを実行する();
1011     break;
1012     //-----------------------------
1013     #endregion
1014    
1015    
1016     case (int) CStage選曲.E戻り値.オプション呼び出し:
1017     #region [ *** ]
1018     //-----------------------------
1019    
1020     r現在のステ.On非活性化();
1021     Trace.TraceInformation( "----------------------" );
1022     Trace.TraceInformation( "■ オプション" );
1023     stageオプション.On活性化();
1024     r直前のステ = r現在のステ;
1025     r現在のステ = stageオプション;
1026    
1027     foreach( STPlugin pg in this.listプラグイン )
1028     {
1029     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1030     pg.plugin.Onステジ変更();
1031     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1032     }
1033    
1034     this.tガベジコレクションを実行する();
1035     break;
1036     //-----------------------------
1037     #endregion
1038    
1039     case (int) CStage選曲.E戻り値.コンフィグ呼び出し:
1040     #region [ *** ]
1041     //-----------------------------
1042     r現在のステ.On非活性化();
1043     Trace.TraceInformation( "----------------------" );
1044     Trace.TraceInformation( "■ コンフィグ" );
1045     stageコンフィグ.On活性化();
1046     r直前のステ = r現在のステ;
1047     r現在のステ = stageコンフィグ;
1048    
1049     foreach( STPlugin pg in this.listプラグイン )
1050     {
1051     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1052     pg.plugin.Onステジ変更();
1053     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1054     }
1055    
1056     this.tガベジコレクションを実行する();
1057     break;
1058     //-----------------------------
1059     #endregion
1060    
1061     case (int) CStage選曲.E戻り値.スキン変更:
1062    
1063     #region [ *** ]
1064     //-----------------------------
1065     r現在のステ.On非活性化();
1066     Trace.TraceInformation( "----------------------" );
1067     Trace.TraceInformation( "■ スキン切り替え" );
1068     stageChangeSkin.On活性化();
1069     r直前のステ = r現在のステ;
1070     r現在のステ = stageChangeSkin;
1071     break;
1072     //-----------------------------
1073     #endregion
1074     }
1075     //-----------------------------
1076     #endregion
1077     break;
1078    
1079     case CStage.Eステ.曲読み込み:
1080     #region [ *** ]
1081     //-----------------------------
1082     if( this.n進行描画の戻り値 != 0 )
1083     {
1084     CDTXMania.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1085    
1086     r現在のステ.On非活性化();
1087 kairera0467 61
1088 kairera0467 65 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1089 kairera0467 61 if ( this.n進行描画の戻り値 == (int) E曲読込画面の戻り値.読込中止 )
1090     {
1091     //DTX.t全チップの再生停止();
1092     DTX.On非活性化();
1093     Trace.TraceInformation( "曲の読み込みを中止しました。" );
1094     this.tガベジコレクションを実行する();
1095     Trace.TraceInformation( "----------------------" );
1096     Trace.TraceInformation( "■ 選曲" );
1097     stage選曲.On活性化();
1098     r直前のステ = r現在のステ;
1099     r現在のステ = stage選曲;
1100     foreach ( STPlugin pg in this.listプラグイン )
1101     {
1102     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1103     pg.plugin.Onステジ変更();
1104     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1105     }
1106     break;
1107     }
1108     #endregion
1109    
1110 kairera0467 65
1111 kairera0467 2 if( !ConfigIni.bギタレボモ )
1112     {
1113     Trace.TraceInformation( "----------------------" );
1114     Trace.TraceInformation( "■ 演奏(ドラム画面)" );
1115     #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1116     for (int i = 0; i < 5; i++)
1117     {
1118     for (int j = 0; j < 2; j++)
1119     {
1120     stage演奏ドラム画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1121     }
1122     }
1123     for (int i = 0; i < 3; i++) {
1124     stage演奏ドラム画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1125     }
1126     #endif
1127     r直前のステ = r現在のステ;
1128     r現在のステ = stage演奏ドラム画面;
1129     }
1130     else
1131     {
1132     Trace.TraceInformation( "----------------------" );
1133     Trace.TraceInformation( "■ 演奏(ギター画面)" );
1134     #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1135     for (int i = 0; i < 5; i++)
1136     {
1137     for (int j = 0; j < 2; j++)
1138     {
1139     stage演奏ギタ画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1140     }
1141     }
1142     for (int i = 0; i < 3; i++) {
1143     stage演奏ギタ画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1144     }
1145     #endif
1146     r直前のステ = r現在のステ;
1147     r現在のステ = stage演奏ギタ画面;
1148     }
1149    
1150     foreach( STPlugin pg in this.listプラグイン )
1151     {
1152     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1153     pg.plugin.Onステジ変更();
1154     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1155     }
1156    
1157     this.tガベジコレクションを実行する();
1158     }
1159     //-----------------------------
1160     #endregion
1161     break;
1162    
1163     case CStage.Eステ.演奏:
1164     #region [ *** ]
1165     //-----------------------------
1166 kairera0467 292
1167 kairera0467 380 double n = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
1168     swlist.Add(n);
1169    
1170 kairera0467 292 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1171     if ( DTXVmode.Enabled && DTXVmode.Refreshed )
1172     {
1173     DTXVmode.Refreshed = false;
1174    
1175     if ( DTXVmode.Command == CDTXVmode.ECommand.Stop )
1176     {
1177     if ( !ConfigIni.bギタレボモ )
1178     {
1179     CDTXMania.stage演奏ドラム画面.t停止();
1180     }
1181     else
1182     {
1183     CDTXMania.stage演奏ギタ画面.t停止();
1184     }
1185 kairera0467 380 if ( previewSound != null )
1186     {
1187     this.previewSound.tサウンドを停止する();
1188     this.previewSound.Dispose();
1189     this.previewSound = null;
1190     }
1191 kairera0467 292 }
1192     else if ( DTXVmode.Command == CDTXVmode.ECommand.Play )
1193     {
1194     if ( DTXVmode.NeedReload )
1195     {
1196     if ( !ConfigIni.bギタレボモ )
1197     {
1198     CDTXMania.stage演奏ドラム画面.t再読込();
1199     }
1200     else
1201     {
1202     CDTXMania.stage演奏ギタ画面.t再読込();
1203     }
1204 kairera0467 380
1205     CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1206     CDTXMania.ConfigIni.bGuitar有効 = true;
1207     CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1208     CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1209     if ( CDTXMania.ConfigIni.b垂直帰線待ちを行う != DTXVmode.VSyncWait )
1210     {
1211     CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1212     CDTXMania.app.b次のタイミングで垂直帰線同期切り替えを行う = true;
1213     }
1214 kairera0467 292 }
1215     else
1216     {
1217     if ( !ConfigIni.bギタレボモ )
1218     {
1219     CDTXMania.stage演奏ドラム画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
1220     }
1221     else
1222     {
1223     CDTXMania.stage演奏ギタ画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
1224     }
1225     }
1226     }
1227     }
1228     #endregion
1229    
1230 kairera0467 2 switch( this.n進行描画の戻り値 )
1231     {
1232 kairera0467 580 case (int) E演奏画面の戻り値.再読込_再演奏:
1233 kairera0467 292 #region [ DTXファイルを再読み込みして、再演奏 ]
1234     DTX.t全チップの再生停止();
1235     DTX.On非活性化();
1236     r現在のステ.On非活性化();
1237     stage曲読み込み.On活性化();
1238     r直前のステ = r現在のステ;
1239     r現在のステ = stage曲読み込み;
1240     this.tガベジコレクションを実行する();
1241     break;
1242     #endregion
1243    
1244     //case (int) E演奏画面の戻り値.再演奏:
1245     #region [ 再読み込み無しで、再演奏 ]
1246     #endregion
1247     // break;
1248    
1249 kairera0467 2 case (int) E演奏画面の戻り値.継続:
1250     break;
1251    
1252     case (int) E演奏画面の戻り値.演奏中断:
1253     #region [ 演奏キャンセル ]
1254     //-----------------------------
1255     scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Play canceled" );
1256    
1257 kairera0467 380 double lastd = 0f;
1258     int f = 0;
1259     foreach ( double d in swlist )
1260     {
1261     double dif = d - lastd;
1262     string s = "";
1263     if ( 0.016 < dif && dif < 0.017 )
1264     {
1265     }
1266     else
1267     {
1268     s = "★";
1269     }
1270     //Trace.TraceInformation( "frame " + f + ": " + d + " (" + dif + ")" + s );
1271     lastd = d;
1272     f++;
1273     }
1274     swlist.Clear();
1275    
1276 kairera0467 2 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1277     //---------------------
1278     foreach( STPlugin pg in this.listプラグイン )
1279     {
1280     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1281     pg.plugin.On演奏キャンセル( scoreIni );
1282     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1283     }
1284     //---------------------
1285     #endregion
1286    
1287     DTX.t全チップの再生停止();
1288     DTX.On非活性化();
1289     r現在のステ.On非活性化();
1290     if( bコンパクトモ )
1291     {
1292     base.Window.Close();
1293     }
1294     else
1295     {
1296     Trace.TraceInformation( "----------------------" );
1297     Trace.TraceInformation( "■ 選曲" );
1298     stage選曲.On活性化();
1299     r直前のステ = r現在のステ;
1300     r現在のステ = stage選曲;
1301    
1302     #region [ プラグイン Onステージ変更() の呼び出し ]
1303     //---------------------
1304     foreach( STPlugin pg in this.listプラグイン )
1305     {
1306     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1307     pg.plugin.Onステジ変更();
1308     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1309     }
1310     //---------------------
1311     #endregion
1312    
1313     this.tガベジコレクションを実行する();
1314     }
1315     break;
1316     //-----------------------------
1317     #endregion
1318    
1319     case (int) E演奏画面の戻り値.ステジ失敗:
1320     #region [ 演奏失敗(StageFailed) ]
1321     //-----------------------------
1322     scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Stage failed" );
1323    
1324     #region [ プラグイン On演奏失敗() の呼び出し ]
1325     //---------------------
1326     foreach( STPlugin pg in this.listプラグイン )
1327     {
1328     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1329     pg.plugin.On演奏失敗( scoreIni );
1330     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1331     }
1332     //---------------------
1333     #endregion
1334    
1335     DTX.t全チップの再生停止();
1336     DTX.On非活性化();
1337     r現在のステ.On非活性化();
1338     if( bコンパクトモ )
1339     {
1340     base.Window.Close();
1341     }
1342     else
1343     {
1344     Trace.TraceInformation( "----------------------" );
1345     Trace.TraceInformation( "■ 選曲" );
1346     stage選曲.On活性化();
1347     r直前のステ = r現在のステ;
1348     r現在のステ = stage選曲;
1349    
1350     #region [ プラグイン Onステージ変更() の呼び出し ]
1351     //---------------------
1352     foreach( STPlugin pg in this.listプラグイン )
1353     {
1354     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1355     pg.plugin.Onステジ変更();
1356     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1357     }
1358     //---------------------
1359     #endregion
1360    
1361     this.tガベジコレクションを実行する();
1362     }
1363     break;
1364     //-----------------------------
1365     #endregion
1366    
1367     case (int) E演奏画面の戻り値.ステジクリア:
1368     #region [ 演奏クリア ]
1369     //-----------------------------
1370     CScoreIni.C演奏記録 c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass;
1371     CDTX.CChip[] chipArray = new CDTX.CChip[10];
1372     if( ConfigIni.bギタレボモ )
1373     {
1374     stage演奏ギタ画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass );
1375     }
1376     else
1377     {
1378     stage演奏ドラム画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass, out chipArray );
1379     }
1380    
1381     if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.24 yyagi Gt/Bsを入れ替えていたなら、演奏結果も入れ替える
1382     {
1383     CScoreIni.C演奏記録 t;
1384     t = c演奏記録_Guitar;
1385     c演奏記録_Guitar = c演奏記録_Bass;
1386     c演奏記録_Bass = t;
1387    
1388     CDTXMania.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す
1389     CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // #24415 2011.2.27 yyagi
1390     // リザルト集計時のみ、Auto系のフラグも元に戻す。
1391     // これを戻すのは、リザルト集計後。
1392     } // "case CStage.Eステージ.結果:"のところ。
1393    
1394     double ps = 0.0, gs = 0.0;
1395     if ( !c演奏記録_Drums.bAUTOである && c演奏記録_Drums.n全チップ数 > 0) {
1396     ps = c演奏記録_Drums.db演奏型スキル値;
1397     gs = c演奏記録_Drums.dbム型スキル値;
1398     }
1399     else if ( !c演奏記録_Guitar.bAUTOである && c演奏記録_Guitar.n全チップ数 > 0) {
1400     ps = c演奏記録_Guitar.db演奏型スキル値;
1401     gs = c演奏記録_Guitar.dbム型スキル値;
1402     }
1403     else
1404     {
1405     ps = c演奏記録_Bass.db演奏型スキル値;
1406     gs = c演奏記録_Bass.dbム型スキル値;
1407     }
1408     string str = "Cleared";
1409     switch( CScoreIni.t総合ランク値を計算して返す( c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass ) )
1410     {
1411     case (int)CScoreIni.ERANK.SS:
1412     str = string.Format( "Cleared (SS: {0:F2})", ps );
1413     break;
1414    
1415     case (int) CScoreIni.ERANK.S:
1416     str = string.Format( "Cleared (S: {0:F2})", ps );
1417     break;
1418    
1419     case (int) CScoreIni.ERANK.A:
1420     str = string.Format( "Cleared (A: {0:F2})", ps );
1421     break;
1422    
1423     case (int) CScoreIni.ERANK.B:
1424     str = string.Format( "Cleared (B: {0:F2})", ps );
1425     break;
1426    
1427     case (int) CScoreIni.ERANK.C:
1428     str = string.Format( "Cleared (C: {0:F2})", ps );
1429     break;
1430    
1431     case (int) CScoreIni.ERANK.D:
1432     str = string.Format( "Cleared (D: {0:F2})", ps );
1433     break;
1434    
1435     case (int) CScoreIni.ERANK.E:
1436     str = string.Format( "Cleared (E: {0:F2})", ps );
1437     break;
1438    
1439     case (int)CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1440     str = "Cleared (No chips)";
1441     break;
1442     }
1443    
1444     scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( str );
1445    
1446     #region [ プラグイン On演奏クリア() の呼び出し ]
1447     //---------------------
1448     foreach( STPlugin pg in this.listプラグイン )
1449     {
1450     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1451     pg.plugin.On演奏クリア( scoreIni );
1452     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1453     }
1454     //---------------------
1455     #endregion
1456    
1457     r現在のステ.On非活性化();
1458     Trace.TraceInformation( "----------------------" );
1459     Trace.TraceInformation( "■ 結果" );
1460     stage結果.st演奏記録.Drums = c演奏記録_Drums;
1461     stage結果.st演奏記録.Guitar = c演奏記録_Guitar;
1462     stage結果.st演奏記録.Bass = c演奏記録_Bass;
1463     stage結果.r空うちドラムチップ = chipArray;
1464     stage結果.On活性化();
1465     r直前のステ = r現在のステ;
1466     r現在のステ = stage結果;
1467    
1468     #region [ プラグイン Onステージ変更() の呼び出し ]
1469     //---------------------
1470     foreach( STPlugin pg in this.listプラグイン )
1471     {
1472     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1473     pg.plugin.Onステジ変更();
1474     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1475     }
1476     //---------------------
1477     #endregion
1478    
1479     break;
1480     //-----------------------------
1481     #endregion
1482     }
1483     //-----------------------------
1484     #endregion
1485     break;
1486    
1487     case CStage.Eステ.結果:
1488     #region [ *** ]
1489     //-----------------------------
1490     if( this.n進行描画の戻り値 != 0 )
1491     {
1492     if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1493     {
1494     CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
1495     }
1496    
1497     DTX.t全チップの再生一時停止();
1498     DTX.On非活性化();
1499     r現在のステ.On非活性化();
1500     if( !bコンパクトモ )
1501     {
1502     Trace.TraceInformation( "----------------------" );
1503     Trace.TraceInformation( "■ 選曲" );
1504     stage選曲.On活性化();
1505     r直前のステ = r現在のステ;
1506     r現在のステ = stage選曲;
1507    
1508     foreach( STPlugin pg in this.listプラグイン )
1509     {
1510     Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1511     pg.plugin.Onステジ変更();
1512     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1513     }
1514    
1515     this.tガベジコレクションを実行する();
1516     }
1517     else
1518     {
1519     base.Window.Close();
1520     }
1521     }
1522     //-----------------------------
1523     #endregion
1524     break;
1525    
1526     case CStage.Eステ.ChangeSkin:
1527     #region [ *** ]
1528     //-----------------------------
1529     if ( this.n進行描画の戻り値 != 0 )
1530     {
1531     r現在のステ.On非活性化();
1532     Trace.TraceInformation( "----------------------" );
1533     Trace.TraceInformation( "■ 選曲" );
1534     stage選曲.On活性化();
1535     r直前のステ = r現在のステ;
1536     r現在のステ = stage選曲;
1537     this.tガベジコレクションを実行する();
1538     }
1539     //-----------------------------
1540     #endregion
1541     break;
1542    
1543     case CStage.Eステ.終了:
1544     #region [ *** ]
1545     //-----------------------------
1546     if( this.n進行描画の戻り値 != 0 )
1547     {
1548     base.Exit();
1549     }
1550     //-----------------------------
1551     #endregion
1552     break;
1553     }
1554     }
1555 kairera0467 82 this.Device.EndScene(); // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
1556     // (つまり、Present()は、Draw()完了後に実行される)
1557     #if !GPUFlushAfterPresent
1558     actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
1559     #endif
1560 kairera0467 397 if ( Sound管理.GetCurrentSoundDeviceType() != "DirectSound" )
1561     {
1562     Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
1563     }
1564    
1565    
1566 kairera0467 2 #region [ 全画面・ウインドウ切り替え ]
1567 kairera0467 580 if ( this.b次のタイミングで全画面_ウィンドウ切り替えを行う )
1568 kairera0467 2 {
1569     ConfigIni.b全画面モ = !ConfigIni.b全画面モ;
1570 kairera0467 580 app.t全画面_ウィンドウモド切り替え();
1571     this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
1572 kairera0467 2 }
1573     #endregion
1574     #region [ 垂直基線同期切り替え ]
1575     if ( this.b次のタイミングで垂直帰線同期切り替えを行う )
1576     {
1577     bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
1578     currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
1579     DeviceSettings currentSettings = app.GraphicsDeviceManager.CurrentSettings;
1580     currentSettings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1581     app.GraphicsDeviceManager.ChangeDevice( currentSettings );
1582     this.b次のタイミングで垂直帰線同期切り替えを行う = false;
1583     base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
1584     if (bIsMaximized)
1585     {
1586     this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
1587     }
1588     }
1589     #endregion
1590     }
1591    
1592    
1593     // その他
1594    
1595     #region [ 汎用ヘルパー ]
1596     //-----------------
1597     public static CTexture tテクスチャの生成( string fileName )
1598     {
1599     return tテクスチャの生成( fileName, false );
1600     }
1601     public static CTexture tテクスチャの生成( string fileName, bool b黒を透過する )
1602     {
1603     if ( app == null )
1604     {
1605     return null;
1606     }
1607     try
1608     {
1609     return new CTexture( app.Device, fileName, TextureFormat, b黒を透過する );
1610     }
1611     catch ( CTextureCreateFailedException )
1612     {
1613     Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1614     return null;
1615     }
1616     catch ( FileNotFoundException )
1617     {
1618     Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1619     return null;
1620     }
1621     }
1622     public static void tテクスチャの解放( ref CTexture tx )
1623     {
1624 kairera0467 90 if( tx != null )
1625     CDTXMania.t安全にDisposeする( ref tx );
1626 kairera0467 2 }
1627 kairera0467 430 public static void tテクスチャの解放( ref CTextureAf tx )
1628     {
1629     CDTXMania.t安全にDisposeする( ref tx );
1630     }
1631 kairera0467 2 public static CTexture tテクスチャの生成( byte[] txData )
1632     {
1633     return tテクスチャの生成( txData, false );
1634     }
1635     public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
1636     {
1637     if ( app == null )
1638     {
1639     return null;
1640     }
1641     try
1642     {
1643     return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
1644     }
1645     catch ( CTextureCreateFailedException )
1646     {
1647     Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1648     return null;
1649     }
1650     }
1651    
1652     public static CTexture tテクスチャの生成( Bitmap bitmap )
1653     {
1654     return tテクスチャの生成( bitmap, false );
1655     }
1656     public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
1657     {
1658     if ( app == null )
1659     {
1660     return null;
1661     }
1662     try
1663     {
1664     return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
1665     }
1666     catch ( CTextureCreateFailedException )
1667     {
1668     Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1669     return null;
1670     }
1671     }
1672    
1673     public static CTexture tテクスチャを生成する(int width, int height)
1674     {
1675     try
1676     {
1677     return new CTexture(CDTXMania.App.D3D9Device, width, height, CDTXMania.TextureFormat);
1678     }
1679     catch
1680     {
1681     Trace.TraceError("空のテクスチャ({0}x{1})の生成に失敗しました。", width, height);
1682     return null;
1683     }
1684     }
1685 kairera0467 430 public static CTextureAf tテクスチャの生成Af( string fileName )
1686     {
1687     return tテクスチャの生成Af( fileName, false );
1688     }
1689     public static CTextureAf tテクスチャの生成Af( string fileName, bool b黒を透過する )
1690     {
1691     if ( app == null )
1692     {
1693     return null;
1694     }
1695     try
1696     {
1697     return new CTextureAf( app.Device, fileName, TextureFormat, b黒を透過する );
1698     }
1699     catch ( CTextureCreateFailedException )
1700     {
1701     Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1702     return null;
1703     }
1704     catch ( FileNotFoundException )
1705     {
1706     Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1707     return null;
1708     }
1709     }
1710 kairera0467 2
1711     public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する(string fileName, IntPtr hWnd, bool bディオレンダラなし)
1712     {
1713     CDirectShow ds = null;
1714 kairera0467 420 if( File.Exists( fileName ) )
1715 kairera0467 2 {
1716 kairera0467 420 try
1717     {
1718     ds = new CDirectShow(fileName, hWnd, bディオレンダラなし);
1719     }
1720     catch (FileNotFoundException)
1721     {
1722     Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1723     ds = null; // Dispose はコンストラクタ内で実施済み
1724     }
1725     catch
1726     {
1727     Trace.TraceError("DirectShow の生成に失敗しました。[{0}]", fileName);
1728     ds = null; // Dispose はコンストラクタ内で実施済み
1729     }
1730 kairera0467 2 }
1731 kairera0467 420 else
1732 kairera0467 2 {
1733     Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1734 kairera0467 420 return null;
1735 kairera0467 2 }
1736    
1737     return ds;
1738     }
1739    
1740     /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
1741     public static void t安全にDisposeする<T>( ref T obj )
1742     {
1743     if ( obj == null )
1744     return;
1745    
1746     var d = obj as IDisposable;
1747    
1748     if ( d != null )
1749     d.Dispose();
1750    
1751     obj = default( T );
1752     }
1753     //-----------------
1754     #endregion
1755     #region [ private ]
1756     //-----------------
1757     private bool bマウスカソル表示中 = true;
1758     public bool bウィンドウがアクティブである = true;
1759     private bool b終了処理完了済み;
1760     private static CDTX dtx;
1761     private List<CActivity> listトップレベルActivities;
1762 kairera0467 24 public int n進行描画の戻り値;
1763 kairera0467 2 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
1764 kairera0467 292 private string strWindowTitle
1765     {
1766     get
1767     {
1768     if ( DTXVmode.Enabled )
1769     {
1770     return "DTXViewer release " + VERSION;
1771     }
1772     else
1773     {
1774     return "DTXMania .NET style release " + VERSION;
1775     }
1776     }
1777     }
1778 kairera0467 380 private CSound previewSound;
1779 kairera0467 2
1780     private void t起動処理()
1781     {
1782     #region [ strEXEのあるフォルダを決定する ]
1783     //-----------------
1784     // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
1785     #if DEBUG
1786     strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
1787     #else
1788     strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
1789     #endif
1790     // END #23629 2010.11.13 from
1791     //-----------------
1792     #endregion
1793    
1794     #region [ Config.ini の読込み ]
1795     //---------------------
1796     ConfigIni = new CConfigIni();
1797     string path = strEXEのあるフォルダ + "Config.ini";
1798     if( File.Exists( path ) )
1799     {
1800     try
1801     {
1802     ConfigIni.tファイルから読み込み( path );
1803     }
1804     catch
1805     {
1806     //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
1807     }
1808     }
1809     this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
1810     // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
1811    
1812     //---------------------
1813     #endregion
1814     #region [ ログ出力開始 ]
1815     //---------------------
1816     Trace.AutoFlush = true;
1817     if( ConfigIni.bログ出力 )
1818     {
1819     try
1820     {
1821 kairera0467 298 Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( strEXEのあるフォルダ + "DTXManiaLog.txt", false, Encoding.GetEncoding( "shift-jis" ) ) ) );
1822 kairera0467 2 }
1823     catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
1824     {
1825     int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
1826     string[] mes_writeErr = {
1827     "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
1828     "Failed to write DTXManiaLog.txt. Please set it writable and try again."
1829     };
1830     MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
1831     Environment.Exit(1);
1832     }
1833     }
1834     Trace.WriteLine("");
1835     Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
1836     Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
1837     Trace.WriteLine( "" );
1838     Trace.TraceInformation( "----------------------" );
1839     Trace.TraceInformation( "■ アプリケーションの初期化" );
1840     Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
1841     Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
1842     Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
1843     //---------------------
1844     #endregion
1845 kairera0467 292 #region [ DTXVmodeクラス の初期化 ]
1846 kairera0467 2 //---------------------
1847 kairera0467 292 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
1848     //Trace.Indent();
1849     try
1850     {
1851     DTXVmode = new CDTXVmode();
1852     DTXVmode.Enabled = false;
1853     //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
1854     }
1855     finally
1856     {
1857     //Trace.Unindent();
1858     }
1859     //---------------------
1860     #endregion
1861     #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
1862     //---------------------
1863 kairera0467 2 bコンパクトモ = false;
1864     strコンパクトモドファイル = "";
1865     string[] commandLineArgs = Environment.GetCommandLineArgs();
1866     if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
1867     {
1868     bコンパクトモ = true;
1869 kairera0467 292 string arg = "";
1870    
1871     for ( int i = 1; i < commandLineArgs.Length; i++ )
1872     {
1873     if ( i != 1 )
1874     {
1875     arg += " " + "\"" + commandLineArgs[ i ] + "\"";
1876     }
1877     else
1878     {
1879     arg += commandLineArgs[ i ];
1880     }
1881     }
1882     DTXVmode.ParseArguments( arg );
1883    
1884     if ( DTXVmode.Enabled )
1885     {
1886     DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
1887     strコンパクトモドファイル = DTXVmode.filename;
1888 kairera0467 384 switch( DTXVmode.soundDeviceType )
1889     {
1890     case ESoundDeviceType.DirectSound:
1891     ConfigIni.nSoundDeviceType = 0;
1892     break;
1893     case ESoundDeviceType.ExclusiveWASAPI:
1894     ConfigIni.nSoundDeviceType = 2;
1895     break;
1896     case ESoundDeviceType.ASIO:
1897     ConfigIni.nSoundDeviceType = 1;
1898     ConfigIni.nASIODevice = DTXVmode.nASIOdevice;
1899     break;
1900     }
1901 kairera0467 397
1902     CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1903     CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1904     CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1905     CDTXMania.ConfigIni.bGuitar有効 = true;
1906 kairera0467 292 }
1907     else // 通常のコンパクトモード
1908     {
1909     strコンパクトモドファイル = commandLineArgs[ 1 ];
1910     }
1911    
1912     if ( !File.Exists( strコンパクトモドファイル ) ) // #32985 2014.1.23 yyagi
1913     {
1914     Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモドファイル );
1915     #if DEBUG
1916     Environment.Exit( -1 );
1917     #else
1918     throw new FileNotFoundException( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモドファイル );
1919     #endif
1920     }
1921     if ( DTXVmode.Enabled )
1922     {
1923     Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモドファイル );
1924     }
1925     else
1926     {
1927     Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモドファイル );
1928     }
1929 kairera0467 2 }
1930     //---------------------
1931     #endregion
1932    
1933     #region [ ウィンドウ初期化 ]
1934     //---------------------
1935     base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1936 kairera0467 292 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1937 kairera0467 2
1938 kairera0467 292 base.Window.Text = this.strWindowTitle; // 事前にDTXVmodeの実体を作っておくこと
1939    
1940    
1941     base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1942     base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1943    
1944 kairera0467 2 base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #34510 yyagi 2010.10.31 to change window size got from Config.ini
1945 kairera0467 21 #if !WindowedFullscreen
1946 kairera0467 2 if (!ConfigIni.bウィンドウモ) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
1947 kairera0467 162 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
1948 kairera0467 21 #endif
1949 kairera0467 162 currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );
1950 kairera0467 21 #if !WindowedFullscreen
1951 kairera0467 162 }
1952 kairera0467 21 #endif
1953     base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
1954 kairera0467 2 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
1955 kairera0467 162 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
1956 kairera0467 2 base.Window.ShowIcon = true;
1957     base.Window.Icon = Properties.Resources.dtx;
1958     base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
1959     base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
1960     base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
1961     base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
1962     base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
1963     base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
1964     //---------------------
1965     #endregion
1966     #region [ Direct3D9Exを使うかどうか判定 ]
1967     #endregion
1968     #region [ Direct3D9 デバイスの生成 ]
1969     //---------------------
1970     DeviceSettings settings = new DeviceSettings();
1971 kairera0467 21 #if WindowedFullscreen
1972 kairera0467 49 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
1973 kairera0467 21 #else
1974 kairera0467 2 settings.Windowed = ConfigIni.bウィンドウモ;
1975 kairera0467 21 #endif
1976 kairera0467 2 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
1977     settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
1978     // settings.BackBufferCount = 3;
1979     settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1980 kairera0467 49 // settings.BackBufferFormat = Format.A8R8G8B8;
1981     // settings.MultisampleType = MultisampleType.FourSamples;
1982     // settings.MultisampleQuality = 4;
1983     // settings.MultisampleType = MultisampleType.None;
1984     // settings.MultisampleQuality = 0;
1985    
1986 kairera0467 2 try
1987     {
1988     base.GraphicsDeviceManager.ChangeDevice(settings);
1989     }
1990     catch (DeviceCreationException e)
1991     {
1992     Trace.TraceError(e.ToString());
1993     MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1994     Environment.Exit(-1);
1995     }
1996 kairera0467 49
1997 kairera0467 2 base.IsFixedTimeStep = false;
1998     // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
1999     base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
2000     base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォカス時スリms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
2001 kairera0467 49 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
2002 kairera0467 21 #if WindowedFullscreen
2003 kairera0467 580 this.t全画面_ウィンドウモド切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
2004 kairera0467 21 #endif
2005 kairera0467 49 actFlushGPU = new CActFlushGPU();
2006 kairera0467 2 //---------------------
2007     #endregion
2008    
2009     DTX = null;
2010    
2011     #region [ Skin の初期化 ]
2012     //---------------------
2013     Trace.TraceInformation( "スキンの初期化を行います。" );
2014     Trace.Indent();
2015     try
2016     {
2017     Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
2018     CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
2019     Trace.TraceInformation( "スキンの初期化を完了しました。" );
2020     }
2021     catch
2022     {
2023     Trace.TraceInformation( "スキンの初期化に失敗しました。" );
2024     throw;
2025     }
2026     finally
2027     {
2028     Trace.Unindent();
2029     }
2030     //---------------------
2031     #endregion
2032     #region [ Timer の初期化 ]
2033     //---------------------
2034     Trace.TraceInformation( "タイマの初期化を行います。" );
2035     Trace.Indent();
2036     try
2037     {
2038     Timer = new CTimer( CTimer.E種別.MultiMedia );
2039     Trace.TraceInformation( "タイマの初期化を完了しました。" );
2040     }
2041     finally
2042     {
2043     Trace.Unindent();
2044     }
2045     //---------------------
2046     #endregion
2047     #region [ FPS カウンタの初期化 ]
2048     //---------------------
2049     Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
2050     Trace.Indent();
2051     try
2052     {
2053     FPS = new CFPS();
2054     Trace.TraceInformation( "FPSカウンタを生成しました。" );
2055     }
2056     finally
2057     {
2058     Trace.Unindent();
2059     }
2060     //---------------------
2061     #endregion
2062     #region [ act文字コンソールの初期化 ]
2063     //---------------------
2064     Trace.TraceInformation( "文字コンソールの初期化を行います。" );
2065     Trace.Indent();
2066     try
2067     {
2068     act文字コンソ = new C文字コンソ();
2069     Trace.TraceInformation( "文字コンソールを生成しました。" );
2070     act文字コンソ.On活性化();
2071     Trace.TraceInformation( "文字コンソールを活性化しました。" );
2072     Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
2073     }
2074     catch( Exception exception )
2075     {
2076     Trace.TraceError( exception.Message );
2077     Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
2078     }
2079     finally
2080     {
2081     Trace.Unindent();
2082     }
2083     //---------------------
2084     #endregion
2085     #region [ Input管理 の初期化 ]
2086     //---------------------
2087     Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
2088     Trace.Indent();
2089     try
2090     {
2091     Input管理 = new CInput管理( base.Window.Handle );
2092     foreach( IInputDevice device in Input管理.list入力デバイス )
2093     {
2094     if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
2095     {
2096     int key = 0;
2097     while( ConfigIni.dicJoystick.ContainsKey( key ) )
2098     {
2099     key++;
2100     }
2101     ConfigIni.dicJoystick.Add( key, device.GUID );
2102     }
2103     }
2104     foreach( IInputDevice device2 in Input管理.list入力デバイス )
2105     {
2106     if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
2107     {
2108     foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
2109     {
2110     if( device2.GUID.Equals( pair.Value ) )
2111     {
2112     ( (CInputJoystick) device2 ).SetID( pair.Key );
2113     break;
2114     }
2115     }
2116     continue;
2117     }
2118     }
2119     Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
2120     }
2121     catch( Exception exception2 )
2122     {
2123     Trace.TraceError( exception2.Message );
2124     Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
2125     throw;
2126     }
2127     finally
2128     {
2129     Trace.Unindent();
2130     }
2131     //---------------------
2132     #endregion
2133     #region [ Pad の初期化 ]
2134     //---------------------
2135     Trace.TraceInformation( "パッドの初期化を行います。" );
2136     Trace.Indent();
2137     try
2138     {
2139     Pad = new CPad( ConfigIni, Input管理 );
2140     Trace.TraceInformation( "パッドの初期化を完了しました。" );
2141     }
2142     catch( Exception exception3 )
2143     {
2144     Trace.TraceError( exception3.Message );
2145     Trace.TraceError( "パッドの初期化に失敗しました。" );
2146     }
2147     finally
2148     {
2149     Trace.Unindent();
2150     }
2151     //---------------------
2152     #endregion
2153     #region [ Sound管理 の初期化 ]
2154     //---------------------
2155     Trace.TraceInformation("サウンドデバイスの初期化を行います。");
2156     Trace.Indent();
2157     try
2158     {
2159     {
2160     ESoundDeviceType soundDeviceType;
2161     switch (CDTXMania.ConfigIni.nSoundDeviceType)
2162     {
2163     case 0:
2164     soundDeviceType = ESoundDeviceType.DirectSound;
2165     break;
2166     case 1:
2167     soundDeviceType = ESoundDeviceType.ASIO;
2168     break;
2169     case 2:
2170     soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
2171     break;
2172     default:
2173     soundDeviceType = ESoundDeviceType.Unknown;
2174     break;
2175     }
2176 kairera0467 49 Sound管理 = new CSound管理( base.Window.Handle,
2177 kairera0467 2 soundDeviceType,
2178     CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
2179 kairera0467 120 //CDTXMania.ConfigIni.nASIOBufferSizeMs,
2180     0,
2181 kairera0467 570 CDTXMania.ConfigIni.nASIODevice,
2182     CDTXMania.ConfigIni.bUseOSTimer
2183 kairera0467 2 );
2184 kairera0467 292 ShowWindowTitleWithSoundType();
2185 kairera0467 25 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
2186 kairera0467 397 Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;
2187     //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;
2188 kairera0467 2 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
2189     }
2190     }
2191     catch (Exception e)
2192 kairera0467 49 {
2193     Trace.TraceError(e.Message);
2194     throw;
2195     }
2196     finally
2197     {
2198     Trace.Unindent();
2199     }
2200 kairera0467 2 //---------------------
2201     #endregion
2202     #region [ Songs管理 の初期化 ]
2203     //---------------------
2204     Trace.TraceInformation( "曲リストの初期化を行います。" );
2205     Trace.Indent();
2206     try
2207     {
2208     Songs管理 = new CSongs管理();
2209     // Songs管理_裏読 = new CSongs管理();
2210     EnumSongs = new CEnumSongs();
2211     actEnumSongs = new CActEnumSongs();
2212     Trace.TraceInformation( "曲リストの初期化を完了しました。" );
2213     }
2214     catch( Exception e )
2215     {
2216     Trace.TraceError( e.Message );
2217     Trace.TraceError( "曲リストの初期化に失敗しました。" );
2218     }
2219     finally
2220     {
2221     Trace.Unindent();
2222     }
2223     //---------------------
2224     #endregion
2225     #region [ CAvi の初期化 ]
2226     //---------------------
2227     CAvi.t初期化();
2228     //---------------------
2229     #endregion
2230     #region [ Random の初期化 ]
2231     //---------------------
2232     Random = new Random( (int) Timer.nシステム時刻 );
2233     //---------------------
2234     #endregion
2235     #region [ ステージの初期化 ]
2236     //---------------------
2237     r現在のステ = null;
2238     r直前のステ = null;
2239     stage起動 = new CStage起動();
2240     stageタイトル = new CStageタイトル();
2241     stageオプション = new CStageオプション();
2242     stageコンフィグ = new CStageコンフィグ();
2243     stage選曲 = new CStage選曲();
2244     stage曲読み込み = new CStage曲読み込み();
2245     stage演奏ドラム画面 = new CStage演奏ドラム画面();
2246     stage演奏ギタ画面 = new CStage演奏ギタ画面();
2247     stage結果 = new CStage結果();
2248     stageChangeSkin = new CStageChangeSkin();
2249     stage終了 = new CStage終了();
2250     this.listトップレベルActivities = new List<CActivity>();
2251     this.listトップレベルActivities.Add( actEnumSongs );
2252     this.listトップレベルActivities.Add( act文字コンソ );
2253     this.listトップレベルActivities.Add( stage起動 );
2254     this.listトップレベルActivities.Add( stageタイトル );
2255     this.listトップレベルActivities.Add( stageオプション );
2256     this.listトップレベルActivities.Add( stageコンフィグ );
2257     this.listトップレベルActivities.Add( stage選曲 );
2258     this.listトップレベルActivities.Add( stage曲読み込み );
2259     this.listトップレベルActivities.Add( stage演奏ドラム画面 );
2260     this.listトップレベルActivities.Add( stage演奏ギタ画面 );
2261     this.listトップレベルActivities.Add( stage結果 );
2262     this.listトップレベルActivities.Add( stageChangeSkin );
2263     this.listトップレベルActivities.Add( stage終了 );
2264     this.listトップレベルActivities.Add( actFlushGPU);
2265     //---------------------
2266     #endregion
2267     #region [ プラグインの検索と生成 ]
2268     //---------------------
2269     PluginHost = new CPluginHost();
2270    
2271     Trace.TraceInformation( "プラグインの検索と生成を行います。" );
2272     Trace.Indent();
2273     try
2274     {
2275     this.tプラグイン検索と生成();
2276     Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
2277     }
2278     finally
2279     {
2280     Trace.Unindent();
2281     }
2282     //---------------------
2283     #endregion
2284     #region [ プラグインの初期化 ]
2285     //---------------------
2286     if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
2287     {
2288     Trace.TraceInformation( "プラグインの初期化を行います。" );
2289     Trace.Indent();
2290     try
2291     {
2292     foreach( STPlugin st in this.listプラグイン )
2293     {
2294     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2295     st.plugin.On初期化( this.PluginHost );
2296     st.plugin.OnManagedリソスの作成();
2297     st.plugin.OnUnmanagedリソスの作成();
2298     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2299     }
2300     Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
2301     }
2302     catch
2303     {
2304     Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
2305     throw;
2306     }
2307     finally
2308     {
2309     Trace.Unindent();
2310     }
2311     }
2312    
2313     //---------------------
2314     #endregion
2315    
2316    
2317     Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );