/// <summary> /// Display an avatar /// </summary> /// <param name="avatar"></param> public void DisplayAvatar(UISim avatar) { this.Avatar = avatar; SetSlotAvailable(false); PersonNameText.Caption = avatar.Name; PersonDescriptionText.CurrentText = avatar.Description; AvatarButton.Texture = Screen.SimSelectButtonImage; CityNameText.Caption = avatar.ResidingCity.Name; String gamepath = GameFacade.GameFilePath(""); int CityNum = GameFacade.GetCityNumber(avatar.ResidingCity.Name); string CityStr = gamepath + "cities\\" + ((CityNum >= 10) ? "city_00" + CityNum.ToString() : "city_000" + CityNum.ToString()); var stream = new FileStream(CityStr + "\\Thumbnail.bmp", FileMode.Open, FileAccess.Read, FileShare.Read); Texture2D cityThumbTex = TextureUtils.Resize(GameFacade.GraphicsDevice, ImageLoader.FromStream( GameFacade.Game.GraphicsDevice, stream), 78, 58); stream.Close(); TextureUtils.CopyAlpha(ref cityThumbTex, Screen.CityHouseButtonAlpha); CityThumb.Texture = cityThumbTex; SetTab(PersonSlotTab.EnterTab); }
/// <summary> /// Handle when a user selects a city /// </summary> /// <param name="element"></param> private void CityListBox_OnChange(UIElement element) { var selectedItem = CityListBox.SelectedItem; if (selectedItem == null) { return; } var city = (CityInfo)selectedItem.Data; String gamepath = GameFacade.GameFilePath(""); int CityNum = GameFacade.GetCityNumber(city.Name); string CityStr = gamepath + "cities/" + ((CityNum >= 10) ? "city_00" + CityNum.ToString() : "city_000" + CityNum.ToString()); //Take a copy so we dont change the original when we alpha mask it var stream = new FileStream(CityStr + "/Thumbnail.bmp", FileMode.Open, FileAccess.Read, FileShare.Read); Texture2D cityThumbTex = TextureUtils.Copy(GameFacade.GraphicsDevice, ImageLoader.FromStream( GameFacade.Game.GraphicsDevice, stream)); TextureUtils.CopyAlpha(ref cityThumbTex, thumbnailAlphaImage); stream.Close(); CityThumb.Texture = cityThumbTex; DescriptionText.CurrentText = city.Description; DescriptionText.VerticalScrollPosition = 0; /** Validate **/ var isValid = true; if (city.Status == CityInfoStatus.Reserved) { isValid = false; /** Already have a sim in this city **/ ShowCityErrorDialog(CityReservedDialogTitle, CityReservedDialogMessage); } else if (city.Status == CityInfoStatus.Full) { isValid = false; /** City is full **/ ShowCityErrorDialog(CityFullDialogTitle, CityFullDialogMessage); } else if (city.Status == CityInfoStatus.Busy) { isValid = false; /** City is busy **/ ShowCityErrorDialog(CityBusyDialogTitle, CityBusyDialogMessage); } OkButton.Disabled = !isValid; }