Skip to content

Commit

Permalink
Revert "Town of us"
Browse files Browse the repository at this point in the history
  • Loading branch information
CarbonNeuron authored May 26, 2021
1 parent 033a6ed commit 66cd807
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 216 deletions.
5 changes: 0 additions & 5 deletions AUCapture-WPF/AUCapture-WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
<None Remove="Resources\Misc\Transparent_Nebula.png" />
<None Remove="Resources\Misc\voteCancel.png" />
<None Remove="Resources\Misc\voteConfirm.png" />
<None Remove="Resources\missingtex.png" />
<None Remove="Resources\rainbowtex.png" />
<None Remove="SplashScreens\capture-splashscreen-lovely.png" />
<None Remove="SplashScreens\SplashScreenDouche.png" />
<None Remove="SplashScreens\SplashScreenLovely.png" />
Expand All @@ -64,8 +62,6 @@

<ItemGroup>
<EmbeddedResource Include="Resources\AutoMuteUs_PK.asc" />
<Resource Include="Resources\missingtex.png" />
<Resource Include="Resources\rainbowtex.png" />
</ItemGroup>

<ItemGroup>
Expand All @@ -81,7 +77,6 @@
<PackageReference Include="PgpCore" Version="5.2.0" />
<PackageReference Include="SharedMemory" Version="2.2.3" />
<PackageReference Include="SharpVectors" Version="1.7.1" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="WpfScreenHelper" Version="1.0.0" />
</ItemGroup>

Expand Down
15 changes: 4 additions & 11 deletions AUCapture-WPF/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ public void SetupLoggingConfig() {
Header = $"Capture version: {v.FileMajorPart}.{v.FileMinorPart}.{v.FileBuildPart}.{v.FilePrivatePart}\n",
Footer = $"\nCapture version: {v.FileMajorPart}.{v.FileMinorPart}.{v.FileBuildPart}.{v.FilePrivatePart}"
};
var consoleOutput = new NLog.Targets.ColoredConsoleTarget("Console") {
UseDefaultRowHighlightingRules = true,
DetectConsoleAvailable = true,
Header = $"Capture version: {v.FileMajorPart}.{v.FileMinorPart}.{v.FileBuildPart}.{v.FilePrivatePart}\n",
Footer = $"\nCapture version: {v.FileMajorPart}.{v.FileMinorPart}.{v.FileBuildPart}.{v.FilePrivatePart}"
};
LoggingConfig.AddRule(LogLevel.Debug, LogLevel.Fatal, consoleOutput);
LoggingConfig.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
NLog.LogManager.Configuration = LoggingConfig;
}
Expand Down Expand Up @@ -84,13 +77,13 @@ public void PlaySound(string URL)
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

SetupLoggingConfig();
var args = e.Args;

// needs to be the first call in the program to prevent weird bugs
if (Settings.PersistentSettings.debugConsole)
AllocConsole();
SetupLoggingConfig();
if (Settings.PersistentSettings.debugConsole)
AllocConsole();

var uriStart = IPCAdapter.getInstance().HandleURIStart(e.Args);

switch (uriStart)
Expand Down
181 changes: 17 additions & 164 deletions AUCapture-WPF/Converters/PlayerColorToBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using AmongUsCapture;
using MahApps.Metro.Controls;

