Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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