mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(NpkOpener): added default encoding field.
added known titles list as widget parameter.
This commit is contained in:
parent
9f3b92e0c4
commit
a775bfe557
@ -29,6 +29,7 @@ using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using GameRes.Formats.Strings;
|
||||
using GameRes.Utility;
|
||||
|
||||
@ -87,14 +88,16 @@ namespace GameRes.Formats.NitroPlus
|
||||
public override bool IsHierarchic { get { return true; } }
|
||||
public override bool CanWrite { get { return true; } }
|
||||
|
||||
public static Dictionary<string, byte[]> KnownKeys = new Dictionary<string, byte[]>();
|
||||
static Npk2Scheme DefaultScheme = new Npk2Scheme { KnownKeys = new Dictionary<string, byte[]>() };
|
||||
internal Dictionary<string, byte[]> KnownKeys { get { return DefaultScheme.KnownKeys; } }
|
||||
|
||||
const uint DefaultSegmentSize = 0x10000;
|
||||
static readonly Encoding DefaultEncoding = Encoding.UTF8;
|
||||
|
||||
public override ResourceScheme Scheme
|
||||
{
|
||||
get { return new Npk2Scheme { KnownKeys = KnownKeys }; }
|
||||
set { KnownKeys = ((Npk2Scheme)value).KnownKeys; }
|
||||
get { return DefaultScheme; }
|
||||
set { DefaultScheme = (Npk2Scheme)value; }
|
||||
}
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
@ -144,7 +147,7 @@ namespace GameRes.Formats.NitroPlus
|
||||
if (0 == name_length || name_length > name_buffer.Length)
|
||||
return null;
|
||||
index.Read (name_buffer, 0, name_length);
|
||||
var name = Encodings.cp932.GetString (name_buffer, 0, name_length);
|
||||
var name = DefaultEncoding.GetString (name_buffer, 0, name_length);
|
||||
var entry = FormatCatalog.Instance.Create<NpkEntry> (name);
|
||||
entry.UnpackedSize = index.ReadUInt32();
|
||||
index.Read (name_buffer, 0, 0x20); // skip
|
||||
@ -206,12 +209,12 @@ namespace GameRes.Formats.NitroPlus
|
||||
|
||||
public override object GetAccessWidget ()
|
||||
{
|
||||
return new GUI.WidgetNPK();
|
||||
return new GUI.WidgetNPK (KnownKeys.Keys);
|
||||
}
|
||||
|
||||
public override object GetCreationWidget ()
|
||||
{
|
||||
return new GUI.WidgetNPK();
|
||||
return new GUI.WidgetNPK (KnownKeys.Keys);
|
||||
}
|
||||
|
||||
byte[] QueryEncryption (string arc_name)
|
||||
@ -231,8 +234,7 @@ namespace GameRes.Formats.NitroPlus
|
||||
byte[] GetKey (string title)
|
||||
{
|
||||
byte[] key;
|
||||
if (KnownKeys.TryGetValue (title, out key))
|
||||
return key;
|
||||
KnownKeys.TryGetValue (title, out key);
|
||||
return key;
|
||||
}
|
||||
|
||||
@ -243,7 +245,7 @@ namespace GameRes.Formats.NitroPlus
|
||||
if (null == npk_options.Key)
|
||||
throw new InvalidEncryptionScheme();
|
||||
|
||||
var enc = Encodings.cp932.WithFatalFallback();
|
||||
var enc = DefaultEncoding.WithFatalFallback();
|
||||
int index_length = 0;
|
||||
var dir = new List<NpkStoredEntry>();
|
||||
foreach (var entry in list)
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using System.Linq;
|
||||
using GameRes.Formats.NitroPlus;
|
||||
|
||||
namespace GameRes.Formats.GUI
|
||||
{
|
||||
@ -9,10 +9,10 @@ namespace GameRes.Formats.GUI
|
||||
/// </summary>
|
||||
public partial class WidgetNPK : Grid
|
||||
{
|
||||
public WidgetNPK ()
|
||||
public WidgetNPK (IEnumerable<string> titles)
|
||||
{
|
||||
InitializeComponent();
|
||||
Scheme.ItemsSource = NpkOpener.KnownKeys.Keys.OrderBy (x => x);
|
||||
Scheme.ItemsSource = titles.OrderBy (x => x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user