Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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