private void UpdateTrainerImage()
        {
            BitmapSource trainerImage = PokeManager.TrainerImage;

            if (gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire)
            {
                trainerImage = ResourceDatabase.GetImageFromName("RubySapphire" + trainerGender.ToString());
            }
            else if (gameSave.GameType == GameTypes.Emerald)
            {
                trainerImage = ResourceDatabase.GetImageFromName("Emerald" + trainerGender.ToString());
            }
            else if (gameSave.GameType == GameTypes.FireRed || gameSave.GameType == GameTypes.LeafGreen)
            {
                trainerImage = ResourceDatabase.GetImageFromName("FireRedLeafGreen" + trainerGender.ToString());
            }
            else if (gameSave.GameType == GameTypes.Colosseum)
            {
                trainerImage = ResourceDatabase.GetImageFromName("ColosseumMale");
            }
            else if (gameSave.GameType == GameTypes.XD)
            {
                trainerImage = ResourceDatabase.GetImageFromName("XDMale");
            }
            imageTrainer.Width  = Math.Min(90, trainerImage.PixelWidth);
            imageTrainer.Height = Math.Min(138, trainerImage.PixelHeight);
            imageTrainer.Source = trainerImage;
        }
        public void TryAddContainer(DecorationTypes decorationType)
        {
            if (inventory.Decorations.ContainsPocket(decorationType))
            {
                TabItem tabItem = new TabItem();
                tabItem.Tag = decorationType;
                if (previousPocket == decorationType)
                {
                    previousPocketIndex = tabControlPockets.Items.Count;
                }
                Image headerImage = new Image();
                headerImage.SnapsToDevicePixels = true;
                headerImage.UseLayoutRounding   = true;
                headerImage.Stretch             = Stretch.None;
                headerImage.Source = ResourceDatabase.GetImageFromName(decorationType.ToString() + "Tab");

                tabItem.Header = headerImage;
                DecorationViewerTab inventoryTab = new DecorationViewerTab();
                inventoryTab.Width  = Double.NaN;
                inventoryTab.Height = Double.NaN;
                tabItem.Content     = inventoryTab;
                tabControlPockets.Items.Add(tabItem);
                inventoryTab.LoadPocket(inventory.Decorations[decorationType]);
                tabs.Add(decorationType, inventoryTab);
                if (currentPocket == DecorationTypes.Unknown)
                {
                    currentPocket = decorationType;
                }
            }
        }
Esempio n. 3
0
        private void AddRibbon(string id)
        {
            Image image = new Image();

            image.Stretch             = Stretch.None;
            image.SnapsToDevicePixels = true;
            image.UseLayoutRounding   = true;
            image.Source           = ResourceDatabase.GetImageFromName("Ribbon" + id);  // PokemonDatabase.GetRibbonImageFromID(id);
            image.IsHitTestVisible = false;
            StackPanel stackPanelImage = new StackPanel();

            stackPanelImage.Orientation = Orientation.Horizontal;
            stackPanelImage.Children.Add(image);
            stackPanelImage.MouseLeftButtonDown += ribbon_MouseLeftButtonDown;
            stackPanelImage.Background           = new SolidColorBrush(Color.FromRgb(244, 244, 245));
            stackPanelImage.Tag = id;

            if (stackPanelRibbons.Children.Count == 0 || ((StackPanel)stackPanelRibbons.Children[stackPanelRibbons.Children.Count - 1]).Children.Count == 9)
            {
                StackPanel stackPanel = new StackPanel();
                stackPanel.Orientation = Orientation.Horizontal;
                stackPanel.Children.Add(stackPanelImage);
                stackPanelRibbons.Children.Add(stackPanel);
            }
            else
            {
                ((StackPanel)stackPanelRibbons.Children[stackPanelRibbons.Children.Count - 1]).Children.Add(stackPanelImage);
            }
        }
Esempio n. 4
0
        private void RefreshTrainer()
        {
            string[] maleTrainers   = { "Youngster", "Bug Catcher", "Rich Boy", "Camper", "Cooltrainer" };
            string[] femaleTrainers = { "Lass", "School Kid", "Lady", "Picnicker", "Cooltrainer" };

            for (int i = 0; i < 5; i++)
            {
                ((ComboBoxItem)comboBoxTrainer.Items[i]).Content = (newGender == Genders.Male ? maleTrainers[i] : femaleTrainers[i]);
            }

            imageTrainer.Source = ResourceDatabase.GetImageFromName(newGender.ToString() + "SecretBaseLarge" + (((int)newTrainerID % 256) % 5).ToString());
        }
Esempio n. 5
0
        public SelectGameTypeWindow(GameTypes gameType1, GameTypes gameType2)
        {
            InitializeComponent();

            this.gameType1 = gameType1;
            this.gameType2 = gameType2;

            imageGame1.Source  = ResourceDatabase.GetImageFromName(gameType1.ToString() + "Physical");
            imageGame2.Source  = ResourceDatabase.GetImageFromName(gameType2.ToString() + "Physical");
            labelGame1.Content = gameType1.ToString();
            labelGame2.Content = gameType2.ToString();
        }
 private void OnFemaleGenderClicked(object sender, RoutedEventArgs e)
 {
     radioButtonMale.IsChecked   = false;
     radioButtonFemale.IsChecked = true;
     trainerGender = Genders.Female;
     if (PokeManager.CustomTrainerImage == null)
     {
         BitmapSource trainerImage = ResourceDatabase.GetImageFromName("Manager" + trainerGender.ToString());
         imageTrainer.Width  = Math.Min(90, trainerImage.PixelWidth);
         imageTrainer.Height = Math.Min(138, trainerImage.PixelHeight);
         imageTrainer.Source = trainerImage;
     }
 }
        private void OnRoomMouseDown(object sender, MouseButtonEventArgs e)
        {
            if ((mode == PlaceModes.Place || mode == PlaceModes.Moving) && selectedDecorationID != 0 && secretBase.CanPlaceDecoration(selectedDecorationID, (byte)hoverX, (byte)hoverY))
            {
                secretBase.PlaceDecoration(selectedDecorationID, (byte)hoverX, (byte)hoverY);

                BitmapSource decorationImage = ItemDatabase.GetDecorationFullSizeImageFromID(selectedDecorationID);
                Image        image           = new OpaqueClickableImage();
                image.Width   = decorationImage.PixelWidth;
                image.Height  = decorationImage.PixelHeight;
                image.Stretch = Stretch.None;
                image.Source  = decorationImage;
                if (ItemDatabase.GetDecorationFromID(selectedDecorationID).DataType == DecorationDataTypes.NoteMat && showNotes)
                {
                    image.Source = ResourceDatabase.GetImageFromName("NoteMat" + (selectedDecorationID - 51).ToString());
                }
                image.Margin = new Thickness(16 * (hoverX - SelectedDecorationData.OriginX), 16 * (hoverY - SelectedDecorationData.OriginY), 0, 0);
                image.HorizontalAlignment = HorizontalAlignment.Left;
                image.VerticalAlignment   = VerticalAlignment.Top;
                image.Tag = secretBase.PlacedDecorations[secretBase.SlotsUsed - 1];
                image.PreviewMouseDown += OnDecorationImageMouseDown;
                image.MouseEnter       += OnDecorationImageMouseEnter;
                image.MouseLeave       += OnDecorationImageMouseLeave;
                image.IsHitTestVisible  = false;
                decorationImages.Add(image);

                this.gridRoomContents.Children.Add(image);

                OrganizeZIndexes();

                SelectPlaceDecoration(0);
                FillListViewItems();

                if (mode == PlaceModes.Moving)
                {
                    Mode = PlaceModes.Move;
                    foreach (Image image2 in decorationImages)
                    {
                        image2.IsHitTestVisible = true;
                    }
                }
                UpdateDetails();
            }
        }
        public void RefreshUI()
        {
            gridContents.Children.Clear();

            RoomData roomData = SecretBaseDatabase.GetRoomAt(index);


            Image room = new Image();

            room.HorizontalAlignment = HorizontalAlignment.Left;
            room.VerticalAlignment   = VerticalAlignment.Top;
            room.Width  = roomData.Image.PixelWidth;
            room.Height = roomData.Image.PixelHeight;
            room.Source = roomData.Image;

            gridContents.Children.Add(room);

            for (int x = 0; x < roomData.Width; x++)
            {
                for (int y = 0; y < roomData.Height; y++)
                {
                    Rectangle type = new Rectangle();
                    type.Width  = 16;
                    type.Height = 16;
                    type.HorizontalAlignment = HorizontalAlignment.Left;
                    type.VerticalAlignment   = VerticalAlignment.Top;
                    type.StrokeThickness     = 0;
                    type.Margin = new Thickness(16 * x, 16 * y, 0, 0);
                    type.Fill   = GetTypeColor(roomData.PlacementGrid[x, y]);
                    gridContents.Children.Add(type);
                }
            }

            Image trainer = new Image();

            trainer.HorizontalAlignment = HorizontalAlignment.Left;
            trainer.VerticalAlignment   = VerticalAlignment.Top;
            trainer.Width  = 16;
            trainer.Height = 24;
            trainer.Margin = new Thickness(16 * roomData.TrainerX, 16 * roomData.TrainerY - 8, 0, 0);
            trainer.Source = ResourceDatabase.GetImageFromName("MaleSecretBase0");
            gridContents.Children.Add(trainer);
        }
