finally add missing object definitions to New World Computing BIN data format
This commit is contained in:
parent
33320bfc77
commit
b3761f679d
@ -24,9 +24,14 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
public enum BINComponentType
|
||||
{
|
||||
None = 0x00,
|
||||
Image = 0x01,
|
||||
Unknown0x02 = 0x02,
|
||||
Border = 0x01,
|
||||
Button = 0x02,
|
||||
Label = 0x08,
|
||||
Unknown0x10 = 0x10
|
||||
Image = 0x10,
|
||||
|
||||
TextBox = 0x0201,
|
||||
DropDownList = 0x0203,
|
||||
TextBox2 = 0x0204,
|
||||
ListBox = 0x0205
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +67,16 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
new Property(ScenePropertyGuids.Label.Text, "Text"),
|
||||
new Property(ScenePropertyGuids.Label.FontFileName, "Font file name")
|
||||
}, Label_Render));
|
||||
NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.DropDownList, "Drop-down list", new Property[]
|
||||
{
|
||||
new Property(ScenePropertyGuids.DropDownList.BackgroundImageFileName, "Background image file name"),
|
||||
new Property(ScenePropertyGuids.DropDownList.BackgroundImageIndex, "Background image index")
|
||||
}, DropDownList_Render));
|
||||
NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.ListBox, "List box", new Property[]
|
||||
{
|
||||
new Property(ScenePropertyGuids.DropDownList.BackgroundImageFileName, "Background image file name"),
|
||||
new Property(ScenePropertyGuids.DropDownList.BackgroundImageIndex, "Background image index")
|
||||
}, ListBox_Render));
|
||||
}
|
||||
|
||||
static void Button_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
|
||||
@ -85,6 +95,40 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
static void ListBox_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
|
||||
{
|
||||
Property propBackgroundImage = NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage];
|
||||
if (propBackgroundImage != null)
|
||||
{
|
||||
PropertyValue propVal = instance.PropertyValues[propBackgroundImage];
|
||||
if (propVal != null)
|
||||
{
|
||||
PictureObjectModel pic = propVal.Value as PictureObjectModel;
|
||||
if (pic != null)
|
||||
{
|
||||
e.Graphics.DrawImage(pic.ToImage(), bounds.X, bounds.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
static void DropDownList_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
|
||||
{
|
||||
Property propBackgroundImage = NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage];
|
||||
if (propBackgroundImage != null)
|
||||
{
|
||||
PropertyValue propVal = instance.PropertyValues[propBackgroundImage];
|
||||
if (propVal != null)
|
||||
{
|
||||
PictureObjectModel pic = propVal.Value as PictureObjectModel;
|
||||
if (pic != null)
|
||||
{
|
||||
e.Graphics.DrawImage(pic.ToImage(), bounds.X, bounds.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
static void Image_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
|
||||
{
|
||||
@ -140,16 +184,6 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
ushort canvasHeight = reader.ReadUInt16();
|
||||
designer.Designs[0].Size = new MBS.Framework.Drawing.Dimension2D(canvasWidth, canvasHeight);
|
||||
|
||||
string icnDataDir = ICNDataDirectory;
|
||||
if (icnDataDir == null)
|
||||
{
|
||||
string fn = Accessor.GetFileName();
|
||||
if (fn != null)
|
||||
{
|
||||
icnDataDir = System.IO.Path.GetDirectoryName(fn);
|
||||
}
|
||||
}
|
||||
|
||||
ushort componentCount = reader.ReadUInt16();
|
||||
bool breakout = false;
|
||||
while (!reader.EndOfStream && !breakout)
|
||||
@ -163,30 +197,98 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
|
||||
switch (componentType)
|
||||
{
|
||||
case BINComponentType.Image:
|
||||
case BINComponentType.TextBox:
|
||||
case BINComponentType.TextBox2:
|
||||
{
|
||||
ushort textLength = reader.ReadUInt16();
|
||||
string text = reader.ReadFixedLengthString(textLength).TrimNull();
|
||||
|
||||
string fntname = reader.ReadFixedLengthString(13).TrimNull();
|
||||
|
||||
ushort u01 = reader.ReadUInt16();
|
||||
ushort u02 = reader.ReadUInt16();
|
||||
|
||||
string icnFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
|
||||
ushort lx = reader.ReadUInt16();
|
||||
ushort ly = reader.ReadUInt16();
|
||||
ushort lwidth = reader.ReadUInt16();
|
||||
ushort lheight = reader.ReadUInt16();
|
||||
|
||||
ushort u1 = reader.ReadUInt16();
|
||||
ushort u2 = reader.ReadUInt16();
|
||||
ushort u3 = reader.ReadUInt16();
|
||||
ushort u4 = reader.ReadUInt16();
|
||||
ushort u5 = reader.ReadUInt16();
|
||||
|
||||
if (componentType == BINComponentType.TextBox2)
|
||||
{
|
||||
string w = reader.ReadFixedLengthString(u5).TrimNull();
|
||||
string fntFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
|
||||
ushort u1a = reader.ReadUInt16();
|
||||
ushort u2a = reader.ReadUInt16();
|
||||
ushort u3a = reader.ReadUInt16();
|
||||
ushort u4a = reader.ReadUInt16();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BINComponentType.ListBox:
|
||||
{
|
||||
string fntFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
string icnFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
|
||||
ushort lx = reader.ReadUInt16();
|
||||
ushort ly = reader.ReadUInt16();
|
||||
ushort lwidth = reader.ReadUInt16();
|
||||
ushort lheight = reader.ReadUInt16();
|
||||
|
||||
ushort u1 = reader.ReadUInt16();
|
||||
PictureObjectModel pic = LoadICN(icnFileName, 0);
|
||||
|
||||
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.ListBox], new Rectangle(x, y, width, height), new PropertyValue[]
|
||||
{
|
||||
new PropertyValue(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Image].Properties[ScenePropertyGuids.Image.BackgroundImageFileName], icnFileName),
|
||||
new PropertyValue(NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage], pic)
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case BINComponentType.DropDownList:
|
||||
{
|
||||
string fntFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
string icnFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
|
||||
ushort lx = reader.ReadUInt16();
|
||||
ushort ly = reader.ReadUInt16();
|
||||
ushort lwidth = reader.ReadUInt16();
|
||||
ushort lheight = reader.ReadUInt16();
|
||||
|
||||
ushort u1 = reader.ReadUInt16();
|
||||
ushort u2 = reader.ReadUInt16();
|
||||
ushort u3 = reader.ReadUInt16();
|
||||
ushort u4 = reader.ReadUInt16();
|
||||
ushort u5 = reader.ReadUInt16();
|
||||
ushort u6 = reader.ReadUInt16();
|
||||
|
||||
PictureObjectModel pic = LoadICN(icnFileName, 0);
|
||||
|
||||
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.DropDownList], new Rectangle(x, y, width, height), new PropertyValue[]
|
||||
{
|
||||
new PropertyValue(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Image].Properties[ScenePropertyGuids.Image.BackgroundImageFileName], icnFileName),
|
||||
new PropertyValue(NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage], pic)
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case BINComponentType.Border:
|
||||
{
|
||||
ushort i1 = reader.ReadUInt16(); // 65535
|
||||
|
||||
BINComponentFlags flags = (BINComponentFlags)reader.ReadUInt16(); // 2049
|
||||
if ((flags & BINComponentFlags.HasICN) == BINComponentFlags.HasICN)
|
||||
{
|
||||
string icnFileName = reader.ReadFixedLengthString(13).TrimNull(); // qwikhero.icn
|
||||
|
||||
PictureObjectModel pic = null;
|
||||
|
||||
string icnFullyQualifiedPath = MBS.Framework.IO.File.Find(System.IO.Path.Combine(new string[] { icnDataDir, icnFileName }), MBS.Framework.IO.CaseSensitiveHandling.CaseInsensitive);
|
||||
if (System.IO.File.Exists(icnFullyQualifiedPath))
|
||||
{
|
||||
PictureCollectionObjectModel pcom = new PictureCollectionObjectModel();
|
||||
try
|
||||
{
|
||||
Document.Load(pcom, icndf, new FileAccessor(icnFullyQualifiedPath));
|
||||
pic = pcom.Pictures[0];
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
PictureObjectModel pic = LoadICN(icnFileName, 0);
|
||||
|
||||
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Image], new Rectangle(x, y, width, height), new PropertyValue[]
|
||||
{
|
||||
@ -204,7 +306,7 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
{
|
||||
ushort textLength = reader.ReadUInt16();
|
||||
string text = reader.ReadFixedLengthString(textLength).TrimNull();
|
||||
string fontFileName = reader.ReadFixedLengthString(13);
|
||||
string fontFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
|
||||
ushort b01 = reader.ReadUInt16();
|
||||
ushort b02 = reader.ReadUInt16();
|
||||
@ -217,7 +319,7 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case BINComponentType.Unknown0x10:
|
||||
case BINComponentType.Image:
|
||||
{
|
||||
// this is the background and shadow images
|
||||
string icnFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
@ -227,22 +329,7 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
ushort b04 = reader.ReadUInt16(); // 16 16
|
||||
ushort b05 = reader.ReadUInt16(); // 0 0
|
||||
|
||||
PictureObjectModel pic = null;
|
||||
|
||||
string icnFullyQualifiedPath = MBS.Framework.IO.File.Find(System.IO.Path.Combine(new string[] { icnDataDir, icnFileName }), MBS.Framework.IO.CaseSensitiveHandling.CaseInsensitive);
|
||||
if (icnFullyQualifiedPath != null)
|
||||
{
|
||||
PictureCollectionObjectModel pcom = new PictureCollectionObjectModel();
|
||||
try
|
||||
{
|
||||
Document.Load(pcom, icndf, new FileAccessor(icnFullyQualifiedPath));
|
||||
pic = pcom.Pictures[icnIndex];
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
PictureObjectModel pic = LoadICN(icnFileName, icnIndex);
|
||||
|
||||
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Image], new Rectangle(x, y, width, height), new PropertyValue[]
|
||||
{
|
||||
@ -251,7 +338,7 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case BINComponentType.Unknown0x02:
|
||||
case BINComponentType.Button:
|
||||
{
|
||||
string icnFileName = reader.ReadFixedLengthString(13).TrimNull();
|
||||
ushort icnIndexStateNormal = reader.ReadUInt16();
|
||||
@ -261,22 +348,7 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
ushort b05 = reader.ReadUInt16();
|
||||
ushort b06 = reader.ReadUInt16();
|
||||
|
||||
PictureObjectModel pic = null;
|
||||
|
||||
string icnFullyQualifiedPath = MBS.Framework.IO.File.Find(System.IO.Path.Combine(new string[] { icnDataDir, icnFileName }), MBS.Framework.IO.CaseSensitiveHandling.CaseInsensitive);
|
||||
if (icnFullyQualifiedPath != null)
|
||||
{
|
||||
PictureCollectionObjectModel pcom = new PictureCollectionObjectModel();
|
||||
try
|
||||
{
|
||||
Document.Load(pcom, icndf, new FileAccessor(icnFullyQualifiedPath));
|
||||
pic = pcom.Pictures[icnIndexStateNormal];
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
PictureObjectModel pic = LoadICN(icnFileName, icnIndexStateNormal);
|
||||
|
||||
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Button], new Rectangle(x, y, width, height), new PropertyValue[]
|
||||
{
|
||||
@ -298,6 +370,41 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
|
||||
}
|
||||
}
|
||||
|
||||
private string icnDataDir = null;
|
||||
|
||||
private PictureObjectModel LoadICN(string icnFileName, int icnIndex)
|
||||
{
|
||||
if (icnDataDir == null)
|
||||
{
|
||||
icnDataDir = ICNDataDirectory;
|
||||
if (icnDataDir == null)
|
||||
{
|
||||
string fn = Accessor.GetFileName();
|
||||
if (fn != null)
|
||||
{
|
||||
icnDataDir = System.IO.Path.GetDirectoryName(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PictureObjectModel pic = null;
|
||||
string icnFullyQualifiedPath = MBS.Framework.IO.File.Find(System.IO.Path.Combine(new string[] { icnDataDir, icnFileName }), MBS.Framework.IO.CaseSensitiveHandling.CaseInsensitive);
|
||||
if (System.IO.File.Exists(icnFullyQualifiedPath))
|
||||
{
|
||||
PictureCollectionObjectModel pcom = new PictureCollectionObjectModel();
|
||||
try
|
||||
{
|
||||
Document.Load(pcom, icndf, new FileAccessor(icnFullyQualifiedPath));
|
||||
pic = pcom.Pictures[icnIndex];
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return pic;
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@ -26,5 +26,7 @@ namespace UniversalEditor.ObjectModels.NWCSceneLayout
|
||||
public static Guid Button { get; } = new Guid("{621e6323-5b10-4fb4-843b-9aa607751a7b}");
|
||||
public static Guid Image { get; } = new Guid("{6f8d562e-8473-4872-be57-9fc04e575e9b}");
|
||||
public static Guid Label { get; } = new Guid("{061ded85-99fd-43b0-b23d-e31c904ba397}");
|
||||
public static Guid DropDownList { get; } = new Guid("{0fef5a86-c4e9-47b7-9d19-3e6d4e5b8d63}");
|
||||
public static Guid ListBox { get; } = new Guid("{b9eb1120-5326-46b3-81a7-741f9b19d74f}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,5 +38,10 @@ namespace UniversalEditor.ObjectModels.NWCSceneLayout
|
||||
public static Guid Text { get; } = new Guid("{25abbdfa-5b9d-491c-9b96-33dc0fd25156}");
|
||||
public static Guid FontFileName { get; } = new Guid("{eca4baa1-9f92-4c80-82fa-490a758083d0}");
|
||||
}
|
||||
public static class DropDownList
|
||||
{
|
||||
public static Guid BackgroundImageFileName { get; } = new Guid("{df3a8c45-a6bf-44d3-bf46-d8569e78bc71}");
|
||||
public static Guid BackgroundImageIndex { get; } = new Guid("{e4226ed5-0ffa-468a-972f-146c934b0aa2}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user