Skip to content

Commit

Permalink
InlineHelp, UIButton, UIGuide, BandButton, other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ihatecompvir committed Jan 8, 2025
1 parent b6e5218 commit 21eabfe
Show file tree
Hide file tree
Showing 17 changed files with 546 additions and 50 deletions.
Binary file added MiloEditor/Images/InlineHelp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MiloEditor/Images/UIGuide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MiloEditor/Images/UIListDir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions MiloEditor/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions MiloEditor/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ private void LoadAssetClassImages()
imageList.Images.Add("WorldInstance", Image.FromFile("Images/WorldInstance.png"));
imageList.Images.Add("CharClipGroup", Image.FromFile("Images/CharClipGroup.png"));
imageList.Images.Add("CheckboxDisplay", Image.FromFile("Images/CheckboxDisplay.png"));
imageList.Images.Add("UIListDir", Image.FromFile("Images/UIListDir.png"));
imageList.Images.Add("UIGuide", Image.FromFile("Images/UIGuide.png"));
imageList.Images.Add("InlineHelp", Image.FromFile("Images/InlineHelp.png"));
imageList.Images.Add("", Image.FromFile("Images/NoDir.png"));

imageList.ColorDepth = ColorDepth.Depth32Bit;
Expand Down Expand Up @@ -321,7 +324,30 @@ private void MiloSceneItemsTree_NodeMouseClick(object sender, TreeNodeMouseClick
if (e.Node.Tag is DirectoryMeta.Entry entry && e.Button == MouseButtons.Left)
{
if (entry.obj != null)
{
CreateEditorPanelForAsset(entry.obj);
}
else
{
// show an unsupported asset panel so its clear the app is still actually functioning, instead of just showing nothing
splitContainer1.Panel2.Controls.Clear();

var unsupportedPanel = new Panel
{
Dock = DockStyle.Fill
};

var unsupportedLabel = new Label
{
Text = "The asset type " + entry.type.value + " is not currently supported.",
Dock = DockStyle.Fill,
TextAlign = ContentAlignment.MiddleCenter,
ForeColor = Color.Black,
};

unsupportedPanel.Controls.Add(unsupportedLabel);
splitContainer1.Panel2.Controls.Add(unsupportedPanel);
}
}

// context menu logic for right-click
Expand Down
12 changes: 12 additions & 0 deletions MiloEditor/MiloEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<None Remove="Images\FileMerger.png" />
<None Remove="Images\Font.png" />
<None Remove="Images\Group.png" />
<None Remove="Images\InlineHelp.png" />
<None Remove="Images\Line.png" />
<None Remove="Images\Lipsync.png" />
<None Remove="Images\MatAnim.png" />
Expand All @@ -58,7 +59,9 @@
<None Remove="Images\TransProxy.png" />
<None Remove="Images\Trigger.png" />
<None Remove="Images\UIColor.png" />
<None Remove="Images\UIGuide.png" />
<None Remove="Images\UILabel.png" />
<None Remove="Images\UIListDir.png" />
<None Remove="Images\WorldDir.png" />
<None Remove="Images\WorldInstance.png" />
</ItemGroup>
Expand Down Expand Up @@ -106,6 +109,9 @@
<Content Include="Images\Group.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\InlineHelp.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\Line.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -184,9 +190,15 @@
<Content Include="Images\UIColor.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\UIGuide.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\UILabel.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\UIListDir.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\WorldDir.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
246 changes: 246 additions & 0 deletions MiloLib/Assets/Band/UI/BandButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
using MiloLib.Assets.UI;
using MiloLib.Classes;
using MiloLib.Utils;

namespace MiloLib.Assets.Band.UI
{
[Name("BandButton"), Description("Button with app-specific features")]
public class BandButton : UIButton
{
private ushort altRevision;
private ushort revision;

[Name("Focus Anim")]
public Symbol focusAnim = new(0, "");
[Name("Pulse Anim")]
public Symbol pulseAnim = new(0, "");

public BandButton 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));

if (revision < 8)
{
if (revision <= 4)
{
trans = trans.Read(reader, false, parent, entry);
draw = draw.Read(reader, false, parent, entry);
}
else
{
base.Read(reader, false, parent, entry);
}
if (revision > 2)
{
reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
}
if (revision <= 4)
{
Symbol.Read(reader);
}

if (revision < 8)
{
reader.ReadBoolean();
}
if (revision != 0)
reader.ReadBoolean();

width = reader.ReadFloat();
height = reader.ReadFloat();

if (revision <= 4)
{
textToken = Symbol.Read(reader);
}
if (revision > 5)
{
alignment = (UILabel.TextAlignments)reader.ReadInt32();
}
}
else if (revision == 8)
{
base.Read(reader, false, parent, entry);

fitType = (UILabel.LabelFitTypes)reader.ReadInt32();
width = reader.ReadFloat();
height = reader.ReadFloat();
leading = reader.ReadFloat();
alignment = (UILabel.TextAlignments)reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
reader.ReadBoolean();
HmxColor4 color = new HmxColor4().Read(reader);
kerning = reader.ReadFloat();
textSize = reader.ReadFloat();
}
else
{
base.Read(reader, false, parent, entry);
if (revision < 0xC)
{
fitType = (UILabel.LabelFitTypes)reader.ReadInt32();
width = reader.ReadFloat();
height = reader.ReadFloat();
}

if (revision < 0xB)
{
leading = reader.ReadFloat();
alignment = (UILabel.TextAlignments)reader.ReadInt32();
}

if (revision < 0xE)
{
reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
reader.ReadInt32();
}

if (revision < 0xB)
{
reader.ReadBoolean();
kerning = reader.ReadFloat();
textSize = reader.ReadFloat();
}
}

if (revision < 0xC)
{
reader.ReadInt32();
}

if (revision == 0xE)
{
// todo

}

if (standalone)
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed");

return this;
}

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

