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();
            }
        }
Ejemplo n.º 2
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);
        }
        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();
        }