Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 430 - (show annotations) (download)
Sat Jan 24 06:14:19 2015 UTC (9 years, 2 months ago) by kairera0467
File size: 104785 byte(s)
#34831 とりあえずそれらしい項目を用意。
#34803 修正。
#xxxxx リバース時にワイリングさせた時の座標を調整。
#xxxxx 本家DTXManiaからテクスチャの最適化メソッドを移植。
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.30(141231)";
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 public static void tテクスチャの解放( ref CTextureAf tx )
1632 {
1633 CDTXMania.t安全にDisposeする( ref tx );
1634 }
1635 public static CTexture tテクスチャの生成( byte[] txData )
1636 {
1637 return tテクスチャの生成( txData, false );
1638 }
1639 public static CTexture tテクスチャの生成( byte[] txData, bool b黒を透過する )
1640 {
1641 if ( app == null )
1642 {
1643 return null;
1644 }
1645 try
1646 {
1647 return new CTexture( app.Device, txData, TextureFormat, b黒を透過する );
1648 }
1649 catch ( CTextureCreateFailedException )
1650 {
1651 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1652 return null;
1653 }
1654 }
1655
1656 public static CTexture tテクスチャの生成( Bitmap bitmap )
1657 {
1658 return tテクスチャの生成( bitmap, false );
1659 }
1660 public static CTexture tテクスチャの生成( Bitmap bitmap, bool b黒を透過する )
1661 {
1662 if ( app == null )
1663 {
1664 return null;
1665 }
1666 try
1667 {
1668 return new CTexture( app.Device, bitmap, TextureFormat, b黒を透過する );
1669 }
1670 catch ( CTextureCreateFailedException )
1671 {
1672 Trace.TraceError( "テクスチャの生成に失敗しました。(txData)" );
1673 return null;
1674 }
1675 }
1676
1677 public static CTexture tテクスチャを生成する(int width, int height)
1678 {
1679 try
1680 {
1681 return new CTexture(CDTXMania.App.D3D9Device, width, height, CDTXMania.TextureFormat);
1682 }
1683 catch
1684 {
1685 Trace.TraceError("空のテクスチャ({0}x{1})の生成に失敗しました。", width, height);
1686 return null;
1687 }
1688 }
1689 public static CTextureAf tテクスチャの生成Af( string fileName )
1690 {
1691 return tテクスチャの生成Af( fileName, false );
1692 }
1693 public static CTextureAf tテクスチャの生成Af( string fileName, bool b黒を透過する )
1694 {
1695 if ( app == null )
1696 {
1697 return null;
1698 }
1699 try
1700 {
1701 return new CTextureAf( app.Device, fileName, TextureFormat, b黒を透過する );
1702 }
1703 catch ( CTextureCreateFailedException )
1704 {
1705 Trace.TraceError( "テクスチャの生成に失敗しました。({0})", fileName );
1706 return null;
1707 }
1708 catch ( FileNotFoundException )
1709 {
1710 Trace.TraceError( "テクスチャファイルが見つかりませんでした。({0})", fileName );
1711 return null;
1712 }
1713 }
1714
1715 public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する(string fileName, IntPtr hWnd, bool bディオレンダラなし)
1716 {
1717 CDirectShow ds = null;
1718 if( File.Exists( fileName ) )
1719 {
1720 try
1721 {
1722 ds = new CDirectShow(fileName, hWnd, bディオレンダラなし);
1723 }
1724 catch (FileNotFoundException)
1725 {
1726 Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1727 ds = null; // Dispose はコンストラクタ内で実施済み
1728 }
1729 catch
1730 {
1731 Trace.TraceError("DirectShow の生成に失敗しました。[{0}]", fileName);
1732 ds = null; // Dispose はコンストラクタ内で実施済み
1733 }
1734 }
1735 else
1736 {
1737 Trace.TraceError("動画ファイルが見つかりませんでした。({0})", fileName);
1738 return null;
1739 }
1740
1741 return ds;
1742 }
1743
1744 /// <summary>プロパティ、インデクサには ref は使用できないので注意。</summary>
1745 public static void t安全にDisposeする<T>( ref T obj )
1746 {
1747 if ( obj == null )
1748 return;
1749
1750 var d = obj as IDisposable;
1751
1752 if ( d != null )
1753 d.Dispose();
1754
1755 obj = default( T );
1756 }
1757 //-----------------
1758 #endregion
1759 #region [ private ]
1760 //-----------------
1761 private bool bマウスカソル表示中 = true;
1762 public bool bウィンドウがアクティブである = true;
1763 private bool b終了処理完了済み;
1764 private static CDTX dtx;
1765 private List<CActivity> listトップレベルActivities;
1766 public int n進行描画の戻り値;
1767 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
1768 private string strWindowTitle
1769 {
1770 get
1771 {
1772 if ( DTXVmode.Enabled )
1773 {
1774 return "DTXViewer release " + VERSION;
1775 }
1776 else
1777 {
1778 return "DTXMania .NET style release " + VERSION;
1779 }
1780 }
1781 }
1782 private CSound previewSound;
1783
1784 private void t起動処理()
1785 {
1786 #region [ strEXEのあるフォルダを決定する ]
1787 //-----------------
1788 // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
1789 #if DEBUG
1790 strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
1791 #else
1792 strEXEのあるフォルダ = Path.GetDirectoryName( Application.ExecutablePath ) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
1793 #endif
1794 // END #23629 2010.11.13 from
1795 //-----------------
1796 #endregion
1797
1798 #region [ Config.ini の読込み ]
1799 //---------------------
1800 ConfigIni = new CConfigIni();
1801 string path = strEXEのあるフォルダ + "Config.ini";
1802 if( File.Exists( path ) )
1803 {
1804 try
1805 {
1806 ConfigIni.tファイルから読み込み( path );
1807 }
1808 catch
1809 {
1810 //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
1811 }
1812 }
1813 this.Window.EnableSystemMenu = CDTXMania.ConfigIni.bIsEnabledSystemMenu; // #28200 2011.5.1 yyagi
1814 // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
1815
1816 //---------------------
1817 #endregion
1818 #region [ ログ出力開始 ]
1819 //---------------------
1820 Trace.AutoFlush = true;
1821 if( ConfigIni.bログ出力 )
1822 {
1823 try
1824 {
1825 Trace.Listeners.Add( new CTraceLogListener( new StreamWriter( strEXEのあるフォルダ + "DTXManiaLog.txt", false, Encoding.GetEncoding( "shift-jis" ) ) ) );
1826 }
1827 catch ( System.UnauthorizedAccessException ) // #24481 2011.2.20 yyagi
1828 {
1829 int c = (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja")? 0 : 1;
1830 string[] mes_writeErr = {
1831 "DTXManiaLog.txtへの書き込みができませんでした。書き込みできるようにしてから、再度起動してください。",
1832 "Failed to write DTXManiaLog.txt. Please set it writable and try again."
1833 };
1834 MessageBox.Show( mes_writeErr[c], "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error );
1835 Environment.Exit(1);
1836 }
1837 }
1838 Trace.WriteLine("");
1839 Trace.WriteLine( "DTXMania powered by YAMAHA Silent Session Drums" );
1840 Trace.WriteLine( string.Format( "Release: {0}", VERSION ) );
1841 Trace.WriteLine( "" );
1842 Trace.TraceInformation( "----------------------" );
1843 Trace.TraceInformation( "■ アプリケーションの初期化" );
1844 Trace.TraceInformation( "OS Version: " + Environment.OSVersion );
1845 Trace.TraceInformation( "ProcessorCount: " + Environment.ProcessorCount.ToString() );
1846 Trace.TraceInformation( "CLR Version: " + Environment.Version.ToString() );
1847 //---------------------
1848 #endregion
1849 #region [ DTXVmodeクラス の初期化 ]
1850 //---------------------
1851 //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
1852 //Trace.Indent();
1853 try
1854 {
1855 DTXVmode = new CDTXVmode();
1856 DTXVmode.Enabled = false;
1857 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
1858 }
1859 finally
1860 {
1861 //Trace.Unindent();
1862 }
1863 //---------------------
1864 #endregion
1865 #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
1866 //---------------------
1867 bコンパクトモ = false;
1868 strコンパクトモドファイル = "";
1869 string[] commandLineArgs = Environment.GetCommandLineArgs();
1870 if( ( commandLineArgs != null ) && ( commandLineArgs.Length > 1 ) )
1871 {
1872 bコンパクトモ = true;
1873 string arg = "";
1874
1875 for ( int i = 1; i < commandLineArgs.Length; i++ )
1876 {
1877 if ( i != 1 )
1878 {
1879 arg += " " + "\"" + commandLineArgs[ i ] + "\"";
1880 }
1881 else
1882 {
1883 arg += commandLineArgs[ i ];
1884 }
1885 }
1886 DTXVmode.ParseArguments( arg );
1887
1888 if ( DTXVmode.Enabled )
1889 {
1890 DTXVmode.Refreshed = false; // 初回起動時は再読み込みに走らせない
1891 strコンパクトモドファイル = DTXVmode.filename;
1892 switch( DTXVmode.soundDeviceType )
1893 {
1894 case ESoundDeviceType.DirectSound:
1895 ConfigIni.nSoundDeviceType = 0;
1896 break;
1897 case ESoundDeviceType.ExclusiveWASAPI:
1898 ConfigIni.nSoundDeviceType = 2;
1899 break;
1900 case ESoundDeviceType.ASIO:
1901 ConfigIni.nSoundDeviceType = 1;
1902 ConfigIni.nASIODevice = DTXVmode.nASIOdevice;
1903 break;
1904 }
1905
1906 CDTXMania.ConfigIni.b垂直帰線待ちを行う = DTXVmode.VSyncWait;
1907 CDTXMania.ConfigIni.bTimeStretch = DTXVmode.TimeStretch;
1908 CDTXMania.ConfigIni.bDrums有効 = !DTXVmode.GRmode;
1909 CDTXMania.ConfigIni.bGuitar有効 = true;
1910 }
1911 else // 通常のコンパクトモード
1912 {
1913 strコンパクトモドファイル = commandLineArgs[ 1 ];
1914 }
1915
1916 if ( !File.Exists( strコンパクトモドファイル ) ) // #32985 2014.1.23 yyagi
1917 {
1918 Trace.TraceError( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモドファイル );
1919 #if DEBUG
1920 Environment.Exit( -1 );
1921 #else
1922 throw new FileNotFoundException( "コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモドファイル );
1923 #endif
1924 }
1925 if ( DTXVmode.Enabled )
1926 {
1927 Trace.TraceInformation( "DTXVモードで起動します。[{0}]", strコンパクトモドファイル );
1928 }
1929 else
1930 {
1931 Trace.TraceInformation( "コンパクトモードで起動します。[{0}]", strコンパクトモドファイル );
1932 }
1933 }
1934 //---------------------
1935 #endregion
1936
1937 #region [ ウィンドウ初期化 ]
1938 //---------------------
1939 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1940 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1941
1942 base.Window.Text = this.strWindowTitle; // 事前にDTXVmodeの実体を作っておくこと
1943
1944
1945 base.Window.StartPosition = FormStartPosition.Manual; // #30675 2013.02.04 ikanick add
1946 base.Window.Location = new Point( ConfigIni.n初期ウィンドウ開始位置X, ConfigIni.n初期ウィンドウ開始位置Y ); // #30675 2013.02.04 ikanick add
1947
1948 base.Window.ClientSize = new Size(ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight); // #34510 yyagi 2010.10.31 to change window size got from Config.ini
1949 #if !WindowedFullscreen
1950 if (!ConfigIni.bウィンドウモ) // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
1951 { // #30666 2013.02.02 yyagi: currentClientSize should be always made
1952 #endif
1953 currentClientSize = new Size( ConfigIni.nウインドウwidth, ConfigIni.nウインドウheight );
1954 #if !WindowedFullscreen
1955 }
1956 #endif
1957 base.Window.MaximizeBox = true; // #23510 2010.11.04 yyagi: to support maximizing window
1958 base.Window.FormBorderStyle = FormBorderStyle.Sizable; // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
1959 // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
1960 base.Window.ShowIcon = true;
1961 base.Window.Icon = Properties.Resources.dtx;
1962 base.Window.KeyDown += new KeyEventHandler( this.Window_KeyDown );
1963 base.Window.MouseUp +=new MouseEventHandler( this.Window_MouseUp);
1964 base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick); // #23510 2010.11.13 yyagi: to go fullscreen mode
1965 base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd); // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
1966 base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
1967 base.Window.ApplicationDeactivated += new EventHandler( this.Window_ApplicationDeactivated );
1968 //---------------------
1969 #endregion
1970 #region [ Direct3D9Exを使うかどうか判定 ]
1971 #endregion
1972 #region [ Direct3D9 デバイスの生成 ]
1973 //---------------------
1974 DeviceSettings settings = new DeviceSettings();
1975 #if WindowedFullscreen
1976 settings.Windowed = true; // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
1977 #else
1978 settings.Windowed = ConfigIni.bウィンドウモ;
1979 #endif
1980 settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
1981 settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
1982 // settings.BackBufferCount = 3;
1983 settings.EnableVSync = ConfigIni.b垂直帰線待ちを行う;
1984 // settings.BackBufferFormat = Format.A8R8G8B8;
1985 // settings.MultisampleType = MultisampleType.FourSamples;
1986 // settings.MultisampleQuality = 4;
1987 // settings.MultisampleType = MultisampleType.None;
1988 // settings.MultisampleQuality = 0;
1989
1990 try
1991 {
1992 base.GraphicsDeviceManager.ChangeDevice(settings);
1993 }
1994 catch (DeviceCreationException e)
1995 {
1996 Trace.TraceError(e.ToString());
1997 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1998 Environment.Exit(-1);
1999 }
2000
2001 base.IsFixedTimeStep = false;
2002 // base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
2003 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.
2004 base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.n非フォカス時スリms)); // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
2005 // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
2006 #if WindowedFullscreen
2007 this.t全画面・ウィンドウモド切り替え(); // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
2008 #endif
2009 actFlushGPU = new CActFlushGPU();
2010 //---------------------
2011 #endregion
2012
2013 DTX = null;
2014
2015 #region [ Skin の初期化 ]
2016 //---------------------
2017 Trace.TraceInformation( "スキンの初期化を行います。" );
2018 Trace.Indent();
2019 try
2020 {
2021 Skin = new CSkin( CDTXMania.ConfigIni.strSystemSkinSubfolderFullName, CDTXMania.ConfigIni.bUseBoxDefSkin );
2022 CDTXMania.ConfigIni.strSystemSkinSubfolderFullName = CDTXMania.Skin.GetCurrentSkinSubfolderFullName( true ); // 旧指定のSkinフォルダが消滅していた場合に備える
2023 Trace.TraceInformation( "スキンの初期化を完了しました。" );
2024 }
2025 catch
2026 {
2027 Trace.TraceInformation( "スキンの初期化に失敗しました。" );
2028 throw;
2029 }
2030 finally
2031 {
2032 Trace.Unindent();
2033 }
2034 //---------------------
2035 #endregion
2036 #region [ Timer の初期化 ]
2037 //---------------------
2038 Trace.TraceInformation( "タイマの初期化を行います。" );
2039 Trace.Indent();
2040 try
2041 {
2042 Timer = new CTimer( CTimer.E種別.MultiMedia );
2043 Trace.TraceInformation( "タイマの初期化を完了しました。" );
2044 }
2045 finally
2046 {
2047 Trace.Unindent();
2048 }
2049 //---------------------
2050 #endregion
2051 #region [ FPS カウンタの初期化 ]
2052 //---------------------
2053 Trace.TraceInformation( "FPSカウンタの初期化を行います。" );
2054 Trace.Indent();
2055 try
2056 {
2057 FPS = new CFPS();
2058 Trace.TraceInformation( "FPSカウンタを生成しました。" );
2059 }
2060 finally
2061 {
2062 Trace.Unindent();
2063 }
2064 //---------------------
2065 #endregion
2066 #region [ act文字コンソールの初期化 ]
2067 //---------------------
2068 Trace.TraceInformation( "文字コンソールの初期化を行います。" );
2069 Trace.Indent();
2070 try
2071 {
2072 act文字コンソ = new C文字コンソ();
2073 Trace.TraceInformation( "文字コンソールを生成しました。" );
2074 act文字コンソ.On活性化();
2075 Trace.TraceInformation( "文字コンソールを活性化しました。" );
2076 Trace.TraceInformation( "文字コンソールの初期化を完了しました。" );
2077 }
2078 catch( Exception exception )
2079 {
2080 Trace.TraceError( exception.Message );
2081 Trace.TraceError( "文字コンソールの初期化に失敗しました。" );
2082 }
2083 finally
2084 {
2085 Trace.Unindent();
2086 }
2087 //---------------------
2088 #endregion
2089 #region [ Input管理 の初期化 ]
2090 //---------------------
2091 Trace.TraceInformation( "DirectInput, MIDI入力の初期化を行います。" );
2092 Trace.Indent();
2093 try
2094 {
2095 Input管理 = new CInput管理( base.Window.Handle );
2096 foreach( IInputDevice device in Input管理.list入力デバイス )
2097 {
2098 if( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && !ConfigIni.dicJoystick.ContainsValue( device.GUID ) )
2099 {
2100 int key = 0;
2101 while( ConfigIni.dicJoystick.ContainsKey( key ) )
2102 {
2103 key++;
2104 }
2105 ConfigIni.dicJoystick.Add( key, device.GUID );
2106 }
2107 }
2108 foreach( IInputDevice device2 in Input管理.list入力デバイス )
2109 {
2110 if( device2.e入力デバイス種別 == E入力デバイス種別.Joystick )
2111 {
2112 foreach( KeyValuePair<int, string> pair in ConfigIni.dicJoystick )
2113 {
2114 if( device2.GUID.Equals( pair.Value ) )
2115 {
2116 ( (CInputJoystick) device2 ).SetID( pair.Key );
2117 break;
2118 }
2119 }
2120 continue;
2121 }
2122 }
2123 Trace.TraceInformation( "DirectInput の初期化を完了しました。" );
2124 }
2125 catch( Exception exception2 )
2126 {
2127 Trace.TraceError( exception2.Message );
2128 Trace.TraceError( "DirectInput, MIDI入力の初期化に失敗しました。" );
2129 throw;
2130 }
2131 finally
2132 {
2133 Trace.Unindent();
2134 }
2135 //---------------------
2136 #endregion
2137 #region [ Pad の初期化 ]
2138 //---------------------
2139 Trace.TraceInformation( "パッドの初期化を行います。" );
2140 Trace.Indent();
2141 try
2142 {
2143 Pad = new CPad( ConfigIni, Input管理 );
2144 Trace.TraceInformation( "パッドの初期化を完了しました。" );
2145 }
2146 catch( Exception exception3 )
2147 {
2148 Trace.TraceError( exception3.Message );
2149 Trace.TraceError( "パッドの初期化に失敗しました。" );
2150 }
2151 finally
2152 {
2153 Trace.Unindent();
2154 }
2155 //---------------------
2156 #endregion
2157 #region [ Sound管理 の初期化 ]
2158 //---------------------
2159 Trace.TraceInformation("サウンドデバイスの初期化を行います。");
2160 Trace.Indent();
2161 try
2162 {
2163 {
2164 ESoundDeviceType soundDeviceType;
2165 switch (CDTXMania.ConfigIni.nSoundDeviceType)
2166 {
2167 case 0:
2168 soundDeviceType = ESoundDeviceType.DirectSound;
2169 break;
2170 case 1:
2171 soundDeviceType = ESoundDeviceType.ASIO;
2172 break;
2173 case 2:
2174 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
2175 break;
2176 default:
2177 soundDeviceType = ESoundDeviceType.Unknown;
2178 break;
2179 }
2180 Sound管理 = new CSound管理( base.Window.Handle,
2181 soundDeviceType,
2182 CDTXMania.ConfigIni.nWASAPIBufferSizeMs,
2183 //CDTXMania.ConfigIni.nASIOBufferSizeMs,
2184 0,
2185 CDTXMania.ConfigIni.nASIODevice
2186 );
2187 ShowWindowTitleWithSoundType();
2188 FDK.CSound管理.bIsTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
2189 Sound管理.nMasterVolume = CDTXMania.ConfigIni.nMasterVolume;
2190 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.ConfigIni.bNoMP3Streaming;
2191 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
2192 }
2193 }
2194 catch (Exception e)
2195 {
2196 Trace.TraceError(e.Message);
2197 throw;
2198 }
2199 finally
2200 {
2201 Trace.Unindent();
2202 }
2203 //---------------------
2204 #endregion
2205 #region [ Songs管理 の初期化 ]
2206 //---------------------
2207 Trace.TraceInformation( "曲リストの初期化を行います。" );
2208 Trace.Indent();
2209 try
2210 {
2211 Songs管理 = new CSongs管理();
2212 // Songs管理_裏読 = new CSongs管理();
2213 EnumSongs = new CEnumSongs();
2214 actEnumSongs = new CActEnumSongs();
2215 Trace.TraceInformation( "曲リストの初期化を完了しました。" );
2216 }
2217 catch( Exception e )
2218 {
2219 Trace.TraceError( e.Message );
2220 Trace.TraceError( "曲リストの初期化に失敗しました。" );
2221 }
2222 finally
2223 {
2224 Trace.Unindent();
2225 }
2226 //---------------------
2227 #endregion
2228 #region [ CAvi の初期化 ]
2229 //---------------------
2230 CAvi.t初期化();
2231 //---------------------
2232 #endregion
2233 #region [ Random の初期化 ]
2234 //---------------------
2235 Random = new Random( (int) Timer.nシステム時刻 );
2236 //---------------------
2237 #endregion
2238 #region [ ステージの初期化 ]
2239 //---------------------
2240 r現在のステ = null;
2241 r直前のステ = null;
2242 stage起動 = new CStage起動();
2243 stageタイトル = new CStageタイトル();
2244 stageオプション = new CStageオプション();
2245 stageコンフィグ = new CStageコンフィグ();
2246 stage選曲 = new CStage選曲();
2247 stage曲読み込み = new CStage曲読み込み();
2248 stage演奏ドラム画面 = new CStage演奏ドラム画面();
2249 stage演奏ギタ画面 = new CStage演奏ギタ画面();
2250 stage結果 = new CStage結果();
2251 stageChangeSkin = new CStageChangeSkin();
2252 stage終了 = new CStage終了();
2253 this.listトップレベルActivities = new List<CActivity>();
2254 this.listトップレベルActivities.Add( actEnumSongs );
2255 this.listトップレベルActivities.Add( act文字コンソ );
2256 this.listトップレベルActivities.Add( stage起動 );
2257 this.listトップレベルActivities.Add( stageタイトル );
2258 this.listトップレベルActivities.Add( stageオプション );
2259 this.listトップレベルActivities.Add( stageコンフィグ );
2260 this.listトップレベルActivities.Add( stage選曲 );
2261 this.listトップレベルActivities.Add( stage曲読み込み );
2262 this.listトップレベルActivities.Add( stage演奏ドラム画面 );
2263 this.listトップレベルActivities.Add( stage演奏ギタ画面 );
2264 this.listトップレベルActivities.Add( stage結果 );
2265 this.listトップレベルActivities.Add( stageChangeSkin );
2266 this.listトップレベルActivities.Add( stage終了 );
2267 this.listトップレベルActivities.Add( actFlushGPU);
2268 //---------------------
2269 #endregion
2270 #region [ プラグインの検索と生成 ]
2271 //---------------------
2272 PluginHost = new CPluginHost();
2273
2274 Trace.TraceInformation( "プラグインの検索と生成を行います。" );
2275 Trace.Indent();
2276 try
2277 {
2278 this.tプラグイン検索と生成();
2279 Trace.TraceInformation( "プラグインの検索と生成を完了しました。" );
2280 }
2281 finally
2282 {
2283 Trace.Unindent();
2284 }
2285 //---------------------
2286 #endregion
2287 #region [ プラグインの初期化 ]
2288 //---------------------
2289 if( this.listプラグイン != null && this.listプラグイン.Count > 0 )
2290 {
2291 Trace.TraceInformation( "プラグインの初期化を行います。" );
2292 Trace.Indent();
2293 try
2294 {
2295 foreach( STPlugin st in this.listプラグイン )
2296 {
2297 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2298 st.plugin.On初期化( this.PluginHost );
2299 st.plugin.OnManagedリソスの作成();
2300 st.plugin.OnUnmanagedリソスの作成();
2301 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2302 }
2303 Trace.TraceInformation( "すべてのプラグインの初期化を完了しました。" );
2304 }
2305 catch
2306 {
2307 Trace.TraceError( "プラグインのどれかの初期化に失敗しました。" );
2308 throw;
2309 }
2310 finally
2311 {
2312 Trace.Unindent();
2313 }
2314 }
2315
2316 //---------------------
2317 #endregion
2318
2319
2320 Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );
2321
2322 #region [ 最初のステージの起動 ]
2323 //---------------------
2324 Trace.TraceInformation("----------------------");
2325 Trace.TraceInformation("■ 起動");
2326
2327 if (CDTXMania.bコンパクトモ)
2328 {
2329 r現在のステ = stage曲読み込み;
2330 }
2331 else
2332 {
2333 r現在のステ = stage起動;
2334 }
2335 r現在のステ.On活性化();
2336 //---------------------
2337 #endregion
2338 }
2339 public void ShowWindowTitleWithSoundType()
2340 {
2341 string delay = "";
2342 if (Sound管理.GetCurrentSoundDeviceType() != "DirectSound")
2343 {
2344 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2345 }
2346 base.Window.Text = strWindowTitle + " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2347 }
2348
2349 private void t終了処理()
2350 {
2351 if( !this.b終了処理完了済み )
2352 {
2353 Trace.TraceInformation( "----------------------" );
2354 Trace.TraceInformation( "■ アプリケーションの終了" );
2355 #region [ 曲検索の終了処理 ]
2356 //---------------------
2357 if ( actEnumSongs != null )
2358 {
2359 Trace.TraceInformation( "曲検索actの終了処理を行います。" );
2360 Trace.Indent();
2361 try
2362 {
2363 actEnumSongs.On非活性化();
2364 actEnumSongs= null;
2365 Trace.TraceInformation( "曲検索actの終了処理を完了しました。" );
2366 }
2367 catch ( Exception e )
2368 {
2369 Trace.TraceError( e.Message );
2370 Trace.TraceError( "曲検索actの終了処理に失敗しました。" );
2371 }
2372 finally
2373 {
2374 Trace.Unindent();
2375 }
2376 }
2377 //---------------------
2378 #endregion
2379 #region [ 現在のステージの終了処理 ]
2380 //---------------------
2381 if( CDTXMania.r現在のステ != null && CDTXMania.r現在のステ.b活性化してる ) // #25398 2011.06.07 MODIFY FROM
2382 {
2383 Trace.TraceInformation( "現在のステージを終了します。" );
2384 Trace.Indent();
2385 try
2386 {
2387 r現在のステ.On非活性化();
2388 Trace.TraceInformation( "現在のステージの終了処理を完了しました。" );
2389 }
2390 finally
2391 {
2392 Trace.Unindent();
2393 }
2394 }
2395 //---------------------
2396 #endregion
2397 #region [ プラグインの終了処理 ]
2398 //---------------------
2399 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2400 {
2401 Trace.TraceInformation( "すべてのプラグインを終了します。" );
2402 Trace.Indent();
2403 try
2404 {
2405 foreach( STPlugin st in this.listプラグイン )
2406 {
2407 Directory.SetCurrentDirectory( st.strプラグインフォルダ );
2408 st.plugin.OnUnmanagedリソスの解放();
2409 st.plugin.OnManagedリソスの解放();
2410 st.plugin.On終了();
2411 Directory.SetCurrentDirectory( CDTXMania.strEXEのあるフォルダ );
2412 }
2413 PluginHost = null;
2414 Trace.TraceInformation( "すべてのプラグインの終了処理を完了しました。" );
2415 }
2416 finally
2417 {
2418 Trace.Unindent();
2419 }
2420 }
2421 //---------------------
2422 #endregion
2423 #region [ 曲リストの終了処理 ]
2424 //---------------------
2425 if (Songs管理 != null)
2426 {
2427 Trace.TraceInformation( "曲リストの終了処理を行います。" );
2428 Trace.Indent();
2429 try
2430 {
2431 Songs管理 = null;
2432 Trace.TraceInformation( "曲リストの終了処理を完了しました。" );
2433 }
2434 catch( Exception exception )
2435 {
2436 Trace.TraceError( exception.Message );
2437 Trace.TraceError( "曲リストの終了処理に失敗しました。" );
2438 }
2439 finally
2440 {
2441 Trace.Unindent();
2442 }
2443 }
2444 CAvi.t終了();
2445 //---------------------
2446 #endregion
2447 #region [ スキンの終了処理 ]
2448 //---------------------
2449 if (Skin != null)
2450 {
2451 Trace.TraceInformation( "スキンの終了処理を行います。" );
2452 Trace.Indent();
2453 try
2454 {
2455 Skin.Dispose();
2456 Skin = null;
2457 Trace.TraceInformation( "スキンの終了処理を完了しました。" );
2458 }
2459 catch( Exception exception2 )
2460 {
2461 Trace.TraceError( exception2.Message );
2462 Trace.TraceError( "スキンの終了処理に失敗しました。" );
2463 }
2464 finally
2465 {
2466 Trace.Unindent();
2467 }
2468 }
2469 //---------------------
2470 #endregion
2471 #region [ DirectSoundの終了処理 ]
2472 //---------------------
2473 if (Sound管理 != null)
2474 {
2475 Trace.TraceInformation( "DirectSound の終了処理を行います。" );
2476 Trace.Indent();
2477 try
2478 {
2479 Sound管理.Dispose();
2480 Sound管理 = null;
2481 Trace.TraceInformation( "DirectSound の終了処理を完了しました。" );
2482 }
2483 catch( Exception exception3 )
2484 {
2485 Trace.TraceError( exception3.Message );
2486 Trace.TraceError( "DirectSound の終了処理に失敗しました。" );
2487 }
2488 finally
2489 {
2490 Trace.Unindent();
2491 }
2492 }
2493 //---------------------
2494 #endregion
2495 #region [ パッドの終了処理 ]
2496 //---------------------
2497 if (Pad != null)
2498 {
2499 Trace.TraceInformation( "パッドの終了処理を行います。" );
2500 Trace.Indent();
2501 try
2502 {
2503 Pad = null;
2504 Trace.TraceInformation( "パッドの終了処理を完了しました。" );
2505 }
2506 catch( Exception exception4 )
2507 {
2508 Trace.TraceError( exception4.Message );
2509 Trace.TraceError( "パッドの終了処理に失敗しました。" );
2510 }
2511 finally
2512 {
2513 Trace.Unindent();
2514 }
2515 }
2516 //---------------------
2517 #endregion
2518 #region [ DirectInput, MIDI入力の終了処理 ]
2519 //---------------------
2520 if (Input管理 != null)
2521 {
2522 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を行います。" );
2523 Trace.Indent();
2524 try
2525 {
2526 Input管理.Dispose();
2527 Input管理 = null;
2528 Trace.TraceInformation( "DirectInput, MIDI入力の終了処理を完了しました。" );
2529 }
2530 catch( Exception exception5 )
2531 {
2532 Trace.TraceError( exception5.Message );
2533 Trace.TraceError( "DirectInput, MIDI入力の終了処理に失敗しました。" );
2534 }
2535 finally
2536 {
2537 Trace.Unindent();
2538 }
2539 }
2540 //---------------------
2541 #endregion
2542 #region [ 文字コンソールの終了処理 ]
2543 //---------------------
2544 if (act文字コンソ != null)
2545 {
2546 Trace.TraceInformation( "文字コンソールの終了処理を行います。" );
2547 Trace.Indent();
2548 try
2549 {
2550 act文字コンソ.On非活性化();
2551 act文字コンソ = null;
2552 Trace.TraceInformation( "文字コンソールの終了処理を完了しました。" );
2553 }
2554 catch( Exception exception6 )
2555 {
2556 Trace.TraceError( exception6.Message );
2557 Trace.TraceError( "文字コンソールの終了処理に失敗しました。" );
2558 }
2559 finally
2560 {
2561 Trace.Unindent();
2562 }
2563 }
2564 //---------------------
2565 #endregion
2566 #region [ FPSカウンタの終了処理 ]
2567 //---------------------
2568 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2569 Trace.Indent();
2570 try
2571 {
2572 if( FPS != null )
2573 {
2574 FPS = null;
2575 }
2576 Trace.TraceInformation( "FPSカウンタの終了処理を完了しました。" );
2577 }
2578 finally
2579 {
2580 Trace.Unindent();
2581 }
2582 //---------------------
2583 #endregion
2584
2585 // ct.Dispose();
2586
2587 #region [ タイマの終了処理 ]
2588 //---------------------
2589 Trace.TraceInformation("タイマの終了処理を行います。");
2590 Trace.Indent();
2591 try
2592 {
2593 if( Timer != null )
2594 {
2595 Timer.Dispose();
2596 Timer = null;
2597
2598 Trace.TraceInformation( "タイマの終了処理を完了しました。" );
2599 }
2600 else
2601 {
2602 Trace.TraceInformation( "タイマは使用されていません。" );
2603 }
2604 }
2605 finally
2606 {
2607 Trace.Unindent();
2608 }
2609 //---------------------
2610 #endregion
2611 #region [ Config.iniの出力 ]
2612 //---------------------
2613 Trace.TraceInformation("Config.ini を出力します。");
2614 // if ( ConfigIni.bIsSwappedGuitarBass ) // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2615 if ( ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped ) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2616 {
2617 ConfigIni.SwapGuitarBassInfos_AutoFlags();
2618 }
2619 string str = strEXEのあるフォルダ + "Config.ini";
2620 Trace.Indent();
2621 try
2622 {
2623 if ( DTXVmode.Enabled )
2624 {
2625 DTXVmode.tUpdateConfigIni();
2626 Trace.TraceInformation( "DTXVモードの設定情報を、Config.iniに保存しました。" );
2627 }
2628 else
2629 {
2630 ConfigIni.t書き出し( str );
2631 Trace.TraceInformation( "保存しました。({0})", str );
2632 }
2633 }
2634 catch( Exception e )
2635 {
2636 Trace.TraceError( e.Message );
2637 Trace.TraceError( "Config.ini の出力に失敗しました。({0})", str );
2638 }
2639 finally
2640 {
2641 Trace.Unindent();
2642 }
2643 //---------------------
2644 #endregion
2645 #region [ DTXVmodeの終了処理 ]
2646 //---------------------
2647 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2648 //Trace.Indent();
2649 try
2650 {
2651 if ( DTXVmode != null )
2652 {
2653 DTXVmode = null;
2654 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2655 }
2656 else
2657 {
2658 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2659 }
2660 }
2661 finally
2662 {
2663 //Trace.Unindent();
2664 }
2665 //---------------------
2666 #endregion
2667 Trace.TraceInformation("アプリケーションの終了処理を完了しました。");
2668
2669
2670 this.b終了処理完了済み = true;
2671 }
2672 }
2673
2674 private CScoreIni tScoreIniBGMAdjustHistoryPlayCountを更新(string str新ヒストリ行)
2675 {
2676 bool bIsUpdatedDrums, bIsUpdatedGuitar, bIsUpdatedBass;
2677 string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2678 CScoreIni ini = new CScoreIni( strFilename );
2679 if( !File.Exists( strFilename ) )
2680 {
2681 ini.stファイル.Title = DTX.TITLE;
2682 ini.stファイル.Name = DTX.strファイル名;
2683 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す( DTX.strファイル名の絶対パス );
2684 for( int i = 0; i < 6; i++ )
2685 {
2686 ini.stセクション[ i ].nPerfectになる範囲ms = nPerfect範囲ms;
2687 ini.stセクション[ i ].nGreatになる範囲ms = nGreat範囲ms;
2688 ini.stセクション[ i ].nGoodになる範囲ms = nGood範囲ms;
2689 ini.stセクション[ i ].nPoorになる範囲ms = nPoor範囲ms;
2690 }
2691 }
2692 ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2693 CScoreIni.t更新条件を取得する( out bIsUpdatedDrums, out bIsUpdatedGuitar, out bIsUpdatedBass );
2694 if( bIsUpdatedDrums || bIsUpdatedGuitar || bIsUpdatedBass )
2695 {
2696 if( bIsUpdatedDrums )
2697 {
2698 ini.stファイル.PlayCountDrums++;
2699 }
2700 if( bIsUpdatedGuitar )
2701 {
2702 ini.stファイル.PlayCountGuitar++;
2703 }
2704 if( bIsUpdatedBass )
2705 {
2706 ini.stファイル.PlayCountBass++;
2707 }
2708 ini.tヒストリを追加する( str新ヒストリ行 );
2709 if( !bコンパクトモ )
2710 {
2711 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2712 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2713 stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2714 for( int j = 0; j < ini.stファイル.History.Length; j++ )
2715 {
2716 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[ j ] = ini.stファイル.History[ j ];
2717 }
2718 }
2719 }
2720 if( ConfigIni.bScoreIniを出力する )
2721 {
2722 ini.t書き出し( strFilename );
2723 }
2724
2725 return ini;
2726 }
2727 private void tガベジコレクションを実行する()
2728 {
2729 GC.Collect();
2730 GC.WaitForPendingFinalizers();
2731 GC.Collect();
2732 GC.WaitForPendingFinalizers();
2733 }
2734 private void tプラグイン検索と生成()
2735 {
2736 this.listプラグイン = new List<STPlugin>();
2737
2738 string strIPluginActivityの名前 = typeof( IPluginActivity ).FullName;
2739 string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2740
2741 this.t指定フォルダ内でのプラグイン検索と生成( strプラグインフォルダパス, strIPluginActivityの名前 );
2742
2743 if( this.listプラグイン.Count > 0 )
2744 Trace.TraceInformation( this.listプラグイン.Count + " 個のプラグインを読み込みました。" );
2745 }
2746 #region [ Windowイベント処理 ]
2747 private void t指定フォルダ内でのプラグイン検索と生成( string strプラグインフォルダパス, string strプラグイン型名 )
2748 {
2749 // 指定されたパスが存在しないとエラー
2750 if( !Directory.Exists( strプラグインフォルダパス ) )
2751 {
2752 Trace.TraceWarning( "プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")" );
2753 return;
2754 }
2755
2756 // (1) すべての *.dll について…
2757 string[] strDLLs = System.IO.Directory.GetFiles( strプラグインフォルダパス, "*.dll" );
2758 foreach( string dllName in strDLLs )
2759 {
2760 try
2761 {
2762 // (1-1) dll をアセンブリとして読み込む。
2763 System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom( dllName );
2764
2765 // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2766 foreach( Type t in asm.GetTypes() )
2767 {
2768 // (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2769 if( t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface( strプラグイン型名 ) != null )
2770 {
2771 // (1-4) クラス名からインスタンスを作成する
2772 var st = new STPlugin() {
2773 plugin = (IPluginActivity) asm.CreateInstance( t.FullName ),
2774 strプラグインフォルダ = Path.GetDirectoryName( dllName ),
2775 strアセンブリ簡易名 = asm.GetName().Name,
2776 Version = asm.GetName().Version,
2777 };
2778
2779 // (1-5) プラグインリストへ登録
2780 this.listプラグイン.Add( st );
2781 Trace.TraceInformation( "プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName( dllName ), st.strアセンブリ簡易名, st.Version.ToString() );
2782 }
2783 }
2784 }
2785 catch
2786 {
2787 Trace.TraceInformation( dllName + " からプラグインを生成することに失敗しました。スキップします。" );
2788 }
2789 }
2790
2791 // (2) サブフォルダがあれば再帰する
2792 string[] strDirs = Directory.GetDirectories( strプラグインフォルダパス, "*" );
2793 foreach( string dir in strDirs )
2794 this.t指定フォルダ内でのプラグイン検索と生成( dir + "\\", strプラグイン型名 );
2795 }
2796 //-----------------
2797 private void Window_ApplicationActivated(object sender, EventArgs e)
2798 {
2799 this.bApplicationActive = true;
2800 }
2801 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2802 {
2803 this.bApplicationActive = false;
2804 }
2805 private void Window_KeyDown(object sender, KeyEventArgs e)
2806 {
2807 if (e.KeyCode == Keys.Menu)
2808 {
2809 e.Handled = true;
2810 e.SuppressKeyPress = true;
2811 }
2812 else if ((e.KeyCode == Keys.Return) && e.Alt)
2813 {
2814 if (ConfigIni != null)
2815 {
2816 ConfigIni.bウィンドウモ = !ConfigIni.bウィンドウモ;
2817 this.t全画面・ウィンドウモド切り替え();
2818 }
2819 e.Handled = true;
2820 e.SuppressKeyPress = true;
2821 }
2822 else
2823 {
2824 for (int i = 0; i < 0x10; i++)
2825 {
2826 if (ConfigIni.KeyAssign.System.Capture[i]. > 0 &&
2827 e.KeyCode == DeviceConstantConverter.KeyToKeyCode((SlimDX.DirectInput.Key)ConfigIni.KeyAssign.System.Capture[i].))
2828 {
2829 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2830 string strFullPath =
2831 Path.Combine(CDTXMania.strEXEのあるフォルダ, "Capture_img");
2832 strFullPath = Path.Combine(strFullPath, DateTime.Now.ToString("yyyyMMddHHmmss") + ".png");
2833 SaveResultScreen(strFullPath);
2834 }
2835 }
2836 }
2837 }
2838 private void Window_MouseUp(object sender, MouseEventArgs e)
2839 {
2840 mb = e.Button;
2841 }
2842
2843 private void Window_MouseDoubleClick(object sender, MouseEventArgs e) // #23510 2010.11.13 yyagi: to go full screen mode
2844 {
2845 if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen) // #26752 2011.11.27 yyagi
2846 {
2847 ConfigIni.bウィンドウモ = false;
2848 this.t全画面・ウィンドウモド切り替え();
2849 }
2850 }
2851 private void Window_ResizeEnd(object sender, EventArgs e) // #23510 2010.11.20 yyagi: to get resized window size
2852 {
2853 if (ConfigIni.bウィンドウモ)
2854 {
2855 ConfigIni.n初期ウィンドウ開始位置X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2856 ConfigIni.n初期ウィンドウ開始位置Y = base.Window.Location.Y; //
2857 }
2858
2859 ConfigIni.nウインドウwidth = (ConfigIni.bウィンドウモ) ? base.Window.ClientSize.Width : currentClientSize.Width; // #23510 2010.10.31 yyagi add
2860 ConfigIni.nウインドウheight = (ConfigIni.bウィンドウモ) ? base.Window.ClientSize.Height : currentClientSize.Height;
2861 }
2862 #endregion
2863
2864 //internal sealed class GCBeep // GC発生の度にbeep
2865 //{
2866 // ~GCBeep()
2867 // {
2868 // Console.Beep();
2869 // if ( !AppDomain.CurrentDomain.IsFinalizingForUnload()
2870 // && !Environment.HasShutdownStarted )
2871 // {
2872 // new GCBeep();
2873 // }
2874 // }
2875 //}
2876
2877 //-----------------
2878
2879 Stopwatch sw = new Stopwatch();
2880 List<double> swlist;
2881
2882 #endregion
2883 }
2884 }

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