if (revision < 8)
{
if (revision <= 4)
{
trans.Write(writer, false, parent, entry);
draw.Write(writer, false, parent, entry);
}
else
{
base.Write(writer, false, parent, entry);
}
if (revision > 2)
{
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteInt32(0);
}
if (revision <= 4)
{
Symbol.Write(writer, new Symbol(0, ""));
}
if (revision < 8)
{
writer.WriteBoolean(false);
}
if (revision != 0)
writer.WriteBoolean(false);

writer.WriteFloat(width);
writer.WriteFloat(height);

if (revision <= 4)
{
Symbol.Write(writer, textToken);
}
if (revision > 5)
{
writer.WriteInt32((int)alignment);
}
}
else if (revision == 8)
{
base.Write(writer, false, parent, entry);


writer.WriteInt32((int)fitType);
writer.WriteFloat(width);
writer.WriteFloat(height);
writer.WriteFloat(leading);
writer.WriteInt32((int)alignment);
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteBoolean(false);
new HmxColor4().Write(writer);
writer.WriteFloat(kerning);
writer.WriteFloat(textSize);
}
else
{
base.Write(writer, false, parent, entry);
if (revision < 0xC)
{
writer.WriteInt32((int)fitType);
writer.WriteFloat(width);
writer.WriteFloat(height);
}

if (revision < 0xB)
{
writer.WriteFloat(leading);
writer.WriteInt32((int)alignment);
}

if (revision < 0xE)
{
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteInt32(0);
writer.WriteInt32(0);
}

if (revision < 0xB)
{
writer.WriteBoolean(false);
writer.WriteFloat(kerning);
writer.WriteFloat(textSize);
}

}

if (revision < 0xC)
{
writer.WriteInt32(0);
}

if (revision == 0xE)
{
// todo

}

if (standalone)
writer.WriteBlock(new byte[4] { 0xAD, 0xDE, 0xAD, 0xDE });
}

}
}
Loading

0 comments on commit 21eabfe

Please sign in to comment.