Example #1
0
        }   // end of Copy()

        /// <summary>
        /// Paste the contents of the cut/paste buffer into the brain.
        /// </summary>
        public void Paste()
        {
            // Anything there?
            if (ReflexPanel.CutPasteBuffer == null || ReflexPanel.CutPasteBuffer.Count == 0)
            {
                return;
            }

            // We want to paste the reflexs bottom up into the current position.  This
            // moves the current reflex and any subsequent ones down.

            Editor      editor = InGame.inGame.Editor;
            ReflexPanel panel  = editor.ActivePanel;

            for (int i = ReflexPanel.CutPasteBuffer.Count - 1; i >= 0; i--)
            {
                panel.InsertReflex();

                // The newly inserted panel should have become the active one.
                panel = editor.ActivePanel;

                // Paste the cut/paste code into this new panel and tell it to rebuild.
                panel.Reflex.Paste(ReflexPanel.CutPasteBuffer[i]);
                panel.AnimatePanelIndent(true);
                panel.uiRebuild = true;
            }

            // Update block with info from cut/paste buffer.
            Size           = ReflexPanel.CutPasteBuffer.Count;
            OriginalIndent = ReflexPanel.CutPasteBuffer[0].Indentation;

            // Ensure indent is correct.
            ValidateIndent();
        }   // end of Paste()
Example #2
0
            public UpdateObjEditCards(ReflexPanel parent /*, ref Shared shared*/)
            {
                this.parent = parent;
                commandMap  = new CommandMap(@"ReflexPanel");

                updateList = new List <UpdateObject>();
            }
Example #3
0
        }   // end of MoveDown()

        /// <summary>
        /// Put a reflex and its children into "moving" mode.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void MoveReflex(Object sender, EventArgs args)
        {
            Foley.PlayPressA();

            // Init the Moving block.
            ReflexPanel panel    = this.parent as ReflexPanel;
            int         curIndex = panel.LineNumber - 1;

            reflexBlock.Init(curIndex);
            reflexBlock.Moving = true;

            UiCursor.ActiveCursor.Parent = this;

            // switch modes
            this.updateObjPending = this.updateObjMoveReflex;
            this.renderObj.State  = ControlRenderObj.idStateSelected;
            AffixLineNumberToCurrentState();
            BokuGame.objectListDirty = true;
        }   // end of MoveReflex()
