コード例 #1
0
 private void OnPocketSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     SelectPlaceDecoration(0);
     if (comboBoxPockets.SelectedIndex != -1)
     {
         pocket = secretBase.GameSave.Inventory.Decorations[(DecorationTypes)(comboBoxPockets.SelectedIndex + 1)];
         FillListViewItems();
     }
 }
コード例 #2
0
        public void LoadPocket(DecorationPocket pocket)
        {
            this.pocket                = pocket;
            pocket.AddListViewItem    += OnAddListViewItem;
            pocket.UpdateListViewItem += OnUpdateListViewItem;
            pocket.RemoveListViewItem += OnRemoveListViewItem;
            listViewItems.ItemsSource  = pocket.ListViewItems;
            buySellInfo.UnloadBuySellInfo();
            UpdateDetails();

            pocket.RepopulateListView();
        }
コード例 #3
0
        private void LoadDecorationPocket(DecorationTypes pocketType, byte[] data)
        {
            DecorationPocket pocket = inventory.Decorations[pocketType];

            uint count = LittleEndian.ToUInt32(data, 0);

            for (int i = 0; i < (int)count; i++)
            {
                pocket.AddDecoration(
                    (byte)LittleEndian.ToUInt16(data, 4 + i * 6),
                    LittleEndian.ToUInt32(data, 4 + i * 6 + 2)
                    );
            }
        }
コード例 #4
0
        private byte[] SaveDecorationPocket(DecorationTypes pocketType)
        {
            DecorationPocket pocket = inventory.Decorations[pocketType];

            List <byte> data = new List <byte>();

            data.AddRange(BitConverter.GetBytes(pocket.SlotsUsed));

            for (int i = 0; i < pocket.SlotsUsed; i++)
            {
                data.AddRange(BitConverter.GetBytes((ushort)pocket[i].ID));
                data.AddRange(BitConverter.GetBytes(pocket[i].Count));
            }

            return(data.ToArray());
        }
