Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 458 - (hide annotations) (download)
Mon Aug 10 12:47:54 2015 UTC (8 years, 7 months ago) by kairera0467
File size: 104785 byte(s)
#34612 LivePointゲージをギター1Pの向きの違いに対応。
#xxxxx ゲージ0時の黒マスク専用画像を廃止。汎用の黒テクスチャで描画させる仕様にした。
#xxxxx 曲決定画面のギターベース難易度表示に不具合があったので修正。
#xxxxx アセンブリバージョンの更新。
#xxxxx DirectShowの汎用ムービー機能を廃止。
#xxxxx StageEffect画像の構造を一新。
#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 458 public static readonly string VERSION = "Ver3.35(150811)";
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 397 if ( Sound管理.GetCurrentSoundDeviceType() != "DirectSound" )
1565     {
1566     Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
1567     }
1568    
1569    
1570 kairera0467 2 #region [ 全画面・ウインドウ切り替え ]
1571     if ( this.b次のタイミングで全画面・ウィンドウ切り替えを行う )
1572     {
1573     ConfigIni.b全画面モ = !ConfigIni.b全画面モ;
1574     app.t全画面・ウィンドウモド切り替え();
1575     this.b次のタイミングで全画面・ウィンドウ切り替えを行う = false;
1576     }
1577     #endregion
1578     #region [ 垂直基線同期切り替え ]
1579     if ( this.b次のタイミングで垂直帰線同期切り替えを行う )
1580     {
1581     bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
1582     currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
1583     DeviceSettings currentSettings = app.GraphicsDeviceManager.CurrentSettings;
1584     currentSettings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1585     app.GraphicsDeviceManager.ChangeDevice( currentSettings );
1586     this.b次のタイミングで垂直帰線同期切り替えを行う = false;
1587     base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
1588     if (bIsMaximized)
1589     {
1590     this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
1591     }
1592     }
1593     #endregion
1594     }
1595    
1596    
1597     // その他
1598    
1599     #region [ 汎用ヘルパー ]
1600     //-----------------
1601     public static CTexture tテクスチャの生成( string fileName )
1602     {
1603     return tテクスチャの生成( fileName, false );
1604     }
1605     public static CTexture tテクスチャの生成( string fileName, bool b黒を透過する )
1606     {
1607     if ( app == null )
1608     {
1609     return null;
1610     }
1611     try
1612     {
1613     return new CTexture( app.Device, fileName, TextureFormat, b黒を透過する );
1614     }
1615     catch ( CTextureCreateFailedException )
1616     {
1617     Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1618     return null;
1619     }
1620     catch ( FileNotFoundException )
1621     {
1622     Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1623     return null;
1624     }
1625     }
1626     public static void tテクスチャの解放( ref CTexture tx )
1627     {
1628 kairera0467 90 if( tx != null )
1629     CDTXMania.t安全にDisposeする( ref tx );
1630 kairera0467 2 }
1631 kairera0467 430 public static void tテクスチャの解放( ref CTextureAf tx )
1632     {
1633     CDTXMania.t安全にDisposeする( ref tx );
1634     }
1635 kairera0467 2 public static CTexture tテクスチャの生成( byte[] txData )
1636     {
1637     return tテクスチャの生成( txData, false );
1638     }
1639     public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
1640     {
1641     if ( app == null )
1642     {
1643     return null;
1644     }
1645     try
1646     {
1647     return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
1648     }
1649     catch ( CTextureCreateFailedException )
1650     {
1651     Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1652     return null;
1653     }
1654     }
1655    
1656     public static CTexture tテクスチャの生成( Bitmap bitmap )
1657     {
1658     return tテクスチャの生成( bitmap, false );
1659     }
1660     public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
1661     {
1662     if ( app == null )
1663     {
1664     return null;
1665     }
1666     try
1667     {
1668     return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
1669     }
1670     catch ( CTextureCreateFailedException )
1671     {
1672     Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1673     return null;
1674     }
1675     }
1676    
1677     public static CTexture tテクスチャを生成する(int width, int height)
1678     {
1679     try
1680     {
1681     return new CTexture(CDTXMania.App.D3D9Device, width, height, CDTXMania.TextureFormat);
1682     }
1683     catch
1684     {
1685     Trace.TraceError("空のテクスチャ({0}x{1})の生成に失敗しました。", width, height);
1686     return null;
1687     }
1688     }
1689 kairera0467 430 public static CTextureAf tテクスチャの生成Af( string fileName )
1690     {
1691     return tテクスチャの生成Af( fileName, false );
1692     }
1693     public static CTextureAf tテクスチャの生成Af( string fileName, bool b黒を透過する )
1694     {
1695     if ( app == null )
1696     {
1697     return null;
1698     }
1699     try
1700     {
1701     return new CTextureAf( app.Device, fileName, TextureFormat, b黒を透過する );
1702     }
1703     catch ( CTextureCreateFailedException )
1704     {
1705     Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1706     return null;
1707     }
1708     catch ( FileNotFoundException )
1709     {
1710     Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1711     return null;
1712     }
1713     }
1714 kairera0467 2
1715     public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する(string fileName, IntPtr hWnd, bool bディオレンダラなし)
1716     {
1717     CDirectShow ds = null;
1718 kairera0467 420 if( File.Exists( fileName ) )
1719 kairera0467 2 {
1720 kairera0467 420 try
1721     {
1722     ds = new CDirectShow(fileName, hWnd, bディオレンダラなし);
1723     }
1724     catch (FileNotFoundException)
1725     {
1726     Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1727     ds = null; // Dispose はコンストラクタ内で実施済み
1728     }
1729     catch
1730     {
1731     Trace.TraceError("DirectShow の生成に失敗しました。[{0}]", fileName);
1732     ds = null; // Dispose はコンストラクタ内で実施済み
1733     }
1734 kairera0467 2 }
1735 kairera0467 420 else
1736 kairera0467 2 {
1737     Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1738 kairera0467 420 return null;
1739 kairera0467 2 }
1740    
1741     return ds;
1742     }
1743    
1744     /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
1745     public static void t安全にDisposeする<T>( ref T obj )
1746     {
1747     if ( obj == null )
1748     return;
1749    
1750     var d = obj as IDisposable;
1751    
1752     if ( d != null )
1753     d.Dispose();
1754    
1755     obj = default( T );
1756     }
1757     //-----------------
1758     #endregion
1759     #region [ private ]
1760     //-----------------
1761     private bool bマウスカソル表示中 = true;
1762     public bool bウィンドウがアクティブである = true;
1763     private bool b終了処理完了済み;
1764     private static CDTX dtx;
1765     private List<CActivity> listトップレベルActivities;
1766 kairera0467 24 public int n進行描画の戻り値;
1767 kairera0467 2 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
1768 kairera0467 292 private string strWindowTitle
1769     {
1770     get
1771     {
1772     if ( DTXVmode.Enabled )
1773     {
1774     return "DTXViewer release " + VERSION;
1775     }
1776     else
1777     {
1778     return "DTXMania .NET style release " + VERSION;
1779     }
1780     }
1781     }
1782 kairera0467 380 private CSound previewSound;
1783 kairera0467 2
1784     private void t起動処理()
1785     {
1786     #region [ strEXEのあるフォルダを決定する ]
1787     //-----------------
1788     // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
1789     #if DEBUG
1790     strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
1791     #else
1792     strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
1793     #endif
1794     // END #23629 2010.11.13 from
1795     //-----------------
1796     #endregion
1797    
1798     #region [ Config.ini の読込み ]
1799     //---------------------
1800     ConfigIni = new CConfigIni();
1801     string path = strEXEのあるフォルダ + "Config.ini";
1802     if( File.Exists( path ) )
1803     {
1804     try
1805     {
1806     ConfigIni.tファイルから読み込み( path );
1807     }
1808     catch
1809     {
1810     //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
1811     }
1812     }
1813     this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
1814     // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
1815    
1816     //---------------------
1817     #endregion
1818     #region [ ログ出力開始 ]
1819     //---------------------
1820     Trace.AutoFlush = true;
1821     if( ConfigIni.bログ出力 )
1822     {
1823     try
1824     {
1825 kairera0467 298 Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( strEXEのあるフォルダ + "DTXManiaLog.txt", false, Encoding.GetEncoding( "shift-jis" ) ) ) );
1826 kairera0467 2 }
1827     catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
1828     {
1829     int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
1830     string[] mes_writeErr = {
1831     "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
1832     "Failed to write DTXManiaLog.txt. Please set it writable and try again."
1833     };
1834     MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
1835     Environment.Exit(1);
1836     }
1837     }
1838     Trace.WriteLine("");
1839     Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
1840     Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
1841     Trace.WriteLine( "" );
1842     Trace.TraceInformation( "----------------------" );
1843     Trace.TraceInformation( "■ アプリケーションの初期化" );
1844     Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
1845     Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
1846     Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
1847     //---------------------
1848     #endregion
1849 kairera0467 292 #region [ DTXVmodeクラス の初期化 ]
1850 kairera0467 2 //---------------------
1851 kairera0467 292 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
1852     //Trace.Indent();
1853     try
1854     {
1855     DTXVmode = new CDTXVmode();
1856     DTXVmode.Enabled = false;
1857     //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
1858     }
1859     finally
1860     {
1861     //Trace.Unindent();
1862     }
1863     //---------------------
1864     #endregion
1865     #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
1866     //---------------------
1867 kairera0467 2 bコンパクトモ = false;
1868     strコンパクトモドファイル = "";
1869     string[] commandLineArgs = Environment.GetCommandLineArgs();
1870     if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
1871     {
1872     bコンパクトモ = true;
1873 kairera0467 292 string arg = "";
1874    
1875     for ( int i = 1; i < commandLineArgs.Length; i++ )
1876     {
1877     if ( i != 1 )
1878     {
1879     arg += " " + "\"" + commandLineArgs[ i ] + "\"";
1880     }
1881     else
1882     {
1883     arg += commandLineArgs[ i ];
1884     }
1885     }
1886     DTXVmode.ParseArguments( arg );
1887    
1888     if ( DTXVmode.Enabled )
1889     {
1890     DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
1891     strコンパクトモドファイル = DTXVmode.filename;
1892 kairera0467 384 switch( DTXVmode.soundDeviceType )
1893     {
1894     case ESoundDeviceType.DirectSound:
1895     ConfigIni.nSoundDeviceType = 0;
1896     break;
1897     case ESoundDeviceType.ExclusiveWASAPI:
1898     ConfigIni.nSoundDeviceType = 2;
1899     break;
1900     case ESoundDeviceType.ASIO:
1901     ConfigIni.nSoundDeviceType = 1;
1902     ConfigIni.nASIODevice = DTXVmode.nASIOdevice;
1903     break;
1904     }
1905 kairera0467 397
1906     CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1907     CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1908     CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1909     CDTXMania.ConfigIni.bGuitar有効 = true;
1910 kairera0467 292 }
1911     else // 通常のコンパクトモード
1912     {
1913     strコンパクトモドファイル = commandLineArgs[ 1 ];
1914     }
1915    
1916     if ( !File.Exists( strコンパクトモドファイル ) ) // #32985 2014.1.23 yyagi
1917     {
1918     Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモドファイル );
1919     #if DEBUG
1920     Environment.Exit( -1 );
1921     #else
1922     throw new FileNotFoundException( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモドファイル );
1923     #endif
1924     }
1925     if ( DTXVmode.Enabled )
1926     {
1927     Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモドファイル );
1928     }
1929     else
1930     {
1931     Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモドファイル );
1932     }
1933 kairera0467 2 }
1934     //---------------------
1935     #endregion
1936    
1937     #region [ ウィンドウ初期化 ]
1938     //---------------------
1939     base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1940 kairera0467 292 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1941 kairera0467 2
1942 kairera0467 292 base.Window.Text = this.strWindowTitle; // 事前にDTXVmodeの実体を作っておくこと
1943    
1944    
1945     base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1946     base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1947    
1948 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
1949 kairera0467 21 #if !WindowedFullscreen
1950 kairera0467 2 if (!ConfigIni.bウィンドウモ) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
1951 kairera0467 162 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
1952 kairera0467 21 #endif
1953 kairera0467 162 currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );
1954 kairera0467 21 #if !WindowedFullscreen
1955 kairera0467 162 }
1956 kairera0467 21 #endif
1957     base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
1958 kairera0467 2 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
1959 kairera0467 162 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
1960 kairera0467 2 base.Window.ShowIcon = true;
1961     base.Window.Icon = Properties.Resources.dtx;
1962     base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
1963     base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
1964     base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
1965     base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
1966     base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
1967     base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
1968     //---------------------
1969     #endregion
1970     #region [ Direct3D9Exを使うかどうか判定 ]
1971     #endregion
1972     #region [ Direct3D9 デバイスの生成 ]
1973     //---------------------
1974     DeviceSettings settings = new DeviceSettings();
1975 kairera0467 21 #if WindowedFullscreen
1976 kairera0467 49 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
1977 kairera0467 21 #else
1978 kairera0467 2 settings.Windowed = ConfigIni.bウィンドウモ;
1979 kairera0467 21 #endif
1980 kairera0467 2 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
1981     settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
1982     // settings.BackBufferCount = 3;
1983     settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1984 kairera0467 49 // settings.BackBufferFormat = Format.A8R8G8B8;
1985     // settings.MultisampleType = MultisampleType.FourSamples;
1986     // settings.MultisampleQuality = 4;
1987     // settings.MultisampleType = MultisampleType.None;
1988     // settings.MultisampleQuality = 0;
1989    
1990 kairera0467 2 try
1991     {
1992     base.GraphicsDeviceManager.ChangeDevice(settings);
1993     }
1994     catch (DeviceCreationException e)
1995     {
1996     Trace.TraceError(e.ToString());
1997     MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1998     Environment.Exit(-1);
1999     }
2000 kairera0467 49
2001 kairera0467 2 base.IsFixedTimeStep = false;
2002     // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
2003     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.
2004     base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォカス時スリms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
2005 kairera0467 49 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
2006 kairera0467 21 #if WindowedFullscreen
2007 kairera0467 49 this.t全画面・ウィンドウモド切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
2008 kairera0467 21 #endif
2009 kairera0467 49 actFlushGPU = new CActFlushGPU();
2010 kairera0467 2 //---------------------
2011     #endregion
2012    
2013     DTX = null;
2014    
2015     #region [ Skin の初期化 ]
2016     //---------------------
2017     Trace.TraceInformation( "スキンの初期化を行います。" );
2018     Trace.Indent();
2019     try
2020     {
2021     Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
2022     CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
2023     Trace.TraceInformation( "スキンの初期化を完了しました。" );
2024     }
2025     catch
2026     {
2027     Trace.TraceInformation( "スキンの初期化に失敗しました。" );
2028     throw;
2029     }
2030     finally
2031     {
2032     Trace.Unindent();
2033     }
2034     //---------------------
2035     #endregion
2036     #region [ Timer の初期化 ]
2037     //---------------------
2038     Trace.TraceInformation( "タイマの初期化を行います。" );
2039     Trace.Indent();
2040     try
2041     {
2042     Timer = new CTimer( CTimer.E種別.MultiMedia );
2043     Trace.TraceInformation( "タイマの初期化を完了しました。" );
2044     }
2045     finally
2046     {
2047     Trace.Unindent();
2048     }
2049     //---------------------
2050     #endregion
2051     #region [ FPS カウンタの初期化 ]
2052     //---------------------
2053     Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
2054     Trace.Indent();
2055     try
2056     {
2057     FPS = new CFPS();
2058     Trace.TraceInformation( "FPSカウンタを生成しました。" );
2059     }
2060     finally
2061     {
2062     Trace.Unindent();
2063     }
2064     //---------------------
2065     #endregion
2066     #region [ act文字コンソールの初期化 ]
2067     //---------------------
2068     Trace.TraceInformation( "文字コンソールの初期化を行います。" );
2069     Trace.Indent();
2070     try
2071     {
2072     act文字コンソ = new C文字コンソ();
2073     Trace.TraceInformation( "文字コンソールを生成しました。" );
2074     act文字コンソ.On活性化();
2075     Trace.TraceInformation( "文字コンソールを活性化しました。" );
2076     Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
2077     }
2078     catch( Exception exception )
2079     {
2080     Trace.TraceError( exception.Message );
2081     Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
2082     }
2083     finally
2084     {
2085     Trace.Unindent();
2086     }
2087     //---------------------
2088     #endregion
2089     #region [ Input管理 の初期化 ]
2090     //---------------------
2091     Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
2092     Trace.Indent();
2093     try
2094     {
2095     Input管理 = new CInput管理( base.Window.Handle );
2096     foreach( IInputDevice device in Input管理.list入力デバイス )
2097     {
2098     if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
2099     {
2100     int key = 0;
2101     while( ConfigIni.dicJoystick.ContainsKey( key ) )
2102     {
2103     key++;
2104     }
2105     ConfigIni.dicJoystick.Add( key, device.GUID );
2106     }
2107     }
2108     foreach( IInputDevice device2 in Input管理.list入力デバイス )
2109     {
2110     if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
2111     {
2112     foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
2113     {
2114     if( device2.GUID.Equals( pair.Value ) )
2115     {
2116     ( (CInputJoystick) device2 ).SetID( pair.Key );
2117     break;
2118     }
2119     }
2120     continue;
2121     }
2122     }
2123     Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
2124     }
2125     catch( Exception exception2 )
2126     {
2127     Trace.TraceError( exception2.Message );
2128     Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
2129     throw;
2130     }
2131     finally
2132     {
2133     Trace.Unindent();
2134     }
2135     //---------------------
2136     #endregion
2137     #region [ Pad の初期化 ]
2138     //---------------------
2139     Trace.TraceInformation( "パッドの初期化を行います。" );
2140     Trace.Indent();
2141     try
2142     {
2143     Pad = new CPad( ConfigIni, Input管理 );
2144     Trace.TraceInformation( "パッドの初期化を完了しました。" );
2145     }
2146     catch( Exception exception3 )
2147     {
2148     Trace.TraceError( exception3.Message );
2149     Trace.TraceError( "パッドの初期化に失敗しました。" );
2150     }
2151     finally
2152     {
2153     Trace.Unindent();
2154     }
2155     //---------------------
2156     #endregion
2157     #region [ Sound管理 の初期化 ]
2158     //---------------------
2159     Trace.TraceInformation("サウンドデバイスの初期化を行います。");
2160     Trace.Indent();
2161     try
2162     {
2163     {
2164     ESoundDeviceType soundDeviceType;
2165     switch (CDTXMania.ConfigIni.nSoundDeviceType)
2166     {
2167     case 0:
2168     soundDeviceType = ESoundDeviceType.DirectSound;
2169     break;
2170     case 1:
2171     soundDeviceType = ESoundDeviceType.ASIO;
2172     break;
2173     case 2:
2174     soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
2175     break;
2176     default:
2177     soundDeviceType = ESoundDeviceType.Unknown;
2178     break;
2179     }
2180 kairera0467 49 Sound管理 = new CSound管理( base.Window.Handle,
2181 kairera0467 2 soundDeviceType,
2182     CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
2183 kairera0467 120 //CDTXMania.ConfigIni.nASIOBufferSizeMs,
2184     0,
2185 kairera0467 2 CDTXMania.ConfigIni.nASIODevice
2186     );
2187 kairera0467 292 ShowWindowTitleWithSoundType();
2188 kairera0467 25 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
2189 kairera0467 397 Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;
2190     //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;
2191 kairera0467 2 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
2192     }
2193     }
2194     catch (Exception e)
2195 kairera0467 49 {
2196     Trace.TraceError(e.Message);
2197     throw;
2198     }
2199     finally
2200     {
2201     Trace.Unindent();
2202     }
2203 kairera0467 2 //---------------------
2204     #endregion
2205     #region [ Songs管理 の初期化 ]
2206     //---------------------
2207     Trace.TraceInformation( "曲リストの初期化を行います。" );
2208     Trace.Indent();
2209     try
2210     {
2211     Songs管理 = new CSongs管理();
2212     // Songs管理_裏読 = new CSongs管理();
2213     EnumSongs = new CEnumSongs();
2214     actEnumSongs = new CActEnumSongs();
2215     Trace.TraceInformation( "曲リストの初期化を完了しました。" );
2216     }
2217     catch( Exception e )
2218     {
2219     Trace.TraceError( e.Message );
2220     Trace.TraceError( "曲リストの初期化に失敗しました。" );
2221     }
2222     finally
2223     {
2224     Trace.Unindent();
2225     }
2226     //---------------------
2227     #endregion
2228     #region [ CAvi の初期化 ]
2229     //---------------------
2230     CAvi.t初期化();
2231     //---------------------
2232     #endregion
2233     #region [ Random の初期化 ]
2234     //---------------------
2235     Random = new Random( (int) Timer.nシステム時刻 );
2236     //---------------------
2237     #endregion
2238     #region [ ステージの初期化 ]
2239     //---------------------
2240     r現在のステ = null;
2241     r直前のステ = null;
2242     stage起動 = new CStage起動();
2243     stageタイトル = new CStageタイトル();
2244     stageオプション = new CStageオプション();
2245     stageコンフィグ = new CStageコンフィグ();
2246     stage選曲 = new CStage選曲();
2247     stage曲読み込み = new CStage曲読み込み();
2248     stage演奏ドラム画面 = new CStage演奏ドラム画面();
2249     stage演奏ギタ画面 = new CStage演奏ギタ画面();
2250     stage結果 = new CStage結果();
2251     stageChangeSkin = new CStageChangeSkin();
2252     stage終了 = new CStage終了();
2253     this.listトップレベルActivities = new List<CActivity>();
2254     this.listトップレベルActivities.Add( actEnumSongs );
2255     this.listトップレベルActivities.Add( act文字コンソ );
2256     this.listトップレベルActivities.Add( stage起動 );
2257     this.listトップレベルActivities.Add( stageタイトル );
2258     this.listトップレベルActivities.Add( stageオプション );
2259     this.listトップレベルActivities.Add( stageコンフィグ );
2260     this.listトップレベルActivities.Add( stage選曲 );
2261     this.listトップレベルActivities.Add( stage曲読み込み );
2262     this.listトップレベルActivities.Add( stage演奏ドラム画面 );
2263     this.listトップレベルActivities.Add( stage演奏ギタ画面 );
2264     this.listトップレベルActivities.Add( stage結果 );
2265     this.listトップレベルActivities.Add( stageChangeSkin );
2266     this.listトップレベルActivities.Add( stage終了 );
2267     this.listトップレベルActivities.Add( actFlushGPU);
2268     //---------------------
2269     #endregion
2270     #region [ プラグインの検索と生成 ]
2271     //---------------------
2272     PluginHost = new CPluginHost();
2273    
2274     Trace.TraceInformation( "プラグインの検索と生成を行います。" );
2275     Trace.Indent();
2276     try
2277     {
2278     this.tプラグイン検索と生成();
2279     Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
2280     }
2281     finally
2282     {
2283     Trace.Unindent();
2284     }
2285     //---------------------
2286     #endregion
2287     #region [ プラグインの初期化 ]
2288     //---------------------
2289     if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
2290     {
2291     Trace.TraceInformation( "プラグインの初期化を行います。" );
2292     Trace.Indent();
2293     try
2294     {
2295     foreach( STPlugin st in this.listプラグイン )
2296     {
2297     Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2298     st.plugin.On初期化( this.PluginHost );
2299     st.plugin.OnManagedリソスの作成();
2300     st.plugin.OnUnmanagedリソスの作成();
2301     Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2302     }
2303     Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
2304     }
2305     catch
2306     {
2307     Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
2308     throw;
2309     }
2310     finally
2311     {
2312     Trace.Unindent();
2313     }
2314     }
2315    
2316     //---------------------
2317     #endregion
2318    
2319    
2320     Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );
2321    
2322     #region [ 最初のステージの起動 ]
2323     //---------------------
2324     Trace.TraceInformation("----------------------");
2325     Trace.TraceInformation("■ 起動");
2326