Skip to content

Commit

Permalink
MINOR v3.1.4 (Rewrite Attempt+Features)
Browse files Browse the repository at this point in the history
- Reverted rending
- Added offset for community profiles.
- First Processor.cs rewrite attempt.

Stuff might be buggy but deal with it for now as I am looking for better ways of implementing stuff.
  • Loading branch information
weedeej committed Mar 6, 2022
1 parent d7ff978 commit 3b3ccaf
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 152 deletions.
4 changes: 4 additions & 0 deletions ValorantCC/SubWindow/ProfilesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<Button Style="{DynamicResource MahApps.Styles.Button}" Name="btnSearchCode" Content="Search Code" MinWidth="85" Background="#FF393B44" Margin="0,5,5,0" Foreground="White" Cursor="Hand" Click="btnSearchCode_Click" BorderBrush="#FF393B44"/>
</StackPanel>
<TextBlock Foreground="White" HorizontalAlignment="Center" Visibility="Collapsed" Name="fetchErrorTxt">An error has occured while fetching profiles.</TextBlock>
<DockPanel x:Name="Pagination">
<Label Content="Previous" FontWeight="Normal" FontStyle="Italic" Cursor="Hand" x:Name="btnPreviousOffset" MouseUp="btnPreviousOffset_MouseUp"/>
<Label Content="Next" HorizontalAlignment="Right" FontStyle="Italic" Cursor="Hand" x:Name="btnNextOffset" MouseUp="btnNextOffset_MouseUp"/>
</DockPanel>
<Image gif:ImageBehavior.AnimatedSource="../Resources/vtspinner optimized.gif" Width="50" Height="52" Margin="0,155,0,0" x:Name="LoadingPlaceHolder" Visibility="Visible" IsVisibleChanged="LoadingPlaceHolder_IsVisibleChanged"/>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0,5,0,0" Height="405" Width="338">

Expand Down
53 changes: 52 additions & 1 deletion ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public partial class ProfilesWindow : MetroWindow
private static API ValCCApi;
private static MainWindow main;
private static List<PublicProfile> PublicProfiles = new List<PublicProfile>();
private int _offset = 0;
public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
{
InitializeComponent();
Expand All @@ -41,6 +42,7 @@ public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
private async void ShareablesContainer_Loaded(object sender, RoutedEventArgs e)
{
LoadingPlaceHolder.Visibility = Visibility.Visible;
Pagination.Visibility = Visibility.Collapsed;
fetchErrorTxt.Visibility = Visibility.Collapsed;
try
{
Expand All @@ -56,6 +58,7 @@ private async void ShareablesContainer_Loaded(object sender, RoutedEventArgs e)
Utilities.Utils.Log(ex.StackTrace.ToString());
}
LoadingPlaceHolder.Visibility = Visibility.Collapsed;
Pagination.Visibility = Visibility.Visible;
}

/// <summary>
Expand Down Expand Up @@ -86,9 +89,10 @@ private async Task<bool> InitialFetch(String sharecode = null)
else
{
Utilities.Utils.Log($"Fetching profiles from server");
FetchResponse fetchResponse = await ValCCApi.Fetch();
FetchResponse fetchResponse = await ValCCApi.Fetch(Offset: _offset);
if (!fetchResponse.success) return false;
Shareables = fetchResponse.data;
Pagination.Visibility = Visibility.Visible;
}

if (Shareables.Count == 0) return true;
Expand Down Expand Up @@ -122,6 +126,7 @@ private async Task<bool> RenderProfiles()
private async void btnSearchCode_Click(object sender, RoutedEventArgs e)
{
LoadingPlaceHolder.Visibility = Visibility.Visible;
Pagination.Visibility = Visibility.Collapsed;
fetchErrorTxt.Visibility = Visibility.Collapsed;
try
{
Expand Down Expand Up @@ -206,5 +211,51 @@ private void LoadingPlaceHolder_IsVisibleChanged(object sender, DependencyProper
else
WpfAnimatedGif.ImageBehavior.GetAnimationController(LoadingPlaceHolder)?.Pause();
}

private async void btnNextOffset_MouseUp(object sender, MouseButtonEventArgs e)
{
LoadingPlaceHolder.Visibility = Visibility.Visible;
Pagination.Visibility = Visibility.Collapsed;
fetchErrorTxt.Visibility = Visibility.Collapsed;
_offset += 20;
try
{
bool fetchSucc = await InitialFetch();
if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
else
{
await RenderProfiles();
}
}
catch (Exception ex)
{
Utilities.Utils.Log(ex.StackTrace.ToString());
}
LoadingPlaceHolder.Visibility = Visibility.Collapsed;
Pagination.Visibility = Visibility.Visible;
}

private async void btnPreviousOffset_MouseUp(object sender, MouseButtonEventArgs e)
{
LoadingPlaceHolder.Visibility = Visibility.Visible;
Pagination.Visibility = Visibility.Collapsed;
fetchErrorTxt.Visibility = Visibility.Collapsed;
if (_offset >= 20) _offset -= 20;
try
{
bool fetchSucc = await InitialFetch();
if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
else
{
await RenderProfiles();
}
}
catch (Exception ex)
{
Utilities.Utils.Log(ex.StackTrace.ToString());
}
LoadingPlaceHolder.Visibility = Visibility.Collapsed;
Pagination.Visibility = Visibility.Visible;
}
}
}
4 changes: 2 additions & 2 deletions ValorantCC/ValorantCC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<Version>3.0.4</Version>
<SignAssembly>false</SignAssembly>
<Version>3.1.4</Version>
<SignAssembly>true</SignAssembly>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions ValorantCC/src/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct FetchResponse
public bool success { get; set; }
public List<ShareableProfile> data { get; set; }
public string message { get; set; }
public int offset { get; set; }
}