namespace AUCapture_WPF.Converters
{
public class PlayerColorToBrush : IValueConverter {
public static Dictionary<PlayerColor, Brush> BrushMapping = new() {
public class PlayerColorToBrush : IValueConverter
{
private static readonly Dictionary<PlayerColor, SolidColorBrush> BrushMapping = new() {
{ PlayerColor.Red, new SolidColorBrush(Color.FromRgb(197, 17, 17))},
{ PlayerColor.Blue, new SolidColorBrush(Color.FromRgb(19, 46, 209))},
{ PlayerColor.Green, new SolidColorBrush(Color.FromRgb(17, 127, 45))},
Expand All @@ -24,50 +22,10 @@ public class PlayerColorToBrush : IValueConverter {
{ PlayerColor.Purple, new SolidColorBrush(Color.FromRgb(107, 47, 187))},
{ PlayerColor.Brown, new SolidColorBrush(Color.FromRgb(113, 73, 30))},
{ PlayerColor.Cyan, new SolidColorBrush(Color.FromRgb(56, 254, 220))},
{ PlayerColor.Lime, new SolidColorBrush(Color.FromRgb(80, 239, 57))},
{ PlayerColor.Watermelon, new SolidColorBrush(Color.FromRgb(168, 50, 62))},
{ PlayerColor.Chocolate, new SolidColorBrush(Color.FromRgb(60, 48, 44))},
{ PlayerColor.SkyBlue, new SolidColorBrush(Color.FromRgb(61, 129, 255))},
{ PlayerColor.Beige, new SolidColorBrush(Color.FromRgb(240, 211, 165))},
{ PlayerColor.HotPink, new SolidColorBrush(Color.FromRgb(236, 61, 255))},
{ PlayerColor.Turquoise, new SolidColorBrush(Color.FromRgb(61, 255, 181))},
{ PlayerColor.Lilac, new SolidColorBrush(Color.FromRgb(186, 161, 255))},
{ PlayerColor.Unknown, null},
{ PlayerColor.Rainbow, null}
{ PlayerColor.Lime, new SolidColorBrush(Color.FromRgb(80, 239, 57))}

};

public static SolidColorBrush RainColorBrush;
public static SolidColorBrush RainColorBrushShaded;

static PlayerColorToBrush() {
var rainbowColor = new SolidColorBrush(Colors.Red);
var rainbowColorShaded = new SolidColorBrush(Colors.Red);
var normalAnimation = GenerateAnimation(false);
var ShadedAnimation = GenerateAnimation(true);
rainbowColor.BeginAnimation(SolidColorBrush.ColorProperty, normalAnimation);
rainbowColorShaded.BeginAnimation(SolidColorBrush.ColorProperty, ShadedAnimation);
RainColorBrush = rainbowColor;
RainColorBrushShaded = rainbowColorShaded;
BrushMapping[PlayerColor.Rainbow] = rainbowColor;
var unknownBrush = new ImageBrush(new BitmapImage(new Uri($"pack://application:,,,/Resources/missingtex.png")));
unknownBrush.TileMode = TileMode.Tile;
unknownBrush.ViewportUnits = BrushMappingMode.Absolute;
unknownBrush.Viewport = new Rect(0, 0, 25, 25);
BrushMapping[PlayerColor.Unknown] = unknownBrush;


}

public static ColorAnimationUsingKeyFrames GenerateAnimation(bool shaded) {
ColorAnimationUsingKeyFrames myAnimation = new ColorAnimationUsingKeyFrames();
myAnimation.KeyFrames = new ColorKeyFrameCollection();
myAnimation.KeyFrames.Add(new RainbowColorKeyFrame(Colors.Red, KeyTime.Uniform, shaded));
myAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(3000));
myAnimation.RepeatBehavior = RepeatBehavior.Forever;
return myAnimation;
}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var color = value as PlayerColor? ?? PlayerColor.Red;
Expand All @@ -92,138 +50,33 @@ public static Color shadeColor(Color inColor, float percent) {
return Color.FromArgb(255, (byte) R, (byte) G, (byte) B);
}

private static Dictionary<PlayerColor, SolidColorBrush> BrushMapping = new() {
{ PlayerColor.Red, new SolidColorBrush(Color.FromRgb(197, 17, 17))},
{ PlayerColor.Blue, new SolidColorBrush(Color.FromRgb(19, 46, 209))},
{ PlayerColor.Green, new SolidColorBrush(Color.FromRgb(17, 127, 45))},
{ PlayerColor.Pink, new SolidColorBrush(Color.FromRgb(237, 84, 186))},
{ PlayerColor.Orange, new SolidColorBrush(Color.FromRgb(239, 125, 13))},
{ PlayerColor.Yellow, new SolidColorBrush(Color.FromRgb(245, 245, 87))},
{ PlayerColor.Black, new SolidColorBrush(Color.FromRgb(63, 71, 78))},
{ PlayerColor.White, new SolidColorBrush(Color.FromRgb(214, 224, 240))},
{ PlayerColor.Purple, new SolidColorBrush(Color.FromRgb(107, 47, 187))},
{ PlayerColor.Brown, new SolidColorBrush(Color.FromRgb(113, 73, 30))},
{ PlayerColor.Cyan, new SolidColorBrush(Color.FromRgb(56, 254, 220))},
{ PlayerColor.Lime, new SolidColorBrush(Color.FromRgb(80, 239, 57))},
{ PlayerColor.Watermelon, new SolidColorBrush(Color.FromRgb(168, 50, 62))},
{ PlayerColor.Chocolate, new SolidColorBrush(Color.FromRgb(60, 48, 44))},
{ PlayerColor.SkyBlue, new SolidColorBrush(Color.FromRgb(61, 129, 255))},
{ PlayerColor.Beige, new SolidColorBrush(Color.FromRgb(240, 211, 165))},
{ PlayerColor.HotPink, new SolidColorBrush(Color.FromRgb(236, 61, 255))},
{ PlayerColor.Turquoise, new SolidColorBrush(Color.FromRgb(61, 255, 181))},
{ PlayerColor.Lilac, new SolidColorBrush(Color.FromRgb(186, 161, 255))},
private static readonly Dictionary<PlayerColor, SolidColorBrush> BrushMapping = new() {
{ PlayerColor.Red, new SolidColorBrush(Color.FromRgb(197, 17, 17))},
{ PlayerColor.Blue, new SolidColorBrush(Color.FromRgb(19, 46, 209))},
{ PlayerColor.Green, new SolidColorBrush(Color.FromRgb(17, 127, 45))},
{ PlayerColor.Pink, new SolidColorBrush(Color.FromRgb(237, 84, 186))},
{ PlayerColor.Orange, new SolidColorBrush(Color.FromRgb(239, 125, 13))},
{ PlayerColor.Yellow, new SolidColorBrush(Color.FromRgb(245, 245, 87))},
{ PlayerColor.Black, new SolidColorBrush(Color.FromRgb(63, 71, 78))},
{ PlayerColor.White, new SolidColorBrush(Color.FromRgb(214, 224, 240))},
{ PlayerColor.Purple, new SolidColorBrush(Color.FromRgb(107, 47, 187))},
{ PlayerColor.Brown, new SolidColorBrush(Color.FromRgb(113, 73, 30))},
{ PlayerColor.Cyan, new SolidColorBrush(Color.FromRgb(56, 254, 220))},
{ PlayerColor.Lime, new SolidColorBrush(Color.FromRgb(80, 239, 57))}

};

static PlayerColorToBrushShaded() {
if (PlayerColorToBrush.BrushMapping[PlayerColor.Unknown] is null || PlayerColorToBrush.BrushMapping[PlayerColor.Rainbow] is null) {
var temp1 = new PlayerColorToBrush();
}

}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var color = value as PlayerColor? ?? PlayerColor.Red;
if (color == PlayerColor.Rainbow) {
return PlayerColorToBrush.RainColorBrushShaded;
}
else if (color == PlayerColor.Unknown) {
return PlayerColorToBrush.BrushMapping[PlayerColor.Unknown];
}
var mainColor = BrushMapping[color];
var shaded = shadeColor(mainColor.Color, -20f);
return new SolidColorBrush(shaded);
}


public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public partial class RainbowColorKeyFrame : ColorKeyFrame
{
#region Constructors

/// <summary>
/// Creates a new LinearColorKeyFrame.
/// </summary>
public RainbowColorKeyFrame(bool shaded) {
Shaded = shaded;
}

/// <summary>
/// Creates a new LinearColorKeyFrame.
/// </summary>
public RainbowColorKeyFrame(Color value)
: base(value)
{
}

public bool Shaded = false;
/// <summary>
/// Creates a new LinearColorKeyFrame.
/// </summary>
public RainbowColorKeyFrame(Color value, KeyTime keyTime, bool shaded)
: base(value, keyTime) {
Shaded = shaded;
}

#endregion

#region Freezable

/// <summary>
/// Implementation of <see cref="System.Windows.Freezable.CreateInstanceCore">Freezable.CreateInstanceCore</see>.
/// </summary>
/// <returns>The new Freezable.</returns>
protected override Freezable CreateInstanceCore()
{
return new RainbowColorKeyFrame(Shaded);
}

#endregion

#region ColorKeyFrame

public static Color Rainbow(double progress)
{
double div = (Math.Abs(progress % 1) * 6);
byte ascending = (byte) ((div % 1) * 255);
byte descending = (byte) (255 - @ascending);

switch ((int) div)
{
case 0:
return Color.FromArgb(255, 255, @ascending, 0);
case 1:
return Color.FromArgb(255, @descending, 255, 0);
case 2:
return Color.FromArgb(255, 0, 255, @ascending);
case 3:
return Color.FromArgb(255, 0, @descending, 255);
case 4:
return Color.FromArgb(255, @ascending, 0, 255);
default: // case 5:
return Color.FromArgb(255, 255, 0, @descending);
}
}

/// <summary>
/// Implemented to linearly interpolate between the baseValue and the
/// Value of this KeyFrame using the keyFrameProgress.
/// </summary>
protected override Color InterpolateValueCore(Color baseValue, double keyFrameProgress) {
var color = Rainbow(keyFrameProgress);
if (Shaded)
{
color = PlayerColorToBrushShaded.shadeColor(color, -20f);
}

return color;
}

#endregion
}
}
Binary file removed AUCapture-WPF/Resources/missingtex.png
Binary file not shown.
Binary file removed AUCapture-WPF/Resources/rainbowtex.png
Binary file not shown.
14 changes: 2 additions & 12 deletions AmongUsCapture/Memory/GameMemReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void DetectPlayerChanges(ProcessMemory memInstance, Dictionary<string, P
else {
// player was here before, we have an old playerInfo to compare against
var oldPlayerInfo = oldPlayers[player.GetPlayerName()];
if (oldPlayerInfo.GetIsDead() != player.GetIsDead()) // player just died
if (!oldPlayerInfo.GetIsDead() && player.GetIsDead()) // player just died
PlayerChanged?.Invoke(this, new PlayerChangedEventArgs {
Action = PlayerAction.Died,
Name = player.GetPlayerName(),
Expand All @@ -184,7 +184,6 @@ private void DetectPlayerChanges(ProcessMemory memInstance, Dictionary<string, P
Color = player.GetPlayerColor()
});


if (oldPlayerInfo.ColorId != player.ColorId)
PlayerChanged?.Invoke(this, new PlayerChangedEventArgs {
Action = PlayerAction.ChangedColor,
Expand Down Expand Up @@ -497,16 +496,7 @@ public enum PlayerColor {
Purple = 8,
Brown = 9,
Cyan = 10,
Lime = 11,
Watermelon = 12,
Chocolate = 13,
SkyBlue = 14,
Beige = 15,
HotPink = 16,
Turquoise = 17,
Lilac = 18,
Rainbow = 19,
Unknown = 999
Lime = 11
}

public enum PlayRegion {
Expand Down
28 changes: 4 additions & 24 deletions AmongUsCapture/Memory/Structs/PlayerInfo.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AUOffsetManager;
using Discord;
using NLog;

namespace AmongUsCapture
{

public class PlayerInfo {
private static List<uint> UnknownColors = new List<uint>();
public class PlayerInfo
{
public byte PlayerId;
public String PlayerName;
public PlayerColor ColorId = PlayerColor.Unknown;
public PlayerColor ColorId;
public uint HatId;
public uint PetId;
public uint SkinId;
public bool Disconnected;
public IntPtr Tasks;
public bool IsImpostor;
public bool IsDead;
public uint realColorID;
public IntPtr _object; //Assume this always has largest offset
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public PlayerInfo(IntPtr baseAddr, ProcessMemory MemInstance, GameOffsets CurrentOffsets) {
bool LogCastError = false;
unsafe {
var baseAddrCopy = baseAddr;
int last = MemInstance.OffsetAddress(ref baseAddrCopy, 0, 0);
Expand All @@ -37,15 +32,7 @@ public PlayerInfo(IntPtr baseAddr, ProcessMemory MemInstance, GameOffsets Curren
PlayerId = Marshal.ReadByte(buffptr, pOf.PlayerIDOffset);
var NamePTR = MemInstance.is64Bit ? (IntPtr) Marshal.ReadInt64(buffptr, pOf.PlayerNameOffset) : (IntPtr) Marshal.ReadInt32(buffptr, pOf.PlayerNameOffset);
PlayerName = NamePTR == IntPtr.Zero ? "" : MemInstance.ReadString(NamePTR, CurrentOffsets.StringOffsets[0], CurrentOffsets.StringOffsets[1]);
var ColorIdNum = (PlayerColor)(uint)Marshal.ReadInt32(buffptr, pOf.ColorIDOffset);
realColorID = (uint)Marshal.ReadInt32(buffptr, pOf.ColorIDOffset);;
if (Enum.IsDefined(typeof(PlayerColor), ColorIdNum)) {
ColorId = (PlayerColor) ColorIdNum;
}
else {
LogCastError = true;
}

ColorId = (PlayerColor)(uint)Marshal.ReadInt32(buffptr, pOf.ColorIDOffset);
HatId = (uint) Marshal.ReadInt32(buffptr, pOf.HatIDOffset);
PetId = (uint) Marshal.ReadInt32(buffptr, pOf.PetIDOffset);
SkinId = (uint) Marshal.ReadInt32(buffptr, pOf.SkinIDOffset);
Expand All @@ -56,13 +43,6 @@ public PlayerInfo(IntPtr baseAddr, ProcessMemory MemInstance, GameOffsets Curren
_object = Marshal.ReadIntPtr(buffptr, pOf.ObjectOffset);
}
}

if (LogCastError) {
if (!UnknownColors.Contains(realColorID)) {
Logger.Debug($"UNKNOWN COLOR. NAME:{GetPlayerName()}, COLOR: {realColorID}");
UnknownColors.Add(realColorID);
}
}
}
public string GetPlayerName() {
return PlayerName;
Expand Down

0 comments on commit 66cd807

Please sign in to comment.