From: yyagi Date: Mon, 18 Jul 2016 17:28:06 +0000 (+0000) Subject: #36256 スキンフォルダの保存パスが相対パスになるよう修正。 X-Git-Tag: Release099f~3^2~63 X-Git-Url: http://git.osdn.net/view?p=dtxmania%2Fdtxmania.git;a=commitdiff_plain;h=300626098326e147169066af642e1a1002539f88 #36256 スキンフォルダの保存パスが相対パスになるよう修正。 git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/trunk@1000 16f42ceb-6dc6-49c8-ba94-f2d53467949d --- diff --git a/DTXManiaプロジェクト/コード/全体/CDTXMania.cs b/DTXManiaプロジェクト/コード/全体/CDTXMania.cs index 6fa63207..beb7d8c0 100644 --- a/DTXManiaプロジェクト/コード/全体/CDTXMania.cs +++ b/DTXManiaプロジェクト/コード/全体/CDTXMania.cs @@ -15,6 +15,7 @@ using FDK; using SampleFramework; using System.Runtime.Serialization; using System.Xml; +using System.Web; namespace DTXMania { @@ -1987,7 +1988,35 @@ namespace DTXMania public void SaveConfig() { - CDTXMania.SerializeXML(strEXEのあるフォルダ + "Config.xml", ConfigIni); + + #region [ Skinパスの絶対パス→相対パス変換 ] + string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value; + Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) ); + if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 ) + { + // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。 + // → 初期値として Default/ を設定する。 + ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar ); + } + + // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。 + // そのため、以下の処理を通すために、いったん絶対パスに変換 + if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) ) + { + ConfigIni.strSystemSkinSubfolderPath.Value = + Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath ); + } + + Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) ); + string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString(); // 相対パスを取得 + relPath = System.Web.HttpUtility.UrlDecode( relPath ); // デコードする + relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar ); // 区切り文字が\ではなく/なので置換する + ConfigIni.strSystemSkinSubfolderPath.Value = relPath; + #endregion + CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni ); + + // 元の絶対パスに戻す + ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath; } public void LoadConfig() @@ -2006,6 +2035,12 @@ namespace DTXMania ConfigIni = new CConfigXml(); SaveConfig(); } + // Skinパスの相対パスを、絶対パスに変換 + if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) ) + { + ConfigIni.strSystemSkinSubfolderPath.Value = + Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath ); + } } } diff --git a/実行時フォルダ/DTXManiaGR.exe b/実行時フォルダ/DTXManiaGR.exe index 6308a3a6..03016353 100644 Binary files a/実行時フォルダ/DTXManiaGR.exe and b/実行時フォルダ/DTXManiaGR.exe differ