GetName() public method

public GetName ( ) : string
return string
コード例 #1
0
ファイル: HuntManager.cs プロジェクト: Cizall/Tibialyzer
 public static void AddLoot(Hunt h, Item item, int itemCount)
 {
     h.AddItem(item, itemCount);
     int stamp = TimestampManager.getDayStamp();
     Tuple<int, int> time = TimestampManager.getCurrentTime();
     LootDatabaseManager.InsertMessage(h, stamp, time.Item1, time.Item2, String.Format("{0}:{1} Loot of a non-existent creature: {2} {3}", time.Item1, time.Item2, itemCount, item.GetName()));
     LootDatabaseManager.UpdateLoot();
 }
コード例 #2
0
 private static Item registerItem(Item item)
 {
     if (item == null) return null;
     lock (ItemLock) {
         if (_itemIdMap.ContainsKey(item.id)) {
             item.image.Dispose();
             return _itemIdMap[item.id];
         }
         _itemIdMap.Add(item.id, item);
         string name = item.GetName().ToLower();
         if (!_itemNameMap.ContainsKey(name)) {
             _itemNameMap.Add(item.GetName().ToLower(), item);
         }
     }
     return item;
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        private void CombineItems()
        {
            foreach (Control c in itemControls)
            {
                Controls.Remove(c);
            }
            itemControls.Clear();

            Size item_size      = new Size(32, 32); //size of item image
            int  dropbar_height = 6;                //height of dropbar
            int  item_spacing   = 6;                //spacing between items
            int  base_x         = this.mainImage.Location.X + this.mainImage.Width + item_spacing;
            int  base_y         = 24;
            int  max_x          = this.Size.Width - 108;
            int  max_y          = 388;

            // add a tooltip that displays the actual droprate when you mouseover
            ToolTip droprate_tooltip = new ToolTip();

            droprate_tooltip.AutoPopDelay = 60000;
            droprate_tooltip.InitialDelay = 500;
            droprate_tooltip.ReshowDelay  = 0;
            droprate_tooltip.ShowAlways   = true;
            droprate_tooltip.UseFading    = true;

            int             x = item_spacing, y = item_spacing;
            List <ItemDrop> sorted_items = creature.itemdrops.OrderByDescending(o => o.percentage).ToList();

            foreach (ItemDrop drop in sorted_items)
            {
                if (x > (max_x - item_size.Width - item_spacing))
                {
                    x  = item_spacing;
                    y += item_size.Height + item_spacing;
                    if (base_y + y + item_size.Height > max_y)
                    {
                        y -= item_size.Height + item_spacing;
                        break;
                    }
                }
                DisplayItem(drop, base_x, base_y, x, y, item_size, droprate_tooltip, dropbar_height);
                x += item_size.Width + item_spacing;
            }

            if (creature.skin != null)
            {
                Item       skinItem    = StorageManager.getItem(creature.skin.skinitemid);
                ItemDrop   skinDrop    = new ItemDrop();
                PictureBox picture_box = new PictureBox();
                picture_box.Location        = new System.Drawing.Point(20, this.huntButton.Location.Y + this.huntButton.Size.Height + 10);
                picture_box.Name            = skinItem.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           = skinItem.GetImage();
                picture_box.SizeMode        = PictureBoxSizeMode.StretchImage;
                picture_box.BackgroundImage = StyleManager.GetImage("item_background.png");
                picture_box.Click          += openItemBox; droprate_tooltip.SetToolTip(picture_box, "You can skin this creature with the item " + skinItem.displayname + ".");
                this.Controls.Add(picture_box);
                itemControls.Add(picture_box);

                skinDrop.itemid     = creature.skin.dropitemid;
                skinDrop.percentage = creature.skin.percentage;
                skinDrop.min        = 1;
                skinDrop.max        = 1;
                DisplayItem(skinDrop, 20 + item_size.Width + item_spacing, this.huntButton.Location.Y + this.huntButton.Size.Height + 10, 0, 0, item_size, droprate_tooltip, dropbar_height, "Skin rate of ");
                if (y < this.huntButton.Location.Y + this.huntButton.Size.Height)
                {
                    y = this.huntButton.Location.Y + this.huntButton.Size.Height;
                }
            }

            if (base_height < (base_y + y + item_spacing * 2 + item_size.Height))
            {
                this.Height = base_y + y + item_spacing * 2 + item_size.Height;
            }
            this.Refresh();
        }
コード例 #5
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);
        }