コード例 #5
0
        private void UpdateResults()
        {
            listViewResults.Items.Clear();
            if (selectedItemID == 0)
            {
                return;
            }
            for (int i = -1; i < PokeManager.NumGameSaves; i++)
            {
                IGameSave gameSave = PokeManager.GetGameSaveAt(i);
                if (gameSave.Inventory == null)
                {
                    continue;
                }
                if (decorationMode && gameSave.Inventory.Decorations != null)
                {
                    if (gameSave.Inventory.Decorations.ContainsPocket(SelectedDecorationData.DecorationType))
                    {
                        DecorationPocket pocket = gameSave.Inventory.Decorations[SelectedDecorationData.DecorationType];
                        int count = 0;
                        for (int j = 0; j < pocket.SlotsUsed; j++)
                        {
                            if (pocket[j].ID == (byte)selectedItemID)
                            {
                                count += (int)pocket[j].Count;
                            }
                        }
                        if (count > 0)
                        {
                            AddListViewItem(i, pocket.PocketType, ItemDatabase.GetDecorationContainerName(pocket.PocketType), count);
                        }
                    }
                }
                else if (!decorationMode)
                {
                    ItemPocket pocket;
                    int        count;
                    if (gameSave.Inventory.Items.ContainsPocket(ItemTypes.PC))
                    {
                        pocket = gameSave.Inventory.Items[ItemTypes.PC];
                        count  = 0;
                        for (int j = 0; j < pocket.SlotsUsed; j++)
                        {
                            if (pocket[j].ID == (ushort)selectedItemID)
                            {
                                count += (int)pocket[j].Count;
                            }
                        }
                        if (count > 0)
                        {
                            AddListViewItem(i, pocket.PocketType, ItemDatabase.GetPocketName(pocket.PocketType), count);
                        }
                    }
                    if (gameSave.Inventory.Items.ContainsPocket(SelectedItemData.PocketType))
                    {
                        pocket = gameSave.Inventory.Items[SelectedItemData.PocketType];
                        count  = 0;
                        for (int j = 0; j < pocket.SlotsUsed; j++)
                        {
                            if (pocket[j].ID == (ushort)selectedItemID)
                            {
                                count += (int)pocket[j].Count;
                            }
                        }
                        if (count > 0)
                        {
                            AddListViewItem(i, pocket.PocketType, ItemDatabase.GetPocketName(pocket.PocketType), count);
                        }
                    }
                    if (SelectedItemData.HasSubPocket && gameSave.Inventory.Items.ContainsPocket(SelectedItemData.SubPocketType))
                    {
                        pocket = gameSave.Inventory.Items[SelectedItemData.SubPocketType];
                        count  = 0;
                        for (int j = 0; j < pocket.SlotsUsed; j++)
                        {
                            if (pocket[j].ID == (ushort)selectedItemID)
                            {
                                count += (int)pocket[j].Count;
                            }
                        }
                        if (count > 0)
                        {
                            AddListViewItem(i, pocket.PocketType, ItemDatabase.GetPocketName(pocket.PocketType), count);
                        }
                    }
                }
            }
            if (!decorationMode)
            {
                pokemonHoldingItem.Clear();
                for (int i = -1; i < PokeManager.NumGameSaves; i++)
                {
                    IGameSave gameSave = PokeManager.GetGameSaveAt(i);

                    if (gameSave is ManagerGameSave)
                    {
                        for (int j = 0; j < (gameSave as ManagerGameSave).NumPokePCRows; j++)
                        {
                            foreach (IPokemon pokemon in (gameSave as ManagerGameSave).GetPokePCRow(j))
                            {
                                if (pokemon.HeldItemID == selectedItemID)
                                {
                                    pokemonHoldingItem.Add(pokemon);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (IPokemon pokemon in gameSave.PokePC)
                        {
                            if (pokemon.HeldItemID == selectedItemID)
                            {
                                pokemonHoldingItem.Add(pokemon);
                            }
                        }
                    }
                }
                if (pokemonHoldingItem.Count > 0)
                {
                    ListViewItem listViewItem = new ListViewItem();
                    listViewItem.Tag = new ItemPocketGameTag(-2);
                    listViewItem.SnapsToDevicePixels = true;
                    listViewItem.UseLayoutRounding   = true;
                    DockPanel dockPanel = new DockPanel();
                    dockPanel.Width = 250;


                    TextBlock itemPocket = new TextBlock();
                    itemPocket.VerticalAlignment = VerticalAlignment.Center;
                    itemPocket.Text     = "Holding Pokémon";
                    itemPocket.MinWidth = 10;

                    TextBlock itemX = new TextBlock();
                    itemX.VerticalAlignment   = VerticalAlignment.Center;
                    itemX.HorizontalAlignment = HorizontalAlignment.Right;
                    itemX.TextAlignment       = TextAlignment.Right;
                    itemX.Text     = "x";
                    itemX.MinWidth = 10;

                    TextBlock itemCount = new TextBlock();
                    itemCount.VerticalAlignment   = VerticalAlignment.Center;
                    itemCount.HorizontalAlignment = HorizontalAlignment.Right;
                    itemCount.TextAlignment       = TextAlignment.Right;
                    itemCount.Width = 30;
                    itemCount.Text  = pokemonHoldingItem.Count.ToString();

                    listViewItem.Content = dockPanel;
                    dockPanel.Children.Add(itemCount);
                    dockPanel.Children.Add(itemX);
                    dockPanel.Children.Add(itemPocket);

                    DockPanel.SetDock(itemX, Dock.Right);
                    DockPanel.SetDock(itemCount, Dock.Right);
                    DockPanel.SetDock(itemPocket, Dock.Left);

                    Separator separator = new Separator();
                    separator.Height      = 7;
                    separator.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
                    listViewResults.Items.Add(separator);

                    listViewResults.Items.Add(listViewItem);
                }
            }
            buttonSeeResults.IsEnabled = false;
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        private void FillListViewItems()
        {
            listViewDecorations.Items.Clear();

            /*for (byte i = 0; i < pocket.SlotsUsed; i++) {
             *      int countLeft = (int)pocket[i].Count;
             *      if (pocket.MaxStackSize == 0) {
             *              foreach (PlacedDecoration decoration in secretBase.PlacedDecorations) {
             *                      if (decoration.ID == pocket[i].ID)
             *                              countLeft--;
             *              }
             *              if (countLeft <= 0)
             *                      continue;
             *      }
             *      else {
             *              if (pocket.Inventory.IsDecorationInUse(i, pocket.PocketType))
             *                      continue;
             *      }
             *      AddDecorationListViewItem(pocket[i], countLeft);
             * }*/
            if (pocket.MaxStackSize == 0)
            {
                List <int> decorations = new List <int>();
                for (int i = 0; i <= 120; i++)
                {
                    decorations.Add(0);
                }
                for (int i = -1; i < PokeManager.NumGameSaves; i++)
                {
                    IGameSave gameSave = PokeManager.GetGameSaveAt(i);
                    if (gameSave.Inventory != null && gameSave.Inventory.Decorations != null)
                    {
                        DecorationPocket newPocket = gameSave.Inventory.Decorations[pocket.PocketType];
                        for (int j = 0; j < newPocket.SlotsUsed; j++)
                        {
                            if (gameSave.Inventory.Decorations.IsDecorationInUse(j, pocket.PocketType))
                            {
                                continue;
                            }
                            decorations[newPocket[j].ID] += (int)newPocket[j].Count;
                        }
                    }
                }
                for (int i = 1; i <= 120; i++)
                {
                    if (decorations[i] == 0)
                    {
                        continue;
                    }
                    int countLeft = decorations[i];
                    foreach (PlacedDecoration decoration in secretBase.PlacedDecorations)
                    {
                        if (decoration.ID == i)
                        {
                            countLeft--;
                        }
                    }
                    if (countLeft <= 0)
                    {
                        continue;
                    }
                    AddDecorationListViewItem(new Decoration((byte)i, (uint)decorations[i], null), countLeft);
                }
            }
            else
            {
                for (byte i = 0; i < pocket.SlotsUsed; i++)
                {
                    if (pocket.Inventory.IsDecorationInUse(i, pocket.PocketType))
                    {
                        continue;
                    }
                    AddDecorationListViewItem(pocket[i]);
                }
            }
        }