Example #1
0
        // just simple validation here
        private bool IsNodeValid(Nodes.NodeRow node)
        {
            if (!node.IsFlagNull() && node.Flag == "3")
            {
                if (node.IsEntityNull() || node.Entity == "1023")
                {
                    MessageBox.Show(this.ParentForm, "Node " + node.ID + " is a Flag node and must have an entity number.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            // TODO: this will have to check the aiscript for node_connect X Y [true|false]
            //       if / when aiscripts are handled, we can add this back.

            /*
             * if (
             *      (node.IsConnection1Null() || node.Connection1 == "-1")
             *      &&
             *      (node.IsConnection2Null() || node.Connection2 == "-1")
             *      &&
             *      (node.IsConnection3Null() || node.Connection3 == "-1")
             *      &&
             *      (node.IsConnection4Null() || node.Connection4 == "-1")
             *      )
             * {
             *      MessageBox.Show(this.ParentForm, "Node " + node.ID + " has no connections.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *      return false;
             * }
             */

            return(true);
        }
Example #2
0
        private bool PrintNodes(Graphics g)
        {
            _pageCounter++;

            _currentX = _pageMarginLeft;
            int height = 20;

            for (int i = _currentRow; i < _nodes.Node.Rows.Count; i++)
            {
                for (int j = 0; j < _nodes.Node.Columns.Count; j++)
                {
                    DataColumn column = _nodes.Node.Columns[j];
                    int        width  = GetColumnWidth(column);

                    g.FillRectangle(new SolidBrush(Color.White), _currentX, _currentY, width, height);
                    g.DrawRectangle(new Pen(Color.Black), _currentX, _currentY, width, height);

                    Nodes.NodeRow row = (Nodes.NodeRow)_nodes.Node.Rows[_currentRow];
                    object        obj = row[column];
                    string        val = obj == null ? "" : obj.ToString();

                    g.DrawString(GetValueString(column, val), _font, new SolidBrush(Color.Black), new RectangleF(_currentX, _currentY, width, height));

                    //next cell
                    _currentX += width;
                }

                _currentX = _pageMarginLeft;

                //advance to next row
                _currentY = _currentY + height;
                _currentRow++;

                //if portrait is selected
                if ((_currentY > _pageHeight - _pageMarginBottom) && (!_pageLandscape))
                {
                    _currentY = _pageMarginTop;
                    _currentX = _pageMarginLeft;
                    return(true);
                }

                //if landscape is selected
                if ((_currentY > _pageWidth - _pageMarginRight) && (_pageLandscape))
                {
                    _currentY = _pageMarginTop;
                    _currentX = _pageMarginLeft;
                    return(true);
                }
            }

            _currentRow = 0;
            _currentY   = _pageMarginTop;
            _currentX   = _pageMarginLeft;

            return(false);
        }
Example #3
0
 public void FromNodeRow(Nodes.NodeRow nodeRow)
 {
     if (!nodeRow.IsIDNull())
     {
         ID = Convert.ToInt32(nodeRow.ID);
     }
     if (!nodeRow.IsEntityNull())
     {
         Entity = Convert.ToInt32(nodeRow.Entity);
     }
     if (!nodeRow.IsRadiusNull())
     {
         Radius = Convert.ToInt32(nodeRow.Radius);
     }
     if (!nodeRow.IsFlagNull())
     {
         Flags = Convert.ToInt32(nodeRow.Flag);
     }
     if (!nodeRow.IsGroupNull())
     {
         Group = Convert.ToInt32(nodeRow.Group);
     }
     if (!nodeRow.IsTeamNull())
     {
         Team = Convert.ToInt32(nodeRow.Team);
     }
     if (!nodeRow.IsConnection1Null())
     {
         Connect1 = Convert.ToInt32(nodeRow.Connection1);
     }
     if (!nodeRow.IsConnection2Null())
     {
         Connect2 = Convert.ToInt32(nodeRow.Connection2);
     }
     if (!nodeRow.IsConnection3Null())
     {
         Connect3 = Convert.ToInt32(nodeRow.Connection3);
     }
     if (!nodeRow.IsConnection4Null())
     {
         Connect4 = Convert.ToInt32(nodeRow.Connection4);
     }
     if (!nodeRow.IsPositionXNull())
     {
         Position = Convert.ToInt32(nodeRow.PositionX);
     }
     if (!nodeRow.IsPositionYNull())
     {
         Position = Convert.ToInt32(nodeRow.PositionY);
     }
     if (!nodeRow.IsPositionZNull())
     {
         Position = Convert.ToInt32(nodeRow.PositionZ);
     }
 }
Example #4
0
        private bool NodeHasConnections(Nodes.NodeRow node)
        {
            if (!node.IsConnection1Null() && node.Connection1 != "-1")
            {
                return(true);
            }

            if (!node.IsConnection2Null() && node.Connection2 != "-1")
            {
                return(true);
            }

            if (!node.IsConnection3Null() && node.Connection3 != "-1")
            {
                return(true);
            }

            if (!node.IsConnection4Null() && node.Connection4 != "-1")
            {
                return(true);
            }

            return(false);
        }
Example #5
0
 public NodeToConnect(Nodes.NodeRow leftNode, Nodes.NodeRow rightNode, int connectionNumber)
 {
     LeftNode = leftNode;
     RightNode = rightNode;
     Connection = connectionNumber;
 }
Example #6
0
        public static void WriteNodes(string fileName, Nodes nodes)
        {
            fileName = GetNodeFile(fileName);
            StringBuilder buff     = new StringBuilder();
            StringBuilder execBuff = new StringBuilder();

            int startNode = 0;
            int endNode   = 99;
            int count     = 0;

            foreach (DataRow row in nodes.Node.Rows)
            {
                Nodes.NodeRow nodeRow = (Nodes.NodeRow)row;

                if (nodeRow.ID == null)
                {
                    continue;
                }

                buff.Append("node_resetlinks " + nodeRow.ID + ";");

                // set flags
                if (!nodeRow.IsFlagNull())
                {
                    buff.Append("node_flag " + nodeRow.ID + " " + nodeRow.Flag + ";");
                }

                // connection
                if (!nodeRow.IsConnection1Null() && nodeRow.Connection1 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection1 + ";");
                }

                // connection
                if (!nodeRow.IsConnection2Null() && nodeRow.Connection2 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection2 + ";");
                }

                // connection
                if (!nodeRow.IsConnection3Null() && nodeRow.Connection3 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection3 + ";");
                }

                // connection
                if (!nodeRow.IsConnection4Null() && nodeRow.Connection4 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection4 + ";");
                }

                // entity
                if (!nodeRow.IsEntityNull())
                {
                    buff.Append("node_ent " + nodeRow.ID + " " + nodeRow.Entity + ";");
                }

                // team
                if (!nodeRow.IsTeamNull())
                {
                    buff.Append("node_team " + nodeRow.ID + " " + nodeRow.Team + ";");
                }

                // group
                if (!nodeRow.IsGroupNull())
                {
                    buff.Append("node_group " + nodeRow.ID + " " + nodeRow.Group + ";");
                }

                // radius
                if (!nodeRow.IsRadiusNull())
                {
                    buff.Append("node_radius " + nodeRow.ID + " " + nodeRow.Radius + ";");
                }

                buff.Append("\r\n");

                count++;

                if (count > endNode)
                {
                    string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + endNode + ".cfg";
                    WriteConfig(subConfigFileName, buff);
                    buff      = new StringBuilder();
                    startNode = endNode + 1;
                    endNode   = startNode + 99;
                    execBuff.Append("exec " + subConfigFileName + "\r\n");
                }
            }

            if (buff.Length > 0)
            {
                string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + (count - 1) + ".cfg";
                WriteConfig(subConfigFileName, buff);
                execBuff.Append("exec " + subConfigFileName + "\r\n");
            }

            WriteConfig(fileName, execBuff);
        }
