private void RefreshTeam() { for (int i = 0; i < 6; i++) { Image imageTeam = (Image)FindName("imageTeam" + (i + 1).ToString()); Rectangle rectTeam = (Rectangle)FindName("rectTeam" + (i + 1).ToString()); Label labelTeam = (Label)FindName("labelTeam" + (i + 1).ToString()); if (i < newPokemonTeam.Count) { imageTeam.Source = PokemonDatabase.GetPokemonBoxImageFromDexID(newPokemonTeam[i].DexID, false, newPokemonTeam[i].FormID); rectTeam.OpacityMask = new ImageBrush(imageTeam.Source); labelTeam.Content = newPokemonTeam[i].Level.ToString(); ToolTip tooltip = new ToolTip(); string content = ""; if (newPokemonTeam[i].IsHoldingItem) { content = "Holding: " + newPokemonTeam[i].HeldItemData.Name + "\n"; } content += newPokemonTeam[i].Move1Data.Name; for (int j = 1; j < 4; j++) { if (newPokemonTeam[i].GetMoveIDAt(j) != 0) { content += "\n" + newPokemonTeam[i].GetMoveDataAt(j).Name; } } tooltip.Content = content; rectTeam.ToolTip = tooltip; } else { imageTeam.Source = null; rectTeam.OpacityMask = new ImageBrush(ResourceDatabase.GetImageFromName("TeamBallBackground")); rectTeam.ToolTip = null; labelTeam.Content = ""; } } }
private void AddAlteringCaveItem(ushort dexID) { StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; Image image = new Image(); //(form == byte.MaxValue ? 0 : form) image.Source = PokemonDatabase.GetPokemonBoxImageFromDexID(dexID, false); image.Stretch = Stretch.None; image.SnapsToDevicePixels = true; image.UseLayoutRounding = true; image.Margin = new Thickness(0, -7, 0, -1); TextBlock text = new TextBlock(); text.Margin = new Thickness(6, 0, 0, 0); text.Text = PokemonDatabase.GetPokemonFromDexID(dexID).Name; text.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(image); stackPanel.Children.Add(text); comboBoxAlteringCave.Items.Add(stackPanel); }
public void FillPokedex() { listViewPokemon.Items.Clear(); for (int i = 1; i <= 386; i++) { bool living = livingFlags[i - 1]; bool seen = gameSave.IsPokemonSeen((ushort)i); bool owned = gameSave.IsPokemonOwned((ushort)i); for (int j = 0; j < 28 && (j == 0 || (viewMode == PokedexViewModes.Living && (i == 201 || (j < 4 && i == 386)))); j++) { if (viewMode == PokedexViewModes.Living) { if (i == 201) { living = unownLivingFlags[j]; } if (i == 386) { living = deoxysLivingFlags[j]; } } if ((viewMode == PokedexViewModes.Owned && !owned) || (viewMode == PokedexViewModes.Seen && !seen) || (viewMode == PokedexViewModes.Living && !living) || (viewMode == PokedexViewModes.SeenMissing && seen) || (viewMode == PokedexViewModes.OwnedMissing && owned) || (viewMode == PokedexViewModes.LivingMissing && living)) { continue; } ListViewItem listViewItem = new ListViewItem(); Grid grid = new Grid(); grid.Height = 28; byte form = 255; if (i == 201) { byte val = 0; uint personality = gameSave.GetPokedexPokemonPersonality(201); val = ByteHelper.SetBits(val, 0, ByteHelper.GetBits(personality, 0, 2)); val = ByteHelper.SetBits(val, 2, ByteHelper.GetBits(personality, 8, 2)); val = ByteHelper.SetBits(val, 4, ByteHelper.GetBits(personality, 16, 2)); val = ByteHelper.SetBits(val, 6, ByteHelper.GetBits(personality, 24, 2)); form = (byte)(val % 28); } Image boxImage = new Image(); boxImage.Source = PokemonDatabase.GetPokemonBoxImageFromDexID((ushort)i, gameSave.IsPokedexPokemonShiny((ushort)i), (viewMode == PokedexViewModes.Living && (i == 201 || i == 386)) ? (byte)j : form); boxImage.Width = 32; boxImage.Height = 32; boxImage.Margin = new Thickness(-2, -7, -2, -2); boxImage.HorizontalAlignment = HorizontalAlignment.Left; boxImage.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(boxImage); if (!seen) { Rectangle boxMask = new Rectangle(); boxMask.Width = 32; boxMask.Height = 32; boxMask.Margin = new Thickness(-2, -7, -2, -2); boxMask.OpacityMask = new ImageBrush(PokemonDatabase.GetPokemonBoxImageFromDexID((ushort)i, false, (viewMode == PokedexViewModes.Living && (i == 201 || i == 386)) ? (byte)j : byte.MaxValue)); boxMask.Fill = new SolidColorBrush(Color.FromArgb(160, 0, 0, 0)); boxMask.HorizontalAlignment = HorizontalAlignment.Left; boxMask.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(boxMask); } if (seen) { Image ownedImage = new Image(); ownedImage.Width = 9; ownedImage.Height = 9; ownedImage.Margin = new Thickness(32, 10, 0, 0); ownedImage.Source = ResourceDatabase.GetImageFromName(living ? "PokedexPokeballLiving" : (owned ? "PokedexPokeballOwned" : "PokedexEyeSeen")); if (!living && owned && (gameSave.GameType == GameTypes.Colosseum || gameSave.GameType == GameTypes.XD)) { ownedImage.Source = ResourceDatabase.GetImageFromName("PokedexRRegistered"); } ownedImage.HorizontalAlignment = HorizontalAlignment.Left; ownedImage.VerticalAlignment = VerticalAlignment.Top; ownedImage.Stretch = Stretch.None; grid.Children.Add(ownedImage); } Label dexID = new Label(); dexID.FontWeight = FontWeights.Bold; dexID.VerticalAlignment = VerticalAlignment.Center; dexID.Content = "No" + i.ToString("000"); dexID.Margin = new Thickness(40, 0, 0, 0); grid.Children.Add(dexID); Label name = new Label(); name.VerticalAlignment = VerticalAlignment.Center; name.Content = PokemonDatabase.GetPokemonFromDexID((ushort)i).Name; if (viewMode == PokedexViewModes.Living && (i == 201 || i == 386)) { name.Content = PokemonDatabase.GetPokemonFromDexID((ushort)i).GetForm((byte)j).Name; } name.Margin = new Thickness(84, 0, 0, 0); grid.Children.Add(name); listViewItem.Tag = i; listViewItem.Content = grid; listViewPokemon.Items.Add(listViewItem); } } }
private void OnSecretBaseSelected(object sender, SelectionChangedEventArgs e) { if (listViewSecretBases.SelectedIndex != -1) { secretBase = (listViewSecretBases.SelectedItem as ListViewItem).Tag as SecretBase; } buttonAdd.IsEnabled = (!IsGBAGame || GBAGameSave.SecretBaseManager.SharedSecretBases.Count < 19); buttonImport.IsEnabled = (!IsGBAGame || GBAGameSave.SecretBaseManager.SharedSecretBases.Count < 19); if (listViewSecretBases.SelectedIndex == -1 || secretBase == null) { roomDisplay.UnloadSecretBase(); locationDisplay.UnloadLocation(); rectRoomDisplay.Visibility = Visibility.Hidden; roomDisplay.Visibility = Visibility.Hidden; locationDisplay.Visibility = Visibility.Hidden; labelOwner.Content = ""; labelTrainerID.Content = ""; labelSecretID.Content = ""; labelRequires.Content = ""; gridTeam.Visibility = Visibility.Visible; secretBase = null; buttonRemove.IsEnabled = false; buttonEditBase.IsEnabled = listViewSecretBases.SelectedIndex != -1; buttonEditTrainer.IsEnabled = false; buttonRegister.IsEnabled = false; buttonExport.IsEnabled = false; buttonSend.IsEnabled = false; for (int i = 0; i < 6; i++) { Image imageTeam = (Image)FindName("imageTeam" + (i + 1).ToString()); Label labelTeam = (Label)FindName("labelTeam" + (i + 1).ToString()); imageTeam.Source = null; labelTeam.Content = ""; } } else { buttonRemove.IsEnabled = true; buttonEditBase.IsEnabled = true; buttonExport.IsEnabled = true; buttonSend.IsEnabled = true; rectRoomDisplay.Visibility = Visibility.Visible; roomDisplay.Visibility = Visibility.Visible; locationDisplay.Visibility = Visibility.Visible; roomDisplay.LoadSecretBase(secretBase); locationDisplay.LoadLocation(secretBase.LocationID); labelOwner.Content = secretBase.TrainerName; labelTrainerID.Content = secretBase.TrainerID.ToString("00000"); labelSecretID.Content = secretBase.SecretID.ToString("00000"); labelRequires.Content = (secretBase.LocationData.Requirements ?? "Nothing"); if (secretBase.IsPlayerSecretBase) { buttonRegister.IsEnabled = false; buttonEditTrainer.IsEnabled = false; } else { buttonEditTrainer.IsEnabled = true; buttonRegister.IsEnabled = IsGBAGame; buttonRegister.Content = ((SharedSecretBase)secretBase).IsRegistered ? "Unregister" : "Register"; } gridTeam.Visibility = Visibility.Visible; for (int i = 0; i < 6; i++) { Image imageTeam = (Image)FindName("imageTeam" + (i + 1).ToString()); Rectangle rectTeam = (Rectangle)FindName("rectTeam" + (i + 1).ToString()); Label labelTeam = (Label)FindName("labelTeam" + (i + 1).ToString()); if (i < secretBase.PokemonTeam.Count) { imageTeam.Source = PokemonDatabase.GetPokemonBoxImageFromDexID(secretBase.PokemonTeam[i].DexID, false, secretBase.PokemonTeam[i].FormID); labelTeam.Content = secretBase.PokemonTeam[i].Level.ToString(); rectTeam.Visibility = Visibility.Visible; ToolTip tooltip = new ToolTip(); string content = ""; if (secretBase.PokemonTeam[i].IsHoldingItem) { content = "Holding: " + secretBase.PokemonTeam[i].HeldItemData.Name + "\n"; } content += secretBase.PokemonTeam[i].Move1Data.Name; for (int j = 1; j < 4; j++) { if (secretBase.PokemonTeam[i].GetMoveIDAt(j) != 0) { content += "\n" + secretBase.PokemonTeam[i].GetMoveDataAt(j).Name; } } tooltip.Content = content; rectTeam.ToolTip = tooltip; } else { imageTeam.Source = null; rectTeam.Visibility = Visibility.Hidden; rectTeam.ToolTip = null; labelTeam.Content = ""; } } } }
public void PopulateResults(IEnumerable <IPokemon> results) { this.grids = new List <Grid>(); stackPanelPokemon.Children.Clear(); int index = 0; StackPanel row = null; int columns = 14; // (int)(stackPanelPokemon.ActualWidth / 30); foreach (IPokemon pokemon in results) { if (index % columns == 0) { row = new StackPanel(); row.Orientation = Orientation.Horizontal; stackPanelPokemon.Children.Add(row); stackPanelPokemon.Height += 30; } Grid grid = new Grid(); grid.Width = 30; grid.Height = 30; grid.MouseEnter += OnMouseEnter; grid.MouseLeave += OnMouseLeave; grid.PreviewMouseDown += OnMouseClicked; grid.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); grid.ToolTip = ""; // Set the tooltip so we can modify it when it opens. grid.ContextMenu = contextMenu; Image image = new Image(); image.Source = pokemon.BoxSprite; image.Stretch = Stretch.None; image.Width = 32; image.Height = 32; image.Margin = new Thickness(-1, -2, -1, 0); image.IsHitTestVisible = false; grid.Children.Add(image); if (pokemon.IsEgg) { image.Source = PokemonDatabase.GetPokemonBoxImageFromDexID(pokemon.DexID, pokemon.IsShiny, pokemon.FormID); Image egg = new Image(); egg.Source = ResourceDatabase.GetImageFromName((PokeManager.Settings.UseNewBoxSprites ? "New" : "") + "SideEgg"); egg.Stretch = Stretch.None; egg.Width = 9; egg.Height = 11; egg.Margin = new Thickness(19, 19, 0, 0); egg.IsHitTestVisible = false; grid.Children.Add(egg); } if (pokemon.IsShadowPokemon) { Rectangle shadowMask = new Rectangle(); shadowMask.Width = 32; shadowMask.Height = 32; shadowMask.Stroke = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); shadowMask.StrokeThickness = 0; shadowMask.Fill = new SolidColorBrush(Color.FromArgb(70, 128, 112, 184)); shadowMask.Margin = new Thickness(-1, -2, -1, 0); shadowMask.OpacityMask = new ImageBrush(pokemon.BoxSprite); shadowMask.IsHitTestVisible = false; grid.Children.Add(shadowMask); } grid.Tag = pokemon; grid.ToolTipOpening += OnTooltipOpening; row.Children.Add(grid); grids.Add(grid); index++; } labelResults.Content = "Results: " + index.ToString(); }
private void OnItemListSelectionChanged(object sender, SelectionChangedEventArgs e) { int index = listViewItems.SelectedIndex; if (index < mailbox.MailboxCount) { if (index != -1) { selectedIndex = index; } if (selectedIndex != -1 && selectedIndex < mailbox.MailboxCount) { selectedMail = mailbox[selectedIndex]; this.imageMailBackground.Source = ResourceDatabase.GetImageFromName(selectedMail.MailItemData.Name.Replace(" ", "")); this.imageItem.Source = ItemDatabase.GetItemImageFromID(selectedMail.MailItemID); this.imagePokemon.Source = PokemonDatabase.GetPokemonBoxImageFromDexID(selectedMail.OriginalHolderDexID, false); this.labelItemName.Content = (selectedMail.MailItemData != null ? selectedMail.MailItemData.Name : "Unknown Mail"); this.labelPokemon.Content = (selectedMail.OriginalHolderPokemonData != null ? selectedMail.OriginalHolderPokemonData.Name : "Unknown Pokemon"); this.labelTrainerID.Content = selectedMail.TrainerID.ToString("00000"); this.labelSecretID.Content = selectedMail.SecretID.ToString("00000"); MailPositionInfo positions = mailPositions[121]; if (mailPositions.ContainsKey(selectedMail.MailItemID)) { positions = mailPositions[selectedMail.MailItemID]; } int textOffset = 4; Color black = Color.FromRgb(0, 0, 0); Color blackShadow = Color.FromRgb(215, 215, 215); Color white = Color.FromRgb(255, 255, 255); Color whiteShadow = Color.FromRgb(100, 100, 100); this.labelFrom.Margin = new Thickness(positions.FromX - 15, positions.FromY - textOffset, 0, 0); this.labelFrom.Width = positions.FromLength + 30; this.labelFrom.Content = "From " + selectedMail.TrainerName; this.labelFrom.Foreground = new SolidColorBrush(positions.Black ? black : white); (this.labelFrom.Effect as DropShadowEffect).Color = (positions.Black ? blackShadow : whiteShadow); this.stackPanelMessageLines.Margin = new Thickness(positions.MessageX, positions.MessageY - textOffset, 0, 0); string[] lines = selectedMail.Lines; for (int i = 0; i < 5; i++) { (this.stackPanelMessageLines.Children[i] as Label).Content = (i < lines.Length ? lines[i] : ""); (this.stackPanelMessageLines.Children[i] as Label).Foreground = new SolidColorBrush(positions.Black ? black : white); ((this.stackPanelMessageLines.Children[i] as Label).Effect as DropShadowEffect).Color = (positions.Black ? blackShadow : whiteShadow); } this.imagePokemon2.Source = PokemonDatabase.GetPokemonBoxImageFromDexID(selectedMail.OriginalHolderDexID, false); this.imagePokemon2.Margin = new Thickness(positions.PokemonX, positions.PokemonY, 0, 0); this.imagePokemon2.Visibility = (positions.PokemonX == -1 ? Visibility.Hidden : Visibility.Visible); } else { this.imageMailBackground.Source = null; this.imageItem.Source = null; this.imagePokemon.Source = null; this.labelItemName.Content = ""; this.labelPokemon.Content = ""; this.labelTrainerID.Content = ""; this.labelSecretID.Content = ""; this.labelFrom.Content = ""; for (int i = 0; i < 5; i++) { (this.stackPanelMessageLines.Children[i] as Label).Content = ""; } this.imagePokemon2.Visibility = Visibility.Hidden; } } }