Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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