Example #7
0
        public static void WriteOmni(Nodes nodes)
        {
            StringBuilder buff = new StringBuilder();

            //nodes
            foreach (DataRow row in nodes.Node.Rows)
            {
                Nodes.NodeRow nodeRow = (Nodes.NodeRow)row;

                if (nodeRow.ID == null)
                {
                    continue;
                }

                buff.Append("Wp.AddWaypoint(Vector3(" + nodeRow.PositionX + "," + nodeRow.PositionY + "," + nodeRow.PositionZ + "), Vector3(0,0,0));\r\n");
                //buff.Append("another gm script line\r\n");
            }

            //radius

            /*foreach (DataRow row in nodes.Node.Rows)
             * {
             *  Nodes.NodeRow nodeRow = (Nodes.NodeRow)row;
             *
             *  int _radiusUID = Convert.ToInt32(nodeRow.ID);
             *  _radiusUID += 1;
             *
             *  buff.Append("Wp.SetRadius(" + _radiusUID + "," + nodeRow.Radius + ".0);\r\n");
             * }*/


            /* flags.Rows.Add(new object[] { "4", "Button" });
             * flags.Rows.Add(new object[] { "7", "Constructable" });
             * flags.Rows.Add(new object[] { "3", "Flag" });
             * flags.Rows.Add(new object[] { "-1", "Invalid" });
             * flags.Rows.Add(new object[] { "5", "Jump" });
             * flags.Rows.Add(new object[] { "2", "Ladder Bottom" });
             * flags.Rows.Add(new object[] { "1", "Ladder Top" });
             * flags.Rows.Add(new object[] { "6", "Leap" });
             * flags.Rows.Add(new object[] { "0", "Normal" });
             * flags.Rows.Add(new object[] { "9", "Walk" }); */

            //flags
            foreach (DataRow row in nodes.Node.Rows)
            {
                Nodes.NodeRow nodeRow = (Nodes.NodeRow)row;

                int _flagsUID = Convert.ToInt32(nodeRow.ID);
                _flagsUID += 1;

                /*if (nodeRow.Flag == "1" || nodeRow.Flag == "2")
                 * {
                 *  buff.Append("Wp.SetWaypointFlag(" + _flagsUID + "," + "\"climb\"" + ",true);\r\n");
                 * }*/

                if (nodeRow.Flag == "16" || nodeRow.Flag == "32")
                {
                    buff.Append("Wp.SetWaypointFlag(" + _flagsUID + "," + "\"jump\"" + ",true);\r\n");
                }

                if (nodeRow.Flag == "9")
                {
                    buff.Append("Wp.SetWaypointFlag(" + _flagsUID + "," + "\"sneak\"" + ",true);\r\n");
                }
            }

            //connections
            foreach (DataRow row in nodes.Node.Rows)
            {
                Nodes.NodeRow nodeRow = (Nodes.NodeRow)row;

                //add one for UID
                int _nodeUID = Convert.ToInt32(nodeRow.ID);
                _nodeUID += 1;

                int _connect1UID = Convert.ToInt32(nodeRow.Connection1);
                _connect1UID += 1;

                int _connect2UID = Convert.ToInt32(nodeRow.Connection2);
                _connect2UID += 1;

                int _connect3UID = Convert.ToInt32(nodeRow.Connection3);
                _connect3UID += 1;

                int _connect4UID = Convert.ToInt32(nodeRow.Connection4);
                _connect4UID += 1;

                if (nodeRow.Connection1 != "-1")
                {
                    buff.Append("Wp.Connect(" + _nodeUID + "," + _connect1UID + ");\r\n");
                }
                if (nodeRow.Connection2 != "-1")
                {
                    buff.Append("Wp.Connect(" + _nodeUID + "," + _connect2UID + ");\r\n");
                }
                if (nodeRow.Connection3 != "-1")
                {
                    buff.Append("Wp.Connect(" + _nodeUID + "," + _connect3UID + ");\r\n");
                }
                if (nodeRow.Connection4 != "-1")
                {
                    buff.Append("Wp.Connect(" + _nodeUID + "," + _connect4UID + ");\r\n");
                }
            }

            string p = System.Environment.GetEnvironmentVariable("OMNIBOTFOLDER") + @"\rtcw\scripts\filename.gm";

            File.WriteAllText(p, buff.ToString());
        }
