90 lines
2.8 KiB
C#
90 lines
2.8 KiB
C#
using LibXom.Data;
|
|
using LibXom.Streams;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibW4M.Data.InputMapping
|
|
{
|
|
public class InputEventMappingData : SaveDataEntry
|
|
{
|
|
public XomString Message;
|
|
public XomString FEResourceID;
|
|
public byte[] AllowedDuplacates;
|
|
public InputMappingData[] InputMappings;
|
|
public int Group;
|
|
|
|
public override string FriendlyName
|
|
{
|
|
get
|
|
{
|
|
if (Message.Value != "")
|
|
return Message.Value;
|
|
if (FEResourceID.Value != "")
|
|
return FEResourceID.Value;
|
|
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public InputEventMappingData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
|
|
{
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
using (XomStreamReader reader = new XomStreamReader(new MemoryStream(this.mainContainer.GetData())))
|
|
{
|
|
reader.Skip(3);
|
|
|
|
this.Message = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
|
|
this.FEResourceID = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
|
|
|
|
this.AllowedDuplacates = reader.ReadByteArray();
|
|
|
|
int[] inputMappingIds = reader.ReadCompressedIntArray();
|
|
InputMappings = new InputMappingData[inputMappingIds.Length];
|
|
|
|
for(int i = 0; i < inputMappingIds.Length; i++)
|
|
{
|
|
InputMappings[i] = new InputMappingData(this.fileBelongs, this.fileBelongs.LookupContainerById(inputMappingIds[i]));
|
|
}
|
|
|
|
this.Group = reader.ReadCompressedInt();
|
|
}
|
|
}
|
|
|
|
public override void Save()
|
|
{
|
|
using (MemoryStream ms = new MemoryStream())
|
|
{
|
|
using (XomStreamWriter writer = new XomStreamWriter(ms))
|
|
{
|
|
writer.Skip(3);
|
|
|
|
writer.WriteCompressedInt(this.Message.Id);
|
|
writer.WriteCompressedInt(this.FEResourceID.Id);
|
|
|
|
writer.WriteByteArray(this.AllowedDuplacates);
|
|
|
|
int[] inputMappingIds = new int[this.InputMappings.Length];
|
|
|
|
for (int i = 0; i < inputMappingIds.Length; i++)
|
|
{
|
|
this.InputMappings[i].Save();
|
|
inputMappingIds[i] = this.InputMappings[i].containerId;
|
|
}
|
|
writer.WriteCompressedIntArray(inputMappingIds);
|
|
|
|
writer.WriteCompressedInt(this.Group);
|
|
|
|
ms.Seek(0x00, SeekOrigin.Begin);
|
|
mainContainer.SetData(ms.ToArray());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|