Esempio n. 1
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);
        }
Esempio n. 2
0
        public static List <TibiaObject> refreshLootCreatures(Hunt h)
        {
            h.lootCreatures.Clear();
            string[]           creatures       = h.trackedCreatures.Split('\n');
            List <TibiaObject> creatureObjects = new List <TibiaObject>();

            foreach (string cr in creatures)
            {
                string   name = cr.ToLower();
                Creature cc   = StorageManager.getCreature(name);
                if (cc != null && !creatureObjects.Contains(cc))
                {
                    creatureObjects.Add(cc);
                    h.lootCreatures.Add(name);
                }
                else if (cc == null)
                {
                    HuntingPlace hunt = StorageManager.getHunt(name);
                    if (hunt != null)
                    {
                        foreach (int creatureid in hunt.creatures)
                        {
                            cc = StorageManager.getCreature(creatureid);
                            if (cc != null && !creatureObjects.Any(item => item.GetName() == name))
                            {
                                creatureObjects.Add(cc);
                                h.lootCreatures.Add(cc.GetName());
                            }
                        }
                    }
                }
            }
            return(creatureObjects);
        }
Esempio n. 3
0
        public override void LoadForm()
        {
            this.SuspendForm();
            this.NotificationInitialize();
            huntLabel.Click      -= c_Click;
            creatureLabel.Click  -= c_Click;
            bossNameLabel.Click  -= c_Click;
            bossPictureBox.Click -= c_Click;
            mapUpLevel.Click     -= c_Click;
            mapDownLevel.Click   -= c_Click;
            mapUpLevel.Image      = StyleManager.GetImage("mapup.png");
            mapDownLevel.Image    = StyleManager.GetImage("mapdown.png");
            mapBox.MapUpdated    += MapBox_MapUpdated;

            pointsLabel.Text = task.taskpoints > 0 ? task.taskpoints.ToString() : "-";
            countLabel.Text  = task.count.ToString();
            taskName.Text    = task.GetName();
            Creature boss = task.GetBoss();

            if (boss != null)
            {
                bossNameLabel.Text   = boss.GetName();
                bossPictureBox.Image = boss.GetImage();
                mapBox.targets.Add(new Target {
                    coordinate = new Coordinate(task.bossposition), image = boss.GetImage(), size = 24
                });
            }
            else
            {
                bossNameLabel.Visible  = false;
                bossPictureBox.Visible = false;
                bossInfoLabel.Visible  = false;
            }
            mapBox.mapCoordinate = new Coordinate(task.bossposition);
            mapBox.map           = StorageManager.getMap(task.bossposition.z);
            mapBox.sourceWidth   = mapBox.Width;
            mapBox.Click        -= c_Click;
            mapBox.UpdateMap();
            taskGroupLabel.Text = task.groupname;
            baseWidth           = this.Size.Width;
            baseHeight          = this.Size.Height;
            refreshAttributes();

            this.NotificationFinalize();
            this.ResumeForm();
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
 private static Creature registerCreature(Creature cr)
 {
     if (cr == null) return null;
     lock (CreatureLock) {
         if (_creatureIdMap.ContainsKey(cr.id)) {
             cr.image.Dispose();
             return _creatureIdMap[cr.id];
         }
         _creatureIdMap.Add(cr.id, cr);
         string name = cr.GetName().ToLower();
         if (!_creatureNameMap.ContainsKey(name)) {
             _creatureNameMap.Add(cr.GetName().ToLower(), cr);
         }
     }
     return cr;
 }
Esempio n. 6
0
 public bool ContainsLootCreature(Creature cr)
 {
     lock (huntLock) {
         return lootCreatures.Contains(cr.GetName(), StringComparer.OrdinalIgnoreCase);
     }
 }
Esempio n. 7
0
 private void creatureBox_Click(object sender, EventArgs e)
 {
     CommandManager.ExecuteCommand("creature" + Constants.CommandSymbol + creature.GetName());
 }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public static void ParseLootMessages(Hunt h, Dictionary <string, List <string> > newDrops, List <Tuple <Creature, List <Tuple <Item, int> > > > newItems, bool commit = true, bool switchHunt = false, bool addEverything = false)
        {
            lock (HuntManager.hunts) {
                SQLiteTransaction transaction = null;
                if (commit)
                {
                    transaction = LootDatabaseManager.BeginTransaction();
                }

                int stamp = TimestampManager.getDayStamp();
                Dictionary <string, List <string> > itemDrops = addEverything ? new Dictionary <string, List <string> >() : globalMessages;
                // now the big one: parse the log messages and check the dropped items
                foreach (KeyValuePair <string, List <string> > kvp in newDrops)
                {
                    string        t        = kvp.Key;
                    List <string> itemList = kvp.Value;
                    if (!itemDrops.ContainsKey(t))
                    {
                        itemDrops.Add(t, new List <string>());
                    }
                    if (itemList.Count > itemDrops[t].Count)
                    {
                        int hour   = int.Parse(t.Substring(0, 2));
                        int minute = int.Parse(t.Substring(3, 2));
                        foreach (string message in itemList)
                        {
                            if (!itemDrops[t].Contains(message))
                            {
                                // new log message, scan it for new items
                                Tuple <Creature, List <Tuple <Item, int> > > resultList = ParseLootMessage(message);
                                if (resultList == null)
                                {
                                    continue;
                                }

                                Creature cr = resultList.Item1;

                                if (switchHunt && commit)
                                {
                                    foreach (Hunt potentialHunt in HuntManager.hunts)
                                    {
                                        if (potentialHunt.lootCreatures.Contains(cr.GetName(), StringComparer.OrdinalIgnoreCase))
                                        {
                                            if (potentialHunt.sideHunt)
                                            {
                                                h = potentialHunt;
                                                HuntManager.activeHunt = potentialHunt;
                                            }
                                            else if (potentialHunt.aggregateHunt && potentialHunt != h)
                                            {
                                                HuntManager.AddKillToHunt(potentialHunt, resultList, t, message, stamp, hour, minute, transaction);
                                            }
                                        }
                                    }
                                }

                                HuntManager.AddKillToHunt(h, resultList, t, message, stamp, hour, minute, transaction);
                                if (MainForm.fileWriter != null && SettingsManager.getSettingBool("AutomaticallyWriteLootToFile"))
                                {
                                    MainForm.fileWriter.WriteLine(message);
                                    MainForm.fileWriter.Flush();
                                }

                                if (newItems != null)
                                {
                                    newItems.Add(resultList);
                                }
                            }
                            else
                            {
                                itemDrops[t].Remove(message);
                            }
                        }
                        itemDrops[t] = itemList;
                    }
                }
                if (transaction != null)
                {
                    transaction.Commit();
                }
            }
        }
Esempio n. 10
0
 private void UpdateCommand()
 {
     this.command.command = String.Format("loot{0}{1}{0}{2}{0}{3}", Constants.CommandSymbol, huntName, lootCreature == null ? "" : lootCreature.GetName(), rawName);
 }
Esempio n. 11
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);
        }
