Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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