Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup, New Images for LoginPage, #7

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Workspace/Assets/Character.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 modified Workspace/Assets/LoginPage.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 modified Workspace/Assets/ThumbsUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 62 additions & 26 deletions Workspace/Components/CTabControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace Galaxy_Swapper_v2.Workspace.Components
{
Expand All @@ -9,40 +11,42 @@ namespace Galaxy_Swapper_v2.Workspace.Components
/// </summary>
public partial class CTabControl : UserControl
{
private bool isSelected = false;

public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(CTabControl));
DependencyProperty.Register(nameof(Icon), typeof(ImageSource), typeof(CTabControl));

public ImageSource Icon
{
get { return (ImageSource)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
get => (ImageSource)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}

public static readonly DependencyProperty IconClickedProperty =
DependencyProperty.Register("IconClicked", typeof(ImageSource), typeof(CTabControl));
DependencyProperty.Register(nameof(IconClicked), typeof(ImageSource), typeof(CTabControl));

public ImageSource IconClicked
{
get { return (ImageSource)GetValue(IconClickedProperty); }
set { SetValue(IconClickedProperty, value); }
get => (ImageSource)GetValue(IconClickedProperty);
set => SetValue(IconClickedProperty, value);
}

public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("Color", typeof(Brush), typeof(CTabControl), new PropertyMetadata(Properties.Colors.External_Brush));
DependencyProperty.Register(nameof(Color), typeof(Brush), typeof(CTabControl), new PropertyMetadata(Properties.Colors.External_Brush));

public Brush Color
{
get { return (Brush)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
get => (Brush)GetValue(ColorProperty);
set => SetValue(ColorProperty, value);
}

public static readonly DependencyProperty PresenceProperty =
DependencyProperty.Register("Presence", typeof(string), typeof(CNewsControl));
DependencyProperty.Register(nameof(Presence), typeof(string), typeof(CNewsControl));

public string Presence
{
get { return (string)GetValue(PresenceProperty); }
set { SetValue(PresenceProperty, value); }
get => (string)GetValue(PresenceProperty);
set => SetValue(PresenceProperty, value);
}

public CTabControl()
Expand All @@ -52,31 +56,63 @@ public CTabControl()

public void Tab_Default()
{
this.Clicked.Visibility = Visibility.Hidden;
this.Default.Visibility = Visibility.Visible;
this.Color = Properties.Colors.External_Brush;
Clicked.Visibility = Visibility.Hidden;
Default.Visibility = Visibility.Visible;
Color = Properties.Colors.External_Brush;
isSelected = false;
AnimateSize(40, 8);
}

public void Tab_Clicked()
{
this.Default.Visibility = Visibility.Hidden;
this.Clicked.Visibility = Visibility.Visible;
this.Color = Properties.Colors.Blue_Brush;
Default.Visibility = Visibility.Hidden;
Clicked.Visibility = Visibility.Visible;

var colorAnimation = new ColorAnimation
{
From = ((SolidColorBrush)Properties.Colors.External_Brush).Color,
To = ((SolidColorBrush)Properties.Colors.Blue_Brush).Color,
Duration = TimeSpan.FromMilliseconds(200),
EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseInOut }
};

var brush = new SolidColorBrush();
brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);

Color = brush;

Utilities.Presence.Update(Presence);
AnimateSize(45, 7);
isSelected = true;
}

private void CTabControl_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
this.Width = 42;
this.Height = 42;
this.Margin = new Thickness(7);
AnimateSize(45, 7);
}

private void CTabControl_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
this.Width = 40;
this.Height = 40;
this.Margin = new Thickness(8);
if (!isSelected)
{
AnimateSize(40, 8);
}
}

private void AnimateSize(int size, int margin)
{
var sizeAnimation = new DoubleAnimation(size, TimeSpan.FromMilliseconds(200))
{
EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseInOut }
};
var marginAnimation = new ThicknessAnimation(new Thickness(margin), TimeSpan.FromMilliseconds(200))
{
EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseInOut }
};

