2 using System.Collections.Generic;
\r
3 using System.Globalization;
\r
5 using System.Windows.Forms;
\r
6 using System.Drawing;
\r
7 using System.Diagnostics;
\r
8 using System.Runtime.InteropServices;
\r
10 using System.Threading;
\r
11 using System.Runtime.Serialization.Formatters.Binary;
\r
13 using SlimDX.Direct3D9;
\r
15 using SampleFramework;
\r
19 internal class CDTXMania : Game
\r
22 #region [ properties ]
\r
23 public static readonly string VERSION = "098(131101)";
\r
24 public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
\r
25 public static readonly string D3DXDLL = "d3dx9_43.dll"; // June 2010
\r
26 //public static readonly string D3DXDLL = "d3dx9_42.dll"; // February 2010
\r
27 //public static readonly string D3DXDLL = "d3dx9_41.dll"; // March 2009
\r
29 public static CDTXMania app
\r
34 public static C文字コンソール act文字コンソール
\r
39 public static bool bコンパクトモード
\r
44 public static CConfigIni ConfigIni
\r
49 public static CDTX DTX
\r
57 if( ( dtx != null ) && ( app != null ) )
\r
60 app.listトップレベルActivities.Remove( dtx );
\r
63 if( ( dtx != null ) && ( app != null ) )
\r
65 app.listトップレベルActivities.Add( dtx );
\r
69 public static CFPS FPS
\r
74 public static CInput管理 Input管理
\r
80 public static int nPerfect範囲ms
\r
84 if( stage選曲.r確定された曲 != null )
\r
86 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
\r
87 if( ( ( c曲リストノード != null ) && ( c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX ) ) && ( c曲リストノード.nPerfect範囲ms >= 0 ) )
\r
89 return c曲リストノード.nPerfect範囲ms;
\r
92 return ConfigIni.nヒット範囲ms.Perfect;
\r
95 public static int nGreat範囲ms
\r
99 if( stage選曲.r確定された曲 != null )
\r
101 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
\r
102 if( ( ( c曲リストノード != null ) && ( c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX ) ) && ( c曲リストノード.nGreat範囲ms >= 0 ) )
\r
104 return c曲リストノード.nGreat範囲ms;
\r
107 return ConfigIni.nヒット範囲ms.Great;
\r
110 public static int nGood範囲ms
\r
114 if( stage選曲.r確定された曲 != null )
\r
116 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
\r
117 if( ( ( c曲リストノード != null ) && ( c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX ) ) && ( c曲リストノード.nGood範囲ms >= 0 ) )
\r
119 return c曲リストノード.nGood範囲ms;
\r
122 return ConfigIni.nヒット範囲ms.Good;
\r
125 public static int nPoor範囲ms
\r
129 if( stage選曲.r確定された曲 != null )
\r
131 C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
\r
132 if( ( ( c曲リストノード != null ) && ( c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX ) ) && ( c曲リストノード.nPoor範囲ms >= 0 ) )
\r
134 return c曲リストノード.nPoor範囲ms;
\r
137 return ConfigIni.nヒット範囲ms.Poor;
\r
141 public static CPad Pad
\r
146 public static Random Random
\r
151 public static CSkin Skin
\r
156 public static CSongs管理 Songs管理
\r
159 set; // 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
\r
161 public static CEnumSongs EnumSongs
\r
166 public static CActEnumSongs actEnumSongs
\r
171 public static CActFlushGPU actFlushGPU
\r
177 public static CSound管理 Sound管理
\r
182 public static CStage起動 stage起動
\r
187 public static CStageタイトル stageタイトル
\r
192 // public static CStageオプション stageオプション
\r
197 public static CStageコンフィグ stageコンフィグ
\r
202 public static CStage選曲 stage選曲
\r
207 public static CStage曲読み込み stage曲読み込み
\r
212 public static CStage演奏ギター画面 stage演奏ギター画面
\r
217 public static CStage演奏ドラム画面 stage演奏ドラム画面
\r
222 public static CStage結果 stage結果
\r
227 public static CStageChangeSkin stageChangeSkin
\r
232 public static CStage終了 stage終了
\r
237 public static CStage r現在のステージ = null;
\r
238 public static CStage r直前のステージ = null;
\r
239 public static string strEXEのあるフォルダ
\r
244 public static string strコンパクトモードファイル
\r
249 public static CTimer Timer
\r
254 public static Format TextureFormat = Format.A8R8G8B8;
\r
255 internal static IPluginActivity act現在入力を占有中のプラグイン = null;
\r
256 public bool bApplicationActive
\r
261 public bool b次のタイミングで垂直帰線同期切り替えを行う
\r
266 public bool b次のタイミングで全画面・ウィンドウ切り替えを行う
\r
271 public Device Device
\r
273 get { return base.GraphicsDeviceManager.Direct3D9.Device; }
\r
275 public CPluginHost PluginHost
\r
280 public List<STPlugin> listプラグイン = new List<STPlugin>();
\r
281 public struct STPlugin
\r
283 public IPluginActivity plugin;
\r
284 public string strプラグインフォルダ;
\r
285 public string strアセンブリ簡易名;
\r
286 public Version Version;
\r
288 private static Size currentClientSize // #23510 2010.10.27 add yyagi to keep current window size
\r
293 // public static CTimer ct;
\r
294 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
\r
296 get { return base.Window.Handle; }
\r
298 public static CDTXVmode DTXVmode // #28821 2014.1.23 yyagi
\r
309 CDTXMania.app = this;
\r
316 public void t全画面・ウィンドウモード切り替え()
\r
318 #if WindowedFullscreen
\r
319 if ( ConfigIni != null )
\r
321 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
\r
322 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
\r
325 #if !WindowedFullscreen
\r
326 settings.Windowed = ConfigIni.bウィンドウモード;
\r
328 if ( ConfigIni.bウィンドウモード == false ) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
\r
330 currentClientSize = this.Window.ClientSize;
\r
331 ConfigIni.nウインドウwidth = this.Window.ClientSize.Width;
\r
332 ConfigIni.nウインドウheight = this.Window.ClientSize.Height;
\r
333 // FDK.CTaskBar.ShowTaskBar( false );
\r
335 #if !WindowedFullscreen
\r
336 base.GraphicsDeviceManager.ChangeDevice( settings );
\r
338 if ( ConfigIni.bウィンドウモード == true ) // #23510 2010.10.27 yyagi: to resume window size from backuped value
\r
340 #if WindowedFullscreen
\r
341 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
\r
342 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
\r
343 // in spite of using fullscreen mode.
\r
344 app.Window.WindowState = FormWindowState.Normal;
\r
345 app.Window.FormBorderStyle = FormBorderStyle.Sizable;
\r
346 app.Window.WindowState = FormWindowState.Normal;
\r
348 base.Window.ClientSize =
\r
349 new Size( currentClientSize.Width, currentClientSize.Height );
\r
350 // FDK.CTaskBar.ShowTaskBar( true );
\r
352 #if WindowedFullscreen
\r
355 app.Window.WindowState = FormWindowState.Normal;
\r
356 app.Window.FormBorderStyle = FormBorderStyle.None;
\r
357 app.Window.WindowState = FormWindowState.Maximized;
\r
359 if ( ConfigIni.bウィンドウモード )
\r
361 if ( !this.bマウスカーソル表示中 )
\r
364 this.bマウスカーソル表示中 = true;
\r
367 else if ( this.bマウスカーソル表示中 )
\r
370 this.bマウスカーソル表示中 = false;
\r
376 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
\r
378 /// リザルト画像のキャプチャと保存。
\r
380 /// <param name="strFilename">保存するファイル名(フルパス)</param>
\r
381 public bool SaveResultScreen( string strFullPath )
\r
383 string strSavePath = Path.GetDirectoryName( strFullPath );
\r
384 if ( !Directory.Exists( strSavePath ) )
\r
388 Directory.CreateDirectory( strSavePath );
\r
396 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
\r
397 using ( Surface pSurface = CDTXMania.app.Device.GetRenderTarget( 0 ) )
\r
399 Surface.ToFile( pSurface, strFullPath, ImageFileFormat.Png );
\r
407 protected override void Initialize()
\r
411 swlist = new List<double>( 8192 );
\r
412 if( this.listトップレベルActivities != null )
\r
414 foreach( CActivity activity in this.listトップレベルActivities )
\r
415 activity.OnManagedリソースの作成();
\r
418 foreach( STPlugin st in this.listプラグイン )
\r
420 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
\r
421 st.plugin.OnManagedリソースの作成();
\r
422 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
424 #if GPUFlushAfterPresent
\r
425 FrameEnd += dtxmania_FrameEnd;
\r
428 #if GPUFlushAfterPresent
\r
429 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
\r
430 { // → Present()直後にGPUをFlushする
\r
431 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
\r
432 actFlushGPU.On進行描画(); // Flush GPU
\r
435 protected override void LoadContent()
\r
437 if ( ConfigIni.bウィンドウモード )
\r
439 if( !this.bマウスカーソル表示中 )
\r
442 this.bマウスカーソル表示中 = true;
\r
445 else if( this.bマウスカーソル表示中 )
\r
448 this.bマウスカーソル表示中 = false;
\r
450 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)));
\r
451 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
\r
452 this.Device.SetRenderState(RenderState.Lighting, false);
\r
453 this.Device.SetRenderState( RenderState.ZEnable, false );
\r
454 this.Device.SetRenderState( RenderState.AntialiasedLineEnable, false );
\r
455 this.Device.SetRenderState( RenderState.AlphaTestEnable, true );
\r
456 this.Device.SetRenderState( RenderState.AlphaRef, 10 );
\r
458 this.Device.SetRenderState( RenderState.MultisampleAntialias, true );
\r
459 this.Device.SetSamplerState( 0, SamplerState.MinFilter, TextureFilter.Linear );
\r
460 this.Device.SetSamplerState( 0, SamplerState.MagFilter, TextureFilter.Linear );
\r
462 this.Device.SetRenderState<Compare>( RenderState.AlphaFunc, Compare.Greater );
\r
463 this.Device.SetRenderState( RenderState.AlphaBlendEnable, true );
\r
464 this.Device.SetRenderState<Blend>( RenderState.SourceBlend, Blend.SourceAlpha );
\r
465 this.Device.SetRenderState<Blend>( RenderState.DestinationBlend, Blend.InverseSourceAlpha );
\r
466 this.Device.SetTextureStageState( 0, TextureStage.AlphaOperation, TextureOperation.Modulate );
\r
467 this.Device.SetTextureStageState( 0, TextureStage.AlphaArg1, 2 );
\r
468 this.Device.SetTextureStageState( 0, TextureStage.AlphaArg2, 1 );
\r
470 if( this.listトップレベルActivities != null )
\r
472 foreach( CActivity activity in this.listトップレベルActivities )
\r
473 activity.OnUnmanagedリソースの作成();
\r
476 foreach( STPlugin st in this.listプラグイン )
\r
478 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
\r
479 st.plugin.OnUnmanagedリソースの作成();
\r
480 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
483 protected override void UnloadContent()
\r
485 if( this.listトップレベルActivities != null )
\r
487 foreach( CActivity activity in this.listトップレベルActivities )
\r
488 activity.OnUnmanagedリソースの解放();
\r
491 foreach( STPlugin st in this.listプラグイン )
\r
493 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
\r
494 st.plugin.OnUnmanagedリソースの解放();
\r
495 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
498 protected override void OnExiting( EventArgs e )
\r
500 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
\r
502 base.OnExiting( e );
\r
504 protected override void Update( GameTime gameTime )
\r
507 protected override void Draw( GameTime gameTime )
\r
509 Sound管理.t再生中の処理をする();
\r
511 if( Timer != null )
\r
513 if (CSound管理.rc演奏用タイマ != null)
\r
514 CSound管理.rc演奏用タイマ.t更新();
\r
516 if( Input管理 != null )
\r
517 Input管理.tポーリング( this.bApplicationActive, CDTXMania.ConfigIni.bバッファ入力を行う );
\r
522 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
\r
523 // Pad.st検知したデバイス.Clear();
\r
525 if( this.Device == null )
\r
528 if ( this.bApplicationActive ) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
\r
529 CPowerManagement.tDisableMonitorSuspend();
\r
531 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
\r
533 if ( ConfigIni.nフレーム毎スリープms >= 0 ) // #xxxxx 2011.11.27 yyagi
\r
535 Thread.Sleep( ConfigIni.nフレーム毎スリープms );
\r
539 #region [ DTXCreatorからの指示 ]
\r
540 if ( this.Window.IsReceivedMessage ) // ウインドウメッセージで、
\r
542 string strMes = this.Window.strMessage;
\r
543 this.Window.IsReceivedMessage = false;
\r
545 if ( strMes != null )
\r
547 DTXVmode.ParseArguments( strMes );
\r
549 if ( DTXVmode.Enabled )
\r
552 strコンパクトモードファイル = DTXVmode.filename;
\r
553 if ( DTXVmode.Command == CDTXVmode.ECommand.Preview )
\r
555 // preview soundの再生
\r
556 string strPreviewFilename = DTXVmode.previewFilename;
\r
557 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
\r
560 if ( this.previewSound != null )
\r
562 this.previewSound.tサウンドを停止する();
\r
563 this.previewSound.Dispose();
\r
564 this.previewSound = null;
\r
566 this.previewSound = CDTXMania.Sound管理.tサウンドを生成する( strPreviewFilename );
\r
567 this.previewSound.n音量 = DTXVmode.previewVolume;
\r
568 this.previewSound.n位置 = DTXVmode.previewPan;
\r
569 this.previewSound.t再生を開始する();
\r
570 Trace.TraceInformation( "DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename );
\r
574 Trace.TraceError( "DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename );
\r
575 if ( this.previewSound != null )
\r
577 this.previewSound.Dispose();
\r
579 this.previewSound = null;
\r
587 this.Device.BeginScene();
\r
588 this.Device.Clear( ClearFlags.ZBuffer | ClearFlags.Target, Color.Black, 1f, 0 );
\r
590 if( r現在のステージ != null )
\r
592 this.n進行描画の戻り値 = ( r現在のステージ != null ) ? r現在のステージ.On進行描画() : 0;
\r
594 #region [ プラグインの進行描画 ]
\r
595 //---------------------
\r
596 foreach( STPlugin sp in this.listプラグイン )
\r
598 Directory.SetCurrentDirectory( sp.strプラグインフォルダ );
\r
600 if( CDTXMania.act現在入力を占有中のプラグイン == null || CDTXMania.act現在入力を占有中のプラグイン == sp.plugin )
\r
601 sp.plugin.On進行描画( CDTXMania.Pad, CDTXMania.Input管理.Keyboard );
\r
603 sp.plugin.On進行描画( null, null );
\r
605 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
607 //---------------------
\r
611 CScoreIni scoreIni = null;
\r
613 if ( Control.IsKeyLocked( Keys.CapsLock ) ) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
\r
614 { // → songs.db等の書き込み時だと音切れするっぽい
\r
615 actEnumSongs.On非活性化();
\r
616 EnumSongs.SongListEnumCompletelyDone();
\r
617 CDTXMania.stage選曲.bIsEnumeratingSongs = false;
\r
619 #region [ 曲検索スレッドの起動/終了 ] // ここに"Enumerating Songs..."表示を集約
\r
620 if ( !CDTXMania.bコンパクトモード )
\r
622 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
\r
624 switch ( r現在のステージ.eステージID )
\r
626 case CStage.Eステージ.タイトル:
\r
627 case CStage.Eステージ.コンフィグ:
\r
628 case CStage.Eステージ.選曲:
\r
629 case CStage.Eステージ.曲読み込み:
\r
630 if ( EnumSongs != null )
\r
632 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
\r
633 if ( r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
\r
634 r直前のステージ.eステージID == CStage.Eステージ.起動 &&
\r
635 this.n進行描画の戻り値 == (int) CStageタイトル.E戻り値.継続 &&
\r
636 !EnumSongs.IsSongListEnumStarted )
\r
638 actEnumSongs.On活性化();
\r
639 CDTXMania.stage選曲.bIsEnumeratingSongs = true;
\r
640 EnumSongs.Init( CDTXMania.Songs管理.listSongsDB, CDTXMania.Songs管理.nSongsDBから取得できたスコア数 ); // songs.db情報と、取得した曲数を、新インスタンスにも与える
\r
641 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
\r
642 if ( CDTXMania.Songs管理.nSongsDBから取得できたスコア数 == 0 ) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
\r
644 EnumSongs.ChangeEnumeratePriority( ThreadPriority.Normal );
\r
649 #region [ 曲検索の中断と再開 ]
\r
650 if ( r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone )
\r
652 switch ( this.n進行描画の戻り値 )
\r
655 //if ( CDTXMania.stage選曲.bIsEnumeratingSongs )
\r
656 if ( !CDTXMania.stage選曲.bIsPlayingPremovie )
\r
658 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
\r
659 EnumSongs.IsSlowdown = false;
\r
663 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
\r
664 EnumSongs.IsSlowdown = true;
\r
666 actEnumSongs.On活性化();
\r
670 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
\r
671 actEnumSongs.On非活性化();
\r
677 #region [ 曲探索中断待ち待機 ]
\r
678 if ( r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
\r
679 EnumSongs.thDTXFileEnumerate != null ) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
\r
681 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
\r
685 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
\r
686 // CStage選曲.On活性化() に回した方がいいかな?
\r
687 if ( EnumSongs.IsSongListEnumerated )
\r
689 actEnumSongs.On非活性化();
\r
690 CDTXMania.stage選曲.bIsEnumeratingSongs = false;
\r
692 bool bRemakeSongTitleBar = ( r現在のステージ.eステージID == CStage.Eステージ.選曲 ) ? true : false;
\r
693 CDTXMania.stage選曲.Refresh( EnumSongs.Songs管理, bRemakeSongTitleBar );
\r
694 EnumSongs.SongListEnumCompletelyDone();
\r
702 switch ( r現在のステージ.eステージID )
\r
704 case CStage.Eステージ.何もしない:
\r
707 case CStage.Eステージ.起動:
\r
709 //-----------------------------
\r
710 if( this.n進行描画の戻り値 != 0 )
\r
715 Trace.TraceInformation( "----------------------" );
\r
716 Trace.TraceInformation( "■ タイトル" );
\r
718 r直前のステージ = r現在のステージ;
\r
719 r現在のステージ = stageタイトル;
\r
724 Trace.TraceInformation( "----------------------" );
\r
725 Trace.TraceInformation( "■ 曲読み込み" );
\r
726 stage曲読み込み.On活性化();
\r
727 r直前のステージ = r現在のステージ;
\r
728 r現在のステージ = stage曲読み込み;
\r
731 foreach( STPlugin pg in this.listプラグイン )
\r
733 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
734 pg.plugin.Onステージ変更();
\r
735 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
738 this.tガベージコレクションを実行する();
\r
740 //-----------------------------
\r
744 case CStage.Eステージ.タイトル:
\r
746 //-----------------------------
\r
747 switch( this.n進行描画の戻り値 )
\r
749 case (int)CStageタイトル.E戻り値.GAMESTART:
\r
751 //-----------------------------
\r
753 Trace.TraceInformation( "----------------------" );
\r
754 Trace.TraceInformation( "■ 選曲" );
\r
756 r直前のステージ = r現在のステージ;
\r
757 r現在のステージ = stage選曲;
\r
758 //-----------------------------
\r
762 #region [ OPTION: 廃止済 ]
\r
763 // case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
\r
765 // //-----------------------------
\r
766 // r現在のステージ.On非活性化();
\r
767 // Trace.TraceInformation( "----------------------" );
\r
768 // Trace.TraceInformation( "■ オプション" );
\r
769 // stageオプション.On活性化();
\r
770 // r直前のステージ = r現在のステージ;
\r
771 // r現在のステージ = stageオプション;
\r
772 // //-----------------------------
\r
777 case (int)CStageタイトル.E戻り値.CONFIG:
\r
779 //-----------------------------
\r
781 Trace.TraceInformation( "----------------------" );
\r
782 Trace.TraceInformation( "■ コンフィグ" );
\r
783 stageコンフィグ.On活性化();
\r
784 r直前のステージ = r現在のステージ;
\r
785 r現在のステージ = stageコンフィグ;
\r
786 //-----------------------------
\r
790 case (int)CStageタイトル.E戻り値.EXIT:
\r
792 //-----------------------------
\r
794 Trace.TraceInformation( "----------------------" );
\r
795 Trace.TraceInformation( "■ 終了" );
\r
797 r直前のステージ = r現在のステージ;
\r
798 r現在のステージ = stage終了;
\r
799 //-----------------------------
\r
804 foreach( STPlugin pg in this.listプラグイン )
\r
806 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
807 pg.plugin.Onステージ変更();
\r
808 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
811 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
\r
812 //-----------------------------
\r
816 // case CStage.Eステージ.オプション:
\r
818 // //-----------------------------
\r
819 // if( this.n進行描画の戻り値 != 0 )
\r
821 // switch( r直前のステージ.eステージID )
\r
823 // case CStage.Eステージ.タイトル:
\r
825 // //-----------------------------
\r
826 // r現在のステージ.On非活性化();
\r
827 // Trace.TraceInformation( "----------------------" );
\r
828 // Trace.TraceInformation( "■ タイトル" );
\r
829 // stageタイトル.On活性化();
\r
830 // r直前のステージ = r現在のステージ;
\r
831 // r現在のステージ = stageタイトル;
\r
833 // foreach( STPlugin pg in this.listプラグイン )
\r
835 // Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
836 // pg.plugin.Onステージ変更();
\r
837 // Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
840 // this.tガベージコレクションを実行する();
\r
842 // //-----------------------------
\r
845 // case CStage.Eステージ.選曲:
\r
847 // //-----------------------------
\r
848 // r現在のステージ.On非活性化();
\r
849 // Trace.TraceInformation( "----------------------" );
\r
850 // Trace.TraceInformation( "■ 選曲" );
\r
851 // stage選曲.On活性化();
\r
852 // r直前のステージ = r現在のステージ;
\r
853 // r現在のステージ = stage選曲;
\r
855 // foreach( STPlugin pg in this.listプラグイン )
\r
857 // Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
858 // pg.plugin.Onステージ変更();
\r
859 // Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
862 // this.tガベージコレクションを実行する();
\r
864 // //-----------------------------
\r
868 // //-----------------------------
\r
872 case CStage.Eステージ.コンフィグ:
\r
874 //-----------------------------
\r
875 if( this.n進行描画の戻り値 != 0 )
\r
877 switch( r直前のステージ.eステージID )
\r
879 case CStage.Eステージ.タイトル:
\r
881 //-----------------------------
\r
883 Trace.TraceInformation( "----------------------" );
\r
884 Trace.TraceInformation( "■ タイトル" );
\r
886 r直前のステージ = r現在のステージ;
\r
887 r現在のステージ = stageタイトル;
\r
889 foreach( STPlugin pg in this.listプラグイン )
\r
891 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
892 pg.plugin.Onステージ変更();
\r
893 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
896 this.tガベージコレクションを実行する();
\r
898 //-----------------------------
\r
901 case CStage.Eステージ.選曲:
\r
903 //-----------------------------
\r
905 Trace.TraceInformation( "----------------------" );
\r
906 Trace.TraceInformation( "■ 選曲" );
\r
908 r直前のステージ = r現在のステージ;
\r
909 r現在のステージ = stage選曲;
\r
911 foreach( STPlugin pg in this.listプラグイン )
\r
913 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
914 pg.plugin.Onステージ変更();
\r
915 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
918 this.tガベージコレクションを実行する();
\r
920 //-----------------------------
\r
924 //-----------------------------
\r
928 case CStage.Eステージ.選曲:
\r
930 //-----------------------------
\r
931 switch( this.n進行描画の戻り値 )
\r
933 case (int) CStage選曲.E戻り値.タイトルに戻る:
\r
935 //-----------------------------
\r
937 Trace.TraceInformation( "----------------------" );
\r
938 Trace.TraceInformation( "■ タイトル" );
\r
940 r直前のステージ = r現在のステージ;
\r
941 r現在のステージ = stageタイトル;
\r
943 foreach( STPlugin pg in this.listプラグイン )
\r
945 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
946 pg.plugin.Onステージ変更();
\r
947 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
950 this.tガベージコレクションを実行する();
\r
952 //-----------------------------
\r
955 case (int) CStage選曲.E戻り値.選曲した:
\r
957 //-----------------------------
\r
959 Trace.TraceInformation( "----------------------" );
\r
960 Trace.TraceInformation( "■ 曲読み込み" );
\r
961 stage曲読み込み.On活性化();
\r
962 r直前のステージ = r現在のステージ;
\r
963 r現在のステージ = stage曲読み込み;
\r
965 foreach( STPlugin pg in this.listプラグイン )
\r
967 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
968 pg.plugin.Onステージ変更();
\r
969 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
972 this.tガベージコレクションを実行する();
\r
974 //-----------------------------
\r
977 // case (int) CStage選曲.E戻り値.オプション呼び出し:
\r
979 // //-----------------------------
\r
980 // r現在のステージ.On非活性化();
\r
981 // Trace.TraceInformation( "----------------------" );
\r
982 // Trace.TraceInformation( "■ オプション" );
\r
983 // stageオプション.On活性化();
\r
984 // r直前のステージ = r現在のステージ;
\r
985 // r現在のステージ = stageオプション;
\r
987 // foreach( STPlugin pg in this.listプラグイン )
\r
989 // Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
990 // pg.plugin.Onステージ変更();
\r
991 // Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
994 // this.tガベージコレクションを実行する();
\r
996 // //-----------------------------
\r
999 case (int) CStage選曲.E戻り値.コンフィグ呼び出し:
\r
1001 //-----------------------------
\r
1002 r現在のステージ.On非活性化();
\r
1003 Trace.TraceInformation( "----------------------" );
\r
1004 Trace.TraceInformation( "■ コンフィグ" );
\r
1005 stageコンフィグ.On活性化();
\r
1006 r直前のステージ = r現在のステージ;
\r
1007 r現在のステージ = stageコンフィグ;
\r
1009 foreach( STPlugin pg in this.listプラグイン )
\r
1011 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1012 pg.plugin.Onステージ変更();
\r
1013 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1016 this.tガベージコレクションを実行する();
\r
1018 //-----------------------------
\r
1021 case (int) CStage選曲.E戻り値.スキン変更:
\r
1024 //-----------------------------
\r
1025 r現在のステージ.On非活性化();
\r
1026 Trace.TraceInformation( "----------------------" );
\r
1027 Trace.TraceInformation( "■ スキン切り替え" );
\r
1028 stageChangeSkin.On活性化();
\r
1029 r直前のステージ = r現在のステージ;
\r
1030 r現在のステージ = stageChangeSkin;
\r
1032 //-----------------------------
\r
1035 //-----------------------------
\r
1039 case CStage.Eステージ.曲読み込み:
\r
1041 //-----------------------------
\r
1042 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
\r
1043 if( this.n進行描画の戻り値 != 0 )
\r
1045 CDTXMania.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
\r
1046 r現在のステージ.On非活性化();
\r
1047 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
\r
1048 if ( this.n進行描画の戻り値 == (int) E曲読込画面の戻り値.読込中止 )
\r
1050 //DTX.t全チップの再生停止();
\r
1052 Trace.TraceInformation( "曲の読み込みを中止しました。" );
\r
1053 this.tガベージコレクションを実行する();
\r
1054 Trace.TraceInformation( "----------------------" );
\r
1055 Trace.TraceInformation( "■ 選曲" );
\r
1057 r直前のステージ = r現在のステージ;
\r
1058 r現在のステージ = stage選曲;
\r
1059 foreach ( STPlugin pg in this.listプラグイン )
\r
1061 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1062 pg.plugin.Onステージ変更();
\r
1063 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1069 if( !ConfigIni.bギタレボモード )
\r
1071 Trace.TraceInformation( "----------------------" );
\r
1072 Trace.TraceInformation( "■ 演奏(ドラム画面)" );
\r
1073 #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
\r
1074 for (int i = 0; i < 5; i++)
\r
1076 for (int j = 0; j < 2; j++)
\r
1078 stage演奏ドラム画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
\r
1081 for (int i = 0; i < 3; i++) {
\r
1082 stage演奏ドラム画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
\r
1085 r直前のステージ = r現在のステージ;
\r
1086 r現在のステージ = stage演奏ドラム画面;
\r
1090 Trace.TraceInformation( "----------------------" );
\r
1091 Trace.TraceInformation( "■ 演奏(ギター画面)" );
\r
1092 #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
\r
1093 for (int i = 0; i < 5; i++)
\r
1095 for (int j = 0; j < 2; j++)
\r
1097 stage演奏ギター画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
\r
1100 for (int i = 0; i < 3; i++) {
\r
1101 stage演奏ギター画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
\r
1104 r直前のステージ = r現在のステージ;
\r
1105 r現在のステージ = stage演奏ギター画面;
\r
1108 foreach( STPlugin pg in this.listプラグイン )
\r
1110 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1111 pg.plugin.Onステージ変更();
\r
1112 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1115 this.tガベージコレクションを実行する();
\r
1117 //-----------------------------
\r
1121 case CStage.Eステージ.演奏:
\r
1123 //-----------------------------
\r
1125 double n = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
\r
1128 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
\r
1129 if ( DTXVmode.Enabled && DTXVmode.Refreshed )
\r
1131 DTXVmode.Refreshed = false;
\r
1133 if ( DTXVmode.Command == CDTXVmode.ECommand.Stop )
\r
1135 if ( !ConfigIni.bギタレボモード )
\r
1137 CDTXMania.stage演奏ドラム画面.t停止();
\r
1141 CDTXMania.stage演奏ギター画面.t停止();
\r
1143 if ( previewSound != null )
\r
1145 this.previewSound.tサウンドを停止する();
\r
1146 this.previewSound.Dispose();
\r
1147 this.previewSound = null;
\r
1150 else if ( DTXVmode.Command == CDTXVmode.ECommand.Play )
\r
1152 if ( DTXVmode.NeedReload )
\r
1154 if ( !ConfigIni.bギタレボモード )
\r
1156 CDTXMania.stage演奏ドラム画面.t再読込();
\r
1160 CDTXMania.stage演奏ギター画面.t再読込();
\r
1163 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
\r
1164 CDTXMania.ConfigIni.bGuitar有効 = true;
\r
1165 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
\r
1166 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
\r
1167 if ( CDTXMania.ConfigIni.b垂直帰線待ちを行う != DTXVmode.VSyncWait )
\r
1169 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
\r
1170 CDTXMania.app.b次のタイミングで垂直帰線同期切り替えを行う = true;
\r
1175 if ( !ConfigIni.bギタレボモード )
\r
1177 CDTXMania.stage演奏ドラム画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
\r
1181 CDTXMania.stage演奏ギター画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
\r
1188 switch( this.n進行描画の戻り値 )
\r
1190 case (int) E演奏画面の戻り値.再読込・再演奏:
\r
1191 #region [ DTXファイルを再読み込みして、再演奏 ]
\r
1194 r現在のステージ.On非活性化();
\r
1195 stage曲読み込み.On活性化();
\r
1196 r直前のステージ = r現在のステージ;
\r
1197 r現在のステージ = stage曲読み込み;
\r
1198 this.tガベージコレクションを実行する();
\r
1202 //case (int) E演奏画面の戻り値.再演奏:
\r
1203 #region [ 再読み込み無しで、再演奏 ]
\r
1207 case (int) E演奏画面の戻り値.継続:
\r
1210 case (int) E演奏画面の戻り値.演奏中断:
\r
1211 #region [ 演奏キャンセル ]
\r
1212 //-----------------------------
\r
1213 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新( "Play canceled" );
\r
1215 double lastd = 0f;
\r
1217 foreach ( double d in swlist )
\r
1219 double dif = d - lastd;
\r
1221 if ( 0.016 < dif && dif < 0.017 )
\r
1228 //Trace.TraceInformation( "frame " + f + ": " + d + " (" + dif + ")" + s );
\r
1234 #region [ プラグイン On演奏キャンセル() の呼び出し ]
\r
1235 //---------------------
\r
1236 foreach( STPlugin pg in this.listプラグイン )
\r
1238 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1239 pg.plugin.On演奏キャンセル( scoreIni );
\r
1240 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1242 //---------------------
\r
1247 r現在のステージ.On非活性化();
\r
1250 base.Window.Close();
\r
1254 Trace.TraceInformation( "----------------------" );
\r
1255 Trace.TraceInformation( "■ 選曲" );
\r
1257 r直前のステージ = r現在のステージ;
\r
1258 r現在のステージ = stage選曲;
\r
1260 #region [ プラグイン Onステージ変更() の呼び出し ]
\r
1261 //---------------------
\r
1262 foreach( STPlugin pg in this.listプラグイン )
\r
1264 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1265 pg.plugin.Onステージ変更();
\r
1266 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1268 //---------------------
\r
1271 this.tガベージコレクションを実行する();
\r
1274 //-----------------------------
\r
1277 case (int) E演奏画面の戻り値.ステージ失敗:
\r
1278 #region [ 演奏失敗(StageFailed) ]
\r
1279 //-----------------------------
\r
1280 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新( "Stage failed" );
\r
1282 #region [ プラグイン On演奏失敗() の呼び出し ]
\r
1283 //---------------------
\r
1284 foreach( STPlugin pg in this.listプラグイン )
\r
1286 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1287 pg.plugin.On演奏失敗( scoreIni );
\r
1288 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1290 //---------------------
\r
1295 r現在のステージ.On非活性化();
\r
1298 base.Window.Close();
\r
1302 Trace.TraceInformation( "----------------------" );
\r
1303 Trace.TraceInformation( "■ 選曲" );
\r
1305 r直前のステージ = r現在のステージ;
\r
1306 r現在のステージ = stage選曲;
\r
1308 #region [ プラグイン Onステージ変更() の呼び出し ]
\r
1309 //---------------------
\r
1310 foreach( STPlugin pg in this.listプラグイン )
\r
1312 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1313 pg.plugin.Onステージ変更();
\r
1314 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1316 //---------------------
\r
1319 this.tガベージコレクションを実行する();
\r
1322 //-----------------------------
\r
1325 case (int) E演奏画面の戻り値.ステージクリア:
\r
1327 //-----------------------------
\r
1328 CScoreIni.C演奏記録 c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass;
\r
1329 CDTX.CChip[] chipArray = new CDTX.CChip[ 10 ];
\r
1330 if( ConfigIni.bギタレボモード )
\r
1332 stage演奏ギター画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass );
\r
1336 stage演奏ドラム画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass, out chipArray );
\r
1339 if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.24 yyagi Gt/Bsを入れ替えていたなら、演奏結果も入れ替える
\r
1341 CScoreIni.C演奏記録 t;
\r
1343 c演奏記録_Guitar = c演奏記録_Bass;
\r
1346 CDTXMania.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す
\r
1347 CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // #24415 2011.2.27 yyagi
\r
1348 // リザルト集計時のみ、Auto系のフラグも元に戻す。
\r
1349 // これを戻すのは、リザルト集計後。
\r
1350 } // "case CStage.Eステージ.結果:"のところ。
\r
1352 double ps = 0.0, gs = 0.0;
\r
1353 if ( !c演奏記録_Drums.b全AUTOである && c演奏記録_Drums.n全チップ数 > 0) {
\r
1354 ps = c演奏記録_Drums.db演奏型スキル値;
\r
1355 gs = c演奏記録_Drums.dbゲーム型スキル値;
\r
1357 else if ( !c演奏記録_Guitar.b全AUTOである && c演奏記録_Guitar.n全チップ数 > 0) {
\r
1358 ps = c演奏記録_Guitar.db演奏型スキル値;
\r
1359 gs = c演奏記録_Guitar.dbゲーム型スキル値;
\r
1363 ps = c演奏記録_Bass.db演奏型スキル値;
\r
1364 gs = c演奏記録_Bass.dbゲーム型スキル値;
\r
1366 string str = "Cleared";
\r
1367 switch( CScoreIni.t総合ランク値を計算して返す( c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass ) )
\r
1369 case (int)CScoreIni.ERANK.SS:
\r
1370 str = string.Format( "Cleared (SS: {0:F2})", ps );
\r
1373 case (int) CScoreIni.ERANK.S:
\r
1374 str = string.Format( "Cleared (S: {0:F2})", ps );
\r
1377 case (int) CScoreIni.ERANK.A:
\r
1378 str = string.Format( "Cleared (A: {0:F2})", ps );
\r
1381 case (int) CScoreIni.ERANK.B:
\r
1382 str = string.Format( "Cleared (B: {0:F2})", ps );
\r
1385 case (int) CScoreIni.ERANK.C:
\r
1386 str = string.Format( "Cleared (C: {0:F2})", ps );
\r
1389 case (int) CScoreIni.ERANK.D:
\r
1390 str = string.Format( "Cleared (D: {0:F2})", ps );
\r
1393 case (int) CScoreIni.ERANK.E:
\r
1394 str = string.Format( "Cleared (E: {0:F2})", ps );
\r
1397 case (int)CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
\r
1398 str = "Cleared (No chips)";
\r
1402 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新( str );
\r
1404 #region [ プラグイン On演奏クリア() の呼び出し ]
\r
1405 //---------------------
\r
1406 foreach( STPlugin pg in this.listプラグイン )
\r
1408 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1409 pg.plugin.On演奏クリア( scoreIni );
\r
1410 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1412 //---------------------
\r
1415 r現在のステージ.On非活性化();
\r
1416 Trace.TraceInformation( "----------------------" );
\r
1417 Trace.TraceInformation( "■ 結果" );
\r
1418 stage結果.st演奏記録.Drums = c演奏記録_Drums;
\r
1419 stage結果.st演奏記録.Guitar = c演奏記録_Guitar;
\r
1420 stage結果.st演奏記録.Bass = c演奏記録_Bass;
\r
1421 stage結果.r空うちドラムチップ = chipArray;
\r
1423 r直前のステージ = r現在のステージ;
\r
1424 r現在のステージ = stage結果;
\r
1426 #region [ プラグイン Onステージ変更() の呼び出し ]
\r
1427 //---------------------
\r
1428 foreach( STPlugin pg in this.listプラグイン )
\r
1430 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1431 pg.plugin.Onステージ変更();
\r
1432 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1434 //---------------------
\r
1438 //-----------------------------
\r
1441 //-----------------------------
\r
1445 case CStage.Eステージ.結果:
\r
1447 //-----------------------------
\r
1448 if( this.n進行描画の戻り値 != 0 )
\r
1450 if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
\r
1452 CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
\r
1455 DTX.t全チップの再生一時停止();
\r
1457 r現在のステージ.On非活性化();
\r
1460 Trace.TraceInformation( "----------------------" );
\r
1461 Trace.TraceInformation( "■ 選曲" );
\r
1463 r直前のステージ = r現在のステージ;
\r
1464 r現在のステージ = stage選曲;
\r
1466 foreach( STPlugin pg in this.listプラグイン )
\r
1468 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
\r
1469 pg.plugin.Onステージ変更();
\r
1470 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
1473 this.tガベージコレクションを実行する();
\r
1477 base.Window.Close();
\r
1480 //-----------------------------
\r
1484 case CStage.Eステージ.ChangeSkin:
\r
1486 //-----------------------------
\r
1487 if ( this.n進行描画の戻り値 != 0 )
\r
1489 r現在のステージ.On非活性化();
\r
1490 Trace.TraceInformation( "----------------------" );
\r
1491 Trace.TraceInformation( "■ 選曲" );
\r
1493 r直前のステージ = r現在のステージ;
\r
1494 r現在のステージ = stage選曲;
\r
1495 this.tガベージコレクションを実行する();
\r
1497 //-----------------------------
\r
1501 case CStage.Eステージ.終了:
\r
1503 //-----------------------------
\r
1504 if( this.n進行描画の戻り値 != 0 )
\r
1508 //-----------------------------
\r
1513 this.Device.EndScene(); // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
\r
1514 // (つまり、Present()は、Draw()完了後に実行される)
\r
1515 #if !GPUFlushAfterPresent
\r
1516 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
\r
1518 if ( Sound管理.GetCurrentSoundDeviceType() != "DirectSound" )
\r
1520 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
\r
1524 #region [ 全画面・ウインドウ切り替え ]
\r
1525 if ( this.b次のタイミングで全画面・ウィンドウ切り替えを行う )
\r
1527 ConfigIni.b全画面モード = !ConfigIni.b全画面モード;
\r
1528 app.t全画面・ウィンドウモード切り替え();
\r
1529 this.b次のタイミングで全画面・ウィンドウ切り替えを行う = false;
\r
1532 #region [ 垂直基線同期切り替え ]
\r
1533 if ( this.b次のタイミングで垂直帰線同期切り替えを行う )
\r
1535 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
\r
1536 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
\r
1537 DeviceSettings currentSettings = app.GraphicsDeviceManager.CurrentSettings;
\r
1538 currentSettings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
\r
1539 app.GraphicsDeviceManager.ChangeDevice( currentSettings );
\r
1540 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
\r
1541 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
\r
1544 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
\r
1552 #region [ 汎用ヘルパー ]
\r
1553 //-----------------
\r
1554 public static CTexture tテクスチャの生成( string fileName )
\r
1556 return tテクスチャの生成( fileName, false );
\r
1558 public static CTexture tテクスチャの生成( string fileName, bool b黒を透過する )
\r
1560 if ( app == null )
\r
1566 return new CTexture( app.Device, fileName, TextureFormat, b黒を透過する );
\r
1568 catch ( CTextureCreateFailedException )
\r
1570 Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
\r
1573 catch ( FileNotFoundException )
\r
1575 Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
\r
1579 public static void tテクスチャの解放( ref CTexture tx )
\r
1581 CDTXMania.t安全にDisposeする( ref tx );
\r
1584 public static CTexture tテクスチャの生成( byte[] txData )
\r
1586 return tテクスチャの生成( txData, false );
\r
1588 public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
\r
1590 if ( app == null )
\r
1596 return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
\r
1598 catch ( CTextureCreateFailedException )
\r
1600 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
\r
1605 public static CTexture tテクスチャの生成( Bitmap bitmap )
\r
1607 return tテクスチャの生成( bitmap, false );
\r
1609 public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
\r
1611 if ( app == null )
\r
1617 return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
\r
1619 catch ( CTextureCreateFailedException )
\r
1621 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
\r
1626 /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
\r
1627 public static void t安全にDisposeする<T>( ref T obj )
\r
1629 if ( obj == null )
\r
1632 var d = obj as IDisposable;
\r
1637 obj = default( T );
\r
1639 //-----------------
\r
1642 #region [ private ]
\r
1643 //-----------------
\r
1644 private bool bマウスカーソル表示中 = true;
\r
1645 private bool b終了処理完了済み;
\r
1646 private static CDTX dtx;
\r
1647 private List<CActivity> listトップレベルActivities;
\r
1648 private int n進行描画の戻り値;
\r
1649 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
\r
1650 private string strWindowTitle
\r
1654 if ( DTXVmode.Enabled )
\r
1656 return "DTXViewer release " + VERSION;
\r
1660 return "DTXMania .NET style release " + VERSION;
\r
1664 private CSound previewSound;
\r
1666 private void t起動処理()
\r
1668 #region [ strEXEのあるフォルダを決定する ]
\r
1669 //-----------------
\r
1670 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
\r
1672 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
\r
1674 strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
\r
1676 // END #23629 2010.11.13 from
\r
1677 //-----------------
\r
1680 #region [ Config.ini の読込み ]
\r
1681 //---------------------
\r
1682 ConfigIni = new CConfigIni();
\r
1683 string path = strEXEのあるフォルダ + "Config.ini";
\r
1684 if( File.Exists( path ) )
\r
1688 ConfigIni.tファイルから読み込み( path );
\r
1692 //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
\r
1695 this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
\r
1696 // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
\r
1698 //---------------------
\r
1700 #region [ ログ出力開始 ]
\r
1701 //---------------------
\r
1702 Trace.AutoFlush = true;
\r
1703 if( ConfigIni.bログ出力 )
\r
1707 Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( System.IO.Path.Combine( strEXEのあるフォルダ, "DTXManiaLog.txt" ), true, Encoding.GetEncoding( "Shift_JIS" ) ) ) );
\r
1709 catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
\r
1711 int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
\r
1712 string[] mes_writeErr = {
\r
1713 "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
\r
1714 "Failed to write DTXManiaLog.txt. Please set it writable and try again."
\r
1716 MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
\r
1717 Environment.Exit(1);
\r
1720 Trace.WriteLine("");
\r
1721 Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
\r
1722 Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
\r
1723 Trace.WriteLine( "" );
\r
1724 Trace.TraceInformation( "----------------------" );
\r
1725 Trace.TraceInformation( "■ アプリケーションの初期化" );
\r
1726 Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
\r
1727 Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
\r
1728 Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
\r
1729 //---------------------
\r
1731 #region [ DTXVmodeクラス の初期化 ]
\r
1732 //---------------------
\r
1733 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
\r
1737 DTXVmode = new CDTXVmode();
\r
1738 DTXVmode.Enabled = false;
\r
1739 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
\r
1743 //Trace.Unindent();
\r
1745 //---------------------
\r
1747 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
\r
1748 //---------------------
\r
1749 bコンパクトモード = false;
\r
1750 strコンパクトモードファイル = "";
\r
1751 string[] commandLineArgs = Environment.GetCommandLineArgs();
\r
1752 if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
\r
1757 for ( int i = 1; i < commandLineArgs.Length; i++ )
\r
1761 arg += " " + "\"" + commandLineArgs[ i ] + "\"";
\r
1765 arg += commandLineArgs[ i ];
\r
1768 DTXVmode.ParseArguments( arg );
\r
1770 if ( DTXVmode.Enabled )
\r
1772 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
\r
1773 strコンパクトモードファイル = DTXVmode.filename;
\r
1774 switch ( DTXVmode.soundDeviceType ) // サウンド再生方式の設定
\r
1776 case ESoundDeviceType.DirectSound:
\r
1777 ConfigIni.nSoundDeviceType = 0;
\r
1779 case ESoundDeviceType.ExclusiveWASAPI:
\r
1780 ConfigIni.nSoundDeviceType = 2;
\r
1782 case ESoundDeviceType.ASIO:
\r
1783 ConfigIni.nSoundDeviceType = 1;
\r
1784 ConfigIni.nASIODevice = DTXVmode.nASIOdevice;
\r
1788 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
\r
1789 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
\r
1790 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
\r
1791 CDTXMania.ConfigIni.bGuitar有効 = true;
\r
1793 else // 通常のコンパクトモード
\r
1795 strコンパクトモードファイル = commandLineArgs[ 1 ];
\r
1798 if ( !File.Exists( strコンパクトモードファイル ) ) // #32985 2014.1.23 yyagi
\r
1800 Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル );
\r
1802 Environment.Exit( -1 );
\r
1804 if ( strコンパクトモードファイル == "" ) // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
\r
1806 Environment.Exit( -1 );
\r
1810 throw new FileNotFoundException( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル );
\r
1814 if ( DTXVmode.Enabled )
\r
1816 Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモードファイル );
\r
1820 Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモードファイル );
\r
1823 //---------------------
\r
1826 #region [ ウィンドウ初期化 ]
\r
1827 //---------------------
\r
1828 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
\r
1829 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
\r
1831 base.Window.Text = this.strWindowTitle; // 事前にDTXVmodeの実体を作っておくこと
\r
1833 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
\r
1834 base.Window.Location = new Point(ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y); // #30675 2013.02.04 ikanick add
\r
1836 base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #34510 yyagi 2010.10.31 to change window size got from Config.ini
\r
1837 #if !WindowedFullscreen
\r
1838 if (!ConfigIni.bウィンドウモード) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
\r
1839 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
\r
1841 currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );
\r
1842 #if !WindowedFullscreen
\r
1845 base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
\r
1846 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
\r
1847 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
\r
1848 base.Window.ShowIcon = true;
\r
1849 base.Window.Icon = Properties.Resources.dtx;
\r
1850 base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
\r
1851 base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
\r
1852 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
\r
1853 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
\r
1854 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
\r
1855 base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
\r
1856 //---------------------
\r
1858 #region [ Direct3D9Exを使うかどうか判定 ]
\r
1860 #region [ Direct3D9 デバイスの生成 ]
\r
1861 //---------------------
\r
1862 DeviceSettings settings = new DeviceSettings();
\r
1863 #if WindowedFullscreen
\r
1864 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
\r
1866 settings.Windowed = ConfigIni.bウィンドウモード;
\r
1868 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
\r
1869 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
\r
1870 // settings.BackBufferCount = 3;
\r
1871 settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
\r
1872 // settings.BackBufferFormat = Format.A8R8G8B8;
\r
1873 // settings.MultisampleType = MultisampleType.FourSamples;
\r
1874 // settings.MultisampleQuality = 4;
\r
1875 // settings.MultisampleType = MultisampleType.None;
\r
1876 // settings.MultisampleQuality = 0;
\r
1880 base.GraphicsDeviceManager.ChangeDevice(settings);
\r
1882 catch (DeviceCreationException e)
\r
1884 Trace.TraceError(e.ToString());
\r
1885 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
1886 Environment.Exit(-1);
\r
1889 base.IsFixedTimeStep = false;
\r
1890 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
\r
1891 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.
\r
1892 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォーカス時スリープms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
\r
1893 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
\r
1894 #if WindowedFullscreen
\r
1895 this.t全画面・ウィンドウモード切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
\r
1897 actFlushGPU = new CActFlushGPU();
\r
1898 //---------------------
\r
1903 #region [ Skin の初期化 ]
\r
1904 //---------------------
\r
1905 Trace.TraceInformation( "スキンの初期化を行います。" );
\r
1909 Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
\r
1910 CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
\r
1911 Trace.TraceInformation( "スキンの初期化を完了しました。" );
\r
1915 Trace.TraceInformation( "スキンの初期化に失敗しました。" );
\r
1922 //---------------------
\r
1925 #region [ Timer の初期化 ]
\r
1926 //---------------------
\r
1927 Trace.TraceInformation( "タイマの初期化を行います。" );
\r
1931 Timer = new CTimer( CTimer.E種別.MultiMedia );
\r
1932 Trace.TraceInformation( "タイマの初期化を完了しました。" );
\r
1938 //---------------------
\r
1942 #region [ FPS カウンタの初期化 ]
\r
1943 //---------------------
\r
1944 Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
\r
1949 Trace.TraceInformation( "FPSカウンタを生成しました。" );
\r
1955 //---------------------
\r
1957 #region [ act文字コンソールの初期化 ]
\r
1958 //---------------------
\r
1959 Trace.TraceInformation( "文字コンソールの初期化を行います。" );
\r
1963 act文字コンソール = new C文字コンソール();
\r
1964 Trace.TraceInformation( "文字コンソールを生成しました。" );
\r
1965 act文字コンソール.On活性化();
\r
1966 Trace.TraceInformation( "文字コンソールを活性化しました。" );
\r
1967 Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
\r
1969 catch( Exception exception )
\r
1971 Trace.TraceError( exception.Message );
\r
1972 Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
\r
1978 //---------------------
\r
1980 #region [ Input管理 の初期化 ]
\r
1981 //---------------------
\r
1982 Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
\r
1986 bool bUseMIDIIn = !DTXVmode.Enabled;
\r
1987 Input管理 = new CInput管理( base.Window.Handle, bUseMIDIIn );
\r
1988 foreach( IInputDevice device in Input管理.list入力デバイス )
\r
1990 if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
\r
1993 while( ConfigIni.dicJoystick.ContainsKey( key ) )
\r
1997 ConfigIni.dicJoystick.Add( key, device.GUID );
\r
2000 foreach( IInputDevice device2 in Input管理.list入力デバイス )
\r
2002 if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
\r
2004 foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
\r
2006 if( device2.GUID.Equals( pair.Value ) )
\r
2008 ( (CInputJoystick) device2 ).SetID( pair.Key );
\r
2015 Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
\r
2017 catch( Exception exception2 )
\r
2019 Trace.TraceError( exception2.Message );
\r
2020 Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
\r
2027 //---------------------
\r
2029 #region [ Pad の初期化 ]
\r
2030 //---------------------
\r
2031 Trace.TraceInformation( "パッドの初期化を行います。" );
\r
2035 Pad = new CPad( ConfigIni, Input管理 );
\r
2036 Trace.TraceInformation( "パッドの初期化を完了しました。" );
\r
2038 catch( Exception exception3 )
\r
2040 Trace.TraceError( exception3.Message );
\r
2041 Trace.TraceError( "パッドの初期化に失敗しました。" );
\r
2047 //---------------------
\r
2049 #region [ Sound管理 の初期化 ]
\r
2050 //---------------------
\r
2051 Trace.TraceInformation( "サウンドデバイスの初期化を行います。" );
\r
2055 ESoundDeviceType soundDeviceType;
\r
2056 switch ( CDTXMania.ConfigIni.nSoundDeviceType )
\r
2059 soundDeviceType = ESoundDeviceType.DirectSound;
\r
2062 soundDeviceType = ESoundDeviceType.ASIO;
\r
2065 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
\r
2068 soundDeviceType = ESoundDeviceType.Unknown;
\r
2071 Sound管理 = new CSound管理( base.Window.Handle,
\r
2073 // CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
\r
2075 // CDTXMania.ConfigIni.nASIOBufferSizeMs,
\r
2077 CDTXMania.ConfigIni.nASIODevice
\r
2079 //Sound管理 = FDK.CSound管理.Instance;
\r
2080 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.ConfigIni.nASIODevice, base.Window.Handle );
\r
2082 ShowWindowTitleWithSoundType();
\r
2083 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
\r
2084 Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;
\r
2085 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;
\r
2086 Trace.TraceInformation( "サウンドデバイスの初期化を完了しました。" );
\r
2088 catch (Exception e)
\r
2090 Trace.TraceError( e.Message );
\r
2097 //---------------------
\r
2099 #region [ Songs管理 の初期化 ]
\r
2100 //---------------------
\r
2101 Trace.TraceInformation( "曲リストの初期化を行います。" );
\r
2105 Songs管理 = new CSongs管理();
\r
2106 // Songs管理_裏読 = new CSongs管理();
\r
2107 EnumSongs = new CEnumSongs();
\r
2108 actEnumSongs = new CActEnumSongs();
\r
2109 Trace.TraceInformation( "曲リストの初期化を完了しました。" );
\r
2111 catch( Exception e )
\r
2113 Trace.TraceError( e.Message );
\r
2114 Trace.TraceError( "曲リストの初期化に失敗しました。" );
\r
2120 //---------------------
\r
2122 #region [ CAvi の初期化 ]
\r
2123 //---------------------
\r
2125 //---------------------
\r
2127 #region [ Random の初期化 ]
\r
2128 //---------------------
\r
2129 Random = new Random( (int) Timer.nシステム時刻 );
\r
2130 //---------------------
\r
2132 #region [ ステージの初期化 ]
\r
2133 //---------------------
\r
2136 stage起動 = new CStage起動();
\r
2137 stageタイトル = new CStageタイトル();
\r
2138 // stageオプション = new CStageオプション();
\r
2139 stageコンフィグ = new CStageコンフィグ();
\r
2140 stage選曲 = new CStage選曲();
\r
2141 stage曲読み込み = new CStage曲読み込み();
\r
2142 stage演奏ドラム画面 = new CStage演奏ドラム画面();
\r
2143 stage演奏ギター画面 = new CStage演奏ギター画面();
\r
2144 stage結果 = new CStage結果();
\r
2145 stageChangeSkin = new CStageChangeSkin();
\r
2146 stage終了 = new CStage終了();
\r
2147 this.listトップレベルActivities = new List<CActivity>();
\r
2148 this.listトップレベルActivities.Add( actEnumSongs );
\r
2149 this.listトップレベルActivities.Add( act文字コンソール );
\r
2150 this.listトップレベルActivities.Add( stage起動 );
\r
2151 this.listトップレベルActivities.Add( stageタイトル );
\r
2152 // this.listトップレベルActivities.Add( stageオプション );
\r
2153 this.listトップレベルActivities.Add( stageコンフィグ );
\r
2154 this.listトップレベルActivities.Add( stage選曲 );
\r
2155 this.listトップレベルActivities.Add( stage曲読み込み );
\r
2156 this.listトップレベルActivities.Add( stage演奏ドラム画面 );
\r
2157 this.listトップレベルActivities.Add( stage演奏ギター画面 );
\r
2158 this.listトップレベルActivities.Add( stage結果 );
\r
2159 this.listトップレベルActivities.Add( stageChangeSkin );
\r
2160 this.listトップレベルActivities.Add( stage終了 );
\r
2161 this.listトップレベルActivities.Add( actFlushGPU );
\r
2162 //---------------------
\r
2164 #region [ プラグインの検索と生成 ]
\r
2165 //---------------------
\r
2166 PluginHost = new CPluginHost();
\r
2168 Trace.TraceInformation( "プラグインの検索と生成を行います。" );
\r
2172 this.tプラグイン検索と生成();
\r
2173 Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
\r
2179 //---------------------
\r
2181 #region [ プラグインの初期化 ]
\r
2182 //---------------------
\r
2183 if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
\r
2185 Trace.TraceInformation( "プラグインの初期化を行います。" );
\r
2189 foreach( STPlugin st in this.listプラグイン )
\r
2191 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
\r
2192 st.plugin.On初期化( this.PluginHost );
\r
2193 st.plugin.OnManagedリソースの作成();
\r
2194 st.plugin.OnUnmanagedリソースの作成();
\r
2195 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
2197 Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
\r
2201 Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
\r
2210 //---------------------
\r
2213 Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );
\r
2215 #region [ 最初のステージの起動 ]
\r
2216 //---------------------
\r
2217 Trace.TraceInformation( "----------------------" );
\r
2218 Trace.TraceInformation( "■ 起動" );
\r
2220 if ( CDTXMania.bコンパクトモード )
\r
2222 r現在のステージ = stage曲読み込み;
\r
2226 r現在のステージ = stage起動;
\r
2229 //---------------------
\r
2233 public void ShowWindowTitleWithSoundType()
\r
2235 string delay = "";
\r
2236 if ( Sound管理.GetCurrentSoundDeviceType() != "DirectSound" )
\r
2238 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
\r
2240 base.Window.Text = strWindowTitle + " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
\r
2243 private void t終了処理()
\r
2245 if( !this.b終了処理完了済み )
\r
2247 Trace.TraceInformation( "----------------------" );
\r
2248 Trace.TraceInformation( "■ アプリケーションの終了" );
\r
2249 #region [ 曲検索の終了処理 ]
\r
2250 //---------------------
\r
2251 if ( actEnumSongs != null )
\r
2253 Trace.TraceInformation( "曲検索actの終了処理を行います。" );
\r
2257 actEnumSongs.On非活性化();
\r
2258 actEnumSongs= null;
\r
2259 Trace.TraceInformation( "曲検索actの終了処理を完了しました。" );
\r
2261 catch ( Exception e )
\r
2263 Trace.TraceError( e.Message );
\r
2264 Trace.TraceError( "曲検索actの終了処理に失敗しました。" );
\r
2271 //---------------------
\r
2273 #region [ 現在のステージの終了処理 ]
\r
2274 //---------------------
\r
2275 if( CDTXMania.r現在のステージ != null && CDTXMania.r現在のステージ.b活性化してる ) // #25398 2011.06.07 MODIFY FROM
\r
2277 Trace.TraceInformation( "現在のステージを終了します。" );
\r
2281 r現在のステージ.On非活性化();
\r
2282 Trace.TraceInformation( "現在のステージの終了処理を完了しました。" );
\r
2289 //---------------------
\r
2291 #region [ プラグインの終了処理 ]
\r
2292 //---------------------
\r
2293 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
\r
2295 Trace.TraceInformation( "すべてのプラグインを終了します。" );
\r
2299 foreach( STPlugin st in this.listプラグイン )
\r
2301 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
\r
2302 st.plugin.OnUnmanagedリソースの解放();
\r
2303 st.plugin.OnManagedリソースの解放();
\r
2305 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
\r
2307 PluginHost = null;
\r
2308 Trace.TraceInformation( "すべてのプラグインの終了処理を完了しました。" );
\r
2315 //---------------------
\r
2317 #region [ 曲リストの終了処理 ]
\r
2318 //---------------------
\r
2319 if (Songs管理 != null)
\r
2321 Trace.TraceInformation( "曲リストの終了処理を行います。" );
\r
2326 Trace.TraceInformation( "曲リストの終了処理を完了しました。" );
\r
2328 catch( Exception exception )
\r
2330 Trace.TraceError( exception.Message );
\r
2331 Trace.TraceError( "曲リストの終了処理に失敗しました。" );
\r
2339 //---------------------
\r
2341 #region [ スキンの終了処理 ]
\r
2342 //---------------------
\r
2345 Trace.TraceInformation( "スキンの終了処理を行います。" );
\r
2351 Trace.TraceInformation( "スキンの終了処理を完了しました。" );
\r
2353 catch( Exception exception2 )
\r
2355 Trace.TraceError( exception2.Message );
\r
2356 Trace.TraceError( "スキンの終了処理に失敗しました。" );
\r
2363 //---------------------
\r
2365 #region [ DirectSoundの終了処理 ]
\r
2366 //---------------------
\r
2367 if (Sound管理 != null)
\r
2369 Trace.TraceInformation( "DirectSound の終了処理を行います。" );
\r
2373 Sound管理.Dispose();
\r
2375 Trace.TraceInformation( "DirectSound の終了処理を完了しました。" );
\r
2377 catch( Exception exception3 )
\r
2379 Trace.TraceError( exception3.Message );
\r
2380 Trace.TraceError( "DirectSound の終了処理に失敗しました。" );
\r
2387 //---------------------
\r
2389 #region [ パッドの終了処理 ]
\r
2390 //---------------------
\r
2393 Trace.TraceInformation( "パッドの終了処理を行います。" );
\r
2398 Trace.TraceInformation( "パッドの終了処理を完了しました。" );
\r
2400 catch( Exception exception4 )
\r
2402 Trace.TraceError( exception4.Message );
\r
2403 Trace.TraceError( "パッドの終了処理に失敗しました。" );
\r
2410 //---------------------
\r
2412 #region [ DirectInput, MIDI入力の終了処理 ]
\r
2413 //---------------------
\r
2414 if (Input管理 != null)
\r
2416 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を行います。" );
\r
2420 Input管理.Dispose();
\r
2422 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を完了しました。" );
\r
2424 catch( Exception exception5 )
\r
2426 Trace.TraceError( exception5.Message );
\r
2427 Trace.TraceError( "DirectInput, MIDI入力の終了処理に失敗しました。" );
\r
2434 //---------------------
\r
2436 #region [ 文字コンソールの終了処理 ]
\r
2437 //---------------------
\r
2438 if (act文字コンソール != null)
\r
2440 Trace.TraceInformation( "文字コンソールの終了処理を行います。" );
\r
2444 act文字コンソール.On非活性化();
\r
2445 act文字コンソール = null;
\r
2446 Trace.TraceInformation( "文字コンソールの終了処理を完了しました。" );
\r
2448 catch( Exception exception6 )
\r
2450 Trace.TraceError( exception6.Message );
\r
2451 Trace.TraceError( "文字コンソールの終了処理に失敗しました。" );
\r
2458 //---------------------
\r
2460 #region [ FPSカウンタの終了処理 ]
\r
2461 //---------------------
\r
2462 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
\r
2470 Trace.TraceInformation( "FPSカウンタの終了処理を完了しました。" );
\r
2476 //---------------------
\r
2478 #region [ タイマの終了処理 ]
\r
2479 //---------------------
\r
2480 Trace.TraceInformation("タイマの終了処理を行います。");
\r
2484 if( Timer != null )
\r
2488 Trace.TraceInformation( "タイマの終了処理を完了しました。" );
\r
2492 Trace.TraceInformation( "タイマは使用されていません。" );
\r
2499 //---------------------
\r
2501 #region [ Config.iniの出力 ]
\r
2502 //---------------------
\r
2503 Trace.TraceInformation("Config.ini を出力します。");
\r
2504 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
\r
2505 if ( ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped ) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
\r
2507 ConfigIni.SwapGuitarBassInfos_AutoFlags();
\r
2509 string str = strEXEのあるフォルダ + "Config.ini";
\r
2513 if ( DTXVmode.Enabled )
\r
2515 DTXVmode.tUpdateConfigIni();
\r
2516 Trace.TraceInformation( "DTXVモードの設定情報を、Config.iniに保存しました。" );
\r
2520 ConfigIni.t書き出し( str );
\r
2521 Trace.TraceInformation( "保存しました。({0})", str );
\r
2524 catch( Exception e )
\r
2526 Trace.TraceError( e.Message );
\r
2527 Trace.TraceError( "Config.ini の出力に失敗しました。({0})", str );
\r
2533 //---------------------
\r
2535 #region [ DTXVmodeの終了処理 ]
\r
2536 //---------------------
\r
2537 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
\r
2541 if ( DTXVmode != null )
\r
2544 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
\r
2548 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
\r
2553 //Trace.Unindent();
\r
2555 //---------------------
\r
2557 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
\r
2560 this.b終了処理完了済み = true;
\r
2563 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
\r
2565 bool bIsUpdatedDrums, bIsUpdatedGuitar, bIsUpdatedBass;
\r
2566 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
\r
2567 CScoreIni ini = new CScoreIni( strFilename );
\r
2568 if( !File.Exists( strFilename ) )
\r
2570 ini.stファイル.Title = DTX.TITLE;
\r
2571 ini.stファイル.Name = DTX.strファイル名;
\r
2572 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す( DTX.strファイル名の絶対パス );
\r
2573 for( int i = 0; i < 6; i++ )
\r
2575 ini.stセクション[ i ].nPerfectになる範囲ms = nPerfect範囲ms;
\r
2576 ini.stセクション[ i ].nGreatになる範囲ms = nGreat範囲ms;
\r
2577 ini.stセクション[ i ].nGoodになる範囲ms = nGood範囲ms;
\r
2578 ini.stセクション[ i ].nPoorになる範囲ms = nPoor範囲ms;
\r
2581 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
\r
2582 CScoreIni.t更新条件を取得する( out bIsUpdatedDrums, out bIsUpdatedGuitar, out bIsUpdatedBass );
\r
2583 if( bIsUpdatedDrums || bIsUpdatedGuitar || bIsUpdatedBass )
\r
2585 if( bIsUpdatedDrums )
\r
2587 ini.stファイル.PlayCountDrums++;
\r
2589 if( bIsUpdatedGuitar )
\r
2591 ini.stファイル.PlayCountGuitar++;
\r
2593 if( bIsUpdatedBass )
\r
2595 ini.stファイル.PlayCountBass++;
\r
2597 ini.tヒストリを追加する( str新ヒストリ行 );
\r
2600 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
\r
2601 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
\r
2602 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
\r
2603 for( int j = 0; j < ini.stファイル.History.Length; j++ )
\r
2605 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[ j ] = ini.stファイル.History[ j ];
\r
2609 if( ConfigIni.bScoreIniを出力する )
\r
2611 ini.t書き出し( strFilename );
\r
2616 private void tガベージコレクションを実行する()
\r
2619 GC.WaitForPendingFinalizers();
\r
2621 GC.WaitForPendingFinalizers();
\r
2623 private void tプラグイン検索と生成()
\r
2625 this.listプラグイン = new List<STPlugin>();
\r
2627 string strIPluginActivityの名前 = typeof( IPluginActivity ).FullName;
\r
2628 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
\r
2630 this.t指定フォルダ内でのプラグイン検索と生成( strプラグインフォルダパス, strIPluginActivityの名前 );
\r
2632 if( this.listプラグイン.Count > 0 )
\r
2633 Trace.TraceInformation( this.listプラグイン.Count + " 個のプラグインを読み込みました。" );
\r
2635 #region [ Windowイベント処理 ]
\r
2636 private void t指定フォルダ内でのプラグイン検索と生成( string strプラグインフォルダパス, string strプラグイン型名 )
\r
2638 // 指定されたパスが存在しないとエラー
\r
2639 if( !Directory.Exists( strプラグインフォルダパス ) )
\r
2641 Trace.TraceWarning( "プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")" );
\r
2645 // (1) すべての *.dll について…
\r
2646 string[] strDLLs = System.IO.Directory.GetFiles( strプラグインフォルダパス, "*.dll" );
\r
2647 foreach( string dllName in strDLLs )
\r
2651 // (1-1) dll をアセンブリとして読み込む。
\r
2652 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom( dllName );
\r
2654 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
\r
2655 foreach( Type t in asm.GetTypes() )
\r
2657 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
\r
2658 if( t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface( strプラグイン型名 ) != null )
\r
2660 // (1-4) クラス名からインスタンスを作成する
\r
2661 var st = new STPlugin() {
\r
2662 plugin = (IPluginActivity) asm.CreateInstance( t.FullName ),
\r
2663 strプラグインフォルダ = Path.GetDirectoryName( dllName ),
\r
2664 strアセンブリ簡易名 = asm.GetName().Name,
\r
2665 Version = asm.GetName().Version,
\r
2668 // (1-5) プラグインリストへ登録
\r
2669 this.listプラグイン.Add( st );
\r
2670 Trace.TraceInformation( "プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName( dllName ), st.strアセンブリ簡易名, st.Version.ToString() );
\r
2676 Trace.TraceInformation( dllName + " からプラグインを生成することに失敗しました。スキップします。" );
\r
2680 // (2) サブフォルダがあれば再帰する
\r
2681 string[] strDirs = Directory.GetDirectories( strプラグインフォルダパス, "*" );
\r
2682 foreach( string dir in strDirs )
\r
2683 this.t指定フォルダ内でのプラグイン検索と生成( dir + "\\", strプラグイン型名 );
\r
2685 //-----------------
\r
2686 private void Window_ApplicationActivated( object sender, EventArgs e )
\r
2688 this.bApplicationActive = true;
\r
2690 private void Window_ApplicationDeactivated( object sender, EventArgs e )
\r
2692 this.bApplicationActive = false;
\r
2694 private void Window_KeyDown( object sender, KeyEventArgs e )
\r
2696 if ( e.KeyCode == Keys.Menu )
\r
2699 e.SuppressKeyPress = true;
\r
2701 else if ( ( e.KeyCode == Keys.Return ) && e.Alt )
\r
2703 if ( ConfigIni != null )
\r
2705 ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
\r
2706 this.t全画面・ウィンドウモード切り替え();
\r
2709 e.SuppressKeyPress = true;
\r
2713 for ( int i = 0; i < 0x10; i++ )
\r
2715 if ( ConfigIni.KeyAssign.System.Capture[ i ].コード > 0 &&
\r
2716 e.KeyCode == DeviceConstantConverter.KeyToKeyCode( (SlimDX.DirectInput.Key) ConfigIni.KeyAssign.System.Capture[ i ].コード ) )
\r
2718 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
\r
2719 string strFullPath =
\r
2720 Path.Combine( CDTXMania.strEXEのあるフォルダ, "Capture_img" );
\r
2721 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
\r
2722 SaveResultScreen( strFullPath );
\r
2727 private void Window_MouseUp( object sender, MouseEventArgs e )
\r
2732 private void Window_MouseDoubleClick( object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
\r
2734 if ( mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen ) // #26752 2011.11.27 yyagi
\r
2736 ConfigIni.bウィンドウモード = false;
\r
2737 this.t全画面・ウィンドウモード切り替え();
\r
2740 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
\r
2742 if ( ConfigIni.bウィンドウモード )
\r
2744 ConfigIni.n初期ウィンドウ開始位置X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
\r
2745 ConfigIni.n初期ウィンドウ開始位置Y = base.Window.Location.Y; //
\r
2748 ConfigIni.nウインドウwidth = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
\r
2749 ConfigIni.nウインドウheight = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
\r
2753 //internal sealed class GCBeep // GC発生の度にbeep
\r
2757 // Console.Beep();
\r
2758 // if ( !AppDomain.CurrentDomain.IsFinalizingForUnload()
\r
2759 // && !Environment.HasShutdownStarted )
\r
2766 //-----------------
\r
2768 Stopwatch sw = new Stopwatch();
\r
2769 List<double> swlist;
\r