OSDN Git Service

#36256 スキンフォルダの保存パスが相対パスになるよう修正。
authoryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Mon, 18 Jul 2016 17:28:06 +0000 (17:28 +0000)
committeryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Mon, 18 Jul 2016 17:28:06 +0000 (17:28 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/trunk@1000 16f42ceb-6dc6-49c8-ba94-f2d53467949d

DTXManiaプロジェクト/コード/全体/CDTXMania.cs
実行時フォルダ/DTXManiaGR.exe

index 6fa6320..beb7d8c 100644 (file)
@@ -15,6 +15,7 @@ using FDK;
 using SampleFramework;\r
 using System.Runtime.Serialization;\r
 using System.Xml;\r
+using System.Web;\r
 \r
 namespace DTXMania\r
 {\r
@@ -1987,7 +1988,35 @@ namespace DTXMania
 \r
                public void SaveConfig()\r
                {\r
-                       CDTXMania.SerializeXML(strEXEのあるフォルダ + "Config.xml", ConfigIni);\r
+\r
+                       #region [ Skinパスの絶対パス→相対パス変換 ]\r
+                       string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;\r
+                       Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );\r
+                       if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )\r
+                       {\r
+                               // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。\r
+                               // → 初期値として Default/ を設定する。\r
+                               ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );\r
+                       }\r
+\r
+                       // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。\r
+                       // そのため、以下の処理を通すために、いったん絶対パスに変換\r
+                       if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )\r
+                       {\r
+                               ConfigIni.strSystemSkinSubfolderPath.Value =\r
+                                       Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );\r
+                       }\r
+\r
+                       Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );\r
+                       string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString();                         // 相対パスを取得\r
+                       relPath = System.Web.HttpUtility.UrlDecode( relPath );                                          // デコードする\r
+                       relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar );        // 区切り文字が\ではなく/なので置換する\r
+                       ConfigIni.strSystemSkinSubfolderPath.Value = relPath;\r
+                       #endregion\r
+                       CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );\r
+\r
+                       // 元の絶対パスに戻す\r
+                       ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;\r
                }\r
 \r
                public void LoadConfig()\r
@@ -2006,6 +2035,12 @@ namespace DTXMania
                                        ConfigIni = new CConfigXml();\r
                                        SaveConfig();\r
                                }\r
+                               // Skinパスの相対パスを、絶対パスに変換\r
+                               if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )\r
+                               {\r
+                                       ConfigIni.strSystemSkinSubfolderPath.Value =\r
+                                               Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );\r
+                               }\r
                        }\r
                }\r
 \r
index 6308a3a..0301635 100644 (file)
Binary files a/実行時フォルダ/DTXManiaGR.exe and b/実行時フォルダ/DTXManiaGR.exe differ