Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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