Esempio n. 9
0
        public void LoadLocation(byte id)
        {
            LocationData locationData = SecretBaseDatabase.GetLocationFromID(id);

            imageRouteSign.Visibility = Visibility.Visible;
            imageLocation.Visibility  = Visibility.Visible;
            labelRoute.Visibility     = Visibility.Visible;
            imageLocation.Source      = locationData.Image;
            imageRouteSign.Source     = ResourceDatabase.GetImageFromName("RouteSign" + (locationData.RouteData.ID >= 124 ? "Water" : "Land"));
            labelRoute.Content        = "Route " + locationData.RouteData.ID;

            ToolTip routeTooltip = new ToolTip();

            BitmapSource routeImage = locationData.RouteData.Image;

            Grid tooltip = new Grid();

            tooltip.Width  = routeImage.PixelWidth / 8 + 10;
            tooltip.Height = routeImage.PixelHeight / 8 + 10;

            Image route = new Image();

            route.HorizontalAlignment = HorizontalAlignment.Left;
            route.VerticalAlignment   = VerticalAlignment.Top;
            route.Width   = routeImage.PixelWidth / 8;
            route.Height  = routeImage.PixelHeight / 8;
            route.Margin  = new Thickness(5, 5, 5, 5);
            route.Stretch = Stretch.Uniform;
            route.Source  = routeImage;

            Image pinpoint = new Image();

            pinpoint.HorizontalAlignment = HorizontalAlignment.Left;
            pinpoint.VerticalAlignment   = VerticalAlignment.Top;
            pinpoint.Width  = 12;
            pinpoint.Height = 12;
            pinpoint.Source = ResourceDatabase.GetImageFromName("RouteLocationSelector");
            pinpoint.Margin = new Thickness(locationData.MapX * 2, locationData.MapY * 2, 0, 0);

            tooltip.Children.Add(route);
            tooltip.Children.Add(pinpoint);
            imageLocation.ToolTip = tooltip;
        }
        private void OnShowNoteMatsChecked(object sender, RoutedEventArgs e)
        {
            showNotes = checkBoxShowNoteMats.IsChecked.Value;

            foreach (Image image in decorationImages)
            {
                PlacedDecoration decoration = image.Tag as PlacedDecoration;
                if (decoration.DecorationData.DataType == DecorationDataTypes.NoteMat)
                {
                    if (showNotes)
                    {
                        image.Source = ResourceDatabase.GetImageFromName("NoteMat" + (decoration.ID - 51).ToString());
                    }
                    else
                    {
                        image.Source = ItemDatabase.GetDecorationFullSizeImageFromID(decoration.ID);
                    }
                }
            }
        }
Esempio n. 11
0
 private void OnVolumeClicked(object sender, RoutedEventArgs e)
 {
     PokeManager.Settings.IsMuted = !PokeManager.Settings.IsMuted;
     if (PokeManager.Settings.IsMuted)
     {
         imageVolume.Source = ResourceDatabase.GetImageFromName("IconVolumeMute");
     }
     else
     {
         imageVolume.Source = ResourceDatabase.GetImageFromName("IconVolumeOn");
     }
     if (playerCry != null)
     {
         playerCry.Volume = PokeManager.Settings.MutedVolume;
     }
     if (playerEvolutionCry != null)
     {
         playerEvolutionCry.Volume = PokeManager.Settings.MutedVolume;
     }
     playerMusic.Volume = PokeManager.Settings.MutedVolume;
 }
Esempio n. 12
0
        private void AddDeoxysItem(byte form, string name)
        {
            string[]   formNames  = new string[] { "Default", "Normal", "Attack", "Defense", "Speed" };
            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;
            Image image = new Image();

            //(form == byte.MaxValue ? 0 : form)
            image.Source              = ResourceDatabase.GetImageFromName("Deoxys" + formNames[form == byte.MaxValue ? 0 : form + 1]);
            image.Stretch             = Stretch.None;
            image.SnapsToDevicePixels = true;
            image.UseLayoutRounding   = true;
            TextBlock text = new TextBlock();

            text.Margin            = new Thickness(6, 0, 0, 0);
            text.Text              = name;
            text.VerticalAlignment = VerticalAlignment.Center;
            stackPanel.Children.Add(image);
            stackPanel.Children.Add(text);
            comboBoxForm.Items.Add(stackPanel);
        }
Esempio n. 13
0
        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    = "";
                }
            }
        }
Esempio n. 14
0
 public void TryAddPocket(ItemTypes pocketType)
 {
     if (inventory.Items.ContainsPocket(pocketType))
     {
         TabItem tabItem = new TabItem();
         tabItem.Tag = pocketType;
         if (previousPocket == pocketType)
         {
             previousPocketIndex = tabControlPockets.Items.Count;
         }
         StackPanel stackPanel = new StackPanel();
         stackPanel.SnapsToDevicePixels = true;
         stackPanel.Orientation         = Orientation.Horizontal;
         Image headerImage = new Image();
         headerImage.SnapsToDevicePixels = true;
         headerImage.UseLayoutRounding   = true;
         headerImage.Stretch             = Stretch.None;
         headerImage.Source = ResourceDatabase.GetImageFromName(pocketType.ToString() + "Tab");
         TextBlock headerName = new TextBlock();
         headerName.Text = ItemDatabase.GetPocketName(pocketType);
         headerName.VerticalAlignment = VerticalAlignment.Center;
         headerName.Margin            = new Thickness(2, 0, 0, 0);
         //stackPanel.Children.Add(headerImage);
         //stackPanel.Children.Add(headerName);
         tabItem.Header = headerImage;                // stackPanel;//ItemTable.GetPocketName(pocketType);
         ItemViewerTab inventoryTab = new ItemViewerTab();
         inventoryTab.Width  = Double.NaN;
         inventoryTab.Height = Double.NaN;
         tabItem.Content     = inventoryTab;
         tabControlPockets.Items.Add(tabItem);
         inventoryTab.LoadPocket(inventory.Items[pocketType]);
         tabs.Add(pocketType, inventoryTab);
         if (currentPocket == ItemTypes.Unknown)
         {
             currentPocket = pocketType;
         }
     }
 }
        public void OnAddListViewItem(object sender, DecorationPocketEventArgs e)
        {
            ListViewItem listViewItem = new ListViewItem();

            listViewItem.SnapsToDevicePixels = true;
            listViewItem.UseLayoutRounding   = true;
            DockPanel dockPanel = new DockPanel();

            dockPanel.Width = 300;

            Image image = new Image();

            image.Source              = ItemDatabase.GetDecorationImageFromID(e.Decoration.ID);
            image.Stretch             = Stretch.None;
            image.SnapsToDevicePixels = true;
            image.UseLayoutRounding   = true;

            TextBlock itemName = new TextBlock();

            itemName.VerticalAlignment = VerticalAlignment.Center;
            itemName.Text         = ItemDatabase.GetDecorationFromID(e.Decoration.ID).Name;
            itemName.TextTrimming = TextTrimming.CharacterEllipsis;
            itemName.Margin       = new Thickness(4, 0, 0, 0);

            Image usedImage = new Image();

            usedImage.Stretch             = Stretch.None;
            usedImage.SnapsToDevicePixels = true;
            usedImage.UseLayoutRounding   = true;
            usedImage.HorizontalAlignment = HorizontalAlignment.Left;
            usedImage.Margin = new Thickness(6, 0, 0, 0);
            DecorationUsages usage = pocket.Inventory.GetDecorationUsage(e.Index, pocket.PocketType);

            if (usage == DecorationUsages.SecretBase)
            {
                usedImage.Source = ResourceDatabase.GetImageFromName("DecorationSecretBase");
            }
            else if (usage == DecorationUsages.Bedroom)
            {
                usedImage.Source = ResourceDatabase.GetImageFromName("DecorationBedroom");
            }

            TextBlock usedCount = new TextBlock();

            usedCount.VerticalAlignment = VerticalAlignment.Center;
            usedCount.Margin            = new Thickness(4, 0, 0, 0);
            int usageCount = pocket.Inventory.GetNumDecorationsWithIDInUse(e.Decoration.ID);

            usedCount.Text = (usageCount > 0 && pocket.MaxStackSize == 0 ? usageCount.ToString() : "");

            TextBlock itemX = new TextBlock();

            itemX.VerticalAlignment   = VerticalAlignment.Center;
            itemX.HorizontalAlignment = HorizontalAlignment.Right;
            itemX.TextAlignment       = TextAlignment.Right;
            itemX.Text     = "x";
            itemX.Width    = Double.NaN;
            itemX.MinWidth = 10;

            TextBlock itemCount = new TextBlock();

            itemCount.VerticalAlignment   = VerticalAlignment.Center;
            itemCount.HorizontalAlignment = HorizontalAlignment.Right;
            itemCount.TextAlignment       = TextAlignment.Right;
            itemCount.Width = 30;
            itemCount.Text  = e.Decoration.Count.ToString();

            listViewItem.Content = dockPanel;
            pocket.ListViewItems.Insert(e.Index, listViewItem);
            dockPanel.Children.Add(image);
            dockPanel.Children.Add(itemName);
            dockPanel.Children.Add(usedImage);
            dockPanel.Children.Add(usedCount);
            dockPanel.Children.Add(itemCount);
            dockPanel.Children.Add(itemX);
            if (pocket.MaxStackSize != 0)
            {
                itemCount.Visibility = Visibility.Hidden;
                itemX.Visibility     = Visibility.Hidden;
            }
            else
            {
                usedCount.Visibility = Visibility.Hidden;
            }

            listViewItem.ContextMenuOpening += OnContextMenuOpening;
            listViewItem.ContextMenu         = contextMenu;


            DockPanel.SetDock(image, Dock.Left);
            DockPanel.SetDock(itemCount, Dock.Right);

            listViewItem.Tag = e.Decoration;
            UpdateDetails();
        }
Esempio n. 16
0
        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);
                }
            }
        }
Esempio n. 17
0
        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;
                }
            }
        }
        public void OnUpdateListViewItem(object sender, DecorationPocketEventArgs e)
        {
            ((Image)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[0]).Source   = ItemDatabase.GetDecorationImageFromID(e.Decoration.ID);
            ((TextBlock)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[1]).Text = ItemDatabase.GetDecorationFromID(e.Decoration.ID).Name;
            DecorationUsages usage = pocket.Inventory.GetDecorationUsage(e.Index, pocket.PocketType);

            if (usage == DecorationUsages.SecretBase)
            {
                ((Image)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[2]).Source = ResourceDatabase.GetImageFromName("DecorationSecretBase");
            }
            else if (usage == DecorationUsages.Bedroom)
            {
                ((Image)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[2]).Source = ResourceDatabase.GetImageFromName("DecorationBedroom");
            }
            else
            {
                ((Image)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[2]).Source = null;
            }
            ((TextBlock)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[4]).Text = e.Decoration.Count.ToString();
            int usageCount = pocket.Inventory.GetNumDecorationsWithIDInUse(e.Decoration.ID);

            ((TextBlock)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[3]).Text = (usageCount > 0 && pocket.MaxStackSize == 0 ? usageCount.ToString() : "");
            pocket.ListViewItems[e.Index].Tag = e.Decoration;
        }
