public ElevatorEdit() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // добавляем подьемники в список Map.ObjectTable objects = MapInterface.TheMap.Objects; listElevators = new List <Map.Object>(); listElevShafts = new List <Map.Object>(); ThingDb.Thing tt; foreach (Map.Object obj in objects) { tt = ThingDb.Things[obj.Name]; if (tt.HasClassFlag(ThingDb.Thing.ClassFlags.ELEVATOR_SHAFT)) { listElevShafts.Add(obj); } else if (tt.HasClassFlag(ThingDb.Thing.ClassFlags.ELEVATOR)) { listElevators.Add(obj); } } checkIsLinked.Checked = false; elevatorList.Enabled = false; }
public TeleportEdit() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // добавляем телепортаторы в список Map.ObjectTable objects = MapInterface.TheMap.Objects; listTeleporters = new List <Map.Object>(); ThingDb.Thing tt; foreach (Map.Object obj in objects) { tt = ThingDb.Things[obj.Name]; if (tt.HasClassFlag(ThingDb.Thing.ClassFlags.TRANSPORTER)) { listTeleporters.Add(obj); } } checkIsLinked.Checked = false; }
private void editObjectToolStripMenuItem_Click(object sender, EventArgs e) { ListSortDirection sorted = ListSortDirection.Ascending; int curIndex = dataGrid1.CurrentRow.Index; int vscroll = dataGrid1.VerticalScrollingOffset; if (dataGrid1.SortOrder == SortOrder.Ascending) { sorted = ListSortDirection.Ascending; } if (dataGrid1.SortOrder == SortOrder.Descending) { sorted = ListSortDirection.Descending; } setting = dataGrid1.SortedColumn; Map.Object P = (Map.Object)(objList.Rows[dataGrid1.CurrentRow.Index][3]); Map.ShowObjectProperties(P); this.objTable = objTable2; if (setting != null) { if (dataGrid1.Columns[setting.Name] != null) { dataGrid1.Sort(dataGrid1.Columns[setting.Name], sorted); } } if (curIndex >= 0) { dataGrid1.ClearSelection(); dataGrid1.Rows[curIndex].Selected = true; dataGrid1.CurrentCell = dataGrid1.Rows[curIndex].Cells[0]; } DatatableSync(); }
public DefaultList(Map.ObjectTable tabl) { table = tabl; InitializeComponent(); foreach (ThingDb.Thing tng in ThingDb.Things.Values) { listDefault.Items.Add(tng.Name.ToLower()); } foreach (string str in Directory.GetFiles(Application.StartupPath + "\\scripts\\objects\\defaultmods\\")) { if (str == "Update.txt") { } else { string[] strs = str.Split("\\".ToCharArray()); string str2 = strs[strs.GetLength(0) - 1]; str2 = str2.Remove(str2.Length - 4); if (listDefault.Items.Contains(str2.ToLower())) { listDefault.Items.Remove(str2.ToLower()); } } } }
private void applyChangesToolStripMenuItem_Click(object sender, EventArgs e) { dataGrid1.CommitEdit(DataGridViewDataErrorContexts.CurrentCellChange); // Find and return changes int c = 0; for (int i = 0; i < dataGrid1.Rows.Count; i++) { var name = dataGrid1[3, i].Value.ToString(); var newScrName = dataGrid1[4, i].Value.ToString(); Map.Object newObj = (Map.Object)objList.Rows[i][3]; int j = objTable2.IndexOf(newObj); Map.Object oldObj = (Map.Object)objTable2[j]; // Set new script name if (oldObj.Scr_Name != newScrName) { ((Map.Object)objTable2[j]).Scr_Name = newScrName; // Check 'Extra Bytes' if (oldObj.Terminator == 0x00) { ((Map.Object)objTable2[j]).Terminator = 0xFF; } c++; } var enchants = GetEnchants(oldObj); if (enchants == null) { continue; } string[] ench = new string[4]; ench[0] = dataGrid1[5, i].Value.ToString(); ench[1] = dataGrid1[6, i].Value.ToString(); ench[2] = dataGrid1[7, i].Value.ToString(); ench[3] = dataGrid1[8, i].Value.ToString(); for (int k = 0; k < 4; k++) { // Ignore all whitespace if (ench[k] == "") { continue; } if (ench[k].Trim() == "") { ench[k] = ""; continue; } // Ensure valid enchant and proper case var isValid = GetValidEnchant(ench[k]); if (isValid != "-1") { ench[k] = isValid; } else { ench[k] = ""; } } // Set new enchants if (enchants != ench) { objTable2[j] = SetEnchants(oldObj, ench); } } // Pass new object table back to MainWindow Result = null; if (c > 0) { Result = objTable2; } DialogResult = DialogResult.OK; Hide(); }
private void button4_Click(object sender, EventArgs e) { button3.Enabled = false; button4.Enabled = false; /* * This function copies all of the items and objects and flips them. * * */ // Flip the walls if (chkFlipWall.Checked) { //int mapsize = 255 * 23; Map.WallMap temap = new Map.WallMap(); foreach (Map.Wall wall in view.Map.Walls.Values) { Map.Wall wal = new Map.Wall(wall.Location, wall.Facing, wall.matId); wal.Location.Y = (255 - wall.Location.X)+1; wal.Location.X = (255 - wall.Location.Y)+1; if (chkAdv.Checked) { wal.matId = (byte)comboBox1.SelectedIndex; wal.Minimap = Convert.ToByte(minimapGroup.Text); } switch (wal.Facing) { case Map.Wall.WallFacing.NORTH_T: wal.Facing = Map.Wall.WallFacing.SOUTH_T; break; case Map.Wall.WallFacing.SOUTH_T: wal.Facing = Map.Wall.WallFacing.NORTH_T; break; case Map.Wall.WallFacing.NE_CORNER: wal.Facing = Map.Wall.WallFacing.SE_CORNER; break; case Map.Wall.WallFacing.SE_CORNER: wal.Facing = Map.Wall.WallFacing.NE_CORNER; break; case Map.Wall.WallFacing.SW_CORNER: wal.Facing = Map.Wall.WallFacing.NW_CORNER; break; case Map.Wall.WallFacing.NW_CORNER: wal.Facing = Map.Wall.WallFacing.SW_CORNER; break; } temap.Add(wal.Location, wal); } foreach (Map.Wall wa in temap.Values) { if (!view.Map.Walls.ContainsKey(wa.Location)) { view.Map.Walls.Add(wa.Location, wa); } } } // Flip the waypoints now /*Map.WaypointList wp = new Map.WaypointList(); foreach (Map.Waypoint wpt in view.Map.Waypoints) { Map.Waypoint wt = new Map.Waypoint(wpt.Name,wpt.Point,wpt.num); wt = wpt; float val = wt.Point.Y; val = (float)((float)(mapsize) - (float)(val)); wt.Point.Y = (float)val; wp.Add(wt); } foreach (Map.Waypoint wpt in wp) { view.Map.Waypoints.Add(wpt); }*/ // Flip the objects now if (chkFlipOb.Checked) { Map.ObjectTable tng2 = new Map.ObjectTable(); foreach (Map.Object tng in view.Map.Objects) { Map.Object tn = new Map.Object(); tn.Properties = tng.Properties; tn.modbuf = (byte[])tng.modbuf.Clone(); tn.Extent = 0; tn.Location.Y = ((256*23) - tng.Location.X)+23; tn.Location.X = ((256*23) - tng.Location.Y)+23; tng2.Add(tn); } foreach (Map.Object tng in tng2) { view.Map.Objects.Add(tng); } } }