示例#1
0
        public void Do(Action act)
        {
            if (act.cancel)
            {
                return;
            }

            //First do the action. Only the *new* action
            act.SetEdControl(EdControl);
            act.Redo();
            act.AfterAction();
            EdControl.mode.Refresh();

            //Then save the done action. Merge with previous actions if needed.
            bool merged = false;

            //Determine if the actions should be merged
            if (merge && UActions.Count > 0 && UActions.Peek().CanMerge&& UActions.Peek().GetType().Equals(act.GetType()))
            {
                Action pAct = UActions.Peek();
                if (pAct is LvlItemAction && act is LvlItemAction && !equalLists((pAct as LvlItemAction).objs, (act as LvlItemAction).objs))
                {
                    merged = false;
                }
                else
                {
                    merged = pAct.Merge(act);
                }
            }

            //If we didn't merge the action we need to save the new action.
            if (!merged)
            {
                UActions.Push(act);
                ToolStripMenuItem item = new ToolStripMenuItem(act.ToString());
                item.MouseEnter += new EventHandler(updateActCount);
                item.Click      += new EventHandler(onUndoActions);
                undo.DropDownItems.Insert(0, item);
            }

            //Clear the redo buffer because we just did a new action.
            if (redo.DropDownItems.Count > 0)
            {
                redo.DropDownItems.Clear();
                RActions.Clear();
            }

            //Always after doing an action.
            EdControl.repaint();

            //Now set some flags.
            undo.Enabled = true;
            redo.Enabled = false;

            merge = true;
            dirty = true;
        }
示例#2
0
        public void Do(Action act, bool select = false)
        {
            if (act.cancel)
            {
                return;
            }

            //First do the action. Only the *new* action
            act.SetEdControl(EdControl);
            act.Redo();

            if (select)
            {
                act.AfterAction();
            }

            EdControl.mode.Refresh();

            //Then save the done action. Merge with previous actions if needed.
            //Determine if the actions should be merged
            if (merge && UActions.Count > 0 && UActions.Peek().CanMerge(act))
            {
                UActions.Peek().Merge(act);
            }
            else
            {
                UActions.Push(act);
                ToolStripMenuItem item = new ToolStripMenuItem(act.ToString());
                item.MouseEnter += new EventHandler(updateActCount);
                item.Click      += new EventHandler(onUndoActions);
                undo.DropDownItems.Insert(0, item);
            }

            //Clear the redo buffer because we just did a new action.
            if (redo.DropDownItems.Count > 0)
            {
                redo.DropDownItems.Clear();
                RActions.Clear();
            }

            //Always after doing an action.
            EdControl.repaint();
            EdControl.GiveFocus();

            //Now set some flags.
            undo.Enabled = true;
            redo.Enabled = false;

            merge = true;
            dirty = true;
        }
示例#3
0
        private void sprSelectAll_Click(object sender, EventArgs e)
        {
            List <LevelItem> sprites = new List <LevelItem>();

            foreach (NSMBSprite s in EdControl.Level.Sprites)
            {
                if (s.Type == SpriteNumber.Value)
                {
                    sprites.Add(s);
                }
            }
            EdControl.SelectObject(sprites);
            EdControl.ScrollToObjects(sprites);
            EdControl.repaint();
        }
示例#4
0
        private void entranceListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DataUpdateFlag)
            {
                return;
            }
            DataUpdateFlag = true;
            List <LevelItem> ents = new List <LevelItem>();

            for (int l = 0; l < entranceListBox.SelectedIndices.Count; l++)
            {
                ents.Add(EdControl.Level.Entrances[entranceListBox.SelectedIndices[l]]);
            }
            if (ents.Count == 0)
            {
                EdControl.SelectObject(null);
            }
            else
            {
                EdControl.SelectObject(ents);
                EdControl.ScrollToObjects(ents);
            }
            DataUpdateFlag = false;
            EdControl.repaint();
        }
示例#5
0
        private void viewsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DataUpdateFlag)
            {
                return;
            }
            DataUpdateFlag = true;
            List <LevelItem> views = new List <LevelItem>();

            for (int l = 0; l < viewsList.SelectedIndices.Count; l++)
            {
                views.Add(lst[viewsList.SelectedIndices[l]]);
            }
            if (views.Count == 0)
            {
                EdControl.SelectObject(null);
            }
            else
            {
                EdControl.SelectObject(views);
                EdControl.ScrollToObjects(views);
            }
            DataUpdateFlag = false;
            EdControl.repaint();
        }
示例#6
0
        private void pathsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DataUpdateFlag)
            {
                return;
            }
            DataUpdateFlag = true;
            List <LevelItem> pts = new List <LevelItem>();

            for (int l = 0; l < pathsList.SelectedIndices.Count; l++)
            {
                foreach (NSMBPathPoint pp in lst[pathsList.SelectedIndices[l]].points)
                {
                    pts.Add(pp);
                }
            }
            if (pts.Count == 0)
            {
                EdControl.SelectObject(null);
            }
            else
            {
                EdControl.SelectObject(pts);
                EdControl.ScrollToObjects(pts);
            }
            DataUpdateFlag = false;
            EdControl.repaint();
        }