Exemplo n.º 1
0
        public override void Update(GameTime gameTime, InputManager inputManager)
        {
            if (inputManager.mouseWheelDown)
            {
                fontSize = MathHelper.Clamp(fontSize - 0.3f, 0.1f, 2.0f);
            }
            else if (inputManager.mouseWheelUp)
            {
                fontSize = MathHelper.Clamp(fontSize + 0.3f, 0.1f, 2.0f);
            }

            if (inputManager.mouseRightHeld)
            {
                if (inputManager.mouseRightStartHold)
                {
                    evDebugRightClickOffset = inputManager.mousePos - evDebugPos;
                }

                if (inputManager.mouseHasMoved)
                {
                    evDebugPos = inputManager.mousePos - evDebugRightClickOffset;
                }
            }

            if (inputManager.mouseLeftHeld)
            {
                if (inputManager.mouseLeftStartHold)
                {
                    selectedNode = SelectNearestNode(inputManager.mousePos);

                    if (selectedNode != null)
                    {
                        evDebugLeftClickOffset = inputManager.mousePos - selectedNode.pos;
                    }
                }

                if (inputManager.mouseHasMoved && selectedNode != null)
                {
                    selectedNode.pos = inputManager.mousePos - evDebugLeftClickOffset;
                }
            }
            else
            {
                if (selectedNode != null)
                {
                    selectedNode = null;
                }
            }


            base.Update(gameTime, inputManager);
        }
Exemplo n.º 2
0
        public DebugEventsMenu()
        {
            evDebugNodes = new List <evDebugNode>();

            List <string> directories = new List <string>();
            string        dir         = Directory.GetCurrentDirectory() + "../../../../Events/";

            fileListing(directories, dir);

            foreach (string fullpath in directories)
            {
                string output = "";

                evDebugNode evNode = new evDebugNode();
                evNode.functionNames = new List <string>();
                evNode.unlockLinks   = new List <linkString>();
                evNode.keyLinks      = new List <linkString>();

                using (FileStream stream = File.Open(fullpath, FileMode.Open, FileAccess.Read))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        //dump file content into a string.
                        output = reader.ReadToEnd();
                    }
                }

                //class name.
                int    idx  = 0;
                int    fIdx = 0;
                string tmp  = Helpers.GetSubString(output, "public class", ":", out idx, out fIdx);
                if (tmp != null)
                {
                    evNode.fileName = tmp;
                    output          = output.Remove(0, idx);
                }

                ParseStrings(output, evNode, "UnlockEvent(new", "(", linkType.unlockLink);
                ParseStrings(output, evNode, "AddKey(typeof(", ")", linkType.keyLink);
                ParseStrings(output, evNode, "void", "(", linkType.voidLink);

                evDebugNodes.Add(evNode);
            }

            AddLinks();

            UpdateNodePositions();
        }
Exemplo n.º 3
0
        private evDebugNode SelectNearestNode(Vector2 mousePos)
        {
            int         nearestDist = int.MaxValue;
            evDebugNode nearestNode = null;

            foreach (evDebugNode node in evDebugNodes)
            {
                int curDist = (int)Vector2.Distance(node.pos + evDebugPos, mousePos);
                if (curDist < 192 && curDist < nearestDist)
                {
                    nearestDist = curDist;
                    nearestNode = node;
                }
            }

            return(nearestNode);
        }
Exemplo n.º 4
0
        private void ParseStrings(string output, evDebugNode evNode, string strStart, string strEnd, linkType LinkType)
        {
            bool   check      = true;
            string tempOutput = output;

            int totalIndex = 0;

            while (check == true)
            {
                int index = 0;
                int fIdx  = 0;

                string tempString = Helpers.GetSubString(tempOutput, strStart, strEnd, out index, out fIdx);
                if (tempString != null)
                {
                    if (LinkType == linkType.unlockLink)
                    {
                        linkString link = new linkString();
                        link.linkname = tempString;
                        link.funcNum  = GetFuncNum(output, index + totalIndex);
                        evNode.unlockLinks.Add(link);
                    }
                    else if (LinkType == linkType.keyLink)
                    {
                        linkString link = new linkString();
                        link.linkname = tempString;
                        link.funcNum  = GetFuncNum(output, index + totalIndex);
                        evNode.keyLinks.Add(link);
                    }
                    else if (LinkType == linkType.voidLink)
                    {
                        evNode.functionNames.Add(tempString);
                    }

                    totalIndex += index;

                    //chop off all text above the current index position.
                    tempOutput = tempOutput.Remove(0, index);
                    continue;
                }

                check = false;
            }
        }