Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
cmkushnir authored Sep 19, 2022
1 parent 1d937d5 commit aaef956
Show file tree
Hide file tree
Showing 50 changed files with 725 additions and 307 deletions.
53 changes: 45 additions & 8 deletions Common/NMS/PAK/Data/PAK.BIN.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ You should have received a copy of the GNU Affero General Public License

namespace cmk.NMS.PAK.BIN
{
/// <summary>
/// Note: some .bin files are binary, some are text.
/// todo: try to determine if binary and display binary w/ hex viewer.
/// </summary>
public class Data
/// <summary>
/// Note: some .bin files are binary, some are text.
/// todo: try to determine if binary and display binary w/ hex viewer.
/// </summary>
public class Data
: cmk.NMS.PAK.TXT.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".BIN"] = extension_info;
}

Expand All @@ -46,16 +45,54 @@ public Data() : base()

//...........................................................

public Data( NMS.PAK.Item.Info INFO, Stream RAW = null, Log LOG = null )
public Data( NMS.PAK.Item.Info INFO, Stream RAW, Log LOG = null )
: base(INFO, RAW, LOG)
{
CheckIfBinary();
}

//...........................................................

public Data( string PATH, Stream RAW = null, Log LOG = null )
public Data( string PATH, Stream RAW, Log LOG = null )
: base(PATH, RAW, LOG)
{
CheckIfBinary();
}

//...........................................................

public bool IsBinary { get; protected set; } = false;

protected void CheckIfBinary()
{
Raw.Position = 0;

// some bin are xml, some are actual binary
if( Raw.ReadByte() != '<' ||
Raw.ReadByte() != '!' ||
Raw.ReadByte() != '-'
) {
IsBinary = true;
Text = "";
}

Raw.Position = 0;
}

//...........................................................

protected override string RawToText( Log LOG = null )
{
if( IsBinary ) return null;
return base.RawToText(LOG);
}

//...........................................................

protected override bool TextToRaw( string TEXT, Log LOG = null )
{
if( IsBinary ) return false;
return base.TextToRaw(TEXT, LOG);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions Common/NMS/PAK/Data/PAK.BNK.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ You should have received a copy of the GNU Affero General Public License

namespace cmk.NMS.PAK.BNK
{
public class Data
public class Data
: cmk.NMS.PAK.Item.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".BNK"] = extension_info;
}

Expand All @@ -42,14 +41,14 @@ public Data() : base()

//...........................................................

public Data( NMS.PAK.Item.Info INFO, Stream RAW = null, Log LOG = null )
public Data( NMS.PAK.Item.Info INFO, Stream RAW, Log LOG = null )
: base(INFO, RAW, LOG)
{
}

//...........................................................

public Data( string PATH, Stream RAW = null, Log LOG = null )
public Data( string PATH, Stream RAW, Log LOG = null )
: base(PATH, RAW, LOG)
{
}
Expand Down
7 changes: 3 additions & 4 deletions Common/NMS/PAK/Data/PAK.CS.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ You should have received a copy of the GNU Affero General Public License

namespace cmk.NMS.PAK.CS
{
public class Data
public class Data
: cmk.NMS.PAK.TXT.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".CS"] = extension_info;
}

Expand All @@ -42,14 +41,14 @@ public Data() : base()

//...........................................................

public Data( NMS.PAK.Item.Info INFO, Stream RAW = null, Log LOG = null )
public Data( NMS.PAK.Item.Info INFO, Stream RAW, Log LOG = null )
: base(INFO, RAW, LOG)
{
}

//...........................................................

public Data( string PATH, Stream RAW = null, Log LOG = null )
public Data( string PATH, Stream RAW, Log LOG = null )
: base(PATH, RAW, LOG)
{
}
Expand Down
7 changes: 3 additions & 4 deletions Common/NMS/PAK/Data/PAK.CSV.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ You should have received a copy of the GNU Affero General Public License

