Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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