Exemple #1
0
        private void UpdateToSelectedAnimationTextureFile(ToolsUtilities.FilePath selectedFilePath, bool skipPushed = false)
        {
            var fileName = selectedFilePath?.Standardized;

            if (!string.IsNullOrEmpty(fileName))
            {
                Texture2D texture = GetTextureFromFile(fileName);
                Texture = texture;

                ShowSpriteOutlineForTexture(Texture);
                UpdateLineGridToTexture(Texture);



                string folder = null;
                bool   doAnyFramesUseThisTexture = false;

                if (SelectedState.Self.AnimationChainListSave != null && SelectedState.Self.SelectedChain != null)
                {
                    folder = FlatRedBall.IO.FileManager.GetDirectory(SelectedState.Self.AnimationChainListSave.FileName);

                    doAnyFramesUseThisTexture =
                        SelectedState.Self.SelectedChain.Frames.Any(item => new ToolsUtilities.FilePath(folder + item.TextureName) == selectedFilePath);
                }



                if (doAnyFramesUseThisTexture && texture != null)
                {
                    UpdateSelectorsToAnimation(skipPushed, texture);
                }
                else
                {
                    mControl.DesiredSelectorCount = 0;
                }
            }
            else
            {
                Texture = null;
                mControl.DesiredSelectorCount = 0;

                ShowSpriteOutlineForTexture(Texture);
                UpdateLineGridToTexture(Texture);
            }

            // Do we need to check if it's changed?
            //if (Texture != textureBefore)
            {
                ApplicationEvents.Self.CallWireframeTextureChange();
            }
        }
Exemple #2
0
        private void UpdateSelectorsToAnimation(bool skipUpdatingRectangleSelector, Texture2D texture)
        {
            string folder          = FlatRedBall.IO.FileManager.GetDirectory(SelectedState.Self.AnimationChainListSave.FileName);
            var    textureFilePath = new ToolsUtilities.FilePath(texture.Name);

            var framesOnThisTexture = SelectedState.Self.SelectedChain.Frames
                                      .Where(item => new ToolsUtilities.FilePath(folder + item.TextureName) == textureFilePath)
                                      .ToList();

            mControl.DesiredSelectorCount = framesOnThisTexture.Count;

            foreach (var selector in mControl.RectangleSelectors)
            {
                // We'll do it ourselves, to consider hotkeys
                selector.AutoSetsCursor = false;
            }

            for (int i = 0; i < framesOnThisTexture.Count; i++)
            {
                var frame = framesOnThisTexture[i];

                var rectangleSelector = mControl.RectangleSelectors[i];
                if (skipUpdatingRectangleSelector == false || rectangleSelector != mPushedRegion)
                {
                    bool hasAlreadyBeenInitialized = rectangleSelector.Tag != null;
                    UpdateRectangleSelectorToFrame(frame, texture, mControl.RectangleSelectors[i]);
                    rectangleSelector.ShowHandles = false;

                    rectangleSelector.Tag = frame;

                    if (!hasAlreadyBeenInitialized)
                    {
                        rectangleSelector.ShowHandles             = false;
                        rectangleSelector.RoundToUnitCoordinates  = true;
                        rectangleSelector.AllowMoveWithoutHandles = true;
                        rectangleSelector.Pushed += HandleRegionPushed;
                        // Only the first cursor will reset back to the arrow, otherwise the others shouldn't
                        rectangleSelector.ResetsCursorIfNotOver = i == 0;
                    }
                }
            }
        }