Exemplo n.º 1
0
        public void ShowAddNewEntityDialog()
        {
            // search:  addentity, add entity
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to create or load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    AddEntityWindow window = new Controls.AddEntityWindow();
                    window.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;

                    double width = window.Width;
                    if (double.IsNaN(width))
                    {
                        width = 0;
                    }
                    double height = window.Height;
                    if (double.IsNaN(height))
                    {
                        height = 0;
                    }

                    window.Left = MainGlueWindow.MousePosition.X - width / 2;
                    window.Top  = MainGlueWindow.MousePosition.Y - height / 2;

                    PluginManager.ModifyAddEntityWindow(window);

                    var result = window.ShowDialog();

                    if (result == true)
                    {
                        string entityName = window.EnteredText;

                        string whyIsntValid;

                        if (!NameVerifier.IsEntityNameValid(entityName, null, out whyIsntValid))
                        {
                            MessageBox.Show(whyIsntValid);
                        }
                        else
                        {
                            string directory = "";

                            if (EditorLogic.CurrentTreeNode.IsDirectoryNode())
                            {
                                directory = EditorLogic.CurrentTreeNode.GetRelativePath();
                                directory = directory.Replace('/', '\\');
                            }
                            var entity = CreateEntityAndObjects(window, entityName, directory);

                            PluginManager.ReactToNewEntityCreated(entity, window);
                        }
                    }
                }
            }
        }
        public void HandleCreateEntityClick(object sender, EventArgs e)
        {
            if (AppState.Self.CurrentMapTilesetTile == null)
            {
                MessageBox.Show("You must first select a tile");
                return;
            }

            TextInputWindow           tiw;
            ControlForAddingCollision collisionControl;
            DialogResult result;

            AskToCreateEntity(out tiw, out collisionControl, out result);

            if (result == DialogResult.OK)
            {
                string entityName = tiw.Result;

                string whyItIsntValid;
                if (NameVerifier.IsEntityNameValid(entityName, null, out whyItIsntValid) == false)
                {
                    MessageBox.Show(whyItIsntValid);
                }
                else
                {
                    var newEntity = GlueCommands.Self.GluxCommands.EntityCommands.AddEntity(
                        entityName, is2D: true);
                    // Give it a factory so that instances can automatically be added
                    newEntity.CreatedByOtherEntities = true;

                    ReferencedFileSave rfs = CreateReferencedFileSave();
                    newEntity.ReferencedFiles.Add(rfs);

                    NamedObjectSave nos = CreateSpriteNamedObject(rfs);
                    newEntity.NamedObjects.Add(nos);

                    if (collisionControl.HasCollision)
                    {
                        NamedObjectSave collisionNos = CreateCollisionNamedObject(
                            collisionControl.CircleSelected, collisionControl.RectangleSelected);
                        newEntity.NamedObjects.Add(collisionNos);
                    }

                    AddNamePropertyToTile(entityName);

                    GlueCommands.Self.GluxCommands.SaveGlux();
                    GlueCommands.Self.UpdateCommands.Update(newEntity);

                    TileGraphicsPluginClass.Self.SaveTiledMapSave(changeType: TmxEditor.Events.ChangeType.Tileset);
                    TileGraphicsPluginClass.Self.UpdateTilesetDisplay();
                }
            }
        }
Exemplo n.º 3
0
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            string whyIsntValid;

            var isValid = NameVerifier.IsEntityNameValid(TextBox.Text, null, out whyIsntValid);

            if (isValid)
            {
                FailureTextBlock.Visibility = Visibility.Collapsed;
            }
            else
            {
                FailureTextBlock.Visibility = Visibility.Visible;
                FailureTextBlock.Text       = whyIsntValid;
            }
        }
Exemplo n.º 4
0
        public void ShowAddNewEntityDialog()
        {
            // search:  addentity, add entity
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to create or load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    AddEntityWindow window = new Controls.AddEntityWindow();

                    PluginManager.ModifyAddEntityWindow(window);

                    var result = window.ShowDialog();

                    if (result == true)
                    {
                        string entityName = window.EnteredText;

                        string whyIsntValid;

                        if (!NameVerifier.IsEntityNameValid(entityName, null, out whyIsntValid))
                        {
                            MessageBox.Show(whyIsntValid);
                        }
                        else
                        {
                            string directory = "";

                            if (EditorLogic.CurrentTreeNode.IsDirectoryNode())
                            {
                                directory = EditorLogic.CurrentTreeNode.GetRelativePath();
                                directory = directory.Replace('/', '\\');
                            }
                            var entity = CreateEntityAndObjects(window, entityName, directory);

                            PluginManager.ReactToNewEntityCreated(entity, window);
                        }
                    }
                }
            }
        }