コード例 #6
0
        private int drawDirections(Coordinate begin, Coordinate end, string settings, string description, int start_x, int y, bool variableSize, int imageCount, bool noText, out int width)
        {
            int  mapSize = this.Size.Width / 2;
            Size minSize = new Size(mapSize, mapSize);

            List <Color>  additionalWalkableColors = new List <Color>();
            List <Target> targetList = new List <Target>();

            // parse settings
            if (settings != null)
            {
                string[] splits = settings.ToLower().Split('@');
                foreach (string split in splits)
                {
                    string[] setting = split.Split('=');
                    switch (setting[0])
                    {
                    case "walkablecolor":
                        string[] rgb = setting[1].Split(',');
                        additionalWalkableColors.Add(Color.FromArgb(int.Parse(rgb[0]), int.Parse(rgb[1]), int.Parse(rgb[2])));
                        break;

                    case "marking":
                        Target   target     = new Target();
                        string[] coordinate = setting[1].Split(',');
                        target.size       = 12;
                        target.image      = StyleManager.GetImage("cross.png");
                        target.coordinate = new Coordinate(int.Parse(coordinate[0]), int.Parse(coordinate[1]), int.Parse(coordinate[2]));
                        targetList.Add(target);
                        break;

                    case "markicon":
                        Image image = null;
                        switch (setting[1].ToLower())
                        {
                        case "item":
                            image = StorageManager.getItem(setting[2]).image;
                            break;

                        case "npc":
                            image = StorageManager.getNPC(setting[2]).image;
                            break;

                        case "cr":
                            image = StorageManager.getCreature(setting[2]).image;
                            break;

                        case "spell":
                            image = StorageManager.getSpell(setting[2]).image;
                            break;

                        case "object":
                            image = StorageManager.getWorldObject(setting[2]).image;
                            break;

                        default:
                            throw new Exception("Unknown image type " + setting[1] + ".");
                        }
                        targetList[targetList.Count - 1].image = image;
                        break;

                    case "marksize":
                        targetList[targetList.Count - 1].size = int.Parse(setting[1]);
                        break;
                    }
                }
            }
            if (targetList.Count == 0)
            {
                targetList = null;
            }

            MapPictureBox map = UIManager.DrawRoute(begin, end, variableSize ? new Size(0, 0) : new Size(mapSize, mapSize), minSize, new Size(mapSize, mapSize), additionalWalkableColors, targetList);

            width = map.Width + 5;
            if (!noText)
            {
                map.Location = new Point(this.Size.Width - (map.Width + 5), y);
            }
            else
            {
                map.Location = new Point(start_x, y);
            }
            map.MapUpdated += refreshTimer;
            this.Controls.Add(map);
            addedControls.Add(map);
            if (noText)
            {
                return(y + map.Height + 5);
            }
            if (description.Contains("@"))
            {
                int      x = 5;
                int      minheightoffset = 20;
                string[] questStrings    = description.Split('@');
                int      minY            = y + map.Size.Height + 10;
                foreach (string instruction in questStrings)
                {
                    if (instruction == "")
                    {
                        y += 10;
                        continue;
                    }
                    if (instruction.Contains("="))
                    {
                        string[] splits = instruction.Split('=');
                        if (splits[0].ToLower() == "cr" || splits[0].ToLower() == "npc" || splits[0].ToLower() == "item")
                        {
                            bool   blockWidth  = true;
                            string imageString = splits[1];
                            if (splits[1].Contains(';'))
                            {
                                string[] options = splits[1].Split(';');
                                imageString = options[0];
                                for (int i = 1; i < options.Length; i++)
                                {
                                    if (options[i].ToLower() == "blockheight")
                                    {
                                        blockWidth = false;
                                    }
                                }
                            }
                            string command = "";
                            Image  image   = null;
                            if (splits[0].ToLower() == "cr")
                            {
                                Creature cr = StorageManager.getCreature(imageString);
                                image   = cr.GetImage();
                                command = "creature" + Constants.CommandSymbol + cr.GetName().ToLower();
                            }
                            else if (splits[0].ToLower() == "npc")
                            {
                                NPC npc = StorageManager.getNPC(imageString);
                                image   = npc.GetImage();
                                command = "npc" + Constants.CommandSymbol + npc.GetName().ToLower();
                            }
                            else if (splits[0].ToLower() == "item")
                            {
                                Item item = StorageManager.getItem(imageString);
                                image   = item.GetImage();
                                command = "item" + Constants.CommandSymbol + item.GetName().ToLower();
                            }
                            PictureBox pictureBox = new PictureBox();
                            pictureBox.Location  = new Point(x, y);
                            pictureBox.Image     = image;
                            pictureBox.SizeMode  = PictureBoxSizeMode.Zoom;
                            pictureBox.Size      = new Size(image.Width, image.Height);
                            pictureBox.BackColor = Color.Transparent;
                            pictureBox.Name      = command;
                            pictureBox.Click    += QuestTitle_Click;
                            if (blockWidth)
                            {
                                x += pictureBox.Size.Width;
                                minheightoffset = pictureBox.Size.Height + 5;
                            }
                            else
                            {
                                y += pictureBox.Size.Height;
                            }

                            addedControls.Add(pictureBox);
                            this.Controls.Add(pictureBox);
                            continue;
                        }
                    }
                    Label label = new Label();
                    label.Location    = new Point(x, y);
                    label.ForeColor   = StyleManager.NotificationTextColor;
                    label.BackColor   = Color.Transparent;
                    label.Font        = requirementFont;
                    label.AutoSize    = true;
                    label.MaximumSize = new Size(this.Size.Width - (map.Size.Width) - x, 0);
                    string labelText = CreateLinks(label, instruction);
                    label.Text = labelText == "" ? "" : "- " + labelText;

                    int labelHeight = 0;
                    using (Graphics gr = Graphics.FromHwnd(label.Handle)) {
                        labelHeight = (int)(gr.MeasureString(label.Text, label.Font, this.Size.Width - (map.Size.Width + 10) - x, StringFormat.GenericTypographic).Height * 1.2);
                    }
                    addedControls.Add(label);
                    this.Controls.Add(label);
                    y += Math.Max(labelHeight, minheightoffset);
                    minheightoffset = 0;
                    x = 5;
                }
                if (y < minY)
                {
                    y = minY;
                }
            }
            else
            {
                Label label = new Label();
                label.Location  = new Point(5, y);
                label.ForeColor = StyleManager.NotificationTextColor;
                label.BackColor = Color.Transparent;
                label.Font      = requirementFont;
                string labelText = CreateLinks(label, description);
                label.Text = labelText == "" ? "" : "- " + labelText;
                Size size;
                using (Graphics gr = Graphics.FromHwnd(label.Handle)) {
                    size       = gr.MeasureString(label.Text, label.Font, this.Size.Width - (map.Size.Width + 10)).ToSize();
                    label.Size = new Size(this.Size.Width - (map.Size.Width + 5), Math.Max((int)(size.Height * 1.3), map.Size.Height));
                }
                addedControls.Add(label);
                this.Controls.Add(label);
                y += Math.Max(label.Size.Height, map.Size.Height) + 10;
            }
            return(y);
        }
