Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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