mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RomManipulation] Make game cleaning more standardized
This commit is contained in:
@@ -168,14 +168,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in cleaning mode, sanitize the game name
|
// If we're in cleaning mode, sanitize the game name
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
///Run the name through the filters to make sure that it's correct
|
gamename = CleanGameName(gamename);
|
||||||
gamename = Style.NormalizeChars(gamename);
|
|
||||||
gamename = Style.RussianToLatin(gamename);
|
|
||||||
gamename = Style.SearchPattern(gamename);
|
|
||||||
gamename = gamename.TrimStart().TrimEnd();
|
|
||||||
|
|
||||||
gamename = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(gamename).Groups[1].Value;
|
|
||||||
gamename = gamename.TrimStart().TrimEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RomData rom = new RomData
|
RomData rom = new RomData
|
||||||
@@ -511,13 +504,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in cleaning mode, sanitize the game name
|
// If we're in cleaning mode, sanitize the game name
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
///Run the name through the filters to make sure that it's correct
|
rominfo[3] = CleanGameName(rominfo[3]);
|
||||||
rominfo[3] = Style.NormalizeChars(rominfo[3]);
|
|
||||||
rominfo[3] = Style.RussianToLatin(rominfo[3]);
|
|
||||||
rominfo[3] = Style.SearchPattern(rominfo[3]);
|
|
||||||
|
|
||||||
rominfo[3] = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(rominfo[3]).Groups[1].Value;
|
|
||||||
rominfo[3] = rominfo[3].TrimStart().TrimEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RomData rom = new RomData
|
RomData rom = new RomData
|
||||||
@@ -583,13 +570,10 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
string tempgame = String.Join("\\", parent);
|
string tempgame = String.Join("\\", parent);
|
||||||
|
|
||||||
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same if in clean mode
|
// If we're in cleaning mode, sanitize the game name
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
string[] splitgame = tempgame.Split(Path.DirectorySeparatorChar);
|
tempgame = CleanGameName(tempgame.Split(Path.DirectorySeparatorChar));
|
||||||
splitgame[splitgame.Length - 1] = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(splitgame[splitgame.Length - 1]).Groups[1].Value;
|
|
||||||
tempgame = String.Join(Path.DirectorySeparatorChar.ToString(), splitgame);
|
|
||||||
tempgame = tempgame.TrimStart().TrimEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RomData rom = new RomData
|
RomData rom = new RomData
|
||||||
@@ -1009,18 +993,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in clean mode, sanitize the game name
|
// If we're in clean mode, sanitize the game name
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
string[] splitgame = tempname.Split(Path.DirectorySeparatorChar);
|
tempname = CleanGameName(tempname.Split(Path.DirectorySeparatorChar));
|
||||||
string intname = splitgame[splitgame.Length - 1];
|
|
||||||
|
|
||||||
///Run the name through the filters to make sure that it's correct
|
|
||||||
intname = Style.NormalizeChars(intname);
|
|
||||||
intname = Style.RussianToLatin(intname);
|
|
||||||
intname = Style.SearchPattern(intname);
|
|
||||||
|
|
||||||
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same if in clean mode
|
|
||||||
splitgame[splitgame.Length - 1] = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(intname).Groups[1].Value;
|
|
||||||
tempname = String.Join(Path.DirectorySeparatorChar.ToString(), splitgame);
|
|
||||||
tempname = tempname.TrimStart().TrimEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add the rom if there's useful information in it
|
// Only add the rom if there's useful information in it
|
||||||
@@ -1077,13 +1050,10 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
tempname = (parent.Count > 0 ? String.Join("\\", parent) + Path.DirectorySeparatorChar : "") + tempname;
|
tempname = (parent.Count > 0 ? String.Join("\\", parent) + Path.DirectorySeparatorChar : "") + tempname;
|
||||||
|
|
||||||
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same if in clean mode
|
// If we're in cleaning mode, sanitize the game name
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
string[] splitgame = tempname.Split(Path.DirectorySeparatorChar);
|
tempname = CleanGameName(tempname.Split(Path.DirectorySeparatorChar));
|
||||||
splitgame[splitgame.Length - 1] = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(splitgame[splitgame.Length - 1]).Groups[1].Value;
|
|
||||||
tempname = String.Join(Path.DirectorySeparatorChar.ToString(), splitgame);
|
|
||||||
tempname = tempname.TrimStart().TrimEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RomData rom = new RomData
|
RomData rom = new RomData
|
||||||
@@ -1245,13 +1215,10 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same if in clean mode
|
// If we're in cleaning mode, sanitize the game name
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
string[] splitgame = tempname.Split(Path.DirectorySeparatorChar);
|
tempname = CleanGameName(tempname.Split(Path.DirectorySeparatorChar));
|
||||||
splitgame[splitgame.Length - 1] = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(splitgame[splitgame.Length - 1]).Groups[1].Value;
|
|
||||||
tempname = String.Join(Path.DirectorySeparatorChar.ToString(), splitgame);
|
|
||||||
tempname = tempname.TrimStart().TrimEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add the rom if there's useful information in it
|
// Only add the rom if there's useful information in it
|
||||||
@@ -1524,5 +1491,35 @@ namespace SabreTools.Helper
|
|||||||
logger.User("A total of " + count + " file hashes will be written out to file");
|
logger.User("A total of " + count + " file hashes will be written out to file");
|
||||||
return sortable;
|
return sortable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean a game (or rom) name to the WoD standard
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">Name of the game to be cleaned</param>
|
||||||
|
/// <returns>The cleaned name</returns>
|
||||||
|
public static string CleanGameName(string game)
|
||||||
|
{
|
||||||
|
///Run the name through the filters to make sure that it's correct
|
||||||
|
game = Style.NormalizeChars(game);
|
||||||
|
game = Style.RussianToLatin(game);
|
||||||
|
game = Style.SearchPattern(game);
|
||||||
|
|
||||||
|
game = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(game).Groups[1].Value;
|
||||||
|
game = game.TrimStart().TrimEnd();
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean a game (or rom) name to the WoD standard
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">Array representing the path to be cleaned</param>
|
||||||
|
/// <returns>The cleaned name</returns>
|
||||||
|
public static string CleanGameName(string[] game)
|
||||||
|
{
|
||||||
|
game[game.Length - 1] = CleanGameName(game[game.Length - 1]);
|
||||||
|
string outgame = String.Join(Path.DirectorySeparatorChar.ToString(), game);
|
||||||
|
outgame = outgame.TrimStart().TrimEnd();
|
||||||
|
return outgame;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user