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(); }
private int drawDirections(Coordinate begin, Coordinate end, string settings, string description, int start_x, int y, bool variableSize, int imageCount, bool noText, out int width) { int mapSize = this.Size.Width / 2; Size minSize = new Size(mapSize, mapSize); List <Color> additionalWalkableColors = new List <Color>(); List <Target> targetList = new List <Target>(); // parse settings if (settings != null) { string[] splits = settings.ToLower().Split('@'); foreach (string split in splits) { string[] setting = split.Split('='); switch (setting[0]) { case "walkablecolor": string[] rgb = setting[1].Split(','); additionalWalkableColors.Add(Color.FromArgb(int.Parse(rgb[0]), int.Parse(rgb[1]), int.Parse(rgb[2]))); break; case "marking": Target target = new Target(); string[] coordinate = setting[1].Split(','); target.size = 12; target.image = StyleManager.GetImage("cross.png"); target.coordinate = new Coordinate(int.Parse(coordinate[0]), int.Parse(coordinate[1]), int.Parse(coordinate[2])); targetList.Add(target); break; case "markicon": Image image = null; switch (setting[1].ToLower()) { case "item": image = StorageManager.getItem(setting[2]).image; break; case "npc": image = StorageManager.getNPC(setting[2]).image; break; case "cr": image = StorageManager.getCreature(setting[2]).image; break; case "spell": image = StorageManager.getSpell(setting[2]).image; break; case "object": image = StorageManager.getWorldObject(setting[2]).image; break; default: throw new Exception("Unknown image type " + setting[1] + "."); } targetList[targetList.Count - 1].image = image; break; case "marksize": targetList[targetList.Count - 1].size = int.Parse(setting[1]); break; } } } if (targetList.Count == 0) { targetList = null; } MapPictureBox map = UIManager.DrawRoute(begin, end, variableSize ? new Size(0, 0) : new Size(mapSize, mapSize), minSize, new Size(mapSize, mapSize), additionalWalkableColors, targetList); width = map.Width + 5; if (!noText) { map.Location = new Point(this.Size.Width - (map.Width + 5), y); } else { map.Location = new Point(start_x, y); } map.MapUpdated += refreshTimer; this.Controls.Add(map); addedControls.Add(map); if (noText) { return(y + map.Height + 5); } if (description.Contains("@")) { int x = 5; int minheightoffset = 20; string[] questStrings = description.Split('@'); int minY = y + map.Size.Height + 10; foreach (string instruction in questStrings) { if (instruction == "") { y += 10; continue; } if (instruction.Contains("=")) { string[] splits = instruction.Split('='); if (splits[0].ToLower() == "cr" || splits[0].ToLower() == "npc" || splits[0].ToLower() == "item") { bool blockWidth = true; string imageString = splits[1]; if (splits[1].Contains(';')) { string[] options = splits[1].Split(';'); imageString = options[0]; for (int i = 1; i < options.Length; i++) { if (options[i].ToLower() == "blockheight") { blockWidth = false; } } } string command = ""; Image image = null; if (splits[0].ToLower() == "cr") { Creature cr = StorageManager.getCreature(imageString); image = cr.GetImage(); command = "creature" + Constants.CommandSymbol + cr.GetName().ToLower(); } else if (splits[0].ToLower() == "npc") { NPC npc = StorageManager.getNPC(imageString); image = npc.GetImage(); command = "npc" + Constants.CommandSymbol + npc.GetName().ToLower(); } else if (splits[0].ToLower() == "item") { Item item = StorageManager.getItem(imageString); image = item.GetImage(); command = "item" + Constants.CommandSymbol + item.GetName().ToLower(); } PictureBox pictureBox = new PictureBox(); pictureBox.Location = new Point(x, y); pictureBox.Image = image; pictureBox.SizeMode = PictureBoxSizeMode.Zoom; pictureBox.Size = new Size(image.Width, image.Height); pictureBox.BackColor = Color.Transparent; pictureBox.Name = command; pictureBox.Click += QuestTitle_Click; if (blockWidth) { x += pictureBox.Size.Width; minheightoffset = pictureBox.Size.Height + 5; } else { y += pictureBox.Size.Height; } addedControls.Add(pictureBox); this.Controls.Add(pictureBox); continue; } } Label label = new Label(); label.Location = new Point(x, y); label.ForeColor = StyleManager.NotificationTextColor; label.BackColor = Color.Transparent; label.Font = requirementFont; label.AutoSize = true; label.MaximumSize = new Size(this.Size.Width - (map.Size.Width) - x, 0); string labelText = CreateLinks(label, instruction); label.Text = labelText == "" ? "" : "- " + labelText; int labelHeight = 0; using (Graphics gr = Graphics.FromHwnd(label.Handle)) { labelHeight = (int)(gr.MeasureString(label.Text, label.Font, this.Size.Width - (map.Size.Width + 10) - x, StringFormat.GenericTypographic).Height * 1.2); } addedControls.Add(label); this.Controls.Add(label); y += Math.Max(labelHeight, minheightoffset); minheightoffset = 0; x = 5; } if (y < minY) { y = minY; } } else { Label label = new Label(); label.Location = new Point(5, y); label.ForeColor = StyleManager.NotificationTextColor; label.BackColor = Color.Transparent; label.Font = requirementFont; string labelText = CreateLinks(label, description); label.Text = labelText == "" ? "" : "- " + labelText; Size size; using (Graphics gr = Graphics.FromHwnd(label.Handle)) { size = gr.MeasureString(label.Text, label.Font, this.Size.Width - (map.Size.Width + 10)).ToSize(); label.Size = new Size(this.Size.Width - (map.Size.Width + 5), Math.Max((int)(size.Height * 1.3), map.Size.Height)); } addedControls.Add(label); this.Controls.Add(label); y += Math.Max(label.Size.Height, map.Size.Height) + 10; } return(y); }