private void menuEditObj_Click(object sender, EventArgs e) { if (dataGrid1.CurrentRow == null) { return; } int curIndex = dataGrid1.CurrentRow.Index; Map.Object obj = (Map.Object)objList.Rows[dataGrid1.CurrentRow.Index][3]; Map.ShowObjectProperties(obj); // Only update current row var enchants = GetEnchants(obj); if (enchants == null) { objList.Rows[dataGrid1.CurrentRow.Index].ItemArray = new object[] { obj.Extent, obj.Location.X, obj.Location.Y, obj, obj.Scr_Name, "", "", "", "" } } ; else { objList.Rows[dataGrid1.CurrentRow.Index].ItemArray = new object[] { obj.Extent, obj.Location.X, obj.Location.Y, obj, obj.Scr_Name, enchants[0], enchants[1], enchants[2], enchants[3] } }; }
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(); }
private void Button2Click(object sender, EventArgs e) { if (objPs.Xfer != null) // DefaultXfer { XferEditor editor = XferEditors.GetEditorForXfer(objPs.Xfer); if (editor != null) { try { editor.SetObject(obj); if (editor.ShowDialog() == DialogResult.OK) { obj = editor.GetObject(); } } catch (Exception) { #if DEBUG throw; #endif } } else { MessageBox.Show("There is no internal mod-gen for that object."); } } }
public override void SetObject(Map.Object obj) { this.obj = obj; // читаем Xfer xfer = obj.GetExtraData <TriggerXfer>(); scriptActivated.Text = xfer.ScriptOnPressed; scriptReleased.Text = xfer.ScriptOnReleased; scriptCollided.Text = xfer.ScriptOnCollided; // единственный способ отличить PressurePlate/Trigger от Button/Lever if (ThingDb.Things[obj.Name].ExtentType != "BOX") { groupBoxArea.Enabled = false; } else { sizeX.Value = xfer.SizeX; sizeY.Value = xfer.SizeY; plateEdgeColor.BackColor = xfer.EdgeColor; plateBackColor.BackColor = xfer.BackColor; } flagsBox.SetItemChecked(0, (xfer.AllowedObjClass & 0x2) == 0x2); // NO_UPDATE flagsBox.SetItemChecked(1, (xfer.AllowedObjClass & 0x4) == 0x4); // DESTROYED flagsBox.SetItemChecked(2, (xfer.AllowedObjClass & 0x1) == 0x1); //MISSILE flagsBox.SetItemChecked(3, (xfer.AllowedObjClass & 0x8) == 0x8); // NO_COLLIDE flagsBox.SetItemChecked(4, (xfer.AllowedObjClass & 0x80000000) == 0x80000000); // NPC flagsBox.SetItemChecked(5, (xfer.AllowedObjClass & 0x10) == 0x10); // EQUIPPED flagsBox.SetItemChecked(6, (xfer.AllowedObjClass & 0x1000000) == 0x1000000); // ENABLED flagsBox.SetItemChecked(7, (xfer.AllowedObjClass & 0x2000000) == 0x2000000); // NO_AUTO_DROP flagsBox.SetItemChecked(8, (xfer.AllowedObjClass & 0x8000000) == 0x8000000); // NO_PUSH_CHARACTERS flagsBox.SetItemChecked(9, (xfer.AllowedObjClass & 0x1000) == 0x1000); // wand numericUpDown1.Value = xfer.AllowedTeamID; LoadScripts(); }
// Note: this is not used for tree animations! // Only if objects types change (like logging a tree, digging stones and so on). public void ChangeObjectType(Map.Object objectType) { if (objectType == this.objectType) { return; // nothing changed } if (this.objectType == Map.Object.None) // from None to something valid { // this is handled by Game so this should not happen at all Debug.NotReached(); return; } if (objectType < Map.Object.Tree0) // from something valid to None (or something we don't need to draw here) { // this is handled by Game so this should not happen at all Debug.NotReached(); return; } this.objectType = objectType; uint spriteIndex = (uint)objectType - 8; var spriteInfo = dataSource.GetSpriteInfo(Data.Resource.MapObject, spriteIndex); var shadowInfo = dataSource.GetSpriteInfo(Data.Resource.MapShadow, spriteIndex); sprite.Resize(spriteInfo.Width, spriteInfo.Height); shadowSprite.Resize(shadowInfo.Width, shadowInfo.Height); }
public override void SetObject(Map.Object obj) { base.SetObject(obj); ReadableXfer xfer = obj.GetExtraData <ReadableXfer>(); readableText.Text = xfer.Text.Trim('\0'); }
public override void SetObject(Map.Object obj) { this.obj = obj; DoorXfer xfer = obj.GetExtraData <DoorXfer>(); dirBox.Text = xfer.Direction.ToString(); // dir2.Text = ((byte)xfer.Direction).ToString(); lockBox.Text = xfer.LockType.ToString(); }
private void addButton_Click(object sender, System.EventArgs e) { Map.Object o = new Map.Object(); ObjectPropertiesDialog propDlg = new ObjectPropertiesDialog(); propDlg.Object = o; propDlg.ShowDialog(); obj.childObjects.Add(o); UpdateList(); }
public RenderMapObject(Map.Object objectType, IRenderLayer renderLayer, ISpriteFactory spriteFactory, DataSource dataSource) : base(renderLayer, spriteFactory, dataSource) { this.objectType = objectType; this.dataSource = dataSource; Initialize(); InitOffsets(dataSource); }
public override void SetDefaultData(Map.Object obj) { obj.NewDefaultExtraData(); xfer = obj.GetExtraData <TriggerXfer>(); if (ThingDb.Things[obj.Name].ExtentType != "BOX") { xfer.BackColor = Color.Black; xfer.EdgeColor = Color.Black; } }
public override void SetObject(Map.Object obj) { this.obj = obj; HoleXfer xfer = obj.GetExtraData <HoleXfer>(); exitX.Text = xfer.FallX.ToString(); exitY.Text = xfer.FallY.ToString(); scriptFn.Text = xfer.UnknownScriptHandler; scriptTime.Text = xfer.ScriptTimeout.ToString(); }
private void addButton_Click(object sender, System.EventArgs e) { Map.Object o = new Map.Object(); o.Extent = 0; ObjectPropertiesDialog propDlg = new ObjectPropertiesDialog(); propDlg.Object = o; propDlg.ShowDialog(); obj.InventoryList.Add(propDlg.Object); UpdateList(); }
public override void SetObject(Map.Object obj) { this.obj = obj; xfer = obj.GetExtraData <RewardMarkerXfer>(); spawnChance.SelectedIndex = xfer.ActivateChance; checkRare.Checked = xfer.RareOrSpecial; for (int i = 0; i < 8; i++) { rewardTypes.SetItemChecked(i, (((uint)xfer.RewardType & flagsArray[i]) == flagsArray[i])); } }
private void goToObjectToolStripMenuItem_Click(object sender, EventArgs e) { Point target = new Point((int)((float)objList.Rows[dataGrid1.CurrentRow.Index]["X-Coor."]), (int)((float)objList.Rows[dataGrid1.CurrentRow.Index]["Y-Coor."])); Map.CenterAtPoint(target); Helpmark.Enabled = true; Map.highlightUndoRedo = target; Map.Object P = (Map.Object)(objList.Rows[dataGrid1.CurrentRow.Index][3]); Map.SelectedObjects.Items.Clear(); Map.SelectedObjects.Items.Add(P); }
public override void SetObject(Map.Object obj) { this.obj = obj; ThingDb.Thing tt = ThingDb.Things[obj.Name]; // читаем Xfer xfer = obj.GetExtraData <ElevatorXfer>(); List <Map.Object> objects = new List <Map.Object>(); // убираем этот элеватор из списков listElevators.Remove(obj); listElevShafts.Remove(obj); // для шахт выводим список подьемников if (tt.HasClassFlag(ThingDb.Thing.ClassFlags.ELEVATOR_SHAFT)) { objects = listElevators; isShaft = true; } // для подьемников список шахт else if (tt.HasClassFlag(ThingDb.Thing.ClassFlags.ELEVATOR)) { objects = listElevShafts; isShaft = false; } elevatorList.Items.Clear(); string name; foreach (Map.Object e in objects) { name = e.ToString(); if (e.Scr_Name.Length > 0) { name = '"' + e.ScrNameShort + '"'; } elevatorList.Items.Add(name); } // показываем куда подключен if (xfer.ExtentLink > 0) { checkIsLinked.Checked = true; int index = 0; foreach (Map.Object o in objects) { if (o.Extent == xfer.ExtentLink) { elevatorList.SelectedIndex = index; break; } index++; } } }
public override void SetDefaultData(Map.Object obj) { base.SetDefaultData(obj); Xfer = obj.GetExtraData <NPCXfer>(); Xfer.DirectionId = 0; Xfer.ScriptEvents = new string[10]; for (int i = 0; i < 10; i++) { Xfer.ScriptEvents[i] = ""; } Xfer.DetectEventTimeout = 1; Xfer.ActionRoamPathFlag = 0xFF; Xfer.StatusFlags = (NoxEnums.MonsterStatus) 0; Xfer.HealthMultiplier = 1F; Xfer.RetreatRatio = 0.05F; Xfer.ResumeRatio = 0.5F; Xfer.SightRange = 150F; Xfer.Aggressiveness = 0.5F; Xfer.DefaultAction = 0; Xfer.EscortObjName = ""; Xfer.KnownSpells = new System.Collections.Generic.List <MonsterXfer.SpellEntry>(); Xfer.ReactionCastingDelayMin = 15; Xfer.ReactionCastingDelayMax = 30; Xfer.BuffCastingDelayMin = 90; Xfer.BuffCastingDelayMax = 120; Xfer.DebuffCastingDelayMin = 30; Xfer.DebuffCastingDelayMax = 40; Xfer.OffensiveCastingDelayMin = 30; Xfer.OffensiveCastingDelayMax = 40; Xfer.BlinkCastingDelayMin = 90; Xfer.BlinkCastingDelayMax = 120; Xfer.LockPathDistance = 30F; Xfer.SpellPowerLevel = 3; Xfer.AimSkillLevel = 0.5F; Xfer.Immortal = false; Xfer.TrapSpell1 = "SPELL_INVALID"; Xfer.TrapSpell2 = "SPELL_INVALID"; Xfer.TrapSpell3 = "SPELL_INVALID"; Xfer.MagicNumber = 0xDEADFACE; Xfer.AddedSubclass = 0; Xfer.Health = 100; Xfer.MaxHealth = 100; Xfer.NPCStrength = 30; Xfer.NPCColors = new Color[6]; for (int i = 0; i < 6; i++) { Xfer.NPCColors[i] = Color.FromArgb(0xD2, 0xAE, 0x79); } Xfer.NPCSpeed = 0.5F; Xfer.NPCVoiceSet = "NPC"; Xfer.BuffList = new MonsterXfer.BuffEntry[0]; Xfer.PoisonLevel = 0; }
public override void SetObject(Map.Object obj) { this.obj = obj; ThingDb.Thing tt = ThingDb.Things[obj.Name]; WeaponXfer weapon; ArmorXfer armor; AmmoXfer ammo; TeamXfer team; switch (tt.Xfer) { case "WeaponXfer": weapon = obj.GetExtraData <WeaponXfer>(); enchantment1.Text = weapon.Enchantments[0]; enchantment2.Text = weapon.Enchantments[1]; enchantment3.Text = weapon.Enchantments[2]; enchantment4.Text = weapon.Enchantments[3]; durability.Enabled = true; durability.Value = weapon.Durability; if (tt.HasClassFlag(ThingDb.Thing.ClassFlags.WAND) && !tt.Subclass[(int)ThingDb.Thing.SubclassBitIndex.STAFF]) { ammoMin.Enabled = true; ammoMax.Enabled = true; ammoMin.Value = weapon.WandChargesCurrent; ammoMax.Value = weapon.WandChargesLimit; } break; case "ArmorXfer": armor = obj.GetExtraData <ArmorXfer>(); enchantment1.Text = armor.Enchantments[0]; enchantment2.Text = armor.Enchantments[1]; enchantment3.Text = armor.Enchantments[2]; enchantment4.Text = armor.Enchantments[3]; durability.Enabled = true; durability.Value = armor.Durability; break; case "AmmoXfer": ammo = obj.GetExtraData <AmmoXfer>(); enchantment1.Text = ammo.Enchantments[0]; enchantment2.Text = ammo.Enchantments[1]; enchantment3.Text = ammo.Enchantments[2]; enchantment4.Text = ammo.Enchantments[3]; ammoMin.Enabled = true; ammoMax.Enabled = true; ammoMin.Value = ammo.AmmoCurrent; ammoMax.Value = ammo.AmmoLimit; break; case "TeamXfer": team = obj.GetExtraData <TeamXfer>(); enchantment1.Text = team.Enchantments[0]; enchantment2.Text = team.Enchantments[1]; enchantment3.Text = team.Enchantments[2]; enchantment4.Text = team.Enchantments[3]; break; } pausePreview = false; }
public override void SetObject(Map.Object obj) { this.obj = obj; MoverXfer xfer = obj.GetExtraData <MoverXfer>(); movingSpeed.Value = xfer.MovingSpeed; waypointID.Value = xfer.WaypointID; movedObjExtent.Value = xfer.MovedObjExtent; moverStatusBox.SelectedIndex = xfer.MoveType; loopWaypointA.Value = xfer.WaypointStartID; loopWaypointB.Value = xfer.WaypointEndID; moverAccel.Text = xfer.MoverAcceleration.ToString(floatFormat); moverSpeed.Text = xfer.MoverSpeed.ToString(floatFormat); }
public override void SetObject(Map.Object obj) { this.obj = obj; SentryXfer xfer = obj.GetExtraData <SentryXfer>(); sentryAngle.Text = xfer.BasePosRadian.ToString(floatFormat); sentrySpeed.Text = xfer.RotateSpeed.ToString(floatFormat); try { sldrAngle.Value = RadianToDegrees(xfer.BasePosRadian); } catch { } try { sldrRotation.Value = (int)(xfer.RotateSpeed * POINT_RATIO); } catch { } lblDegrees.Text = sldrAngle.Value + "°"; Invalidate(); }
public override void SetDefaultData(Map.Object obj) { base.SetDefaultData(obj); // Default values for armor and weapons ThingDb.Thing tt = ThingDb.Things[obj.Name]; if (tt.Xfer == "WeaponXfer") { obj.GetExtraData <WeaponXfer>().DefaultsFor(tt); } else if (tt.Xfer == "ArmorXfer") { obj.GetExtraData <ArmorXfer>().Durability = (short)tt.Health; } }
public void drawTeleWays(Graphics g) { foreach (KeyValuePair <Map.Object, int> keyValuePair1 in telelist) { bool flag = false; Map.Object key = keyValuePair1.Key; int num = keyValuePair1.Value; float x2 = -1f; float y2 = -1f; if (num > 0) { foreach (KeyValuePair <Map.Object, int> keyValuePair2 in telelist) { if (keyValuePair2.Key.Extent == num) { x2 = keyValuePair2.Key.Location.X; y2 = keyValuePair2.Key.Location.Y; if (keyValuePair2.Value == key.Extent) { flag = true; } } } } else if (ThingDb.Things[key.Name].Xfer == "HoleXfer") { HoleXfer extraData = key.GetExtraData <HoleXfer>(); x2 = extraData.FallX; y2 = extraData.FallY; } if ((double)x2 >= 0.0 && (double)y2 >= 0.0) { Color color = Color.FromArgb((int)byte.MaxValue, 237, 204); if (flag) { color = Color.FromArgb((int)byte.MaxValue, 211, 130); } else { g.FillEllipse(new SolidBrush(color), key.Location.X - 5f, key.Location.Y - 6f, 12f, 12f); } g.DrawLine(new Pen(color, 2f) { CustomEndCap = Arrow }, key.Location.X, key.Location.Y, x2, y2); } } }
public override void SetObject(Map.Object obj) { base.SetObject(obj); xfer = obj.GetExtraData <GlyphXfer>(); textBoxTargX.Text = xfer.TargX.ToString(floatFormat); textBoxTargY.Text = xfer.TargY.ToString(floatFormat); for (int i = 0; i < spellNameBoxes.Length; i++) { if (xfer.Spells.Count <= i) { break; } spellNameBoxes[i].Text = xfer.Spells[i]; } }
public override void SetObject(Map.Object obj) { this.obj = obj; try { Xfer = obj.GetExtraData <MonsterXfer>(); Text += string.Format(" - editing {0}", obj); } catch (Exception ex) { string msg = string.Format("Failed to parse XFer data. {0}", ex.Message); MessageBox.Show(msg, "MonsterXFer", MessageBoxButtons.OK, MessageBoxIcon.Error); //this.DialogResult = DialogResult.Cancel; //this.Close(); } InputFormData(); }
private string[] GetEnchants(Map.Object obj) { ThingDb.Thing tt = ThingDb.Things[obj.Name]; WeaponXfer weapon; ArmorXfer armor; AmmoXfer ammo; TeamXfer team; string[] enchants = new string[4]; switch (tt.Xfer) { case "WeaponXfer": weapon = obj.GetExtraData <WeaponXfer>(); enchants[0] = weapon.Enchantments[0]; enchants[1] = weapon.Enchantments[1]; enchants[2] = weapon.Enchantments[2]; enchants[3] = weapon.Enchantments[3]; break; case "ArmorXfer": armor = obj.GetExtraData <ArmorXfer>(); enchants[0] = armor.Enchantments[0]; enchants[1] = armor.Enchantments[1]; enchants[2] = armor.Enchantments[2]; enchants[3] = armor.Enchantments[3]; break; case "AmmoXfer": ammo = obj.GetExtraData <AmmoXfer>(); enchants[0] = ammo.Enchantments[0]; enchants[1] = ammo.Enchantments[1]; enchants[2] = ammo.Enchantments[2]; enchants[3] = ammo.Enchantments[3]; break; case "TeamXfer": team = obj.GetExtraData <TeamXfer>(); enchants[0] = team.Enchantments[0]; enchants[1] = team.Enchantments[1]; enchants[2] = team.Enchantments[2]; enchants[3] = team.Enchantments[3]; break; default: enchants = null; break; } return(enchants); }
void GenerateMonsterData(Map.Object monster) { int index = monstersListBox.SelectedIndex; MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write((short)0x40); // pr1 bw.Write((short)0x40); // pr2 bw.Write((int)(index + 1)); // Ext bw.Write((int)0); // GID bw.Write((float)0); // X bw.Write((float)0); // Y bw.Write((byte)0); // Term monster.GetExtraData <MonsterXfer>().WriteToStream(ms, 0x40, ThingDb.Things[monster.Name]); bw.Flush(); byte[] result = ms.ToArray(); bw.Close(); Xfer.MonsterData[index] = result; }
private Map.Object SetEnchants(Map.Object obj, string[] enchants) { ThingDb.Thing tt = ThingDb.Things[obj.Name]; WeaponXfer weapon; ArmorXfer armor; AmmoXfer ammo; TeamXfer team; switch (tt.Xfer) { case "WeaponXfer": weapon = obj.GetExtraData <WeaponXfer>(); weapon.Enchantments[0] = enchants[0]; weapon.Enchantments[1] = enchants[1]; weapon.Enchantments[2] = enchants[2]; weapon.Enchantments[3] = enchants[3]; break; case "ArmorXfer": armor = obj.GetExtraData <ArmorXfer>(); armor.Enchantments[0] = enchants[0]; armor.Enchantments[1] = enchants[1]; armor.Enchantments[2] = enchants[2]; armor.Enchantments[3] = enchants[3]; break; case "AmmoXfer": ammo = obj.GetExtraData <AmmoXfer>(); ammo.Enchantments[0] = enchants[0]; ammo.Enchantments[1] = enchants[1]; ammo.Enchantments[2] = enchants[2]; ammo.Enchantments[3] = enchants[3]; break; case "TeamXfer": team = obj.GetExtraData <TeamXfer>(); team.Enchantments[0] = enchants[0]; team.Enchantments[1] = enchants[1]; team.Enchantments[2] = enchants[2]; team.Enchantments[3] = enchants[3]; break; } return(obj); }
public Map.Object GetClonedObject() { Map.Object newObj = new Map.Object(obj.Name, new PointF(5, 5)); ThingDb.Thing tt = ThingDb.Things[newObj.Name]; WeaponXfer weapon; ArmorXfer armor; AmmoXfer ammo; TeamXfer team; var enchants = new string[] { enchantment1.Text, enchantment2.Text, enchantment3.Text, enchantment4.Text }; switch (tt.Xfer) { case "WeaponXfer": weapon = newObj.GetExtraData <WeaponXfer>(); weapon.Enchantments = enchants; weapon.Durability = (short)durability.Value; if (ammoMin.Enabled && ammoMax.Enabled) { weapon.WandChargesCurrent = (byte)ammoMin.Value; weapon.WandChargesLimit = (byte)ammoMax.Value; } break; case "ArmorXfer": armor = newObj.GetExtraData <ArmorXfer>(); armor.Enchantments = enchants; armor.Durability = (short)durability.Value; break; case "AmmoXfer": ammo = newObj.GetExtraData <AmmoXfer>(); ammo.Enchantments = enchants; ammo.AmmoCurrent = (byte)ammoMin.Value; ammo.AmmoLimit = (byte)ammoMax.Value; break; case "TeamXfer": team = newObj.GetExtraData <TeamXfer>(); team.Enchantments = enchants; break; } return(newObj); }
void ButtonMonsterPropsClick(object sender, EventArgs e) { int index = monstersListBox.SelectedIndex; if (index >= 0) { Map.Object virtualObj; MonsterEdit monsterEditor = new MonsterEdit(); if (Xfer.MonsterData[index] == null) { // valid monster? if (currentMonsterName.SelectedIndex < 0) { return; } // new monster slot virtualObj = new Map.Object(currentMonsterName.Text, PointF.Empty); virtualObj.ReadRule1 = 0x40; // default data virtualObj.NewDefaultExtraData(); virtualObj.GetExtraData <MonsterXfer>().InitForMonsterName(currentMonsterName.Text); monsterEditor.SetObject(virtualObj); } else { // modify existing one virtualObj = new Map.Object(currentMonsterName.Text, PointF.Empty); BinaryReader br = new BinaryReader(new MemoryStream(Xfer.MonsterData[index])); virtualObj.ReadRule1 = br.ReadInt16(); br.BaseStream.Seek(19, SeekOrigin.Current); virtualObj.GetExtraData <MonsterXfer>().FromStream(br.BaseStream, virtualObj.ReadRule1, ThingDb.Things[virtualObj.Name]); monsterEditor.SetObject(virtualObj); } if (monsterEditor.ShowDialog() == DialogResult.OK) { virtualObj = monsterEditor.GetObject(); GenerateMonsterData(virtualObj); } } }
public override void SetObject(Map.Object obj) { this.obj = obj; typeOfKnowledge.Items.Clear(); switch (ThingDb.Things[obj.Name].Xfer) { case "FieldGuideXfer": FillMonsterIds(); typeOfKnowledge.Text = obj.GetExtraData <FieldGuideXfer>().MonsterThingType; break; case "SpellRewardXfer": FillSpellIds(); typeOfKnowledge.Text = obj.GetExtraData <SpellRewardXfer>().SpellName; break; case "AbilityRewardXfer": FillAbilityIds(); typeOfKnowledge.Text = obj.GetExtraData <AbilityRewardXfer>().AbilityName; break; } }
public override void SetObject(Map.Object obj) { this.obj = obj; ThingDb.Thing tt = ThingDb.Things[obj.Name]; TransporterXfer xfer = obj.GetExtraData <TransporterXfer>(); transpSelect.Items.Clear(); // из списка добавляем в gui string name; foreach (Map.Object e in listTeleporters) { name = e.ToString(); if (e.Scr_Name.Length > 0) { name = '"' + e.ScrNameShort + '"'; } transpSelect.Items.Add(name); } // с каким телепортером связан if (xfer.ExtentLink > 0) { checkIsLinked.Checked = true; int index = 0; foreach (Map.Object o in listTeleporters) { if (o.Extent == xfer.ExtentLink) { transpSelect.SelectedIndex = index; break; } index++; } } }
void MapView_DeletePressed(object sender, KeyEventArgs e) { if (SelectedObject != null) { int val = SelectedObject.UniqueID; Map.Objects.Remove(SelectedObject); SelectedObject = null; unsafe { MainWindow.myMap.DeleteObject((int)val); } mapPanel.Invalidate(); } }
private void button1_Click(object sender, EventArgs e) { ScriptFunctions me = new ScriptFunctions(); if (me.CheckMod(m_ExePath, obj.Name)) { ModEditor me2 = new ModEditor(obj, me, m_ExePath); me2.ShowDialog(); obj = me2.GetObj(); boxMod.Clear(); foreach (byte b in obj.modbuf) boxMod.Text += String.Format("{0:x2} ", b); } else { MessageBox.Show("There is no mod editor for that object."); } }
private void DrawObjects(Graphics g, List <Map.Object> objects, bool shadow = false) { Pen pen; PointF center, ptf, topLeft; ThingDb.Thing tt; Map.Object underCursor = null; if (MapInterface.CurrentMode == EditMode.OBJECT_SELECT || MainWindow.Instance.mapView.picking) { underCursor = MainWindow.Instance.mapView.GetObjectUnderCursor(); } if (mapRenderer.proDefault && underCursor == null) { MainWindow.Instance.mapView.mapPanel.Cursor = Cursors.Default; } bool drawExtents3D = EditorSettings.Default.Draw_Extents_3D; if (EditorSettings.Default.Draw_Objects) { foreach (Map.Object oe in objects) { var customRender = oe as CustomRenderObject; if (customRender != null) { customRender.Render(g); continue; } ptf = oe.Location; float x = ptf.X, y = ptf.Y; tt = ThingDb.Things[oe.Name]; center = new PointF(x, y); topLeft = new PointF(center.X - objectSelectionRadius, center.Y - objectSelectionRadius); pen = mapRenderer.ColorLayout.Objects; // Object facing helper if (EditorSettings.Default.Draw_ObjectFacing) { float deg = -1F; if (tt.Xfer == "MonsterXfer") { MonsterXfer xfer = oe.GetExtraData <MonsterXfer>(); deg = (float)MonsterXfer.NOX_DIRECT_VALS[xfer.DirectionId] / 256F * 360F; } if (tt.Xfer == "NPCXfer") { NPCXfer xfer = oe.GetExtraData <NPCXfer>(); deg = (float)MonsterXfer.NOX_DIRECT_VALS[xfer.DirectionId] / 256F * 360F; } if (deg >= 0F) { using (var m = new System.Drawing.Drawing2D.Matrix()) { m.RotateAt(deg, center); g.Transform = m; g.DrawLine(objMoveablePen, center.X, center.Y, center.X + 20, center.Y); g.ResetTransform(); } } // Sentry ray if (tt.Xfer == "SentryXfer") { SentryXfer sentry = oe.GetExtraData <SentryXfer>(); float targX = x + ((float)Math.Cos(sentry.BasePosRadian) * 80F); float targY = y + ((float)Math.Sin(sentry.BasePosRadian) * 80F); // show sentry ray direction g.DrawLine(sentryPen, x, y, targX, targY); } } // invisible triggers and pressure plates if (tt.DrawType == "TriggerDraw" || tt.DrawType == "PressurePlateDraw") { if (shadow) { DrawObjectExtent(g, oe, drawExtents3D); } //else // DrawTriggerExtent(g, oe, underCursor); continue; } // black powder if (EditorSettings.Default.Edit_PreviewMode) // Visual Preview { if (tt.DrawType == "BlackPowderDraw") { /* Rectangle bp = new Rectangle((int)x - 2, (int)y - 2, 4, 4); * g.FillRectangle(new SolidBrush(Color.Gray), bp);*/ continue; } if (tt.Xfer == "InvisibleLightXfer") { /*bool isUnderCursor = false; * * Pen Penlight = new Pen(Color.Yellow, 1); * if (underCursor != null) isUnderCursor = underCursor.Equals(oe); * * if (isUnderCursor) * Penlight = new Pen(Color.Orange, 1); * * bool isSelected = mapRenderer.SelectedObjects.Items.Contains(oe); * bool isSelected2 = MapInterface.RecSelected.Contains(oe); * if (isSelected && isSelected2 && MapInterface.KeyHelper.ShiftKey) * { * isSelected = false; * isSelected2 = false; * } * * * if (isSelected || isSelected2) * { * Penlight = Pens.DarkOrange; * if (mapRenderer.proHand && isUnderCursor) * MainWindow.Instance.mapView.mapPanel.Cursor = Cursors.Hand; * * } * * g.DrawEllipse(Penlight, new RectangleF(center.X - 9, center.Y - 9, 18, 18)); * g.DrawEllipse(Penlight, new RectangleF(center.X - 13, center.Y - 13, 26, 26)); * g.DrawEllipse(Penlight, new RectangleF(center.X - 17, center.Y - 17, 34, 34)); */ continue; } Bitmap image = GetObjectImage(oe, shadow); /*if (tt.Name.StartsWith("Amb") && image == null) * { * image = mapRenderer.VideoBag.GetBitmap(tt.SpriteMenuIcon); * drawOffsetX = 82; * drawOffsetY = 122; * }*/ if (image == null || tt.DrawType == "NoDraw") { // in case of failure draw only the extent //DrawObjectExtent(g, oe, drawExtents3D); } else { int sizeX = tt.SizeX / 2; int sizeY = tt.SizeY / 2; x -= (sizeX - drawOffsetX); y -= (sizeY - drawOffsetY) + tt.Z; // no blurring int ix = Convert.ToInt32(x); int iy = Convert.ToInt32(y); // recolor in case it is being selected bool isSelected = mapRenderer.SelectedObjects.Items.Contains(oe); bool isSelected2 = MapInterface.RecSelected.Contains(oe); if (isSelected && isSelected2 && MapInterface.KeyHelper.ShiftKey) { isSelected = false; isSelected2 = false; } bool isUnderCursor = false; if (underCursor != null) { isUnderCursor = underCursor.Equals(oe); } // draw the image if (isSelected || isUnderCursor || shadow || isSelected2) { // highlight selection var shader = new BitmapShader(image); shader.LockBitmap(); var hltColor = mapRenderer.ColorLayout.Selection; if (isSelected || isSelected2) { if (mapRenderer.proHand && isUnderCursor) { MainWindow.Instance.mapView.mapPanel.Cursor = Cursors.Hand; } shader.ColorShade(hltColor, 0.5F); } else if (isUnderCursor) { hltColor = Color.PaleGreen; if (MapInterface.CurrentMode == EditMode.OBJECT_PLACE && !MainWindow.Instance.mapView.picking) { hltColor = mapRenderer.ColorLayout.Removing; } shader.ColorGradWaves(hltColor, 7F, Environment.TickCount); } if (shadow) { shader.MakeSemitransparent(165); } image = shader.UnlockBitmap(); g.DrawImage(image, ix, iy, image.Width, image.Height); image.Dispose(); } else { g.DrawImage(image, ix, iy, image.Width, image.Height); } } } else { if (mapRenderer.SelectedObjects.Items.Contains(oe)) { pen = Pens.Green; } if (MapInterface.RecSelected.Contains(oe)) { pen = Pens.Green; } if ((mapRenderer.SelectedObjects.Items.Contains(oe) && MapInterface.RecSelected.Contains(oe))) { pen = mapRenderer.ColorLayout.Objects; } g.DrawEllipse(pen, new RectangleF(topLeft, new Size(2 * objectSelectionRadius, 2 * objectSelectionRadius)));//55 // If is a door if ((tt.Class & ThingDb.Thing.ClassFlags.DOOR) == ThingDb.Thing.ClassFlags.DOOR) { DoorXfer door = oe.GetExtraData <DoorXfer>(); if (door.Direction == DoorXfer.DOORS_DIR.South) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X - 20, (int)center.Y - 20)); if (drawExtents3D) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y - 40), new Point((int)center.X - 20, (int)center.Y - 60)); g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X - 20, (int)center.Y - 60)); g.DrawLine(doorPen, new Point((int)center.X - 20, (int)center.Y - 20), new Point((int)center.X - 20, (int)center.Y - 60)); } } else if (door.Direction == DoorXfer.DOORS_DIR.West) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X + 20, (int)center.Y - 20)); if (drawExtents3D) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y - 40), new Point((int)center.X + 20, (int)center.Y - 60)); g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X + 20, (int)center.Y - 60)); g.DrawLine(doorPen, new Point((int)center.X + 20, (int)center.Y - 20), new Point((int)center.X + 20, (int)center.Y - 60)); } } else if (door.Direction == DoorXfer.DOORS_DIR.North) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X + 20, (int)center.Y + 20)); if (drawExtents3D) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y - 40), new Point((int)center.X + 20, (int)center.Y - 20)); g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X + 20, (int)center.Y - 20)); g.DrawLine(doorPen, new Point((int)center.X + 20, (int)center.Y + 20), new Point((int)center.X + 20, (int)center.Y - 20)); } } else if (door.Direction == DoorXfer.DOORS_DIR.East) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X - 20, (int)center.Y + 20)); if (drawExtents3D) { g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y - 40), new Point((int)center.X - 20, (int)center.Y - 20)); g.DrawLine(doorPen, new Point((int)center.X, (int)center.Y), new Point((int)center.X - 20, (int)center.Y - 20)); g.DrawLine(doorPen, new Point((int)center.X - 20, (int)center.Y + 20), new Point((int)center.X - 20, (int)center.Y - 20)); } } } } if (EditorSettings.Default.Draw_Extents) { if (!(!EditorSettings.Default.Draw_AllExtents && oe.HasFlag(ThingDb.Thing.FlagsFlags.NO_COLLIDE))) { DrawObjectExtent(g, oe, drawExtents3D); } } } // Draw labels on the separate cycle to prevent layer glitching if (EditorSettings.Default.Draw_AllText) { foreach (Map.Object oe in objects) { Point textLocaton = new Point(Convert.ToInt32(oe.Location.X), Convert.ToInt32(oe.Location.Y)); textLocaton.X -= objectSelectionRadius; textLocaton.Y -= objectSelectionRadius; if (EditorSettings.Default.Draw_ObjCustomLabels && oe.Team > 0) { // Draw team Point loc = new Point(textLocaton.X, textLocaton.Y - 12); TextRenderer.DrawText(g, String.Format(FORMAT_OBJECT_TEAM, oe.Team), objectExtentFont, loc, Color.LightPink); } if (EditorSettings.Default.Draw_ObjCustomLabels && oe.Scr_Name.Length > 0) { // Draw custom label Size size = TextRenderer.MeasureText(oe.ScrNameShort, objectExtentFont); textLocaton.X -= size.Width / 3; TextRenderer.DrawText(g, oe.ScrNameShort, objectExtentFont, textLocaton, Color.Cyan); } else if (EditorSettings.Default.Draw_ObjThingNames) { // Draw thing name Size size = TextRenderer.MeasureText(oe.Name, objectExtentFont); textLocaton.X -= size.Width / 3; TextRenderer.DrawText(g, oe.Name, objectExtentFont, textLocaton, Color.Green); } else if (!EditorSettings.Default.Edit_PreviewMode && oe.Extent >= 0 && !(EditorSettings.Default.Draw_Extents || EditorSettings.Default.Draw_AllExtents)) { TextRenderer.DrawText(g, oe.Extent.ToString(), objectExtentFont, textLocaton, Color.Purple); } } } } }
public ModEditor(Map.Object objectMod,ScriptFunctions scrfuncs, string path) { InitializeComponent(); ClearNodes(); obj = objectMod; Scripting = scrfuncs; lblname.Text = obj.Name; lblextent.Text = obj.Extent.ToString(); m_ExePath = path; HandleMod(); }
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); } } }
private void mapPanel_MouseDown(object sender, MouseEventArgs e) { Point pt = new Point(e.X, e.Y); Point tilePt = GetNearestTilePoint(pt); Point wallPt = GetNearestWallPoint(pt); // if (CurrentMode != Mode.MAKE_WAYPOINT && CurrentMode != Mode.EDIT_WAYPOINT) // KeyStates.wp1 = null; if (e.Button.Equals(MouseButtons.Middle)/* && e.Clicks == 1*/)//if middle click { KeyStates.WheelClick = true; // KeyStates.lastX = mouseLocation.X; // KeyStates.lastY = mouseLocation.Y; if (CurrentMode == Mode.MAKE_FLOOR || CurrentMode == Mode.EDIT_EDGE) { threeFloorBox.Checked = !threeFloorBox.Checked; } // else if (CurrentMode == Mode.EDIT_WAYPOINT) //{ // Map.Waypoints.SetNameFromPoint(pt, wpNameBox.Text); // } } if (e.Button.Equals(MouseButtons.Right)/* && e.Clicks == 1*/)//if single right click { KeyStates.MRight = true; // Add context menu popup if( SelectedObject != null && (CurrentMode == Mode.MAKE_OBJECT || CurrentMode == Mode.SELECT)) contextMenu.Show(mapPanel,mouseLocation); if( CurrentMode == Mode.MAKE_FLOOR ) RemoveTile(tilePt); else if (CurrentMode == Mode.EDIT_EDGE) { RemoveEdge(tilePt); } else if (CurrentMode == Mode.MAKE_WAYPOINT) { Map.Waypoint wp = Map.Waypoints.GetWPFromPoint(pt); if (wp != null) { Map.Waypoints.Remove(wp); } //KeyStates.wp1 = null; } else if (CurrentMode == Mode.EDIT_WAYPOINT) { Map.Waypoint wp = Map.Waypoints.GetWPFromPoint(pt); if (wp != null && KeyStates.wp1 != null && KeyStates.wp1 != wp) { //wp.RemoveConnByNum(KeyStates.wp1); KeyStates.wp1.RemoveConnByNum(wp); KeyStates.wp1 = null; } else { KeyStates.wp1 = wp; } } } if (e.Button.Equals(MouseButtons.Left)/* && e.Clicks == 1*/)//if single left click { KeyStates.MLeft = true; if (CurrentMode == Mode.SELECT) { //dragging = Map.SelectObject(pointClicked) == SelectedObject;//only start "dragging" if this object has already been selected if (SelectObject(pt) == SelectedObject) dragging = true; else { SelectedObject = SelectObject(pt); KeyStates.MLeft = false; } } else if (CurrentMode == Mode.EDIT_EDGE) { EditEdge(tilePt); } else if (CurrentMode == Mode.MAKE_WALL) { if (!Map.Walls.ContainsKey(wallPt)) { Map.Walls.Add(wallPt, wallSelector.NewWall(wallPt)); Map.Wall.WallFacing facing = Map.Walls[wallPt].Facing; if ( facing == Map.Wall.WallFacing.NORTH || facing == Map.Wall.WallFacing.WEST) { Map.Walls[wallPt].Variation = CreateVariationW(wallPt, (ushort)Map.Walls[wallPt].Variation, (ushort)Map.Walls[wallPt].Variations, true); } else { Map.Walls[wallPt].Variation = CreateVariationW(wallPt, (ushort)Map.Walls[wallPt].Variation, (ushort)Map.Walls[wallPt].Variations, false); } wallDrag = wallPt; dragging = true; } else Map.Walls.Remove(wallPt); } else if (CurrentMode == Mode.MAKE_OBJECT) { string m_ExePath = Process.GetCurrentProcess().MainModule.FileName; m_ExePath = Path.GetDirectoryName(m_ExePath); Map.Object obj = (Map.Object)DefaultObject.Clone(); obj.Name = cboObjCreate.Items[cboObjCreate.SelectedIndex].ToString(); //boxMod.Clear(); string mod = ""; if (File.Exists(m_ExePath + "\\scripts\\objects\\defaultmods\\" + obj.Name + ".txt")) { StreamReader SR; SR = File.OpenText(m_ExePath + "\\scripts\\objects\\defaultmods\\" + obj.Name + ".txt"); if (SR != null) { obj.Properties = (Map.Object.Property)Convert.ToInt16(SR.ReadLine()); obj.Terminator = Convert.ToByte(SR.ReadLine()); while (!SR.EndOfStream) { mod += SR.ReadLine() + " "; } } SR.Close(); } //boxMod.Text = mod; if (mod.Length > 0) { MemoryStream stream = new MemoryStream(); BinaryWriter wtr = new BinaryWriter(stream); Regex bytes = new Regex("[0-9|a-f|A-F]{2}"); foreach (Match match in bytes.Matches(mod)) wtr.Write(Convert.ToByte(match.Value, 16)); obj.modbuf = stream.ToArray(); } else obj.modbuf = new byte[0]; //} if (SnapGrid)//snap to grid when grid is on pt = new Point((int)Math.Round((decimal)(pt.X / squareSize)) * squareSize, (int)Math.Round((decimal)(pt.Y / squareSize)) * squareSize); if (SnapHalfGrid)//snap to half grid when grid is on pt = new Point((int)Math.Round((decimal)((pt.X / (squareSize)) * squareSize) + squareSize / 2), (int)Math.Round((decimal)((pt.Y / (squareSize)) * squareSize) + squareSize / 2)); obj.Location = pt; obj.Extent = DefaultObject.Extent + 1; obj.UniqueID = IdCount++; while (Map.Objects.extents.Contains(obj.Extent)) obj.Extent++; Map.Objects.Add(obj); unsafe { IntPtr ptr = Marshal.StringToHGlobalAnsi(obj.Name); int val = obj.UniqueID; MainWindow.myMap.AddObject(ptr.ToPointer(), (int)obj.Location.X, (int)obj.Location.Y, val); } } else if (CurrentMode == Mode.MAKE_WINDOW) { if (Map.Walls.ContainsKey(wallPt)) Map.Walls[wallPt].Window = !Map.Walls[wallPt].Window; } else if (CurrentMode == Mode.MAKE_DESTRUCTABLE) { if (Map.Walls.ContainsKey(wallPt)) Map.Walls[wallPt].Destructable = !Map.Walls[wallPt].Destructable; } else if (CurrentMode == Mode.MAKE_SECRET) { if (Map.Walls.ContainsKey(wallPt)) { Map.Walls[wallPt].Secret = !Map.Walls[wallPt].Secret; Map.Walls[wallPt].Secret_flags = (uint)Map.Wall.SecretFlags.Unknown100; foreach (String s in secretFlagsBoxes.CheckedItems) Map.Walls[wallPt].Secret_flags = Map.Walls[wallPt].Secret_flags | (uint)Enum.Parse(typeof(Map.Wall.SecretFlags), s); } } else if (CurrentMode == Mode.MAKE_WAYPOINT) { int i; for (i = 1; Map.Waypoints.num_wp.ContainsKey(i); i++) ; Map.Waypoint wp = new Map.Waypoint(wpNameBox.Text, pt, i); wp.enabled = 1; Map.Waypoints.Add(wp); Map.Waypoints.num_wp.Add(i, wp); //if (chkAutoLink1.Checked && KeyStates.wp1 != null) //{ // wp.AddConnByNum(KeyStates.wp1, Convert.ToByte(txtWpDefault.Text)); //} //if (chkAutoLink2.Checked && KeyStates.wp1 != null) //{ // KeyStates.wp1.AddConnByNum(wp, Convert.ToByte(txtWpDefault.Text)); //} //KeyStates.wp1 = wp; } else if (CurrentMode == Mode.EDIT_WAYPOINT) { Map.Waypoint wp = Map.Waypoints.GetWPFromPoint(pt); if (wp != null && KeyStates.wp1 != null && wp != KeyStates.wp1) { //wp.AddConnByNum(KeyStates.wp1,Map.Waypoint.WaypointConnection.DefaultFlag); KeyStates.wp1.AddConnByNum(wp, Convert.ToByte(txtWpDefault.Text)); KeyStates.wp1 = null; } else { KeyStates.wp1 = wp; } } else if (CurrentMode == Mode.SELECT_WAYPOINT) { Map.Waypoint wp = Map.Waypoints.GetWPFromPoint(pt); if (wp != null && wp != KeyStates.wp1) { string oldname = wpNameBox.Text; OverrideChecking = true; checkBox3.Checked = Convert.ToBoolean(wp.enabled); OverrideChecking = false; wpNameBox.Text = wp.Name; if( KeyStates.wp1 !=null) KeyStates.wp1.Name = oldname; KeyStates.wp1 = wp; KeyStates.MLeft = false; } } else if (CurrentMode == Mode.MAKE_FLOOR) { AddTile(tilePt); } else if (CurrentMode == Mode.ADD_POLYGON_PT) { Map.Polygon poly = (Map.Polygon)Map.Polygons[listPolygons.SelectedIndex]; if (poly != null) poly.Points.Add(new PointF(pt.X, pt.Y)); } mapPanel.Invalidate(); } }
public static System.Object importXml(System.IO.Stream stream) { Type objType = null; Object member = null; FieldInfo fi; String temp = ""; XmlReader xmlReader = XmlReader.Create(stream); while (xmlReader.Read()) { switch (xmlReader.Name) { case "Object": member = new Map.Object(); objType = member.GetType(); break; default: break; } if (member != null) break; } if (member == null) { xmlReader.Close(); return member; } while (xmlReader.Read()) { if (xmlReader.IsStartElement()) if (!xmlReader.IsEmptyElement) { fi = objType.GetField(xmlReader.Name); switch (fi.FieldType.FullName) { case "System.Drawing.PointF": temp = xmlReader.ReadElementContentAsString(); fi.SetValue(member, new System.Drawing.PointF(Convert.ToSingle(temp.Split(' ')[0]), Convert.ToSingle(temp.Split(' ')[1]))); break; case "System.Byte[]": temp = xmlReader.ReadElementContentAsString(); if (temp.Length > 0) { System.IO.MemoryStream memstream = new System.IO.MemoryStream(); System.IO.BinaryWriter wtr = new System.IO.BinaryWriter(memstream); System.Text.RegularExpressions.Regex bytes = new System.Text.RegularExpressions.Regex("[0-9|a-f|A-F]{2}"); foreach (System.Text.RegularExpressions.Match match in bytes.Matches(temp)) wtr.Write(Convert.ToByte(match.Value, 16)); fi.SetValue(member, memstream.ToArray()); wtr.Close(); } break; case "NoxShared.Map+Object+Property": fi.SetValue(member, xmlReader.ReadElementContentAs(typeof(System.Int16), null)); break; case "System.Collections.ArrayList": break; case "System.Collections.Generic.List<>": break; default: try { fi.SetValue(member, xmlReader.ReadElementContentAs(fi.FieldType, null)); } catch { } break; } } } xmlReader.Close(); return member; }
public void RemoveObject(Point pt) { SelectedObject = SelectObject(pt); if (SelectedObject != null) { int val = SelectedObject.UniqueID; Map.Objects.Remove(SelectedObject); unsafe { MainWindow.myMap.DeleteObject((int)val); } } }