using System; using System.Net; using System.Windows; using System.Threading; using System.Diagnostics; using System.Windows.Media; using System.Windows.Controls; using System.Windows.Input; using System.IO; namespace Launcher { public partial class UserWindow : Window { private WebClient ServerClient = new WebClient(); public UserWindow() { InitializeComponent(); } private void Window_Initialized(Object Sender, EventArgs Args) { Title = String.Format("{0} - User Control Panel", App.LauncherTitle); ID.Content = App.ID; Username.Content = App.Username; if (App.MallPoints != -1) { MallPoints.Content = App.MallPoints; } else { MallPoints.Content = 0; } String ServerCount = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=InformationRequest&ServerID={1}&InformationType=ServerCount", App.ServerIP, 0)); for (Byte ServerID = 1; ServerID < Convert.ToByte(ServerCount) + 1; ServerID++) { Servers.Items.Add(ServerClient.DownloadString(String.Format("http://{0}:10002?Type=InformationRequest&ServerID={1}&InformationType=ServerName", App.ServerIP, ServerID))); } String RebirthablesIDsString = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=Rebirth&Username={1}&Password={2}&RType=LEC", App.ServerIP, App.Username, App.Password)); if (RebirthablesIDsString != String.Empty) { String[] RebirthablesIDs = RebirthablesIDsString.Split('#'); foreach (String RebirthablesID in RebirthablesIDs) { Rebirth_sIDs.Items.Add(RebirthablesID); } Rebirth_sIDs.SelectedIndex = 0; } else { Rebirth_Back.Visibility = Visibility.Hidden; Rebirth_Panel.Visibility = Visibility.Hidden; Rebirth_Character1.Visibility = Visibility.Hidden; Rebirth_Character2.Visibility = Visibility.Hidden; } String UnstucksIDsString = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=Unstuck&Username={1}&Password={2}&UType=LUC", App.ServerIP, App.Username, App.Password)); if (UnstucksIDsString != String.Empty) { String[] UnstucksIDs = UnstucksIDsString.Split('#'); foreach (String UnstucksID in UnstucksIDs) { Unstuck_sIDs.Items.Add(UnstucksID); } Unstuck_sIDs.SelectedIndex = 0; } else { Unstuck_sIDs.IsEnabled = false; Unstuck_Go.IsEnabled = false; } Servers.SelectedIndex = 0; Servers_SelectionChanged(null, null); if (!File.Exists(String.Format("{0}Launcher\\NoBackground.txt", AppDomain.CurrentDomain.BaseDirectory))) { Video.Source = new Uri(String.Format("{0}Video.mp4", AppDomain.CurrentDomain.BaseDirectory)); Video.Play(); } } private void Video_MediaEnded(Object Sender, RoutedEventArgs Args) { Video.Position = TimeSpan.Zero; Video.Play(); } private void DonateSR_Click(Object Sender, RoutedEventArgs Args) { String DonationURL = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=InformationRequest&ServerID={1}&InformationType=Donate", App.ServerIP, 0)); Process.Start(String.Format(DonationURL, App.ID)); } private void UpdatePassword_Click(Object Sender, RoutedEventArgs Args) { if (UP_OPassword.Password == String.Empty || UP_NPassword.Password == String.Empty || UP_NRePassword.Password == String.Empty) { MessageBox.Show("Please fill in the boxes with the correct information.", String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); return; } UP_OPassword.IsEnabled = false; UP_NPassword.IsEnabled = false; UP_NRePassword.IsEnabled = false; Play.IsEnabled = false; if (UP_OPassword.Password != App.Password) { MessageBox.Show("Old password doesnt match your account."); } else if (UP_NPassword.Password == UP_NRePassword.Password) { String Response = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=PasswordChange&Username={1}&OldPassword={2}&NewPassword={3}", App.ServerIP, App.Username, App.Password, UP_NPassword.Password)); if (!Response.StartsWith("Success")) { MessageBox.Show(Response, String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } else { String[] ResponseSplit = Response.Split('#'); App.Password = UP_NPassword.Password; MessageBox.Show(ResponseSplit[1], String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } } else { MessageBox.Show("Your password & re-password do not match.", String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } UP_OPassword.IsEnabled = true; UP_NPassword.IsEnabled = true; UP_NRePassword.IsEnabled = true; Play.IsEnabled = true; } private void Servers_SelectionChanged(Object Sender, SelectionChangedEventArgs Args) { Boolean IsEnabled = Convert.ToBoolean(ServerClient.DownloadString(String.Format("http://{0}:10002?Type=MaintenanceStatus&ServerID={1}&Username={2}", App.ServerIP, Servers.SelectedIndex + 1, App.Username))); Play.IsEnabled = IsEnabled; if (!IsEnabled) { Status.Foreground = new SolidColorBrush(Colors.Red); Status.Content = "Maintenance"; } else { Status.Foreground = new SolidColorBrush(Colors.Green); Status.Content = "Online"; } } private void Refresh_Click(Object Sender, RoutedEventArgs Args) { Servers_SelectionChanged(null, null); } private void Play_Click(Object Sender, RoutedEventArgs Args) { String Response = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=PasswordStatus&Username={1}&Password={2}", App.ServerIP, App.Username, App.Password)); if (Convert.ToBoolean(Response.Split('#')[0])) { MessageBox.Show(Response.Split('#')[1], String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } else { Byte ServerID = Convert.ToByte(Servers.SelectedIndex + 1); PatchWindow PW = new PatchWindow(ServerID); PW.Show(); Dispatcher.BeginInvoke((Action)(() => { Close(); })); } } private void Patches_Click(Object Sender, RoutedEventArgs Args) { Hide(); PatchLogWindow PLW = new PatchLogWindow(Convert.ToByte(Servers.SelectedIndex + 1)); PLW.ShowDialog(); Dispatcher.BeginInvoke((Action)(() => { Show(); })); } private void Close_Click(Object Sender, RoutedEventArgs Args) { Process.GetCurrentProcess().Kill(); } private void ShowPassword_Click(Object Sender, RoutedEventArgs Args) { if (Convert.ToString(Password.Content) == "***") { Password.Content = App.Password; } else { Password.Content = "***"; } } private void UP_OPassword_PasswordChanged(Object Sender, RoutedEventArgs Args) { if (UP_OPassword.Password.Length >= 1) { UP_OPasswordB.Content = ""; } else { UP_OPasswordB.Content = "Password"; } } private void UP_NPassword_PasswordChanged(Object Sender, RoutedEventArgs Args) { if (UP_NPassword.Password.Length >= 1) { UP_NPasswordB.Content = ""; } else { UP_NPasswordB.Content = "Password"; } } private void UP_NRePassword_PasswordChanged(Object Sender, RoutedEventArgs Args) { if (UP_NRePassword.Password.Length >= 1) { UP_NRePasswordB.Content = ""; } else { UP_NRePasswordB.Content = "Password"; } } private void Rebirth_Go_Click(Object Sender, RoutedEventArgs Args) { String Response = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=Rebirth&Username={1}&Password={2}&RType=RC&Name={3}", App.ServerIP, App.Username, App.Password, Rebirth_sIDs.SelectedItem)); if (!Response.StartsWith("Success")) { MessageBox.Show(Response, String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } else { MessageBox.Show(Response.Split('#')[1], String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } } private void CookieClicker_MouseLeftButtonUp(Object Sender, MouseButtonEventArgs Args) { Cookie_Total.Content = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=ClickCookie&Username={1}&Password={2}", App.ServerIP, App.Username, App.Password)); } private void Repatch_Click(Object Sender, RoutedEventArgs Args) { String VersionFile = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=InformationRequest&ServerID={1}&InformationType=VersionFile", App.ServerIP, Servers.SelectedIndex + 1)); File.Delete(String.Format("{0}Launcher\\{1}", AppDomain.CurrentDomain.BaseDirectory, VersionFile)); MessageBox.Show(String.Format("Your launcher will install from patch 0 on server {0}, when you press play! C:", App.LauncherTitle), String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } private void GC_Username_TextChanged(Object Sender, TextChangedEventArgs Args) { if (GC_Username.Text.Length >= 1) { GC_UsernameB.Content = ""; } else { GC_UsernameB.Content = "Username"; } } private void GC_Amount_TextChanged(Object Sender, TextChangedEventArgs Args) { if (GC_Amount.Text.Length >= 1) { GC_AmountB.Content = ""; } else { GC_AmountB.Content = "Amount"; } } private void GC_Give_Click(Object Sender, RoutedEventArgs Args) { Boolean AmountIsInt = false; try { Int32.Parse(GC_Amount.Text); AmountIsInt = true; } catch { MessageBox.Show("Please enter a correct number in the amount part.", String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } if (AmountIsInt) { String Response = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=GiveCoins&Username={1}&Password={2}&GiveUsername={3}&Amount={4}", App.ServerIP, App.Username, App.Password, GC_Username.Text, GC_Amount.Text)); if (!Response.StartsWith("Success")) { MessageBox.Show(Response, String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } else { App.MallPoints = Convert.ToInt64(Response.Split('#')[1]); MallPoints.Content = App.MallPoints; MessageBox.Show(Response.Split('#')[2], String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } } } private void DonatePSC_Click(Object Sender, RoutedEventArgs Args) { PSCWindow PSCW = new PSCWindow(); PSCW.Show(); } private void Unstuck_Go_Click(Object Sender, RoutedEventArgs Args) { String Response = ServerClient.DownloadString(String.Format("http://{0}:10002?Type=Unstuck&Username={1}&Password={2}&UType=UC&Name={3}", App.ServerIP, App.Username, App.Password, Rebirth_sIDs.SelectedItem)); if (!Response.StartsWith("Success")) { MessageBox.Show(Response, String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } else { MessageBox.Show(Response.Split('#')[1], String.Format("{0} Launcher", App.LauncherTitle), MessageBoxButton.OK); } } } }