public struct ShareableProfile
Expand Down Expand Up @@ -49,13 +50,13 @@ public API(AuthTokens Tokens, CrosshairProfile TargetProfile, int ActionInt, boo
Shareable = isShareable;
}

public async Task<FetchResponse> Fetch(String sharecode = null)
public async Task<FetchResponse> Fetch(String sharecode = null, int Offset = 0)
{
RestRequest request;
if (sharecode != null)
request = new RestRequest($"/sharecode/{sharecode}", Method.Get);
else
request = new RestRequest("/profiles", Method.Get);
request = new RestRequest($"/profiles?offset={Offset}", Method.Get);

RestResponse response = await client.ExecuteAsync(request);
if (!response.IsSuccessful && response.StatusCode != System.Net.HttpStatusCode.NotFound)
Expand All @@ -65,13 +66,14 @@ public async Task<FetchResponse> Fetch(String sharecode = null)
}
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return new FetchResponse() { success = true, data = new List<ShareableProfile>() };
return new FetchResponse() { success = true, data = new List<ShareableProfile>(), offset = Offset };
}

return new FetchResponse()
{
success = true,
data = JsonConvert.DeserializeObject<List<ShareableProfile>>(response.Content)
data = JsonConvert.DeserializeObject<List<ShareableProfile>>(response.Content),
offset = Offset
};
}

Expand Down
21 changes: 7 additions & 14 deletions ValorantCC/src/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,11 @@ public partial class AuthResponse

public partial class VersionResponse
{
public int Status;
public VersionData Data;
public int Status { get; set; }
public string riotClientVersion { get; set; }

}
public partial class VersionData
{
public string RiotClientVersion { get; set; }
public string ManifestID { get; set; }
public string Version { get; set; }
public string BuildVersion { get; set; }
public string Branch { get; set; }
public string BuildDate { get; set; }
}

