mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(NPK2): added GUI widget.
This commit is contained in:
parent
ebb6c91a73
commit
9a94416f23
@ -133,6 +133,9 @@
|
||||
<Compile Include="MnoViolet\ImageDIF.cs" />
|
||||
<Compile Include="Nexas\ImageGRP.cs" />
|
||||
<Compile Include="NitroPlus\ArcNPK.cs" />
|
||||
<Compile Include="NitroPlus\WidgetNPK.xaml.cs">
|
||||
<DependentUpon>WidgetNPK.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NonColor\ArcDAT.cs" />
|
||||
<Compile Include="Crc64.cs" />
|
||||
<Compile Include="NonColor\WidgetNCARC.xaml.cs">
|
||||
@ -593,6 +596,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="NitroPlus\WidgetNPK.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="NonColor\WidgetNCARC.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -28,8 +28,9 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using GameRes.Formats.Properties;
|
||||
using GameRes.Formats.Strings;
|
||||
|
||||
namespace GameRes.Formats.NitroPlus
|
||||
{
|
||||
@ -47,6 +48,11 @@ namespace GameRes.Formats.NitroPlus
|
||||
public bool IsCompressed { get { return Size < UnpackedSize; } }
|
||||
}
|
||||
|
||||
public class Npk2Options : ResourceOptions
|
||||
{
|
||||
public byte[] Key;
|
||||
}
|
||||
|
||||
internal class NpkArchive : ArcFile
|
||||
{
|
||||
public readonly Aes Encryption;
|
||||
@ -141,8 +147,14 @@ namespace GameRes.Formats.NitroPlus
|
||||
entry.UnpackedSize = index.ReadUInt32();
|
||||
index.Read (name_buffer, 0, 0x20); // skip
|
||||
int segment_count = index.ReadInt32();
|
||||
if (segment_count <= 0)
|
||||
if (segment_count < 0)
|
||||
return null;
|
||||
if (0 == segment_count)
|
||||
{
|
||||
entry.Offset = 0;
|
||||
dir.Add (entry);
|
||||
continue;
|
||||
}
|
||||
entry.Segments.Capacity = segment_count;
|
||||
uint packed_size = 0;
|
||||
bool is_packed = false;
|
||||
@ -169,6 +181,8 @@ namespace GameRes.Formats.NitroPlus
|
||||
|
||||
public override Stream OpenEntry (ArcFile arc, Entry entry)
|
||||
{
|
||||
if (0 == entry.Size)
|
||||
return Stream.Null;
|
||||
var narc = arc as NpkArchive;
|
||||
var nent = entry as NpkEntry;
|
||||
if (null == narc || null == nent)
|
||||
@ -183,11 +197,28 @@ namespace GameRes.Formats.NitroPlus
|
||||
return new NpkStream (narc, nent);
|
||||
}
|
||||
|
||||
public override ResourceOptions GetDefaultOptions ()
|
||||
{
|
||||
return new Npk2Options { Key = GetKey (Settings.Default.NPKScheme) };
|
||||
}
|
||||
|
||||
public override object GetAccessWidget ()
|
||||
{
|
||||
return new GUI.WidgetNPK();
|
||||
}
|
||||
|
||||
byte[] QueryEncryption ()
|
||||
{
|
||||
if (0 == KnownKeys.Count)
|
||||
return null;
|
||||
return KnownKeys.Values.First();
|
||||
var options = Query<Npk2Options> (arcStrings.ArcEncryptedNotice);
|
||||
return options.Key;
|
||||
}
|
||||
|
||||
byte[] GetKey (string title)
|
||||
{
|
||||
byte[] key;
|
||||
if (KnownKeys.TryGetValue (title, out key))
|
||||
return key;
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
|
9
ArcFormats/NitroPlus/WidgetNPK.xaml
Normal file
9
ArcFormats/NitroPlus/WidgetNPK.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Grid x:Class="GameRes.Formats.GUI.WidgetNPK"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:p="clr-namespace:GameRes.Formats.Properties"
|
||||
MaxWidth="250">
|
||||
<ComboBox Name="Scheme" Width="180"
|
||||
ItemsSource="{Binding}"
|
||||
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=NPKScheme, Mode=TwoWay}"/>
|
||||
</Grid>
|
18
ArcFormats/NitroPlus/WidgetNPK.xaml.cs
Normal file
18
ArcFormats/NitroPlus/WidgetNPK.xaml.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Linq;
|
||||
using GameRes.Formats.NitroPlus;
|
||||
|
||||
namespace GameRes.Formats.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WidgetNPK.xaml
|
||||
/// </summary>
|
||||
public partial class WidgetNPK : Grid
|
||||
{
|
||||
public WidgetNPK ()
|
||||
{
|
||||
InitializeComponent();
|
||||
Scheme.ItemsSource = NpkOpener.KnownKeys.Keys.OrderBy (x => x);
|
||||
}
|
||||
}
|
||||
}
|
12
ArcFormats/Properties/Settings.Designer.cs
generated
12
ArcFormats/Properties/Settings.Designer.cs
generated
@ -585,5 +585,17 @@ namespace GameRes.Formats.Properties {
|
||||
this["BELLTitle"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string NPKScheme {
|
||||
get {
|
||||
return ((string)(this["NPKScheme"]));
|
||||
}
|
||||
set {
|
||||
this["NPKScheme"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,5 +143,8 @@
|
||||
<Setting Name="BELLTitle" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="NPKScheme" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@ -145,6 +145,9 @@
|
||||
<setting name="BELLTitle" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="NPKScheme" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</GameRes.Formats.Properties.Settings>
|
||||
</userSettings>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
|
Loading…
x
Reference in New Issue
Block a user