Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (show annotations) (download)
Sun Mar 10 04:56:46 2013 UTC (11 years ago) by kairera0467
File size: 94823 byte(s)


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

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