Ejemplo n.º 1
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.º 2
0
        private void refresh()
        {
            foreach (Control c in createdControls)
            {
                this.Controls.Remove(c);
                c.Dispose();
            }
            int base_y   = this.listTitle.Location.Y + this.listTitle.Height + 10;
            int newWidth = 352;

            MainForm.PageInfo pageInfo = new MainForm.PageInfo(false, false);

            int y;

            if (displayType == DisplayType.Details)
            {
                y = MainForm.DisplayCreatureAttributeList(this.Controls, objects, 10, base_y, out newWidth, null, createdControls, currentPage, 20, pageInfo, null, null, sortHeader, sortedHeader, desc, null, null, addConditionalAttributes);
            }
            else
            {
                y = MainForm.DisplayCreatureList(this.Controls, objects, 10, base_y, 344, 4, null, 1, createdControls, currentPage, 600, pageInfo, currentDisplay);
                if (currentDisplay >= 0)
                {
                    currentDisplay = -1;
                    currentPage    = pageInfo.currentPage;
                }
            }
            startDisplay = pageInfo.startDisplay;
            updateCommand();

            newWidth = Math.Max(newWidth, 275);
            if (pageInfo.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 (pageInfo.nextPage)
            {
                PictureBox nextpage = new PictureBox();
                nextpage.Location  = new Point(10 + newWidth - 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);
            }
            toggleButton.Location = new Point(newWidth - toggleButton.Size.Width, toggleButton.Location.Y);
            if (pageInfo.prevPage || pageInfo.nextPage)
            {
                y += 23;
            }
            this.Size = new Size(10 + newWidth, base_y + y + 10);
            this.refreshTimer();
        }