Example #8
0
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            ArrayList nodesToConnect = new ArrayList();

            for (int x = 0; x < _nodes.Node.Count; x++)
            {
                Nodes.NodeRow nodeRow = _nodes.Node[x];

                if (x < _nodes.Node.Count - 1)
                {
                    Nodes.NodeRow nextNode = _nodes.Node[x + 1];

                    if (!NodeHasConnections(nodeRow))
                    {
                        nodesToConnect.Add(new NodeToConnect(nodeRow, nextNode, 1));

                        if (!NodeHasConnections(nextNode))
                        {
                            if (x == _nodes.Node.Count - 2)
                            {
                                nodesToConnect.Add(new NodeToConnect(nextNode, nodeRow, 1));
                            }
                            else
                            {
                                nodesToConnect.Add(new NodeToConnect(nextNode, nodeRow, 2));
                            }
                        }
                    }
                }
            }

            Hashtable nodeCount = new Hashtable();

            foreach (NodeToConnect nodeToConnect in nodesToConnect)
            {
                if (!nodeCount.ContainsKey(nodeToConnect.LeftNode.ID))
                {
                    nodeCount.Add(nodeToConnect.LeftNode.ID, nodeToConnect.LeftNode.ID);
                }

                switch (nodeToConnect.Connection)
                {
                case 1:
                    nodeToConnect.LeftNode.Connection1 = nodeToConnect.RightNode.ID;
                    break;

                case 2:
                    nodeToConnect.LeftNode.Connection2 = nodeToConnect.RightNode.ID;
                    break;

                case 3:
                    nodeToConnect.LeftNode.Connection3 = nodeToConnect.RightNode.ID;
                    break;

                case 4:
                    nodeToConnect.LeftNode.Connection4 = nodeToConnect.RightNode.ID;
                    break;
                }
            }

            MessageBox.Show(this.ParentForm, "Connected " + nodeCount.Count + " nodes with " + nodesToConnect.Count + " connections.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #9
0
 public NodeToConnect(Nodes.NodeRow leftNode, Nodes.NodeRow rightNode, int connectionNumber)
 {
     LeftNode   = leftNode;
     RightNode  = rightNode;
     Connection = connectionNumber;
 }