OSDN Git Service

曲読込ステージから 曲ツリー管理 の依存を排除。
[strokestylet/CsWin10Desktop3.git] / StrokeStyleT / ステージ / 曲読込 / 曲読込ステージ.cs
index 31e4ad2..7012a61 100644 (file)
@@ -2,12 +2,16 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
+using FDK;     // for string 拡張
 using FDK.メディア;
 
 namespace SST.ステージ.曲読込
 {
        class 曲読込ステージ : SST.ステージ.ステージ
        {
+               // 外部依存アクション。
+               public Func<string> 読込曲のファイルパスを取得する = null;
+
                public enum フェーズ { 初期状態, 読込中, 終了 }
                public フェーズ 現在のフェーズ { get; protected set; } = フェーズ.初期状態;
 
@@ -17,6 +21,8 @@ namespace SST.ステージ.曲読込
 
                        #region " 条件チェック "
                        //----------------
+                       Trace.Assert( null != this.読込曲のファイルパスを取得する, "[バグあり] 活性化の前に外部依存アクションを接続してください。" );
+
                        if( StrokeStyleT.ビュアーモードである )
                        {
                                // ビュアーモードでは、現在選択されているノードが null でも OK。
@@ -29,11 +35,6 @@ namespace SST.ステージ.曲読込
                        #endregion
 
                        this.現在のフェーズ = フェーズ.読込中;
-
-                       var 選択曲 = (SST.曲.MusicNode) StrokeStyleT.曲ツリー管理.現在選択されているノード;
-
-                       if( null != 選択曲 )
-                               FDK.Log.Info( $"選択曲「{選択曲.タイトル}」({FDK.フォルダ.絶対パスをフォルダ変数付き絶対パスに変換して返す( 選択曲.sstfファイルパス )})" );
                }
                protected override void On非活性化( デバイスリソース dr )
                {
@@ -41,7 +42,10 @@ namespace SST.ステージ.曲読込
                }
                public override void 進行描画する( デバイスリソース dr )
                {
-                       var 選択曲 = (SST.曲.MusicNode) StrokeStyleT.曲ツリー管理.現在選択されているノード;
+                       string 選択曲ファイルパス = this.読込曲のファイルパスを取得する();
+
+                       if( 選択曲ファイルパス.Nullでも空でもない() )
+                               選択曲ファイルパス = SST.フォルダ.絶対パスに含まれるフォルダ変数を展開して返す( 選択曲ファイルパス );
 
                        switch( this.現在のフェーズ )
                        {
@@ -50,11 +54,11 @@ namespace SST.ステージ.曲読込
                                        StrokeStyleT.演奏スコア?.Dispose();
 
                                        // SSTFファイルを読み込んでスコアを構築。
-                                       if( null != 選択曲 )
+                                       if( 選択曲ファイルパス.Nullでも空でもない() )
                                        {
                                                var user = StrokeStyleT.ユーザ管理.現在選択されているユーザ;
                                                StrokeStyleT.演奏スコア = new SSTFormat.スコア(
-                                                       選択曲.sstfファイルパス,
+                                                       選択曲ファイルパス,
                                                        user.Rideは左,
                                                        user.Chinaは左,
                                                        user.Splashは左 );