Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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