diff --git a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/Bobocraft 2 Launcher.csproj b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/Bobocraft 2 Launcher.csproj index 17a04b1..11777d9 100644 --- a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/Bobocraft 2 Launcher.csproj +++ b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/Bobocraft 2 Launcher.csproj @@ -15,9 +15,14 @@ <None Remove="images\LauncherBackground.png" /> <None Remove="LauncherBackground.png" /> <None Remove="shape_square.png" /> + <None Remove="user-1808597_1280.png" /> <None Remove="vector_dizzy.png" /> </ItemGroup> + <ItemGroup> + <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> + </ItemGroup> + <ItemGroup> <Resource Include="avatar.png" /> <Resource Include="bobocraft 2 logo vector.png" /> @@ -26,6 +31,7 @@ <Resource Include="images\LauncherBackground.png" /> <Resource Include="LauncherBackground.png" /> <Resource Include="shape_square.png" /> + <Resource Include="user-1808597_1280.png" /> <Resource Include="vector_dizzy.png" /> </ItemGroup> diff --git a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml index 7abf7a0..13f3445 100644 --- a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml +++ b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml @@ -43,5 +43,14 @@ </Button> <TextBlock x:Name="CountdownHeadline" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="10" Background="#7F000000" Foreground="White" Margin="0,50,0,0" Text="Time Until Next Scheduled Bobo Session:"/> <Label Name="CountdownLabel" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,70,0,0" Height="30" Width="235" Foreground="White" Background="#7F000000"/> + <Image Name="OnlineUserpfp" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="62,57,0,0" Height="40" Width="40" Source="/user-1808597_1280.png"/> + <TextBlock x:Name="CraftersOnlineText" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="10" Background="#7F000000" Foreground="LightGreen" Margin="15,105,0,0" Text="Crafters Online Now!"/> + <TextBlock x:Name="CraftersOnlineNumber" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="30" Background="#7F000000" Foreground="LightGreen" Margin="21,57,0,0" Text="0"/> + <Button Name ="DiscordButtonLFP" BorderThickness="0" Click ="DiscordButton_ClickLFP" Background="#00000000" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,102,316,0" Height="20" Width="23" RenderTransformOrigin="-1.39,1.253"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Width="20" Height="20"> + <Image Source="/discord-mark-blue.png" HorizontalAlignment="Left" VerticalAlignment="Center" Width="20" Height="20" /> + </StackPanel> + </Button> + <TextBlock x:Name="CountdownTailline" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="10" Background="#7F000000" Foreground="White" Margin="0,105,0,0" Text="Want To Play Now? Ask In The 'looking-for-players' Channel If Anyone Wants To Join!"/> </Grid> </Window> diff --git a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml.cs b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml.cs index 4d3b24e..bc1f75d 100644 --- a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml.cs +++ b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/MainWindow.xaml.cs @@ -12,6 +12,10 @@ using System.Windows.Controls; using System.Windows.Input; using System.Timers; using System.Globalization; +using System.Text.Json; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Windows.Media; namespace GameLauncher { @@ -61,7 +65,11 @@ namespace GameLauncher private string NextSessionString; private string NextSessionFile; private string NextSessionFileLink; - + private string NorbiServerInfoLink; + private string ServerInfoJson; + private string ServerInfoString; + private int PlayerCount; + private LauncherStatus _status; internal LauncherStatus Status @@ -140,7 +148,10 @@ namespace GameLauncher CRF2ManagerZipLink = "https://drive.usercontent.google.com/u/0/uc?id=1ah4QN3HOj2nsCsHKxRkyTI_eKJIK3atb&export=download"; CSCZipLink = "https://cloud.norbipeti.eu/s/6dTzZyAbyXRwHc9/download/Connection%20Health%20Calculator.zip"; NextSessionFileLink = "https://drive.google.com/uc?export=download&id=1lMctvUExhyjw8FRrpiCKmfVnqNQMI7U7"; + NorbiServerInfoLink = "https://norbipeti.eu/rc2matchmaking/servers"; + PlayerCount = 0; SetupTimer(); + CheckPlayerCount(); } private void SetupTimer() @@ -163,6 +174,7 @@ namespace GameLauncher CountdownLabel.Content = "ROBOCRAFT SESSION TODAY!"; } else { CountdownLabel.Content = $"{timeLeft.Days} days {timeLeft.Hours} hours {timeLeft.Minutes} minutes {timeLeft.Seconds} seconds"; } + CheckPlayerCount(); }); } private void PullSessionTimeFromLink() @@ -308,6 +320,52 @@ namespace GameLauncher } + private void CheckPlayerCount() + { + try + { + WebClient webClient = new WebClient(); + webClient.Headers.Add("Authorization", "TlBDQVRSQzI="); + ServerInfoJson = webClient.DownloadString(NorbiServerInfoLink); + JArray _ServerArray = new JArray(); + _ServerArray = JArray.Parse(ServerInfoJson); + PlayerCount = 0; + for(int i = 0; i < _ServerArray.Count; i++) + { + var server = _ServerArray[i]; + var onlinePlayers = server["onlinePlayers"]; + int PlayersInt = 0; + int.TryParse(onlinePlayers.ToString(), out PlayersInt); + PlayerCount += PlayersInt; + } + if (PlayerCount > 0) + { + CraftersOnlineNumber.Text = PlayerCount.ToString(); + //CraftersOnlineNumber.Foreground = new SolidColorBrush(Colors.LightGreen); + CraftersOnlineNumber.Visibility = Visibility.Visible; + CraftersOnlineText.Visibility = Visibility.Visible; + OnlineUserpfp.Visibility = Visibility.Visible; + } + else + { + CraftersOnlineNumber.Visibility = Visibility.Hidden; + CraftersOnlineText.Visibility = Visibility.Hidden; + OnlineUserpfp.Visibility = Visibility.Hidden; + } + + } + catch (Exception ex) + { + Status = LauncherStatus.failed; + MessageBox.Show($"Error checking for server info: {ex}"); + } + } + + + + + + private void CheckForCRFManagerUpdates() { @@ -581,6 +639,15 @@ namespace GameLauncher }); } + private void DiscordButton_ClickLFP(object sender, RoutedEventArgs e) + { + Process.Start(new ProcessStartInfo() + { + FileName = "https://discord.gg/4szuSwTURA", + UseShellExecute = true + }); + } + private void FAQButton_Click(object sender, RoutedEventArgs e) { if (FAQFullText.Visibility == Visibility.Visible) { FAQFullText.Visibility = Visibility.Hidden; } diff --git a/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/user-1808597_1280.png b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/user-1808597_1280.png new file mode 100644 index 0000000..6d0c3e7 Binary files /dev/null and b/Bobocraft 2 Launcher v11 actually fixed countdown/GameLauncher/user-1808597_1280.png differ