Ejemplo n.º 1
0
        public TibiaObject getTibiaObject()
        {
            if (tibiaObject == null)
            {
                switch (type)
                {
                case TibiaObjectType.Creature:
                    tibiaObject = MainForm.getCreature(id);
                    break;

                case TibiaObjectType.Item:
                    tibiaObject = MainForm.getItem(id);
                    break;

                case TibiaObjectType.NPC:
                    tibiaObject = MainForm.getNPC(id);
                    break;

                case TibiaObjectType.Mount:
                    tibiaObject = MainForm.getMount(id);
                    break;

                case TibiaObjectType.Outfit:
                    tibiaObject = MainForm.getOutfit(id);
                    break;

                case TibiaObjectType.Spell:
                    tibiaObject = MainForm.getSpell(id);
                    break;
                }
            }
            return(tibiaObject);
        }
Ejemplo n.º 2
0
 public override IComparable GetHeaderValue(int header)
 {
     if (header == hashes[0])
     {
         return(name);
     }
     if (header == hashes[1])
     {
         Item i = MainForm.getItem(tameitemid);
         if (i == null)
         {
             return("");
         }
         return(i.displayname);
     }
     if (header == hashes[2])
     {
         Creature cr = MainForm.getCreature(tamecreatureid);
         if (cr == null)
         {
             return("");
         }
         return(cr.displayname);
     }
     if (header == hashes[3])
     {
         return(tibiastore);
     }
     return(base.GetHeaderValue(header));
 }
Ejemplo n.º 3
0
        public override List <Attribute> GetAttributes()
        {
            Item     i            = MainForm.getItem(tameitemid);
            Creature cr           = MainForm.getCreature(tamecreatureid);
            string   itemName     = i == null ? "-" : MainForm.ToTitle(i.displayname);
            string   creatureName = cr == null ? "-" : MainForm.ToTitle(cr.displayname);

            return(new List <Attribute> {
                new StringAttribute(name, 120), new StringAttribute(itemName, 80), new StringAttribute(creatureName, 80), new BooleanAttribute(tibiastore)
            });
        }
Ejemplo n.º 4
0
        public override void LoadForm()
        {
            if (mount == null)
            {
                return;
            }
            this.SuspendLayout();
            NotificationInitialize();

            this.mountTitle.Text     = mount.name;
            this.mountImageBox.Image = mount.image;
            if (mount.tibiastore)
            {
                this.tameItemImageBox.Visible      = false;
                this.tameItemLabel.Visible         = false;
                this.tameCreatureImageBox.Image    = MainForm.tibia_store_image;
                this.tameCreatureLabel.Text        = "Tibia Store";
                this.tameCreatureImageBox.Location = new System.Drawing.Point(this.tameCreatureImageBox.Location.X, this.tameCreatureImageBox.Location.Y - 50);
                this.tameCreatureLabel.Location    = new System.Drawing.Point(this.tameCreatureLabel.Location.X, this.tameCreatureLabel.Location.Y - 50);
            }
            else if (mount.tamecreatureid > 0 && mount.tameitemid > 0)
            {
                Creature tameCreature = MainForm.getCreature(mount.tamecreatureid);
                Item     tameItem     = MainForm.getItem(mount.tameitemid);

                this.tameCreatureImageBox.Image = tameCreature.image;
                this.tameCreatureLabel.Text     = MainForm.ToTitle(tameCreature.displayname);
                this.tameItemImageBox.Image     = tameItem.image;
                this.tameItemLabel.Text         = MainForm.ToTitle(tameItem.displayname);

                tameCreatureImageBox.Name = tameCreature.GetName();
                tameCreatureLabel.Name    = tameCreature.GetName();
                tameItemImageBox.Name     = tameItem.GetName();
                tameItemLabel.Name        = tameItem.GetName();

                this.tameCreatureLabel.Click    += TameCreatureImageBox_Click;
                this.tameCreatureImageBox.Click += TameCreatureImageBox_Click;
                this.tameItemImageBox.Click     += TameItemImageBox_Click;
                this.tameItemLabel.Click        += TameItemImageBox_Click;
            }
            else
            {
                this.tameCreatureImageBox.Visible = false;
                this.tameCreatureLabel.Visible    = false;
                this.tameItemImageBox.Visible     = false;
                this.tameItemLabel.Visible        = false;
            }


            base.NotificationFinalize();
            this.ResumeLayout(false);
        }
Ejemplo n.º 5
0
 public Item GetRewardItem()
 {
     if (this.rewardItems.Count > 0)
     {
         List <Item> items = new List <Item>();
         foreach (int i in this.rewardItems)
         {
             Item item = MainForm.getItem(i);
             items.Add(item);
         }
         return(items.OrderByDescending(o => o.GetMaxValue()).First());
     }
     return(null);
 }
Ejemplo n.º 6
0
        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 = MainForm.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 = MainForm.item_background;
            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);

            // 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);
        }
Ejemplo n.º 7
0
        public override void LoadForm()
        {
            this.SuspendForm();
            int horizontal, left, right;

            this.statsButton.Name = creature.GetName().ToLower();
            this.huntButton.Name  = creature.GetName().ToLower();
            int health     = creature.health;
            int experience = creature.experience;
            List <Resistance> resistances = new List <Resistance>();

            resistances.Add(new Resistance("Ice", creature.res_ice));
            resistances.Add(new Resistance("Holy", creature.res_holy));
            resistances.Add(new Resistance("Death", creature.res_death));
            resistances.Add(new Resistance("Phys", creature.res_phys));
            resistances.Add(new Resistance("Earth", creature.res_earth));
            resistances.Add(new Resistance("Energy", creature.res_energy));
            resistances.Add(new Resistance("Fire", creature.res_fire));
            // load image from the creature
            this.mainImage.Image = creature.GetImage();
            // set health of creature
            this.healthLabel.Text = (health > 0 ? health.ToString() + " Health" : "Unknown");
            horizontal            = 96 - healthLabel.Size.Width;
            left  = horizontal / 2;
            right = horizontal - left;
            this.healthLabel.Padding = new Padding(left, 2, right, 2);
            // set exp of creature
            this.expLabel.Text = (experience >= 0 ? experience.ToString() : "Unknown") + " Exp";
            horizontal         = 96 - expLabel.Size.Width;
            left  = horizontal / 2;
            right = horizontal - left;
            this.expLabel.Padding = new Padding(left, 2, right, 2);
            // add resistances of creature in order
            AddResistances(resistances);
            // set background of actual form to transparent
            this.BackColor = MainForm.background_color;
            this.Opacity   = MainForm.opacity;
            if (MainForm.transparent)
            {
                this.TransparencyKey = MainForm.background_color;
                this.Opacity         = 1;
            }
            this.nameLabel.Text = MainForm.ToTitle(this.creature.displayname);
            Font f        = MainForm.fontList[0];
            Font prevFont = f;

            for (int i = 0; i < MainForm.fontList.Count; i++)
            {
                Font font  = MainForm.fontList[i];
                int  width = TextRenderer.MeasureText(this.nameLabel.Text, font).Width;
                if (width < this.mainImage.Size.Width)
                {
                    f = prevFont;
                }
                else
                {
                    break;
                }
                prevFont = font;
            }

            string goldstring  = "";
            double averageGold = 0;

            foreach (ItemDrop itemDrop in creature.itemdrops)
            {
                if (itemDrop.percentage > 0)
                {
                    Item item = MainForm.getItem(itemDrop.itemid);
                    averageGold += ((itemDrop.max + itemDrop.min) / 2.0) * itemDrop.percentage * item.GetMaxValue() / 100;
                }
            }
            if (averageGold < 10000)
            {
                goldstring = ((long)averageGold).ToString();
            }
            else if (averageGold < 1000000)
            {
                goldstring = ((long)averageGold / 1000).ToString() + "K";
            }
            else
            {
                goldstring = ((long)averageGold / 1000000).ToString() + "M";
            }
            this.averageGoldLabel.Text = "Average Gold: " + goldstring;

            this.maxDamageLabel.Text        = "Max Damage: " + (this.creature.maxdamage >= 0 ? this.creature.maxdamage.ToString() : "-");
            this.abilitiesLabel.Text        = RemoveTextInBrackets(this.creature.abilities.Replace(", ", "\n"));
            this.abilitiesLabel.BorderStyle = BorderStyle.FixedSingle;

            string tooltip;

            this.illusionableBox.Image = creature.illusionable ? MainForm.checkmark_yes : MainForm.checkmark_no;
            tooltip = creature.illusionable ? "Creature illusion works for this creature." : "Creature illusion does not work for this creature.";
            resistance_tooltip.SetToolTip(illusionableBox, tooltip);
            resistance_tooltip.SetToolTip(illusionableLabel, tooltip);
            this.summonableBox.Image = creature.summoncost > 0 ? MainForm.checkmark_yes : MainForm.checkmark_no;
            tooltip = creature.summoncost > 0 ? "This creature can be summoned for " + creature.summoncost + " mana." : "This creature cannot be summoned.";
            resistance_tooltip.SetToolTip(summonableBox, tooltip);
            resistance_tooltip.SetToolTip(summonableLabel, tooltip);
            this.invisibleBox.Image = !creature.senseinvis ? MainForm.checkmark_yes : MainForm.checkmark_no;
            tooltip = !creature.senseinvis ? "This creature does not detect invisibility." : "This creature detects invisibility.";
            resistance_tooltip.SetToolTip(invisibleBox, tooltip);
            resistance_tooltip.SetToolTip(invisibleLabel, tooltip);
            this.paralysableBox.Image = creature.paralysable ? MainForm.checkmark_yes : MainForm.checkmark_no;
            tooltip = creature.paralysable ? "This creature can be paralysed." : "This creature cannot be paralysed.";
            resistance_tooltip.SetToolTip(paralysableBox, tooltip);
            resistance_tooltip.SetToolTip(paralysableLabel, tooltip);
            this.pushableBox.Image = creature.pushable ? MainForm.checkmark_yes : MainForm.checkmark_no;
            tooltip = creature.pushable ? "This creature can be pushed." : "This creature cannot be pushed.";
            resistance_tooltip.SetToolTip(pushableBox, tooltip);
            resistance_tooltip.SetToolTip(pushableLabel, tooltip);
            this.pushesBox.Image = creature.pushes ? MainForm.checkmark_yes : MainForm.checkmark_no;
            tooltip = creature.pushes ? "This creature pushes smaller creatures." : "This creature cannot push smaller creatures.";
            resistance_tooltip.SetToolTip(pushesBox, tooltip);
            resistance_tooltip.SetToolTip(pushesLabel, tooltip);

            this.Size           = new Size(this.Size.Width, (int)Math.Max(this.abilitiesLabel.Location.Y + this.abilitiesLabel.Size.Height + 10, this.expLabel.Location.Y + this.expLabel.Height + 10));
            this.nameLabel.Font = f;
            this.nameLabel.Left = this.mainImage.Left + (mainImage.Width - this.nameLabel.Size.Width) / 2;
            base.NotificationInitialize();

            List <Task> involvedTasks = new List <Task>();

            foreach (KeyValuePair <string, List <Task> > kvp in MainForm.taskList)
            {
                foreach (Task t in kvp.Value)
                {
                    if (t.bossid == creature.id)
                    {
                        involvedTasks.Add(t);
                    }
                    foreach (int cr in t.creatures)
                    {
                        if (cr == creature.id)
                        {
                            involvedTasks.Add(t);
                        }
                    }
                }
            }
            if (involvedTasks.Count > 0)
            {
                int baseY    = this.Size.Height;
                int newWidth = 0;
                int y        = MainForm.DisplayCreatureAttributeList(Controls, involvedTasks.ToList <TibiaObject>(), 10, baseY, out newWidth);
                this.Size = new Size(Math.Max(newWidth, Size.Width), baseY + y);
            }

            base.NotificationFinalize();
            this.ResumeForm();
        }
Ejemplo n.º 8
0
        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 ? MainForm.checkmark_yes : MainForm.checkmark_no;
            this.cityLabel.Text   = quest.city == null ? "Unknown" : MainForm.ToTitle(quest.city);
            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 = MainForm.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   = MainForm.label_text_color;
                missionButton.Location    = new System.Drawing.Point(x, y);
                missionButton.Name        = quest.questInstructions[missionName][0].specialCommand != null ? quest.questInstructions[missionName][0].specialCommand : "guide" + MainForm.commandSymbol + quest.name.ToLower() + MainForm.commandSymbol + "1" + MainForm.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 = MainForm.label_text_color;
                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 = MainForm.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 + MainForm.DisplayCreatureList(this.Controls, itemList, 10, y, this.Size.Width - 10, 1, null, 1, itemControls);
                    int itemnr = 0;
                    foreach (Control control in itemControls)
                    {
                        control.BackgroundImage = MainForm.item_background;
                        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.ToArray().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 = MainForm.label_text_color;
                        if (m != null && m.Groups.Count > 1)
                        {
                            string quest = m.Groups[1].Value;
                            txt             = txt.Replace(m.Groups[0].Value, quest);
                            label.Name      = MainForm.getQuest(quest.ToLower()).GetCommand();
                            label.ForeColor = Color.FromArgb(105, 105, 255);
                            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 = MainForm.label_text_color;
                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 + MainForm.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 = MainForm.getOutfit(reward);
                        rewardOutfits.Add(outfit);
                    }

                    y = y + MainForm.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);
        }
Ejemplo n.º 9
0
        private void CombineItems()
        {
            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         = 110;
            int  base_y         = this.mainImage.Location.Y;
            int  max_x          = 250;
            int  max_y          = base_y + 134;

            // 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;
                }
                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    = MainForm.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 = MainForm.item_background;
                picture_box.Click          += openItemBox; droprate_tooltip.SetToolTip(picture_box, "You can skin this creature with the item " + skinItem.displayname + ".");
                this.Controls.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 (this.Height < (y + item_size.Height * 2 + item_spacing))
            {
                this.Height = y + item_size.Height * 2 + item_spacing;
            }
            this.Refresh();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 11
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      = MainForm.cross_image;
                        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 = MainForm.getItem(setting[2]).image;
                            break;

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

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

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

                        case "object":
                            image = MainForm.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 = MainForm.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 = MainForm.getCreature(imageString);
                                image   = cr.GetImage();
                                command = "creature" + MainForm.commandSymbol + cr.GetName().ToLower();
                            }
                            else if (splits[0].ToLower() == "npc")
                            {
                                NPC npc = MainForm.getNPC(imageString);
                                image   = npc.GetImage();
                                command = "npc" + MainForm.commandSymbol + npc.GetName().ToLower();
                            }
                            else if (splits[0].ToLower() == "item")
                            {
                                Item item = MainForm.getItem(imageString);
                                image   = item.GetImage();
                                command = "item" + MainForm.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   = MainForm.label_text_color;
                    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 = MainForm.label_text_color;
                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);
        }
Ejemplo n.º 12
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);
        }