Skip to content
Open
7 changes: 6 additions & 1 deletion LibForge/ForgeTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ void WithIO(Action<Stream, Stream> action)
case "tex2png":
WithIO((fi, fo) =>
{
var compressionType = "default";
if(args.Length > 3)
{
compressionType = args[3];
}
var tex = TextureReader.ReadStream(fi);
var bitmap = TextureConverter.ToBitmap(tex, 0);
var bitmap = TextureConverter.ToBitmap(tex, 0, compressionType);
bitmap.Save(fo, System.Drawing.Imaging.ImageFormat.Png);
});
break;
Expand Down
5 changes: 4 additions & 1 deletion LibForge/ForgeToolGUI/ForgeToolGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{233099F7-0471-4064-B000-F6DDE21E64E6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<RootNamespace>ForgeToolGUI</RootNamespace>
<AssemblyName>ForgeToolGUI</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
Expand Down Expand Up @@ -36,6 +36,9 @@
<PropertyGroup>
<ApplicationIcon>anvil.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="MidiCS">
<HintPath>..\..\Dependencies\MidiCS.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion LibForge/ForgeToolGUI/Inspectors/ConversionInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void LoadCons(string[] filenames)
}
catch (Exception e)
{
logBox.AppendText($"Error loading {filename}: {e.Message}" + Environment.NewLine);
logBox.AppendText($"Error loading {filename}: {e.Message}" + Environment.NewLine + "Error Stack:" + Environment.NewLine + e.StackTrace);
}
}
UpdateState();
Expand Down
4 changes: 2 additions & 2 deletions LibForge/ForgeToolGUI/Inspectors/Inspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static Inspector GetInspector(object obj)
switch (obj)
{
case Texture i:
return new ImageInspector(TextureConverter.ToBitmap(i, 0));
return new ImageInspector(i);
case string s:
return new StringInspector(s);
case SongData d:
Expand Down Expand Up @@ -54,7 +54,7 @@ public static object LoadObject(GameArchives.IFile i)
{
try
{
return TextureReader.ReadStream(s);
return TextureReader.ReadStream(s, i.Name);
}
catch (Exception ex)
{
Expand Down
52 changes: 49 additions & 3 deletions LibForge/ForgeToolGUI/Inspectors/TextureInspector.Designer.cs

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

45 changes: 41 additions & 4 deletions LibForge/ForgeToolGUI/Inspectors/TextureInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,54 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LibForge;
using System.IO;

namespace ForgeToolGUI
{
public partial class ImageInspector : Inspector
{
public ImageInspector(Image i)
LibForge.Texture.Texture uncompressedTexture;
public ImageInspector(LibForge.Texture.Texture i)
{
InitializeComponent();
pictureBox1.Width = i.Width;
pictureBox1.Height = i.Height;
pictureBox1.Image = i;
uncompressedTexture = i;
Image decompressedImage = LibForge.Texture.TextureConverter.ToBitmap(i, 0, "default");
pictureBox1.Width = decompressedImage.Width;
pictureBox1.Height = decompressedImage.Height;
pictureBox1.Image = decompressedImage;
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
changeImageDecompression(DecompressList.SelectedItem.ToString());
}

private void changeImageDecompression(String decompression)
{
Image newDecompressedImage = LibForge.Texture.TextureConverter.ToBitmap(uncompressedTexture, 0, decompression);
pictureBox1.Width = newDecompressedImage.Width;
pictureBox1.Height = newDecompressedImage.Height;
pictureBox1.Image = newDecompressedImage;
}

private void label1_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.InitialDirectory = @"./";
dialog.RestoreDirectory = true;
dialog.FileName = uncompressedTexture.FileName.Replace("bmp_ps4", "").Replace("png_ps4", "") + ".png";
dialog.DefaultExt = "png";

if(dialog.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image.Save(dialog.FileName, System.Drawing.Imaging.ImageFormat.Png);
}
}
}
}
4 changes: 2 additions & 2 deletions LibForge/LibForge.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
# Visual Studio Version 16
VisualStudioVersion = 16.0.32602.291
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibForge", "LibForge\LibForge.csproj", "{3684B7E6-0978-487A-895C-D0ED8F6B7B9A}"
EndProject
Expand Down
4 changes: 4 additions & 0 deletions LibForge/LibForge/LibForge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<Compile Include="Midi\RBMidReader.cs" />
<Compile Include="Milo\BlockStructure.cs" />
<Compile Include="Milo\CharLipSync.cs" />
<Compile Include="Milo\Compression.cs" />
<Compile Include="Milo\MiloFile.cs" />
<Compile Include="Milo\IMiloEntry.cs" />
<Compile Include="RBSong\PropAnimResource.cs" />
Expand Down Expand Up @@ -133,5 +134,8 @@
<Name>LibOrbisPkg</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
28 changes: 21 additions & 7 deletions LibForge/LibForge/Midi/RBMidConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public MidiConverter(MidiFile mf, int hopoThreshold = 170, Action<string> warnAc
public RBMid ToRBMid()
{
rb = new RBMid();
var processedMidiTracks = ConvertVenueTrack(mf.Tracks);
var processedMidiTracks = ConvertVenueTrack(mf.Tracks, warnAction);
ReadMidiFileResourceFromMidiFile(rb, mf, processedMidiTracks, MeasureTicks);
rb.Format = 0x10;

Expand Down Expand Up @@ -1150,16 +1150,22 @@ private void HandleVocalsTrk(MidiTrackProcessed track)
// Event handlers
bool AddLyric(MidiText e)
{
// TODO: investigate further what is read from midi
try {
if (e.Text[0] != '[')
{
lyrics.Add(new RBMid.TICKTEXT
{
Text = e.Text.Trim(' '),
Tick = e.StartTicks,
});
lyrics.Add(new RBMid.TICKTEXT
{
Text = e.Text.Trim(' '),
Tick = e.StartTicks,
});
return true;
}
return false;
} catch
{
return false;
}
}
bool AddVocalNote(MidiNote e)
{
Expand Down Expand Up @@ -1608,7 +1614,7 @@ private void HandleVenueTrk(MidiTrackProcessed track)
}

// Converts the venue track from RBN2 to RBN1 so that RB4 can autogen animations
private static List<MidiTrack> ConvertVenueTrack(List<MidiTrack> tracks)
private static List<MidiTrack> ConvertVenueTrack(List<MidiTrack> tracks, Action<string> warnAction)
{
const int tpqn = 480;
const int note_length = tpqn / 4; //16th note
Expand All @@ -1620,12 +1626,19 @@ private static List<MidiTrack> ConvertVenueTrack(List<MidiTrack> tracks)
var venueTrack = tracks.Where(x => x.Name == "VENUE").FirstOrDefault();
if (venueTrack == null)
{
MidiTrack eventTrack = tracks.Where(x => x.Name == "EVENTS").FirstOrDefault();
foreach(var message in eventTrack.Messages)
{
warnAction(message.ToString());
}
warnAction?.Invoke("no venueTrack");
return tracks;
}
if(!venueTrack.Messages.Any(m => m is TextEvent t
&& (t.Text.Contains(".pp]") || t.Text.Contains("[coop") || t.Text.Contains("[directed"))))
{
// If this is already a RBN1 VENUE, skip it.
warnAction("Skipping, already a RBN1 Venue");
return tracks;
}
long last_first = 0;
Expand All @@ -1642,6 +1655,7 @@ private static List<MidiTrack> ConvertVenueTrack(List<MidiTrack> tracks)
{
var index = mt.Text.IndexOf("[", StringComparison.Ordinal);
var new_event = mt.Text.Substring(index, mt.Text.Length - index).Trim();
warnAction(new_event);

if (new_event.Contains("[directed"))
{
Expand Down
45 changes: 40 additions & 5 deletions LibForge/LibForge/Milo/BlockStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,61 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LibForge.Milo
{
public enum BlockStructure : uint
{
/// <summary>
/// Structured as milo (No compression)
/// Raw data. Uncompressed.
/// </summary>
NONE = 0,
/// <summary>
/// Raw data. Compressed with GZip.
/// <para>*FreQ</para>
/// </summary>
GZIP = 1,
/// <summary>
/// Structured as milo. No compression.
/// <para>*RBN</para>
/// </summary>
MILO_A = 0xCABEDEAF,
/// <summary>
/// Structured as milo (Compressed with ZLib)
/// Structured as milo. Compressed with ZLib.
/// <para>*GH1</para>
/// <para>*GH2</para>
/// <para>*GH80's</para>
/// <para>*RB1</para>
/// <para>*RBTP Vol. 1</para>
/// <para>*RB2</para>
/// <para>*ACDC RB</para>
/// <para>*RBTB Vol. 2</para>
/// <para>*RBTP Classic Rock</para>
/// <para>*RBTP Country</para>
/// <para>*TBRB</para>
/// <para>*RBTP Metal</para>
/// <para>*LRB</para>
/// <para>*GDRB</para>
/// <para>*RBTP Country 2</para>
/// </summary>
MILO_B = 0xCBBEDEAF,
/// <summary>
/// Structured as milo (Compressed with GZip)
/// Structured as milo. Compressed with GZip.
/// <para>*Amp</para>
/// <para>*KR1</para>
/// <para>*KR2</para>
/// <para>*KR3</para>
/// </summary>
MILO_C = 0xCCBEDEAF,
/// <summary>
/// Structured as milo (Compressed with ZLib)
/// Structured as milo. Compressed with ZLib.
/// <para>*RB3</para>
/// <para>*DC1</para>
/// <para>*DC2</para>
/// <para>*RBB</para>
/// <para>*DC3</para>
/// </summary>
MILO_D = 0xCDBEDEAF
}
}
}
Loading