2 using System.Collections.Concurrent;
3 using System.Collections.Generic;
4 using System.Diagnostics;
8 using System.Windows.Forms;
17 public static SST.フォルダ フォルダ
18 => ( StrokeStyleT.bs_フォルダ );
20 public static FDK.入力.Keyboard キーボード入力
21 => ( StrokeStyleT.bs_キーボード入力 );
23 public static FDK.入力.MidiIn MIDI入力
24 => ( StrokeStyleT.bs_MIDI入力 );
26 public static void すべての入力デバイスをポーリングする()
28 // hack: 追加の入力デバイスができたら、ここにポーリングコードを追加すること。
29 StrokeStyleT.キーボード入力?.ポーリングする();
30 StrokeStyleT.MIDI入力?.ポーリングする();
33 public static FDK.メディア.サウンド.WASAPI排他.ExclusiveDevice Wasapiデバイス
34 => ( StrokeStyleT.bs_Wasapiデバイス );
36 public static Random 乱数
37 => ( StrokeStyleT.bs_乱数 );
39 public static SST.ユーザ.ユーザ管理 ユーザ管理
40 => ( StrokeStyleT.bs_ユーザ管理 );
42 public static SST.曲.曲ツリー管理 曲ツリー管理
43 => ( StrokeStyleT.bs_曲ツリー管理 );
45 public static SSTFormat.スコア 演奏スコア { get; set; } = null;
47 public static SST.設定.Config Config
48 => ( StrokeStyleT.bs_Config );
50 public static bool ビュアーモードである
55 public static bool ビュアーモードではない
57 get { return !StrokeStyleT.ビュアーモードである; }
58 set { StrokeStyleT.ビュアーモードである = !value; }
61 public static ConcurrentQueue<SST.ステージ.演奏.ビュアーメッセージ> ビュアーメッセージキュー
62 => ( StrokeStyleT.bs_ビュアーメッセージキュー );
66 // フォルダ変数を真っ先に登録する。(ほかのメンバのコンストラクタでフォルダ変数を利用できるようにするため。)
67 StrokeStyleT.bs_フォルダ = new SST.フォルダ();
68 SST.フォルダ.フォルダ変数を追加する( "Static", StrokeStyleT.フォルダ.StaticFolder );
69 SST.フォルダ.フォルダ変数を追加する( "AppData", StrokeStyleT.フォルダ.AppDataFolder );
70 SST.フォルダ.フォルダ変数を追加する( "User", null );
74 this.State = ApplicationState.起動;
75 this.MainForm = new SharpDX.Windows.RenderForm();
76 this.MainForm.AllowUserResizing = false; // ユーザはフォームサイズを変更できない。
77 this.MainForm.UserResized += フォームサイズが変更された;
82 Debug.Assert( null != this.MainForm );
83 SharpDX.Windows.RenderLoop.Run( this.MainForm, () => {
85 // アプリケーションの状態に応じて処理分岐。
88 case ApplicationState.起動:
90 this.State = ApplicationState.進行描画;
93 case ApplicationState.進行描画:
95 if( this.State == ApplicationState.終了 )
99 case ApplicationState.終了:
107 protected enum ApplicationState { 起動, 進行描画, 終了 }
108 protected ApplicationState State;
109 protected SharpDX.Windows.RenderForm MainForm = null;
110 protected SharpDX.Size2F 設計画面サイズdpx = SharpDX.Size2F.Empty;
112 protected FDK.メディア.デバイスリソース デバイスリソース = null;
113 protected SST.ステージ.ステージ 最初のダミーステージ = null;
114 protected SST.ステージ.起動.起動ステージ 起動ステージ = null;
115 protected SST.ステージ.タイトル.タイトルステージ タイトルステージ = null;
116 protected SST.ステージ.ログイン.ログインステージ ログインステージ = null;
117 protected SST.ステージ.選曲.選曲ステージ 選曲ステージ = null;
118 protected SST.ステージ.曲読込.曲読込ステージ 曲読込ステージ = null;
119 protected SST.ステージ.演奏.演奏ステージ 演奏ステージ = null;
120 protected SST.ステージ.結果.結果ステージ 結果ステージ = null;
121 protected SST.ステージ.ステージ 現在のステージ = null;
123 protected void 初期化する()
125 FDK.Log.現在のスレッドに名前をつける( "Render" );
126 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
127 Debug.Assert( null == this.デバイスリソース, "デバイスリソースの作成前であること。" );
129 StrokeStyleT.bs_ユーザ管理 = new ユーザ.ユーザ管理();
130 StrokeStyleT.bs_曲ツリー管理 = new 曲.曲ツリー管理();
132 #region " コマンドライン引数を解析する。"
134 // 最初の要素は exe ファイル名なのでスキップする。
135 this.コマンドライン引数を解析する( Environment.GetCommandLineArgs().Skip( 1 ) );
139 #region " 高解像度タイマを使えないならエラー。"
141 if( false == System.Diagnostics.Stopwatch.IsHighResolution )
142 throw new SSTException( "このシステムは、高解像度タイマをサポートしていません。" );
145 #region " MediaFoundation を起動する。"
147 SharpDX.MediaFoundation.MediaManager.Startup();
150 #region " Sleep 精度を上げる。"
152 Win32.timeBeginPeriod( 1 );
156 #region " コンフィグ を初期化する。"
158 FDK.Log.Info( "コンフィグを初期化します。" );
159 StrokeStyleT.bs_Config = new 設定.Config();
160 StrokeStyleT.bs_Config.ConfigXmlを読み込む();
164 #region " コンフィグで指定されたウィンドウサイズに変更する。"
166 this.MainForm.ClientSize = new System.Drawing.Size( StrokeStyleT.Config.物理画面サイズpx.Width, StrokeStyleT.Config.物理画面サイズpx.Height );
169 #region " フォームタイトルと設計画面サイズを設定する。"
171 this.MainForm.Text = $"StrokeStyle<T> {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
172 if( StrokeStyleT.ビュアーモードである )
173 this.MainForm.Text += " (Viewer)";
175 this.設計画面サイズdpx = new SharpDX.Size2F( 1920f, 1080f );
179 #region " デバイスリソースを作成する。"
181 FDK.Log.BeginInfo( "デバイスリソースを作成します。" );
182 FDK.Log.Info( $"設計画面サイズ: {this.設計画面サイズdpx}" );
183 FDK.Log.Info( $"物理画面サイズ: {this.MainForm.ClientSize}" );
184 this.デバイスリソース = new FDK.メディア.デバイスリソース( this.設計画面サイズdpx );
185 this.デバイスリソース.すべてのリソースを作成する( this.MainForm.ClientSize, this.MainForm.Handle );
189 #region " ステージを生成する。"
191 this.最初のダミーステージ = new ステージ.ステージ();
192 this.起動ステージ = new ステージ.起動.起動ステージ();
193 this.タイトルステージ = new ステージ.タイトル.タイトルステージ();
194 this.ログインステージ = new ステージ.ログイン.ログインステージ();
195 this.選曲ステージ = new ステージ.選曲.選曲ステージ();
196 this.曲読込ステージ = new ステージ.曲読込.曲読込ステージ();
197 this.演奏ステージ = new ステージ.演奏.演奏ステージ();
198 this.結果ステージ = new ステージ.結果.結果ステージ();
201 this.曲読込ステージ.読込曲のファイルパスを取得する = () => ( ( StrokeStyleT.曲ツリー管理.現在選択されているノード as SST.曲.MusicNode )?.sstfファイルパス );
202 this.結果ステージ.演奏ステージインスタンスを取得する = () => ( this.演奏ステージ );
203 this.結果ステージ.BGMを終了する = () => { this.演奏ステージ.BGMを解放する(); };
206 #region " ユーザを初期化する。"
208 FDK.Log.Info( "ユーザ情報を初期化します。" );
209 StrokeStyleT.ユーザ管理.UsersXmlを読み込む();
212 foreach( var ユーザ in StrokeStyleT.ユーザ管理.ユーザリスト )
213 ユーザ.SourcesXmlを読み込む();
216 #region " WASAPI デバイスを初期化する。"
218 StrokeStyleT.bs_Wasapiデバイス = new FDK.メディア.サウンド.WASAPI排他.ExclusiveDevice();
219 StrokeStyleT.bs_Wasapiデバイス.初期化する( 15.0f );
222 #region " キーボード入力 を初期化する。"
224 FDK.Log.Info( "キーボード入力デバイスを初期化します。" );
225 StrokeStyleT.bs_キーボード入力 = new FDK.入力.Keyboard( this.MainForm.Handle );
228 #region " MIDI入力 を初期化する。"
230 FDK.Log.Info( "MIDI入力デバイスを初期化します。" );
231 StrokeStyleT.bs_MIDI入力 = new FDK.入力.MidiIn();
235 FDK.Log.Info( "最初のダミーステージを開始します。" );
236 this.現在のステージ = this.最初のダミーステージ;
238 //#warning 全画面モード切替えを KeyDown で仮実装。
239 this.MainForm.KeyDown += ( target, arg ) => {
242 if( arg.KeyCode == System.Windows.Forms.Keys.F11 )
244 this.全画面モードとウィンドウモードを切り替える();
249 Debug.Assert( SharpDX.Size2F.Empty != this.設計画面サイズdpx, "初期化メソッド内で設計画面サイズを設定してあること。" );
250 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
252 protected void 終了する()
254 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
255 Debug.Assert( null != this.デバイスリソース, "デバイスリソースが解放される前であること。" );
257 #region " ステージを終了し、解放する。"
259 if( ( null != this.現在のステージ ) && ( this.現在のステージ.活性化している ) ) // 念のため
260 this.現在のステージ.非活性化する( this.デバイスリソース );
262 this.最初のダミーステージ = null;
264 this.タイトルステージ = null;
265 this.ログインステージ = null;
273 #region " デバイスリソースを解放する。"
275 FDK.Utilities.解放する( ref this.デバイスリソース );
279 #region " MIDI入力デバイスを解放する。"
281 FDK.Log.Info( "MIDI入力デバイスを解放します。" );
282 FDK.Utilities.解放する( ref StrokeStyleT.bs_MIDI入力 );
285 #region " キーボード入力デバイスを解放する。"
287 FDK.Log.Info( "キーボード入力デバイスを解放します。" );
288 FDK.Utilities.解放する( ref StrokeStyleT.bs_キーボード入力 );
291 #region " WASAPIデバイスを解放する。"
293 FDK.Log.Info( "WASAPIデバイスを解放します。" );
294 FDK.Utilities.解放する( ref StrokeStyleT.bs_Wasapiデバイス );
298 #region " コンフィグを保存し、解放する。"
300 FDK.Log.Info( "コンフィグを解放します。" );
301 StrokeStyleT.bs_Config.ConfigXmlを保存する();
302 StrokeStyleT.bs_Config = null;
307 FDK.Utilities.解放する( ref this.MainForm );
311 #region " MediaFoundation を終了する。"
313 SharpDX.MediaFoundation.MediaManager.Shutdown();
317 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
319 protected void 進行描画する()
321 #region " D3Dデバイスが消失していれば再構築する。"
324 this.デバイスリソース.D3Dデバイスが消失していれば再構築する( out 異常発生 );
326 // 再構築不可能な異常の場合は、即終了する。
329 this.State = ApplicationState.終了;
334 #region " 描画の前処理を行う。"
337 var d3dDevice = (SharpDX.Direct3D11.Device) null;
338 using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
340 using( var d3dContext = d3dDevice.ImmediateContext )
342 // 既定のD3Dレンダーターゲットビューを黒でクリアする。
343 d3dContext.ClearRenderTargetView( this.デバイスリソース.D3DRenderTargetView, SharpDX.Color4.Black );
345 // 深度バッファを 1.0f でクリアする。
346 d3dContext.ClearDepthStencilView(
347 this.デバイスリソース.D3DDepthStencilView,
348 SharpDX.Direct3D11.DepthStencilClearFlags.Depth,
355 #region " 現在のステージを進行描画する。"
357 this.現在のステージ?.進行描画する( this.デバイスリソース );
360 #region " スワップチェーンを表示する。"
362 if( StrokeStyleT.Config.垂直帰線待ちを行う )
364 // We recommend that you use Flush when the CPU waits for an arbitrary amount of time
365 // ( such as when you call the Sleep function).
366 // https://msdn.microsoft.com/ja-jp/library/windows/desktop/ff476425(v=vs.85).aspx
367 var d3dDevice = (SharpDX.Direct3D11.Device) null;
368 using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
370 using( var d3dContext = d3dDevice.ImmediateContext )
376 this.デバイスリソース.SwapChain1.Present(
377 ( StrokeStyleT.Config.垂直帰線待ちを行う ) ? 1 : 0,
378 SharpDX.DXGI.PresentFlags.None );
381 #region " ステージの状態をチェックし、必要あれば遷移またはアプリを終了する。"
383 if( null != this.現在のステージ )
385 switch( this.現在のステージ.GetType().Name )
387 case nameof( ステージ.ステージ ):
388 #region " ビュアーモード → AutoPlayerでログインして曲読込ステージへ。"
390 if( StrokeStyleT.ビュアーモードである )
392 FDK.Log.Info( "ビュアーモード: AutoPlayer ユーザでログインします。" );
393 this.ログインする( Properties.Resources.AUTOPLAYER );
395 this.曲読込ステージ.読込曲のファイルパスを取得する = () => ( null ); // 今は null 。あとでメッセージキューを見る。
396 this.曲読込ステージ.活性化する( this.デバイスリソース );
397 this.現在のステージ = this.曲読込ステージ;
401 #region " 通常モード → 起動ステージへ。"
405 this.起動ステージ.活性化する( this.デバイスリソース );
406 this.現在のステージ = this.起動ステージ;
412 case nameof( ステージ.起動.起動ステージ ):
413 #region " 終了 → タイトルステージへ。"
415 if( this.起動ステージ.現在のフェーズ == ステージ.起動.起動ステージ.フェーズ.終了 )
417 this.現在のステージ.非活性化する( this.デバイスリソース );
418 this.現在のステージ = this.タイトルステージ;
419 this.現在のステージ.活性化する( this.デバイスリソース );
425 case nameof( ステージ.タイトル.タイトルステージ ):
426 #region " 確定 → ログインステージへ。"
428 if( this.タイトルステージ.現在のフェーズ == ステージ.タイトル.タイトルステージ.フェーズ.確定 )
430 this.現在のステージ.非活性化する( this.デバイスリソース );
431 this.現在のステージ = this.ログインステージ;
432 this.現在のステージ.活性化する( this.デバイスリソース );
436 #region " キャンセル → アプリを終了する。"
438 else if( this.タイトルステージ.現在のフェーズ == ステージ.タイトル.タイトルステージ.フェーズ.キャンセル )
440 this.現在のステージ.非活性化する( this.デバイスリソース );
442 this.State = ApplicationState.終了;
448 case nameof( ステージ.ログイン.ログインステージ ):
449 #region " 確定 → ログイン処理を行って、選曲ステージへ。"
451 if( this.ログインステージ.現在のフェーズ == ステージ.ログイン.ログインステージ.フェーズ.確定 )
453 var user = StrokeStyleT.ユーザ管理.現在選択されているユーザ;
457 foreach( var path in user.曲の検索元フォルダパスのリスト )
458 SST.曲.曲ツリー管理.フォルダから曲を再帰的に検索して子ノードリストに追加する( user.曲ツリーのルートノード, path );
460 StrokeStyleT.曲ツリー管理.現在の管理対象ツリー = StrokeStyleT.ユーザ管理.現在選択されているユーザ.曲ツリーのルートノード;
463 this.現在のステージ.非活性化する( this.デバイスリソース );
464 this.現在のステージ = this.選曲ステージ;
465 this.現在のステージ.活性化する( this.デバイスリソース );
469 #region " キャンセル → タイトルステージへ。"
471 else if( this.ログインステージ.現在のフェーズ == ステージ.ログイン.ログインステージ.フェーズ.キャンセル )
473 this.現在のステージ.非活性化する( this.デバイスリソース );
474 this.現在のステージ = this.タイトルステージ;
475 this.現在のステージ.活性化する( this.デバイスリソース );
481 case nameof( ステージ.選曲.選曲ステージ ):
482 #region " 曲確定 → 曲読込ステージへ。"
484 if( this.選曲ステージ.現在のフェーズ == ステージ.選曲.選曲ステージ.フェーズ.曲確定 )
486 // 曲ノードが選択されていることを確認。
487 Trace.Assert( null != StrokeStyleT.曲ツリー管理.現在選択されているノード, "[バグあり] 選択曲が null です。" );
488 this.現在のステージ.非活性化する( this.デバイスリソース );
489 this.現在のステージ = this.曲読込ステージ;
490 this.現在のステージ.活性化する( this.デバイスリソース );
494 #region " キャンセル → アプリを終了する。"
496 else if( this.選曲ステージ.現在のフェーズ == ステージ.選曲.選曲ステージ.フェーズ.キャンセル )
498 this.現在のステージ.非活性化する( this.デバイスリソース );
500 this.State = ApplicationState.終了;
506 case nameof( ステージ.曲読込.曲読込ステージ ):
507 #region " 終了 → 演奏ステージへ。"
508 //--------------------
509 if( this.曲読込ステージ.現在のフェーズ == ステージ.曲読込.曲読込ステージ.フェーズ.終了 )
511 this.現在のステージ.非活性化する( this.デバイスリソース );
513 if( StrokeStyleT.ビュアーモードである )
516 this.現在のステージ = this.演奏ステージ;
517 this.現在のステージ.活性化する( this.デバイスリソース );
519 //--------------------
523 case nameof( ステージ.演奏.演奏ステージ ):
524 #region " 演奏終了 → 結果ステージへ。"
525 //--------------------
526 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.クリアor失敗 )
528 this.現在のステージ.非活性化する( this.デバイスリソース );
529 this.現在のステージ = this.結果ステージ;
530 this.現在のステージ.活性化する( this.デバイスリソース );
532 //--------------------
534 #region " キャンセル → 選曲ステージへ。"
535 //--------------------
536 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.キャンセル )
538 this.現在のステージ.非活性化する( this.デバイスリソース );
539 this.現在のステージ = this.選曲ステージ;
540 this.現在のステージ.活性化する( this.デバイスリソース );
542 //--------------------
544 #region " ビュアーメッセージ受信 → 曲読込ステージへ。"
545 //--------------------
546 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中 )
548 var msg = (SST.ステージ.演奏.ビュアーメッセージ) null;
549 if( ( 0 < StrokeStyleT.ビュアーメッセージキュー.Count ) &&
550 ( StrokeStyleT.ビュアーメッセージキュー.TryDequeue( out msg ) ) )
552 FDK.Log.Info( "ビュアーメッセージを受信しました。" );
553 this.曲読込ステージ.読込曲のファイルパスを取得する = () => { return msg.曲ファイルパス; };
555 this.現在のステージ.非活性化する( this.デバイスリソース );
556 this.演奏ステージ.BGMを解放する();
557 this.現在のステージ = this.曲読込ステージ;
558 this.現在のステージ.活性化する( this.デバイスリソース );
561 //--------------------
565 case nameof( ステージ.結果.結果ステージ ):
566 #region " 終了 → 選曲ステージへ。"
567 //--------------------
568 if( this.結果ステージ.現在のフェーズ == ステージ.結果.結果ステージ.フェーズ.終了 )
570 this.現在のステージ.非活性化する( this.デバイスリソース );
571 this.現在のステージ = this.選曲ステージ;
572 this.現在のステージ.活性化する( this.デバイスリソース );
574 //--------------------
582 protected void デバイス依存リソースを解放する()
584 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
585 Debug.Assert( null != this.デバイスリソース ); // 解放前であること。
587 this.現在のステージ?.デバイス依存リソースを解放する( this.デバイスリソース );
589 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
591 protected void デバイス依存リソースを再構築する()
593 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
594 Debug.Assert( null != this.デバイスリソース ); // 再生成済みであること。
596 this.現在のステージ?.デバイス依存リソースを作成する( this.デバイスリソース );
598 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
601 private void フォームサイズが変更された( object sender, EventArgs e )
603 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
604 FDK.Log.Info( $"新しいクライアントサイズ = {this.MainForm.ClientSize}" );
608 if( null == this.デバイスリソース )
610 FDK.Log.Info( " まだ初期化されてないので、何もしません。" );
611 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
614 if( this.MainForm.WindowState == FormWindowState.Minimized )
616 FDK.Log.Info( "最小化されました。" );
617 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
620 if( this.State != ApplicationState.進行描画 )
622 FDK.Log.Info( " アプリケーションの状態が進行描画じゃないので、何もしません。" );
623 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
629 Debug.Assert( null != this.デバイスリソース, "デバイスリソースが作成済みであること。" );
631 // 現在の画面モードを取得しておく。(Alt+TABなど、勝手に全画面を解除されることもあるので。)
632 SharpDX.Mathematics.Interop.RawBool fullscreen;
633 SharpDX.DXGI.Output outputTarget;
634 this.デバイスリソース.SwapChain1.GetFullscreenState( out fullscreen, out outputTarget );
635 this.MainForm.IsFullscreen = fullscreen;
636 outputTarget?.Dispose();
637 FDK.Log.Info( $"現在、全画面モードである = {this.MainForm.IsFullscreen}" );
640 this.デバイス依存リソースを解放する();
641 this.デバイスリソース.サイズに依存するリソースを解放する();
644 this.デバイスリソース.物理画面サイズpx = new SharpDX.Size2F( this.MainForm.ClientSize.Width, this.MainForm.ClientSize.Height );
647 this.デバイスリソース.サイズに依存するリソースを作成する();
648 this.デバイス依存リソースを再構築する();
650 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
652 private void 全画面モードとウィンドウモードを切り替える()
654 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
656 this.MainForm.IsFullscreen = !this.MainForm.IsFullscreen;
657 this.デバイスリソース.SwapChain1.SetFullscreenState( this.MainForm.IsFullscreen, null );
659 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
661 private void ログインする( string ユーザ名 )
663 StrokeStyleT.ユーザ管理.ユーザを選択する( ユーザ名 );
664 FDK.Log.Info( $"ユーザが選択されました。[{StrokeStyleT.ユーザ管理.現在選択されているユーザ.名前}]" );
666 private void デバイス情報を出力する()
668 using( var stream = new NamedPipeClientStream( "SSTFEditor Viewer Device Information" ) )
672 stream.Connect( 1000 );
674 using( var writer = new StreamWriter( stream ) )
676 writer.WriteLine( $"SoundDevice.Delay={StrokeStyleT.Wasapiデバイス.遅延ms.ToString()}" );
677 FDK.Log.Info( "デバイス情報を出力しました。" );
680 catch( TimeoutException )
682 FDK.Log.WARNING( "SSTFEditor ビュアー用パイプへの接続がタイムアウトしました。SSTFEditor が起動していない可能性があります。" );
686 private void 二重起動された( string[] args )
688 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
690 if( StrokeStyleT.ビュアーモードである )
692 this.コマンドライン引数を解析する( args );
696 FDK.Log.ERROR( "アプリが二重起動されましたが、先行アプリがビュアーモードではないので何もしません。" );
699 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
701 /// <param name="args">コマンドライン引数の列挙。exeファイル名は含まない。</param>
702 private void コマンドライン引数を解析する( IEnumerable<string> args )
704 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
708 if( 0 == args.Count() )
710 FDK.Log.Info( "引数は指定されていません。" ); // ビュアーモードではない。
714 StrokeStyleT.ビュアーモードである = true;
719 var msg = new ステージ.演奏.ビュアーメッセージ() {
720 種別 = ステージ.演奏.ビュアーメッセージ.E種別.演奏開始, // 規定値は「演奏開始」
723 ドラム音を発声する = false, // 規定値は false
727 var optionSet = new Mono.Options.OptionSet() {
728 "Usage: StrokeStyleT [File] [OPTIONS]+",
729 " File\t\t\t\tビュアーモードで表示する曲ファイル名です。",
730 { "p=|part=", "ビュアーモードで起動し、指定された小節番号から演奏を開始します。小節番号を省略すると、先頭から再生します。", (int v) => { msg.演奏開始小節番号 = v; } },
731 { "s|stop", "ビュアーモードで演奏中であれば、演奏を停止します。", v => { if ( v != null ) { msg.種別 = ステージ.演奏.ビュアーメッセージ.E種別.演奏停止; } } },
732 { "d|drums", "ビュアーモードで、チップヒット時に内蔵のドラム音を再生します。", v => { if( v != null ) { msg.ドラム音を発声する = true; } } },
736 List<string> ファイルパスs = optionSet.Parse( args );
739 if( msg.種別 == ステージ.演奏.ビュアーメッセージ.E種別.演奏停止 )
741 // (A) 演奏停止(曲ファイルパスは省略可。)
742 FDK.Log.Info( "ビュアーメッセージ: 演奏停止" );
746 // (B) 演奏開始(曲ファイルパスは必須。)
747 if( 0 < ファイルパスs.Count )
749 if( File.Exists( ファイルパスs[ 0 ] ) )
751 msg.曲ファイルパス = ファイルパスs[ 0 ];
755 msg.曲ファイルパス = null; // ファイルが存在しなかったら null 。
756 throw new Mono.Options.OptionException( $"ファイルが存在しません。[{FDK.フォルダ.絶対パスをフォルダ変数付き絶対パスに変換して返す( ファイルパスs[ 0 ] )}]", "File" );
761 throw new Mono.Options.OptionException( "ファイルの指定がありません。", "File" );
764 FDK.Log.Info( "ビュアーメッセージ: 演奏開始" );
765 FDK.Log.Info( $"曲ファイルパス: {msg.曲ファイルパス}" );
766 FDK.Log.Info( $"開始小節番号: {msg.演奏開始小節番号}" );
767 FDK.Log.Info( $"ドラム音: {msg.ドラム音を発声する}" );
771 StrokeStyleT.ビュアーメッセージキュー.Enqueue( msg );
772 FDK.Log.Info( "ビュアーメッセージを送信しました。" );
774 catch( Mono.Options.OptionException e )
776 FDK.Log.ERROR( $"{e.Message}" );
781 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
787 private static SST.フォルダ bs_フォルダ = null;
788 private static FDK.入力.Keyboard bs_キーボード入力 = null;
789 private static FDK.入力.MidiIn bs_MIDI入力 = null;
790 private static FDK.メディア.サウンド.WASAPI排他.ExclusiveDevice bs_Wasapiデバイス = null;
791 private static readonly Random bs_乱数 = new Random( DateTime.Now.Millisecond );
792 private static SST.ユーザ.ユーザ管理 bs_ユーザ管理 = null;
793 private static SST.曲.曲ツリー管理 bs_曲ツリー管理 = null;
794 private static SST.設定.Config bs_Config = null;
795 private static readonly ConcurrentQueue<SST.ステージ.演奏.ビュアーメッセージ> bs_ビュアーメッセージキュー = new ConcurrentQueue<ステージ.演奏.ビュアーメッセージ>();