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 Decoration(byte id, uint count, DecorationPocket container)
 {
     this.pocket = container;
     this.id     = id;
     this.count  = count;
 }
        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();
        }