Skip to content

Commit

Permalink
layer sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Dec 14, 2018
1 parent 7c5c18d commit 7527966
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 78 deletions.
2 changes: 1 addition & 1 deletion IndustrialPark/ArchiveEditor/AddAsset/AddAssetDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void textBoxAssetName_TextChanged(object sender, EventArgs e)
{
assetName = textBoxAssetName.Text;

if (assetType != AssetType.BSP | assetType != AssetType.JSP)
if (assetType != AssetType.BSP && assetType != AssetType.JSP)
textBoxAssetID.Text = "0x" + Functions.BKDRHash(assetName).ToString("X8");
}
}
Expand Down
49 changes: 29 additions & 20 deletions IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ namespace IndustrialPark
{
public partial class ArchiveEditorFunctions
{
private class LHDRComparer : IComparer<LayerType>
{
private static readonly List<LayerType> layerOrder = new List<LayerType> {
LayerType.TEXTURE,
LayerType.BSP,
LayerType.JSPINFO,
LayerType.MODEL,
LayerType.ANIMATION,
LayerType.DEFAULT,
LayerType.CUTSCENE,
LayerType.SRAM,
LayerType.SNDTOC
};

public int Compare(LayerType l1, LayerType l2)
{
if (l1 == l2)
return 0;

if (layerOrder.Contains(l1) && layerOrder.Contains(l2))
return layerOrder.IndexOf(l1) > layerOrder.IndexOf(l2) ? 1 : -1;

return 0;
}
}

public static List<uint> hiddenAssets = new List<uint>();

public List<uint> GetHiddenAssets()
Expand Down Expand Up @@ -301,17 +327,7 @@ public void ImportHip(HipSection[] hipSections)
}
}

List<Section_LHDR> newList = new List<Section_LHDR>();

foreach (Section_LHDR LHDR in DICT.LTOC.LHDRList)
if (LHDR.layerType == LayerType.TEXTURE)
newList.Add(LHDR);

foreach (Section_LHDR LHDR in DICT.LTOC.LHDRList)
if (LHDR.layerType != LayerType.TEXTURE)
newList.Add(LHDR);

DICT.LTOC.LHDRList = newList;
DICT.LTOC.LHDRList = DICT.LTOC.LHDRList.OrderBy(f => f.layerType, new LHDRComparer()).ToList();

RecalculateAllMatrices();
}
Expand Down Expand Up @@ -673,21 +689,14 @@ public void CollapseLayers()
{
layers[LHDR.layerType].assetIDlist.AddRange(LHDR.assetIDlist);
}
else
else if (LHDR.assetIDlist.Count != 0)
{
layers.Add(LHDR.layerType, LHDR);
}
}

DICT.LTOC.LHDRList = new List<Section_LHDR>();

if (layers.ContainsKey(LayerType.TEXTURE))
{
DICT.LTOC.LHDRList.Add(layers[LayerType.TEXTURE]);
layers.Remove(LayerType.TEXTURE);
}

DICT.LTOC.LHDRList.AddRange(layers.Values.ToList());
DICT.LTOC.LHDRList.AddRange(layers.Values.ToList().OrderBy(f => f.layerType, new LHDRComparer()));
}
}
}
Loading

0 comments on commit 7527966

Please sign in to comment.