Skip to content

Commit

Permalink
Add raw map extractor option
Browse files Browse the repository at this point in the history
  • Loading branch information
Supamiu committed Oct 3, 2023
1 parent 051e78a commit 3cfab97
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions SaintCoinach.Cmd/Commands/MapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public MapCommand(ARealmReversed realm)

public override async Task<bool> InvokeAsync(string paramList) {
var format = ImageFormat.Png;
var rawFileNames = false;

if (!string.IsNullOrEmpty(paramList)) {
var parameters = paramList.Split(' ');
rawFileNames = parameters.Contains("raw");
if (parameters.Contains("jpg"))
format = ImageFormat.Jpeg;
else if (parameters.Contains("png"))
Expand All @@ -45,27 +47,32 @@ public override async Task<bool> InvokeAsync(string paramList) {
continue;

var outPathSb = new StringBuilder("ui/map/");
var territoryName = map.TerritoryType?.Name?.ToString();
if (!string.IsNullOrEmpty(territoryName)) {
if (territoryName.Length < 3) {
outPathSb.AppendFormat("{0}/", territoryName);
if(rawFileNames) {
outPathSb.AppendFormat("{0}/{1}", map.Id.ToString().Split('/')[0], map.Id.ToString().Replace("/", "."));
outPathSb.Append(FormatToExtension(format));
} else {
var territoryName = map.TerritoryType?.Name?.ToString();
if (!string.IsNullOrEmpty(territoryName)) {
if (territoryName.Length < 3) {
outPathSb.AppendFormat("{0}/", territoryName);
}
else {
outPathSb.AppendFormat("{0}/", territoryName.Substring(0, 3));
}

outPathSb.AppendFormat("{0} - ", territoryName);
}
else {
outPathSb.AppendFormat("{0}/", territoryName.Substring(0, 3));
outPathSb.AppendFormat("{0}", ToPathSafeString(map.PlaceName.Name.ToString()));
if (map.LocationPlaceName != null && map.LocationPlaceName.Key != 0 && !map.LocationPlaceName.Name.IsEmpty)
outPathSb.AppendFormat(" - {0}", ToPathSafeString(map.LocationPlaceName.Name.ToString()));
var mapKey = outPathSb.ToString();
fileSet.TryGetValue(mapKey, out int mapIndex);
if (mapIndex > 0) {
outPathSb.AppendFormat(" - {0}", mapIndex);
}

outPathSb.AppendFormat("{0} - ", territoryName);
}
outPathSb.AppendFormat("{0}", ToPathSafeString(map.PlaceName.Name.ToString()));
if (map.LocationPlaceName != null && map.LocationPlaceName.Key != 0 && !map.LocationPlaceName.Name.IsEmpty)
outPathSb.AppendFormat(" - {0}", ToPathSafeString(map.LocationPlaceName.Name.ToString()));
var mapKey = outPathSb.ToString();
fileSet.TryGetValue(mapKey, out int mapIndex);
if (mapIndex > 0) {
outPathSb.AppendFormat(" - {0}", mapIndex);
fileSet[mapKey] = mapIndex + 1;
outPathSb.Append(FormatToExtension(format));
}
fileSet[mapKey] = mapIndex + 1;
outPathSb.Append(FormatToExtension(format));

var outFile = new FileInfo(Path.Combine(_Realm.GameVersion, outPathSb.ToString()));
if (!outFile.Directory.Exists)
Expand Down

0 comments on commit 3cfab97

Please sign in to comment.