Skip to content

Commit

Permalink
Merge pull request #39 from burninrubber0/Fixes
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
burninrubber0 authored Jun 10, 2023
2 parents f8ad8f0 + 9c939a3 commit 0c0793d
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 11 deletions.
20 changes: 10 additions & 10 deletions BaseHandlers/TriggerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -841,15 +841,14 @@ public bool Write(BundleEntry entry)
writer.Write(mpLandmarks.Count + mpGenericRegions.Count + mpBlackspots.Count + mpVFXBoxRegions.Count);
writer.WriteUniquePadding(4); // padding

List<uint> TriggerRegionOffsets = new List<uint>();

long currentPosition = writer.BaseStream.Position;
writer.BaseStream.Position = LandmarkOffsetPosition;
writer.Write((uint)currentPosition);
writer.BaseStream.Position = currentPosition;
List<uint> landmarkOffsets = new List<uint>();
foreach (Landmark landmark in mpLandmarks)
{
TriggerRegionOffsets.Add((uint)writer.BaseStream.Position);
landmarkOffsets.Add((uint)writer.BaseStream.Position);
landmark.Write(writer);
}
writer.WritePadding();
Expand All @@ -872,7 +871,6 @@ public bool Write(BundleEntry entry)
foreach (GenericRegion region in mpGenericRegions)
{
genericRegionOffsets.Add(region.mId, (uint)writer.BaseStream.Position);
TriggerRegionOffsets.Add((uint)writer.BaseStream.Position);
region.Write(writer);
}
writer.WritePadding();
Expand All @@ -891,9 +889,10 @@ public bool Write(BundleEntry entry)
writer.BaseStream.Position = BlackspotOffsetPosition;
writer.Write((uint)currentPosition);
writer.BaseStream.Position = currentPosition;
List<uint> blackspotOffsets = new List<uint>();
foreach (Blackspot blackspot in mpBlackspots)
{
TriggerRegionOffsets.Add((uint)writer.BaseStream.Position);
blackspotOffsets.Add((uint)writer.BaseStream.Position);
blackspot.Write(writer);
}
writer.WritePadding();
Expand All @@ -902,9 +901,10 @@ public bool Write(BundleEntry entry)
writer.BaseStream.Position = VFXBoxRegionsOffsetPosition;
writer.Write((uint)currentPosition);
writer.BaseStream.Position = currentPosition;
List<uint> vfxBoxRegionOffsets = new List<uint>();
foreach (VFXBoxRegion region in mpVFXBoxRegions)
{
TriggerRegionOffsets.Add((uint)writer.BaseStream.Position);
vfxBoxRegionOffsets.Add((uint)writer.BaseStream.Position);
region.Write(writer);
}
writer.WritePadding();
Expand Down Expand Up @@ -947,10 +947,10 @@ public bool Write(BundleEntry entry)
writer.BaseStream.Position = TriggerOffsetPosition;
writer.Write((uint)currentPosition);
writer.BaseStream.Position = currentPosition;
foreach (uint region in TriggerOffsets)
{
writer.Write(region);
}
foreach (uint region in vfxBoxRegionOffsets) writer.Write(region);
foreach (uint region in blackspotOffsets) writer.Write(region);
foreach (uint region in genericRegionOffsets.Values) writer.Write(region);
foreach (uint region in landmarkOffsets) writer.Write(region);

currentPosition = writer.BaseStream.Position;
writer.BaseStream.Position = SizePosition;
Expand Down
77 changes: 77 additions & 0 deletions BundleManager/EntryEditor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
Expand Down Expand Up @@ -88,6 +89,76 @@ private void FocusTab()
}
}

private delegate byte[] GetDataHex();
private delegate void SetDataHex(byte[] hex);
private byte[] DataHex
{
get
{
if (hexData.InvokeRequired)
{
GetDataHex method = () =>
{
return hexData.HexData;
};
return (byte[])Invoke(method);
}
else
{
return hexData.HexData;
}
}
set
{
if (hexData.InvokeRequired)
{
SetDataHex method = (byte[] hex) =>
{
hexData.HexData = hex;
};
Invoke(method, value);
}
else
{
hexData.HexData = value;
}
}
}

private byte[] ExtraDataHex
{
get
{
if (hexExtraData.InvokeRequired)
{
GetDataHex method = () =>
{
return hexExtraData.HexData;
};
return (byte[])Invoke(method);
}
else
{
return hexExtraData.HexData;
}
}
set
{
if (hexExtraData.InvokeRequired)
{
SetDataHex method = (byte[] hex) =>
{
hexExtraData.HexData = hex;
};
Invoke(method, value);
}
else
{
hexExtraData.HexData = value;
}
}
}

private delegate Image GetImage();
private delegate void SetImage(Image img);
private Image Image
Expand Down Expand Up @@ -404,6 +475,12 @@ private void UpdateDisplay()
ImageMenuVisible = ImageVisible;
BinaryMenuVisible = TabsVisible;

if (TabsVisible)
{
DataHex = _entry.EntryBlocks[0].Data;
ExtraDataHex = _entry.EntryBlocks[1].Data;
}

MenuVisible = true;

InfoText = GetInfo();
Expand Down
2 changes: 1 addition & 1 deletion LangEditor/LangEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public LangEdit()
public void GenerateDictionary()
{
dict = new Dictionary<uint, string>();
StreamReader keys = new StreamReader("keys/keys.txt", Encoding.UTF8);
StreamReader keys = new StreamReader(AppContext.BaseDirectory + "keys/keys.txt", Encoding.UTF8);
string key;
while ((key = keys.ReadLine()) != null)
{
Expand Down

0 comments on commit 0c0793d

Please sign in to comment.