From: yyagi Date: Wed, 2 May 2012 16:00:07 +0000 (+0000) Subject: #28195 スキン切替の実装。まだConfig.iniのSystem/SkinPathで変更できるだけで、本体動作中の動的な変更はできない。 X-Git-Tag: Release099f~222 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2b5e4f92eb6e0cc456240d063182b5c7ad535465;p=dtxmania%2Fdtxmania.git #28195 スキン切替の実装。まだConfig.iniのSystem/SkinPathで変更できるだけで、本体動作中の動的な変更はできない。 ここしばらくのバージョンアップで追加したテクスチャ画像がなくても最低限の動作はするよう、特定の画像ファイルに限りtry-catchを強化してある。 詳細はチケットを参照のこと。 git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/trunk@386 16f42ceb-6dc6-49c8-ba94-f2d53467949d --- diff --git a/DTXManiaプロジェクト/コード/ステージ/02.タイトル/CActEnumSongs.cs b/DTXManiaプロジェクト/コード/ステージ/02.タイトル/CActEnumSongs.cs index 40bdeca8..891231b0 100644 --- a/DTXManiaプロジェクト/コード/ステージ/02.タイトル/CActEnumSongs.cs +++ b/DTXManiaプロジェクト/コード/ステージ/02.タイトル/CActEnumSongs.cs @@ -52,7 +52,15 @@ namespace DTXMania { if ( this.b活性化してない ) return; - this.txNowEnumeratingSongs = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\ScreenTitle NowEnumeratingSongs.png" ), false ); + string pathNowEnumeratingSongs = CSkin.Path( @"Graphics\ScreenTitle NowEnumeratingSongs.png" ); + if ( File.Exists( pathNowEnumeratingSongs ) ) + { + this.txNowEnumeratingSongs = CDTXMania.tテクスチャの生成( pathNowEnumeratingSongs, false ); + } + else + { + this.txNowEnumeratingSongs = null; + } base.OnManagedリソースの作成(); } public override void OnManagedリソースの解放() diff --git a/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectPopupMenu.cs b/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectPopupMenu.cs index f2810e1b..c5082704 100644 --- a/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectPopupMenu.cs +++ b/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectPopupMenu.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.Text; using System.Runtime.InteropServices; using System.Drawing; +using System.IO; using FDK; @@ -198,8 +199,16 @@ namespace DTXMania { if ( !base.b活性化してない ) { - this.txCursor = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\ScreenConfig menu cursor.png" ), false ); - this.txPopupMenuBackground = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\ScreenSelect sort menu background.png" ), false ); + string pathCursor = CSkin.Path( @"Graphics\ScreenConfig menu cursor.png" );; + string pathPopupMenuBackground = CSkin.Path( @"Graphics\ScreenSelect sort menu background.png" ); + if ( File.Exists ( pathCursor ) ) + { + this.txCursor = CDTXMania.tテクスチャの生成( pathCursor, false ); + } + if ( File.Exists( pathPopupMenuBackground ) ) + { + this.txPopupMenuBackground = CDTXMania.tテクスチャの生成( pathPopupMenuBackground, false ); + } base.OnManagedリソースの作成(); } } diff --git a/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectQuickConfig.cs b/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectQuickConfig.cs index 36caa446..360bf93a 100644 --- a/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectQuickConfig.cs +++ b/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectQuickConfig.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Drawing; +using System.IO; using SlimDX; using FDK; @@ -439,8 +440,11 @@ namespace DTXMania { if( !base.b活性化してない ) { - this.txパネル本体 = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\ScreenSelect popup auto settings.png" ), true ); - + string pathパネル本体 = CSkin.Path( @"Graphics\ScreenSelect popup auto settings.png" ); + if ( File.Exists( pathパネル本体 ) ) + { + this.txパネル本体 = CDTXMania.tテクスチャの生成( pathパネル本体, true ); + } base.OnManagedリソースの作成(); } } diff --git a/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectShowCurrentPosition.cs b/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectShowCurrentPosition.cs index 354c1ec6..06dbb25a 100644 --- a/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectShowCurrentPosition.cs +++ b/DTXManiaプロジェクト/コード/ステージ/05.選曲/CActSelectShowCurrentPosition.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Drawing; using System.Diagnostics; +using System.IO; using SlimDX; using FDK; @@ -34,8 +35,16 @@ namespace DTXMania { if ( !base.b活性化してない ) { - this.txScrollBar = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\ScreenSelect scrollbar.png" ), false ); - this.txScrollPosition = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\ScreenSelect scrollbar.png" ), false ); + string pathScrollBar = CSkin.Path( @"Graphics\ScreenSelect scrollbar.png" ); + string pathScrollPosition = CSkin.Path( @"Graphics\ScreenSelect scrollbar.png" ); + if ( File.Exists( pathScrollBar ) ) + { + this.txScrollBar = CDTXMania.tテクスチャの生成( pathScrollBar, false ); + } + if ( File.Exists( pathScrollPosition ) ) + { + this.txScrollPosition = CDTXMania.tテクスチャの生成( pathScrollPosition, false ); + } base.OnManagedリソースの作成(); } } diff --git a/DTXManiaプロジェクト/コード/ステージ/07.演奏/CStage演奏画面共通.cs b/DTXManiaプロジェクト/コード/ステージ/07.演奏/CStage演奏画面共通.cs index 0b76b023..754a072d 100644 --- a/DTXManiaプロジェクト/コード/ステージ/07.演奏/CStage演奏画面共通.cs +++ b/DTXManiaプロジェクト/コード/ステージ/07.演奏/CStage演奏画面共通.cs @@ -272,6 +272,7 @@ namespace DTXMania CDTXMania.DTX.SwapGuitarBassInfos(); } this.sw = new Stopwatch(); + this.sw2 = new Stopwatch(); // this.gclatencymode = GCSettings.LatencyMode; // GCSettings.LatencyMode = GCLatencyMode.LowLatency; // GCのgen2はせいぜい1演奏辺り1,2回しか発生しないので、ここでわざわざGC gen2は抑止しない } @@ -544,6 +545,7 @@ namespace DTXMania // protected int nRisky_InitialVar, nRiskyTime; // #23559 2011.7.28 yyagi → CAct演奏ゲージ共通クラスに隠蔽 protected Stopwatch sw; // 2011.6.13 最適化検討用のストップウォッチ + protected Stopwatch sw2; // protected GCLatencyMode gclatencymode; protected E判定 e指定時刻からChipのJUDGEを返す( long nTime, CDTX.CChip pChip, int nInputAdjustTime ) @@ -695,11 +697,14 @@ namespace DTXMania } protected CDTX.CChip r指定時刻に一番近いChip・ヒット未済問わず不可視考慮( long nTime, int nChannel, int nInputAdjustTime ) { + sw2.Start(); +//Trace.TraceInformation( "NTime={0}, nChannel={1:x2}", nTime, nChannel ); nTime += nInputAdjustTime; // #24239 2011.1.23 yyagi InputAdjust int nIndex_InitialPositionSearchingToPast; if ( this.n現在のトップChip == -1 ) // 演奏データとして1個もチップがない場合は { + sw2.Stop(); return null; } int count = CDTXMania.DTX.listChip.Count; @@ -778,11 +783,13 @@ namespace DTXMania } else // 検索対象が未来方向には見つからなかった(しかし過去方向には見つかった)場合 { + sw2.Stop(); return CDTXMania.DTX.listChip[ nIndex_NearestChip_Past ]; } } else if ( nIndex_NearestChip_Past < 0 ) // 検索対象が過去方向には見つからなかった(しかし未来方向には見つかった)場合 { + sw2.Stop(); return CDTXMania.DTX.listChip[ nIndex_NearestChip_Future ]; } // 検索対象が過去未来の双方に見つかったなら、より近い方を採用する @@ -792,8 +799,10 @@ namespace DTXMania int nDiffTime_Past = Math.Abs( (int) ( nTime - nearestChip_Past.n発声時刻ms ) ); if ( nDiffTime_Future >= nDiffTime_Past ) { + sw2.Stop(); return nearestChip_Past; } + sw2.Stop(); return nearestChip_Future; } protected void tサウンド再生( CDTX.CChip rChip, long n再生開始システム時刻ms, E楽器パート part ) @@ -1147,12 +1156,15 @@ namespace DTXMania } protected CDTX.CChip r指定時刻に一番近い未ヒットChip( long nTime, int nChannel, int nInputAdjustTime, int n検索範囲時間ms ) { + sw2.Start(); +//Trace.TraceInformation( "nTime={0}, nChannel={1:x2}, 現在のTop={2}", nTime, nChannel,CDTXMania.DTX.listChip[ this.n現在のトップChip ].n発声時刻ms ); nTime += nInputAdjustTime; int nIndex_InitialPositionSearchingToPast; int nTimeDiff; if ( this.n現在のトップChip == -1 ) // 演奏データとして1個もチップがない場合は { + sw2.Stop(); return null; } int count = CDTXMania.DTX.listChip.Count; @@ -1228,6 +1240,7 @@ namespace DTXMania } if ( ( nIndex_NearestChip_Future >= count ) && ( nIndex_NearestChip_Past < 0 ) ) // 検索対象が過去未来どちらにも見つからなかった場合 { + sw2.Stop(); return null; } CDTX.CChip nearestChip; // = null; // 以下のifブロックのいずれかで必ずnearestChipには非nullが代入されるので、null初期化を削除 @@ -1259,8 +1272,10 @@ namespace DTXMania nTimeDiff = Math.Abs( (int) ( nTime - nearestChip.n発声時刻ms ) ); if ( ( n検索範囲時間ms > 0 ) && ( nTimeDiff > n検索範囲時間ms ) ) // チップは見つかったが、検索範囲時間外だった場合 { + sw2.Stop(); return null; } + sw2.Stop(); return nearestChip; } @@ -1814,7 +1829,7 @@ namespace DTXMania if ( configIni.bBGM音を発声する ) { dTX.tWavの再生停止( this.n最後に再生したBGMの実WAV番号[ pChip.nチャンネル番号 - 0x61 ] ); - dTX.tチップの再生( pChip, CDTXMania.Timer.n前回リセットした時のシステム時刻 + pChip.n発声時刻ms, (int) Eレーン.BGM, dTX.nモニタを考慮した音量( E楽器パート.UNKNOWN ) ); + dTX.tチップの再生( pChip, CDTXMania.Timer.n前回リセットした時のシステム時刻 + pChip.n発声時刻ms, ( int ) Eレーン.BGM, dTX.nモニタを考慮した音量( E楽器パート.UNKNOWN ) ); this.n最後に再生したBGMの実WAV番号[ pChip.nチャンネル番号 - 0x61 ] = pChip.n整数値・内部番号; } } @@ -2004,14 +2019,17 @@ namespace DTXMania protected abstract void t進行描画・チップ・空打ち音設定・ドラム( CConfigIni configIni, ref CDTX dTX, ref CDTX.CChip pChip ); protected void t進行描画・チップアニメ() { - for ( int i = 0; i < 3; i++ ) // drums: 0-3 gt/bs: 1-3 + for ( int i = 0; i < 3; i++ ) // 0=drums, 1=guitar, 2=bass { if ( this.ctチップ模様アニメ[ i ] != null ) { this.ctチップ模様アニメ[ i ].t進行Loop(); } } - this.ctWailingチップ模様アニメ.t進行Loop(); + if ( this.ctWailingチップ模様アニメ != null ) + { + this.ctWailingチップ模様アニメ.t進行Loop(); + } } protected bool t進行描画・フェードイン・アウト() diff --git a/DTXManiaプロジェクト/コード/ステージ/07.演奏/ドラム画面/CAct演奏Drumsグラフ.cs b/DTXManiaプロジェクト/コード/ステージ/07.演奏/ドラム画面/CAct演奏Drumsグラフ.cs index 0715ade9..94f618ab 100644 --- a/DTXManiaプロジェクト/コード/ステージ/07.演奏/ドラム画面/CAct演奏Drumsグラフ.cs +++ b/DTXManiaプロジェクト/コード/ステージ/07.演奏/ドラム画面/CAct演奏Drumsグラフ.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Drawing; +using System.IO; using SlimDX; using FDK; @@ -70,7 +71,11 @@ namespace DTXMania { if( !base.b活性化してない ) { - this.txグラフ = CDTXMania.tテクスチャの生成(CSkin.Path(@"Graphics\ScreenPlay graph.png")); + string pathグラフ = CSkin.Path( @"Graphics\ScreenPlay graph.png" ); + if ( File.Exists( pathグラフ ) ) + { + this.txグラフ = CDTXMania.tテクスチャの生成( pathグラフ ); + } base.OnManagedリソースの作成(); } } diff --git a/DTXManiaプロジェクト/コード/全体/CConfigIni.cs b/DTXManiaプロジェクト/コード/全体/CConfigIni.cs index 0bcc5543..49dba5ac 100644 --- a/DTXManiaプロジェクト/コード/全体/CConfigIni.cs +++ b/DTXManiaプロジェクト/コード/全体/CConfigIni.cs @@ -482,6 +482,7 @@ namespace DTXMania public int nPoliphonicSounds; // #28228 2012.5.1 yyagi レーン毎の最大同時発音数 public bool bバッファ入力を行う; public bool bIsEnabledSystemMenu; // #28200 2012.5.1 yyagi System Menuの使用可否切替 + public string strSkinSubfolder; // #28195 2012.5.2 yyagi Skin切替用 System/以下のサブフォルダ名 public bool bConfigIniがないかDTXManiaのバージョンが異なる { get @@ -1016,6 +1017,7 @@ namespace DTXMania this.eBDGroup = EBDGroup.打ち分ける; // #27029 2012.1.4 from HHPedalとBassPedalのグルーピング this.nPoliphonicSounds = 4; // #28228 2012.5.1 yyagi レーン毎の最大同時発音数 this.bIsEnabledSystemMenu = true; // #28200 2012.5.1 yyagi System Menuの利用可否切替(使用可) + this.strSkinSubfolder = ""; // #28195 2012.5.2 yyagi 使用中のSkinサブフォルダ名 } public CConfigIni( string iniファイル名 ) : this() @@ -1072,13 +1074,23 @@ namespace DTXMania #endif sw.WriteLine( "; リリースバージョン" ); + sw.WriteLine( "; Release Version." ); sw.WriteLine( "Version={0}", CDTXMania.VERSION ); sw.WriteLine(); sw.WriteLine( "; 演奏データの格納されているフォルダへのパス。" ); sw.WriteLine( @"; セミコロン(;)で区切ることにより複数のパスを指定できます。(例: d:\DTXFiles1\;e:\DTXFiles2\)" ); + sw.WriteLine( "; Pathes for DTX data." ); + sw.WriteLine( @"; You can specify many pathes separated with semicolon(;). (e.g. d:\DTXFiles1\;e:\DTXFiles2\)" ); sw.WriteLine( "DTXPath={0}", this.str曲データ検索パス ); sw.WriteLine(); + sw.WriteLine( "; 使用するSkinのサブフォルダ名。" ); + sw.WriteLine( "; System/SkinFiles.Default/Graphics/... などの場合は、SkinPath=SkinFiles.Default を指定します。" ); + sw.WriteLine( "; Skin subfolder path." ); + sw.WriteLine( "; e.g. System/SkinFiles.Default/Graphics/... -> Set SkinPath=SkinFiles.Default" ); + sw.WriteLine( "SkinPath={0}", this.strSkinSubfolder ); + sw.WriteLine(); sw.WriteLine( "; 画面モード(0:ウィンドウ, 1:全画面)" ); + sw.WriteLine( "; Screen mode. (0:Window, 1:Fullscreen)" ); sw.WriteLine( "FullScreen={0}", this.b全画面モード ? 1 : 0 ); sw.WriteLine(); @@ -1701,7 +1713,11 @@ namespace DTXMania { this.str曲データ検索パス = str4; } - else if( str3.Equals( "FullScreen" ) ) + else if ( str3.Equals( "SkinPath" ) ) + { + this.strSkinSubfolder = str4; + } + else if ( str3.Equals( "FullScreen" ) ) { this.b全画面モード = C変換.bONorOFF( str4[ 0 ] ); } diff --git a/DTXManiaプロジェクト/コード/全体/CDTXMania.cs b/DTXManiaプロジェクト/コード/全体/CDTXMania.cs index a35a0fc2..6b9904f5 100644 --- a/DTXManiaプロジェクト/コード/全体/CDTXMania.cs +++ b/DTXManiaプロジェクト/コード/全体/CDTXMania.cs @@ -1476,8 +1476,10 @@ for (int i = 0; i < 3; i++) { Trace.Indent(); try { - Skin = new CSkin(); - Trace.TraceInformation( "スキンの初期化を完了しました。" ); + Trace.TraceInformation( "初期化開始。{0}", CDTXMania.ConfigIni.strSkinSubfolder ); + Skin = new CSkin( CDTXMania.ConfigIni.strSkinSubfolder ); + CDTXMania.ConfigIni.strSkinSubfolder = CSkin.strSkinSubfolder; // 旧指定のSkinフォルダが消滅していた場合に備える + Trace.TraceInformation( "スキンの初期化を完了しました。{0}",CDTXMania.ConfigIni.strSkinSubfolder ); } catch { diff --git a/DTXManiaプロジェクト/コード/全体/CSkin.cs b/DTXManiaプロジェクト/コード/全体/CSkin.cs index c77d01ca..95341b4f 100644 --- a/DTXManiaプロジェクト/コード/全体/CSkin.cs +++ b/DTXManiaプロジェクト/コード/全体/CSkin.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using System.IO; +using System.Diagnostics; using FDK; namespace DTXMania @@ -266,22 +267,22 @@ namespace DTXMania // プロパティ - public Cシステムサウンド bgmオプション画面; - public Cシステムサウンド bgmコンフィグ画面; - public Cシステムサウンド bgm起動画面; - public Cシステムサウンド bgm選曲画面; - public Cシステムサウンド soundSTAGEFAILED音; - public Cシステムサウンド soundカーソル移動音; - public Cシステムサウンド soundゲーム開始音; - public Cシステムサウンド soundゲーム終了音; - public Cシステムサウンド soundステージクリア音; - public Cシステムサウンド soundタイトル音; - public Cシステムサウンド soundフルコンボ音; - public Cシステムサウンド sound歓声音; - public Cシステムサウンド sound曲読込開始音; - public Cシステムサウンド sound決定音; - public Cシステムサウンド sound取消音; - public Cシステムサウンド sound変更音; + public Cシステムサウンド bgmオプション画面 = null; + public Cシステムサウンド bgmコンフィグ画面 = null; + public Cシステムサウンド bgm起動画面 = null; + public Cシステムサウンド bgm選曲画面 = null; + public Cシステムサウンド soundSTAGEFAILED音 = null; + public Cシステムサウンド soundカーソル移動音 = null; + public Cシステムサウンド soundゲーム開始音 = null; + public Cシステムサウンド soundゲーム終了音 = null; + public Cシステムサウンド soundステージクリア音 = null; + public Cシステムサウンド soundタイトル音 = null; + public Cシステムサウンド soundフルコンボ音 = null; + public Cシステムサウンド sound歓声音 = null; + public Cシステムサウンド sound曲読込開始音 = null; + public Cシステムサウンド sound決定音 = null; + public Cシステムサウンド sound取消音 = null; + public Cシステムサウンド sound変更音 = null; public readonly int nシステムサウンド数 = 16; public Cシステムサウンド this[ Eシステムサウンド sound ] { @@ -398,11 +399,55 @@ namespace DTXMania } } + public string[] strSkinSubfolders = null; // ListだとignoreCaseな検索が面倒なので、配列に逃げる :-) + public static string strSkinSubfolder = null; // コンストラクタ - + public CSkin( string _strSkinSubfolder ) + { + strSkinSubfolder = _strSkinSubfolder; + ReloadSkinPaths(); + Trace.TraceInformation( "SkinPath設定: {0}", strSkinSubfolder ); + ReloadSkin(); + } public CSkin() { + ReloadSkinPaths(); + Trace.TraceInformation( "SkinPath設定: {0}", strSkinSubfolder ); + ReloadSkin(); + //this.soundカーソル移動音 = new Cシステムサウンド( @"Sounds\Move.ogg", false, false, false ); + //this.sound決定音 = new Cシステムサウンド( @"Sounds\Decide.ogg", false, false, false ); + //this.sound変更音 = new Cシステムサウンド( @"Sounds\Change.ogg", false, false, false ); + //this.sound取消音 = new Cシステムサウンド( @"Sounds\Cancel.ogg", false, false, true ); + //this.sound歓声音 = new Cシステムサウンド( @"Sounds\Audience.ogg", false, false, true ); + //this.soundSTAGEFAILED音 = new Cシステムサウンド( @"Sounds\Stage failed.ogg", false, true, true ); + //this.soundゲーム開始音 = new Cシステムサウンド( @"Sounds\Game start.ogg", false, false, false ); + //this.soundゲーム終了音 = new Cシステムサウンド( @"Sounds\Game end.ogg", false, true, false ); + //this.soundステージクリア音 = new Cシステムサウンド( @"Sounds\Stage clear.ogg", false, true, true ); + //this.soundフルコンボ音 = new Cシステムサウンド( @"Sounds\Full combo.ogg", false, false, true ); + //this.sound曲読込開始音 = new Cシステムサウンド( @"Sounds\Now loading.ogg", false, true, true ); + //this.soundタイトル音 = new Cシステムサウンド( @"Sounds\Title.ogg", false, true, false ); + //this.bgm起動画面 = new Cシステムサウンド( @"Sounds\Setup BGM.ogg", true, true, false ); + //this.bgmオプション画面 = new Cシステムサウンド( @"Sounds\Option BGM.ogg", true, true, false ); + //this.bgmコンフィグ画面 = new Cシステムサウンド( @"Sounds\Config BGM.ogg", true, true, false ); + //this.bgm選曲画面 = new Cシステムサウンド( @"Sounds\Select BGM.ogg", true, true, false ); + } + + /// + /// Skin(Sounds)を再読込する。 + /// あらかじめstrSkinSubfolderを適切に設定しておくこと。 + /// その後、ReloadSkinPaths()を実行し、strSkinSubfolderの正当性を確認した上で、本メソッドを呼び出すこと。 + /// + private void ReloadSkin() + { + for ( int i = 0; i < nシステムサウンド数; i++ ) + { + if ( this[ i ] != null && this[i].b読み込み成功 ) + { + this[ i ].t停止する(); + this[ i ].Dispose(); + } + } this.soundカーソル移動音 = new Cシステムサウンド( @"Sounds\Move.ogg", false, false, false ); this.sound決定音 = new Cシステムサウンド( @"Sounds\Decide.ogg", false, false, false ); this.sound変更音 = new Cシステムサウンド( @"Sounds\Change.ogg", false, false, false ); @@ -421,12 +466,67 @@ namespace DTXMania this.bgm選曲画面 = new Cシステムサウンド( @"Sounds\Select BGM.ogg", true, true, false ); } + /// + /// Skinの一覧を再取得する。 + /// System/SkinFiles.*****/Graphics (やSounds/) というフォルダ構成を想定している。 + /// もし再取得の結果、現在使用中のSkinのパス(strSkinSubfloder)が消えていた場合は、 + /// 以下の優先順位で存在確認の上strSkinSubfolderを再設定する。 + /// 1. System/SkinFiles.Default/ + /// 2. System/SkinFiles.*****/ で最初にenumerateされたもの + /// 3. System/ (従来互換) + /// + public void ReloadSkinPaths() + { + string path; + #region [ まず System/SkinFiles.*** をenumerateする ] + path = System.IO.Path.Combine( CDTXMania.strEXEのあるフォルダ, "System" ); + strSkinSubfolders = System.IO.Directory.GetDirectories( path, "SkinFiles.*" ); + for ( int i = 0; i < strSkinSubfolders.Length; i++ ) + { + string[] spl = strSkinSubfolders[ i ].Split( System.IO.Path.DirectorySeparatorChar ); + strSkinSubfolders[ i ] = spl[ spl.Length - 1 ]; // subfolder名から、~~/System/ までの部分を削除 + Trace.TraceInformation( "SkinPath検出: {0}", strSkinSubfolders[ i ] ); + } + Array.Sort( strSkinSubfolders ); // BinarySearch実行前にSortが必要 + #endregion + #region [ 次に、カレントのSkinパスが存在するか調べる。あれば終了。] + if ( Array.BinarySearch( strSkinSubfolders, strSkinSubfolder, StringComparer.InvariantCultureIgnoreCase ) >= 0 ) + return; + #endregion + #region [ カレントのSkinパスが消滅しているので、再設定する。] + /// 以下の優先順位で現在使用中のSkinパスを再設定する。 + /// 1. System/SkinFiles.Default/ + /// 2. System/SkinFiles.*****/ で最初にenumerateされたもの + /// 3. System/ (従来互換) + #region [ System/SkinFiles.Default/ があるなら、そこにカレントSkinパスを設定する] + if ( Array.BinarySearch( strSkinSubfolders, "SkinFiles.Default", StringComparer.InvariantCultureIgnoreCase ) >= 0 ) + { + strSkinSubfolder = "SkinFiles.Default"; + return; + } + #endregion + #region [ System/SkinFiles.*****/ で最初にenumerateされたものを、カレントSkinパスに再設定する ] + if ( strSkinSubfolders.Length > 0 ) + { + strSkinSubfolder = strSkinSubfolders[ 0 ]; + return; + } + #endregion + #region [ System/ に、カレントSkinパスを再設定する。] + strSkinSubfolder = ""; // ""にすることで、結果的に System/ 相当の相対パスになる。 + #endregion + #endregion + } // メソッド public static string Path( string strファイルの相対パス ) { - return ( CDTXMania.strEXEのあるフォルダ + @"System\" + strファイルの相対パス ); + string path; + path = System.IO.Path.Combine( CDTXMania.strEXEのあるフォルダ, "System" ); + path = System.IO.Path.Combine( path, strSkinSubfolder ); + path = System.IO.Path.Combine( path, strファイルの相対パス ); + return path; } #region [ IDisposable 実装 ]