GetUsedItems() public static method

public static GetUsedItems ( Hunt hunt ) : int>>.List
hunt Hunt
return int>>.List
Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void UpdateWasteForm()
        {
            Hunt hunt = HuntManager.activeHunt;

            int minheight, maxheight;

            ClearControlList(usedItemsControls, out minheight, out maxheight);

            int y = 30;

            foreach (Control c in damageControls.Count > 0 ? damageControls : (lootControls.Count > 0 ? lootControls : summaryControls))
            {
                y = Math.Max(c.Location.Y + c.Height, y);
            }

            int maxUsedItems = SettingsManager.getSettingInt("SummaryMaxUsedItems");

            if (maxUsedItems < 0)
            {
                maxUsedItems = 5;
            }
            if (maxUsedItems > 0)
            {
                int counter = 0;
                CreateHeaderLabel("Used Items", x, ref y, usedItemsControls);
                int width = 0;
                var items = new List <Tuple <Item, int> >();
                foreach (Tuple <Item, int> tpl in HuntManager.GetUsedItems(hunt))
                {
                    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, usedItemsControls);
                            items.Clear();
                            width = 0;
                            if (++counter >= maxUsedItems)
                            {
                                break;
                            }
                        }
                    }
                }
                if (items.Count > 0)
                {
                    CreateItemList(items, x, ref y, usedItemsControls);
                    items.Clear();
                }
            }
            if (y != maxheight)
            {
                this.Size = new Size(ImageWidth + 10, y + 5);
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public void UpdateWasteForm()
        {
            Hunt hunt = HuntManager.activeHunt;

            int minheight, maxheight;

            ClearControlList(usedItemsControls, out minheight, out maxheight);

            int y = 30;

            foreach (Control c in damageControls.Count > 0 ? damageControls : (lootControls.Count > 0 ? lootControls : summaryControls))
            {
                y = Math.Max(c.Location.Y + c.Height, y);
            }
            totalWaste = 0;
            int maxUsedItems = SettingsManager.getSettingInt("SummaryMaxUsedItems");

            if (maxUsedItems < 0)
            {
                maxUsedItems = 5;
            }
            if (maxUsedItems > 0)
            {
                List <ItemRegion> region;
                int imageHeight = SettingsManager.getSettingInt("SummaryWasteItemSize");
                imageHeight = imageHeight < 0 ? BlockHeight : imageHeight;
                int counter = 0;
                CreateHeaderLabel("Used Items", x, ref y, usedItemsControls);
                int  width   = 0;
                var  items   = new List <Tuple <Item, int> >();
                bool display = true;
                foreach (Tuple <Item, int> tpl in HuntManager.GetUsedItems(hunt))
                {
                    int amount = tpl.Item2;
                    totalWaste += amount * tpl.Item1.GetMaxValue();
                    while (amount > 0 && display)
                    {
                        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, usedItemsControls, imageHeight, region, counter).MouseDown += OpenWasteWindow;
                            wasteRegions[counter] = region;
                            items.Clear();
                            width = 0;
                            if (++counter >= maxUsedItems)
                            {
                                display = false;
                            }
                        }
                    }
                }
                if (items.Count > 0)
                {
                    region = new List <ItemRegion>();
                    CreateItemList(items, x, ref y, usedItemsControls, imageHeight, region, counter).MouseDown += OpenWasteWindow;
                    wasteRegions[counter] = region;
                    items.Clear();
                }
            }
            if (y != maxheight)
            {
                this.Size = new Size(BlockWidth + 10, y + 5);
            }
        }