Skip to content

Commit

Permalink
Fixes and stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Feb 12, 2022
1 parent 362a00d commit 3ff4ad8
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 87 deletions.
10 changes: 5 additions & 5 deletions ValorantCC/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@
<TextBlock Margin="2,2,2,2" FontWeight="Bold" Grid.Row="4" Grid.Column="0" Foreground="White" FontFamily="Segoe UI Semibold"><Run Text="Sniper Dot Color"/></TextBlock>
<xctk:ColorPicker x:Name="sniper_dot_color" Grid.Row="4" Grid.Column="1" SelectedColorChanged="sniper_dot_color_SelectedColorChanged" UsingAlphaChannel="False" AdvancedTabHeader="Manual" Margin="10,0,4,0" Cursor="Hand" OpacityMask="#FFB82525" Height="23.96" VerticalAlignment="Center" Background="{x:Null}" DisplayColorAndName="True" BorderBrush="#FFDADADA" Foreground="White" HeaderBackground="#FF252526" HeaderForeground="White" TabBackground="#FF252526" TabForeground="#FFFBF9F9" DropDownBorderBrush="#FF252526" DropDownBackground="#FF252526" ShowStandardColors="False"/>
</Grid>
<Border Width="auto" Height="18" Background="#FF44464F" Margin="-2,2,-2,2">
<TextBlock FontWeight="Bold" Margin="6,0,2,2" Foreground="White" FontFamily="Segoe UI Semibold">
<Run Text="Message:"/>
<Run Foreground="Yellow" Text="Waiting for Valorant or Riot Client. . ." FontSize="10" Name="MessageTxt"/>
</TextBlock>
<Border Width="auto" MinHeight="18" Background="#FF44464F" Margin="-2,2,-2,2">
<DockPanel>
<TextBlock FontWeight="Bold" Margin="6,0,2,2" Foreground="White" FontFamily="Segoe UI Semibold" FontSize="10" Text="Message: "/>
<TextBlock FontWeight="Bold" Margin="0,0,2,2" Foreground="Yellow" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" Name="MessageTxt" FontSize="10" Text="Waiting for Valorant or Riot Client. . ."/>
</DockPanel>
</Border>
</StackPanel>
</UserControl>
Expand Down
35 changes: 21 additions & 14 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using Utilities;
Expand Down Expand Up @@ -68,7 +69,7 @@ private async void btnSave_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
MessageTxt.Text = "You are not logged in!";
Utils.MessageText("You are not logged in!", Brushes.Red);
return;
}
if (DataProcessor.ProfileListed)
Expand All @@ -84,12 +85,11 @@ private async void btnSave_Click(object sender, RoutedEventArgs e)
await DataProcessor.Construct();
profiles.Items.Refresh();
profiles.SelectedIndex = DataProcessor.CurrentProfile;
MessageTxt.Foreground = Brushes.Lime;
MessageTxt.Text = "Saved! Restart Valorant.";
Utils.MessageText("Saved! Restart Valorant.", Brushes.Lime);
return;
}
MessageTxt.Foreground = Brushes.Red;
MessageTxt.Text = "Failed. Consult developer.";
Utils.MessageText("Failed. Consult developer.", Brushes.Red);

return;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ private async void btnReload_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
MessageTxt.Text = "You are not logged in!";
Utils.MessageText("You are not logged in!", Brushes.Red);
return;
}
Utils.Log("Reload Clicked > Reconstructing Processor.");
Expand Down Expand Up @@ -276,8 +276,7 @@ private void btnOpenLogs_Click(object sender, RoutedEventArgs e)
Process p = new Process();
p.StartInfo = new ProcessStartInfo() { FileName = Path.GetDirectoryName(Utils.LoggingFile), UseShellExecute = true };
p.Start();
MessageTxt.Foreground = Brushes.Lime;
MessageTxt.Text = "Log folder opened! Please include OLD files to your report if exists.";
Utils.MessageText("Log folder opened! Please include OLD files to your report if exists.", Brushes.Lime);
}

private void next_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -306,7 +305,7 @@ private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
MessageTxt.Text = "You are not logged in!";
Utils.MessageText("You are not logged in !", Brushes.Red);
return;
}
try
Expand All @@ -326,23 +325,31 @@ private void chkbxShareable_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
MessageTxt.Text = "You are not logged in!";
Utils.MessageText("You are not logged in !", Brushes.Red);
((CheckBox)sender).IsChecked = !((CheckBox)sender).IsChecked;
return;
}
}

private void btnShare_Click(object sender, RoutedEventArgs e)
private async void btnShare_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
MessageTxt.Text = "You are not logged in!";
Utils.MessageText("You are not logged in !", Brushes.Red);
return;
}
MessageTxt.Text = "Your profile has been saved! Make sure you have the 'shareable' checkbox checked!";
exitButton.Visibility = Visibility.Collapsed;
Utils.MessageText("Your profile is being saved...", Brushes.Yellow);

