Ejemplo n.º 1
0
        protected void HandleMemberSet(object sender, MemberChangeArgs args)
        {
            string name  = args.Member;
            object value = args.Value;

            (this.Instance as IElement).Properties.SetValue(name, value);
        }
Ejemplo n.º 2
0
        void TextureNameChange(object sender, MemberChangeArgs args)
        {
            string absoluteFileName = (string)args.Value;
            string achxFolder;

            if (!System.IO.File.Exists(absoluteFileName))
            {
                MessageBox.Show("The file\n" + absoluteFileName + "\ndoesn't exist");
            }
            else
            {
                bool shouldProceed =
                    TryAskToMoveFileRelativeToAnimationChainFile(false, ref absoluteFileName, out achxFolder);

                if (shouldProceed)
                {
                    ShowWarningsForTooBigTextures(absoluteFileName);


                    string relativeFileName = FileManager.MakeRelative(absoluteFileName, achxFolder);

                    AnimationFrameInstance.TextureName = relativeFileName;
                }
            }
        }
        private void ChangeType(object sender, MemberChangeArgs args)
        {
            var customVariable =
                (CustomVariable)args.Owner;

            customVariable.Type = args.Value as string;
        }
Ejemplo n.º 4
0
 void HandleOrthogonalMemberChange(object sender, MemberChangeArgs args)
 {
     // We need to lose focus so we can update the UI immediately
     this.PropertyGrid.Enabled = false;
     UpdateDisplayedProperties(mInstance as Camera);
     UpdateSets();
     this.PropertyGrid.Enabled = true;
 }
        private void AfterTimeSet(object sender, MemberChangeArgs args)
        {
            if (AppState.Self.CurrentSpline != null)
            {
                AppState.Self.CurrentSpline.Sort();
            }

            // Refresh the entire spline because time and ordering may have changed
            AppCommands.Self.Gui.RefreshTreeView(AppState.Self.CurrentSpline);
        }