Esempio n. 19
0
        public void RefreshUI()
        {
            if (gameSave != null)
            {
                loaded = false;
                BitmapSource trainerImage = null;
                if (PokeManager.IsAprilFoolsMode)
                {
                    trainerImage = ResourceDatabase.GetImageFromName("YoungsterMale");
                }
                else if (gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire)
                {
                    trainerImage = ResourceDatabase.GetImageFromName("RubySapphire" + gameSave.TrainerGender.ToString());
                }
                else if (gameSave.GameType == GameTypes.Emerald)
                {
                    trainerImage = ResourceDatabase.GetImageFromName("Emerald" + gameSave.TrainerGender.ToString());
                }
                else if (gameSave.GameType == GameTypes.FireRed || gameSave.GameType == GameTypes.LeafGreen)
                {
                    trainerImage = ResourceDatabase.GetImageFromName("FireRedLeafGreen" + gameSave.TrainerGender.ToString());
                }
                else if (gameSave.GameType == GameTypes.Colosseum)
                {
                    trainerImage = ResourceDatabase.GetImageFromName("ColosseumMale");
                }
                else if (gameSave.GameType == GameTypes.XD)
                {
                    trainerImage = ResourceDatabase.GetImageFromName("XDMale");
                }
                else if (gameSave.GameType == GameTypes.Any)
                {
                    trainerImage = PokeManager.TrainerImage;
                }
                if (trainerImage != null)
                {
                    imageTrainer.Width  = Math.Min(90, trainerImage.PixelWidth);
                    imageTrainer.Height = Math.Min(138, trainerImage.PixelHeight);
                }
                imageTrainer.Source = trainerImage;

                labelTrainerName.Content = gameSave.TrainerName;
                labelTrainerID.Content   = gameSave.TrainerID.ToString("00000");
                labelSecretID.Content    = gameSave.SecretID.ToString("00000");
                if (gameSave.GameType == GameTypes.Any)
                {
                    ManagerGameSave managerSave = gameSave as ManagerGameSave;
                    TimeSpan        newPlayTime = managerSave.PlayTime + new TimeSpan((DateTime.Now - managerSave.TimeOfLastSave).Ticks);
                    labelPlayTime.Content = ((int)newPlayTime.TotalHours).ToString() + ":" + newPlayTime.Minutes.ToString("00") + ":" + newPlayTime.Seconds.ToString("00");
                }
                else if (gameSave.GameType == GameTypes.XD || gameSave.GameType == GameTypes.Colosseum)
                {
                    labelPlayTime.Content = "---";
                }
                else
                {
                    labelPlayTime.Content = gameSave.HoursPlayed + ":" + gameSave.MinutesPlayed.ToString("00") + ":" + gameSave.SecondsPlayed.ToString("00");
                }
                if (gameSave.GameType == GameTypes.Colosseum || gameSave.GameType == GameTypes.XD)
                {
                    labelPokedexText.Content = "StrMemo";
                }
                else
                {
                    labelPokedexText.Content = "Pokédex";
                }
                labelPokedex.Content = gameSave.PokemonOwned.ToString();
                labelMoney.Content   = "$" + gameSave.Money.ToString("#,0");
                if (gameSave.GameType != GameTypes.Colosseum && gameSave.GameType != GameTypes.XD)
                {
                    labelCoins.Content = gameSave.Coins.ToString("#,0") + " Coins";
                }
                else
                {
                    labelCoins.Content = "---";
                }
                if (gameSave.GameType == GameTypes.Any || gameSave.GameType == GameTypes.Emerald)
                {
                    labelBattlePts.Content = gameSave.BattlePoints.ToString("#,0") + " BP";
                }
                else
                {
                    labelBattlePts.Content = "---";
                }
                if (gameSave.GameType == GameTypes.Any || gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire || gameSave.GameType == GameTypes.Emerald)
                {
                    labelSoot.Content = gameSave.VolcanicAsh.ToString("#,0") + " Soot";
                }
                else
                {
                    labelSoot.Content = "---";
                }
                if (gameSave.GameType == GameTypes.Any || gameSave.GameType == GameTypes.Colosseum || gameSave.GameType == GameTypes.XD)
                {
                    labelCoupons.Content = gameSave.PokeCoupons.ToString("#,0") + " PC";
                }
                else
                {
                    labelCoupons.Content = "---";
                }


                buttonMoney.IsEnabled     = true;
                buttonCoins.IsEnabled     = (gameSave.GameType != GameTypes.Colosseum && gameSave.GameType != GameTypes.XD);
                buttonBattlePts.IsEnabled = (gameSave.GameType == GameTypes.Any || gameSave.GameType == GameTypes.Emerald);
                buttonCoupons.IsEnabled   = (gameSave.GameType == GameTypes.Any || gameSave.GameType == GameTypes.Colosseum || gameSave.GameType == GameTypes.XD);
                buttonSoot.IsEnabled      = (gameSave.GameType == GameTypes.Any || gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire || gameSave.GameType == GameTypes.Emerald);

                gridBadges.Visibility   = Visibility.Hidden;
                gridSettings.Visibility = Visibility.Hidden;

                if (gameSave is GBAGameSave)
                {
                    gridBadges.Visibility = Visibility.Visible;

                    bool[] badges  = (gameSave as GBAGameSave).Badges;
                    bool   isKanto = gameSave.GameType == GameTypes.FireRed || gameSave.GameType == GameTypes.LeafGreen;
                    for (int i = 0; i < 8; i++)
                    {
                        Image imageBadge = (Image)FindName("badge" + (i + 1).ToString());
                        if (badges[i])
                        {
                            imageBadge.Source = ResourceDatabase.GetImageFromName((isKanto ? "Kanto" : "Hoenn") + "Badge" + (i + 1).ToString());
                        }
                        else
                        {
                            imageBadge.Source = null;
                        }
                    }

                    if (gameSave.GameType == GameTypes.Emerald || gameSave.GameType == GameTypes.FireRed || gameSave.GameType == GameTypes.LeafGreen)
                    {
                        gridSettings.Visibility = Visibility.Visible;
                        comboBoxAlteringCave.Items.Clear();
                        AddAlteringCaveItem(41);
                        AddAlteringCaveItem(179);
                        AddAlteringCaveItem(204);
                        AddAlteringCaveItem(228);
                        AddAlteringCaveItem(216);
                        AddAlteringCaveItem(190);
                        AddAlteringCaveItem(213);
                        AddAlteringCaveItem(234);
                        AddAlteringCaveItem(235);
                        comboBoxAlteringCave.SelectedIndex = (int)(gameSave as GBAGameSave).AlteringCavePokemon;

                        labelStevenBattleText.IsEnabled = gameSave.GameType == GameTypes.Emerald;
                        buttonStevenBattle.IsEnabled    = gameSave.GameType == GameTypes.Emerald && (gameSave as GBAGameSave).HasBattledStevenEmerald;
                    }
                }

                loaded = true;
            }
        }
        public SecretBaseLocationChooser(byte location, SecretBaseManager manager, bool startInvalid)
        {
            InitializeComponent();

            this.originalLocation = location;
            this.location         = (location == 0 ? (byte)181 : location);
            this.manager          = manager;
            this.startInvalid     = startInvalid;

            for (int i = 0; i < SecretBaseDatabase.NumLocations; i++)
            {
                LocationData locationData = SecretBaseDatabase.GetLocationAt(i);

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Tag = locationData.ID;
                StackPanel stackPanel = new StackPanel();
                stackPanel.Orientation = Orientation.Horizontal;
                Grid grid = new Grid();
                grid.Width  = 16;
                grid.Height = 16;

                Image type = new Image();
                type.Width  = 16;
                type.Height = 16;
                type.HorizontalAlignment = HorizontalAlignment.Center;
                type.VerticalAlignment   = VerticalAlignment.Center;
                type.Source = ResourceDatabase.GetImageFromName("SecretBaseType" + locationData.Type.ToString());

                Label layout = new Label();
                layout.Padding                    = new Thickness(0, 0, 0, 0);
                layout.Width                      = 16;
                layout.Height                     = 16;
                layout.HorizontalAlignment        = HorizontalAlignment.Center;
                layout.VerticalAlignment          = VerticalAlignment.Center;
                layout.HorizontalContentAlignment = HorizontalAlignment.Center;
                layout.VerticalContentAlignment   = VerticalAlignment.Center;
                layout.Content                    = locationData.Layout.ToString();
                layout.FontWeight                 = FontWeights.Bold;
                //layout.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));

                grid.Children.Add(type);
                grid.Children.Add(layout);

                Label label = new Label();
                label.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                label.Padding           = new Thickness(4, 0, 4, 0);
                label.Content           = "Route " + locationData.RouteData.ID;
                if ((startInvalid || originalLocation != locationData.ID) && manager != null && manager.IsLocationInUse(locationData.ID))
                {
                    label.Foreground = new SolidColorBrush(Color.FromRgb(220, 0, 0));
                }
                else if (OriginalLocationData != null && locationData.Type == OriginalLocationData.Type && locationData.Layout == OriginalLocationData.Layout)
                {
                    label.Foreground = new SolidColorBrush(Color.FromRgb(0, 140, 60));
                    label.FontWeight = FontWeights.Bold;
                }

                stackPanel.Children.Add(grid);
                stackPanel.Children.Add(label);
                listViewItem.Content = stackPanel;
                listViewSecretBases.Items.Add(listViewItem);
                if (locationData.ID == this.location)
                {
                    listViewSecretBases.SelectedIndex = listViewSecretBases.Items.Count - 1;
                }
            }
            if (listViewSecretBases.SelectedIndex == -1)
            {
                OnLocationSelected(null, null);
            }
        }
        public void LoadSecretBase(SecretBase secretBase)
        {
            this.secretBase = secretBase;
            foreach (Image image in decorationImages)
            {
                this.gridRoomContents.Children.Remove(image);
            }

            if (pocket != null)
            {
                pocket = secretBase.GameSave.Inventory.Decorations[pocket.PocketType];
            }
            else
            {
                pocket = secretBase.GameSave.Inventory.Decorations[DecorationTypes.Desk];
            }
            comboBoxPockets.SelectedIndex = (int)DecorationTypes.Desk - 1;
            OnPocketSelectionChanged(null, null);

            imageLocation.Source = LocationData.Image;

            imageTrainer.Margin = new Thickness(16 * RoomData.TrainerX, 16 * RoomData.TrainerY - 8, 0, 0);
            imageTrainer.Source = ResourceDatabase.GetImageFromName(secretBase.TrainerGender.ToString() + "SecretBase" + ((byte)secretBase.TrainerID % 5).ToString());

            BitmapSource roomImage = RoomData.Image;

            gridRoomContents.Width  = roomImage.PixelWidth;
            gridRoomContents.Height = roomImage.PixelHeight;
            imageRoom.Width         = roomImage.PixelWidth;
            imageRoom.Height        = roomImage.PixelHeight;
            imageRoom.Source        = roomImage;

            imageRouteSign.Source = ResourceDatabase.GetImageFromName("RouteSign" + (RouteData.ID >= 124 ? "Water" : "Land"));
            labelRoute.Content    = "Route " + RouteData.ID;

            /*if (RoomData.Type == SecretBaseRoomTypes.Tree || RoomData.Type == SecretBaseRoomTypes.Shrub) {
             *      rectRoomBackground.Visibility = Visibility.Hidden;
             * }
             * else {*/
            rectRoomBackground.Margin     = new Thickness((1 - RoomData.Width % 2) * -8, (1 - RoomData.Height % 2) * -8, 0, 0);
            rectRoomBackground.Visibility = Visibility.Visible;
            (rectRoomBackground.Fill as ImageBrush).ImageSource = RoomData.BackgroundImage;
            //}

            foreach (PlacedDecoration decoration in secretBase.PlacedDecorations)
            {
                DecorationData decorationData  = decoration.DecorationData;
                BitmapSource   decorationImage = ItemDatabase.GetDecorationFullSizeImageFromID(decoration.ID);
                Image          image           = new OpaqueClickableImage();
                image.Width   = decorationImage.PixelWidth;
                image.Height  = decorationImage.PixelHeight;
                image.Stretch = Stretch.None;
                image.Source  = decorationImage;
                if (decoration.DecorationData.DataType == DecorationDataTypes.NoteMat && showNotes)
                {
                    image.Source = ResourceDatabase.GetImageFromName("NoteMat" + (decoration.ID - 51).ToString());
                }
                image.Margin = new Thickness(16 * (decoration.X - decorationData.OriginX), 16 * (decoration.Y - decorationData.OriginY), 0, 0);
                image.HorizontalAlignment = HorizontalAlignment.Left;
                image.VerticalAlignment   = VerticalAlignment.Top;
                image.Tag = decoration;
                image.PreviewMouseDown += OnDecorationImageMouseDown;
                image.MouseEnter       += OnDecorationImageMouseEnter;
                image.MouseLeave       += OnDecorationImageMouseLeave;
                image.IsHitTestVisible  = mode == PlaceModes.PutAway || mode == PlaceModes.Move;
                decorationImages.Add(image);

                this.gridRoomContents.Children.Add(image);
            }
            OrganizeZIndexes();
            Grid.SetZIndex(imageTrainer, 16 * RoomData.TrainerY);

            routeTooltip = new ToolTip();

            BitmapSource routeImage = RouteData.Image;

            Grid tooltip = new Grid();

            tooltip.Width  = routeImage.PixelWidth / 8 + 10;
            tooltip.Height = routeImage.PixelHeight / 8 + 10;

            Image route = new Image();

            route.HorizontalAlignment = HorizontalAlignment.Left;
            route.VerticalAlignment   = VerticalAlignment.Top;
            route.Width   = routeImage.PixelWidth / 8;
            route.Height  = routeImage.PixelHeight / 8;
            route.Margin  = new Thickness(5, 5, 5, 5);
            route.Stretch = Stretch.Uniform;
            route.Source  = routeImage;

            Image pinpoint = new Image();

            pinpoint.HorizontalAlignment = HorizontalAlignment.Left;
            pinpoint.VerticalAlignment   = VerticalAlignment.Top;
            pinpoint.Width  = 12;
            pinpoint.Height = 12;
            pinpoint.Source = ResourceDatabase.GetImageFromName("RouteLocationSelector");
            pinpoint.Margin = new Thickness(LocationData.MapX * 2, LocationData.MapY * 2, 0, 0);

            tooltip.Children.Add(route);
            tooltip.Children.Add(pinpoint);
            imageLocation.ToolTip = tooltip;

            UpdateDetails();
        }
        private void FillListViewItem(GameSaveFileInfo gameSaveFile, ListViewItem listViewItem)
        {
            IGameSave gameSave = gameSaveFile.GameSave;

            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;

            Image       gameImage = new Image();
            BitmapImage bitmap    = ResourceDatabase.GetImageFromName(gameSaveFile.GameType.ToString() + "Physical");

            gameImage.Source = bitmap;
            if (bitmap == null)
            {
                gameImage.Width = 20;
            }
            else
            {
                gameImage.Width = bitmap.PixelWidth * (20.0 / bitmap.PixelHeight);
            }
            gameImage.Height            = 20;
            gameImage.VerticalAlignment = VerticalAlignment.Center;

            TextBlock gameName     = new TextBlock();
            string    gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString());

            if (gameSaveFile.Nickname != "")
            {
                gameName.Text = gameSaveFile.Nickname + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : "");
            }
            else
            {
                gameName.Text = gameTypeName + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : "");
            }
            gameName.VerticalAlignment = VerticalAlignment.Center;
            gameName.Margin            = new Thickness(5, 0, 0, 0);

            TextBlock trainerName = new TextBlock();

            trainerName.Text              = gameSave.TrainerName;
            trainerName.Foreground        = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0)));
            trainerName.VerticalAlignment = VerticalAlignment.Center;

            TextBlock ending = new TextBlock();

            ending.Text = "]";
            ending.VerticalAlignment = VerticalAlignment.Center;

            stackPanel.Children.Add(gameImage);
            stackPanel.Children.Add(gameName);
            if (gameSaveFile.GameType != GameTypes.PokemonBox)
            {
                stackPanel.Children.Add(trainerName);
                stackPanel.Children.Add(ending);
            }

            listViewItem.ContextMenu         = contextMenu;
            listViewItem.ContextMenuOpening += OnContextMenuOpening;
            listViewItem.Content             = stackPanel;
            listViewItem.Tag     = gameSaveFile;
            listViewItem.ToolTip = gameSaveFile.FilePath;
        }