コード例 #7
0
        public static void AddLoot(Hunt h, Item item, int itemCount)
        {
            h.AddItem(item, itemCount);
            int stamp             = TimestampManager.getDayStamp();
            Tuple <int, int> time = TimestampManager.getCurrentTime();

            LootDatabaseManager.InsertMessage(h, stamp, time.Item1, time.Item2, String.Format("{0}:{1} Loot of a non-existent creature: {2} {3}", time.Item1, time.Item2, itemCount, item.GetName()));
            LootDatabaseManager.UpdateLoot();
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public static bool ResolveConditions(Tuple <Creature, List <Tuple <Item, int> > > dropInformation)
        {
            List <string> conditions = SettingsManager.getSetting("NotificationConditions");

            var connection = new SQLiteConnection("Data Source=:memory:");

            connection.Open();

            SQLiteCommand command;

            command = new SQLiteCommand("CREATE TABLE item(name STRING, value INTEGER, capacity DOUBLE, count INTEGER)", connection);
            command.ExecuteNonQuery();
            command = new SQLiteCommand("CREATE TABLE creature(name STRING, exp INTEGER, hp INTEGER)", connection);
            command.ExecuteNonQuery();

            Creature cr = dropInformation.Item1;

            if (cr != null)
            {
                command = new SQLiteCommand(String.Format("INSERT INTO creature (name, exp, hp) VALUES (\"{0}\",{1},{2})", cr.GetName().Replace("\"", "\\\""), cr.experience, cr.health), connection);
                command.ExecuteNonQuery();
                if (dropInformation.Item2 != null && dropInformation.Item2.Count > 0)
                {
                    foreach (Tuple <Item, int> tpl in dropInformation.Item2)
                    {
                        Item it    = tpl.Item1;
                        int  count = tpl.Item2;
                        if (it == null)
                        {
                            continue;
                        }
                        command = new SQLiteCommand(String.Format("INSERT INTO item (name, value, capacity, count) VALUES (\"{0}\",{1},{2},{3})", it.GetName().Replace("\"", "\\\""), it.GetMaxValue(), it.capacity.ToString(CultureInfo.InvariantCulture), count), connection);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {
                    command = new SQLiteCommand(String.Format("INSERT INTO item (name, value, capacity, count) VALUES (\"nothing\",0,1,1)"), connection);
                    command.ExecuteNonQuery();
                }
            }

            foreach (string condition in conditions)
            {
                if (condition.Trim().Length == 0)
                {
                    continue;
                }
                string query = String.Format("SELECT {0} FROM item,creature", condition);
                try {
                    command = new SQLiteCommand(query, connection);
                    SQLiteDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        double value = reader.GetDouble(0);
                        if (value > 0)
                        {
                            return(true);
                        }
                    }
                } catch {
                }
            }
            return(false);
        }
コード例 #10
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        = 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);
        }
コード例 #11
0
        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);
        }