Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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