ValCCAPI.Shareable = (bool)chkbxShareable.IsChecked;
ValCCAPI.profile = SelectedProfile;
_ = ValCCAPI.Set();
SetCallResponse response = await ValCCAPI.Set();
String sharecode = response.data.shareCode;
Clipboard.SetText(sharecode);
MessageWindow.Show($"Your sharecode is: \"{sharecode}\" and is copied.\nIf you want this profile accessible across the community,\nPlease be sure that you have the 'shareable' checkbox checked.", "Profile shared!");

Utils.MessageText("Your profile has been saved. It can now be browsed if \"shareable\" checkbox is checked before saving.", Brushes.Lime);
exitButton.Visibility = Visibility.Visible;
}
}
}
15 changes: 10 additions & 5 deletions ValorantCC/SubWindow/MessageWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ValorantCC.SubWindow"
mc:Ignorable="d"
Title="MessageWindow" Width="350" Background="#FF232429" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" WindowStyle="None" WindowStartupLocation="CenterOwner" SizeToContent="Height" ResizeMode="NoResize" ShowInTaskbar="False">
<Border BorderBrush="White" BorderThickness="1" Padding="0,10,0,10">
<StackPanel VerticalAlignment="Center">
<TextBox x:Name="Messagetxtbox" TextWrapping="Wrap" Text="Here goes the text to be displayed" Width="Auto" Height="Auto" Foreground="White" FontSize="14" HorizontalContentAlignment="Left" Background="#FF232429" VerticalContentAlignment="Center" BorderThickness="0" Padding="10,0,10,0"/>
<Button x:Name="OKbtn" Style="{DynamicResource RoundButton}" Content="OK" Cursor="Hand" Height="22" Width="84" Background="#FF295FFE" FontFamily="Quicksand" FontSize="14" FontWeight="DemiBold" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold" Margin="0,10,0,0" Click="OKbtn_Click"/>
Title="MessageWindow" Width="350" Background="#FF232429" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" WindowStyle="None" WindowStartupLocation="CenterOwner" SizeToContent="WidthAndHeight" ResizeMode="NoResize" ShowInTaskbar="False">
<Border BorderBrush="White" BorderThickness="1 0.5 1 1">
<StackPanel>
<Label x:Name="TitleBar" Content="Title" Foreground="White" Padding="5,0,0,0" Focusable="False" FontSize="14"/>
<Border BorderBrush="White" BorderThickness="0 0.5 0 0" Padding="0,10,0,10">
<StackPanel VerticalAlignment="Center">
<TextBlock x:Name="Messagetxtbox" TextWrapping="Wrap" Text="Here goes the text to be displayed" Width="Auto" Height="Auto" Foreground="White" FontSize="14" HorizontalAlignment="Left" Background="#FF232429" VerticalAlignment="Center" Padding="10,0,10,0"/>
<Button x:Name="OKbtn" Style="{DynamicResource RoundButton}" Content="OK" Cursor="Hand" Height="22" Width="84" Background="#FF295FFE" FontFamily="Quicksand" FontSize="14" FontWeight="DemiBold" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold" Margin="0,10,0,0" Click="OKbtn_Click"/>
</StackPanel>
</Border>
</StackPanel>
</Border>
</Window>
7 changes: 4 additions & 3 deletions ValorantCC/SubWindow/MessageWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ namespace ValorantCC.SubWindow
/// </summary>
public partial class MessageWindow : Window
{
public static void Show(string Message)
public static void Show(string Message, string Title = null)
{
MessageWindow MessageWin = new(Message);
MessageWindow MessageWin = new(Message, Title);
MessageWin.Owner = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
MessageWin.ShowDialog();
}

public MessageWindow(string Message)
public MessageWindow(string Message, string Title = null)
{
InitializeComponent();
TitleBar.Content = Title;
Messagetxtbox.Text = Message;
Messagetxtbox.Focusable = false;
OKbtn.Focus();
Expand Down
4 changes: 2 additions & 2 deletions ValorantCC/SubWindow/ProfilesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mc:Ignorable="d"
Title="ProfilesWindow" RenderOptions.BitmapScalingMode="Fant" Background="Transparent" AllowsTransparency="True" Height="481" Width="339" ResizeMode="NoResize" SizeToContent="WidthAndHeight" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" WindowStyle="None">

<Border BorderThickness="0" CornerRadius="7" Background="#232429" Height="450" Loaded="Border_Loaded" Margin="0,15,0,15">
<Border BorderThickness="0" CornerRadius="7" Background="#232429" Height="450" Margin="0,15,0,15">
<Grid>
<Border BorderThickness="0" BorderBrush="Transparent" Background ="#16171B" Margin="0,-2,-1,425" CornerRadius="7,5,0,0" MouseDown="Border_MouseDown">
<Grid Height="Auto" Width="Auto" Margin="0,0,1,-2" OpacityMask="#FFA42727">
Expand All @@ -32,7 +32,7 @@
<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="388" Width="338">

<StackPanel Name="ShareablesContainer" HorizontalAlignment="Center">
<StackPanel Name="ShareablesContainer" HorizontalAlignment="Center" Loaded="ShareablesContainer_Loaded">
</StackPanel>
</ScrollViewer>
</StackPanel>
Expand Down
7 changes: 4 additions & 3 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
ValCCApi = ValCCAPI;
}

private async void Border_Loaded(object sender, RoutedEventArgs e)
private async void ShareablesContainer_Loaded(object sender, RoutedEventArgs e)
{
LoadingPlaceHolder.Visibility = Visibility.Visible;
await InitialFetch();
Expand All @@ -51,10 +51,11 @@ private async void Border_Loaded(object sender, RoutedEventArgs e)
/// <param name="sharecode">Nullable. Searched Code</param>
private async Task<bool> InitialFetch(String sharecode = null)
{
btnSearchCode.IsEnabled = false;
PublicProfiles.Clear();
ShareablesContainer.Children.Clear();
List<ShareableProfile> Shareables;
if (!string.IsNullOrEmpty(sharecode) || !string.IsNullOrWhiteSpace(sharecode))
if (!string.IsNullOrWhiteSpace(sharecode))
{
ValCCApi.Action = 3;
Shareables = (await ValCCApi.Fetch(sharecode)).data;
Expand All @@ -63,7 +64,6 @@ private async Task<bool> InitialFetch(String sharecode = null)
{
ValCCApi.Action = 2;
Shareables = (await ValCCApi.Fetch()).data;

}

if (Shareables.Count == 0) return true;
Expand All @@ -81,6 +81,7 @@ private async Task<bool> InitialFetch(String sharecode = null)
}
PublicProfiles.Add(new PublicProfile() { owner = currentShareable.displayName, settings = profile, sharecode = currentShareable.shareCode, ID = i });
}
btnSearchCode.IsEnabled = true;
return true;
}

Expand Down
19 changes: 14 additions & 5 deletions ValorantCC/src/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@

namespace ValorantCC
{
public struct VoidCallResponse
public struct SetCallResponse
{
public bool success { get; set; }
public Object data { get; set; }
public SetResponse data { get; set; }
}

public struct SetResponse
{
public string settings { get; set; }
public string displayName { get; set; }
public string gameTag { get; set; }
public string shareCode { get; set; }
public bool shareable { get; set; }
}

public struct FetchResponse
Expand Down Expand Up @@ -72,7 +81,7 @@ public async Task<FetchResponse> Fetch(String sharecode = null)
return JsonConvert.DeserializeObject<FetchResponse>(response.Content);
}

public async Task<VoidCallResponse> Set()
public async Task<SetCallResponse> Set()
{
PostPayload payload = new PostPayload()
{
Expand All @@ -86,8 +95,8 @@ public async Task<VoidCallResponse> Set()
request.AddJsonBody(payload);
request.AddOrUpdateHeader("Authorization", $"Bearer {AuthTokens.AccessToken}"); // Pass to server so nobody can set somebody's saved profile.
RestResponse response = await client.ExecuteAsync(request);
if (!response.IsSuccessful) return new VoidCallResponse() { success = false };
return JsonConvert.DeserializeObject<VoidCallResponse>(response.Content);
if (!response.IsSuccessful) return new SetCallResponse() { success = false };
return JsonConvert.DeserializeObject<SetCallResponse>(response.Content);
}

}
Expand Down
3 changes: 1 addition & 2 deletions ValorantCC/src/BackgroundAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public async void LoopCheck()

main.DotTxt.Foreground = Brushes.Lime;
main.StatusTxt.Foreground = Brushes.Lime;
main.MessageTxt.Foreground = Brushes.Lime;
main.MessageTxt.Text = Utils.LoginResponse(processor);
Utils.MessageText(Utils.LoginResponse(processor), Brushes.Lime);
main.StatusTxt.Text = "Logged In!";

main.ch_display.Visibility = Visibility.Visible;
Expand Down
14 changes: 7 additions & 7 deletions ValorantCC/src/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public partial class ProfileList

public partial class Data
{
public Actionmapping[] actionMappings { get; set; }
public object[] axisMappings { get; set; }
public Boolsetting[] boolSettings { get; set; }
public Floatsetting[] floatSettings { get; set; }
public Intsetting[] intSettings { get; set; }
public List<Actionmapping> actionMappings { get; set; }
public List<object> axisMappings { get; set; }
public List<Boolsetting> boolSettings { get; set; }
public List<Floatsetting> floatSettings { get; set; }
public List<Intsetting> intSettings { get; set; }
public int roamingSetttingsVersion { get; set; }
public Stringsetting[] stringSettings { get; set; }
public string[] settingsProfiles { get; set; }
public List<Stringsetting> stringSettings { get; set; }
public List<string> settingsProfiles { get; set; }
}

}
Loading

0 comments on commit 3ff4ad8

Please # to comment.