Esempio n. 23
0
        public void LoadSecretBase(SecretBase secretBase)
        {
            this.secretBase = secretBase;
            foreach (Image image in decorationImages)
            {
                this.gridRoomContents.Children.Remove(image);
            }
            gridRoomContents.Visibility = Visibility.Visible;

            imageTrainer.Margin     = new Thickness(16 * RoomData.TrainerX, 16 * RoomData.TrainerY - 8, 0, 0);
            imageTrainer.Source     = ResourceDatabase.GetImageFromName(secretBase.TrainerGender.ToString() + "SecretBase" + ((byte)secretBase.TrainerID % 5).ToString());
            imageTrainer.Visibility = (secretBase.IsPlayerSecretBase ? Visibility.Hidden : Visibility.Visible);

            BitmapSource roomImage = RoomData.Image;

            gridRoomContents.Width  = roomImage.PixelWidth;
            gridRoomContents.Height = roomImage.PixelHeight;
            imageRoom.Width         = roomImage.PixelWidth;
            imageRoom.Height        = roomImage.PixelHeight;
            imageRoom.Source        = roomImage;

            /*if (RoomData.Type == SecretBaseRoomTypes.Tree || RoomData.Type == SecretBaseRoomTypes.Shrub) {
             *      rectRoomBackground.Visibility = Visibility.Hidden;
             * }
             * else {*/
            rectRoomBackground.Margin     = new Thickness((1 - RoomData.Width % 2) * -8, (1 - RoomData.Height % 2) * -8, 0, 0);
            rectRoomBackground.Visibility = Visibility.Visible;
            (rectRoomBackground.Fill as ImageBrush).ImageSource = RoomData.BackgroundImage;
            //}

            foreach (PlacedDecoration decoration in secretBase.PlacedDecorations)
            {
                DecorationData decorationData  = decoration.DecorationData;
                BitmapSource   decorationImage = ItemDatabase.GetDecorationFullSizeImageFromID(decoration.ID);
                Image          image           = new OpaqueClickableImage();
                image.Width               = decorationImage.PixelWidth;
                image.Height              = decorationImage.PixelHeight;
                image.Stretch             = Stretch.None;
                image.Source              = decorationImage;
                image.Margin              = new Thickness(16 * (decoration.X - decorationData.OriginX), 16 * (decoration.Y - decorationData.OriginY), 0, 0);
                image.HorizontalAlignment = HorizontalAlignment.Left;
                image.VerticalAlignment   = VerticalAlignment.Top;
                image.Tag = decoration;
                decorationImages.Add(image);

                this.gridRoomContents.Children.Add(image);
            }

            foreach (Image image in decorationImages)
            {
                PlacedDecoration decoration = image.Tag as PlacedDecoration;
                int zIndex = 16 * decoration.Y;
                if (decoration.DecorationData.DecorationType == DecorationTypes.Doll)
                {
                    if (decoration.ID >= 111)                     // Big Doll
                    {
                        zIndex += 160;
                    }
                    else
                    {
                        zIndex += 162;
                    }
                }
                else if (decoration.DecorationData.DecorationType == DecorationTypes.Cushion)
                {
                    zIndex += 162;
                }
                Grid.SetZIndex(image, zIndex);
            }

            Grid.SetZIndex(imageTrainer, 16 * RoomData.TrainerY);
        }
