BXLYT : Recalculate material indices automatically on save.
This commit is contained in:
parent
3126bef310
commit
e39e6f7d03
@ -450,8 +450,16 @@ namespace LayoutBXLYT.Cafe
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
RecalculateMaterialReferences();
|
||||
|
||||
Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
|
||||
|
||||
foreach (var pane in PaneLookup.Values)
|
||||
{
|
||||
if (pane is PIC1)
|
||||
((PIC1)pane).MaterialIndex = (ushort)MaterialList.Materials.IndexOf(((PIC1)pane).Material);
|
||||
}
|
||||
|
||||
writer.SetByteOrder(true);
|
||||
writer.WriteSignature(Magic);
|
||||
if (!IsBigEndian)
|
||||
|
@ -479,6 +479,8 @@ namespace LayoutBXLYT
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
RecalculateMaterialReferences();
|
||||
|
||||
Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
|
||||
|
||||
writer.SetByteOrder(true);
|
||||
|
@ -2285,6 +2285,24 @@ namespace LayoutBXLYT
|
||||
return new BxlytMaterial();
|
||||
}
|
||||
|
||||
public void RecalculateMaterialReferences()
|
||||
{
|
||||
List<BxlytMaterial> materials = Materials;
|
||||
foreach (var pane in PaneLookup.Values)
|
||||
{
|
||||
if (pane is IPicturePane)
|
||||
((IPicturePane)pane).MaterialIndex = (ushort)materials.IndexOf(((IPicturePane)pane).Material);
|
||||
if (pane is IWindowPane)
|
||||
{
|
||||
((IWindowPane)pane).Content.MaterialIndex = (ushort)materials.IndexOf(((IWindowPane)pane).Content.Material);
|
||||
foreach (var window in ((IWindowPane)pane).WindowFrames)
|
||||
window.MaterialIndex = (ushort)materials.IndexOf(window.Material);
|
||||
}
|
||||
if (pane is ITextPane)
|
||||
((ITextPane)pane).MaterialIndex = (ushort)materials.IndexOf(((ITextPane)pane).Material);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveTextureReferences(string texture)
|
||||
{
|
||||
foreach (var mat in Materials)
|
||||
|
Loading…
x
Reference in New Issue
Block a user