namespace cmk.NMS.PAK.CSV
{
public class Data
public class Data
: cmk.NMS.PAK.TXT.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".CSV"] = extension_info;
}

Expand All @@ -42,14 +41,14 @@ public Data() : base()

//...........................................................

public Data( NMS.PAK.Item.Info INFO, Stream RAW = null, Log LOG = null )
public Data( NMS.PAK.Item.Info INFO, Stream RAW, Log LOG = null )
: base(INFO, RAW, LOG)
{
}

//...........................................................

public Data( string PATH, Stream RAW = null, Log LOG = null )
public Data( string PATH, Stream RAW, Log LOG = null )
: base(PATH, RAW, LOG)
{
}
Expand Down
17 changes: 12 additions & 5 deletions Common/NMS/PAK/Data/PAK.DDS.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ You should have received a copy of the GNU Affero General Public License

using System;
using System.IO;
using System.Windows.Media.Imaging;
using Pfim;

//=============================================================================

namespace cmk.NMS.PAK.DDS
{
public class Data
public class Data
: cmk.NMS.PAK.Item.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".DDS"] = extension_info;
}

Expand All @@ -43,15 +44,15 @@ public Data() : base()

//...........................................................

public Data( NMS.PAK.Item.Info INFO, Stream RAW = null, Log LOG = null )
public Data( NMS.PAK.Item.Info INFO, Stream RAW, Log LOG = null )
: base(INFO, RAW, LOG)
{
Dds = RawToDDS(LOG);
}

//...........................................................

public Data( string PATH, Stream RAW = null, Log LOG = null )
public Data( string PATH, Stream RAW, Log LOG = null )
: base(PATH, RAW, LOG)
{
Dds = RawToDDS(LOG);
Expand All @@ -61,6 +62,12 @@ public Data( string PATH, Stream RAW = null, Log LOG = null )

public Pfim.Dds Dds { get; set; }

public BitmapSource GetBitmap( bool FREEZE = true )
=> Dds.GetBitmap(FREEZE);

public BitmapSource GetBitmap( int HEIGHT, bool FREEZE = true )
=> Dds.GetBitmap(HEIGHT, FREEZE);

//...........................................................

protected Pfim.Dds RawToDDS( Log LOG = null )
Expand Down Expand Up @@ -98,7 +105,7 @@ public override bool Save( Log LOG = null )
if( !DDSToRaw(Dds, LOG) ) return false;
IsEdited = true;
}
return true;
return base.Save(LOG);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions Common/NMS/PAK/Data/PAK.JSON.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ You should have received a copy of the GNU Affero General Public License

namespace cmk.NMS.PAK.JSON
{
public class Data
public class Data
: cmk.NMS.PAK.TXT.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".JSON"] = extension_info;
}

Expand All @@ -42,14 +41,14 @@ public Data() : base()

//...........................................................

public Data( NMS.PAK.Item.Info INFO, Stream RAW = null, Log LOG = null )
public Data( NMS.PAK.Item.Info INFO, Stream RAW, Log LOG = null )
: base(INFO, RAW, LOG)
{
}

//...........................................................

public Data( string PATH, Stream RAW = null, Log LOG = null )
public Data( string PATH, Stream RAW, Log LOG = null )
: base(PATH, RAW, LOG)
{
}
Expand Down
3 changes: 1 addition & 2 deletions Common/NMS/PAK/Data/PAK.LUA.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ You should have received a copy of the GNU Affero General Public License

namespace cmk.NMS.PAK.LUA
{
public class Data
public class Data
: cmk.NMS.PAK.TXT.Data
{
static Data()
{
var extension_info = new NMS.PAK.Item.Extension{ Data = typeof(Data) };
extension_info.Viewers.Insert(0, typeof(Viewer));
extension_info.Differs.Insert(0, typeof(Differ));

s_extensions[".LUA"] = extension_info;
}

Expand Down
Loading

0 comments on commit aaef956

Please sign in to comment.