public static String cars() { if (Access.sHttp.request.HttpMethod == "POST") { if (Access.CurrentSession.ActivePersona.Cars.Count > 1) { Int32 carId = Int32.Parse(Access.sHttp.request.Params.Get("serialNumber")); Car curCar = Access.CurrentSession.ActivePersona.Cars.First(c => c.Id == carId); Int32 curCarIndex = Access.CurrentSession.ActivePersona.Cars.IndexOf(curCar); Economy economy = Economy.defineManually(new Economy.ProductInformation() { currency = Basket.Currency.Cash, price = curCar.ResalePrice }, 1); economy.doIncrement(); PersonaManagement.removeCar(curCar); Int32 newIndex; if (Access.CurrentSession.ActivePersona.Cars.Count <= curCarIndex) { newIndex = Access.CurrentSession.ActivePersona.Cars.Count - 1; } else { newIndex = curCarIndex; } Access.CurrentSession.ActivePersona.CurrentCarIndex = newIndex; return(Access.CurrentSession.ActivePersona.SelectedCar.getOwnedCarTrans().SerializeObject()); } } else if (Access.sHttp.request.HttpMethod == "PUT") { // TODO: Make performance parts use economy -> attribHash Car curCar = Access.CurrentSession.ActivePersona.Cars[Access.CurrentSession.ActivePersona.CurrentCarIndex]; OwnedCarTrans newCar = Access.sHttp.getPostData().DeserializeObject <OwnedCarTrans>(); curCar.PerformanceParts = XElement.Parse(newCar.customCar.performanceParts.SerializeObject()); return(curCar.getOwnedCarTrans().SerializeObject()); } return(""); }
private async void button_ClickHandler(object sender, RoutedEventArgs e) { switch ((sender as Button).Name) { case "buttonOpenBasicPersonaInfo": flyoutBasicPersonaInfo.IsOpen = !flyoutBasicPersonaInfo.IsOpen; break; case "buttonOpenDetailedPersonaInfo": flyoutDetailedPersonaInfo.IsOpen = !flyoutDetailedPersonaInfo.IsOpen; break; case "buttonOpenPersonaList": flyoutPersonaList.IsOpen = !flyoutPersonaList.IsOpen; break; case "buttonUpdatePersonaInfoTile": RandomPersonaInfo.Stop(); tRandomPersonaInfo_Tick(null, null); RandomPersonaInfo.Start(); break; case "buttonPaints": case "buttonPerformanceParts": case "buttonSkillModParts": case "buttonVinyls": case "buttonVisualParts": tbGaragePartInfo.SetBinding(MVVMSyntax._TextProperty, new Binding() { Converter = new STEditConverter(this), Path = new PropertyPath("ActivePersona.SelectedCar." + ((sender as Button).Name).Remove(0, 6)), UpdateSourceTrigger = UpdateSourceTrigger.LostFocus, Mode = BindingMode.TwoWay, Source = Access.CurrentSession }); flyoutGaragePartInfo.IsOpen = !flyoutGaragePartInfo.IsOpen; break; case "buttonAddCar": buttonAddCar.IsEnabled = false; await this.ShowMetroDialogAsync(carDialog, new MetroDialogSettings() { AnimateHide = true, AnimateShow = true }); buttonAddCar.IsEnabled = true; break; case "buttonRemoveCar": if (listCar.Items.Count > 1) { Int32 selectedItemIndex = listCar.SelectedIndex; if (selectedItemIndex != -1) { PersonaManagement.removeCar((Car)listCar.Items[selectedItemIndex]); } else { new ToolTip() { Content = Access.dataAccess.appSettings.uiSettings.language.RemoveCarNoSelectedCarError, StaysOpen = false, IsOpen = true }; } } else { new ToolTip() { Content = Access.dataAccess.appSettings.uiSettings.language.RemoveCarLastCarError, StaysOpen = false, IsOpen = true }; } break; case "buttonSettings": flyoutSettings.IsOpen = !flyoutSettings.IsOpen; break; case "buttonBackground": { OpenFileDialog backgroundDialog = new OpenFileDialog() { CheckFileExists = true, CheckPathExists = true, DefaultExt = ".png", Filter = "Image files (*.jpg, *.jpeg, *.png) | *.jpg; *.jpeg; *.png", AddExtension = true, Multiselect = false, Title = "Please select an image" }; if (backgroundDialog.ShowDialog() == true) { String selectedBackground = backgroundDialog.FileName; if (File.Exists(selectedBackground)) { Access.dataAccess.appSettings.uiSettings.style.Background = selectedBackground; } } } break; case "buttonResetBackground": { Access.dataAccess.appSettings.uiSettings.style.Background = null; } break; case "buttonAddonManager": if (!AddonManagerTalk.isAddonManagerRunning && AddonManagerTalk.isWaitingForClient) { String addonManagerLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AddonManager.exe"); if (!File.Exists(addonManagerLocation)) { await this.ShowMessageAsync(Access.dataAccess.appSettings.uiSettings.language.InformUserInformation, Access.dataAccess.appSettings.uiSettings.language.AddonManagerNotFoundError); return; } Access.addonManagerTalk.initialize(); String args = String.Format("/catalogs '{0}' /baskets '{1}' /gameplay '{2}' /accents '{3}' /themes '{4}' /languages '{5}' /logs '{6}' /offlineServer {7}", Path.GetFullPath(DataEx.dir_HttpServerCatalogs), Path.GetFullPath(DataEx.dir_HttpServerBaskets), Path.GetFullPath(DataEx.dir_GameplayMods), Path.GetFullPath(DataEx.dir_Accents), Path.GetFullPath(DataEx.dir_Themes), Path.GetFullPath(DataEx.dir_Languages), Path.GetFullPath(DataEx.dir_Logs), Access.addonManagerTalk.port); Process.Start(addonManagerLocation, args); } break; } }
private void SetupComponents() { #region FlipViewPersona Image[] aFlipViewAvatarArray = new Image[28]; for (int i = 0; i < 28; i++) { ImageSource source = BitmapFrame.Create( new Uri("pack://application:,,,/OfflineServer;component/images/NFSW_Avatars/Avatar_" + i.ToString() + ".png", UriKind.Absolute), BitmapCreateOptions.DelayCreation, BitmapCacheOption.OnDemand); source.Freeze(); Image avatarImage = new Image() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Source = source }; aFlipViewAvatarArray[i] = avatarImage; } FlipViewPersonaImage.ItemsSource = aFlipViewAvatarArray; Binding indexBind = new Binding() { Path = new PropertyPath("ActivePersona.IconIndex"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay, Delay = 1000, Source = Access.CurrentSession }; BindingOperations.SetBinding(FlipViewPersonaImage, FlipView.SelectedIndexProperty, indexBind); #endregion #region MetroTile -> Random Persona Info tRandomPersonaInfo_Tick(null, null); RandomPersonaInfo.Tick += new EventHandler(tRandomPersonaInfo_Tick); RandomPersonaInfo.Interval = new TimeSpan(0, 0, 10); RandomPersonaInfo.Start(); #endregion #region carDialog Binding lBindSelect = new Binding() { Path = new PropertyPath("language.Select"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; Binding lBindCancel = new Binding() { Path = new PropertyPath("language.Cancel"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; Binding lBindSelectCar = new Binding() { Path = new PropertyPath("language.AddACarText"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; ComboBox carComboBox = new ComboBox(); carComboBox.SetValue(Canvas.LeftProperty, 5d); carComboBox.SetValue(Canvas.TopProperty, 20d); carComboBox.Width = 297d; carComboBox.ItemsSource = CarDefinitions.physicsProfileHashNormal.Values; carComboBox.SelectedIndex = 0; Button selectButton = new Button(); selectButton.SetValue(Canvas.LeftProperty, 148d); selectButton.SetValue(Canvas.TopProperty, 54d); selectButton.Width = 80d; selectButton.Click += (object sender, RoutedEventArgs routedEventArgs) => { selectButton.IsEnabled = false; CarEntity carEntity = new CarEntity(); carEntity.baseCarId = CarDefinitions.baseCarId.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key; carEntity.carClassHash = CarClass.getHashFromCarClass("E"); carEntity.durability = 100; carEntity.heatLevel = 1; carEntity.paints = new List <CustomPaintTrans>().SerializeObject(); carEntity.performanceParts = new List <PerformancePartTrans>().SerializeObject(); carEntity.physicsProfileHash = CarDefinitions.physicsProfileHashNormal.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key; carEntity.rating = 123; carEntity.resalePrice = 0; carEntity.skillModParts = new List <SkillModPartTrans>().SerializeObject(); carEntity.vinyls = new List <CustomVinylTrans>().SerializeObject(); carEntity.visualParts = new List <VisualPartTrans>().SerializeObject(); PersonaManagement.addCar(carEntity); DialogManager.HideMetroDialogAsync(this, carDialog); selectButton.IsEnabled = true; }; Button cancelButton = new Button(); cancelButton.SetValue(Canvas.LeftProperty, 233d); cancelButton.SetValue(Canvas.TopProperty, 54d); cancelButton.Width = 70d; cancelButton.Click += (object sender, RoutedEventArgs routedEventArgs) => { DialogManager.HideMetroDialogAsync(this, carDialog); }; Canvas canvas = new Canvas(); canvas.Children.Add(carComboBox); canvas.Children.Add(selectButton); canvas.Children.Add(cancelButton); carDialog = new CustomDialog(); carDialog.Height = 200d; carDialog.Content = canvas; // internationalization BindingOperations.SetBinding(carDialog, CustomDialog.TitleProperty, lBindSelectCar); BindingOperations.SetBinding(selectButton, Button.ContentProperty, lBindSelect); BindingOperations.SetBinding(cancelButton, Button.ContentProperty, lBindCancel); #endregion #region nfswDialog TextBlock text = new TextBlock(); text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; text.TextAlignment = TextAlignment.Center; text.FontSize = 32d; text.MaxWidth = 480d; Viewbox viewBox = new Viewbox(); viewBox.StretchDirection = StretchDirection.DownOnly; viewBox.Width = 480d; viewBox.Child = text; nfswDialog = new CustomDialog(); nfswDialog.Height = 200d; nfswDialog.Width = 520d; nfswDialog.HorizontalContentAlignment = HorizontalAlignment.Center; nfswDialog.VerticalContentAlignment = VerticalAlignment.Center; nfswDialog.Content = viewBox; Binding bindTag = new Binding() { Path = new PropertyPath("Tag"), Mode = BindingMode.OneWay, Source = nfswDialog }; BindingOperations.SetBinding(text, TextBlock.TextProperty, bindTag); #endregion }
private void Button_ClickHandler(object sender, RoutedEventArgs e) { switch ((sender as Button).Name) { case "buttonOpenBasicPersonaInfo": flyoutBasicPersonaInfo.IsOpen = !flyoutBasicPersonaInfo.IsOpen; break; case "buttonOpenDetailedPersonaInfo": flyoutDetailedPersonaInfo.IsOpen = !flyoutDetailedPersonaInfo.IsOpen; break; case "buttonOpenPersonaList": flyoutPersonaList.IsOpen = !flyoutPersonaList.IsOpen; break; case "buttonUpdatePersonaInfoTile": RandomPersonaInfo.Stop(); tRandomPersonaInfo_Tick(null, null); RandomPersonaInfo.Start(); break; case "buttonPaints": case "buttonPerformanceParts": case "buttonSkillModParts": case "buttonVinyls": case "buttonVisualParts": tbGaragePartInfo.SetBinding(MVVMSyntax._TextProperty, new Binding() { Converter = new STEditConverter(this), Path = new PropertyPath("ActivePersona.SelectedCar." + ((sender as Button).Name).Remove(0, 6)), UpdateSourceTrigger = UpdateSourceTrigger.LostFocus, Mode = BindingMode.TwoWay, Source = Access.CurrentSession }); flyoutGaragePartInfo.IsOpen = !flyoutGaragePartInfo.IsOpen; break; case "buttonAddCar": this.ShowMetroDialogAsync(carDialog, new MetroDialogSettings() { AnimateHide = true, AnimateShow = true }); break; case "buttonRemoveCar": if (listCar.Items.Count > 1) { Int32 selectedItemIndex = listCar.SelectedIndex; if (selectedItemIndex != -1) { PersonaManagement.removeCar((Car)listCar.Items[selectedItemIndex]); listCar.SelectedIndex = Math.Min(selectedItemIndex, listCar.Items.Count - 1); } else { new ToolTip() { Content = Access.dataAccess.appSettings.uiSettings.language.RemoveCarNoSelectedCarError, StaysOpen = false, IsOpen = true }; } } else { new ToolTip() { Content = Access.dataAccess.appSettings.uiSettings.language.RemoveCarLastCarError, StaysOpen = false, IsOpen = true }; } break; case "buttonSettings": flyoutSettings.IsOpen = !flyoutSettings.IsOpen; break; case "buttonAddonManager": if (!AddonManagerTalk.isAddonManagerRunning && AddonManagerTalk.isWaitingForClient) { String addonManagerLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AddonManager.exe"); if (!File.Exists(addonManagerLocation)) { this.ShowMessageAsync(Access.dataAccess.appSettings.uiSettings.language.InformUserInformation, Access.dataAccess.appSettings.uiSettings.language.AddonManagerNotFoundError); return; } Access.addonManagerTalk.initialize(); String args = String.Format("/catalogs '{0}' /baskets '{1}' /accents '{2}' /themes '{3}' /languages '{4}' /memorypatches '{5}' /logs '{6}' /offlineServer {7}", Path.GetFullPath(DataEx.dir_HttpServerCatalogs), Path.GetFullPath(DataEx.dir_HttpServerBaskets), Path.GetFullPath(DataEx.dir_Accents), Path.GetFullPath(DataEx.dir_Themes), Path.GetFullPath(DataEx.dir_Languages), Path.GetFullPath(DataEx.dir_MemoryPatches), Path.GetFullPath(DataEx.dir_Logs), Access.addonManagerTalk.port); Process.Start(addonManagerLocation, args); } break; } }
private void SetupComponents() { #region FlipViewPersona FlipViewPersonaImage.HideControlButtons(); Grid[] aFlipViewAvatarArray = new Grid[28]; for (int i = 0; i < 28; i++) { Grid Grid_FlipViewDummy; Image Image_FlipViewDummy; Image_FlipViewDummy = new Image() { Margin = new Thickness(5.5d), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Stretch = Stretch.Uniform, Source = (ImageSource)BitmapFrame.Create(new Uri("pack://application:,,,/OfflineServer;component/images/NFSW_Avatars/Avatar_" + i.ToString() + ".png", UriKind.Absolute)) }; Grid_FlipViewDummy = new Grid() { Margin = new Thickness(0.4d) }; Grid_FlipViewDummy.Children.Add(Image_FlipViewDummy); Image t1 = new Image() { Source = Image_FlipViewDummy.Source }; t1.Effect = new BlurEffect() { Radius = 4.5d, RenderingBias = RenderingBias.Quality, KernelType = KernelType.Gaussian }; Grid_FlipViewDummy.Background = new VisualBrush(t1); aFlipViewAvatarArray[i] = Grid_FlipViewDummy; } FlipViewPersonaImage.ItemsSource = aFlipViewAvatarArray; Binding indexBind = new Binding() { Path = new PropertyPath("ActivePersona.IconIndex"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay, Source = Access.CurrentSession }; BindingOperations.SetBinding(FlipViewPersonaImage, FlipView.SelectedIndexProperty, indexBind); #endregion #region MetroTile -> Random Persona Info tRandomPersonaInfo_Tick(null, null); RandomPersonaInfo.Tick += new EventHandler(tRandomPersonaInfo_Tick); RandomPersonaInfo.Interval = new TimeSpan(0, 0, 10); RandomPersonaInfo.Start(); #endregion #region carDialog Binding lBindSelect = new Binding() { Path = new PropertyPath("language.Select"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; Binding lBindCancel = new Binding() { Path = new PropertyPath("language.Cancel"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; Binding lBindSelectCar = new Binding() { Path = new PropertyPath("language.AddACarText"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; ComboBox carComboBox = new ComboBox(); carComboBox.SetValue(Canvas.LeftProperty, 5d); carComboBox.SetValue(Canvas.TopProperty, 20d); carComboBox.Width = 297d; carComboBox.ItemsSource = CarDefinitions.physicsProfileHashNormal.Values; carComboBox.SelectedIndex = 0; Button selectButton = new Button(); selectButton.SetValue(Canvas.LeftProperty, 148d); selectButton.SetValue(Canvas.TopProperty, 54d); selectButton.Width = 80d; selectButton.Click += (object sender, RoutedEventArgs routedEventArgs) => { selectButton.IsEnabled = false; CarEntity carEntity = new CarEntity(); carEntity.baseCarId = CarDefinitions.baseCarId.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key; carEntity.carId = Access.CurrentSession.ActivePersona.Cars.Last().CarId + 1; carEntity.durability = 100; carEntity.heatLevel = 1; carEntity.paints = "<Paints/>"; carEntity.performanceParts = "<PerformanceParts/>"; carEntity.physicsProfileHash = CarDefinitions.physicsProfileHashNormal.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key; carEntity.raceClass = CarClass.E; carEntity.rating = 123; carEntity.resalePrice = 0; carEntity.skillModParts = "<SkillModParts/>"; carEntity.vinyls = "<Vinyls/>"; carEntity.visualParts = "<VisualParts/>"; PersonaManagement.addCar(carEntity); DialogManager.HideMetroDialogAsync(this, carDialog); }; Button cancelButton = new Button(); cancelButton.SetValue(Canvas.LeftProperty, 233d); cancelButton.SetValue(Canvas.TopProperty, 54d); cancelButton.Width = 70d; cancelButton.Click += (object sender, RoutedEventArgs routedEventArgs) => { DialogManager.HideMetroDialogAsync(this, carDialog); }; Canvas canvas = new Canvas(); canvas.Children.Add(carComboBox); canvas.Children.Add(selectButton); canvas.Children.Add(cancelButton); carDialog = new CustomDialog(); carDialog.Height = 200d; carDialog.Content = canvas; // internationalization BindingOperations.SetBinding(carDialog, CustomDialog.TitleProperty, lBindSelectCar); BindingOperations.SetBinding(selectButton, Button.ContentProperty, lBindSelect); BindingOperations.SetBinding(cancelButton, Button.ContentProperty, lBindCancel); #endregion }
public static String baskets() { BasketTrans basketTrans = Access.sHttp.getPostData().DeserializeObject <BasketTrans>(); CommerceResultTrans commerceResultTrans = new CommerceResultTrans(); List <InventoryItemTrans> inventoryItems = new List <InventoryItemTrans>(); List <OwnedCarTrans> purchasedCars = new List <OwnedCarTrans>(); Economy economy = Economy.defineFromBasketItemTransList(basketTrans.basketItems); if (economy == null) { commerceResultTrans.status = Basket.ShoppingCartPurchaseResult.Fail_InvalidBasket; } else if (!economy.canBuy()) { commerceResultTrans.status = Basket.ShoppingCartPurchaseResult.Fail_InsufficientFunds; } else { economy.doTransaction(); commerceResultTrans.status = Basket.ShoppingCartPurchaseResult.Success; commerceResultTrans.wallets.walletTrans = new WalletTrans() { balance = economy.balance, currency = economy.currency }; foreach (BasketItemTrans basketItemTrans in basketTrans.basketItems) { for (int i = 0; i < basketItemTrans.quantity; i++) { switch (basketItemTrans.getItemType()) { case Basket.BasketItemType.Unknown: { commerceResultTrans.status = Basket.ShoppingCartPurchaseResult.Fail_ItemNotAvailableStandalone; goto finalize; // ahahah f**k you anti-goto people } case Basket.BasketItemType.THRevive: // implement TH break; case Basket.BasketItemType.Repair: { Access.CurrentSession.ActivePersona.SelectedCar.Durability = (Int16)100; } break; case Basket.BasketItemType.CarSlot: // implement carslots break; case Basket.BasketItemType.Powerup: String powerupType = basketItemTrans.productId.Replace("SRV-POWERUP-", ""); // TODO: // expose to UI // improve Persona.Inventory InventoryItemEntity entity = PersonaManagement.persona.inventory.FirstOrDefault(ii => ii.entitlementTag == powerupType); if (entity != null) { entity = InventoryItemManagement.getInventoryItemEntity(entity.id); entity.remainingUseCount += DataEx.productInformations[basketItemTrans.productId].useCount; entity.setInventoryItemEntity(); inventoryItems.Add(entity.getInventoryItemTrans()); } break; case Basket.BasketItemType.Car: { OwnedCarTrans purchasedCar = Catalog.getCarBasketDefinition(basketItemTrans.productId); if (purchasedCar == null) { continue; } CarEntity carEntity = new CarEntity(); carEntity.baseCarId = purchasedCar.customCar.baseCarId; carEntity.carClassHash = purchasedCar.customCar.carClassHash; carEntity.durability = purchasedCar.durability; carEntity.heatLevel = purchasedCar.heatLevel; carEntity.name = purchasedCar.customCar.name; carEntity.paints = purchasedCar.customCar.paints.SerializeObject(); carEntity.performanceParts = purchasedCar.customCar.performanceParts.SerializeObject(); carEntity.physicsProfileHash = purchasedCar.customCar.physicsProfileHash; carEntity.rating = purchasedCar.customCar.rating; carEntity.resalePrice = purchasedCar.customCar.resalePrice; carEntity.skillModParts = purchasedCar.customCar.skillModParts.SerializeObject(); carEntity.vinyls = purchasedCar.customCar.vinyls.SerializeObject(); carEntity.visualParts = purchasedCar.customCar.visualParts.SerializeObject(); carEntity = PersonaManagement.addCar(carEntity); purchasedCar.id = carEntity.id; purchasedCar.customCar.id = carEntity.id; purchasedCars.Add(purchasedCar); } break; } } } } finalize: commerceResultTrans.commerceItems = new List <CommerceItemTrans>(); commerceResultTrans.inventoryItems = inventoryItems.Count > 0 ? inventoryItems : new List <InventoryItemTrans>() { new InventoryItemTrans() }; commerceResultTrans.purchasedCars = purchasedCars; return(commerceResultTrans.SerializeObject()); }