Ejemplo n.º 6
0
        void HandleTextureChanged(object sender, MemberChangeArgs memberChangeArgs)
        {
            // Justin has reported a bug here.  I don't know what is going on, so I'm going to spit out the error to a message box
            try
            {
                string fullFileName     = memberChangeArgs.Value as string;
                string emitterDirectory = FileManager.GetDirectory(ProjectManager.Self.FileName);

                if (FileManager.IsRelative(fullFileName))
                {
                    // This file is relative.
                    // This means that the user
                    // typed in a value rather than
                    // using the file window.  We should
                    // assume that the file is relative to
                    // the emitter.
                    fullFileName = emitterDirectory + fullFileName;
                }

                if (!FileManager.IsRelativeTo(fullFileName, emitterDirectory))
                {
                    MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
                    mbmb.MessageText = "The selected file:\n\n" + fullFileName + "\n\nis not relative to the Emitter file.  What would you like to do?";

                    mbmb.AddButton("Copy the file to the same folder as the Emitter file", System.Windows.Forms.DialogResult.Yes);
                    mbmb.AddButton("Keep the file where it is (this may limit the portability of the Emitter file)", System.Windows.Forms.DialogResult.No);

                    DialogResult result = mbmb.ShowDialog();

                    if (result == DialogResult.Yes)
                    {
                        string destination = emitterDirectory + FileManager.RemovePath(fullFileName);

                        try
                        {
                            System.IO.File.Copy(fullFileName, destination, true);
                            fullFileName = destination;
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Could not copy the file:\n" + e);
                        }
                    }
                }

                string relativeFileName = FileManager.MakeRelative(fullFileName, emitterDirectory);

                SettingsSaveInstance.Texture = relativeFileName;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Ejemplo n.º 7
0
        void OnFilteringChange(object sender, MemberChangeArgs args)
        {
            bool newValue = (bool)args.Value;

            if (newValue)
            {
                FlatRedBallServices.GraphicsOptions.TextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear;
            }
            else
            {
                FlatRedBallServices.GraphicsOptions.TextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Point;
            }
        }
Ejemplo n.º 8
0
        void HandleAniimationPathChanged(object sender, MemberChangeArgs memberChangeArgs)
        {
            string fullFileName     = memberChangeArgs.Value as string;
            string emitterDirectory = FileManager.GetDirectory(ProjectManager.Self.FileName);

            if (FileManager.IsRelative(fullFileName))
            {
                // This file is relative.
                // This means that the user
                // typed in a value rather than
                // using the file window.  We should
                // assume that the file is relative to
                // the emitter.
                fullFileName = emitterDirectory + fullFileName;
            }
            string relativeFileName = FileManager.MakeRelative(fullFileName, emitterDirectory);

            SettingsSaveInstance.AnimationChains = relativeFileName;
        }
Ejemplo n.º 9
0
        void HandleAfteruseGlobalContentChanged(object sender, MemberChangeArgs args)
        {
            IElement element = Instance as IElement;

            List <IElement> elementsToMakeGlobal = new List <IElement>();

            if (element.UseGlobalContent)
            {
                GetAllElementsReferencedThroughObjectsRecursively(element, elementsToMakeGlobal);

                if (elementsToMakeGlobal.Count != 0)
                {
                    string message = "Setting " + FileManager.RemovePath(element.Name) +
                                     " to use a global content manager will result in the following Entities being " +
                                     " loaded with a global content manager.  What would you like to do?";

                    ListBoxWindow lbw = new ListBoxWindow();
                    lbw.Message = message;

                    foreach (var item in elementsToMakeGlobal)
                    {
                        lbw.AddItem(item);
                    }

                    lbw.ClearButtons();
                    lbw.AddButton("Set all to use global content", System.Windows.Forms.DialogResult.Yes);
                    lbw.AddButton("Nothing - this may result in runtime errors", System.Windows.Forms.DialogResult.No);
                    var result = lbw.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        foreach (IElement toMakeGlobal in elementsToMakeGlobal)
                        {
                            toMakeGlobal.UseGlobalContent = true;
                            GlueCommands.Self.GenerateCodeCommands.GenerateElementCode(toMakeGlobal);
                        }
                    }
                }
            }
        }
        public static void OnMemberChanged(object sender, MemberChangeArgs args)
        {
            CustomVariable variable = args.Owner as CustomVariable;

            object value = args.Value;

            if (GetShouldCustomVariableBeConvertedToType(args, variable))
            {
                var variableRuntimeType = variable.GetRuntimeType();

                value = PropertyValuePair.ConvertStringToType((string)args.Value, variableRuntimeType);
            }

            if (EditorLogic.CurrentEntitySave != null)
            {
                EditorLogic.CurrentEntitySave.SetCustomVariable(EditorLogic.CurrentCustomVariable.Name, value);
            }
            else
            {
                EditorLogic.CurrentScreenSave.SetCustomVariable(EditorLogic.CurrentCustomVariable.Name, value);
            }
        }
Ejemplo n.º 11
0
        public void SetNumberOfTilesWide(object sender, MemberChangeArgs args)
        {
            string asString = (string)args.Value;
            int    valueToSet;

            if (asString.Contains("cells") && SelectedState.Self.SelectedTexture != null)
            {
                asString = asString.Replace(" cells", "");

                int cellsWide = int.Parse(asString);

                valueToSet = SelectedState.Self.SelectedTexture.Width / cellsWide;
            }
            else
            {
                int.TryParse((string)args.Value, out valueToSet);
                //valueToSet = int.Parse((string)args.Value);
            }
            if (TileMapInformation != null)
            {
                TileMapInformation.TileWidth = valueToSet;
            }
        }
Ejemplo n.º 12
0
        public void SetNumberOfTilesTall(object sender, MemberChangeArgs args)
        {
            string asString = (string)args.Value;
            int    valueToSet;

            if (asString.Contains("cells") && SelectedState.Self.SelectedTexture != null)
            {
                asString = asString.Replace(" cells", "");

                int cellsTall = int.Parse(asString);

                valueToSet = SelectedState.Self.SelectedTexture.Height / cellsTall;
            }
            else
            {
                // If it fails that's okay...I think.
                int.TryParse((string)args.Value, out valueToSet);
            }
            if (TileMapInformation != null)
            {
                TileMapInformation.TileHeight = valueToSet;
            }
        }
Ejemplo n.º 13
0
 protected void SetClassName(object sender, MemberChangeArgs args)
 {
     ((IElement)Instance).RenameElement((string)args.Value);
 }
Ejemplo n.º 14
0
        void CoordinateChange(object sender, MemberChangeArgs args)
        {
            AnimationFrameSave frame = Instance as AnimationFrameSave;

            if (mTexture == null)
            {
                // We can't do anything.
            }
            else
            {
                if (args.Member == "X")
                {
                    int oldValue = MathFunctions.RoundToInt(frame.LeftCoordinate * mTexture.Width);
                    int newValue = ((int)args.Value);

                    int   increaseAsInt          = newValue - oldValue;
                    float increaseAsTextureCoord = increaseAsInt / (float)mTexture.Width;

                    // Users expect the entire frame to shift, so we want to shift the right coordinates too.
                    frame.LeftCoordinate  += increaseAsTextureCoord;
                    frame.RightCoordinate += increaseAsTextureCoord;

                    SetForPixelCoordinates(ref frame.LeftCoordinate, mTexture.Width);
                    SetForPixelCoordinates(ref frame.RightCoordinate, mTexture.Width);
                }
                else if (args.Member == "Y")
                {
                    int oldValue = MathFunctions.RoundToInt(frame.TopCoordinate * mTexture.Height);
                    int newValue = ((int)args.Value);

                    int   increaseAsInt          = newValue - oldValue;
                    float increaseAsTextureCoord = increaseAsInt / (float)mTexture.Height;



                    frame.TopCoordinate    += increaseAsTextureCoord;
                    frame.BottomCoordinate += increaseAsTextureCoord;

                    SetForPixelCoordinates(ref frame.TopCoordinate, mTexture.Height);
                    SetForPixelCoordinates(ref frame.BottomCoordinate, mTexture.Height);
                }
                else if (args.Member == "Width")
                {
                    float widthInCoords = ((int)args.Value) / (float)mTexture.Width;
                    frame.RightCoordinate = frame.LeftCoordinate + widthInCoords;
                }
                else if (args.Member == "Height")
                {
                    float heightInCoords = ((int)args.Value) / (float)mTexture.Height;
                    frame.BottomCoordinate = frame.TopCoordinate + heightInCoords;
                }
                else if (args.Member == "TileX")
                {
                    int valueAsInt = (int)args.Value;
                    SetTileX(frame, valueAsInt);
                }
                else if (args.Member == "TileY")
                {
                    int valueAsInt = (int)args.Value;
                    SetTileY(frame, valueAsInt);
                }
            }
        }
 void SetProjectSpecificFiles(object sender, MemberChangeArgs args)
 {
     // do nothing
 }
        public static bool GetShouldCustomVariableBeConvertedToType(MemberChangeArgs args, CustomVariable variable)
        {
            var runtimeType = variable.GetRuntimeType();

            return(runtimeType != null && args.Value is string && !variable.GetIsFile() && variable.Type != "Color");
        }
Ejemplo n.º 17
0
 void AfterNameSet(object sender, MemberChangeArgs args)
 {
     AppCommands.Self.Gui.RefreshTreeView();
 }
Ejemplo n.º 18
0
 private void SetRelativeY(object sender, MemberChangeArgs args)
 {
     AnimationFrameInstance.RelativeY = (float)args.Value / PreviewManager.Self.OffsetMultiplier;
 }