public class AuthObj
{
LockfileData LocalCredentials;
Expand Down Expand Up @@ -123,13 +115,14 @@ private async Task<AuthTokens> ObtainAuthTokens()
private async static Task<String> GetVersion()
{
Utilities.Utils.Log("Obtaining Client Version info");
RestRequest request = new RestRequest("https://valorant-api.com/v1/version", Method.Get);
RestRequest request = new RestRequest("https://vtools-next.vercel.app/api/skinslist/version", Method.Get);

RestResponse response = await client.ExecuteAsync(request);
if (!response.IsSuccessful) return "0.0.0";
if (!response.IsSuccessful) return "release-04.04-shipping-15-678808";

VersionResponse RespData = JsonConvert.DeserializeObject<VersionResponse>(response.Content.ToString());
return RespData.Data.RiotClientVersion;
RespData.Status = ((int)response.StatusCode);
return RespData.riotClientVersion;
}
}
}
61 changes: 33 additions & 28 deletions ValorantCC/src/Binder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;
namespace ValorantCC
{
public partial class Actionmapping
Expand Down Expand Up @@ -52,45 +53,45 @@ public partial class CrosshairProfile

public partial class ProfileSettings
{
public CrosshairColor Color { get; set; } = new CrosshairColor();
public bool bHasOutline { get; set; } = false;
public float OutlineThickness { get; set; } = 1;
public CrosshairColor OutlineColor { get; set; } = new CrosshairColor();
public float OutlineOpacity { get; set; } = 0;
public float CenterDotSize { get; set; } = 1;
public float CenterDotOpacity { get; set; } = 0;
public bool bDisplayCenterDot { get; set; } = false;
public bool bFixMinErrorAcrossWeapons { get; set; } = false;
public LineSettings InnerLines { get; set; } = new LineSettings();
public LineSettings OuterLines { get; set; } = new LineSettings();
public CrosshairColor Color { get; set; }
public bool bHasOutline { get; set; }
public float OutlineThickness { get; set; }
public CrosshairColor OutlineColor { get; set; }
public float OutlineOpacity { get; set; }
public float CenterDotSize { get; set; }
public float CenterDotOpacity { get; set; }
public bool bDisplayCenterDot { get; set; }
public bool bFixMinErrorAcrossWeapons { get; set; }
public LineSettings InnerLines { get; set; }
public LineSettings OuterLines { get; set; }

}

public partial class SniperSettings
{
public CrosshairColor CenterDotColor { get; set; } = new CrosshairColor();
public float CenterDotSize { get; set; } = 0;
public float CenterDotOpacity { get; set; } = 0;
public bool bDisplayCenterDot { get; set; } = false;
public CrosshairColor CenterDotColor { get; set; }
public float CenterDotSize { get; set; }
public float CenterDotOpacity { get; set; }
public bool bDisplayCenterDot { get; set; }
}
public partial class CrosshairColor
{
public byte R { get; set; } = 0;
public byte G { get; set; } = 0;
public byte B { get; set; } = 0;
public byte A { get; set; } = 0;
public byte R { get; set; } = 254;
public byte G { get; set; } = 254;
public byte B { get; set; } = 254;
public byte A { get; set; } = 255;
}

public partial class LineSettings
{
public float LineThickness { get; set; } = 2;
public float LineLength { get; set; } = 4;
public float LineOffset { get; set; } = 2;
public bool bShowMovementError { get; set; } = false;
public bool bShowShootingError { get; set; } = false;
public bool bShowMinError { get; set; } = false;
public float Opacity { get; set; } = 1;
public bool bShowLines { get; set; } = true;
public float LineThickness { get; set; }
public float LineLength { get; set; }
public float LineOffset { get; set; }
public bool bShowMovementError { get; set; }
public bool bShowShootingError { get; set; }
public bool bShowMinError { get; set; }
public float Opacity { get; set; }
public bool bShowLines { get; set; }
public float firingErrorScale { get; set; }
public float movementErrorScale { get; set; }
}
Expand All @@ -113,4 +114,8 @@ public partial class Data
public List<string> settingsProfiles { get; set; }
}

}
public partial class FetchResponseData
{
public Data data { get; set; }
}
}
63 changes: 63 additions & 0 deletions ValorantCC/src/Crosshair/CrosshairMain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace ValorantCC.src.Crosshair
{
public class CrosshairMain
{
public static Data ChangeInActiveProfile(List<Color> Colors, int SelectedIndex, Data UserSettings, ProfileList FetchedProfiles)
{
Utilities.Utils.Log("Updating inactive color");

var SelectedProfile = FetchedProfiles.Profiles[SelectedIndex];
if (!SelectedProfile.bUseAdvancedOptions) SelectedProfile.bUseAdvancedOptions = true;
SelectedProfile.Primary.Color.R = Colors[0].R; SelectedProfile.Primary.Color.G = Colors[0].G; SelectedProfile.Primary.Color.B = Colors[0].B; SelectedProfile.Primary.Color.A = Colors[0].A;
SelectedProfile.Primary.OutlineColor.R = Colors[1].R; SelectedProfile.Primary.OutlineColor.G = Colors[1].G; SelectedProfile.Primary.OutlineColor.B = Colors[1].B; SelectedProfile.Primary.OutlineColor.A = Colors[1].A;
SelectedProfile.aDS.Color.R = Colors[2].R; SelectedProfile.aDS.Color.G = Colors[2].G; SelectedProfile.aDS.Color.B = Colors[2].B; SelectedProfile.aDS.Color.A = Colors[2].A;
SelectedProfile.aDS.OutlineColor.R = Colors[3].R; SelectedProfile.aDS.OutlineColor.G = Colors[3].G; SelectedProfile.aDS.OutlineColor.B = Colors[3].B; SelectedProfile.aDS.OutlineColor.A = Colors[3].A;
SelectedProfile.Sniper.CenterDotColor.R = Colors[4].R; SelectedProfile.Sniper.CenterDotColor.G = Colors[4].G; SelectedProfile.Sniper.CenterDotColor.B = Colors[4].B; SelectedProfile.Sniper.CenterDotColor.A = Colors[4].A;
return UserSettings;
}

public static Data ChangeActiveProfile(List<Color> Colors, int SelectedIndex, Data UserSettings, ProfileList FetchedProfiles)
{
Utilities.Utils.Log("Updating active color");
try
{
Stringsetting activeProfileColor = UserSettings.stringSettings.First(setting => setting.settingEnum == "EAresStringSettingName::CrosshairColor");
activeProfileColor.value = Utilities.Utils.ColorToString(Colors[0]);
}
catch
{
Utilities.Utils.Log("User has no entry for CrosshairColor, Creating one...");
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairColor", value = Utilities.Utils.ColorToString(Colors[0]) });
}
finally
{
var SelectedProfile = FetchedProfiles.Profiles[SelectedIndex];
if (!SelectedProfile.bUseAdvancedOptions) SelectedProfile.bUseAdvancedOptions = true;
Utilities.Utils.Log("Removing Old colors.");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairSniperCenterDotColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairADSColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairOutlineColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairADSOutlineColor");
Utilities.Utils.Log("Appending new colors.");
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairSniperCenterDotColor", value = Utilities.Utils.ColorToString(Colors[4]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairADSColor", value = Utilities.Utils.ColorToString(Colors[2]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairOutlineColor", value = Utilities.Utils.ColorToString(Colors[1]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairADSOutlineColor", value = Utilities.Utils.ColorToString(Colors[3]) });
Utilities.Utils.Log("Modifying profile colors.");
SelectedProfile.Primary.Color.R = Colors[0].R; SelectedProfile.Primary.Color.G = Colors[0].G; SelectedProfile.Primary.Color.B = Colors[0].B; SelectedProfile.Primary.Color.A = Colors[0].A;
SelectedProfile.Primary.OutlineColor.R = Colors[1].R; SelectedProfile.Primary.OutlineColor.G = Colors[1].G; SelectedProfile.Primary.OutlineColor.B = Colors[1].B; SelectedProfile.Primary.OutlineColor.A = Colors[1].A;
SelectedProfile.aDS.Color.R = Colors[2].R; SelectedProfile.aDS.Color.G = Colors[2].G; SelectedProfile.aDS.Color.B = Colors[2].B; SelectedProfile.aDS.Color.A = Colors[2].A;
SelectedProfile.aDS.OutlineColor.R = Colors[3].R; SelectedProfile.aDS.OutlineColor.G = Colors[3].G; SelectedProfile.aDS.OutlineColor.B = Colors[3].B; SelectedProfile.aDS.OutlineColor.A = Colors[3].A;
SelectedProfile.Sniper.CenterDotColor.R = Colors[4].R; SelectedProfile.Sniper.CenterDotColor.G = Colors[4].G; SelectedProfile.Sniper.CenterDotColor.B = Colors[4].B; SelectedProfile.Sniper.CenterDotColor.A = Colors[4].A;
}
return UserSettings;
}
}
}
Loading

0 comments on commit 3b3ccaf

Please # to comment.