Esempio n. 24
0
        public static void Initialize()
        {
            ItemDatabase.gen3ImageMap = new Dictionary <ushort, BitmapSource>();
            ItemDatabase.gen3ItemMap  = new Dictionary <ushort, ItemData>();
            ItemDatabase.gen3ItemList = new List <ItemData>();

            ItemDatabase.pokeblockLargeImageMap = new Dictionary <PokeblockColors, BitmapSource>();
            ItemDatabase.pokeblockSmallImageMap = new Dictionary <PokeblockColors, BitmapSource>();

            ItemDatabase.decorationImageMap         = new Dictionary <byte, BitmapSource>();
            ItemDatabase.decorationFullSizeImageMap = new Dictionary <byte, BitmapSource>();
            ItemDatabase.decorationMap  = new Dictionary <byte, DecorationData>();
            ItemDatabase.decorationList = new List <DecorationData>();

            ItemDatabase.easyChatMap        = new Dictionary <ushort, string>();
            ItemDatabase.easyChatReverseMap = new Dictionary <string, ushort>();
            ItemDatabase.easyChatList       = new List <string>();

            ItemDatabase.pocketNamesMap = new Dictionary <ItemTypes, string>()
            {
                { ItemTypes.PC, "PC" },
                { ItemTypes.Items, "Items" },
                { ItemTypes.KeyItems, "Key Items" },
                { ItemTypes.PokeBalls, "Poké Balls" },
                { ItemTypes.TMCase, "TMs & HMs" },
                { ItemTypes.Berries, "Berries" },
                { ItemTypes.CologneCase, "Cologne Case" },
                { ItemTypes.DiscCase, "Disc Case" },
                { ItemTypes.InBattle, "In-Battle Items" },
                { ItemTypes.Valuables, "Valuable Items" },
                { ItemTypes.Hold, "Hold Items" },
                { ItemTypes.Misc, "Other Items" },
                { ItemTypes.Any, "Any" },
                { ItemTypes.TheVoid, "The Void" }
            };
            ItemDatabase.decorationContainerNamesMap = new Dictionary <DecorationTypes, string>()
            {
                { DecorationTypes.Desk, "Desks" },
                { DecorationTypes.Chair, "Chairs" },
                { DecorationTypes.Plant, "Plants" },
                { DecorationTypes.Ornament, "Ornaments" },
                { DecorationTypes.Mat, "Mats" },
                { DecorationTypes.Poster, "Posters" },
                { DecorationTypes.Doll, "Dolls" },
                { DecorationTypes.Cushion, "Cushions" }
            };

            secretBaseUsedIcon = ResourceDatabase.GetImageFromName("DecorationSecretBase");
            bedroomUsedIcon    = ResourceDatabase.GetImageFromName("DecorationBedroom");

            SQLiteCommand    command;
            SQLiteDataReader reader;
            DataTable        table;

            SQLiteConnection connection = new SQLiteConnection("Data Source=ItemDatabase.db");

            connection.Open();

            // Load Gen3 Item Data
            command = new SQLiteCommand("SELECT * FROM Items", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("Items");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                ItemData item = new ItemData(row, Generations.Gen3);
                gen3ItemMap.Add(item.ID, item);
                gen3ItemList.Add(item);
            }

            // Load Gen3 Item Images
            command = new SQLiteCommand("SELECT * FROM ItemImages", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("Images");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                ushort       id    = (ushort)(long)row["ID"];
                BitmapSource image = LoadImage((byte[])row["Image"]);
                gen3ImageMap.Add(id, image);
            }

            // Load Gen3 Decoration Data
            command = new SQLiteCommand("SELECT * FROM Decorations", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("Decorations");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                DecorationData decoration = new DecorationData(row);
                decorationMap.Add(decoration.ID, decoration);
                decorationList.Add(decoration);
            }

            // Load Gen3 Decoration Images
            command = new SQLiteCommand("SELECT * FROM DecorationImages", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("DecorationImages");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                byte id = (byte)(long)row["ID"];
                decorationImageMap.Add(id, LoadImage((byte[])row["Image"]));
                decorationFullSizeImageMap.Add(id, LoadImage((byte[])row["ImageFullSize"]));
            }

            // Load Gen3 Pokeblock Small Images
            command = new SQLiteCommand("SELECT * FROM PokeblockImages", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("PokeblockImages");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                PokeblockColors id = (PokeblockColors)(long)row["ID"];
                pokeblockSmallImageMap.Add(id, LoadImage((byte[])row["ImageSmall"]));
                pokeblockLargeImageMap.Add(id, LoadImage((byte[])row["ImageLarge"]));
            }
            // Load Gen3 Pokeblock Large Images

            /*command = new SQLiteCommand("SELECT * FROM PokeblockLargeImages", connection);
             * reader = command.ExecuteReader();
             * table = new DataTable("PokeblockLargeImages");
             * table.Load(reader);
             * foreach (DataRow row in table.Rows) {
             *      PokeblockColors id = (PokeblockColors)(long)row["ID"];
             *      BitmapImage image = LoadImage((byte[])row["Data"]);
             *      pokeblockLargeImageMap.Add(id, image);
             * }*/


            connection.Close();
        }
 private void OnWallpaperSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (comboBoxWallpaper.SelectedIndex != -1)
     {
         int newIndex = comboBoxWallpaper.SelectedIndex;
         newWallpaper = (byte)comboBoxWallpaper.SelectedIndex;
         if (pokeBox is ManagerPokeBox)
         {
             if (newIndex < customWallpaperStartIndex)
             {
                 newUsingCustomWallpaper = false;
                 newWallpaperName        = ((ManagerPokeBoxWallpapers)newIndex).ToString();
             }
             else
             {
                 newUsingCustomWallpaper = true;
                 newWallpaperName        = PokemonDatabase.GetCustomWallpaperNameAt(newIndex - customWallpaperStartIndex);
             }
         }
         if (pokeBox.GameType == GameTypes.Ruby || pokeBox.GameType == GameTypes.Sapphire)
         {
             imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperRS" + ((PokeBoxWallpapers)newWallpaper).ToString(), "WallpaperDefault");
         }
         else if (pokeBox.GameType == GameTypes.PokemonBox)
         {
             imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperRS" + ((PokemonBoxPokeBoxWallpapers)newWallpaper).ToString(), "WallpaperDefault");
         }
         else if (pokeBox.GameType == GameTypes.Emerald)
         {
             imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperEmerald" + ((PokeBoxWallpapers)newWallpaper).ToString(), "WallpaperDefault");
         }
         else if (pokeBox.GameType == GameTypes.FireRed || pokeBox.GameType == GameTypes.LeafGreen)
         {
             imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperFRLG" + ((PokeBoxWallpapers)newWallpaper).ToString(), "WallpaperDefault");
         }
         else if (pokeBox.GameType == GameTypes.Colosseum)
         {
             imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperColosseum" + ((ColosseumPokeBoxWallpapers)newWallpaper).ToString() + "E", "WallpaperDefault");
         }
         else if (pokeBox.GameType == GameTypes.XD)
         {
             imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperXD" + ((XDPokeBoxWallpapers)newWallpaper).ToString(), "WallpaperDefault");
         }
         else if (pokeBox.GameType == GameTypes.Any)
         {
             if (newUsingCustomWallpaper)
             {
                 BitmapSource bitmap = PokemonDatabase.GetCustomWallpaper(newWallpaperName);
                 if (bitmap != null)
                 {
                     imageWallpaper.Source = bitmap;
                 }
                 else
                 {
                     imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperDefault");
                 }
             }
             else
             {
                 imageWallpaper.Source = ResourceDatabase.GetImageFromName("WallpaperManager" + newWallpaperName, "WallpaperDefault");
             }
         }
     }
 }
        private void FillListViewItem(ListViewItem listViewItem, SecretBase secretBase = null)
        {
            if (secretBase == null)
            {
                secretBase = listViewItem.Tag as SecretBase;
            }
            else
            {
                listViewItem.Tag = secretBase;
            }

            if (secretBase == null)
            {
                listViewItem.Content = "No Player Secret Base";
            }
            else
            {
                StackPanel stackPanel = new StackPanel();
                stackPanel.Orientation = Orientation.Horizontal;
                Grid grid = new Grid();
                grid.Width  = 16;
                grid.Height = 18;

                Image type = new Image();
                type.Width  = 16;
                type.Height = 16;
                type.HorizontalAlignment = HorizontalAlignment.Center;
                type.VerticalAlignment   = VerticalAlignment.Center;
                type.Source = ResourceDatabase.GetImageFromName("SecretBaseType" + secretBase.LocationData.Type.ToString());

                Label layout = new Label();
                layout.Padding                    = new Thickness(0, 0, 0, 0);
                layout.Width                      = 16;
                layout.Height                     = 16;
                layout.HorizontalAlignment        = HorizontalAlignment.Center;
                layout.VerticalAlignment          = VerticalAlignment.Center;
                layout.HorizontalContentAlignment = HorizontalAlignment.Center;
                layout.VerticalContentAlignment   = VerticalAlignment.Center;
                layout.Content                    = secretBase.LocationData.Layout.ToString();
                layout.FontWeight                 = FontWeights.Bold;
                //layout.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));

                grid.Children.Add(type);
                grid.Children.Add(layout);

                Label label = new Label();
                label.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                label.Padding           = new Thickness(4, 0, 4, 0);
                label.Content           = "Route " + secretBase.RouteData.ID + " - " + secretBase.TrainerName + "";

                Image registered = new Image();
                registered.Width  = 9;
                registered.Height = 9;
                registered.HorizontalAlignment = HorizontalAlignment.Center;
                registered.VerticalAlignment   = VerticalAlignment.Center;
                registered.Source     = ResourceDatabase.GetImageFromName("PokedexRRegistered");
                registered.Visibility = Visibility.Hidden;
                if (!secretBase.IsPlayerSecretBase && ((SharedSecretBase)secretBase).IsRegistered)
                {
                    registered.Visibility = Visibility.Visible;
                }

                stackPanel.Children.Add(grid);
                stackPanel.Children.Add(label);
                stackPanel.Children.Add(registered);
                listViewItem.Content = stackPanel;
            }
        }
