public void UpdateSummaryForm() { int minheight, maxheight; ClearControlList(summaryControls, out minheight, out maxheight); int y = maxheight < 0 ? 30 : minheight; PictureBox loot = CreateSummaryLabel("Loot value (gp)", totalValue.ToString("N0"), x, ref y, StyleManager.ItemGoldColor, summaryControls); tooltip.SetToolTip(loot, String.Format("Average gold for these creature kills: {0} gold.", averageValue.ToString("N0"))); CreateSummaryLabel("Exp gained", HuntManager.activeHunt.totalExp.ToString("N0"), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Time", LootDropForm.TimeToString((long)HuntManager.activeHunt.totalTime), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Supplies used (gp)", totalWaste.ToString("N0"), x, ref y, StyleManager.WasteColor, summaryControls); long profit = totalValue - totalWaste; CreateSummaryLabel(profit > 0 ? "Profit (gp)" : "Waste (gp)", profit.ToString("N0"), x, ref y, profit > 0 ? StyleManager.ItemGoldColor : StyleManager.WasteColor, summaryControls); if (ScanningManager.lastResults != null) { CreateSummaryLabel("Exp/hour", ScanningManager.lastResults.expPerHour.ToString("N0"), x, ref y, StyleManager.NotificationTextColor, summaryControls); } if (MemoryReader.experience >= 0) { long baseExperience = ExperienceBar.GetExperience(MemoryReader.level - 1); long exp = MemoryReader.experience - baseExperience; long maxExp = ExperienceBar.GetExperience(MemoryReader.level) - baseExperience; double percentage = ((double)exp) / ((double)maxExp); if (percentage >= 0 && percentage <= 1) { var levelBar = CreateSummaryBar("Level", String.Format("{0:0.}%", percentage * 100), percentage, x, ref y, StyleManager.NotificationTextColor, StyleManager.SummaryExperienceColor, summaryControls); tooltip.SetToolTip(levelBar, String.Format("Experience to level up: {0}", (maxExp - exp).ToString("N0"))); } } }
private void RefreshWaste() { foreach (Control c in wasteControls) { Controls.Remove(c); c.Dispose(); } wasteControls.Clear(); int base_x = 5, x = 0; int base_y = 32, y = 0; int max_x = this.Size.Width - 5; Size item_size = new Size(32, 32); int item_spacing = 4; foreach (var tpl in HuntManager.GetUsedItems(hunt)) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (x >= (max_x - item_size.Width - item_spacing)) { x = 0; y += item_size.Height + item_spacing; } int mitems = 1; if (item.stackable) { mitems = Math.Min(count, 100); } count -= mitems; PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = item.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Click += openItem_Click; if (item.stackable) { picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } else { picture_box.Image = item.GetImage(); } picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.BackgroundImage = StyleManager.GetImage("item_background.png"); this.Controls.Add(picture_box); wasteControls.Add(picture_box); x += item_size.Width + item_spacing; } } this.Size = new Size(this.Size.Width, base_y + y + item_size.Height + item_spacing * 2); }
public static Bitmap DrawCountOnItem(Item item, int itemCount) { Bitmap image; if (item.stackable) { try { image = new Bitmap(LootDropForm.GetStackImage(item.image, itemCount, item)); } catch { image = new Bitmap(item.image); } } else { image = new Bitmap(item.image); } using (Graphics gr = Graphics.FromImage(image)) { int numbers = (int)Math.Floor(Math.Log(itemCount, 10)) + 1; int xoffset = 1, logamount = itemCount; for (int i = 0; i < numbers; i++) { int imagenr = logamount % 10; Image imageNumber = StyleManager.GetImage(imagenr + ".png"); xoffset = xoffset + imageNumber.Width + (itemCount >= 1000 ? 0 : 1); lock (imageNumber) { gr.DrawImage(imageNumber, new Point(image.Width - xoffset, image.Height - imageNumber.Height - 3)); } logamount /= 10; } } return(image); }
public static Bitmap DrawCountOnItem(Item item, int itemCount) { Bitmap image; if (item.stackable) { image = new Bitmap(LootDropForm.GetStackImage(item.image, itemCount, item)); } else { image = new Bitmap(item.image); } using (Graphics gr = Graphics.FromImage(image)) { int numbers = (int)Math.Floor(Math.Log(itemCount, 10)) + 1; int xoffset = 1, logamount = itemCount; for (int i = 0; i < numbers; i++) { int imagenr = logamount % 10; xoffset = xoffset + MainForm.image_numbers[imagenr].Width + (itemCount >= 1000 ? 0 : 1); gr.DrawImage(MainForm.image_numbers[imagenr], new Point(image.Width - xoffset, image.Height - MainForm.image_numbers[imagenr].Height - 3)); logamount /= 10; } } return(image); }
public static void ShowLootDrops(Hunt h, string comm, string screenshot_path) { LootDropForm ldf = new LootDropForm(comm); ldf.hunt = h; ShowNotification(ldf, comm, screenshot_path); }
public void UpdateSummaryForm() { int minheight, maxheight; ClearControlList(summaryControls, out minheight, out maxheight); int y = maxheight < 0 ? 30 : minheight; CreateSummaryLabel("Loot", totalValue.ToString(), x, ref y, StyleManager.ItemGoldColor, summaryControls); CreateSummaryLabel("Exp", HuntManager.activeHunt.totalExp.ToString(), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Time", LootDropForm.TimeToString((long)HuntManager.activeHunt.totalTime), x, ref y, StyleManager.NotificationTextColor, summaryControls); }
private void UpdateLootInternal() { refreshTimer(); var tpl = LootDropForm.GenerateLootInformation(hunt, rawName, lootCreature); creatures = tpl.Item1; items = tpl.Item2; this.SuspendForm(); RefreshLoot(); this.ResumeForm(); }
private void DisplayItem(ItemDrop drop, int base_x, int base_y, int x, int y, Size item_size, ToolTip droprate_tooltip, int dropbar_height, string prefix = "Drop rate of ") { Item dropItem = StorageManager.getItem(drop.itemid); // the main picture of the item PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = dropItem.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Image = drop.max > 1 ? LootDropForm.DrawCountOnItem(dropItem, drop.max) : dropItem.GetImage(); picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.BackgroundImage = StyleManager.GetImage("item_background.png"); picture_box.Click += openItemBox; droprate_tooltip.SetToolTip(picture_box, prefix + dropItem.displayname + " is " + (drop.percentage >= 0 ? Math.Round(drop.percentage, 1).ToString() + "%." : "unknown.")); this.Controls.Add(picture_box); itemControls.Add(picture_box); // the 'dropbar' that roughly displays the droprate of the item PictureBox dropbar_box = new PictureBox(); Brush brush; dropbar_box.Location = new System.Drawing.Point(base_x + x, base_y + y + item_size.Height); dropbar_box.Name = "dropbar_image"; dropbar_box.Size = new System.Drawing.Size(item_size.Width, dropbar_height); dropbar_box.TabIndex = 1; dropbar_box.TabStop = false; Image image = new Bitmap(dropbar_box.Width, dropbar_box.Height); Graphics gr = Graphics.FromImage(image); gr.FillRectangle(Brushes.DarkGray, new Rectangle(0, 0, item_size.Width, dropbar_height)); //dropbar base bar if (drop.percentage < 1) { brush = Brushes.DarkRed; // <1% is red } else if (drop.percentage < 15) { brush = Brushes.Yellow; //<15% is yellow } else { brush = Brushes.ForestGreen; //everything else is green } gr.FillRectangle(brush, new Rectangle(0, 0, (int)(Math.Ceiling(item_size.Width * drop.percentage / 100) + 1), dropbar_height)); dropbar_box.Image = image; this.Controls.Add(dropbar_box); itemControls.Add(dropbar_box); }
private static void RenderItemCount(Graphics gr, Tuple <Item, int> item, Rectangle region) { if (region.Width > 28) { RenderImageResized(gr, item.Item1.GetImage(), region); if (item.Item1.stackable || item.Item2 > 1) { LootDropForm.DrawCountOnGraphics(gr, item.Item2, region.X + region.Width - 1, region.Y + region.Height - 1); } } else { RenderImageResized(gr, (item.Item1.stackable || item.Item2 > 1) ? LootDropForm.DrawCountOnItem(item.Item1, item.Item2) : item.Item1.GetImage(), region); } }
public void UpdateLoot() { if (this.IsDisposed) { return; } refreshTimer(); var tpl = LootDropForm.GenerateLootInformation(hunt, rawName, lootCreature); creatures = tpl.Item1; items = tpl.Item2; this.SuspendForm(); RefreshLoot(); this.ResumeForm(); }
public Image ItemBox(Item item, int amount = 0) { Bitmap bitmap = new Bitmap(ImageWidth, ImageHeight); using (Graphics gr = Graphics.FromImage(bitmap)) { using (Brush brush = new SolidBrush(StyleManager.MainFormButtonColor)) { gr.FillRectangle(brush, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); } gr.DrawRectangle(Pens.Black, new Rectangle(0, 0, bitmap.Width - 1, bitmap.Height - 1)); RenderImageResized(gr, StyleManager.GetImage("item_background.png"), new Rectangle(1, 1, ImageHeight - 2, ImageHeight - 2)); RenderImageResized(gr, (amount > 1 || item.stackable) ? LootDropForm.GetStackImage(item.GetImage(), amount > 0 ? amount : 1, item) : item.GetImage(), new Rectangle(1, 1, ImageHeight - 2, ImageHeight - 2)); RenderText(gr, item.displayname.ToTitle(), ImageHeight + 2, Color.Empty, StyleManager.NotificationTextColor); if (amount > 0) { RenderText(gr, amount.ToString(), -ImageWidth, Color.FromArgb(StyleManager.MainFormButtonColor.R / 2, StyleManager.MainFormButtonColor.G / 2, StyleManager.MainFormButtonColor.B / 2), StyleManager.NotificationTextColor); } } return(bitmap); }
public void UpdateSummaryForm() { int minheight, maxheight; ClearControlList(summaryControls, out minheight, out maxheight); int y = maxheight < 0 ? 30 : minheight; PictureBox loot = CreateSummaryLabel("Loot value (gp)", totalValue.ToString("N0"), x, ref y, StyleManager.ItemGoldColor, summaryControls); tooltip.SetToolTip(loot, String.Format("Average gold for these creature kills: {0} gold.", averageValue.ToString("N0"))); CreateSummaryLabel("Exp gained", HuntManager.activeHunt.totalExp.ToString("N0"), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Time", LootDropForm.TimeToString((long)HuntManager.activeHunt.totalTime), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Supplies used (gp)", totalWaste.ToString("N0"), x, ref y, StyleManager.WasteColor, summaryControls); long profit = totalValue - totalWaste; CreateSummaryLabel(profit > 0 ? "Profit (gp)" : "Waste (gp)", profit.ToString("N0"), x, ref y, profit > 0 ? StyleManager.ItemGoldColor : StyleManager.WasteColor, summaryControls); if (ScanningManager.lastResults != null) { CreateSummaryLabel("Exp/hour", ScanningManager.lastResults.expPerHour.ToString("N0"), x, ref y, StyleManager.NotificationTextColor, summaryControls); } }
public static Bitmap DrawCountOnItem(Item item, int itemCount, int size = -1) { Bitmap image; if (item.stackable) { try { image = new Bitmap(LootDropForm.GetStackImage(item.image, itemCount, item)); } catch { image = new Bitmap(item.image); } } else { image = new Bitmap(item.image); } using (Graphics gr = Graphics.FromImage(image)) { DrawCountOnGraphics(gr, itemCount, image.Width, image.Height); } return(image); }
public static void ShowLootDrops(Hunt h, string comm, string screenshot_path) { LootDropForm ldf = new LootDropForm(comm); ldf.hunt = h; ShowNotification(ldf, comm, screenshot_path); }
public SimpleLootNotification(Creature cr, List <Tuple <Item, int> > items, string message) : base() { this.InitializeComponent(); this.creature = cr; this.Size = new Size(SettingsManager.getSettingInt("SimpleNotificationWidth"), this.Size.Height); bool showCopyButton = SettingsManager.getSettingBool("SimpleNotificationCopyButton"); this.InitializeSimpleNotification(); creatureBox.Click -= c_Click; ToolTip value_tooltip = new ToolTip(); value_tooltip.AutoPopDelay = 60000; value_tooltip.InitialDelay = 500; value_tooltip.ReshowDelay = 0; value_tooltip.ShowAlways = true; value_tooltip.UseFading = true; int max_x = this.Size.Width - creatureBox.Width - (showCopyButton ? 32 : 4); int base_x = 64, base_y = 20; int x = 0; int y = 0; int item_spacing = 4; Size item_size = new Size(32, 32); List <Tuple <Item, int> > updatedItems = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in items) { if (tpl.Item1.GetName().ToLower() == "gold coin" && tpl.Item2 > 100) { Item platinumCoin = StorageManager.getItem("platinum coin"); updatedItems.Add(new Tuple <Item, int>(platinumCoin, tpl.Item2 / 100)); updatedItems.Add(new Tuple <Item, int>(tpl.Item1, tpl.Item2 % 100)); } else { updatedItems.Add(tpl); } } updatedItems = updatedItems.OrderByDescending(o => o.Item1.GetMaxValue() * o.Item2).ToList(); x = 0; foreach (Tuple <Item, int> tpl in updatedItems) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (x >= (max_x - item_size.Width - item_spacing)) { item_size = new Size(24, 24); x = 0; base_y = 4; creatureDropLabel.Visible = false; break; } int mitems = 1; if (item.stackable) { mitems = Math.Min(count, 100); } count -= mitems; x += item_size.Width + item_spacing; } if (x == 0) { break; } } x = 0; foreach (Tuple <Item, int> tpl in updatedItems) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (x >= (max_x - item_size.Width - item_spacing)) { x = 0; y = y + item_size.Height + item_spacing; } int mitems = 1; if (item.stackable) { mitems = Math.Min(count, 100); } count -= mitems; PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = item.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Click += openItem_Click; if (item.stackable) { picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } else { picture_box.Image = item.GetImage(); } picture_box.SizeMode = PictureBoxSizeMode.Zoom; picture_box.BackgroundImage = StyleManager.GetImage("item_background.png"); picture_box.BackgroundImageLayout = ImageLayout.Zoom; value_tooltip.SetToolTip(picture_box, item.displayname.ToTitle() + " value: " + Math.Max(item.actual_value, item.vendor_value) * mitems); this.Controls.Add(picture_box); x += item_size.Width + item_spacing; } } Image creatureImage = cr.GetImage(); if (creatureImage.Size.Width <= creatureBox.Width && creatureImage.Size.Height <= creatureBox.Height) { creatureBox.SizeMode = PictureBoxSizeMode.CenterImage; } else { creatureBox.SizeMode = PictureBoxSizeMode.Zoom; } this.creatureBox.Image = cr.GetImage(); this.creatureDropLabel.Text = String.Format("Loot of {0}.", cr.displayname); if (showCopyButton) { PictureBox copyButton = new PictureBox(); copyButton.Size = new Size(32, 32); copyButton.BackColor = Color.Transparent; copyButton.Location = new Point(this.Size.Width - copyButton.Size.Width - 4, base_y == 4 ? (this.Size.Height - copyButton.Size.Height) / 2 : base_y); copyButton.Click += CopyLootText; copyButton.Name = message; copyButton.Image = StyleManager.GetImage("copyicon.png"); copyButton.SizeMode = PictureBoxSizeMode.Zoom; this.Controls.Add(copyButton); } }
public static bool ExecuteCommand(string command, ParseMemoryResults parseMemoryResults = null) { try { if (parseMemoryResults == null) { parseMemoryResults = ScanningManager.lastResults; } string comp = command.Trim().ToLower(); Console.WriteLine(command); if (comp.StartsWith("creature" + Constants.CommandSymbol)) //creature@ { string[] split = command.Split(Constants.CommandSymbol); string parameter = split[1].Trim().ToLower(); Creature cr = StorageManager.getCreature(parameter); if (cr != null) { NotificationManager.ShowCreatureDrops(cr, command); } else { List <TibiaObject> creatures = StorageManager.searchCreature(parameter); if (creatures.Count == 1) { NotificationManager.ShowCreatureDrops(creatures[0].AsCreature(), command); } else if (creatures.Count > 1) { NotificationManager.ShowCreatureList(creatures, "Creature List", command); } } } else if (comp.StartsWith("look" + Constants.CommandSymbol)) //look@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); if (parameter == "on") { SettingsManager.setSetting("LookMode", "True"); } else if (parameter == "off") { SettingsManager.setSetting("LookMode", "False"); } else { List <string> times = TimestampManager.getLatestTimes(5); List <TibiaObject> items = new List <TibiaObject>(); foreach (string message in GlobalDataManager.GetLookInformation(times)) { string itemName = Parser.parseLookItem(message).ToLower(); Item item = StorageManager.getItem(itemName); if (item != null) { items.Add(item); } else { Creature cr = StorageManager.getCreature(itemName); if (cr != null) { items.Add(cr); } } } if (items.Count == 1) { if (items[0] is Item) { NotificationManager.ShowItemNotification("item" + Constants.CommandSymbol + items[0].GetName().ToLower()); } else if (items[0] is Creature) { NotificationManager.ShowCreatureDrops(items[0].AsCreature(), command); } } else if (items.Count > 1) { NotificationManager.ShowCreatureList(items, "Looked At Items", command); } } } else if (comp.StartsWith("stats" + Constants.CommandSymbol)) //stats@ { string name = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Creature cr = StorageManager.getCreature(name); if (cr != null) { NotificationManager.ShowCreatureStats(cr, command); } } else if (comp.StartsWith("close" + Constants.CommandSymbol)) //close@ // close all notifications { NotificationManager.ClearNotifications(); PopupManager.ClearSimpleNotifications(); } else if (comp.StartsWith("delete" + Constants.CommandSymbol)) //delete@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); int killCount; if (int.TryParse(parameter, out killCount)) { HuntManager.deleteCreatureWithThreshold(killCount); } else { Creature cr = StorageManager.getCreature(parameter); if (cr != null) { HuntManager.deleteCreatureFromLog(cr); } } } else if (comp.StartsWith("skin" + Constants.CommandSymbol)) //skin@ { string[] split = command.Split(Constants.CommandSymbol); string parameter = split[1].Trim().ToLower(); int count = 1; Creature cr = StorageManager.getCreature(parameter); if (cr != null) { if (split.Length > 2) { int.TryParse(split[2], out count); } HuntManager.InsertSkin(cr, count); } else { int.TryParse(parameter, out count); // find creature with highest killcount with a skin and skin that cr = HuntManager.GetHighestKillCreature(HuntManager.activeHunt); if (cr != null) { HuntManager.InsertSkin(cr, count); } } } else if (comp.StartsWith("city" + Constants.CommandSymbol)) //city@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); if (StorageManager.cityNameMap.ContainsKey(parameter)) { City city = StorageManager.cityNameMap[parameter]; NotificationManager.ShowCityDisplayForm(city, command); } } else if (comp.StartsWith("damage" + Constants.CommandSymbol)) //damage@ { if (parseMemoryResults != null) { string[] splits = command.Split(Constants.CommandSymbol); string screenshot_path = ""; string parameter = splits[1].Trim().ToLower(); if (parameter == "screenshot" && splits.Length > 2) { parameter = ""; screenshot_path = splits[2]; } NotificationManager.ShowDamageMeter(parseMemoryResults.damagePerSecond, command, parameter, screenshot_path); } } else if (comp.StartsWith("experience" + Constants.CommandSymbol)) //experience@ { if (parseMemoryResults != null) { NotificationManager.ShowExperienceChartNotification(command); } } else if (comp.StartsWith("remindme" + Constants.CommandSymbol)) //remindme@ { string[] splits = command.Split(Constants.CommandSymbol); string time = splits[1].ToLower().Replace(" ", "").Replace("\t", "").Replace("\n", "") + 's'; //remove all whitespace int timeInSeconds = 0; int startIndex = 0, endIndex = 0; for (int i = 0; i < time.Length; i++) { if (time[i].isDigit()) { endIndex = i + 1; } else if (endIndex > startIndex) { int value = int.Parse(time.Substring(startIndex, endIndex - startIndex)); if (time[i] == 'm') { value *= 60; } else if (time[i] == 'h') { value *= 3600; } timeInSeconds += value; startIndex = i + 1; endIndex = startIndex; } else { startIndex = i + 1; } } if (timeInSeconds > 0) { Image iconImage = null; if (splits.Length > 4) { string icon = splits[4]; TibiaObject[] objects = new TibiaObject[] { StorageManager.getItem(icon), StorageManager.getCreature(icon), StorageManager.getNPC(icon), StorageManager.getMount(icon), StorageManager.getSpell(icon), StorageManager.getOutfit(icon) }; foreach (var obj in objects) { if (obj != null) { iconImage = obj.GetImage(); if (iconImage != null) { break; } } } } string title = splits.Length > 2 ? splits[2] : "Reminder!"; string message = splits.Length > 3 ? splits[3] : String.Format("Reminder from {0} seconds ago!", timeInSeconds); const int notificationWarningTime = 5; if (timeInSeconds <= notificationWarningTime) { PopupManager.ShowSimpleNotification(new SimpleTimerNotification(iconImage, title, message, timeInSeconds)); } else { System.Timers.Timer timer = new System.Timers.Timer(1000 * (timeInSeconds - notificationWarningTime)); timer.Elapsed += (sender, e) => { timer.Enabled = false; timer.Dispose(); MainForm.mainForm.Invoke((MethodInvoker) delegate { PopupManager.ShowSimpleNotification(new SimpleTimerNotification(iconImage, title, message, notificationWarningTime)); }); }; timer.Enabled = true; } } } else if (comp.StartsWith("exp" + Constants.CommandSymbol)) //exp@ { string title = "Experience"; string text = "Currently gaining " + (parseMemoryResults == null ? "unknown" : ((int)parseMemoryResults.expPerHour).ToString()) + " experience an hour."; Image image = StyleManager.GetImage("tibia.png"); if (!SettingsManager.getSettingBool("UseRichNotificationType")) { PopupManager.ShowSimpleNotification(title, text, image); } else { PopupManager.ShowSimpleNotification(new SimpleTextNotification(null, title, text)); } } else if (comp.StartsWith("waste" + Constants.CommandSymbol)) //waste@ { NotificationManager.ShowWasteForm(HuntManager.activeHunt, command); } else if (comp.StartsWith("summary" + Constants.CommandSymbol)) //summary@ { NotificationManager.ShowSummaryForm(command); } else if (comp.StartsWith("loot" + Constants.CommandSymbol)) //loot@ { string[] splits = command.Split(Constants.CommandSymbol); string screenshot_path = ""; string parameter = splits[1].Trim().ToLower(); if (parameter == "screenshot" && splits.Length > 2) { parameter = ""; screenshot_path = splits[2]; } Hunt currentHunt = HuntManager.activeHunt; if (splits.Length >= 2 && splits[1] != "") { Hunt h = HuntManager.GetHunt(splits[1]); if (h != null) { currentHunt = h; } } // display loot notification NotificationManager.ShowLootDrops(currentHunt, command, screenshot_path); } else if (comp.StartsWith("clipboard" + Constants.CommandSymbol)) //clipboard@ // Copy loot message to the clipboard // clipboard@damage copies the damage information to the clipboard // clipboard@<creature> copies the loot of a specific creature to the clipboard // clipboard@ copies all loot to the clipboard { string creatureName = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Creature lootCreature = null; if (creatureName == "damage" && parseMemoryResults != null) { var damageInformation = DamageChart.GenerateDamageInformation(parseMemoryResults.damagePerSecond, ""); string damageString = "Damage Dealt: "; foreach (var damage in damageInformation) { damageString += String.Format("{0}: {1:N1}%; ", damage.name, damage.percentage); } Clipboard.SetText(damageString.Substring(0, damageString.Length - 2)); return(true); } else if (creatureName != "") { lootCreature = StorageManager.getCreature(creatureName); } var tpl = LootDropForm.GenerateLootInformation(HuntManager.activeHunt, "", lootCreature); var creatureKills = tpl.Item1; var itemDrops = tpl.Item2; string lootString = ""; if (creatureKills.Count == 1) { foreach (KeyValuePair <Creature, int> kvp in creatureKills) { lootString = "Total Loot of " + kvp.Value.ToString() + " " + kvp.Key.GetName() + (kvp.Value > 1 ? "s" : "") + ": "; } } else { int totalKills = 0; foreach (KeyValuePair <Creature, int> kvp in creatureKills) { totalKills += kvp.Value; } lootString = "Total Loot of " + totalKills + " Kills: "; } foreach (Tuple <Item, int> kvp in itemDrops) { lootString += kvp.Item2 + " " + kvp.Item1.displayname + (kvp.Item2 > 1 ? "s" : "") + ", "; } lootString = lootString.Substring(0, lootString.Length - 2) + "."; Clipboard.SetText(lootString); } else if (comp.StartsWith("reset" + Constants.CommandSymbol)) //reset@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); int time = 0; if (parameter == "old") { HuntManager.clearOldLog(HuntManager.activeHunt); } else if (int.TryParse(parameter, out time) && time > 0) { HuntManager.clearOldLog(HuntManager.activeHunt, time); } else { // reset@<hunt> resets the specified hunt if (parameter.Length > 0 && HuntManager.resetHunt(parameter)) { return(true); } else { //reset@ deletes all loot from the currently active hunt HuntManager.resetHunt(HuntManager.activeHunt); } } MainForm.mainForm.refreshHunts(); ReadMemoryManager.ignoreStamp = TimestampManager.createStamp(); } else if (comp.StartsWith("refresh" + Constants.CommandSymbol)) //refresh@ // refresh: refresh duration on current form, or if no current form, repeat last command without removing it from stack /*if (tooltipForm != null && !tooltipForm.IsDisposed) { * try { * (tooltipForm as NotificationForm).ResetTimer(); * } catch { * } * } else if (command_stack.Count > 0) {*/ { ExecuteCommand(NotificationManager.LastCommand().command); //} return(true); } else if (comp.StartsWith("switch" + Constants.CommandSymbol)) //switch@ // switch: switch to hunt { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); HuntManager.SwitchHunt(parameter); HuntManager.SaveHunts(); } else if (comp.StartsWith("item" + Constants.CommandSymbol)) //item@ //show the item with all the NPCs that sell it { NotificationManager.ShowItemNotification(command); } else if (comp.StartsWith("task" + Constants.CommandSymbol)) //task@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); if (StorageManager.taskList.Keys.Contains(parameter)) { NotificationManager.ShowCreatureList(StorageManager.taskList[parameter].ToList <TibiaObject>(), StorageManager.taskList[parameter][0].groupname, command); } else { int id = -1; int.TryParse(parameter, out id); List <TibiaObject> tasks = new List <TibiaObject>(); foreach (KeyValuePair <string, List <Task> > kvp in StorageManager.taskList) { foreach (Task t in kvp.Value) { if (id >= 0 && t.id == id) { NotificationManager.ShowTaskNotification(t, command); return(true); } else { if (t.GetName().Contains(parameter, StringComparison.OrdinalIgnoreCase)) { tasks.Add(t); } } } } if (tasks.Count == 1) { NotificationManager.ShowTaskNotification(tasks[0] as Task, command); } else { NotificationManager.ShowCreatureList(tasks, String.Format("Tasks Containing \"{0}\"", parameter), command); } } } else if (comp.StartsWith("category" + Constants.CommandSymbol)) //category@ // list all items with the specified category { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); List <TibiaObject> items = StorageManager.getItemsByCategory(parameter); if (items.Count == 1) { NotificationManager.ShowItemNotification("item" + Constants.CommandSymbol + items[0].GetName().ToLower()); } else if (items.Count > 1) { NotificationManager.ShowCreatureList(items, "Category: " + parameter, command, true); } } else if (comp.StartsWith("hunt" + Constants.CommandSymbol)) //hunt@ { string[] splits = command.Split(Constants.CommandSymbol); string parameter = splits[1].Trim().ToLower(); int page = 0; if (splits.Length > 2 && int.TryParse(splits[2], out page)) { } if (Constants.cities.Contains(parameter)) { List <HuntingPlace> huntingPlaces = StorageManager.getHuntsInCity(parameter); NotificationManager.ShowCreatureList(huntingPlaces.ToList <TibiaObject>(), "Hunts in " + parameter, command); return(true); } HuntingPlace h = StorageManager.getHunt(parameter); if (h != null) { NotificationManager.ShowHuntingPlace(h, command); return(true); } Creature cr = StorageManager.getCreature(parameter); if (cr != null) { List <HuntingPlace> huntingPlaces = StorageManager.getHuntsForCreature(cr.id); NotificationManager.ShowCreatureList(huntingPlaces.ToList <TibiaObject>(), "Hunts containing creature " + parameter.ToTitle(), command); return(true); } int minlevel = -1, maxlevel = -1; int level; if (int.TryParse(parameter, out level)) { minlevel = (int)(level * 0.8); maxlevel = (int)(level * 1.2); } else if (parameter.Contains('-')) { string[] split = parameter.Split('-'); int.TryParse(split[0].Trim(), out minlevel); int.TryParse(split[1].Trim(), out maxlevel); } if (minlevel >= 0 && maxlevel >= 0) { List <HuntingPlace> huntingPlaces = StorageManager.getHuntsForLevels(minlevel, maxlevel); huntingPlaces = huntingPlaces.OrderBy(o => o.level).ToList(); NotificationManager.ShowCreatureList(huntingPlaces.ToList <TibiaObject>(), "Hunts between levels " + minlevel.ToString() + "-" + maxlevel.ToString(), command); return(true); } else { string title; List <HuntingPlace> huntList = StorageManager.searchHunt(parameter); title = "Hunts Containing \"" + parameter + "\""; if (huntList.Count == 1) { NotificationManager.ShowHuntingPlace(huntList[0], command); } else if (huntList.Count > 1) { NotificationManager.ShowCreatureList(huntList.ToList <TibiaObject>(), title, command); } } } else if (comp.StartsWith("npc" + Constants.CommandSymbol)) //npc@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); NPC npc = StorageManager.getNPC(parameter); if (npc != null) { NotificationManager.ShowNPCForm(npc, command); } else if (Constants.cities.Contains(parameter)) { NotificationManager.ShowCreatureList(StorageManager.getNPCWithCity(parameter), "NPC List", command); } else { NotificationManager.ShowCreatureList(StorageManager.searchNPC(parameter), "NPC List", command); } } else if (comp.StartsWith("savelog" + Constants.CommandSymbol)) { HuntManager.SaveLog(HuntManager.activeHunt, command.Split(Constants.CommandSymbol)[1].Trim().Replace("'", "\\'")); } else if (comp.StartsWith("loadlog" + Constants.CommandSymbol)) { HuntManager.LoadLog(HuntManager.activeHunt, command.Split(Constants.CommandSymbol)[1].Trim().Replace("'", "\\'")); } else if (comp.StartsWith("setdiscardgoldratio" + Constants.CommandSymbol)) { double val; if (double.TryParse(command.Split(Constants.CommandSymbol)[1].Trim(), out val)) { StorageManager.setGoldRatio(val); } } else if (comp.StartsWith("wiki" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim(); string response = ""; using (WebClient client = new WebClient()) { response = client.DownloadString(String.Format("http://tibia.wikia.com/api/v1/Search/List?query={0}&limit=1&minArticleQuality=10&batch=1&namespaces=0", parameter)); } Regex regex = new Regex("\"url\":\"([^\"]+)\""); Match m = regex.Match(response); var gr = m.Groups[1]; MainForm.OpenUrl(gr.Value.Replace("\\/", "/")); } else if (comp.StartsWith("char" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim(); MainForm.OpenUrl("https://secure.tibia.com/community/?subtopic=characters&name=" + parameter); } else if (comp.StartsWith("setconvertgoldratio" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim(); string[] split = parameter.Split('-'); if (split.Length < 2) { return(true); } int stackable = 0; if (split[0] == "1") { stackable = 1; } double val; if (double.TryParse(split[1], out val)) { StorageManager.setConvertRatio(val, stackable == 1); } } else if (comp.StartsWith("recent" + Constants.CommandSymbol) || comp.StartsWith("url" + Constants.CommandSymbol) || comp.StartsWith("last" + Constants.CommandSymbol)) { bool url = comp.StartsWith("url" + Constants.CommandSymbol); int type = url ? 1 : 0; string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); if (comp.StartsWith("last" + Constants.CommandSymbol)) { parameter = "1"; } List <Command> command_list = GlobalDataManager.GetRecentCommands(type).Select(o => new Command() { player = o.Item1, command = o.Item2 }).ToList(); command_list.Reverse(); int number; //recent@<number> opens the last <number> command, so recent@1 opens the last command if (int.TryParse(parameter, out number)) { if (number > 0 && number <= command_list.Count) { ListNotification.OpenCommand(command_list[number - 1].command, type);; return(true); } } else { //recent@<player> opens the last bool found = false; foreach (Command comm in command_list) { if (comm.player.ToLower() == parameter) { ListNotification.OpenCommand(command_list[number].command, type); found = true; break; } } if (found) { return(true); } } NotificationManager.ShowListNotification(command_list, type, command); } else if (comp.StartsWith("spell" + Constants.CommandSymbol)) // spell@ { string[] splits = command.Split(Constants.CommandSymbol); string parameter = splits[1].Trim().ToLower(); int initialVocation = -1; if (splits.Length > 2 && int.TryParse(splits[2], out initialVocation)) { } Spell spell = StorageManager.getSpell(parameter); if (spell != null) { NotificationManager.ShowSpellNotification(spell, initialVocation, command); } else { List <TibiaObject> spellList = new List <TibiaObject>(); string title; if (Constants.vocations.Contains(parameter)) { spellList = StorageManager.getSpellsForVocation(parameter); title = parameter.ToTitle() + " Spells"; } else { spellList = StorageManager.searchSpell(parameter); if (spellList.Count == 0) { spellList = StorageManager.searchSpellWords(parameter); } title = "Spells Containing \"" + parameter + "\""; } if (spellList.Count == 1) { NotificationManager.ShowSpellNotification(spellList[0].AsSpell(), initialVocation, command); } else if (spellList.Count > 1) { NotificationManager.ShowCreatureList(spellList, title, command); } } } else if (comp.StartsWith("outfit" + Constants.CommandSymbol)) // outfit@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Outfit outfit = StorageManager.getOutfit(parameter); if (outfit != null) { NotificationManager.ShowOutfitNotification(outfit, command); } else { string title; List <TibiaObject> outfitList = StorageManager.searchOutfit(parameter); title = "Outfits Containing \"" + parameter + "\""; if (outfitList.Count == 1) { NotificationManager.ShowOutfitNotification(outfitList[0].AsOutfit(), command); } else if (outfitList.Count > 1) { NotificationManager.ShowCreatureList(outfitList, title, command); } } } else if (comp.StartsWith("quest" + Constants.CommandSymbol)) // quest@ { string[] splits = command.Split(Constants.CommandSymbol); string parameter = splits[1].Trim().ToLower(); int page = 0; if (splits.Length > 2 && int.TryParse(splits[2], out page)) { } List <Quest> questList = new List <Quest>(); if (StorageManager.questNameMap.ContainsKey(parameter)) { NotificationManager.ShowQuestNotification(StorageManager.questNameMap[parameter], command); } else { string title; if (Constants.cities.Contains(parameter)) { title = "Quests In " + parameter; foreach (Quest q in StorageManager.questIdMap.Values) { if (q.city.ToLower() == parameter) { questList.Add(q); } } } else { title = "Quests Containing \"" + parameter + "\""; string[] splitStrings = parameter.Split(' '); foreach (Quest quest in StorageManager.questIdMap.Values) { bool found = true; foreach (string str in splitStrings) { if (!quest.name.Contains(str, StringComparison.OrdinalIgnoreCase)) { found = false; break; } } if (found) { questList.Add(quest); } } } if (questList.Count == 1) { NotificationManager.ShowQuestNotification(questList[0], command); } else if (questList.Count > 1) { NotificationManager.ShowCreatureList(questList.ToList <TibiaObject>(), title, command); //ShowQuestList(questList, title, command, page); } } } else if (comp.StartsWith("guide" + Constants.CommandSymbol)) // guide@ { string[] splits = command.Split(Constants.CommandSymbol); string parameter = splits[1].Trim().ToLower(); int page = 0; string mission = ""; if (splits.Length > 2 && int.TryParse(splits[2], out page)) { } if (splits.Length > 3) { mission = splits[3]; } List <Quest> questList = new List <Quest>(); if (StorageManager.questNameMap.ContainsKey(parameter)) { NotificationManager.ShowQuestGuideNotification(StorageManager.questNameMap[parameter], command, page, mission); } else { string title; foreach (Quest quest in StorageManager.questIdMap.Values) { if (quest.name.Contains(parameter, StringComparison.OrdinalIgnoreCase)) { questList.Add(quest); } } title = "Quests Containing \"" + parameter + "\""; if (questList.Count == 1) { NotificationManager.ShowQuestGuideNotification(questList[0], command, page, mission); } else if (questList.Count > 1) { NotificationManager.ShowCreatureList(questList.ToList <TibiaObject>(), title, command); } } } else if (comp.StartsWith("direction" + Constants.CommandSymbol)) // direction@ { string[] splits = command.Split(Constants.CommandSymbol); string parameter = splits[1].Trim().ToLower(); int page = 0; if (splits.Length > 2 && int.TryParse(splits[2], out page)) { } List <HuntingPlace> huntList = new List <HuntingPlace>(); HuntingPlace h = StorageManager.getHunt(parameter); if (h != null) { NotificationManager.ShowHuntGuideNotification(h, command, page); } else { string title; huntList = StorageManager.searchHunt(parameter); title = "Hunts Containing \"" + parameter + "\""; if (huntList.Count == 1) { NotificationManager.ShowHuntGuideNotification(huntList[0], command, page); } else if (huntList.Count > 1) { NotificationManager.ShowCreatureList(huntList.ToList <TibiaObject>(), title, command); } } } else if (comp.StartsWith("mount" + Constants.CommandSymbol)) // mount@ { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Mount m = StorageManager.getMount(parameter); if (m != null) { NotificationManager.ShowMountNotification(m, command); } else { string title; List <TibiaObject> mountList = StorageManager.searchMount(parameter); title = "Mounts Containing \"" + parameter + "\""; if (mountList.Count == 1) { NotificationManager.ShowMountNotification(mountList[0].AsMount(), command); } else if (mountList.Count > 1) { NotificationManager.ShowCreatureList(mountList, title, command); } } } else if (comp.StartsWith("pickup" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Item item = StorageManager.getItem(parameter); if (item != null) { StorageManager.setItemDiscard(item, false); } } else if (comp.StartsWith("nopickup" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Item item = StorageManager.getItem(parameter); if (item != null) { StorageManager.setItemDiscard(item, true); } } else if (comp.StartsWith("convert" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Item item = StorageManager.getItem(parameter); if (item != null) { StorageManager.setItemConvert(item, true); } } else if (comp.StartsWith("noconvert" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Item item = StorageManager.getItem(parameter); if (item != null) { StorageManager.setItemConvert(item, false); } } else if (comp.StartsWith("setval" + Constants.CommandSymbol)) { string parameter = command.Split(Constants.CommandSymbol)[1].Trim(); if (!parameter.Contains('=')) { return(true); } string[] split = parameter.Split('='); string item = split[0].Trim().ToLower().Replace("'", "\\'"); long value = 0; if (long.TryParse(split[1].Trim(), out value)) { Item it = StorageManager.getItem(split[0]); if (it != null) { StorageManager.setItemValue(it, value); } } } else if (comp.StartsWith("screenshot" + Constants.CommandSymbol)) { ScreenshotManager.saveScreenshot("Screenshot", ScreenshotManager.takeScreenshot()); } else { bool found = false; foreach (string city in Constants.cities) { if (comp.StartsWith(city + Constants.CommandSymbol)) { string itemName = command.Split(Constants.CommandSymbol)[1].Trim().ToLower(); Item item = StorageManager.getItem(itemName); if (item != null) { NPC npc = StorageManager.getNPCSellingItemInCity(item.id, city); if (npc != null) { NotificationManager.ShowNPCForm(npc, command); } } else { Spell spell = StorageManager.getSpell(itemName); if (spell != null) { NPC npc = StorageManager.getNPCTeachingSpellInCity(spell.id, city); if (npc != null) { NotificationManager.ShowNPCForm(npc, command); } } } found = true; } } // else try custom commands foreach (SystemCommand c in MainForm.mainForm.GetCustomCommands()) { if (c.tibialyzer_command.Trim().Length > 0 && comp.StartsWith(c.tibialyzer_command + Constants.CommandSymbol)) { string[] parameters = command.Split(Constants.CommandSymbol); string systemCallParameters = c.parameters; int i = 0; while (true) { if (systemCallParameters.Contains("{" + i.ToString() + "}")) { systemCallParameters = systemCallParameters.Replace("{" + i.ToString() + "}", parameters.Length > i + 1 ? parameters[i + 1].Trim() : ""); } else { break; } i++; } ProcessStartInfo procStartInfo = new ProcessStartInfo(c.command, systemCallParameters); procStartInfo.UseShellExecute = true; // Do not show the cmd window to the user. procStartInfo.CreateNoWindow = true; procStartInfo.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(procStartInfo); return(true); } } if (found) { return(true); } //if we get here we didn't find any command return(false); } return(true); } catch (Exception e) { MainForm.mainForm.DisplayWarning(String.Format("Tibialyzer Exception While Processing Command \"{0}\".\nMessage: {1} ", command, e.Message)); Console.WriteLine(e.Message); return(true); } }
public void RefreshLoot() { foreach (Control c in createdControls) { this.Controls.Remove(c); c.Dispose(); } createdControls.Clear(); if (page < 0) { page = 0; } int base_x = 20, base_y = 30; int x = 0, y = 0; int item_spacing = 4; Size item_size = new Size(32, 32); int max_x = SettingsManager.getSettingInt("LootFormWidth"); if (max_x < minLootWidth) { max_x = minLootWidth; } int width_x = max_x + item_spacing * 2; long total_value = 0; int currentPage = 0; bool prevPage = page > 0; bool nextPage = false; averageGold = GetAverageGold(creatures); foreach (Tuple <Item, int> tpl in items) { total_value += tpl.Item1.GetMaxValue() * tpl.Item2; } Dictionary <Item, List <PictureBox> > newItemControls = new Dictionary <Item, List <PictureBox> >(); foreach (Tuple <Item, int> tpl in items) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (base_x + x >= (max_x - item_size.Width - item_spacing)) { x = 0; if (y + item_size.Height + item_spacing > pageHeight) { currentPage++; if (currentPage > page) { nextPage = true; break; } else { y = 0; } } else { y = y + item_size.Height + item_spacing; } } int mitems = 1; if (item.stackable || SettingsManager.getSettingBool("StackAllItems")) { mitems = Math.Min(count, 100); } count -= mitems; if (currentPage == page) { PictureBox picture_box; if (itemControls.ContainsKey(item)) { picture_box = itemControls[item][0]; itemControls[item].RemoveAt(0); if (itemControls[item].Count == 0) { itemControls.Remove(item); } picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); if (picture_box.TabIndex != mitems && (item.stackable || mitems > 1)) { picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } picture_box.TabIndex = mitems; long individualValue = item.GetMaxValue(); value_tooltip.SetToolTip(picture_box, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(item.displayname) + " value: " + (individualValue >= 0 ? (individualValue * mitems).ToString() : "Unknown")); } else { picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = item.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = mitems; picture_box.TabStop = false; if (item.stackable || mitems > 1) { picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } else { picture_box.Image = item.GetImage(); } picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.BackgroundImage = StyleManager.GetImage("item_background.png"); picture_box.Click += openItemBox; long individualValue = item.GetMaxValue(); value_tooltip.SetToolTip(picture_box, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(item.displayname) + " value: " + (individualValue >= 0 ? (individualValue * mitems).ToString() : "Unknown")); this.Controls.Add(picture_box); } if (!newItemControls.ContainsKey(item)) { newItemControls.Add(item, new List <PictureBox>()); } newItemControls[item].Add(picture_box); } x += item_size.Width + item_spacing; } if (currentPage > page) { break; } } if (page > currentPage) { page = currentPage; RefreshLoot(); return; } foreach (KeyValuePair <Item, List <PictureBox> > kvp in itemControls) { foreach (PictureBox p in kvp.Value) { this.Controls.Remove(p); p.Dispose(); } } itemControls = newItemControls; y = y + item_size.Height + item_spacing; if (prevPage) { PictureBox prevpage = new PictureBox(); prevpage.Location = new Point(10, base_y + y); prevpage.Size = new Size(97, 23); prevpage.Image = StyleManager.GetImage("prevpage.png"); prevpage.BackColor = Color.Transparent; prevpage.SizeMode = PictureBoxSizeMode.StretchImage; prevpage.Click += Prevpage_Click; this.Controls.Add(prevpage); createdControls.Add(prevpage); } if (nextPage) { PictureBox nextpage = new PictureBox(); nextpage.Location = new Point(width_x - 108, base_y + y); nextpage.Size = new Size(98, 23); nextpage.BackColor = Color.Transparent; nextpage.Image = StyleManager.GetImage("nextpage.png"); nextpage.SizeMode = PictureBoxSizeMode.StretchImage; nextpage.Click += Nextpage_Click; this.Controls.Add(nextpage); createdControls.Add(nextpage); } if (prevPage || nextPage) { y += 23; } x = 0; base_x = 5; Size creature_size = new Size(1, 1); Size labelSize = new Size(1, 1); foreach (KeyValuePair <Creature, int> tpl in creatures) { Creature creature = tpl.Key; creature_size.Width = Math.Max(creature_size.Width, creature.GetImage().Width); creature_size.Height = Math.Max(creature_size.Height, creature.GetImage().Height); } { Dictionary <Creature, Tuple <PictureBox, Label> > newCreatureControls = new Dictionary <Creature, Tuple <PictureBox, Label> >(); int i = 0; foreach (Creature cr in creatures.Keys.OrderByDescending(o => creatures[o] * (1 + o.experience)).ToList <Creature>()) { Creature creature = cr; int killCount = creatures[cr]; if (x >= max_x - creature_size.Width - item_spacing * 2) { x = 0; y = y + creature_size.Height + 23; if (y > maxCreatureHeight) { break; } } int xoffset = (creature_size.Width - creature.GetImage().Width) / 2; int yoffset = (creature_size.Height - creature.GetImage().Height) / 2; Label count; PictureBox picture_box; if (creatureControls.ContainsKey(creature)) { picture_box = creatureControls[creature].Item1; count = creatureControls[creature].Item2; creatureControls.Remove(creature); picture_box.Location = new System.Drawing.Point(base_x + x + xoffset, base_y + y + yoffset + (creature_size.Height - creature.GetImage().Height) / 2); count.Location = new Point(base_x + x + xoffset, base_y + y + creature_size.Height); count.Text = killCount.ToString() + "x"; } else { count = new Label(); count.Text = killCount.ToString() + "x"; count.Font = loot_font; count.Size = new Size(1, 10); count.Location = new Point(base_x + x + xoffset, base_y + y + creature_size.Height); count.AutoSize = true; count.TextAlign = ContentAlignment.MiddleCenter; count.ForeColor = StyleManager.NotificationTextColor; count.BackColor = Color.Transparent; picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x + xoffset, base_y + y + yoffset + (creature_size.Height - creature.GetImage().Height) / 2); picture_box.Name = creature.GetName(); picture_box.Size = new System.Drawing.Size(creature.GetImage().Width, creature.GetImage().Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Image = creature.GetImage(); picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.Click += openCreatureDrops; picture_box.BackColor = Color.Transparent; this.Controls.Add(picture_box); this.Controls.Add(count); } int measured_size = (int)count.CreateGraphics().MeasureString(count.Text, count.Font).Width; int width = Math.Max(measured_size, creature.GetImage().Width); if (width > creature.GetImage().Width) { picture_box.Location = new Point(picture_box.Location.X + (width - creature.GetImage().Width) / 2, picture_box.Location.Y); } else { count.Location = new Point(count.Location.X + (width - measured_size) / 2, count.Location.Y); } newCreatureControls.Add(creature, new Tuple <PictureBox, Label>(picture_box, count)); labelSize = count.Size; i++; x += width + xoffset; } y = y + creature_size.Height + labelSize.Height * 2; foreach (KeyValuePair <Creature, Tuple <PictureBox, Label> > kvp in creatureControls) { this.Controls.Remove(kvp.Value.Item1); this.Controls.Remove(kvp.Value.Item2); kvp.Value.Item1.Dispose(); kvp.Value.Item2.Dispose(); } creatureControls = newCreatureControls; } long usedItemValue = 0; foreach (var tpl in HuntManager.GetUsedItems(hunt)) { usedItemValue += tpl.Item1.GetMaxValue() * tpl.Item2; } int xPosition = width_x - totalValueValue.Size.Width - 5; y = base_y + y + item_spacing + 10; huntNameLabel.Text = hunt.name.ToString(); totalValueLabel.Location = new Point(5, y); totalValueValue.Location = new Point(xPosition, y); totalValueValue.Text = total_value.ToString("N0"); value_tooltip.SetToolTip(totalValueValue, String.Format("Average gold for these creature kills: {0} gold.", averageGold.ToString("N0"))); totalExpLabel.Location = new Point(5, y += 20); totalExpValue.Location = new Point(xPosition, y); totalExpValue.Text = hunt.totalExp.ToString("N0"); expHourValue.Text = ScanningManager.lastResults == null ? "-" : ScanningManager.lastResults.expPerHour.ToString("N0"); expHourLabel.Location = new Point(5, y += 20); expHourValue.Location = new Point(xPosition, y); totalTimeLabel.Location = new Point(5, y += 20); totalTimeValue.Location = new Point(xPosition, y); usedItemsValue.Text = usedItemValue.ToString("N0"); usedItemsLabel.Location = new Point(5, y += 20); usedItemsValue.Location = new Point(xPosition, y); long profit = total_value - usedItemValue; value_tooltip.SetToolTip(usedItemsValue, String.Format(profit > 0 ? "Total Profit: {0} gold" : "Total Waste: {0} gold", profit.ToString("N0"))); totalTimeValue.Text = TimeToString((long)hunt.totalTime); y += 20; int widthSize = width_x / 3 - 5; lootButton.Size = new Size(widthSize, lootButton.Size.Height); lootButton.Location = new Point(5, y); allLootButton.Size = new Size(widthSize, lootButton.Size.Height); allLootButton.Location = new Point(7 + widthSize, y); rawLootButton.Size = new Size(widthSize, lootButton.Size.Height); rawLootButton.Location = new Point(10 + 2 * widthSize, y); y += allLootButton.Size.Height + 2; huntNameLabel.Size = new Size(width_x, huntNameLabel.Size.Height); this.Size = new Size(width_x, y + 5); lootLarger.Location = new Point(Size.Width - lootLarger.Size.Width - 4, 4); lootSmaller.Location = new Point(Size.Width - 2 * lootLarger.Size.Width - 4, 4); }
private void CreateItemList(List <Tuple <Item, int> > items, int x, ref int y, List <Control> controls) { Image image = new Bitmap(ImageWidth, ImageHeight); using (Graphics gr = Graphics.FromImage(image)) { int counter = 0; foreach (Tuple <Item, int> item in items) { Rectangle region = new Rectangle(x + (counter++) * (ImageHeight + 1), 0, ImageHeight - 1, ImageHeight - 1); RenderImageResized(gr, StyleManager.GetImage("item_background.png"), region); RenderImageResized(gr, (item.Item1.stackable || item.Item2 > 1) ? LootDropForm.DrawCountOnItem(item.Item1, item.Item2) : item.Item1.GetImage(), region); } } PictureBox box = new PictureBox(); box.Size = image.Size; box.BackColor = Color.Transparent; box.Location = new Point(x, y); box.Image = image; this.Controls.Add(box); controls.Add(box); y += box.Height; }
public void UpdateLootForm() { Hunt hunt = HuntManager.activeHunt; int minheight, maxheight; ClearControlList(lootControls, out minheight, out maxheight); int counter; int y = minheight; if (maxheight < 0) { y = 30; foreach (Control c in summaryControls) { y = Math.Max(c.Location.Y + c.Height, y); } } var loot = LootDropForm.GenerateLootInformation(hunt, "", null); totalValue = 0; foreach (Tuple <Item, int> tpl in loot.Item2) { totalValue += tpl.Item1.GetMaxValue() * tpl.Item2; } int maxDrops = SettingsManager.getSettingInt("SummaryMaxItemDrops"); if (maxDrops < 0) { maxDrops = 5; } if (maxDrops > 0) { CreateHeaderLabel("Item Drops", x, ref y, lootControls); counter = 0; int width = 0; var items = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in loot.Item2) { int amount = tpl.Item2; while (amount > 0) { int count = Math.Min(100, amount); amount -= count; items.Add(new Tuple <Item, int>(tpl.Item1, count)); width += ImageHeight + 2; if (width > ImageWidth - ImageHeight) { CreateItemList(items, x, ref y, lootControls); items.Clear(); width = 0; if (++counter >= maxDrops) { break; } } } } if (items.Count > 0) { CreateItemList(items, x, ref y, lootControls); items.Clear(); } } int maxCreatures = SettingsManager.getSettingInt("SummaryMaxCreatures"); if (maxCreatures < 0) { maxCreatures = 5; } if (maxCreatures > 0) { CreateHeaderLabel("Creature Kills", x, ref y, lootControls); counter = 0; foreach (Creature cr in loot.Item1.Keys.OrderByDescending(o => loot.Item1[o] * (1 + o.experience)).ToList <Creature>()) { CreateCreatureBox(cr, loot.Item1[cr], x, ref y, lootControls); if (++counter >= maxCreatures) { break; } } } int maxRecentDrops = SettingsManager.getSettingInt("SummaryMaxRecentDrops"); if (maxRecentDrops < 0) { maxRecentDrops = 5; } if (maxRecentDrops > 0) { CreateHeaderLabel("Recent Drops", x, ref y, lootControls); var recentDrops = ScanningManager.GetRecentDrops(maxRecentDrops); foreach (var drops in recentDrops) { CreateCreatureDropsBox(drops.Item1, drops.Item2, drops.Item3, x, ref y, lootControls); } } UpdateDamageForm(); }
public Image RecentDropsBox(Creature creature, List <Tuple <Item, int> > items, int imageHeight, List <ItemRegion> regions) { Bitmap bitmap = new Bitmap(BlockWidth, imageHeight); using (Graphics gr = Graphics.FromImage(bitmap)) { using (Brush brush = new SolidBrush(StyleManager.MainFormButtonColor)) { gr.FillRectangle(brush, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); } gr.DrawRectangle(Pens.Black, new Rectangle(0, 0, bitmap.Width - 1, bitmap.Height - 1)); Rectangle creatureRegion = new Rectangle(1, 1, imageHeight - 1, imageHeight - 1); RenderImageResized(gr, StyleManager.GetImage("item_background.png"), new Rectangle(1, 1, imageHeight - 2, imageHeight - 2)); RenderImageResized(gr, creature.GetImage(), creatureRegion); regions.Add(new ItemRegion { item = creature, region = creatureRegion }); int count = 0; foreach (Tuple <Item, int> item in items) { Rectangle region = new Rectangle(8 + (imageHeight - 1) * ++count, 1, imageHeight - 2, imageHeight - 2); regions.Add(new ItemRegion { item = item.Item1, region = region }); RenderImageResized(gr, StyleManager.GetImage("item_background.png"), region); RenderImageResized(gr, (item.Item1.stackable || item.Item2 > 1) ? LootDropForm.DrawCountOnItem(item.Item1, item.Item2) : item.Item1.GetImage(), region); } } return(bitmap); }
public void UpdateLootForm() { Hunt hunt = HuntManager.activeHunt; int minheight, maxheight; ClearControlList(lootControls, out minheight, out maxheight); int counter; int y = minheight; if (maxheight < 0) { y = 30; foreach (Control c in summaryControls) { y = Math.Max(c.Location.Y + c.Height, y); } } var loot = LootDropForm.GenerateLootInformation(hunt, "", null); totalValue = 0; foreach (Tuple <Item, int> tpl in loot.Item2) { totalValue += tpl.Item1.GetMaxValue() * tpl.Item2; } averageValue = LootDropForm.GetAverageGold(loot.Item1); int maxDrops = SettingsManager.getSettingInt("SummaryMaxItemDrops"); if (maxDrops < 0) { maxDrops = 5; } if (maxDrops > 0) { List <ItemRegion> region; int imageHeight = SettingsManager.getSettingInt("SummaryLootItemSize"); imageHeight = imageHeight < 0 ? BlockHeight : imageHeight; CreateHeaderLabel("Item Drops", x, ref y, lootControls); counter = 0; bool display = true; int width = 0; var items = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in loot.Item2) { int amount = tpl.Item2; while (amount > 0) { int count = Math.Min(100, amount); amount -= count; items.Add(new Tuple <Item, int>(tpl.Item1, count)); width += imageHeight + 2; if (width > BlockWidth - imageHeight) { region = new List <ItemRegion>(); CreateItemList(items, x, ref y, lootControls, imageHeight, region, counter).MouseDown += OpenLootWindow; lootRegions[counter] = region; items.Clear(); width = 0; if (++counter >= maxDrops) { display = false; break; } } } if (!display) { break; } } if (items.Count > 0) { region = new List <ItemRegion>(); CreateItemList(items, x, ref y, lootControls, imageHeight, region, counter).MouseDown += OpenLootWindow; lootRegions[counter] = region; items.Clear(); } } int maxCreatures = SettingsManager.getSettingInt("SummaryMaxCreatures"); if (maxCreatures < 0) { maxCreatures = 5; } if (maxCreatures > 0) { CreateHeaderLabel("Creature Kills", x, ref y, lootControls); counter = 0; foreach (Creature cr in loot.Item1.Keys.OrderByDescending(o => loot.Item1[o] * (1 + o.experience)).ToList <Creature>()) { CreateCreatureBox(cr, loot.Item1[cr], x, ref y, lootControls); if (++counter >= maxCreatures) { break; } } } int maxRecentDrops = SettingsManager.getSettingInt("SummaryMaxRecentDrops"); if (maxRecentDrops < 0) { maxRecentDrops = 5; } if (maxRecentDrops > 0) { CreateHeaderLabel("Recent Drops", x, ref y, lootControls); int imageHeight = SettingsManager.getSettingInt("SummaryRecentDropsItemSize"); imageHeight = imageHeight < 0 ? BlockHeight : imageHeight; var recentDrops = ScanningManager.GetRecentDrops(maxRecentDrops); int index = 0; foreach (var drops in recentDrops) { List <ItemRegion> region = new List <ItemRegion>(); CreateCreatureDropsBox(drops.Item1, drops.Item2, drops.Item3, x, ref y, lootControls, imageHeight, region, index).MouseDown += OpenRecentDropsWindow; recentDropsRegions[index++] = region; } } UpdateDamageForm(); }
private PictureBox CreateItemList(List <Tuple <Item, int> > items, int x, ref int y, List <Control> controls, int imageHeight, List <ItemRegion> newRegions = null, int boxIndex = 0) { Image image = new Bitmap(BlockWidth, imageHeight); using (Graphics gr = Graphics.FromImage(image)) { int counter = 0; foreach (Tuple <Item, int> item in items) { Rectangle region = new Rectangle(x + (counter++) * (imageHeight + 1), 0, imageHeight - 1, imageHeight - 1); if (newRegions != null) { newRegions.Add(new ItemRegion { item = item.Item1, region = region }); } RenderImageResized(gr, StyleManager.GetImage("item_background.png"), region); RenderImageResized(gr, (item.Item1.stackable || item.Item2 > 1) ? LootDropForm.DrawCountOnItem(item.Item1, item.Item2) : item.Item1.GetImage(), region); } } PictureBox box = new PictureBox(); box.Size = image.Size; box.BackColor = Color.Transparent; box.Location = new Point(x, y); box.Image = image; box.Name = boxIndex.ToString(); this.Controls.Add(box); controls.Add(box); y += box.Height; return(box); }
private void ShowLootDrops(Dictionary<Creature, int> creatures, List<Tuple<Item, int>> items, Hunt h, string comm, string screenshot_path) { LootDropForm ldf = new LootDropForm(comm); ldf.creatures = creatures; ldf.items = items; ldf.hunt = h; ShowNotification(ldf, comm, screenshot_path); }
public SimpleLootNotification(Creature cr, List <Tuple <Item, int> > items) : base() { this.InitializeComponent(); this.creature = cr; this.InitializeSimpleNotification(); creatureBox.Click -= c_Click; ToolTip value_tooltip = new ToolTip(); value_tooltip.AutoPopDelay = 60000; value_tooltip.InitialDelay = 500; value_tooltip.ReshowDelay = 0; value_tooltip.ShowAlways = true; value_tooltip.UseFading = true; int max_x = 300; int base_x = 64, base_y = 20; int x = 0; int y = 0; int item_spacing = 4; Size item_size = new Size(32, 32); List <Tuple <Item, int> > updatedItems = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in items) { if (tpl.Item1.GetName().ToLower() == "gold coin" && tpl.Item2 > 100) { Item platinumCoin = StorageManager.getItem("platinum coin"); updatedItems.Add(new Tuple <Item, int>(platinumCoin, tpl.Item2 / 100)); updatedItems.Add(new Tuple <Item, int>(tpl.Item1, tpl.Item2 % 100)); } else { updatedItems.Add(tpl); } } updatedItems = updatedItems.OrderByDescending(o => o.Item1.GetMaxValue() * o.Item2).ToList(); foreach (Tuple <Item, int> tpl in updatedItems) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (x >= (max_x - item_size.Width - item_spacing)) { x = 0; y = y + item_size.Height + item_spacing; } int mitems = 1; if (item.stackable) { mitems = Math.Min(count, 100); } count -= mitems; PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = item.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Click += openItem_Click; if (item.stackable) { picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } else { picture_box.Image = item.GetImage(); } picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.BackgroundImage = StyleManager.GetImage("item_background.png"); value_tooltip.SetToolTip(picture_box, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(item.displayname) + " value: " + Math.Max(item.actual_value, item.vendor_value) * mitems); this.Controls.Add(picture_box); x += item_size.Width + item_spacing; } } Image creatureImage = cr.GetImage(); if (creatureImage.Size.Width <= creatureBox.Width && creatureImage.Size.Height <= creatureBox.Height) { creatureBox.SizeMode = PictureBoxSizeMode.CenterImage; } else { creatureBox.SizeMode = PictureBoxSizeMode.Zoom; } this.creatureBox.Image = cr.GetImage(); this.creatureDropLabel.Text = String.Format("Loot of {0}.", cr.displayname); }
public override void LoadForm() { if (quest == null) { return; } this.SuspendLayout(); NotificationInitialize(); wikiButton.Click -= c_Click; this.questTitle.Text = quest.name; this.premiumBox.Image = quest.premium ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png"); this.cityLabel.Text = quest.city == null ? "Unknown" : quest.city.ToTitle(); this.levelLabel.Text = quest.minlevel.ToString(); this.legendLabel.Text = quest.legend; List <TibiaObject> rewards = new List <TibiaObject>(); foreach (int reward in quest.rewardItems) { Item item = StorageManager.getItem(reward); rewards.Add(item); } rewards = rewards.OrderByDescending(o => (o as Item).GetMaxValue()).ToList <TibiaObject>(); int x = 5; int y = 77; foreach (string missionName in quest.questInstructions.Keys) { if (quest.questInstructions[missionName].Count == 0) { continue; } if (x + 150 >= this.Size.Width) { x = 5; y += 25; } Label missionButton = new Label(); missionButton.BackColor = System.Drawing.Color.Transparent; missionButton.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; missionButton.Font = wikiButton.Font; missionButton.ForeColor = StyleManager.NotificationTextColor; missionButton.Location = new System.Drawing.Point(x, y); missionButton.Name = quest.questInstructions[missionName][0].specialCommand != null ? quest.questInstructions[missionName][0].specialCommand : "guide" + Constants.CommandSymbol + quest.name.ToLower() + Constants.CommandSymbol + "1" + Constants.CommandSymbol + missionName; missionButton.Padding = new System.Windows.Forms.Padding(2); missionButton.Text = missionName; missionButton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; missionButton.Click += MissionButton_Click; missionButton.Size = new Size(150, 21); this.Controls.Add(missionButton); x += missionButton.Width + 5; } y += 25; using (Graphics gr = Graphics.FromHwnd(legendLabel.Handle)) { this.legendLabel.Location = new Point(legendLabel.Location.X, y); y += (int)gr.MeasureString(this.legendLabel.Text, this.legendLabel.Font, this.legendLabel.MaximumSize.Width).Height + 20; } if (this.quest.additionalRequirements.Count > 0 || this.quest.questRequirements.Count > 0) { Label label = new Label(); label.Text = "Requirements"; label.Location = new Point(5, y); label.ForeColor = StyleManager.NotificationTextColor; label.BackColor = Color.Transparent; label.Font = questTitle.Font; label.Size = new Size(this.Size.Width - 10, label.Height); this.Controls.Add(label); y += 25; // Item requirements if (this.quest.questRequirements.Count > 0) { List <Tuple <int, Item> > requirements = new List <Tuple <int, Item> >(); foreach (Tuple <int, int> tpl in quest.questRequirements) { Item item = StorageManager.getItem(tpl.Item2); requirements.Add(new Tuple <int, Item>(tpl.Item1, item)); } requirements = requirements.OrderBy(o => o.Item1 * o.Item2.GetMaxValue()).ToList(); List <TibiaObject> itemList = requirements.Select(o => o.Item2).ToList <TibiaObject>(); List <Control> itemControls = new List <Control>(); y = y + UIManager.DisplayCreatureList(this.Controls, itemList, 10, y, this.Size.Width - 10, 1, null, 1, itemControls); int itemnr = 0; foreach (Control control in itemControls) { control.BackgroundImage = StyleManager.GetImage("item_background.png"); int itemCount = requirements[itemnr].Item1; Item item = requirements[itemnr].Item2; (control as PictureBox).Image = LootDropForm.DrawCountOnItem(item, itemCount); itemnr++; } } // Text requirements if (this.quest.additionalRequirements.Count > 0) { List <string> requirementStrings = this.quest.additionalRequirements.ToList(); if (this.quest.minlevel > 0) { requirementStrings.Add(String.Format("You must be at least level {0}.", this.quest.minlevel)); } y += 5; Regex questRegex = new Regex("\\[([^]]+)\\]"); foreach (string text in requirementStrings) { label = new Label(); string txt = text; Match m = questRegex.Match(txt); label.ForeColor = StyleManager.NotificationTextColor; if (m != null && m.Groups.Count > 1) { string requiredQuestName = m.Groups[1].Value; txt = txt.Replace(m.Groups[0].Value, requiredQuestName); label.Name = StorageManager.getQuest(requiredQuestName.ToLower()).GetCommand(); label.ForeColor = StyleManager.ClickableLinkColor; label.Click += MissionButton_Click; } label.Text = txt == "" ? "" : "- " + txt; label.Location = new Point(5, y); label.BackColor = Color.Transparent; label.Font = QuestGuideForm.requirementFont; Size size; using (Graphics gr = Graphics.FromHwnd(label.Handle)) { size = gr.MeasureString(label.Text, label.Font, this.Size.Width - 50).ToSize(); label.Size = new Size(this.Size.Width - 10, (int)(size.Height * 1.2)); } this.Controls.Add(label); y += label.Size.Height; } } } if (rewards.Count > 0 || quest.rewardOutfits.Count > 0) { Label label = new Label(); label.Text = "Rewards"; label.Location = new Point(40, y); label.ForeColor = StyleManager.NotificationTextColor; label.BackColor = Color.Transparent; label.Font = questTitle.Font; this.Controls.Add(label); y += 25; if (rewards.Count > 0) { List <Control> itemControls = new List <Control>(); y = y + UIManager.DisplayCreatureList(this.Controls, rewards, 10, y, this.Size.Width - 10, 1, null, 1, itemControls); } if (quest.rewardOutfits.Count > 0) { List <Control> outfitControls = new List <Control>(); List <TibiaObject> rewardOutfits = new List <TibiaObject>(); foreach (int reward in quest.rewardOutfits) { Outfit outfit = StorageManager.getOutfit(reward); rewardOutfits.Add(outfit); } y = y + UIManager.DisplayCreatureList(this.Controls, rewardOutfits, 10, y, this.Size.Width - 10, 4, null, 1, outfitControls); } } this.Size = new Size(this.Size.Width, y + 20); base.NotificationFinalize(); this.ResumeLayout(false); }
public SimpleLootNotification(Creature cr, List <Tuple <Item, int> > items) : base() { this.InitializeComponent(); this.creature = cr; this.InitializeSimpleNotification(); creatureBox.Click -= c_Click; ToolTip value_tooltip = new ToolTip(); value_tooltip.AutoPopDelay = 60000; value_tooltip.InitialDelay = 500; value_tooltip.ReshowDelay = 0; value_tooltip.ShowAlways = true; value_tooltip.UseFading = true; int max_x = 300; int base_x = 64, base_y = 20; int x = 0; int y = 0; int item_spacing = 4; Size item_size = new Size(32, 32); List <Tuple <Item, int> > updatedItems = new List <Tuple <Item, int> >(); foreach (Tuple <Item, int> tpl in items) { if (tpl.Item1.GetName().ToLower() == "gold coin" && tpl.Item2 > 100) { Item platinumCoin = MainForm.getItem("platinum coin"); updatedItems.Add(new Tuple <Item, int>(platinumCoin, tpl.Item2 / 100)); updatedItems.Add(new Tuple <Item, int>(tpl.Item1, tpl.Item2 % 100)); } else { updatedItems.Add(tpl); } } foreach (Tuple <Item, int> tpl in updatedItems) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (x >= (max_x - item_size.Width - item_spacing)) { x = 0; y = y + item_size.Height + item_spacing; } int mitems = 1; if (item.stackable) { mitems = Math.Min(count, 100); } count -= mitems; PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = item.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Click += openItem_Click; if (item.stackable) { /* * Bitmap image = LootDropForm.GetStackImage(item.image, mitems, item); * Graphics gr = Graphics.FromImage(image); * int numbers = (int)Math.Floor(Math.Log(mitems, 10)) + 1; * int xoffset = 1, logamount = mitems; * for (int i = 0; i < numbers; i++) { * int imagenr = logamount % 10; * xoffset = xoffset + MainForm.image_numbers[imagenr].Width + 1; * gr.DrawImage(MainForm.image_numbers[imagenr], * new Point(image.Width - xoffset, image.Height - MainForm.image_numbers[imagenr].Height - 3)); * logamount /= 10; * }*/ picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } else { picture_box.Image = item.GetImage(); } picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.BackgroundImage = MainForm.item_background; value_tooltip.SetToolTip(picture_box, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(item.displayname) + " value: " + Math.Max(item.actual_value, item.vendor_value) * mitems); this.Controls.Add(picture_box); x += item_size.Width + item_spacing; } } this.creatureBox.Image = cr.GetImage(); this.creatureDropLabel.Text = String.Format("Loot of {0}.", cr.displayname); }
public void RefreshLoot() { foreach (Control c in createdControls) { this.Controls.Remove(c); c.Dispose(); } createdControls.Clear(); if (page < 0) { page = 0; } int base_x = 20, base_y = 30; int x = 0, y = 0; int item_spacing = 4; Size item_size = new Size(32, 32); int max_x = MainForm.mainForm.getSettingInt("LootFormWidth"); if (max_x < minLootWidth) { max_x = minLootWidth; } int width_x = max_x + item_spacing * 2; // add a tooltip that displays the actual droprate when you mouseover ToolTip value_tooltip = new ToolTip(); value_tooltip.AutoPopDelay = 60000; value_tooltip.InitialDelay = 500; value_tooltip.ReshowDelay = 0; value_tooltip.ShowAlways = true; value_tooltip.UseFading = true; long total_value = 0; int currentPage = 0; bool prevPage = page > 0; bool nextPage = false; averageGold = 0; foreach (KeyValuePair <Creature, int> tpl in creatures) { double average = 0; foreach (ItemDrop dr in tpl.Key.itemdrops) { Item it = MainForm.getItem(dr.itemid); if (!it.discard && it.GetMaxValue() > 0 && dr.percentage > 0) { average += ((dr.min + dr.max) / 2.0) * (dr.percentage / 100.0) * it.GetMaxValue(); } } Console.WriteLine(average); Console.WriteLine(tpl.Value); averageGold += (int)(average * tpl.Value); } foreach (Tuple <Item, int> tpl in items) { total_value += tpl.Item1.GetMaxValue() * tpl.Item2; } foreach (Tuple <Item, int> tpl in items) { Item item = tpl.Item1; int count = tpl.Item2; while (count > 0) { if (base_x + x >= (max_x - item_size.Width - item_spacing)) { x = 0; if (y + item_size.Height + item_spacing > pageHeight) { currentPage++; if (currentPage > page) { nextPage = true; break; } else { y = 0; } } else { y = y + item_size.Height + item_spacing; } } int mitems = 1; if (item.stackable || count > 100) { mitems = Math.Min(count, 100); } count -= mitems; if (currentPage == page) { PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y); picture_box.Name = item.GetName(); picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height); picture_box.TabIndex = 1; picture_box.TabStop = false; if (item.stackable || mitems > 1) { picture_box.Image = LootDropForm.DrawCountOnItem(item, mitems); } else { picture_box.Image = item.GetImage(); } picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.BackgroundImage = MainForm.item_background; picture_box.Click += openItemBox; long individualValue = Math.Max(item.actual_value, item.vendor_value); value_tooltip.SetToolTip(picture_box, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(item.displayname) + " value: " + (individualValue >= 0 ? (individualValue * mitems).ToString() : "Unknown")); createdControls.Add(picture_box); this.Controls.Add(picture_box); } x += item_size.Width + item_spacing; } if (currentPage > page) { break; } } if (page > currentPage) { page = currentPage; RefreshLoot(); return; } y = y + item_size.Height + item_spacing; if (prevPage) { PictureBox prevpage = new PictureBox(); prevpage.Location = new Point(10, base_y + y); prevpage.Size = new Size(97, 23); prevpage.Image = MainForm.prevpage_image; prevpage.BackColor = Color.Transparent; prevpage.SizeMode = PictureBoxSizeMode.StretchImage; prevpage.Click += Prevpage_Click; this.Controls.Add(prevpage); createdControls.Add(prevpage); } if (nextPage) { PictureBox nextpage = new PictureBox(); nextpage.Location = new Point(width_x - 108, base_y + y); nextpage.Size = new Size(98, 23); nextpage.BackColor = Color.Transparent; nextpage.Image = MainForm.nextpage_image; nextpage.SizeMode = PictureBoxSizeMode.StretchImage; nextpage.Click += Nextpage_Click; this.Controls.Add(nextpage); createdControls.Add(nextpage); } if (prevPage || nextPage) { y += 23; } x = 0; base_x = 5; Size creature_size = new Size(1, 1); Size labelSize = new Size(1, 1); foreach (KeyValuePair <Creature, int> tpl in creatures) { Creature creature = tpl.Key; creature_size.Width = Math.Max(creature_size.Width, creature.GetImage().Width); creature_size.Height = Math.Max(creature_size.Height, creature.GetImage().Height); } { int i = 0; foreach (Creature cr in creatures.Keys.OrderByDescending(o => creatures[o] * (1 + o.experience)).ToList <Creature>()) { Creature creature = cr; int killCount = creatures[cr]; if (x >= max_x - creature_size.Width - item_spacing * 2) { x = 0; y = y + creature_size.Height + 23; if (y > maxCreatureHeight) { break; } } int xoffset = (creature_size.Width - creature.GetImage().Width) / 2; int yoffset = (creature_size.Height - creature.GetImage().Height) / 2; Label count = new Label(); count.Text = killCount.ToString() + "x"; count.Font = loot_font; count.Size = new Size(1, 10); count.Location = new Point(base_x + x + xoffset, base_y + y + creature_size.Height); count.AutoSize = true; count.TextAlign = ContentAlignment.MiddleCenter; count.ForeColor = Color.FromArgb(191, 191, 191); count.BackColor = Color.Transparent; int measured_size = (int)count.CreateGraphics().MeasureString(count.Text, count.Font).Width; int width = Math.Max(measured_size, creature.GetImage().Width); PictureBox picture_box = new PictureBox(); picture_box.Location = new System.Drawing.Point(base_x + x + xoffset, base_y + y + yoffset + (creature_size.Height - creature.GetImage().Height) / 2); picture_box.Name = creature.GetName(); picture_box.Size = new System.Drawing.Size(creature.GetImage().Width, creature.GetImage().Height); picture_box.TabIndex = 1; picture_box.TabStop = false; picture_box.Image = creature.GetImage(); picture_box.SizeMode = PictureBoxSizeMode.StretchImage; picture_box.Click += openCreatureDrops; picture_box.BackColor = Color.Transparent; if (width > creature.GetImage().Width) { picture_box.Location = new Point(picture_box.Location.X + (width - creature.GetImage().Width) / 2, picture_box.Location.Y); } else { count.Location = new Point(count.Location.X + (width - measured_size) / 2, count.Location.Y); } labelSize = count.Size; i++; x += width + xoffset; createdControls.Add(picture_box); createdControls.Add(count); this.Controls.Add(picture_box); this.Controls.Add(count); } y = y + creature_size.Height + labelSize.Height * 2; } int xPosition = width_x - totalValueValue.Size.Width - 5; y = base_y + y + item_spacing + 10; huntNameLabel.Text = hunt.name.ToString(); totalValueLabel.Location = new Point(5, y); totalValueValue.Location = new Point(xPosition, y); totalValueValue.Text = total_value.ToString(); value_tooltip.SetToolTip(totalValueValue, String.Format("Average gold for these creature kills: {0} gold.", averageGold)); totalExpLabel.Location = new Point(5, y += 20); totalExpValue.Location = new Point(xPosition, y); totalExpValue.Text = hunt.totalExp.ToString(); totalTimeLabel.Location = new Point(5, y += 20); totalTimeValue.Location = new Point(xPosition, y); long totalSeconds = (long)hunt.totalTime; string displayString = ""; if (totalSeconds >= 3600) { displayString += (totalSeconds / 3600).ToString() + "h "; totalSeconds = totalSeconds % 3600; } if (totalSeconds >= 60) { displayString += (totalSeconds / 60).ToString() + "m "; totalSeconds = totalSeconds % 60; } displayString += totalSeconds.ToString() + "s"; totalTimeValue.Text = displayString; y += 20; int widthSize = width_x / 3 - 5; lootButton.Size = new Size(widthSize, lootButton.Size.Height); lootButton.Location = new Point(5, y); allLootButton.Size = new Size(widthSize, lootButton.Size.Height); allLootButton.Location = new Point(7 + widthSize, y); rawLootButton.Size = new Size(widthSize, lootButton.Size.Height); rawLootButton.Location = new Point(10 + 2 * widthSize, y); y += allLootButton.Size.Height + 2; huntNameLabel.Size = new Size(width_x, huntNameLabel.Size.Height); this.Size = new Size(width_x, y + 5); lootLarger.Location = new Point(Size.Width - lootLarger.Size.Width - 4, 4); lootSmaller.Location = new Point(Size.Width - 2 * lootLarger.Size.Width - 4, 4); }