mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-25 04:14:13 +08:00
added game title lookup facility.
This commit is contained in:
parent
f9f9853810
commit
6a57bfb43d
@ -166,8 +166,8 @@ namespace GameRes.Formats.Cyberworks
|
|||||||
return null;
|
return null;
|
||||||
if (!has_images)
|
if (!has_images)
|
||||||
return new ArcFile (file, this, dir);
|
return new ArcFile (file, this, dir);
|
||||||
var options = Query<BellOptions> (arcStrings.ArcEncryptedNotice);
|
var scheme = QueryScheme (file.Name);
|
||||||
return new BellArchive (file, this, dir, options.Scheme);
|
return new BellArchive (file, this, dir, scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] ReadToc (string toc_name)
|
byte[] ReadToc (string toc_name)
|
||||||
@ -275,6 +275,15 @@ namespace GameRes.Formats.Cyberworks
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AImageScheme QueryScheme (string arc_name)
|
||||||
|
{
|
||||||
|
var title = FormatCatalog.Instance.LookupGame (arc_name);
|
||||||
|
if (!string.IsNullOrEmpty (title) && KnownSchemes.ContainsKey (title))
|
||||||
|
return KnownSchemes[title];
|
||||||
|
var options = Query<BellOptions> (arcStrings.ArcEncryptedNotice);
|
||||||
|
return options.Scheme;
|
||||||
|
}
|
||||||
|
|
||||||
public override ResourceOptions GetDefaultOptions ()
|
public override ResourceOptions GetDefaultOptions ()
|
||||||
{
|
{
|
||||||
return new BellOptions { Scheme = GetScheme (Settings.Default.BELLTitle) };
|
return new BellOptions { Scheme = GetScheme (Settings.Default.BELLTitle) };
|
||||||
|
@ -71,7 +71,6 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
public class Xp3Scheme : ResourceScheme
|
public class Xp3Scheme : ResourceScheme
|
||||||
{
|
{
|
||||||
public Dictionary<string, ICrypt> KnownSchemes;
|
public Dictionary<string, ICrypt> KnownSchemes;
|
||||||
public Dictionary<string, string> ExeMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Archive version 1: encrypt file first, then calculate checksum
|
// Archive version 1: encrypt file first, then calculate checksum
|
||||||
@ -749,25 +748,15 @@ NextEntry:
|
|||||||
|
|
||||||
ICrypt GuessCryptAlgorithm (ArcView file)
|
ICrypt GuessCryptAlgorithm (ArcView file)
|
||||||
{
|
{
|
||||||
if (0 == KiriKiriScheme.ExeMap.Count)
|
var title = FormatCatalog.Instance.LookupGame (file.Name);
|
||||||
|
if (string.IsNullOrEmpty (title))
|
||||||
return null;
|
return null;
|
||||||
var exe_pattern = VFS.CombinePath (VFS.GetDirectoryName (file.Name), "*.exe");
|
|
||||||
foreach (var exe in VFS.GetFiles (exe_pattern).Select (e => Path.GetFileName (e.Name)))
|
|
||||||
{
|
|
||||||
string title;
|
|
||||||
if (KiriKiriScheme.ExeMap.TryGetValue (exe, out title))
|
|
||||||
{
|
|
||||||
Settings.Default.XP3Scheme = title;
|
|
||||||
return GetScheme (title);
|
return GetScheme (title);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Xp3Scheme KiriKiriScheme = new Xp3Scheme
|
static Xp3Scheme KiriKiriScheme = new Xp3Scheme
|
||||||
{
|
{
|
||||||
KnownSchemes = new Dictionary<string, ICrypt>(),
|
KnownSchemes = new Dictionary<string, ICrypt>(),
|
||||||
ExeMap = new Dictionary<string, string>(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static IDictionary<string, ICrypt> KnownSchemes
|
public static IDictionary<string, ICrypt> KnownSchemes
|
||||||
|
@ -90,7 +90,7 @@ namespace GameRes.Formats.ShiinaRio // 椎名里緒
|
|||||||
if (index_offset >= file.MaxOffset)
|
if (index_offset >= file.MaxOffset)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var scheme = QueryEncryption();
|
var scheme = QueryEncryption (file.Name);
|
||||||
if (null == scheme)
|
if (null == scheme)
|
||||||
return null;
|
return null;
|
||||||
var decoder = new Decoder (version, scheme);
|
var decoder = new Decoder (version, scheme);
|
||||||
@ -282,10 +282,18 @@ namespace GameRes.Formats.ShiinaRio // 椎名里緒
|
|||||||
return new GUI.WidgetWARC();
|
return new GUI.WidgetWARC();
|
||||||
}
|
}
|
||||||
|
|
||||||
EncryptionScheme QueryEncryption ()
|
EncryptionScheme QueryEncryption (string arc_name)
|
||||||
|
{
|
||||||
|
EncryptionScheme scheme = null;
|
||||||
|
var title = FormatCatalog.Instance.LookupGame (arc_name);
|
||||||
|
if (!string.IsNullOrEmpty (title))
|
||||||
|
scheme = GetScheme (title);
|
||||||
|
if (null == scheme)
|
||||||
{
|
{
|
||||||
var options = Query<WarOptions> (arcStrings.ArcEncryptedNotice);
|
var options = Query<WarOptions> (arcStrings.ArcEncryptedNotice);
|
||||||
return options.Scheme;
|
scheme = options.Scheme;
|
||||||
|
}
|
||||||
|
return scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EncryptionScheme GetScheme (string scheme)
|
static EncryptionScheme GetScheme (string scheme)
|
||||||
|
@ -53,6 +53,8 @@ namespace GameRes
|
|||||||
private MultiValueDictionary<string, IResource> m_extension_map = new MultiValueDictionary<string, IResource>();
|
private MultiValueDictionary<string, IResource> m_extension_map = new MultiValueDictionary<string, IResource>();
|
||||||
private MultiValueDictionary<uint, IResource> m_signature_map = new MultiValueDictionary<uint, IResource>();
|
private MultiValueDictionary<uint, IResource> m_signature_map = new MultiValueDictionary<uint, IResource>();
|
||||||
|
|
||||||
|
private Dictionary<string, string> m_game_map = new Dictionary<string, string>();
|
||||||
|
|
||||||
/// <summary> The only instance of this class.</summary>
|
/// <summary> The only instance of this class.</summary>
|
||||||
public static FormatCatalog Instance { get { return m_instance; } }
|
public static FormatCatalog Instance { get { return m_instance; } }
|
||||||
|
|
||||||
@ -205,6 +207,23 @@ namespace GameRes
|
|||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Look up game title based on archive <paramref name="arc_name"/> and files matching
|
||||||
|
/// <paramref name="pattern"/> in the same directory as archive.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Game title, or null if no match was found.</returns>
|
||||||
|
public string LookupGame (string arc_name, string pattern = "*.exe")
|
||||||
|
{
|
||||||
|
pattern = VFS.CombinePath (VFS.GetDirectoryName (arc_name), pattern);
|
||||||
|
foreach (var file in VFS.GetFiles (pattern).Select (e => Path.GetFileName (e.Name)))
|
||||||
|
{
|
||||||
|
string title;
|
||||||
|
if (m_game_map.TryGetValue (file, out title))
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void DeserializeScheme (Stream input)
|
public void DeserializeScheme (Stream input)
|
||||||
{
|
{
|
||||||
using (var reader = new BinaryReader (input, System.Text.Encoding.UTF8, true))
|
using (var reader = new BinaryReader (input, System.Text.Encoding.UTF8, true))
|
||||||
@ -228,6 +247,8 @@ namespace GameRes
|
|||||||
format.Scheme = scheme;
|
format.Scheme = scheme;
|
||||||
}
|
}
|
||||||
CurrentSchemeVersion = db.Version;
|
CurrentSchemeVersion = db.Version;
|
||||||
|
if (db.GameMap != null)
|
||||||
|
m_game_map = db.GameMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +256,8 @@ namespace GameRes
|
|||||||
{
|
{
|
||||||
var db = new SchemeDataBase {
|
var db = new SchemeDataBase {
|
||||||
Version = CurrentSchemeVersion,
|
Version = CurrentSchemeVersion,
|
||||||
SchemeMap = new Dictionary<string, ResourceScheme>()
|
SchemeMap = new Dictionary<string, ResourceScheme>(),
|
||||||
|
GameMap = m_game_map,
|
||||||
};
|
};
|
||||||
foreach (var format in Formats)
|
foreach (var format in Formats)
|
||||||
{
|
{
|
||||||
@ -265,5 +287,6 @@ namespace GameRes
|
|||||||
public int Version;
|
public int Version;
|
||||||
|
|
||||||
public Dictionary<string, ResourceScheme> SchemeMap;
|
public Dictionary<string, ResourceScheme> SchemeMap;
|
||||||
|
public Dictionary<string, string> GameMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user