public void InitializeNodes(ArrayList nodes, bool hasConnectErrors) { _hasConnectErrors = hasConnectErrors; _nodes = new Nodes(); int count = 0; foreach (Node node in nodes) { string connect1 = node.Connect1 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect1); string connect2 = node.Connect2 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect2); string connect3 = node.Connect3 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect3); string connect4 = node.Connect4 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect4); _nodes.Node.AddNodeRow( Convert.ToString(count), Convert.ToString(node.Flags), Convert.ToString(node.Radius), Convert.ToString(node.Entity), Convert.ToString(node.Team), Convert.ToString(node.Group), connect1, connect2, connect3, connect4, Convert.ToString(node.PositionX), Convert.ToString(node.PositionY), Convert.ToString(node.PositionZ)); count++; } this.SuspendLayout(); dgNodes.DataSource = _nodes.Tables[0]; this.ResumeLayout(false); //no adding of new rows thru dataview... CurrencyManager cm = (CurrencyManager)this.BindingContext[dgNodes.DataSource, dgNodes.DataMember]; ((DataView)cm.List).AllowNew = false; }
public NodePrinter(PrintDocument document, Nodes nodes, string fileName) { _fileName = fileName; _printDocument = document; _nodes = nodes; //init page settings _pageWidth = document.DefaultPageSettings.PaperSize.Width; _pageHeight = document.DefaultPageSettings.PaperSize.Height; _pageLandscape = document.DefaultPageSettings.Landscape; //init margin settings _pageMarginLeft = document.DefaultPageSettings.Margins.Left; _pageMarginTop = document.DefaultPageSettings.Margins.Top; _pageMarginRight = document.DefaultPageSettings.Margins.Right; _pageMarginBottom = document.DefaultPageSettings.Margins.Bottom; _currentY = _pageMarginTop; _currentX = _pageMarginLeft; }
public NodeToConnect(Nodes.NodeRow leftNode, Nodes.NodeRow rightNode, int connectionNumber) { LeftNode = leftNode; RightNode = rightNode; Connection = connectionNumber; }
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; }
// 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; }
public void Write(string fileName, Nodes nodes, Actions actions, Routes routes) { if (File.Exists(fileName)) { // copy the .nav file string backupNavFile = fileName + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + ".nav"; File.Move(fileName, backupNavFile); File.SetLastWriteTime(backupNavFile, DateTime.Now); } FileStream fs = File.Create(fileName); BinaryWriter writer = new BinaryWriter(fs); byte[] header = new byte[] { 70, 114, 105, 116, 122, 66, 111, 116, 0, 7, 0, 0, 0 }; writer.Write(header); writer.Write(FromInt(nodes.Node.Count)); if (nodes.Node.Count > 0) { int nodeCounter = 0; foreach (Nodes.NodeRow nodeRow in nodes.Node) { Node node = (Node)_nodes[nodeCounter]; node.FromNodeRow(nodeRow); writer.Write(node.ToByteArray()); nodeCounter++; } if (actions.Action.Count > 0) { int actionCounter = 0; writer.Write(FromInt(actions.Action.Count)); foreach (Actions.ActionRow actionRow in actions.Action) { Action action = (Action)_actions[actionCounter]; action.FromActionRow(actionRow); writer.Write(action.ToByteArray()); actionCounter++; } if (routes.Route.Count > 0) { int routeCounter = 0; writer.Write(FromInt(routes.Route.Count)); foreach (Routes.RouteRow routeRow in routes.Route) { Route route = (Route)_routes[routeCounter]; route.FromRouteRow(routeRow); writer.Write(route.ToByteArray()); routeCounter++; } } else { writer.Write(FromInt(0)); } } else { writer.Write(FromInt(0)); writer.Write(FromInt(0)); } } else { writer.Write(FromInt(0)); writer.Write(FromInt(0)); } writer.Close(); fs.Close(); }
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); }
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); }
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()); }
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()); }
public void InitializeNodes(ArrayList nodes) { try { if (_nodes != null) { _nodes.Clear(); } else { _nodes = new Nodes(); } int count = 0; foreach (Node node in nodes) { string connect1 = node.Connect1 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect1); string connect2 = node.Connect2 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect2); string connect3 = node.Connect3 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect3); string connect4 = node.Connect4 == Int32.MinValue ? "-1" : Convert.ToString(node.Connect4); _nodes.Node.AddNodeRow( Convert.ToString(count), Convert.ToString(node.Flags), Convert.ToString(node.Radius), Convert.ToString(node.Entity), Convert.ToString(node.Team), Convert.ToString(node.Group), connect1, connect2, connect3, connect4, Convert.ToString(node.PositionX), Convert.ToString(node.PositionY), Convert.ToString(node.PositionZ)); count++; } dgNodes.DataSource = _nodes.Tables[0]; dgNodes.Refresh(); } catch (Exception ex) { MessageBox.Show(this.ParentForm, "Error Loading Nodes. " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }