Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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