Esempio n. 1
0
        public override void LoadForm()
        {
            this.SuspendForm();
            base.NotificationInitialize();

            this.cityNameLabel.Text = MainForm.ToTitle(city.name);
            mapBox             = MainForm.DrawRoute(city.location, new Coordinate(-1, -1, mapSize.Width), mapSize, mapSize, mapSize, new List <Color>(), new List <Target>());
            mapBox.Location    = new Point(5, cityNameLabel.Location.Y + cityNameLabel.Height);
            mapBox.MapUpdated += ResetTimer;
            this.Controls.Add(mapBox);

            baseHeight = this.Size.Height;
            int listHeight = InitializeList(city.utilities, null);

            this.Size = new Size(this.Size.Width, Math.Max(listHeight, baseHeight));

            npcButton.Click         -= c_Click;
            utilityButton.Click     -= c_Click;
            huntButton.Click        -= c_Click;
            questButton.Click       -= c_Click;
            nextButton.Click        -= c_Click;
            previousButton.Click    -= c_Click;
            this.mapUpLevel.Image    = MainForm.mapup_image;
            this.mapUpLevel.Click   -= c_Click;
            this.mapDownLevel.Image  = MainForm.mapdown_image;
            this.mapDownLevel.Click -= c_Click;

            this.NotificationFinalize();
            this.ResumeForm();
        }
Esempio n. 2
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);
        }