public RmpEntry AddRmp(MapLocation loc) { RmpEntry re = Rmp.AddEntry( (byte)loc.Row, (byte)loc.Col, (byte)loc.Height); ((XCMapTile)this[re.Row, re.Col, re.Height]).Rmp = re; return(re); }
public void RemoveEntry(RmpEntry r) { int oldIdx = r.Index; //Console.WriteLine("delete: "+r); entries.Remove(r); foreach(RmpEntry rr in entries) { if(rr.Index > oldIdx) rr.Index--; for(int i=0;i<5;i++) { Link l = rr[i]; if(l.Index==oldIdx) l.Index=Link.NotUsed; else if(l.Index>oldIdx && l.Index<0xFB) l.Index--; } } }
public RmpEntry AddEntry(byte row, byte col,byte height) { //Console.WriteLine("Adding {0},{1},{2}",row,col,height); RmpEntry re = new RmpEntry((byte)entries.Count,row,col,height); entries.Add(re); return re; }
private void btnRemove_Click(object sender, System.EventArgs e) { map.Rmp.RemoveEntry(currEntry); ((XCMapTile) map[currEntry.Row, currEntry.Col, currEntry.Height]).Rmp = null; currEntry = null; gbNodeInfo.Enabled = false; Refresh(); }
private byte calcLinkDistance(RmpEntry from, RmpEntry to, TextBox result) { int dist = ((int) Math.Sqrt(Math.Pow(from.Row - to.Row, 2) + Math.Pow(from.Col - to.Col, 2) + Math.Pow(from.Height - to.Height, 2))); if (result != null) { result.Text = dist.ToString(); } return (byte) dist; }
public override void HeightChanged(IMap_Base sender, HeightChangedEventArgs e) { currEntry = ((XCMapTile) map[clickRow, clickCol]).Rmp; fillGUI(); Refresh(); }
private RmpView() { clickRow = clickCol = 0; InitializeComponent(); rmpPanel = new RmpPanel(); contentPane.Controls.Add(rmpPanel); rmpPanel.MapPanelClicked += new MapPanelClickDelegate(panelClick); rmpPanel.MouseMove += new MouseEventHandler(mouseMove); rmpPanel.Dock = DockStyle.Fill; locInfo = new Label(); links = new Label(); locInfo.Width = 100; locInfo.Height = ClientSize.Height - rmpPanel.Height; links.Height = locInfo.Height; links.Width = ClientSize.Width - locInfo.Width; locInfo.Top = rmpPanel.Bottom; locInfo.Left = 0; links.Top = locInfo.Top; links.Left = locInfo.Right; links.BorderStyle = BorderStyle.Fixed3D; //this.Menu = new MainMenu(); //MenuItem f = new MenuItem("Edit"); //Menu.MenuItems.Add(f); //f.MenuItems.Add("Options",new EventHandler(options_click)); object[] uTypeItms = new object[] {UnitType.Any, UnitType.Flying, UnitType.FlyingLarge, UnitType.Large, UnitType.Small}; cbType.Items.AddRange(uTypeItms); cbUse1.Items.AddRange(uTypeItms); cbUse2.Items.AddRange(uTypeItms); cbUse3.Items.AddRange(uTypeItms); cbUse4.Items.AddRange(uTypeItms); cbUse5.Items.AddRange(uTypeItms); cbType.DropDownStyle = ComboBoxStyle.DropDownList; cbUse1.DropDownStyle = ComboBoxStyle.DropDownList; cbUse2.DropDownStyle = ComboBoxStyle.DropDownList; cbUse3.DropDownStyle = ComboBoxStyle.DropDownList; cbUse4.DropDownStyle = ComboBoxStyle.DropDownList; cbUse5.DropDownStyle = ComboBoxStyle.DropDownList; //object[] itms = {UnitRank.Civilian0,UnitRank.XCom1,UnitRank.Soldier2,UnitRank.Navigator3,UnitRank.LeaderCommander4,UnitRank.Engineer5,UnitRank.Misc1,UnitRank.Medic7,UnitRank.Misc2}; object[] itms2 = { UnitRankNum.Zero, UnitRankNum.One, UnitRankNum.Two, UnitRankNum.Three, UnitRankNum.Four, UnitRankNum.Five, UnitRankNum.Six, UnitRankNum.Seven, UnitRankNum.Eight }; cbRank1.Items.AddRange(RmpFile.UnitRankUFO); cbRank1.DropDownStyle = ComboBoxStyle.DropDownList; cbRank2.Items.AddRange(itms2); cbRank2.DropDownStyle = ComboBoxStyle.DropDownList; cbLink1.DropDownStyle = ComboBoxStyle.DropDownList; cbLink2.DropDownStyle = ComboBoxStyle.DropDownList; cbLink3.DropDownStyle = ComboBoxStyle.DropDownList; cbLink4.DropDownStyle = ComboBoxStyle.DropDownList; cbLink5.DropDownStyle = ComboBoxStyle.DropDownList; cbUsage.DropDownStyle = ComboBoxStyle.DropDownList; cbUsage.Items.AddRange(RmpFile.SpawnUsage); currEntry = null; Text = "RmpView"; }
private void panelClick(object sender, MapPanelClickEventArgs e) { idxLabel.Text = this.Text; try { if (currEntry != null && e.MouseEventArgs.Button == MouseButtons.Right) { RmpEntry selEntry = ((XCMapTile) e.ClickTile).Rmp; if (selEntry != null) { bool ExistingLink = false; bool SpaceAvailable = false; int SpaceAt = 512; for (int i = 0; i < 5; i++) { if (currEntry[i].Index == selEntry.Index) { ExistingLink = true; break; } if (currEntry[i].Index == (byte) LinkTypes.NotUsed) { SpaceAvailable = true; if (i < SpaceAt) SpaceAt = i; } } if (!ExistingLink && SpaceAvailable) { currEntry[SpaceAt].Index = selEntry.Index; currEntry[SpaceAt].Distance = calcLinkDistance(currEntry, selEntry, null); } if (AutoconnectNodes.Checked) { ExistingLink = false; SpaceAvailable = false; SpaceAt = 512; for (int i = 0; i < 5; i++) { if (selEntry[i].Index == currEntry.Index) { ExistingLink = true; break; } if (selEntry[i].Index == (byte) LinkTypes.NotUsed) { SpaceAvailable = true; if (i < SpaceAt) SpaceAt = i; } } if (!ExistingLink && SpaceAvailable) { selEntry[SpaceAt].Index = currEntry.Index; selEntry[SpaceAt].Distance = calcLinkDistance(selEntry, currEntry, null); } } fillGUI(); Refresh(); return; } } currEntry = ((XCMapTile) e.ClickTile).Rmp; if (currEntry == null && e.MouseEventArgs.Button == MouseButtons.Right) { if (map is XCMapFile) { RmpEntry prevEntry = (((XCMapFile) map).Rmp.Length > 0 ? ((XCMapFile) map).Rmp[((XCMapFile) map).Rmp.Length - 1] : null); currEntry = ((XCMapFile) map).AddRmp(e.ClickLocation); if (AutoconnectNodes.Checked) { currEntry[0].Index = (byte) (((XCMapFile) map).Rmp.Length - 2); if (prevEntry != null) { currEntry[0].Distance = calcLinkDistance(currEntry, prevEntry, txtDist1); for (int pI = 0; pI < prevEntry.NumLinks; pI++) { if (prevEntry[pI].Index == 0xFF) { prevEntry[pI].Index = (byte) (((XCMapFile) map).Rmp.Length - 1); prevEntry[pI].Distance = calcLinkDistance(prevEntry, currEntry, null); break; } } } } } } } catch { return; } fillGUI(); }