Skip to content

Commit

Permalink
RB3 RndMat, RB3 OutfitConfig, CharMeshHide
Browse files Browse the repository at this point in the history
  • Loading branch information
ihatecompvir committed Jan 8, 2025
1 parent 9d2da76 commit d31c312
Show file tree
Hide file tree
Showing 10 changed files with 1,255 additions and 552 deletions.
75 changes: 70 additions & 5 deletions MiloEditor/Panels/EditorPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ private void BuildUI(object obj, int startX, int startY, bool drawTypeLabels)
{
// color pickers for a HmxColor4 List (inside ColorPalettes, mainly, but can appear other places)
case List<HmxColor4> colorList:
inputControl = BuildColorPicker(colorList, field);
inputControl = BuildListColorPicker(colorList, field);
break;
case HmxColor4 color:
inputControl = BuildColorPicker(new List<HmxColor4> { color }, field);
inputControl = BuildColor4Picker(color, field);
break;
case HmxColor3 color: // TODO: make a real Color3 picker
inputControl = BuildColorPicker(new List<HmxColor4> { new HmxColor4(color.r, color.g, color.b, 1.0f) }, field);
case HmxColor3 color:
inputControl = BuildColor3Picker(color, field);
break;
// list of bytes
case List<byte> byteValue:
Expand Down Expand Up @@ -363,8 +363,73 @@ private void BuildUI(object obj, int startX, int startY, bool drawTypeLabels)
}
}

private Control BuildColor4Picker(HmxColor4 color, FieldInfo field)
{
var colorPicker = new ColorPicker
{
Width = 100,
Height = 30,
Margin = new Padding(5),
BorderStyle = BorderStyle.FixedSingle,
Color = Color.FromArgb(255, (int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255))
};

colorPicker.ColorChanged += (sender, args) =>
{
var picker = (ColorPicker)sender;
var selectedColor = picker.Color;
float a = selectedColor.A / 255.0f;
float r = selectedColor.R / 255.0f;
float g = selectedColor.G / 255.0f;
float b = selectedColor.B / 255.0f;

object ownerObject = ResolveFieldOwner(targetObject, field);

if (ownerObject != null)
{
// Update the field value
HmxColor4 updatedColor = new HmxColor4 { a = a, r = r, g = g, b = b };
field.SetValue(ownerObject, updatedColor);
}
};

return colorPicker;
}

private Control BuildColor3Picker(HmxColor3 color, FieldInfo field)
{
var colorPicker = new ColorPicker
{
Width = 100,
Height = 30,
Margin = new Padding(5),
BorderStyle = BorderStyle.FixedSingle,
Color = Color.FromArgb(255, (int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255))
};

colorPicker.ColorChanged += (sender, args) =>
{
var picker = (ColorPicker)sender;
var selectedColor = picker.Color;
float r = selectedColor.R / 255.0f;
float g = selectedColor.G / 255.0f;
float b = selectedColor.B / 255.0f;

object ownerObject = ResolveFieldOwner(targetObject, field);

if (ownerObject != null)
{
// Update the field value
HmxColor3 updatedColor = new HmxColor3 { r = r, g = g, b = b };
field.SetValue(ownerObject, updatedColor);
}
};

return colorPicker;
}


private Control BuildColorPicker(List<HmxColor4> colorList, FieldInfo field)
private Control BuildListColorPicker(List<HmxColor4> colorList, FieldInfo field)
{
var scrollingPanel = new Panel
{
Expand Down
4 changes: 2 additions & 2 deletions MiloLib/Assets/Band/BandCrowdMeterDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class BandCrowdMeterDir : RndDir
//{ Game.MiloGame.GreenDayRockBand, 22 },
{ Game.MiloGame.RockBand3, 3 },
};
public ushort altRevision;
public ushort revision;
private ushort altRevision;
private ushort revision;

private uint colorCount;

Expand Down
145 changes: 145 additions & 0 deletions MiloLib/Assets/Band/BandPatchMesh.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
using MiloLib.Classes;
using MiloLib.Utils;

namespace MiloLib.Assets.Band
{
public class BandPatchMesh
{


public class MeshPair
{
public class PatchPair
{
public Symbol patch = new(0, "");
public Symbol tex = new(0, "");

public PatchPair Read(EndianReader reader)
{
patch = Symbol.Read(reader);
tex = Symbol.Read(reader);
return this;
}

public void Write(EndianWriter writer)
{
Symbol.Write(writer, patch);
Symbol.Write(writer, tex);
}
}

public Symbol mesh = new(0, "");
private uint patchPairCount;
public List<PatchPair> patchPairs = new();

public class MeshVert
{

}

public MeshPair Read(EndianReader reader)
{
mesh = Symbol.Read(reader);
return this;
}

public void Write(EndianWriter writer)
{
Symbol.Write(writer, mesh);
}


}

private ushort altRevision;
private ushort revision;

private uint meshPairCount;
public List<MeshPair> meshPairs = new();

public bool renderTo;

public Symbol source = new(0, "");

public int category;

public Symbol unkSymbol1 = new(0, "");
public Symbol unkSymbol2 = new(0, "");

public Symbol unkSymbol3 = new(0, "");

public BandPatchMesh Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry)
{
uint combinedRevision = reader.ReadUInt32();
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));

source = Symbol.Read(reader);

if (revision > 3)
{
meshPairCount = reader.ReadUInt32();
for (int i = 0; i < meshPairCount; i++)
meshPairs.Add(new MeshPair().Read(reader));
}
else
{
meshPairs.Add(new MeshPair().Read(reader));
}
if (revision < 1)
unkSymbol1 = Symbol.Read(reader);

if (revision < 4)
unkSymbol2 = Symbol.Read(reader);

if (revision > 1)
{
if (revision > 2)
renderTo = reader.ReadBoolean();
else
unkSymbol3 = Symbol.Read(reader);
}

if (revision > 3)
category = reader.ReadInt32();

return this;
}

public void Write(EndianWriter writer, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry? entry)
{
writer.WriteUInt32(BitConverter.IsLittleEndian ? (uint)(altRevision << 16 | revision) : (uint)(revision << 16 | altRevision));

Symbol.Write(writer, source);

if (revision > 3)
{
writer.WriteUInt32((uint)meshPairs.Count);
foreach (MeshPair meshPair in meshPairs)
meshPair.Write(writer);
}
else
{
meshPairs[0].Write(writer);
}

if (revision < 1)
Symbol.Write(writer, unkSymbol1);

if (revision < 4)
Symbol.Write(writer, unkSymbol2);

if (revision > 1)
{
if (revision > 2)
writer.WriteBoolean(renderTo);
else
Symbol.Write(writer, unkSymbol3);
}

if (revision > 3)
writer.WriteInt32(category);
}

}
}
Loading

0 comments on commit d31c312

Please sign in to comment.