Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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