Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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