Esempio n. 27
0
        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();
        }
Esempio n. 28
0
        public void LoadInventory(Inventory inventory)
        {
            int previousGameIndex = (this.inventory != null ? this.inventory.GameIndex : -1);

            foreach (KeyValuePair <ItemTypes, ItemViewerTab> pair in tabs)
            {
                pair.Value.UnloadPocket();
            }
            if (pokeblockTab != null)
            {
                pokeblockTab.UnloadPokeblockCase();
                pokeblockTab = null;
            }

            this.previousPocketIndex = -1;
            this.tabs.Clear();
            this.tabControlPockets.Items.Clear();
            this.inventory      = inventory;
            this.previousPocket = (currentPocket == ItemTypes.Items && previousGameIndex == -1 ? ItemTypes.PC : currentPocket);
            this.currentPocket  = ItemTypes.PC;
            TryAddPocket(ItemTypes.PC);
            if (!inventory.Items.ContainsPocket(ItemTypes.InBattle))
            {
                TryAddPocket(ItemTypes.Items);
            }
            TryAddPocket(ItemTypes.InBattle);
            TryAddPocket(ItemTypes.Valuables);
            TryAddPocket(ItemTypes.Hold);
            TryAddPocket(ItemTypes.Misc);
            TryAddPocket(ItemTypes.PokeBalls);
            TryAddPocket(ItemTypes.Berries);
            TryAddPocket(ItemTypes.TMCase);
            TryAddPocket(ItemTypes.KeyItems);
            TryAddPocket(ItemTypes.CologneCase);
            TryAddPocket(ItemTypes.DiscCase);

            if (inventory.Pokeblocks != null)
            {
                TabItem tabItem = new TabItem();
                tabItem.Tag = ItemTypes.Unknown;
                if (previousPocket == ItemTypes.Unknown)
                {
                    previousPocketIndex = tabControlPockets.Items.Count;
                }
                StackPanel stackPanel = new StackPanel();
                stackPanel.SnapsToDevicePixels = true;
                stackPanel.Orientation         = Orientation.Horizontal;
                Image headerImage = new Image();
                headerImage.SnapsToDevicePixels = true;
                headerImage.UseLayoutRounding   = true;
                headerImage.Stretch             = Stretch.None;
                headerImage.Source = ResourceDatabase.GetImageFromName("PokeblockCaseTab");
                TextBlock headerName = new TextBlock();
                headerName.Text = "Pokéblock Case";
                headerName.VerticalAlignment = VerticalAlignment.Center;
                headerName.Margin            = new Thickness(2, 0, 0, 0);
                //stackPanel.Children.Add(headerImage);
                //stackPanel.Children.Add(headerName);
                tabItem.Header      = headerImage;           // stackPanel;// "Pokéblock Case";
                pokeblockTab        = new PokeblockViewerTab();
                pokeblockTab.Width  = Double.NaN;
                pokeblockTab.Height = Double.NaN;
                tabItem.Content     = pokeblockTab;
                tabControlPockets.Items.Add(tabItem);
                pokeblockTab.LoadPokeblockCase(inventory.Pokeblocks);
            }
            this.currentPocket = (ItemTypes)(tabControlPockets.Items[0] as TabItem).Tag;
            if (previousPocketIndex != -1)
            {
                Dispatcher.BeginInvoke((Action)(() => tabControlPockets.SelectedIndex = previousPocketIndex));
                this.currentPocket = previousPocket;
            }
        }
