Exemple #1
0
        private void SceneTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            suppressSelectionEvents = true;

            selection.Clear();

            // match our editor selection to our tree
            foreach (TreeNode selectedNode in sceneTreeView.SelectedNodes)
            {
                // figure out which kind of node we are by looking at the immediate parent.
                if (selectedNode == sceneTreeView.TopNode)
                {
                    continue;
                }
                if (selectedNode == levelItemNode || selectedNode == deathZoneNode ||
                    selectedNode == setNode || selectedNode == camNode ||
                    selectedNode == missionSETNode || selectedNode == splineNode)
                {
                    continue;
                }

                Item _item = GetItemForNode(selectedNode);
                selection.Add(_item);                 // todo: need to find a way to suppress
                // selection update events to prevent this from going crazy
            }

            suppressSelectionEvents = false;
        }
        private void SceneTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            suppressSelectionEvents = true;

            // Find items that were in the selection but are no longer selected
            List <Item> removeitems = new List <Item>();

            foreach (Item olditem in selection.Items)
            {
                bool found = false;
                foreach (TreeNode selectedNode in sceneTreeView.SelectedNodes)
                {
                    Item _item = GetItemForNode(selectedNode);
                    if (olditem == _item)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    removeitems.Add(olditem);
                }
            }

            // Remove items that are no longer selected
            foreach (Item remove in removeitems)
            {
                selection.Remove(remove);
            }

            // Add items that weren't selected previously
            foreach (TreeNode selectedNode in sceneTreeView.SelectedNodes)
            {
                // figure out which kind of node we are by looking at the immediate parent.
                Item _item = GetItemForNode(selectedNode);
                if (selectedNode == sceneTreeView.TopNode)
                {
                    continue;
                }
                if (selectedNode == levelItemNode || selectedNode == deathZoneNode ||
                    selectedNode == setNode || selectedNode == camNode ||
                    selectedNode == missionSETNode || selectedNode == splineNode)
                {
                    continue;
                }

                if (!selection.Contains(_item))
                {
                    selection.Add(_item);
                }
            }

            suppressSelectionEvents = false;
        }
Exemple #3
0
        public static void DuplicateSelection(Device d3ddevice, EditorItemSelection selection, out bool errorFlag, out string errorMsg)
        {
            if (selection.ItemCount < 0) { errorFlag = true; errorMsg = "Negative selection count... what did you do?!?"; return; }

            List<Item> newItems = new List<Item>();
            List<Item> currentItems = selection.GetSelection();

            // duplicate goes here
            for (int i = 0; i < selection.ItemCount; i++)
            {
                if (currentItems[i] is SETItem)
                {
                    SETItem originalItem = (SETItem)currentItems[i];
                    SETItem newItem = new SETItem(originalItem.GetBytes(), 0, selection);

                    SETItems[Character].Add(newItem);
                    newItems.Add(newItem);
                }
                else if (currentItems[i] is LevelItem)
                {
                    LevelItem originalItem = (LevelItem)currentItems[0];
                    LevelItem newItem = new LevelItem(d3ddevice, originalItem.CollisionData.Model.Attach, originalItem.Position, originalItem.Rotation, LevelItems.Count, selection);

                    newItem.CollisionData.SurfaceFlags = originalItem.CollisionData.SurfaceFlags;
                    newItems.Add(newItem);
                }
                else if (currentItems[i] is CAMItem)
                {
                    CAMItem originalItem = (CAMItem)currentItems[i];
                    CAMItem newItem = new CAMItem(originalItem.GetBytes(), 0, selection);

                    CAMItems[Character].Add(newItem);
                    newItems.Add(newItem);
                }
            }

            selection.Clear();
            selection.Add(newItems);

            InvalidateRenderState();

            errorFlag = false;
            errorMsg = "";
        }