稍微修改

This commit is contained in:
tangbin
2025-09-10 20:01:05 +08:00
parent deab39ea12
commit c74d65a74f
6 changed files with 80 additions and 68 deletions

View File

@@ -38,8 +38,18 @@ public class UIMapPanel : MonoBehaviour
return;
}
MapManager.Instance.allMaps.Clear();
string[] mapFolders = Directory.GetDirectories(mapsDirectory);
foreach (string folderPath in mapFolders)
string[] mapFolders = Directory.GetDirectories(mapsDirectory);
// <20><> mapId <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var sortedMapFolders = mapFolders
.OrderBy(folderPath =>
{
string folderName = Path.GetFileName(folderPath); // <20><><EFBFBD><EFBFBD> "v1000"
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
var match = Regex.Match(folderName, @"\d+");
return match.Success ? int.Parse(match.Value) : int.MaxValue;
})
.ToArray();
foreach (string folderPath in sortedMapFolders)
{
string[] pathSplit = folderPath.Split(Path.DirectorySeparatorChar);
string mapId = pathSplit[pathSplit.Length - 1]; // <20><><EFBFBD><EFBFBD> "v1000"
@@ -50,7 +60,7 @@ public class UIMapPanel : MonoBehaviour
string[] imageFiles = Directory.GetFiles(textureDirectory, "*.jpg");
int maxRow = 0;
int maxCol = 0;
string pattern = $@"{mapId}_r(\d+)_c(\d+)"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ƥ<EFBFBD><C6A5> v1000_rXX_cYY
string pattern = $@"r(\d+)_c(\d+)"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ƥ<EFBFBD><C6A5> v1000_rXX_cYY
Regex regex = new Regex(pattern);
foreach (string filePath in imageFiles)
@@ -159,7 +169,7 @@ public class UIMapPanel : MonoBehaviour
int col = (index % width) + 1;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>ͼID<49><44>
string newFileName = $"v{mapId}_r{row}_c{col}";
string newFileName = $"r{row}_c{col}";
string newFilePath = Path.Combine(mapsDirectory, newFileName + fileExtension);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
@@ -190,7 +200,7 @@ public class UIMapPanel : MonoBehaviour
private bool IsAlreadyRenamed(string[] imageFiles, int mapId)
{
// Ŀ<><C4BF><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>v{mapId}_r<5F><72><EFBFBD><EFBFBD>_c<5F><63><EFBFBD><EFBFBD>
string pattern = $"^v{mapId}_r\\d+_c\\d+$";
string pattern = $"^r\\d+_c\\d+$";
var regex = new System.Text.RegularExpressions.Regex(pattern);
foreach (string filePath in imageFiles)
@@ -218,7 +228,7 @@ public class UIMapPanel : MonoBehaviour
{
bool hasMapFormat = false;
bool hasTargetFormat = false;
string pattern = $"^v{mapId}_r\\d+_c\\d+$";
string pattern = $"^r\\d+_c\\d+$";
var regex = new System.Text.RegularExpressions.Regex(pattern);
foreach (string filePath in imageFiles)