Esempio n. 12
0
 public bool ContainsLootCreature(Creature cr)
 {
     lock (huntLock) {
         return(lootCreatures.Contains(cr.GetName(), StringComparer.OrdinalIgnoreCase));
     }
 }
Esempio n. 13
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      = StyleManager.NotificationBackgroundColor;
            this.nameLabel.Text = this.creature.displayname.ToTitle();
            Font f        = StyleManager.FontList[0];
            Font prevFont = f;

            for (int i = 0; i < StyleManager.FontList.Count; i++)
            {
                Font font  = StyleManager.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 = StorageManager.getItem(itemDrop.itemid);
                    averageGold += ((itemDrop.max + itemDrop.min) / 2.0) * itemDrop.percentage * item.GetMaxValue() / 100;
                }
            }
            goldstring = StyleManager.GoldToText((long)averageGold);
            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;

            // average gold of creature
            this.averageGoldCenterLabel.Text = goldstring.Replace("Average Gold:", "") + " Gold";
            horizontal = 96 - averageGoldCenterLabel.Size.Width;
            left       = horizontal / 2;
            right      = horizontal - left;
            this.averageGoldCenterLabel.Padding = new Padding(left, 2, right, 2);
            // max damage of creature
            this.maxDamageCenterLabel.Text = (this.creature.maxdamage > 0 ? this.creature.maxdamage.ToString() + " Dmg" : "Unknown");
            horizontal = 96 - maxDamageCenterLabel.Size.Width;
            left       = horizontal / 2;
            right      = horizontal - left;
            this.maxDamageCenterLabel.Padding   = new Padding(left, 2, right, 2);
            this.maxDamageCenterLabel.ForeColor = StyleManager.MainFormSmallDangerColor;

            string tooltip;

            this.illusionableBox.Image = creature.illusionable ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png");
            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 ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png");
            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 ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png");
            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 ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png");
            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 ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png");
            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 ? StyleManager.GetImage("checkmark-yes.png") : StyleManager.GetImage("checkmark-no.png");
            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();
            RefreshTaskList(this.Size.Height);
            base.NotificationFinalize();
            this.RefreshForm();
            this.ResumeForm();
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
 private void creatureBox_Click(object sender, EventArgs e)
 {
     MainForm.mainForm.ExecuteCommand("creature" + MainForm.commandSymbol + creature.GetName());
 }