this.BeginAnimation(WidthProperty, sizeAnimation);
this.BeginAnimation(HeightProperty, sizeAnimation);
this.BeginAnimation(MarginProperty, marginAnimation);
}
}
}
}
47 changes: 6 additions & 41 deletions Workspace/Swapping/Compression/Types/Oodle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,40 @@ public static class Oodle
{
[DllImport("oo2core_5_win64.dll")]
private static extern int OodleLZ_Compress(OodleFormat format, byte[] decompressedBuffer, long decompressedSize, byte[] compressedBuffer, OodleCompressionLevel compressionLevel, uint a, uint b, uint c, uint threadModule);

[DllImport("oo2core_5_win64.dll")]
private static extern int OodleLZ_Decompress(byte[] buffer, long bufferSize, byte[] outputBuffer, long outputBufferSize, uint a, uint b, ulong c, uint d, uint e, uint f, uint g, uint h, uint i, uint threadModule);

public static byte[] Compress(byte[] buffer, OodleCompressionLevel CompressionLevel)
{
uint Uint;
try
{
Uint = (uint)Oodle.OodleLZ_Compress(OodleFormat.Kraken, buffer, buffer.Length, new byte[(int)(uint)buffer.Length + 274U * (((uint)buffer.Length + 262143U) / 262144U)], CompressionLevel, 0U, 0U, 0U, 0);
}
catch (AccessViolationException)
{
Uint = 64U;
}

var array = new byte[(uint)buffer.Length + 274U * (((uint)buffer.Length + 262143U) / 262144U)];
var compressedBytes = new byte[Uint + (uint)OodleLZ_Compress(OodleFormat.Kraken, buffer, buffer.Length, array, CompressionLevel, 0U, 0U, 0U, 0U) - (int)Uint];
Buffer.BlockCopy(array, 0, compressedBytes, 0, OodleLZ_Compress(OodleFormat.Kraken, buffer, buffer.Length, array, CompressionLevel, 0U, 0U, 0U, 0U));
var compressedBytes = new byte[OodleLZ_Compress(OodleFormat.Kraken, buffer, buffer.Length, array, CompressionLevel, 0U, 0U, 0U, 0U)];
Buffer.BlockCopy(array, 0, compressedBytes, 0, compressedBytes.Length);
return compressedBytes;
}

public static byte[] Decompress(byte[] data, int decompressedSize)
{
byte[] decompressedData = new byte[decompressedSize];
Decompress(data, (uint)data.Length, ref decompressedData, (uint)decompressedSize);

return decompressedData;
}

#region Enums
private enum OodleFormat : uint
{
LZH,
LZHLW,
LZNIB,
None,
LZB16,
LZBLW,
LZA,
LZNA,
Kraken,
Mermaid,
BitKnit,
Selkie,
Akkorokamui
LZH, LZHLW, LZNIB, None, LZB16, LZBLW, LZA, LZNA, Kraken, Mermaid, BitKnit, Selkie, Akkorokamui
}

public enum OodleCompressionLevel : ulong
{
None,
Fastest,
Faster,
Fast,
Normal,
Level1,
Level2,
Level3,
Level4,
Level5
None, Fastest, Faster, Fast, Normal, Level1, Level2, Level3, Level4, Level5
}
#endregion

#region Utils
private static uint Decompress(byte[] buffer, uint bufferSize, ref byte[] outputBuffer, uint outputBufferSize)
{
if (buffer.Length > 0 && bufferSize > 0 && outputBuffer.Length > 0 && outputBufferSize > 0)
return (uint)OodleLZ_Decompress(buffer, bufferSize, outputBuffer, outputBufferSize, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

return 0;
}
#endregion
}
}
9 changes: 5 additions & 4 deletions Workspace/Swapping/LobbyBGSwap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class LobbyBGSwap
{
private static readonly string PersistentDownloadDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\FortniteGame\\Saved\\PersistentDownloadDir\\CMS";
private static readonly string DownloadCache = "DownloadCache.json";

private static string[] List()
{
var paths = new List<string>();
Expand All @@ -22,7 +23,7 @@ private static string[] List()
{
Log.Error($"Caught exception while converting lobby screen: Directory does not exist: {PersistentDownloadDir}");
Message.DisplaySTA(Languages.Read(Languages.Type.Header, "Error"), string.Format(Languages.Read(Languages.Type.Message, "PersistentDownloadDirError"), PersistentDownloadDir), discord: true, solutions: Languages.ReadSolutions(Languages.Type.Message, "PersistentDownloadDirError"));
return null!;
return null;
}

string content = File.ReadAllText($"{PersistentDownloadDir}\\{DownloadCache}");
Expand All @@ -31,7 +32,7 @@ private static string[] List()
{
Log.Error($"Caught exception while converting lobby screen: DownloadCache.json is not in a valid JSON format");
Message.DisplaySTA(Languages.Read(Languages.Type.Header, "Error"), Languages.Read(Languages.Type.Message, "DownloadCacheInvalidJSON"), discord: true, solutions: Languages.ReadSolutions(Languages.Type.Message, "DownloadCacheInvalidJSON"));
return null!;
return null;
}

var parse = JObject.Parse(content);
Expand All @@ -51,7 +52,7 @@ private static string[] List()
{
Log.Error($"{filePath} is currently in use!");
Message.DisplaySTA(Languages.Read(Languages.Type.Header, "Error"), $"{filePath} is currently in use! Please close Fortnite and try swapping again.", discord: true);
return null!;
return null;
}

paths.Add(filePath);
Expand Down Expand Up @@ -149,4 +150,4 @@ public static void Revert()
Message.DisplaySTA(Languages.Read(Languages.Type.Header, "Info"), string.Format(Languages.Read(Languages.Type.View, "SwapView", "Reverted"), TimeSpan.Seconds), MessageBoxButton.OK);
}
}
}
}
80 changes: 46 additions & 34 deletions Workspace/Swapping/Other/CustomEpicGamesLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,54 @@ public static class CustomEpicGamesLauncher
{
private static readonly List<byte[]> cpatterns = new List<byte[]>()
{
new byte[] {
0x44, 0x3A, 0x5C, 0x62, 0x75, 0x69, 0x6C, 0x64,
0x5C, 0x2B, 0x2B, 0x50, 0x6F, 0x72, 0x74, 0x61,
0x6C, 0x5C, 0x53, 0x79, 0x6E, 0x63, 0x5C, 0x50,
0x6F, 0x72, 0x74, 0x61, 0x6C, 0x5C, 0x53, 0x6F,
0x75, 0x72, 0x63, 0x65, 0x5C, 0x50, 0x72, 0x6F,
0x67, 0x72, 0x61, 0x6D, 0x73, 0x5C, 0x45, 0x70,
0x69, 0x63, 0x47, 0x61, 0x6D, 0x65, 0x73, 0x4C,
0x61, 0x75, 0x6E, 0x63, 0x68, 0x65, 0x72, 0x5C,
0x4C, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5C, 0x44,
0x61, 0x74, 0x61, 0x41, 0x63, 0x63, 0x65, 0x73,
0x73, 0x5C, 0x50, 0x75, 0x62, 0x6C, 0x69, 0x63,
0x5C, 0x4E, 0x6F, 0x74, 0x69, 0x66, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x68, 0x00,
0x21, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73,
0x69, 0x73, 0x74, 0x28, 0x29
},
new byte[] {
0x44, 0x3A, 0x2F, 0x62, 0x75, 0x69, 0x6C, 0x64,
0x2F, 0x2B, 0x2B, 0x50, 0x6F, 0x72, 0x74, 0x61,
0x6C, 0x2F, 0x53, 0x79, 0x6E, 0x63, 0x2F, 0x45,
0x6E, 0x67, 0x69, 0x6E, 0x65, 0x2F, 0x53, 0x6F,
0x75, 0x72, 0x63, 0x65, 0x2F, 0x52, 0x75, 0x6E,
0x74, 0x69, 0x6D, 0x65, 0x2F, 0x43, 0x6F, 0x72,
0x65, 0x2F, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74,
0x65, 0x2F, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77,
0x73, 0x2F, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77,
0x73, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x4F, 0x75,
0x74, 0x70, 0x75, 0x74, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x2E, 0x63, 0x70, 0x70
},
new byte[]
{
0x44, 0x3A, 0x5C, 0x62, 0x75, 0x69, 0x6C, 0x64,
0x5C, 0x2B, 0x2B, 0x50, 0x6F, 0x72, 0x74, 0x61,
0x6C, 0x5C, 0x53, 0x79, 0x6E, 0x63, 0x5C, 0x50,
0x6F, 0x72, 0x74, 0x61, 0x6C, 0x5C, 0x53, 0x6F,
0x75, 0x72, 0x63, 0x65, 0x5C, 0x50, 0x72, 0x6F,
0x67, 0x72, 0x61, 0x6D, 0x73, 0x5C, 0x45, 0x70,
0x69, 0x63, 0x47, 0x61, 0x6D, 0x65, 0x73, 0x4C,
0x61, 0x75, 0x6E, 0x63, 0x68, 0x65, 0x72, 0x5C,
0x4C, 0x61, 0x79, 0x65, 0x72, 0x73, 0x5C, 0x44,
0x61, 0x74, 0x61, 0x41, 0x63, 0x63, 0x65, 0x73,
0x73, 0x5C, 0x50, 0x75, 0x62, 0x6C, 0x69, 0x63,
0x5C, 0x4E, 0x6F, 0x74, 0x69, 0x66, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x68, 0x00,
0x21, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73,
0x69, 0x73, 0x74, 0x28, 0x29
},
new byte[]
{
0x44, 0x3A, 0x2F, 0x62, 0x75, 0x69, 0x6C, 0x64,
0x2F, 0x2B, 0x2B, 0x50, 0x6F, 0x72, 0x74, 0x61,
0x6C, 0x2F, 0x53, 0x79, 0x6E, 0x63, 0x2F, 0x45,
0x6E, 0x67, 0x69, 0x6E, 0x65, 0x2F, 0x53, 0x6F,
0x75, 0x72, 0x63, 0x65, 0x2F, 0x52, 0x75, 0x6E,
0x74, 0x69, 0x6D, 0x65, 0x2F, 0x43, 0x6F, 0x72,
0x65, 0x2F, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74,
0x65, 0x2F, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77,
0x73, 0x2F, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77,
0x73, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x4F, 0x75,
0x74, 0x70, 0x75, 0x74, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x2E, 0x63, 0x70, 0x70
},
};

public static void Convert()
{
string EpicInstalltion = Settings.Read(Settings.Type.EpicInstalltion).Value<string>();

if (!File.Exists(EpicInstalltion)) throw new CustomException($"Epic Games Launcher does not exist at:{EpicInstalltion}\nPlease ensure you have the corredct path for Epic Games Launcher selected!");
if (!EpicInstalltion.CanEdit()) throw new CustomException($"Failed to open stream for Epic Games Launcher!\nPlease ensure Epic Games Launcher is closed during this process.");
if (!File.Exists(EpicInstalltion))
{
throw new CustomException($"Epic Games Launcher does not exist at:{EpicInstalltion}\nPlease ensure you have the correct path for Epic Games Launcher selected!");
}

if (!EpicInstalltion.CanEdit())
{
throw new CustomException($"Failed to open stream for Epic Games Launcher!\nPlease ensure Epic Games Launcher is closed during this process.");
}

Log.Information($"Opening stream for: {EpicInstalltion}");

Expand Down Expand Up @@ -88,7 +97,10 @@ public static void Revert()
string EpicInstalltion = Settings.Read(Settings.Type.EpicInstalltion).Value<string>();

if (!File.Exists(EpicInstalltion)) return;
if (!EpicInstalltion.CanEdit()) throw new CustomException($"Failed to open stream for Epic Games Launcher!\nPlease ensure Epic Games Launcher is closed during this process.");
if (!EpicInstalltion.CanEdit())
{
throw new CustomException($"Failed to open stream for Epic Games Launcher!\nPlease ensure Epic Games Launcher is closed during this process.");
}

Log.Information($"Deleting: {EpicInstalltion}");

Expand Down
Loading