Esempio n. 29
0
        public EvolutionWindow(IPokemon pokemon, ushort evolutionDexID)
        {
            InitializeComponent();

            this.pokemon        = pokemon;
            this.evolutionDexID = evolutionDexID;
            this.evolved        = false;

            this.evolutionState = 0;

            this.timer          = new DispatcherTimer();
            this.timer.Tick    += OnTick;
            this.timer.Interval = TimeSpan.FromSeconds(1.5);
            this.timer.Start();

            this.storyboard                      = new Storyboard();
            this.storyboard.Completed           += OnStoryboardCompleted;
            this.imagePrevolution.Source         = PokemonDatabase.GetPokemonImageFromDexID(pokemon.DexID, pokemon.IsShiny);
            this.imageEvolution.Source           = PokemonDatabase.GetPokemonImageFromDexID(evolutionDexID, pokemon.IsShiny);
            this.rectMaskPrevolution.OpacityMask = new ImageBrush(PokemonDatabase.GetPokemonImageFromDexID(pokemon.DexID, pokemon.IsShiny));
            this.rectMaskEvolution.OpacityMask   = new ImageBrush(PokemonDatabase.GetPokemonImageFromDexID(evolutionDexID, pokemon.IsShiny));
            this.rectMaskPrevolution.Opacity     = 0;
            this.textBlockMessage.Text           = "What?\nYour " + pokemon.Nickname + " is evolving!";
            playerCry                      = new MediaPlayer();
            playerCry.MediaEnded          += OnMediaEnded;
            playerCry.Volume               = PokeManager.Settings.MutedVolume;
            playerEvolutionCry             = new MediaPlayer();
            playerEvolutionCry.MediaEnded += OnMediaEnded;
            playerEvolutionCry.Volume      = PokeManager.Settings.MutedVolume;
            playerMusic                    = new MediaPlayer();
            playerMusic.MediaEnded        += OnMediaEnded;
            playerMusic.Volume             = PokeManager.Settings.MutedVolume;

            if (PokeManager.Settings.IsMuted)
            {
                imageVolume.Source = ResourceDatabase.GetImageFromName("IconVolumeMute");
            }
            else
            {
                imageVolume.Source = ResourceDatabase.GetImageFromName("IconVolumeOn");
            }

            CreateAnimation();
            string cryFile = PokemonDatabase.FindCryFile(pokemon.DexID);

            try {
                if (cryFile != null)
                {
                    playerCry.Open(new Uri(cryFile));
                }
                else
                {
                    playerCry = null;
                }
            } catch (Exception) {
                playerCry = null;
            }
            cryFile = PokemonDatabase.FindCryFile(evolutionDexID);
            try {
                if (cryFile != null)
                {
                    playerEvolutionCry.Open(new Uri(cryFile));
                }
                else
                {
                    playerEvolutionCry = null;
                }
            } catch (Exception) {
                playerEvolutionCry = null;
            }
            playerMusic.Open(new Uri(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Audio", "Evolution.wav")));
        }