Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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