Example #4
0
        }   // end of MoveDown()

        /// <summary>
        /// Exchanges the position of 2 blocks of reflexes in the current task.
        /// Also aniamtes the UI.
        /// Assumes that the camera should end up looking at b0
        /// </summary>
        /// <param name="b0"></param>
        /// <param name="b1"></param>
        public void SwapBlocks(ReflexBlock b0, ReflexBlock b1)
        {
            List <ReflexPanel> panels = InGame.inGame.Editor.ActivePanels;
            Task task = panels[0].Reflex.Task;

            // Why isn't this a constant somewhere???
            float heightPanel = panels[0].BoundingBox.Max.Y - panels[0].BoundingBox.Min.Y;

            // How far to move b0's panels.
            int steps0 = b0.Index < b1.Index ? b1.Size : -b1.Size;

            for (int i = b0.Index; i < b0.Index + b0.Size; i++)
            {
                panels[i].AnimatePanelMove(-steps0 * heightPanel);
            }

            // Move the camera the same amount.
            InGame.inGame.Editor.MoveCamera(-steps0 * heightPanel);

            // Move b1's panels.
            int steps1 = b1.Index < b0.Index ? b0.Size : -b0.Size;

            for (int i = b1.Index; i < b1.Index + b1.Size; i++)
            {
                panels[i].AnimatePanelMove(-steps1 * heightPanel);
            }

            /*
             * Debug.Print("before");
             * Debug.Print("panels");
             * for (int i = 0; i < panels.Count; i++)
             * {
             *  Debug.Print(panels[i].UniqueNum.ToString() + " " + panels[i].LineNumber.ToString());
             * }
             * Debug.Print("reflexes");
             * for (int i = 0; i < task.reflexes.Count; i++)
             * {
             *  Debug.Print(((Reflex)task.reflexes[i]).UniqueNum.ToString());
             * }
             */

            // Now actually swap the panels.  Copy the panel refs to
            // an array and then copy them back in their new position.
            ReflexPanel[] panelArray = new ReflexPanel[panels.Count];
            panels.CopyTo(panelArray);

            // b0's elements
            for (int i = 0; i < b0.Size; i++)
            {
                panels[b0.Index + i + steps0] = panelArray[b0.Index + i];
            }
            // b1's elements
            for (int i = 0; i < b1.Size; i++)
            {
                panels[b1.Index + i + steps1] = panelArray[b1.Index + i];
            }

            // Now do the same for the reflexes.
            Reflex[] reflexArray = new Reflex[task.reflexes.Count];
            task.reflexes.CopyTo(reflexArray);

            // b0's elements
            for (int i = 0; i < b0.Size; i++)
            {
                task.reflexes[b0.Index + i + steps0] = reflexArray[b0.Index + i];
            }
            // b1's elements
            for (int i = 0; i < b1.Size; i++)
            {
                task.reflexes[b1.Index + i + steps1] = reflexArray[b1.Index + i];
            }

            // Update line numbers.
            for (int i = 0; i < panels.Count; i++)
            {
                panels[i].LineNumber = i + 1;
            }

            // Hack mode...
            // In the rendering of the editor we need to keep the order of the reflexes
            // in sync.  This is so the mouse hit testing can know which reflex it is
            // hitting.  So, reorder the elements in the renderobject also.
            // Without doing this, what happens is that the reflexes in the panel
            // and reflex arrays (already 1 too many) are reordered but the render list
            // isn't.  When the mouse hit testing finds a hit it has no way to associate
            // that with the actual reflex being hit so we have to rely on its index
            // in the renderlist.  Hence the need to keep them in sync and a warning to
            // future generations that overly aggressive abstraction will come back to bite you.

            List <RenderObject> rlist = InGame.inGame.Editor.renderObj.renderList;

            RenderObject[] rArray = new RenderObject[rlist.Count];
            rlist.CopyTo(rArray);

            // b0's elements
            for (int i = 0; i < b0.Size; i++)
            {
                rlist[b0.Index + i + steps0] = rArray[b0.Index + i];
            }
            // b1's elements
            for (int i = 0; i < b1.Size; i++)
            {
                rlist[b1.Index + i + steps1] = rArray[b1.Index + i];
            }


            /*
             * Debug.Print("before");
             * Debug.Print("panels");
             * for (int i = 0; i < panels.Count; i++)
             * {
             *  Debug.Print(panels[i].UniqueNum.ToString() + " " + panels[i].LineNumber.ToString());
             * }
             * Debug.Print("reflexes");
             * for (int i = 0; i < task.reflexes.Count; i++)
             * {
             *  Debug.Print(((Reflex)task.reflexes[i]).UniqueNum.ToString());
             * }
             */

            // Update the active panel to stil point to the same reflex.
            InGame.inGame.Editor.IndexActivePanel = b0.Index + steps0;

            // Update the values in the blocks.
            b0.Index += steps0;
            b1.Index += steps1;
        }   // end of SwapBlocks()
Example #5
0
        public void RemoveReflex(Object sender, EventArgs args)
        {
            ReflexPanel parentPanel = this.parent as ReflexPanel;

            parentPanel.RemoveReflex();
        }
Example #6
0
        }   // end of MoveReflex()

        public void InsertReflex(Object sender, EventArgs args)
        {
            ReflexPanel parentPanel = this.parent as ReflexPanel;

            parentPanel.InsertReflex();
        }