Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 513 - (show annotations) (download)
Mon Jan 4 06:10:50 2016 UTC (8 years, 3 months ago) by kairera0467
File size: 104993 byte(s)
#xxxxx 重大な不具合が判明したため、ギター画面でのスキルメーター機能を封印。
1 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 using DirectShowLib;
19
20 namespace DTXMania
21 {
22 internal class CDTXMania : Game
23 {
24 // プロパティ
25
26 public static readonly string VERSION = "Ver3.50(1601--)";
27 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 private set;
46 }
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 #region [ 入力範囲ms ]
104 public static int nPerfect範囲ms
105 {
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 }
164 #endregion
165 public static CPad Pad
166 {
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 public bool b汎用ムである = false;
268 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 // public static CTimer ct;
324 public IntPtr WindowHandle // 2012.10.24 yyagi; to add ASIO support
325 {
326 get { return base.Window.Handle; }
327 }
328 public static CDTXVmode DTXVmode // #28821 2014.1.23 yyagi
329 {
330 get;
331 set;
332 }
333 //fork
334 public static STDGBVALUE< List<int> > listAutoGhostLag = new STDGBVALUE<List<int>>();
335 public static STDGBVALUE< List<int> > listTargetGhsotLag = new STDGBVALUE<List<int>>();
336
337 // コンストラクタ
338
339 public CDTXMania()
340 {
341 CDTXMania.app = this;
342 this.t起動処理();
343 }
344
345
346 // メソッド
347
348 public void t全画面・ウィンドウモド切り替え()
349 {
350 #if WindowedFullscreen
351 if ( ConfigIni != null )
352 #else
353 DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
354 if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモ != settings.Windowed ) )
355 #endif
356 {
357 #if !WindowedFullscreen
358 settings.Windowed = ConfigIni.bウィンドウモ;
359 #endif
360 if ( ConfigIni.bウィンドウモ == false ) // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
361 {
362 currentClientSize = this.Window.ClientSize;
363 ConfigIni.nウインドウwidth = this.Window.ClientSize.Width;
364 ConfigIni.nウインドウheight = this.Window.ClientSize.Height;
365 // FDK.CTaskBar.ShowTaskBar( false );
366 }
367 #if !WindowedFullscreen
368 base.GraphicsDeviceManager.ChangeDevice( settings );
369 #endif
370 if ( ConfigIni.bウィンドウモ == true ) // #23510 2010.10.27 yyagi: to resume window size from backuped value
371 {
372 #if WindowedFullscreen
373 // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
374 // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
375 // in spite of using fullscreen mode.
376 app.Window.WindowState = FormWindowState.Normal;
377 app.Window.FormBorderStyle = FormBorderStyle.Sizable;
378 app.Window.WindowState = FormWindowState.Normal;
379 #endif
380 base.Window.ClientSize =
381 new Size( currentClientSize.Width, currentClientSize.Height );
382 // FDK.CTaskBar.ShowTaskBar( true );
383 }
384 #if WindowedFullscreen
385 else
386 {
387 app.Window.WindowState = FormWindowState.Normal;
388 app.Window.FormBorderStyle = FormBorderStyle.None;
389 app.Window.WindowState = FormWindowState.Maximized;
390 }
391 if ( ConfigIni.bウィンドウモ )
392 {
393 if ( !this.bマウスカソル表示中 )
394 {
395 Cursor.Show();
396 this.bマウスカソル表示中 = true;
397 }
398 }
399 else if ( this.bマウスカソル表示中 )
400 {
401 Cursor.Hide();
402 this.bマウスカソル表示中 = false;
403 }
404 #endif
405 }
406 }
407
408
409 #region [ #24609 リザルト画像をpngで保存する ] // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
410 /// <summary>
411 /// リザルト画像のキャプチャと保存。
412 /// </summary>
413 /// <param name="strFilename">保存するファイル名(フルパス)</param>
414 public bool SaveResultScreen( string strFullPath )
415 {
416 string strSavePath = Path.GetDirectoryName( strFullPath );
417 if ( !Directory.Exists( strSavePath ) )
418 {
419 try
420 {
421 Directory.CreateDirectory( strSavePath );
422 }
423 catch
424 {
425 return false;
426 }
427 }
428
429 // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
430 using ( Surface pSurface = CDTXMania.app.Device.GetRenderTarget( 0 ) )
431 {
432 Surface.ToFile( pSurface, strFullPath, ImageFileFormat.Png );
433 }
434 return true;
435 }
436 #endregion
437
438 // Game 実装
439 protected override void Initialize()
440 {
441 // new GCBeep();
442 sw.Start();
443 swlist = new List<double>( 8192 );
444 if( this.listトップレベルActivities != null )
445 {
446 foreach (CActivity activity in this.listトップレベルActivities)
447 {
448 activity.OnManagedリソスの作成();
449 }
450 }
451
452 foreach( STPlugin st in this.listプラグイン )
453 {
454 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
455 st.plugin.OnManagedリソスの作成();
456 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
457 }
458 #if GPUFlushAfterPresent
459 FrameEnd += dtxmania_FrameEnd;
460 #endif
461 }
462 #if GPUFlushAfterPresent
463 void dtxmania_FrameEnd( object sender, EventArgs e ) // GraphicsDeviceManager.game_FrameEnd()後に実行される
464 { // → Present()直後にGPUをFlushする
465 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
466 actFlushGPU.On進行描画(); // Flush GPU
467 }
468 #endif
469 protected override void LoadContent()
470 {
471 if ( ConfigIni.bウィンドウモ )
472 {
473 if( !this.bマウスカソル表示中 )
474 {
475 Cursor.Show();
476 this.bマウスカソル表示中 = true;
477 }
478 }
479 else if( this.bマウスカソル表示中 )
480 {
481 Cursor.Hide();
482 this.bマウスカソル表示中 = false;
483 }
484 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)));
485 this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
486 this.Device.SetRenderState( RenderState.Lighting, false );
487 this.Device.SetRenderState( RenderState.ZEnable, false );
488 this.Device.SetRenderState( RenderState.AntialiasedLineEnable, false );
489 this.Device.SetRenderState( RenderState.AlphaTestEnable, true );
490 this.Device.SetRenderState( RenderState.AlphaRef, 10 );
491
492 if (CDTXMania.ConfigIni.b縮小文字のアンチエイリアスを有効にする == true)
493 {
494 this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
495 this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
496 this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
497 }
498
499 this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
500 this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
501 this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
502 this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
503 this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
504 this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
505 this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
506
507 if( this.listトップレベルActivities != null )
508 {
509 foreach( CActivity activity in this.listトップレベルActivities )
510 activity.OnUnmanagedリソスの作成();
511 }
512
513 foreach( STPlugin st in this.listプラグイン )
514 {
515 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
516 st.plugin.OnUnmanagedリソスの作成();
517 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
518 }
519
520 }
521 protected override void UnloadContent()
522 {
523 if( this.listトップレベルActivities != null )
524 {
525 foreach( CActivity activity in this.listトップレベルActivities )
526 activity.OnUnmanagedリソスの解放();
527 }
528
529 foreach( STPlugin st in this.listプラグイン )
530 {
531 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
532 st.plugin.OnUnmanagedリソスの解放();
533 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
534 }
535 }
536 protected override void OnExiting( EventArgs e )
537 {
538 CPowerManagement.tEnableMonitorSuspend(); // スリープ抑止状態を解除
539 this.t終了処理();
540 base.OnExiting( e );
541 }
542 protected override void Update( GameTime gameTime )
543 {
544 }
545 protected override void Draw( GameTime gameTime )
546 {
547 Sound管理.t再生中の処理をする();
548
549 if( Timer != null )
550 Timer.t更新();
551
552 if ( CSound管理.rc演奏用タイマ != null )
553 CSound管理.rc演奏用タイマ.t更新();
554
555 if( Input管理 != null )
556 Input管理.tリング( this.bApplicationActive, CDTXMania.ConfigIni.bバッファ入力を行う );
557
558 if( FPS != null )
559 FPS.tカウンタ更新();
560
561 //if( Pad != null ) ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
562 // Pad.st検知したデバイス.Clear();
563
564 if( this.Device == null )
565 return;
566
567 if (this.bApplicationActive) // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
568 CPowerManagement.tDisableMonitorSuspend();
569
570 // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
571 #region [ スリープ ]
572 if ( ConfigIni.nフレム毎スリms >= 0 ) // #xxxxx 2011.11.27 yyagi
573 {
574 Thread.Sleep( ConfigIni.nフレム毎スリms );
575 }
576 #endregion
577
578 #region [ DTXCreatorからの指示 ]
579 if ( this.Window.IsReceivedMessage ) // ウインドウメッセージで、
580 {
581 string strMes = this.Window.strMessage;
582 this.Window.IsReceivedMessage = false;
583
584 if ( strMes != null )
585 {
586 DTXVmode.ParseArguments( strMes );
587
588 if ( DTXVmode.Enabled )
589 {
590 bコンパクトモ = true;
591 strコンパクトモドファイル = DTXVmode.filename;
592 if ( DTXVmode.Command == CDTXVmode.ECommand.Preview )
593 {
594 // preview soundの再生
595 string strPreviewFilename = DTXVmode.previewFilename;
596 //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
597 try
598 {
599 if ( this.previewSound != null )
600 {
601 this.previewSound.tサウンドを停止する();
602 this.previewSound.Dispose();
603 this.previewSound = null;
604 }
605 this.previewSound = CDTXMania.Sound管理.tサウンドを生成する( strPreviewFilename );
606 this.previewSound.n音量 = DTXVmode.previewVolume;
607 this.previewSound.n位置 = DTXVmode.previewPan;
608 this.previewSound.t再生を開始する();
609 Trace.TraceInformation( "DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename );
610 }
611 catch
612 {
613 Trace.TraceError( "DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename );
614 if ( this.previewSound != null )
615 {
616 this.previewSound.Dispose();
617 }
618 this.previewSound = null;
619 }
620 }
621 }
622 }
623 }
624 #endregion
625
626 this.Device.BeginScene();
627 this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, Color.Black, 1f, 0);
628
629 if( r現在のステ != null )
630 {
631 this.n進行描画の戻り値 = ( r現在のステ != null ) ? r現在のステ.On進行描画() : 0;
632
633 #region [ プラグインの進行描画 ]
634 //---------------------
635 foreach( STPlugin sp in this.listプラグイン )
636 {
637 Directory.SetCurrentDirectory( sp.strプラグインフォルダ );
638
639 if( CDTXMania.act現在入力を占有中のプラグイン == null || CDTXMania.act現在入力を占有中のプラグイン == sp.plugin )
640 sp.plugin.On進行描画( CDTXMania.Pad, CDTXMania.Input管理.Keyboard );
641 else
642 sp.plugin.On進行描画( null, null );
643
644 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
645 }
646 //---------------------
647 #endregion
648
649
650 CScoreIni scoreIni = null;
651
652 if( Control.IsKeyLocked( Keys.CapsLock ) ) // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
653 { // → songs.db等の書き込み時だと音切れするっぽい
654 actEnumSongs.On非活性化();
655 EnumSongs.SongListEnumCompletelyDone();
656 CDTXMania.stage選曲.bIsEnumeratingSongs = false;
657 }
658 #region [ 曲検索スレッドの起動/終了 ] // ここに"Enumerating Songs..."表示を集約
659 if (!CDTXMania.bコンパクトモ)
660 {
661 actEnumSongs.On進行描画(); // "Enumerating Songs..."アイコンの描画
662 } // "Enumerating Songs..."アイコンの描画
663 switch ( r現在のステ.eステID )
664 {
665 case CStage.Eステ.タイトル:
666 case CStage.Eステ.コンフィグ:
667 case CStage.Eステ.オプション:
668 case CStage.Eステ.選曲:
669 case CStage.Eステ.曲読み込み:
670 if ( EnumSongs != null )
671 {
672 DTXVmode.Refreshed = false; // 曲のリロード中に発生した再リロードは、無視する。
673 #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
674 if ( r現在のステ.eステID == CStage.Eステ.タイトル &&
675 r直前のステ.eステID == CStage.Eステ.起動 &&
676 this.n進行描画の戻り値 == (int) CStageタイトル.E戻り値.継続 &&
677 !EnumSongs.IsSongListEnumStarted )
678 {
679 actEnumSongs.On活性化();
680 CDTXMania.stage選曲.bIsEnumeratingSongs = true;
681 EnumSongs.Init( CDTXMania.Songs管理.listSongsDB, CDTXMania.Songs管理.nSongsDBから取得できたスコア数 ); // songs.db情報と、取得した曲数を、新インスタンスにも与える
682 EnumSongs.StartEnumFromDisk(); // 曲検索スレッドの起動・開始
683 if ( CDTXMania.Songs管理.nSongsDBから取得できたスコア数 == 0 ) // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
684 {
685 EnumSongs.ChangeEnumeratePriority( ThreadPriority.Normal );
686 }
687 }
688 #endregion
689
690 #region [ 曲検索の中断と再開 ]
691 if ( r現在のステ.eステID == CStage.Eステ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone )
692 {
693 switch ( this.n進行描画の戻り値 )
694 {
695 case 0: // 何もない
696 //if ( CDTXMania.stage選曲.bIsEnumeratingSongs )
697 if ( !CDTXMania.stage選曲.bIsPlayingPremovie || CDTXMania.Skin.ds選曲画面背景動画 != null )
698 {
699 EnumSongs.Resume(); // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
700 EnumSongs.IsSlowdown = false;
701 }
702 else
703 {
704 // EnumSongs.Suspend(); // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
705 EnumSongs.IsSlowdown = true;
706 }
707 actEnumSongs.On活性化();
708 break;
709
710 case 2: // 曲決定
711 EnumSongs.Suspend(); // #27060 バックグラウンドの曲検索を一時停止
712 actEnumSongs.On非活性化();
713 break;
714 }
715 }
716 #endregion
717
718 #region [ 曲探索中断待ち待機 ]
719 if ( r現在のステ.eステID == CStage.Eステ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
720 EnumSongs.thDTXFileEnumerate != null ) // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
721 {
722 EnumSongs.WaitUntilSuspended(); // 念のため、曲検索が一時中断されるまで待機
723 }
724 #endregion
725
726 #region [ 曲検索が完了したら、実際の曲リストに反映する ]
727 // CStage選曲.On活性化() に回した方がいいかな?
728 if ( EnumSongs.IsSongListEnumerated )
729 {
730 actEnumSongs.On非活性化();
731 CDTXMania.stage選曲.bIsEnumeratingSongs = false;
732
733 bool bRemakeSongTitleBar = ( r現在のステ.eステID == CStage.Eステ.選曲 ) ? true : false;
734 CDTXMania.stage選曲.Refresh( EnumSongs.Songs管理, bRemakeSongTitleBar );
735 EnumSongs.SongListEnumCompletelyDone();
736 }
737 #endregion
738 }
739 break;
740 }
741 #endregion
742
743 switch ( r現在のステ.eステID )
744 {
745 case CStage.Eステ.何もしない:
746 break;
747
748 case CStage.Eステ.起動:
749 #region [ *** ]
750 //-----------------------------
751 if( this.n進行描画の戻り値 != 0 )
752 {
753 if( !bコンパクトモ )
754 {
755 r現在のステ.On非活性化();
756 Trace.TraceInformation( "----------------------" );
757 Trace.TraceInformation( "■ タイトル" );
758 stageタイトル.On活性化();
759 r直前のステ = r現在のステ;
760 r現在のステ = stageタイトル;
761 }
762 else
763 {
764 r現在のステ.On非活性化();
765 Trace.TraceInformation( "----------------------" );
766 Trace.TraceInformation( "■ 曲読み込み" );
767 stage曲読み込み.On活性化();
768 r直前のステ = r現在のステ;
769 r現在のステ = stage曲読み込み;
770
771 }
772 foreach( STPlugin pg in this.listプラグイン )
773 {
774 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
775 pg.plugin.Onステジ変更();
776 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
777 }
778
779 this.tガベジコレクションを実行する();
780 }
781 //-----------------------------
782 #endregion
783 break;
784
785 case CStage.Eステ.タイトル:
786 #region [ *** ]
787 //-----------------------------
788 switch( this.n進行描画の戻り値 )
789 {
790 case (int)CStageタイトル.E戻り値.GAMESTART:
791 #region [ 選曲処理へ ]
792 //-----------------------------
793 r現在のステ.On非活性化();
794 Trace.TraceInformation( "----------------------" );
795 Trace.TraceInformation( "■ 選曲" );
796 stage選曲.On活性化();
797 r直前のステ = r現在のステ;
798 r現在のステ = stage選曲;
799 //-----------------------------
800 #endregion
801 break;
802
803 #region [ OPTION: 廃止済 ]
804 /*
805 case 2: // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
806 #region [ *** ]
807 //-----------------------------
808 r現在のステージ.On非活性化();
809 Trace.TraceInformation( "----------------------" );
810 Trace.TraceInformation( "■ オプション" );
811 stageオプション.On活性化();
812 r直前のステージ = r現在のステージ;
813 r現在のステージ = stageオプション;
814 //-----------------------------
815 #endregion
816 break;
817 */
818 #endregion
819
820 case (int)CStageタイトル.E戻り値.CONFIG:
821 #region [ *** ]
822 //-----------------------------
823 r現在のステ.On非活性化();
824 Trace.TraceInformation( "----------------------" );
825 Trace.TraceInformation( "■ コンフィグ" );
826 stageコンフィグ.On活性化();
827 r直前のステ = r現在のステ;
828 r現在のステ = stageコンフィグ;
829 //-----------------------------
830 #endregion
831 break;
832
833 case (int)CStageタイトル.E戻り値.EXIT:
834 #region [ *** ]
835 //-----------------------------
836 r現在のステ.On非活性化();
837 Trace.TraceInformation( "----------------------" );
838 Trace.TraceInformation( "■ 終了" );
839 stage終了.On活性化();
840 r直前のステ = r現在のステ;
841 r現在のステ = stage終了;
842 //-----------------------------
843 #endregion
844 break;
845 }
846
847 foreach( STPlugin pg in this.listプラグイン )
848 {
849 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
850 pg.plugin.Onステジ変更();
851 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
852 }
853
854 //this.tガベージコレクションを実行する(); // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
855 //-----------------------------
856 #endregion
857 break;
858
859
860 case CStage.Eステ.オプション:
861 #region [ *** ]
862 //-----------------------------
863 if( this.n進行描画の戻り値 != 0 )
864 {
865 switch( r直前のステ.eステID )
866 {
867 case CStage.Eステ.タイトル:
868 #region [ *** ]
869 //-----------------------------
870 r現在のステ.On非活性化();
871 Trace.TraceInformation( "----------------------" );
872 Trace.TraceInformation( "■ タイトル" );
873 stageタイトル.On活性化();
874 r直前のステ = r現在のステ;
875 r現在のステ = stageタイトル;
876
877 foreach( STPlugin pg in this.listプラグイン )
878 {
879 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
880 pg.plugin.Onステジ変更();
881 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
882 }
883
884 this.tガベジコレクションを実行する();
885 break;
886 //-----------------------------
887 #endregion
888
889 case CStage.Eステ.選曲:
890 #region [ *** ]
891 //-----------------------------
892 r現在のステ.On非活性化();
893 Trace.TraceInformation( "----------------------" );
894 Trace.TraceInformation( "■ 選曲" );
895 stage選曲.On活性化();
896 r直前のステ = r現在のステ;
897 r現在のステ = stage選曲;
898
899 foreach( STPlugin pg in this.listプラグイン )
900 {
901 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
902 pg.plugin.Onステジ変更();
903 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
904 }
905
906 this.tガベジコレクションを実行する();
907 break;
908 //-----------------------------
909 #endregion
910 }
911 }
912 //-----------------------------
913 #endregion
914 break;
915
916
917 case CStage.Eステ.コンフィグ:
918 #region [ *** ]
919 //-----------------------------
920 if( this.n進行描画の戻り値 != 0 )
921 {
922 switch( r直前のステ.eステID )
923 {
924 case CStage.Eステ.タイトル:
925 #region [ *** ]
926 //-----------------------------
927 r現在のステ.On非活性化();
928 Trace.TraceInformation( "----------------------" );
929 Trace.TraceInformation( "■ タイトル" );
930 stageタイトル.On活性化();
931 r直前のステ = r現在のステ;
932 r現在のステ = stageタイトル;
933
934 foreach( STPlugin pg in this.listプラグイン )
935 {
936 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
937 pg.plugin.Onステジ変更();
938 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
939 }
940
941 this.tガベジコレクションを実行する();
942 break;
943 //-----------------------------
944 #endregion
945
946 case CStage.Eステ.選曲:
947 #region [ *** ]
948 //-----------------------------
949 r現在のステ.On非活性化();
950 Trace.TraceInformation( "----------------------" );
951 Trace.TraceInformation( "■ 選曲" );
952 stage選曲.On活性化();
953 r直前のステ = r現在のステ;
954 r現在のステ = stage選曲;
955
956 foreach( STPlugin pg in this.listプラグイン )
957 {
958 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
959 pg.plugin.Onステジ変更();
960 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
961 }
962
963 this.tガベジコレクションを実行する();
964 break;
965 //-----------------------------
966 #endregion
967 }
968 }
969 //-----------------------------
970 #endregion
971 break;
972
973 case CStage.Eステ.選曲:
974 #region [ *** ]
975 //-----------------------------
976 switch( this.n進行描画の戻り値 )
977 {
978 case (int) CStage選曲.E戻り値.タイトルに戻る:
979 #region [ *** ]
980 //-----------------------------
981 r現在のステ.On非活性化();
982 Trace.TraceInformation( "----------------------" );
983 Trace.TraceInformation( "■ タイトル" );
984 stageタイトル.On活性化();
985 r直前のステ = r現在のステ;
986 r現在のステ = stageタイトル;
987
988 foreach( STPlugin pg in this.listプラグイン )
989 {
990 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
991 pg.plugin.Onステジ変更();
992 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
993 }
994
995 this.tガベジコレクションを実行する();
996 break;
997 //-----------------------------
998 #endregion
999
1000 case (int) CStage選曲.E戻り値.選曲した:
1001 #region [ *** ]
1002 //-----------------------------
1003 r現在のステ.On非活性化();
1004 Trace.TraceInformation( "----------------------" );
1005 Trace.TraceInformation( "■ 曲読み込み" );
1006 stage曲読み込み.On活性化();
1007 r直前のステ = r現在のステ;
1008 r現在のステ = stage曲読み込み;
1009
1010 foreach( STPlugin pg in this.listプラグイン )
1011 {
1012 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1013 pg.plugin.Onステジ変更();
1014 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1015 }
1016
1017 this.tガベジコレクションを実行する();
1018 break;
1019 //-----------------------------
1020 #endregion
1021
1022
1023 case (int) CStage選曲.E戻り値.オプション呼び出し:
1024 #region [ *** ]
1025 //-----------------------------
1026
1027 r現在のステ.On非活性化();
1028 Trace.TraceInformation( "----------------------" );
1029 Trace.TraceInformation( "■ オプション" );
1030 stageオプション.On活性化();
1031 r直前のステ = r現在のステ;
1032 r現在のステ = stageオプション;
1033
1034 foreach( STPlugin pg in this.listプラグイン )
1035 {
1036 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1037 pg.plugin.Onステジ変更();
1038 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1039 }
1040
1041 this.tガベジコレクションを実行する();
1042 break;
1043 //-----------------------------
1044 #endregion
1045
1046 case (int) CStage選曲.E戻り値.コンフィグ呼び出し:
1047 #region [ *** ]
1048 //-----------------------------
1049 r現在のステ.On非活性化();
1050 Trace.TraceInformation( "----------------------" );
1051 Trace.TraceInformation( "■ コンフィグ" );
1052 stageコンフィグ.On活性化();
1053 r直前のステ = r現在のステ;
1054 r現在のステ = stageコンフィグ;
1055
1056 foreach( STPlugin pg in this.listプラグイン )
1057 {
1058 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1059 pg.plugin.Onステジ変更();
1060 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1061 }
1062
1063 this.tガベジコレクションを実行する();
1064 break;
1065 //-----------------------------
1066 #endregion
1067
1068 case (int) CStage選曲.E戻り値.スキン変更:
1069
1070 #region [ *** ]
1071 //-----------------------------
1072 r現在のステ.On非活性化();
1073 Trace.TraceInformation( "----------------------" );
1074 Trace.TraceInformation( "■ スキン切り替え" );
1075 stageChangeSkin.On活性化();
1076 r直前のステ = r現在のステ;
1077 r現在のステ = stageChangeSkin;
1078 break;
1079 //-----------------------------
1080 #endregion
1081 }
1082 //-----------------------------
1083 #endregion
1084 break;
1085
1086 case CStage.Eステ.曲読み込み:
1087 #region [ *** ]
1088 //-----------------------------
1089 if( this.n進行描画の戻り値 != 0 )
1090 {
1091 CDTXMania.Pad.st検知したデバイス.Clear(); // 入力デバイスフラグクリア(2010.9.11)
1092
1093 r現在のステ.On非活性化();
1094
1095 #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1096 if ( this.n進行描画の戻り値 == (int) E曲読込画面の戻り値.読込中止 )
1097 {
1098 //DTX.t全チップの再生停止();
1099 DTX.On非活性化();
1100 Trace.TraceInformation( "曲の読み込みを中止しました。" );
1101 this.tガベジコレクションを実行する();
1102 Trace.TraceInformation( "----------------------" );
1103 Trace.TraceInformation( "■ 選曲" );
1104 stage選曲.On活性化();
1105 r直前のステ = r現在のステ;
1106 r現在のステ = stage選曲;
1107 foreach ( STPlugin pg in this.listプラグイン )
1108 {
1109 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1110 pg.plugin.Onステジ変更();
1111 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1112 }
1113 break;
1114 }
1115 #endregion
1116
1117
1118 if( !ConfigIni.bギタレボモ )
1119 {
1120 Trace.TraceInformation( "----------------------" );
1121 Trace.TraceInformation( "■ 演奏(ドラム画面)" );
1122 #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1123 for (int i = 0; i < 5; i++)
1124 {
1125 for (int j = 0; j < 2; j++)
1126 {
1127 stage演奏ドラム画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1128 }
1129 }
1130 for (int i = 0; i < 3; i++) {
1131 stage演奏ドラム画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1132 }
1133 #endif
1134 r直前のステ = r現在のステ;
1135 r現在のステ = stage演奏ドラム画面;
1136 }
1137 else
1138 {
1139 Trace.TraceInformation( "----------------------" );
1140 Trace.TraceInformation( "■ 演奏(ギター画面)" );
1141 #if false // #23625 2011.1.11 Config.iniからダメージ/回復値の定数変更を行う場合はここを有効にする 087リリースに合わせ機能無効化
1142 for (int i = 0; i < 5; i++)
1143 {
1144 for (int j = 0; j < 2; j++)
1145 {
1146 stage演奏ギタ画面.fDamageGaugeDelta[i, j] = ConfigIni.fGaugeFactor[i, j];
1147 }
1148 }
1149 for (int i = 0; i < 3; i++) {
1150 stage演奏ギタ画面.fDamageLevelFactor[i] = ConfigIni.fDamageLevelFactor[i];
1151 }
1152 #endif
1153 r直前のステ = r現在のステ;
1154 r現在のステ = stage演奏ギタ画面;
1155 }
1156
1157 foreach( STPlugin pg in this.listプラグイン )
1158 {
1159 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1160 pg.plugin.Onステジ変更();
1161 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1162 }
1163
1164 this.tガベジコレクションを実行する();
1165 }
1166 //-----------------------------
1167 #endregion
1168 break;
1169
1170 case CStage.Eステ.演奏:
1171 #region [ *** ]
1172 //-----------------------------
1173
1174 double n = (double)sw.ElapsedTicks / (double)Stopwatch.Frequency;
1175 swlist.Add(n);
1176
1177 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1178 if ( DTXVmode.Enabled && DTXVmode.Refreshed )
1179 {
1180 DTXVmode.Refreshed = false;
1181
1182 if ( DTXVmode.Command == CDTXVmode.ECommand.Stop )
1183 {
1184 if ( !ConfigIni.bギタレボモ )
1185 {
1186 CDTXMania.stage演奏ドラム画面.t停止();
1187 }
1188 else
1189 {
1190 CDTXMania.stage演奏ギタ画面.t停止();
1191 }
1192 if ( previewSound != null )
1193 {
1194 this.previewSound.tサウンドを停止する();
1195 this.previewSound.Dispose();
1196 this.previewSound = null;
1197 }
1198 }
1199 else if ( DTXVmode.Command == CDTXVmode.ECommand.Play )
1200 {
1201 if ( DTXVmode.NeedReload )
1202 {
1203 if ( !ConfigIni.bギタレボモ )
1204 {
1205 CDTXMania.stage演奏ドラム画面.t再読込();
1206 }
1207 else
1208 {
1209 CDTXMania.stage演奏ギタ画面.t再読込();
1210 }
1211
1212 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1213 CDTXMania.ConfigIni.bGuitar有効 = true;
1214 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1215 CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1216 if ( CDTXMania.ConfigIni.b垂直帰線待ちを行う != DTXVmode.VSyncWait )
1217 {
1218 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1219 CDTXMania.app.b次のタイミングで垂直帰線同期切り替えを行う = true;
1220 }
1221 }
1222 else
1223 {
1224 if ( !ConfigIni.bギタレボモ )
1225 {
1226 CDTXMania.stage演奏ドラム画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
1227 }
1228 else
1229 {
1230 CDTXMania.stage演奏ギタ画面.t演奏位置の変更( CDTXMania.DTXVmode.nStartBar );
1231 }
1232 }
1233 }
1234 }
1235 #endregion
1236
1237 switch( this.n進行描画の戻り値 )
1238 {
1239 case (int) E演奏画面の戻り値.再読込・再演奏:
1240 #region [ DTXファイルを再読み込みして、再演奏 ]
1241 DTX.t全チップの再生停止();
1242 DTX.On非活性化();
1243 r現在のステ.On非活性化();
1244 stage曲読み込み.On活性化();
1245 r直前のステ = r現在のステ;
1246 r現在のステ = stage曲読み込み;
1247 this.tガベジコレクションを実行する();
1248 break;
1249 #endregion
1250
1251 //case (int) E演奏画面の戻り値.再演奏:
1252 #region [ 再読み込み無しで、再演奏 ]
1253 #endregion
1254 // break;
1255
1256 case (int) E演奏画面の戻り値.継続:
1257 break;
1258
1259 case (int) E演奏画面の戻り値.演奏中断:
1260 #region [ 演奏キャンセル ]
1261 //-----------------------------
1262 scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Play canceled" );
1263
1264 double lastd = 0f;
1265 int f = 0;
1266 foreach ( double d in swlist )
1267 {
1268 double dif = d - lastd;
1269 string s = "";
1270 if ( 0.016 < dif && dif < 0.017 )
1271 {
1272 }
1273 else
1274 {
1275 s = "★";
1276 }
1277 //Trace.TraceInformation( "frame " + f + ": " + d + " (" + dif + ")" + s );
1278 lastd = d;
1279 f++;
1280 }
1281 swlist.Clear();
1282
1283 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1284 //---------------------
1285 foreach( STPlugin pg in this.listプラグイン )
1286 {
1287 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1288 pg.plugin.On演奏キャンセル( scoreIni );
1289 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1290 }
1291 //---------------------
1292 #endregion
1293
1294 DTX.t全チップの再生停止();
1295 DTX.On非活性化();
1296 r現在のステ.On非活性化();
1297 if( bコンパクトモ )
1298 {
1299 base.Window.Close();
1300 }
1301 else
1302 {
1303 Trace.TraceInformation( "----------------------" );
1304 Trace.TraceInformation( "■ 選曲" );
1305 stage選曲.On活性化();
1306 r直前のステ = r現在のステ;
1307 r現在のステ = stage選曲;
1308
1309 #region [ プラグイン Onステージ変更() の呼び出し ]
1310 //---------------------
1311 foreach( STPlugin pg in this.listプラグイン )
1312 {
1313 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1314 pg.plugin.Onステジ変更();
1315 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1316 }
1317 //---------------------
1318 #endregion
1319
1320 this.tガベジコレクションを実行する();
1321 }
1322 break;
1323 //-----------------------------
1324 #endregion
1325
1326 case (int) E演奏画面の戻り値.ステジ失敗:
1327 #region [ 演奏失敗(StageFailed) ]
1328 //-----------------------------
1329 scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( "Stage failed" );
1330
1331 #region [ プラグイン On演奏失敗() の呼び出し ]
1332 //---------------------
1333 foreach( STPlugin pg in this.listプラグイン )
1334 {
1335 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1336 pg.plugin.On演奏失敗( scoreIni );
1337 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1338 }
1339 //---------------------
1340 #endregion
1341
1342 DTX.t全チップの再生停止();
1343 DTX.On非活性化();
1344 r現在のステ.On非活性化();
1345 if( bコンパクトモ )
1346 {
1347 base.Window.Close();
1348 }
1349 else
1350 {
1351 Trace.TraceInformation( "----------------------" );
1352 Trace.TraceInformation( "■ 選曲" );
1353 stage選曲.On活性化();
1354 r直前のステ = r現在のステ;
1355 r現在のステ = stage選曲;
1356
1357 #region [ プラグイン Onステージ変更() の呼び出し ]
1358 //---------------------
1359 foreach( STPlugin pg in this.listプラグイン )
1360 {
1361 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1362 pg.plugin.Onステジ変更();
1363 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1364 }
1365 //---------------------
1366 #endregion
1367
1368 this.tガベジコレクションを実行する();
1369 }
1370 break;
1371 //-----------------------------
1372 #endregion
1373
1374 case (int) E演奏画面の戻り値.ステジクリア:
1375 #region [ 演奏クリア ]
1376 //-----------------------------
1377 CScoreIni.C演奏記録 c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass;
1378 CDTX.CChip[] chipArray = new CDTX.CChip[10];
1379 if( ConfigIni.bギタレボモ )
1380 {
1381 stage演奏ギタ画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass );
1382 }
1383 else
1384 {
1385 stage演奏ドラム画面.t演奏結果を格納する( out c演奏記録_Drums, out c演奏記録_Guitar, out c演奏記録_Bass, out chipArray );
1386 }
1387
1388 if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.24 yyagi Gt/Bsを入れ替えていたなら、演奏結果も入れ替える
1389 {
1390 CScoreIni.C演奏記録 t;
1391 t = c演奏記録_Guitar;
1392 c演奏記録_Guitar = c演奏記録_Bass;
1393 c演奏記録_Bass = t;
1394
1395 CDTXMania.DTX.SwapGuitarBassInfos(); // 譜面情報も元に戻す
1396 CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // #24415 2011.2.27 yyagi
1397 // リザルト集計時のみ、Auto系のフラグも元に戻す。
1398 // これを戻すのは、リザルト集計後。
1399 } // "case CStage.Eステージ.結果:"のところ。
1400
1401 double ps = 0.0, gs = 0.0;
1402 if ( !c演奏記録_Drums.bAUTOである && c演奏記録_Drums.n全チップ数 > 0) {
1403 ps = c演奏記録_Drums.db演奏型スキル値;
1404 gs = c演奏記録_Drums.dbム型スキル値;
1405 }
1406 else if ( !c演奏記録_Guitar.bAUTOである && c演奏記録_Guitar.n全チップ数 > 0) {
1407 ps = c演奏記録_Guitar.db演奏型スキル値;
1408 gs = c演奏記録_Guitar.dbム型スキル値;
1409 }
1410 else
1411 {
1412 ps = c演奏記録_Bass.db演奏型スキル値;
1413 gs = c演奏記録_Bass.dbム型スキル値;
1414 }
1415 string str = "Cleared";
1416 switch( CScoreIni.t総合ランク値を計算して返す( c演奏記録_Drums, c演奏記録_Guitar, c演奏記録_Bass ) )
1417 {
1418 case (int)CScoreIni.ERANK.SS:
1419 str = string.Format( "Cleared (SS: {0:F2})", ps );
1420 break;
1421
1422 case (int) CScoreIni.ERANK.S:
1423 str = string.Format( "Cleared (S: {0:F2})", ps );
1424 break;
1425
1426 case (int) CScoreIni.ERANK.A:
1427 str = string.Format( "Cleared (A: {0:F2})", ps );
1428 break;
1429
1430 case (int) CScoreIni.ERANK.B:
1431 str = string.Format( "Cleared (B: {0:F2})", ps );
1432 break;
1433
1434 case (int) CScoreIni.ERANK.C:
1435 str = string.Format( "Cleared (C: {0:F2})", ps );
1436 break;
1437
1438 case (int) CScoreIni.ERANK.D:
1439 str = string.Format( "Cleared (D: {0:F2})", ps );
1440 break;
1441
1442 case (int) CScoreIni.ERANK.E:
1443 str = string.Format( "Cleared (E: {0:F2})", ps );
1444 break;
1445
1446 case (int)CScoreIni.ERANK.UNKNOWN: // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1447 str = "Cleared (No chips)";
1448 break;
1449 }
1450
1451 scoreIni = this.tScoreIniBGMAdjustHistoryPlayCountを更新( str );
1452
1453 #region [ プラグイン On演奏クリア() の呼び出し ]
1454 //---------------------
1455 foreach( STPlugin pg in this.listプラグイン )
1456 {
1457 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1458 pg.plugin.On演奏クリア( scoreIni );
1459 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1460 }
1461 //---------------------
1462 #endregion
1463
1464 r現在のステ.On非活性化();
1465 Trace.TraceInformation( "----------------------" );
1466 Trace.TraceInformation( "■ 結果" );
1467 stage結果.st演奏記録.Drums = c演奏記録_Drums;
1468 stage結果.st演奏記録.Guitar = c演奏記録_Guitar;
1469 stage結果.st演奏記録.Bass = c演奏記録_Bass;
1470 stage結果.r空うちドラムチップ = chipArray;
1471 stage結果.On活性化();
1472 r直前のステ = r現在のステ;
1473 r現在のステ = stage結果;
1474
1475 #region [ プラグイン Onステージ変更() の呼び出し ]
1476 //---------------------
1477 foreach( STPlugin pg in this.listプラグイン )
1478 {
1479 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1480 pg.plugin.Onステジ変更();
1481 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1482 }
1483 //---------------------
1484 #endregion
1485
1486 break;
1487 //-----------------------------
1488 #endregion
1489 }
1490 //-----------------------------
1491 #endregion
1492 break;
1493
1494 case CStage.Eステ.結果:
1495 #region [ *** ]
1496 //-----------------------------
1497 if( this.n進行描画の戻り値 != 0 )
1498 {
1499 if ( CDTXMania.ConfigIni.bIsSwappedGuitarBass ) // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1500 {
1501 CDTXMania.ConfigIni.SwapGuitarBassInfos_AutoFlags(); // Auto入れ替え
1502 }
1503
1504 DTX.t全チップの再生一時停止();
1505 DTX.On非活性化();
1506 r現在のステ.On非活性化();
1507 if( !bコンパクトモ )
1508 {
1509 Trace.TraceInformation( "----------------------" );
1510 Trace.TraceInformation( "■ 選曲" );
1511 stage選曲.On活性化();
1512 r直前のステ = r現在のステ;
1513 r現在のステ = stage選曲;
1514
1515 foreach( STPlugin pg in this.listプラグイン )
1516 {
1517 Directory.SetCurrentDirectory( pg.strプラグインフォルダ );
1518 pg.plugin.Onステジ変更();
1519 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
1520 }
1521
1522 this.tガベジコレクションを実行する();
1523 }
1524 else
1525 {
1526 base.Window.Close();
1527 }
1528 }
1529 //-----------------------------
1530 #endregion
1531 break;
1532
1533 case CStage.Eステ.ChangeSkin:
1534 #region [ *** ]
1535 //-----------------------------
1536 if ( this.n進行描画の戻り値 != 0 )
1537 {
1538 r現在のステ.On非活性化();
1539 Trace.TraceInformation( "----------------------" );
1540 Trace.TraceInformation( "■ 選曲" );
1541 stage選曲.On活性化();
1542 r直前のステ = r現在のステ;
1543 r現在のステ = stage選曲;
1544 this.tガベジコレクションを実行する();
1545 }
1546 //-----------------------------
1547 #endregion
1548 break;
1549
1550 case CStage.Eステ.終了:
1551 #region [ *** ]
1552 //-----------------------------
1553 if( this.n進行描画の戻り値 != 0 )
1554 {
1555 base.Exit();
1556 }
1557 //-----------------------------
1558 #endregion
1559 break;
1560 }
1561 }
1562 this.Device.EndScene(); // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
1563 // (つまり、Present()は、Draw()完了後に実行される)
1564 #if !GPUFlushAfterPresent
1565 actFlushGPU.On進行描画(); // Flush GPU // EndScene()~Present()間 (つまりVSync前) でFlush実行
1566 #endif
1567 if ( Sound管理.GetCurrentSoundDeviceType() != "DirectSound" )
1568 {
1569 Sound管理.t再生中の処理をする(); // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
1570 }
1571
1572
1573 #region [ 全画面・ウインドウ切り替え ]
1574 if ( this.b次のタイミングで全画面・ウィンドウ切り替えを行う )
1575 {
1576 ConfigIni.b全画面モ = !ConfigIni.b全画面モ;
1577 app.t全画面・ウィンドウモド切り替え();
1578 this.b次のタイミングで全画面・ウィンドウ切り替えを行う = false;
1579 }
1580 #endregion
1581 #region [ 垂直基線同期切り替え ]
1582 if ( this.b次のタイミングで垂直帰線同期切り替えを行う )
1583 {
1584 bool bIsMaximized = this.Window.IsMaximized; // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
1585 currentClientSize = this.Window.ClientSize; // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
1586 DeviceSettings currentSettings = app.GraphicsDeviceManager.CurrentSettings;
1587 currentSettings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1588 app.GraphicsDeviceManager.ChangeDevice( currentSettings );
1589 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
1590 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height); // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
1591 if (bIsMaximized)
1592 {
1593 this.Window.WindowState = FormWindowState.Maximized; // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
1594 }
1595 }
1596 #endregion
1597 }
1598
1599
1600 // その他
1601
1602 #region [ 汎用ヘルパー ]
1603 //-----------------
1604 public static CTexture tテクスチャの生成( string fileName )
1605 {
1606 return tテクスチャの生成( fileName, false );
1607 }
1608 public static CTexture tテクスチャの生成( string fileName, bool b黒を透過する )
1609 {
1610 if ( app == null )
1611 {
1612 return null;
1613 }
1614 try
1615 {
1616 return new CTexture( app.Device, fileName, TextureFormat, b黒を透過する );
1617 }
1618 catch ( CTextureCreateFailedException )
1619 {
1620 Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1621 return null;
1622 }
1623 catch ( FileNotFoundException )
1624 {
1625 Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1626 return null;
1627 }
1628 }
1629 public static void tテクスチャの解放( ref CTexture tx )
1630 {
1631 if( tx != null )
1632 CDTXMania.t安全にDisposeする( ref tx );
1633 }
1634 public static void tテクスチャの解放( ref CTextureAf tx )
1635 {
1636 CDTXMania.t安全にDisposeする( ref tx );
1637 }
1638 public static CTexture tテクスチャの生成( byte[] txData )
1639 {
1640 return tテクスチャの生成( txData, false );
1641 }
1642 public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
1643 {
1644 if ( app == null )
1645 {
1646 return null;
1647 }
1648 try
1649 {
1650 return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
1651 }
1652 catch ( CTextureCreateFailedException )
1653 {
1654 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1655 return null;
1656 }
1657 }
1658
1659 public static CTexture tテクスチャの生成( Bitmap bitmap )
1660 {
1661 return tテクスチャの生成( bitmap, false );
1662 }
1663 public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
1664 {
1665 if ( app == null )
1666 {
1667 return null;
1668 }
1669 try
1670 {
1671 return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
1672 }
1673 catch ( CTextureCreateFailedException )
1674 {
1675 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1676 return null;
1677 }
1678 }
1679
1680 public static CTexture tテクスチャを生成する(int width, int height)
1681 {
1682 try
1683 {
1684 return new CTexture(CDTXMania.App.D3D9Device, width, height, CDTXMania.TextureFormat);
1685 }
1686 catch
1687 {
1688 Trace.TraceError("空のテクスチャ({0}x{1})の生成に失敗しました。", width, height);
1689 return null;
1690 }
1691 }
1692 public static CTextureAf tテクスチャの生成Af( string fileName )
1693 {
1694 return tテクスチャの生成Af( fileName, false );
1695 }
1696 public static CTextureAf tテクスチャの生成Af( string fileName, bool b黒を透過する )
1697 {
1698 if ( app == null )
1699 {
1700 return null;
1701 }
1702 try
1703 {
1704 return new CTextureAf( app.Device, fileName, TextureFormat, b黒を透過する );
1705 }
1706 catch ( CTextureCreateFailedException )
1707 {
1708 Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1709 return null;
1710 }
1711 catch ( FileNotFoundException )
1712 {
1713 Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1714 return null;
1715 }
1716 }
1717
1718 public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する(string fileName, IntPtr hWnd, bool bディオレンダラなし)
1719 {
1720 CDirectShow ds = null;
1721 if( File.Exists( fileName ) )
1722 {
1723 try
1724 {
1725 ds = new CDirectShow(fileName, hWnd, bディオレンダラなし);
1726 }
1727 catch (FileNotFoundException)
1728 {
1729 Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1730 ds = null; // Dispose はコンストラクタ内で実施済み
1731 }
1732 catch
1733 {
1734 Trace.TraceError("DirectShow の生成に失敗しました。[{0}]", fileName);
1735 ds = null; // Dispose はコンストラクタ内で実施済み
1736 }
1737 }
1738 else
1739 {
1740 Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1741 return null;
1742 }
1743
1744 return ds;
1745 }
1746
1747 /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
1748 public static void t安全にDisposeする<T>( ref T obj )
1749 {
1750 if ( obj == null )
1751 return;
1752
1753 var d = obj as IDisposable;
1754
1755 if ( d != null )
1756 d.Dispose();
1757
1758 obj = default( T );
1759 }
1760 //-----------------
1761 #endregion
1762 #region [ private ]
1763 //-----------------
1764 private bool bマウスカソル表示中 = true;
1765 public bool bウィンドウがアクティブである = true;
1766 private bool b終了処理完了済み;
1767 private static CDTX dtx;
1768 private List<CActivity> listトップレベルActivities;
1769 public int n進行描画の戻り値;
1770 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
1771 private string strWindowTitle
1772 {
1773 get
1774 {
1775 if ( DTXVmode.Enabled )
1776 {
1777 return "DTXViewer release " + VERSION;
1778 }
1779 else
1780 {
1781 return "DTXMania .NET style release " + VERSION;
1782 }
1783 }
1784 }
1785 private CSound previewSound;
1786
1787 private void t起動処理()
1788 {
1789 #region [ strEXEのあるフォルダを決定する ]
1790 //-----------------
1791 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
1792 #if DEBUG
1793 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
1794 #else
1795 strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
1796 #endif
1797 // END #23629 2010.11.13 from
1798 //-----------------
1799 #endregion
1800
1801 #region [ Config.ini の読込み ]
1802 //---------------------
1803 ConfigIni = new CConfigIni();
1804 string path = strEXEのあるフォルダ + "Config.ini";
1805 if( File.Exists( path ) )
1806 {
1807 try
1808 {
1809 ConfigIni.tファイルから読み込み( path );
1810 }
1811 catch
1812 {
1813 //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
1814 }
1815 }
1816 this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
1817 // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
1818
1819 //---------------------
1820 #endregion
1821 #region [ ログ出力開始 ]
1822 //---------------------
1823 Trace.AutoFlush = true;
1824 if( ConfigIni.bログ出力 )
1825 {
1826 try
1827 {
1828 Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( strEXEのあるフォルダ + "DTXManiaLog.txt", false, Encoding.GetEncoding( "shift-jis" ) ) ) );
1829 }
1830 catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
1831 {
1832 int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
1833 string[] mes_writeErr = {
1834 "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
1835 "Failed to write DTXManiaLog.txt. Please set it writable and try again."
1836 };
1837 MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
1838 Environment.Exit(1);
1839 }
1840 }
1841 Trace.WriteLine("");
1842 Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
1843 Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
1844 Trace.WriteLine( "" );
1845 Trace.TraceInformation( "----------------------" );
1846 Trace.TraceInformation( "■ アプリケーションの初期化" );
1847 Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
1848 Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
1849 Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
1850 //---------------------
1851 #endregion
1852 #region [ DTXVmodeクラス の初期化 ]
1853 //---------------------
1854 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
1855 //Trace.Indent();
1856 try
1857 {
1858 DTXVmode = new CDTXVmode();
1859 DTXVmode.Enabled = false;
1860 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
1861 }
1862 finally
1863 {
1864 //Trace.Unindent();
1865 }
1866 //---------------------
1867 #endregion
1868 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
1869 //---------------------
1870 bコンパクトモ = false;
1871 strコンパクトモドファイル = "";
1872 string[] commandLineArgs = Environment.GetCommandLineArgs();
1873 if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
1874 {
1875 bコンパクトモ = true;
1876 string arg = "";
1877
1878 for ( int i = 1; i < commandLineArgs.Length; i++ )
1879 {
1880 if ( i != 1 )
1881 {
1882 arg += " " + "\"" + commandLineArgs[ i ] + "\"";
1883 }
1884 else
1885 {
1886 arg += commandLineArgs[ i ];
1887 }
1888 }
1889 DTXVmode.ParseArguments( arg );
1890
1891 if ( DTXVmode.Enabled )
1892 {
1893 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
1894 strコンパクトモドファイル = DTXVmode.filename;
1895 switch( DTXVmode.soundDeviceType )
1896 {
1897 case ESoundDeviceType.DirectSound:
1898 ConfigIni.nSoundDeviceType = 0;
1899 break;
1900 case ESoundDeviceType.ExclusiveWASAPI:
1901 ConfigIni.nSoundDeviceType = 2;
1902 break;
1903 case ESoundDeviceType.ASIO:
1904 ConfigIni.nSoundDeviceType = 1;
1905 ConfigIni.nASIODevice = DTXVmode.nASIOdevice;
1906 break;
1907 }
1908
1909 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1910 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1911 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1912 CDTXMania.ConfigIni.bGuitar有効 = true;
1913 }
1914 else // 通常のコンパクトモード
1915 {
1916 strコンパクトモドファイル = commandLineArgs[ 1 ];
1917 }
1918
1919 if ( !File.Exists( strコンパクトモドファイル ) ) // #32985 2014.1.23 yyagi
1920 {
1921 Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモドファイル );
1922 #if DEBUG
1923 Environment.Exit( -1 );
1924 #else
1925 throw new FileNotFoundException( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモドファイル );
1926 #endif
1927 }
1928 if ( DTXVmode.Enabled )
1929 {
1930 Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモドファイル );
1931 }
1932 else
1933 {
1934 Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモドファイル );
1935 }
1936 }
1937 //---------------------
1938 #endregion
1939
1940 #region [ ウィンドウ初期化 ]
1941 //---------------------
1942 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1943 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1944
1945 base.Window.Text = this.strWindowTitle; // 事前にDTXVmodeの実体を作っておくこと
1946
1947
1948 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1949 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1950
1951 base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #34510 yyagi 2010.10.31 to change window size got from Config.ini
1952 #if !WindowedFullscreen
1953 if (!ConfigIni.bウィンドウモ) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
1954 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
1955 #endif
1956 currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );
1957 #if !WindowedFullscreen
1958 }
1959 #endif
1960 base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
1961 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
1962 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
1963 base.Window.ShowIcon = true;
1964 base.Window.Icon = Properties.Resources.dtx;
1965 base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
1966 base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
1967 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
1968 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
1969 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
1970 base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
1971 //---------------------
1972 #endregion
1973 #region [ Direct3D9Exを使うかどうか判定 ]
1974 #endregion
1975 #region [ Direct3D9 デバイスの生成 ]
1976 //---------------------
1977 DeviceSettings settings = new DeviceSettings();
1978 #if WindowedFullscreen
1979 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
1980 #else
1981 settings.Windowed = ConfigIni.bウィンドウモ;
1982 #endif
1983 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
1984 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
1985 // settings.BackBufferCount = 3;
1986 settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1987 // settings.BackBufferFormat = Format.A8R8G8B8;
1988 // settings.MultisampleType = MultisampleType.FourSamples;
1989 // settings.MultisampleQuality = 4;
1990 // settings.MultisampleType = MultisampleType.None;
1991 // settings.MultisampleQuality = 0;
1992
1993 try
1994 {
1995 base.GraphicsDeviceManager.ChangeDevice(settings);
1996 }
1997 catch (DeviceCreationException e)
1998 {
1999 Trace.TraceError(e.ToString());
2000 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
2001 Environment.Exit(-1);
2002 }
2003
2004 base.IsFixedTimeStep = false;
2005 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
2006 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.
2007 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォカス時スリms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
2008 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
2009 #if WindowedFullscreen
2010 this.t全画面・ウィンドウモド切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
2011 #endif
2012 actFlushGPU = new CActFlushGPU();
2013 //---------------------
2014 #endregion
2015
2016 DTX = null;
2017
2018 #region [ Skin の初期化 ]
2019 //---------------------
2020 Trace.TraceInformation( "スキンの初期化を行います。" );
2021 Trace.Indent();
2022 try
2023 {
2024 Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
2025 CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
2026 Trace.TraceInformation( "スキンの初期化を完了しました。" );
2027 }
2028 catch
2029 {
2030 Trace.TraceInformation( "スキンの初期化に失敗しました。" );
2031 throw;
2032 }
2033 finally
2034 {
2035 Trace.Unindent();
2036 }
2037 //---------------------
2038 #endregion
2039 #region [ Timer の初期化 ]
2040 //---------------------
2041 Trace.TraceInformation( "タイマの初期化を行います。" );
2042 Trace.Indent();
2043 try
2044 {
2045 Timer = new CTimer( CTimer.E種別.MultiMedia );
2046 Trace.TraceInformation( "タイマの初期化を完了しました。" );
2047 }
2048 finally
2049 {
2050 Trace.Unindent();
2051 }
2052 //---------------------
2053 #endregion
2054 #region [ FPS カウンタの初期化 ]
2055 //---------------------
2056 Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
2057 Trace.Indent();
2058 try
2059 {
2060 FPS = new CFPS();
2061 Trace.TraceInformation( "FPSカウンタを生成しました。" );
2062 }
2063 finally
2064 {
2065 Trace.Unindent();
2066 }
2067 //---------------------
2068 #endregion
2069 #region [ act文字コンソールの初期化 ]
2070 //---------------------
2071 Trace.TraceInformation( "文字コンソールの初期化を行います。" );
2072 Trace.Indent();
2073 try
2074 {
2075 act文字コンソ = new C文字コンソ();
2076 Trace.TraceInformation( "文字コンソールを生成しました。" );
2077 act文字コンソ.On活性化();
2078 Trace.TraceInformation( "文字コンソールを活性化しました。" );
2079 Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
2080 }
2081 catch( Exception exception )
2082 {
2083 Trace.TraceError( exception.Message );
2084 Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
2085 }
2086 finally
2087 {
2088 Trace.Unindent();
2089 }
2090 //---------------------
2091 #endregion
2092 #region [ Input管理 の初期化 ]
2093 //---------------------
2094 Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
2095 Trace.Indent();
2096 try
2097 {
2098 Input管理 = new CInput管理( base.Window.Handle );
2099 foreach( IInputDevice device in Input管理.list入力デバイス )
2100 {
2101 if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
2102 {
2103 int key = 0;
2104 while( ConfigIni.dicJoystick.ContainsKey( key ) )
2105 {
2106 key++;
2107 }
2108 ConfigIni.dicJoystick.Add( key, device.GUID );
2109 }
2110 }
2111 foreach( IInputDevice device2 in Input管理.list入力デバイス )
2112 {
2113 if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
2114 {
2115 foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
2116 {
2117 if( device2.GUID.Equals( pair.Value ) )
2118 {
2119 ( (CInputJoystick) device2 ).SetID( pair.Key );
2120 break;
2121 }
2122 }
2123 continue;
2124 }
2125 }
2126 Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
2127 }
2128 catch( Exception exception2 )
2129 {
2130 Trace.TraceError( exception2.Message );
2131 Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
2132 throw;
2133 }
2134 finally
2135 {
2136 Trace.Unindent();
2137 }
2138 //---------------------
2139 #endregion
2140 #region [ Pad の初期化 ]
2141 //---------------------
2142 Trace.TraceInformation( "パッドの初期化を行います。" );
2143 Trace.Indent();
2144 try
2145 {
2146 Pad = new CPad( ConfigIni, Input管理 );
2147 Trace.TraceInformation( "パッドの初期化を完了しました。" );
2148 }
2149 catch( Exception exception3 )
2150 {
2151 Trace.TraceError( exception3.Message );
2152 Trace.TraceError( "パッドの初期化に失敗しました。" );
2153 }
2154 finally
2155 {
2156 Trace.Unindent();
2157 }
2158 //---------------------
2159 #endregion
2160 #region [ Sound管理 の初期化 ]
2161 //---------------------
2162 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
2163 Trace.Indent();
2164 try
2165 {
2166 {
2167 ESoundDeviceType soundDeviceType;
2168 switch (CDTXMania.ConfigIni.nSoundDeviceType)
2169 {
2170 case 0:
2171 soundDeviceType = ESoundDeviceType.DirectSound;
2172 break;
2173 case 1:
2174 soundDeviceType = ESoundDeviceType.ASIO;
2175 break;
2176 case 2:
2177 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
2178 break;
2179 default:
2180 soundDeviceType = ESoundDeviceType.Unknown;
2181 break;
2182 }
2183 Sound管理 = new CSound管理( base.Window.Handle,
2184 soundDeviceType,
2185 CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
2186 //CDTXMania.ConfigIni.nASIOBufferSizeMs,
2187 0,
2188 CDTXMania.ConfigIni.nASIODevice
2189 );
2190 ShowWindowTitleWithSoundType();
2191 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
2192 Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;
2193 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;
2194 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
2195 }
2196 }
2197 catch (Exception e)
2198 {
2199 Trace.TraceError(e.Message);
2200 throw;
2201 }
2202 finally
2203 {
2204 Trace.Unindent();
2205 }
2206 //---------------------
2207 #endregion
2208 #region [ Songs管理 の初期化 ]
2209 //---------------------
2210 Trace.TraceInformation( "曲リストの初期化を行います。" );
2211 Trace.Indent();
2212 try
2213 {
2214 Songs管理 = new CSongs管理();
2215 // Songs管理_裏読 = new CSongs管理();
2216 EnumSongs = new CEnumSongs();
2217 actEnumSongs = new CActEnumSongs();
2218 Trace.TraceInformation( "曲リストの初期化を完了しました。" );
2219 }
2220 catch( Exception e )
2221 {
2222 Trace.TraceError( e.Message );
2223 Trace.TraceError( "曲リストの初期化に失敗しました。" );
2224 }
2225 finally
2226 {
2227 Trace.Unindent();
2228 }
2229 //---------------------
2230 #endregion
2231 #region [ CAvi の初期化 ]
2232 //---------------------
2233 CAvi.t初期化();
2234 //---------------------
2235 #endregion
2236 #region [ Random の初期化 ]
2237 //---------------------
2238 Random = new Random( (int) Timer.nシステム時刻 );
2239 //---------------------
2240 #endregion
2241 #region [ ステージの初期化 ]
2242 //---------------------
2243 r現在のステ = null;
2244 r直前のステ = null;
2245 stage起動 = new CStage起動();
2246 stageタイトル = new CStageタイトル();
2247 stageオプション = new CStageオプション();
2248 stageコンフィグ = new CStageコンフィグ();
2249 stage選曲 = new CStage選曲();
2250 stage曲読み込み = new CStage曲読み込み();
2251 stage演奏ドラム画面 = new CStage演奏ドラム画面();
2252 stage演奏ギタ画面 = new CStage演奏ギタ画面();
2253 stage結果 = new CStage結果();
2254 stageChangeSkin = new CStageChangeSkin();
2255 stage終了 = new CStage終了();
2256 this.listトップレベルActivities = new List<CActivity>();
2257 this.listトップレベルActivities.Add( actEnumSongs );
2258 this.listトップレベルActivities.Add( act文字コンソ );
2259 this.listトップレベルActivities.Add( stage起動 );
2260 this.listトップレベルActivities.Add( stageタイトル );
2261 this.listトップレベルActivities.Add( stageオプション );
2262 this.listトップレベルActivities.Add( stageコンフィグ );
2263 this.listトップレベルActivities.Add( stage選曲 );
2264 this.listトップレベルActivities.Add( stage曲読み込み );
2265 this.listトップレベルActivities.Add( stage演奏ドラム画面 );
2266 this.listトップレベルActivities.Add( stage演奏ギタ画面 );
2267 this.listトップレベルActivities.Add( stage結果 );
2268 this.listトップレベルActivities.Add( stageChangeSkin );
2269 this.listトップレベルActivities.Add( stage終了 );
2270 this.listトップレベルActivities.Add( actFlushGPU);
2271 //---------------------
2272 #endregion
2273 #region [ プラグインの検索と生成 ]
2274 //---------------------
2275 PluginHost = new CPluginHost();
2276
2277 Trace.TraceInformation( "プラグインの検索と生成を行います。" );
2278 Trace.Indent();
2279 try
2280 {
2281 this.tプラグイン検索と生成();
2282 Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
2283 }
2284 finally
2285 {
2286 Trace.Unindent();
2287 }
2288 //---------------------
2289 #endregion
2290 #region [ プラグインの初期化 ]
2291 //---------------------
2292 if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
2293 {
2294 Trace.TraceInformation( "プラグインの初期化を行います。" );
2295 Trace.Indent();
2296 try
2297 {
2298 foreach( STPlugin st in this.listプラグイン )
2299 {
2300 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2301 st.plugin.On初期化( this.PluginHost );
2302 st.plugin.OnManagedリソスの作成();
2303 st.plugin.OnUnmanagedリソスの作成();
2304 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2305 }
2306 Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
2307 }
2308 catch
2309 {
2310 Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
2311 throw;
2312 }
2313 finally
2314 {
2315 Trace.Unindent();
2316 }
2317 }
2318
2319 //---------------------
2320 #endregion
2321
2322
2323 Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );
2324
2325 #region [ 最初のステージの起動 ]
2326 //---------------------
2327 Trace.TraceInformation("----------------------");
2328 Trace.TraceInformation("■ 起動");
2329
2330 if (CDTXMania.bコンパクトモ)
2331 {
2332 r現在のステ = stage曲読み込み;
2333 }
2334 else
2335 {
2336 r現在のステ = stage起動;
2337 }
2338 r現在のステ.On活性化();
2339 //---------------------
2340 #endregion
2341 }
2342 public void ShowWindowTitleWithSoundType()
2343 {
2344 string delay = "";
2345 if (Sound管理.GetCurrentSoundDeviceType() != "DirectSound")
2346 {
2347 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2348 }
2349 base.Window.Text = strWindowTitle + " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2350 }
2351
2352 private void t終了処理()
2353 {
2354 if( !this.b終了処理完了済み )
2355 {
2356 Trace.TraceInformation( "----------------------" );
2357 Trace.TraceInformation( "■ アプリケーションの終了" );
2358 #region [ 曲検索の終了処理 ]
2359 //---------------------
2360 if ( actEnumSongs != null )
2361 {
2362 Trace.TraceInformation( "曲検索actの終了処理を行います。" );
2363 Trace.Indent();
2364 try
2365 {
2366 actEnumSongs.On非活性化();
2367 actEnumSongs= null;
2368 Trace.TraceInformation( "曲検索actの終了処理を完了しました。" );
2369 }
2370 catch ( Exception e )
2371 {
2372 Trace.TraceError( e.Message );
2373 Trace.TraceError( "曲検索actの終了処理に失敗しました。" );
2374 }
2375 finally
2376 {
2377 Trace.Unindent();
2378 }
2379 }
2380 //---------------------
2381 #endregion
2382 #region [ 現在のステージの終了処理 ]
2383 //---------------------
2384 if( CDTXMania.r現在のステ != null && CDTXMania.r現在のステ.b活性化してる ) // #25398 2011.06.07 MODIFY FROM
2385 {
2386 Trace.TraceInformation( "現在のステージを終了します。" );
2387 Trace.Indent();
2388 try
2389 {
2390 r現在のステ.On非活性化();
2391 Trace.TraceInformation( "現在のステージの終了処理を完了しました。" );
2392 }
2393 finally
2394 {
2395 Trace.Unindent();
2396 }
2397 }
2398 //---------------------
2399 #endregion
2400 #region [ プラグインの終了処理 ]
2401 //---------------------
2402 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2403 {
2404 Trace.TraceInformation( "すべてのプラグインを終了します。" );
2405 Trace.Indent();
2406 try
2407 {
2408 foreach( STPlugin st in this.listプラグイン )
2409 {
2410 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2411 st.plugin.OnUnmanagedリソスの解放();
2412 st.plugin.OnManagedリソスの解放();
2413 st.plugin.On終了();
2414 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2415 }
2416 PluginHost = null;
2417 Trace.TraceInformation( "すべてのプラグインの終了処理を完了しました。" );
2418 }
2419 finally
2420 {
2421 Trace.Unindent();
2422 }
2423 }
2424 //---------------------
2425 #endregion
2426 #region [ 曲リストの終了処理 ]
2427 //---------------------
2428 if (Songs管理 != null)
2429 {
2430 Trace.TraceInformation( "曲リストの終了処理を行います。" );
2431 Trace.Indent();
2432 try
2433 {
2434 Songs管理 = null;
2435 Trace.TraceInformation( "曲リストの終了処理を完了しました。" );
2436 }
2437 catch( Exception exception )
2438 {
2439 Trace.TraceError( exception.Message );
2440 Trace.TraceError( "曲リストの終了処理に失敗しました。" );
2441 }
2442 finally
2443 {
2444 Trace.Unindent();
2445 }
2446 }
2447 CAvi.t終了();
2448 //---------------------
2449 #endregion
2450 #region [ スキンの終了処理 ]
2451 //---------------------
2452 if (Skin != null)
2453 {
2454 Trace.TraceInformation( "スキンの終了処理を行います。" );
2455 Trace.Indent();
2456 try
2457 {
2458 Skin.Dispose();
2459 Skin = null;
2460 Trace.TraceInformation( "スキンの終了処理を完了しました。" );
2461 }
2462 catch( Exception exception2 )
2463 {
2464 Trace.TraceError( exception2.Message );
2465 Trace.TraceError( "スキンの終了処理に失敗しました。" );
2466 }
2467 finally
2468 {
2469 Trace.Unindent();
2470 }
2471 }
2472 //---------------------
2473 #endregion
2474 #region [ DirectSoundの終了処理 ]
2475 //---------------------
2476 if (Sound管理 != null)
2477 {
2478 Trace.TraceInformation( "DirectSound の終了処理を行います。" );
2479 Trace.Indent();
2480 try
2481 {
2482 Sound管理.Dispose();
2483 Sound管理 = null;
2484 Trace.TraceInformation( "DirectSound の終了処理を完了しました。" );
2485 }
2486 catch( Exception exception3 )
2487 {
2488 Trace.TraceError( exception3.Message );
2489 Trace.TraceError( "DirectSound の終了処理に失敗しました。" );
2490 }
2491 finally
2492 {
2493 Trace.Unindent();
2494 }
2495 }
2496 //---------------------
2497 #endregion
2498 #region [ パッドの終了処理 ]
2499 //---------------------
2500 if (Pad != null)
2501 {
2502 Trace.TraceInformation( "パッドの終了処理を行います。" );
2503 Trace.Indent();
2504 try
2505 {
2506 Pad = null;
2507 Trace.TraceInformation( "パッドの終了処理を完了しました。" );
2508 }
2509 catch( Exception exception4 )
2510 {
2511 Trace.TraceError( exception4.Message );
2512 Trace.TraceError( "パッドの終了処理に失敗しました。" );
2513 }
2514 finally
2515 {
2516 Trace.Unindent();
2517 }
2518 }
2519 //---------------------
2520 #endregion
2521 #region [ DirectInput, MIDI入力の終了処理 ]
2522 //---------------------
2523 if (Input管理 != null)
2524 {
2525 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を行います。" );
2526 Trace.Indent();
2527 try
2528 {
2529 Input管理.Dispose();
2530 Input管理 = null;
2531 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を完了しました。" );
2532 }
2533 catch( Exception exception5 )
2534 {
2535 Trace.TraceError( exception5.Message );
2536 Trace.TraceError( "DirectInput, MIDI入力の終了処理に失敗しました。" );
2537 }
2538 finally
2539 {
2540 Trace.Unindent();
2541 }
2542 }
2543 //---------------------
2544 #endregion
2545 #region [ 文字コンソールの終了処理 ]
2546 //---------------------
2547 if (act文字コンソ != null)
2548 {
2549 Trace.TraceInformation( "文字コンソールの終了処理を行います。" );
2550 Trace.Indent();
2551 try
2552 {
2553 act文字コンソ.On非活性化();
2554 act文字コンソ = null;
2555 Trace.TraceInformation( "文字コンソールの終了処理を完了しました。" );
2556 }
2557 catch( Exception exception6 )
2558 {
2559 Trace.TraceError( exception6.Message );
2560 Trace.TraceError( "文字コンソールの終了処理に失敗しました。" );
2561 }
2562 finally
2563 {
2564 Trace.Unindent();
2565 }
2566 }
2567 //---------------------
2568 #endregion
2569 #region [ FPSカウンタの終了処理 ]
2570 //---------------------
2571 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2572 Trace.Indent();
2573 try
2574 {
2575 if( FPS != null )
2576 {
2577 FPS = null;
2578 }
2579 Trace.TraceInformation( "FPSカウンタの終了処理を完了しました。" );
2580 }
2581 finally
2582 {
2583 Trace.Unindent();
2584 }
2585 //---------------------
2586 #endregion
2587
2588 // ct.Dispose();
2589
2590 #region [ タイマの終了処理 ]
2591 //---------------------
2592 Trace.TraceInformation("タイマの終了処理を行います。");
2593 Trace.Indent();
2594 try
2595 {
2596 if( Timer != null )
2597 {
2598 Timer.Dispose();
2599 Timer = null;
2600
2601 Trace.TraceInformation( "タイマの終了処理を完了しました。" );
2602 }
2603 else
2604 {
2605 Trace.TraceInformation( "タイマは使用されていません。" );
2606 }
2607 }
2608 finally
2609 {
2610 Trace.Unindent();
2611 }
2612 //---------------------
2613 #endregion
2614 #region [ Config.iniの出力 ]
2615 //---------------------
2616 Trace.TraceInformation("Config.ini を出力します。");
2617 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2618 if ( ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped ) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2619 {
2620 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2621 }
2622 string str = strEXEのあるフォルダ + "Config.ini";
2623 Trace.Indent();
2624 try
2625 {
2626 if ( DTXVmode.Enabled )
2627 {
2628 DTXVmode.tUpdateConfigIni();
2629 Trace.TraceInformation( "DTXVモードの設定情報を、Config.iniに保存しました。" );
2630 }
2631 else
2632 {
2633 ConfigIni.t書き出し( str );
2634 Trace.TraceInformation( "保存しました。({0})", str );
2635 }
2636 }
2637 catch( Exception e )
2638 {
2639 Trace.TraceError( e.Message );
2640 Trace.TraceError( "Config.ini の出力に失敗しました。({0})", str );
2641 }
2642 finally
2643 {
2644 Trace.Unindent();
2645 }
2646 //---------------------
2647 #endregion
2648 #region [ DTXVmodeの終了処理 ]
2649 //---------------------
2650 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2651 //Trace.Indent();
2652 try
2653 {
2654 if ( DTXVmode != null )
2655 {
2656 DTXVmode = null;
2657 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2658 }
2659 else
2660 {
2661 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2662 }
2663 }
2664 finally
2665 {
2666 //Trace.Unindent();
2667 }
2668 //---------------------
2669 #endregion
2670 Trace.TraceInformation("アプリケーションの終了処理を完了しました。");
2671
2672
2673 this.b終了処理完了済み = true;
2674 }
2675 }
2676
2677 private CScoreIni tScoreIniBGMAdjustHistoryPlayCountを更新(string str新ヒストリ行)
2678 {
2679 bool bIsUpdatedDrums, bIsUpdatedGuitar, bIsUpdatedBass;
2680 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2681 CScoreIni ini = new CScoreIni( strFilename );
2682 if( !File.Exists( strFilename ) )
2683 {
2684 ini.stファイル.Title = DTX.TITLE;
2685 ini.stファイル.Name = DTX.strファイル名;
2686 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す( DTX.strファイル名の絶対パス );
2687 for( int i = 0; i < 6; i++ )
2688 {
2689 ini.stセクション[ i ].nPerfectになる範囲ms = nPerfect範囲ms;
2690 ini.stセクション[ i ].nGreatになる範囲ms = nGreat範囲ms;
2691 ini.stセクション[ i ].nGoodになる範囲ms = nGood範囲ms;
2692 ini.stセクション[ i ].nPoorになる範囲ms = nPoor範囲ms;
2693 }
2694 }
2695 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2696 CScoreIni.t更新条件を取得する( out bIsUpdatedDrums, out bIsUpdatedGuitar, out bIsUpdatedBass );
2697 if( bIsUpdatedDrums || bIsUpdatedGuitar || bIsUpdatedBass )
2698 {
2699 if( bIsUpdatedDrums )
2700 {
2701 ini.stファイル.PlayCountDrums++;
2702 }
2703 if( bIsUpdatedGuitar )
2704 {
2705 ini.stファイル.PlayCountGuitar++;
2706 }
2707 if( bIsUpdatedBass )
2708 {
2709 ini.stファイル.PlayCountBass++;
2710 }
2711 ini.tヒストリを追加する( str新ヒストリ行 );
2712 if( !bコンパクトモ )
2713 {
2714 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2715 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2716 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2717 for( int j = 0; j < ini.stファイル.History.Length; j++ )
2718 {
2719 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[ j ] = ini.stファイル.History[ j ];
2720 }
2721 }
2722 }
2723 if( ConfigIni.bScoreIniを出力する )
2724 {
2725 ini.t書き出し( strFilename );
2726 }
2727
2728 return ini;
2729 }
2730 private void tガベジコレクションを実行する()
2731 {
2732 GC.Collect();
2733 GC.WaitForPendingFinalizers();
2734 GC.Collect();
2735 GC.WaitForPendingFinalizers();
2736 }
2737 private void tプラグイン検索と生成()
2738 {
2739 this.listプラグイン = new List<STPlugin>();
2740
2741 string strIPluginActivityの名前 = typeof( IPluginActivity ).FullName;
2742 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2743
2744 this.t指定フォルダ内でのプラグイン検索と生成( strプラグインフォルダパス, strIPluginActivityの名前 );
2745
2746 if( this.listプラグイン.Count > 0 )
2747 Trace.TraceInformation( this.listプラグイン.Count + " 個のプラグインを読み込みました。" );
2748 }
2749 #region [ Windowイベント処理 ]
2750 private void t指定フォルダ内でのプラグイン検索と生成( string strプラグインフォルダパス, string strプラグイン型名 )
2751 {
2752 // 指定されたパスが存在しないとエラー
2753 if( !Directory.Exists( strプラグインフォルダパス ) )
2754 {
2755 Trace.TraceWarning( "プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")" );
2756 return;
2757 }
2758
2759 // (1) すべての *.dll について…
2760 string[] strDLLs = System.IO.Directory.GetFiles( strプラグインフォルダパス, "*.dll" );
2761 foreach( string dllName in strDLLs )
2762 {
2763 try
2764 {
2765 // (1-1) dll をアセンブリとして読み込む。
2766 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom( dllName );
2767
2768 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2769 foreach( Type t in asm.GetTypes() )
2770 {
2771 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2772 if( t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface( strプラグイン型名 ) != null )
2773 {
2774 // (1-4) クラス名からインスタンスを作成する
2775 var st = new STPlugin() {
2776 plugin = (IPluginActivity) asm.CreateInstance( t.FullName ),
2777 strプラグインフォルダ = Path.GetDirectoryName( dllName ),
2778 strアセンブリ簡易名 = asm.GetName().Name,
2779 Version = asm.GetName().Version,
2780 };
2781
2782 // (1-5) プラグインリストへ登録
2783 this.listプラグイン.Add( st );
2784 Trace.TraceInformation( "プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName( dllName ), st.strアセンブリ簡易名, st.Version.ToString() );
2785 }
2786 }
2787 }
2788 catch
2789 {
2790 Trace.TraceInformation( dllName + " からプラグインを生成することに失敗しました。スキップします。" );
2791 }
2792 }
2793
2794 // (2) サブフォルダがあれば再帰する
2795 string[] strDirs = Directory.GetDirectories( strプラグインフォルダパス, "*" );
2796 foreach( string dir in strDirs )
2797 this.t指定フォルダ内でのプラグイン検索と生成( dir + "\\", strプラグイン型名 );
2798 }
2799 //-----------------
2800 private void Window_ApplicationActivated(object sender, EventArgs e)
2801 {
2802 this.bApplicationActive = true;
2803 }
2804 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2805 {
2806 this.bApplicationActive = false;
2807 }
2808 private void Window_KeyDown(object sender, KeyEventArgs e)
2809 {
2810 if (e.KeyCode == Keys.Menu)
2811 {
2812 e.Handled = true;
2813 e.SuppressKeyPress = true;
2814 }
2815 else if ((e.KeyCode == Keys.Return) && e.Alt)
2816 {
2817 if (ConfigIni != null)
2818 {
2819 ConfigIni.bウィンドウモ = !ConfigIni.bウィンドウモ;
2820 this.t全画面・ウィンドウモド切り替え();
2821 }
2822 e.Handled = true;
2823 e.SuppressKeyPress = true;
2824 }
2825 else
2826 {
2827 for (int i = 0; i < 0x10; i++)
2828 {
2829 if (ConfigIni.KeyAssign.System.Capture[i]. > 0 &&
2830 e.KeyCode == DeviceConstantConverter.KeyToKeyCode((SlimDX.DirectInput.Key)ConfigIni.KeyAssign.System.Capture[i].))
2831 {
2832 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2833 string strFullPath =
2834 Path.Combine(CDTXMania.strEXEのあるフォルダ, "Capture_img");
2835 strFullPath = Path.Combine(strFullPath, DateTime.Now.ToString("yyyyMMddHHmmss") + ".png");
2836 SaveResultScreen(strFullPath);
2837 }
2838 }
2839 }
2840 }
2841 private void Window_MouseUp(object sender, MouseEventArgs e)
2842 {
2843 mb = e.Button;
2844 }
2845
2846 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
2847 {
2848 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
2849 {
2850 ConfigIni.bウィンドウモ = false;
2851 this.t全画面・ウィンドウモド切り替え();
2852 }
2853 }
2854 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
2855 {
2856 if (ConfigIni.bウィンドウモ)
2857 {
2858 ConfigIni.n初期ウィンドウ開始位置X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2859 ConfigIni.n初期ウィンドウ開始位置Y = base.Window.Location.Y; //
2860 }
2861
2862 ConfigIni.nウインドウwidth = (ConfigIni.bウィンドウモ) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
2863 ConfigIni.nウインドウheight = (ConfigIni.bウィンドウモ) ? base.Window.ClientSize.Height : currentClientSize.Height;
2864 }
2865 #endregion
2866
2867 //internal sealed class GCBeep // GC発生の度にbeep
2868 //{
2869 // ~GCBeep()
2870 // {
2871 // Console.Beep();
2872 // if ( !AppDomain.CurrentDomain.IsFinalizingForUnload()
2873 // && !Environment.HasShutdownStarted )
2874 // {
2875 // new GCBeep();
2876 // }
2877 // }
2878 //}
2879
2880 //-----------------
2881
2882 Stopwatch sw = new Stopwatch();
2883 List<double> swlist;
2884
2885 #endregion
2886 }
2887 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26