diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj
index 9b59aabe..5d169e81 100644
--- a/ArcFormats/ArcFormats.csproj
+++ b/ArcFormats/ArcFormats.csproj
@@ -306,6 +306,12 @@
+
+
+
+
+ WidgetSJDAT.xaml
+
@@ -575,6 +581,7 @@
WidgetTactics.xaml
+
@@ -1094,6 +1101,10 @@
Designer
MSBuild:Compile
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
diff --git a/ArcFormats/Properties/Settings.Designer.cs b/ArcFormats/Properties/Settings.Designer.cs
index 74720ae3..c3674968 100644
--- a/ArcFormats/Properties/Settings.Designer.cs
+++ b/ArcFormats/Properties/Settings.Designer.cs
@@ -789,5 +789,17 @@ namespace GameRes.Formats.Properties {
this["LEAFTitle"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string SJDatTitle {
+ get {
+ return ((string)(this["SJDatTitle"]));
+ }
+ set {
+ this["SJDatTitle"] = value;
+ }
+ }
}
}
diff --git a/ArcFormats/Properties/Settings.settings b/ArcFormats/Properties/Settings.settings
index 5b4b1ac5..c5258ce6 100644
--- a/ArcFormats/Properties/Settings.settings
+++ b/ArcFormats/Properties/Settings.settings
@@ -194,5 +194,8 @@
+
+
+
\ No newline at end of file
diff --git a/Legacy/StudioJikkenshitsu/ImageDAT.cs b/ArcFormats/StudioJikkenshitsu/ImageDAT.cs
similarity index 83%
rename from Legacy/StudioJikkenshitsu/ImageDAT.cs
rename to ArcFormats/StudioJikkenshitsu/ImageDAT.cs
index a14c3d8f..b9648dd2 100644
--- a/Legacy/StudioJikkenshitsu/ImageDAT.cs
+++ b/ArcFormats/StudioJikkenshitsu/ImageDAT.cs
@@ -29,8 +29,10 @@ using System.ComponentModel.Composition;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
+using GameRes.Formats.Strings;
// [010719][Studio Jikkenshitsu] Shin Gekka Bijin ~Hitori Shizuka
+// [030606][Studio Jikkenshitsu] Bias {biAs+}
// [031212][Studio Jikkenshitsu] Jam n' Limit
namespace GameRes.Formats.Jikkenshitsu
@@ -50,6 +52,11 @@ namespace GameRes.Formats.Jikkenshitsu
public IDictionary KnownSchemes;
}
+ internal class SjOptions : ResourceOptions
+ {
+ public byte[] Key;
+ }
+
[Export(typeof(ImageFormat))]
public class SpDatFormat : ImageFormat
{
@@ -63,11 +70,7 @@ namespace GameRes.Formats.Jikkenshitsu
Signatures = new uint[] { 0x010003, 0x010007, 0x01000B, 0x010046, 0 };
}
- // Futanari Clinic Karte #1
-// static readonly byte[] DefaultKey = { 10, 0, 5, 10, 11, 0, 9, 0, 1, 13, 5, 2, 3, 5, 6, 4 };
-
- // Jam n' Limit
- static readonly byte[] DefaultKey = { 12, 5, 0, 8, 5, 1, 2, 10, 4, 8, 2, 3, 9, 6, 0, 1 };
+ byte[] DefaultKey = null;
public override ImageMetaData ReadMetaData (IBinaryStream file)
{
@@ -77,14 +80,24 @@ namespace GameRes.Formats.Jikkenshitsu
int flags = header.ToUInt16 (0);
if ((flags & ~0xFF) != 0)
return null;
- return new SpMetaData {
+ var info = new SpMetaData {
Width = header.ToUInt16 (0x16),
Height = header.ToUInt16 (0x18),
BPP = 8,
Flags = flags,
Colors = header.ToUInt16 (0x1E),
- Key = DefaultKey,
};
+ if (info.IsEncrypted)
+ {
+ if (null == DefaultKey)
+ {
+ DefaultKey = QueryKey (file.Name);
+ if (null == DefaultKey)
+ return null;
+ }
+ info.Key = DefaultKey;
+ }
+ return info;
}
public override ImageData Read (IBinaryStream file, ImageMetaData info)
@@ -106,6 +119,30 @@ namespace GameRes.Formats.Jikkenshitsu
get { return DefaultScheme; }
set { DefaultScheme = (SjSchemeMap)value; }
}
+
+ public override ResourceOptions GetDefaultOptions ()
+ {
+ return new SjOptions { Key = GetKey (Properties.Settings.Default.SJDatTitle) };
+ }
+
+ public override object GetAccessWidget ()
+ {
+ return new GUI.WidgetSJDAT (DefaultScheme.KnownSchemes.Keys);
+ }
+
+ byte[] QueryKey (string filename)
+ {
+ var options = Query (arcStrings.ArcImageEncrypted);
+ return options.Key;
+ }
+
+ byte[] GetKey (string title)
+ {
+ byte[] key = null;
+ if (!string.IsNullOrEmpty (title))
+ DefaultScheme.KnownSchemes.TryGetValue (title, out key);
+ return key;
+ }
}
internal class SpReader
@@ -124,7 +161,7 @@ namespace GameRes.Formats.Jikkenshitsu
m_input = input;
m_info = info;
m_output = new byte[info.Width * info.Height];
- m_stride = (int)info.Width;
+ m_stride = info.iWidth;
}
public byte[] Unpack ()
@@ -210,8 +247,8 @@ namespace GameRes.Formats.Jikkenshitsu
byte[] ConvertToRgbA (byte[] alpha)
{
- m_stride = (int)m_info.Width * 4;
- var pixels = new byte[m_stride * (int)m_info.Height];
+ m_stride = m_info.iWidth * 4;
+ var pixels = new byte[m_stride * m_info.iHeight];
var colors = Palette.Colors;
int dst = 0;
for (int src = 0; src < m_output.Length; ++src)
diff --git a/Legacy/StudioJikkenshitsu/ImageGRD.cs b/ArcFormats/StudioJikkenshitsu/ImageGRD.cs
similarity index 98%
rename from Legacy/StudioJikkenshitsu/ImageGRD.cs
rename to ArcFormats/StudioJikkenshitsu/ImageGRD.cs
index 28545222..6c80715f 100644
--- a/Legacy/StudioJikkenshitsu/ImageGRD.cs
+++ b/ArcFormats/StudioJikkenshitsu/ImageGRD.cs
@@ -51,7 +51,7 @@ namespace GameRes.Formats.Jikkenshitsu
public override uint Signature { get { return 0x20445247; } } // 'GRD '
// Giin Oyako
- static readonly byte[] DefaultKey = { 0xF, 0, 1, 2, 8, 5, 0xA, 0xB, 5, 9, 0xE, 0xD, 1, 8, 0, 6 };
+ static readonly byte[] DefaultKey = { 15, 0, 1, 2, 8, 5, 10, 11, 5, 9, 14, 13, 1, 8, 0, 6 };
public override ImageMetaData ReadMetaData (IBinaryStream file)
{
diff --git a/Legacy/StudioJikkenshitsu/SjTransform.cs b/ArcFormats/StudioJikkenshitsu/SjTransform.cs
similarity index 100%
rename from Legacy/StudioJikkenshitsu/SjTransform.cs
rename to ArcFormats/StudioJikkenshitsu/SjTransform.cs
diff --git a/ArcFormats/StudioJikkenshitsu/WidgetSJDAT.xaml b/ArcFormats/StudioJikkenshitsu/WidgetSJDAT.xaml
new file mode 100644
index 00000000..51bbea95
--- /dev/null
+++ b/ArcFormats/StudioJikkenshitsu/WidgetSJDAT.xaml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/ArcFormats/StudioJikkenshitsu/WidgetSJDAT.xaml.cs b/ArcFormats/StudioJikkenshitsu/WidgetSJDAT.xaml.cs
new file mode 100644
index 00000000..12111021
--- /dev/null
+++ b/ArcFormats/StudioJikkenshitsu/WidgetSJDAT.xaml.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Controls;
+
+namespace GameRes.Formats.GUI
+{
+ ///
+ /// Interaction logic for WidgetSJDAT.xaml
+ ///
+ public partial class WidgetSJDAT : StackPanel
+ {
+ public WidgetSJDAT (IEnumerable known_schemes)
+ {
+ InitializeComponent ();
+ this.Title.ItemsSource = known_schemes.OrderBy (x => x);
+ }
+ }
+}
diff --git a/ArcFormats/app.config b/ArcFormats/app.config
index 342f505b..4ab43b0e 100644
--- a/ArcFormats/app.config
+++ b/ArcFormats/app.config
@@ -196,6 +196,9 @@
+
+
+
diff --git a/Legacy/Legacy.csproj b/Legacy/Legacy.csproj
index 32ed679a..562d907e 100644
--- a/Legacy/Legacy.csproj
+++ b/Legacy/Legacy.csproj
@@ -139,9 +139,6 @@
-
-
-