public UpdateMap ( bool periodicUpdate = false ) : void | ||
periodicUpdate | bool | |
return | void |
private void UtilityBox_Click(object sender, EventArgs e) { if (npcList == null) { Utility utility = city.utilities[int.Parse((sender as Control).Name)]; mapBox.mapCoordinate = new Coordinate(utility.location); mapBox.UpdateMap(); } else { NPC npc = npcList[int.Parse((sender as Control).Name)] as NPC; CommandManager.ExecuteCommand("npc" + Constants.CommandSymbol + npc.name); } }
public override void LoadForm() { this.SuspendForm(); this.NotificationInitialize(); huntLabel.Click -= c_Click; creatureLabel.Click -= c_Click; bossNameLabel.Click -= c_Click; bossPictureBox.Click -= c_Click; mapUpLevel.Click -= c_Click; mapDownLevel.Click -= c_Click; mapUpLevel.Image = StyleManager.GetImage("mapup.png"); mapDownLevel.Image = StyleManager.GetImage("mapdown.png"); mapBox.MapUpdated += MapBox_MapUpdated; pointsLabel.Text = task.taskpoints > 0 ? task.taskpoints.ToString() : "-"; countLabel.Text = task.count.ToString(); taskName.Text = task.GetName(); Creature boss = task.GetBoss(); if (boss != null) { bossNameLabel.Text = boss.GetName(); bossPictureBox.Image = boss.GetImage(); mapBox.targets.Add(new Target { coordinate = new Coordinate(task.bossposition), image = boss.GetImage(), size = 24 }); } else { bossNameLabel.Visible = false; bossPictureBox.Visible = false; bossInfoLabel.Visible = false; } mapBox.mapCoordinate = new Coordinate(task.bossposition); mapBox.map = StorageManager.getMap(task.bossposition.z); mapBox.sourceWidth = mapBox.Width; mapBox.Click -= c_Click; mapBox.UpdateMap(); taskGroupLabel.Text = task.groupname; baseWidth = this.Size.Width; baseHeight = this.Size.Height; refreshAttributes(); this.NotificationFinalize(); this.ResumeForm(); }
private void UpdateMap() { Target target = new Target(); target.coordinate = new Coordinate(targetCoordinate); target.image = StyleManager.GetImage("cross.png"); target.size = 12; if (mapBox.map != null) { mapBox.map.Dispose(); } mapBox.map = StorageManager.getMap(targetCoordinate.z); mapBox.targets.Clear(); mapBox.targets.Add(target); mapBox.mapCoordinate = new Coordinate(targetCoordinate); mapBox.sourceWidth = mapBox.Width; mapBox.UpdateMap(); }
private void UpdateMap() { Target target = new Target(); target.coordinate = new Coordinate(targetCoordinate); target.image = MainForm.cross_image; target.size = 12; if (mapBox.map != null) { mapBox.map.Dispose(); } mapBox.map = MainForm.getMap(targetCoordinate.z); mapBox.targets.Clear(); mapBox.targets.Add(target); mapBox.mapCoordinate = new Coordinate(targetCoordinate); mapBox.sourceWidth = mapBox.Width; mapBox.UpdateMap(); }
public override void LoadForm() { this.SuspendForm(); NotificationInitialize(); Coordinate coord = startCoordinate; if (coord == null) { try { MemoryReader.UpdateBattleList(); coord = new Coordinate(MemoryReader.X, MemoryReader.Y, MemoryReader.Z); } catch { coord = new Coordinate(); } } Map m = StorageManager.getMap(coord.z); mapBox.map = m; mapBox.mapImage = null; mapBox.sourceWidth = mapBox.Width; mapBox.beginCoordinate = new Coordinate(coord); mapBox.mapCoordinate = new Coordinate(coord); mapBox.zCoordinate = coord.z; mapBox.MapUpdated += MapBox_MapUpdated; mapBox.UpdateMap(); coordinateBox.Text = String.Format("{0},{1},{2}", coord.x, coord.y, coord.z); mapBox.Click -= c_Click; this.mapUpLevel.Image = StyleManager.GetImage("mapup.png"); this.mapUpLevel.Click -= c_Click; this.mapUpLevel.Click += mapUpLevel_Click; this.mapDownLevel.Image = StyleManager.GetImage("mapdown.png"); this.mapDownLevel.Click -= c_Click; this.mapDownLevel.Click += mapDownLevel_Click; base.NotificationFinalize(); this.ResumeForm(); }
public override void LoadForm() { if (npc == null) { return; } this.SuspendForm(); NotificationInitialize(); npcImage.Image = npc.GetImage(); creatureName.Text = MainForm.ToTitle(npc.city); Font f = MainForm.fontList[0]; for (int i = 0; i < MainForm.fontList.Count; i++) { Font font = MainForm.fontList[i]; Size size = TextRenderer.MeasureText(this.creatureName.Text, font); if (size.Width < creatureName.MaximumSize.Width && size.Height < creatureName.MaximumSize.Height) { f = font; } else { break; } } this.creatureName.Font = f; for (int i = 0; i < headers.Length; i++) { objectList[i] = new List <TibiaObject>(); } extraAttributes[0] = "Value"; attributeFunctions[0] = SellPrice; attributeSortFunctions[0] = SellSort; removedLists[0] = new List <string> { "Value" }; foreach (ItemSold itemSold in npc.sellItems) { objectList[0].Add(new LazyTibiaObject { id = itemSold.itemid, type = TibiaObjectType.Item }); } extraAttributes[1] = "Price"; attributeFunctions[1] = BuyPrice; attributeSortFunctions[1] = BuySort; removedLists[1] = new List <string> { "Value" }; foreach (ItemSold itemSold in npc.buyItems) { objectList[1].Add(new LazyTibiaObject { id = itemSold.itemid, type = TibiaObjectType.Item }); } extraAttributes[2] = "Vocation"; attributeFunctions[2] = SpellVoc; attributeSortFunctions[2] = SpellSort; removedLists[2] = new List <string> { "Words" }; foreach (SpellTaught spellTaught in npc.spellsTaught) { objectList[2].Add(new LazyTibiaObject { id = spellTaught.spellid, type = TibiaObjectType.Spell }); } // Transport foreach (Transport transport in npc.transportOffered) { objectList[3].Add(transport); } // Quests Involved In foreach (Quest q in npc.involvedQuests) { objectList[4].Add(q); } base_y = this.Size.Height; int x = 5; for (int i = 0; i < headers.Length; i++) { if (objectList[i].Count > 0) { Label label = new Label(); label.Text = headers[i]; label.Location = new Point(x, base_y); label.ForeColor = MainForm.label_text_color; label.BackColor = Color.Transparent; label.Font = MainForm.text_font; label.Size = new Size(90, 25); label.TextAlign = ContentAlignment.MiddleCenter; label.BorderStyle = BorderStyle.FixedSingle; label.Name = i.ToString(); label.Click += toggleObjectDisplay; objectControls[i] = label; this.Controls.Add(label); if (currentControlList < 0 || currentControlList > headers.Length) { currentControlList = i; } x += 90; } else { objectControls[i] = null; } } base_y += 25; Map m = MainForm.getMap(npc.pos.z); mapBox.map = m; mapBox.mapImage = null; Target t = new Target(); t.coordinate = new Coordinate(npc.pos); t.image = npc.GetImage(); t.size = 20; mapBox.targets.Add(t); mapBox.sourceWidth = mapBox.Width; mapBox.mapCoordinate = new Coordinate(npc.pos); mapBox.zCoordinate = npc.pos.z; mapBox.UpdateMap(); mapBox.Click -= c_Click; this.mapUpLevel.Image = MainForm.mapup_image; this.mapUpLevel.Click -= c_Click; this.mapUpLevel.Click += mapUpLevel_Click; this.mapDownLevel.Image = MainForm.mapdown_image; this.mapDownLevel.Click -= c_Click; this.mapDownLevel.Click += mapDownLevel_Click; refresh(); base.NotificationFinalize(); this.ResumeForm(); }
public override void LoadForm() { this.SuspendForm(); NotificationInitialize(); UnregisterControl(nextStepButton); npcImage.Image = imageObject == null?StyleManager.GetImage("cross.png") : imageObject.GetImage(); lock (npcImage.Image) { if (npcImage.Image.Width > npcImage.Width || npcImage.Image.Height > npcImage.Height) { npcImage.SizeMode = PictureBoxSizeMode.Zoom; } } creatureName.Text = imageObject == null ? "Target" : imageObject.GetName().ToTitle(); Font f = StyleManager.FontList[0]; for (int i = 0; i < StyleManager.FontList.Count; i++) { Font font = StyleManager.FontList[i]; Size size = TextRenderer.MeasureText(this.creatureName.Text, font); if (size.Width < creatureName.MaximumSize.Width && size.Height < creatureName.MaximumSize.Height) { f = font; } else { break; } } this.creatureName.Font = f; Map m = StorageManager.getMap(targetCoordinate.z); mapBox.map = m; mapBox.mapImage = null; Target t = new Target(); t.coordinate = new Coordinate(targetCoordinate); t.image = imageObject == null?StyleManager.GetImage("cross.png") : imageObject.GetImage(); t.size = 20; mapBox.targets.Add(t); mapBox.sourceWidth = mapBox.Width; mapBox.mapCoordinate = new Coordinate(targetCoordinate); mapBox.SetTargetCoordinate(new Coordinate(targetCoordinate)); mapBox.zCoordinate = targetCoordinate.z; mapBox.UpdateMap(); mapBox.MapUpdated += MapBox_MapUpdated; UnregisterControl(mapBox); this.mapUpLevel.Image = StyleManager.GetImage("mapup.png"); this.UnregisterControl(mapUpLevel); this.mapUpLevel.Click += mapUpLevel_Click; this.mapDownLevel.Image = StyleManager.GetImage("mapdown.png"); this.UnregisterControl(mapDownLevel); this.mapDownLevel.Click += mapDownLevel_Click; base.NotificationFinalize(); this.ResumeForm(); }
public static MapPictureBox DrawRoute(Coordinate begin, Coordinate end, Size pictureBoxSize, Size minSize, Size maxSize, List<Color> additionalWalkableColors, List<Target> targetList = null) { if (end.x >= 0 && begin.z != end.z) { throw new Exception("Can't draw route with different z-coordinates"); } Rectangle sourceRectangle; MapPictureBox pictureBox = new MapPictureBox(); if (pictureBoxSize.Width != 0) { pictureBox.Size = pictureBoxSize; } pictureBox.SizeMode = PictureBoxSizeMode.Zoom; if (targetList != null) { foreach (Target target in targetList) { pictureBox.targets.Add(target); } if (end.x < 0) { if (pictureBoxSize.Width == 0) { pictureBoxSize = new Size(Math.Min(Math.Max(end.z, minSize.Width), maxSize.Width), Math.Min(Math.Max(end.z, minSize.Height), maxSize.Height)); pictureBox.Size = pictureBoxSize; } Map map = getMap(begin.z); pictureBox.map = map; pictureBox.sourceWidth = end.z; pictureBox.mapCoordinate = new Coordinate(begin.x, begin.y, begin.z); pictureBox.zCoordinate = begin.z; pictureBox.UpdateMap(); return pictureBox; } } // First find the route at a high level Node beginNode = Pathfinder.GetNode(begin.x, begin.y, begin.z); Node endNode = Pathfinder.GetNode(end.x, end.y, end.z); List<Rectangle> collisionBounds = null; DijkstraNode highresult = Dijkstra.FindRoute(beginNode, endNode); if (highresult != null) { collisionBounds = new List<Rectangle>(); while (highresult != null) { highresult.rect.Inflate(5, 5); collisionBounds.Add(highresult.rect); highresult = highresult.previous; } if (collisionBounds.Count == 0) collisionBounds = null; } Map m = getMap(begin.z); DijkstraPoint result = Dijkstra.FindRoute(m.image, new Point(begin.x, begin.y), new Point(end.x, end.y), collisionBounds, additionalWalkableColors); if (result == null) { throw new Exception("Couldn't find route."); } // create a rectangle from the result double minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue; DijkstraPoint node = result; while (node != null) { if (node.point.X < minX) minX = node.point.X; if (node.point.Y < minY) minY = node.point.Y; if (node.point.X > maxX) maxX = node.point.X; if (node.point.Y > maxY) maxY = node.point.Y; node = node.previous; } minX -= 10; minY -= 10; maxX += 10; maxY += 10; int size = (int)Math.Max(maxX - minX, maxY - minY); sourceRectangle = new Rectangle((int)minX, (int)minY, size, size); if (pictureBoxSize.Width == 0) { pictureBoxSize = new Size(Math.Min(Math.Max(sourceRectangle.Width, minSize.Width), maxSize.Width), Math.Min(Math.Max(sourceRectangle.Height, minSize.Height), maxSize.Height)); pictureBox.Size = pictureBoxSize; } TibiaPath path = new TibiaPath(); path.begin = new Coordinate(begin); path.end = new Coordinate(end); path.path = result; pictureBox.paths.Add(path); pictureBox.map = m; pictureBox.sourceWidth = size; pictureBox.mapCoordinate = new Coordinate(sourceRectangle.X + sourceRectangle.Width / 2, sourceRectangle.Y + sourceRectangle.Height / 2, begin.z); pictureBox.zCoordinate = begin.z; pictureBox.UpdateMap(); return pictureBox; }
public static MapPictureBox DrawRoute(Coordinate begin, Coordinate end, Size pictureBoxSize, Size minSize, Size maxSize, List <Color> additionalWalkableColors, List <Target> targetList = null) { if (end.x >= 0 && begin.z != end.z) { throw new Exception("Can't draw route with different z-coordinates"); } Rectangle sourceRectangle; MapPictureBox pictureBox = new MapPictureBox(); if (pictureBoxSize.Width != 0) { pictureBox.Size = pictureBoxSize; } pictureBox.SizeMode = PictureBoxSizeMode.Zoom; if (targetList != null) { foreach (Target target in targetList) { pictureBox.targets.Add(target); } if (end.x < 0) { if (pictureBoxSize.Width == 0) { pictureBoxSize = new Size(Math.Min(Math.Max(end.z, minSize.Width), maxSize.Width), Math.Min(Math.Max(end.z, minSize.Height), maxSize.Height)); pictureBox.Size = pictureBoxSize; } Map map = StorageManager.getMap(begin.z); pictureBox.map = map; pictureBox.sourceWidth = end.z; pictureBox.mapCoordinate = new Coordinate(begin.x, begin.y, begin.z); pictureBox.zCoordinate = begin.z; pictureBox.UpdateMap(); return(pictureBox); } } // First find the route at a high level Node beginNode = Pathfinder.GetNode(begin.x, begin.y, begin.z); Node endNode = Pathfinder.GetNode(end.x, end.y, end.z); List <Rectangle> collisionBounds = null; DijkstraNode highresult = Dijkstra.FindRoute(beginNode, endNode); if (highresult != null) { collisionBounds = new List <Rectangle>(); while (highresult != null) { highresult.rect.Inflate(5, 5); collisionBounds.Add(highresult.rect); highresult = highresult.previous; } if (collisionBounds.Count == 0) { collisionBounds = null; } } Map m = StorageManager.getMap(begin.z); DijkstraPoint result = Dijkstra.FindRoute(m.image, new Point(begin.x, begin.y), new Point(end.x, end.y), collisionBounds, additionalWalkableColors); if (result == null) { throw new Exception("Couldn't find route."); } // create a rectangle from the result double minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue; DijkstraPoint node = result; while (node != null) { if (node.point.X < minX) { minX = node.point.X; } if (node.point.Y < minY) { minY = node.point.Y; } if (node.point.X > maxX) { maxX = node.point.X; } if (node.point.Y > maxY) { maxY = node.point.Y; } node = node.previous; } minX -= 10; minY -= 10; maxX += 10; maxY += 10; int size = (int)Math.Max(maxX - minX, maxY - minY); sourceRectangle = new Rectangle((int)minX, (int)minY, size, size); if (pictureBoxSize.Width == 0) { pictureBoxSize = new Size(Math.Min(Math.Max(sourceRectangle.Width, minSize.Width), maxSize.Width), Math.Min(Math.Max(sourceRectangle.Height, minSize.Height), maxSize.Height)); pictureBox.Size = pictureBoxSize; } TibiaPath path = new TibiaPath(); path.begin = new Coordinate(begin); path.end = new Coordinate(end); path.path = result; pictureBox.paths.Add(path); pictureBox.map = m; pictureBox.sourceWidth = size; pictureBox.mapCoordinate = new Coordinate(sourceRectangle.X + sourceRectangle.Width / 2, sourceRectangle.Y + sourceRectangle.Height / 2, begin.z); pictureBox.zCoordinate = begin.z; pictureBox.UpdateMap(); return(pictureBox); }
public override void LoadForm() { if (house == null) { return; } this.SuspendForm(); NotificationInitialize(); houseName.Text = house.GetName().ToTitle(); Font f = StyleManager.FontList[0]; for (int i = 0; i < StyleManager.FontList.Count; i++) { Font font = StyleManager.FontList[i]; Size size = TextRenderer.MeasureText(this.houseName.Text, font); if (size.Width < houseName.MaximumSize.Width && size.Height < houseName.MaximumSize.Height) { f = font; } else { break; } } this.houseName.Font = f; cityLabel.Text = house.city.ToString(); sizeLabel.Text = String.Format("{0} sqm", house.sqm); bedLabel.Text = house.beds.ToString(); if (house.world != null) { statusLabel.Text = house.occupied ? "rented" : (house.hoursleft <= 0 ? "free" : "auctioned"); if (house.occupied || house.hoursleft < 0) { timeLeftLabel.Visible = false; timeLeftHeader.Visible = false; } else { timeLeftLabel.Text = String.Format("{0}{1}", house.hoursleft > 24 ? house.hoursleft / 24 : house.hoursleft, house.hoursleft > 24 ? "D" : "h"); } } else { timeLeftHeader.Visible = false; statusHeader.Visible = false; timeLeftLabel.Visible = false; statusLabel.Visible = false; } Map m = StorageManager.getMap(house.pos.z); mapBox.map = m; mapBox.mapImage = null; Target t = new Target(); t.coordinate = new Coordinate(house.pos); t.image = house.GetImage(); t.size = 20; mapBox.targets.Add(t); mapBox.sourceWidth = mapBox.Width; mapBox.mapCoordinate = new Coordinate(house.pos); mapBox.zCoordinate = house.pos.z; mapBox.UpdateMap(); UnregisterControl(mapBox); this.mapUpLevel.Image = StyleManager.GetImage("mapup.png"); this.UnregisterControl(mapUpLevel); this.mapUpLevel.Click += mapUpLevel_Click; this.mapDownLevel.Image = StyleManager.GetImage("mapdown.png"); this.UnregisterControl(mapDownLevel); this.mapDownLevel.Click += mapDownLevel_Click; base.NotificationFinalize(); this.ResumeForm(); }