Skip to content

Commit

Permalink
display instrument/band info
Browse files Browse the repository at this point in the history
  • Loading branch information
InvoxiPlayGames committed Oct 3, 2022
1 parent 5393de0 commit 296c625
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
- name: Setup MSBuild
uses: microsoft/[email protected]
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
es: NuGet/setup-nuget@v1
- name: Build Solution
run: |
cd $GITHUB_WORKSPACE
nuget restore RB3EHelper.sln
msbuild.exe RB3EHelper.sln /p:platform="Any CPU" /p:configuration="Release"
nuget restore ./RB3EHelper.sln
msbuild.exe ./RB3EHelper.sln /p:platform="Any CPU" /p:configuration="Release"
- name: Upload
uses: actions/upload-artifact@v2
with:
Expand Down
59 changes: 57 additions & 2 deletions RB3EHelper/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DiscordRPC;
using System.Diagnostics.Metrics;
using System.Net.Sockets;
using System.Text;

Expand All @@ -16,6 +17,38 @@ public partial class MainForm : Form
string song_artist = "";
string song_name = "";
string shortname = "";
int band_member_count = 0;
byte first_track_type = 0;
byte first_difficulty = 0;

private static string InstrumentName(byte track_type)
{
switch (track_type)
{
case 0: return "Drums";
case 1: return "Guitar";
case 2: return "Bass";
case 3: return "Vocals";
case 4: return "Keys";
case 5: return "Pro Keys";
case 6: return "Pro Guitar";
case 7: return "Harmonies";
case 8: return "Pro Bass";
}
return "Rock band";
}

private static string DifficultyName(byte difficulty)
{
switch (difficulty)
{
case 0: return "Easy";
case 1: return "Medium";
case 2: return "Hard";
case 3: return "Expert";
}
return "Balls hard";
}

static private string PlatformString(byte platform)
{
Expand Down Expand Up @@ -81,8 +114,17 @@ private void UpdatePresence()
// set the song info if we're in a song
if (in_game && song_name != "" && song_artist != "")
{
rp.Details = $"Playing '{song_name}'";
rp.State = $"by {song_artist}";
rp.Details = $"'{song_name}' by {song_artist}";
if (band_member_count == 1)
{
rp.State = $"Playing {DifficultyName(first_difficulty)} {InstrumentName(first_track_type)}";
rp.Assets.SmallImageKey = InstrumentName(first_track_type).ToLower();
}
else
{
rp.State = $"In a {band_member_count} player band";
rp.Assets.SmallImageKey = "band";
}
rp.Timestamps = new Timestamps()
{
Start = gamestarted
Expand Down Expand Up @@ -162,6 +204,19 @@ async private void ListenerThread()
shortname = Encoding.ASCII.GetString(result.Buffer, RB3E_EventHeader.Size, header.PacketSize);
InvokeStringChange(shortnameLabel, shortname);
break;
case 7:
RB3E_EventBandInfo bandinfo = new RB3E_EventBandInfo(result.Buffer, RB3E_EventHeader.Size);
for (int i = 0; i < 4; i++)
{
if (band_member_count == 0)
{
first_difficulty = bandinfo.Difficulty[i];
first_track_type = bandinfo.TrackType[i];
}
if (bandinfo.MemberExists[i] == 0x01)
band_member_count++;
}
break;
default:
Console.WriteLine($"Unknown packet type {header.PacketType}");
break;
Expand Down
21 changes: 21 additions & 0 deletions RB3EHelper/StructDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,25 @@ public RB3E_EventStagekit(byte[] data, int start)
RightChannel = data[start + 1];
}
}

class RB3E_EventBandInfo
{
public static int Size = 0xC;
public byte[] MemberExists;
public byte[] Difficulty;
public byte[] TrackType;

public RB3E_EventBandInfo(byte[] data, int start)
{
if (data.Length - start < Size)
throw new Exception("Invalid byte array size given for RB3E_EventScore constructor.");

MemberExists = new byte[4];
Difficulty = new byte[4];
TrackType = new byte[4];
Array.Copy(data, start + 0, MemberExists, 0, 4);
Array.Copy(data, start + 4, Difficulty, 0, 4);
Array.Copy(data, start + 8, TrackType, 0, 4);
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RB3EHelper

A simple C# .NET 6.0 program to fetch data from the [RB3Enhanced](https://rb3e.rbenhanced.rocks) mod for Rock Band 3 over the network.
A simple C# .NET 6.0 program to fetch data from the [RB3Enhanced](https://github.com/RBEnhanced/RB3Enhanced) mod for Rock Band 3 over the network.

Currently, this can output both to a Discord status and to text files (for use with OBS layouts, and such).

Expand Down

0 comments on commit 296c625

Please sign in to comment.