示例#1
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      = MainForm.mapup_image;
            mapDownLevel.Image    = MainForm.mapdown_image;
            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           = MainForm.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();
        }
示例#2
0
        private void UpdateMap()
        {
            Target target = new Target();

            target.coordinate = new Coordinate(targetCoordinate);
            target.image      = MainForm.cross_image;
            target.size       = 12;

            if (mapBox.map != null)
            {
                mapBox.map.Dispose();
            }
            mapBox.map = MainForm.getMap(targetCoordinate.z);
            mapBox.targets.Clear();
            mapBox.targets.Add(target);
            mapBox.mapCoordinate = new Coordinate(targetCoordinate);
            mapBox.sourceWidth   = mapBox.Width;
            mapBox.UpdateMap();
        }
示例#3
0
        public override void LoadForm()
        {
            if (npc == null)
            {
                return;
            }

            this.SuspendForm();
            NotificationInitialize();
            npcImage.Image    = npc.GetImage();
            creatureName.Text = MainForm.ToTitle(npc.city);
            Font f = MainForm.fontList[0];

            for (int i = 0; i < MainForm.fontList.Count; i++)
            {
                Font font = MainForm.fontList[i];
                Size size = TextRenderer.MeasureText(this.creatureName.Text, font);
                if (size.Width < creatureName.MaximumSize.Width && size.Height < creatureName.MaximumSize.Height)
                {
                    f = font;
                }
                else
                {
                    break;
                }
            }
            this.creatureName.Font = f;

            for (int i = 0; i < headers.Length; i++)
            {
                objectList[i] = new List <TibiaObject>();
            }
            extraAttributes[0]        = "Value";
            attributeFunctions[0]     = SellPrice;
            attributeSortFunctions[0] = SellSort;
            removedLists[0]           = new List <string> {
                "Value"
            };
            foreach (ItemSold itemSold in npc.sellItems)
            {
                objectList[0].Add(new LazyTibiaObject {
                    id = itemSold.itemid, type = TibiaObjectType.Item
                });
            }
            extraAttributes[1]        = "Price";
            attributeFunctions[1]     = BuyPrice;
            attributeSortFunctions[1] = BuySort;
            removedLists[1]           = new List <string> {
                "Value"
            };
            foreach (ItemSold itemSold in npc.buyItems)
            {
                objectList[1].Add(new LazyTibiaObject {
                    id = itemSold.itemid, type = TibiaObjectType.Item
                });
            }
            extraAttributes[2]        = "Vocation";
            attributeFunctions[2]     = SpellVoc;
            attributeSortFunctions[2] = SpellSort;
            removedLists[2]           = new List <string> {
                "Words"
            };
            foreach (SpellTaught spellTaught in npc.spellsTaught)
            {
                objectList[2].Add(new LazyTibiaObject {
                    id = spellTaught.spellid, type = TibiaObjectType.Spell
                });
            }
            // Transport
            foreach (Transport transport in npc.transportOffered)
            {
                objectList[3].Add(transport);
            }
            // Quests Involved In
            foreach (Quest q in npc.involvedQuests)
            {
                objectList[4].Add(q);
            }

            base_y = this.Size.Height;
            int x = 5;

            for (int i = 0; i < headers.Length; i++)
            {
                if (objectList[i].Count > 0)
                {
                    Label label = new Label();
                    label.Text        = headers[i];
                    label.Location    = new Point(x, base_y);
                    label.ForeColor   = MainForm.label_text_color;
                    label.BackColor   = Color.Transparent;
                    label.Font        = MainForm.text_font;
                    label.Size        = new Size(90, 25);
                    label.TextAlign   = ContentAlignment.MiddleCenter;
                    label.BorderStyle = BorderStyle.FixedSingle;
                    label.Name        = i.ToString();
                    label.Click      += toggleObjectDisplay;
                    objectControls[i] = label;
                    this.Controls.Add(label);
                    if (currentControlList < 0 || currentControlList > headers.Length)
                    {
                        currentControlList = i;
                    }
                    x += 90;
                }
                else
                {
                    objectControls[i] = null;
                }
            }
            base_y += 25;

            Map m = MainForm.getMap(npc.pos.z);

            mapBox.map      = m;
            mapBox.mapImage = null;

            Target t = new Target();

            t.coordinate = new Coordinate(npc.pos);
            t.image      = npc.GetImage();
            t.size       = 20;

            mapBox.targets.Add(t);
            mapBox.sourceWidth   = mapBox.Width;
            mapBox.mapCoordinate = new Coordinate(npc.pos);
            mapBox.zCoordinate   = npc.pos.z;
            mapBox.UpdateMap();

            mapBox.Click -= c_Click;

            this.mapUpLevel.Image    = MainForm.mapup_image;
            this.mapUpLevel.Click   -= c_Click;
            this.mapUpLevel.Click   += mapUpLevel_Click;
            this.mapDownLevel.Image  = MainForm.mapdown_image;
            this.mapDownLevel.Click -= c_Click;
            this.mapDownLevel.Click += mapDownLevel_Click;

            refresh();
            base.NotificationFinalize();
            this.ResumeForm();
        }
示例#4
0
        public void UpdateMap()
        {
            if (beginCoordinate == null)
            {
                beginCoordinate = new Coordinate(mapCoordinate);
                beginWidth      = sourceWidth;
            }
            if (beginCoordinate.x == Coordinate.MaxWidth / 2 && beginCoordinate.y == Coordinate.MaxHeight / 2 && beginCoordinate.z == 7)
            {
                if (this.Image != MainForm.nomapavailable && this.Image != null)
                {
                    this.Image.Dispose();
                }
                this.Image    = MainForm.nomapavailable;
                this.SizeMode = PictureBoxSizeMode.Zoom;
                return;
            }
            if (mapCoordinate.z < 0)
            {
                mapCoordinate.z = 0;
            }
            else if (mapCoordinate.z >= MainForm.mapFilesCount)
            {
                mapCoordinate.z = MainForm.mapFilesCount - 1;
            }
            if (mapCoordinate.x - sourceWidth / 2 < 0)
            {
                mapCoordinate.x = sourceWidth / 2;
            }
            if (mapCoordinate.x + sourceWidth / 2 > map.image.Width)
            {
                mapCoordinate.x = map.image.Width - sourceWidth / 2;
            }
            if (mapCoordinate.y - sourceWidth / 2 < 0)
            {
                mapCoordinate.y = sourceWidth / 2;
            }
            if (mapCoordinate.y + sourceWidth / 2 > map.image.Height)
            {
                mapCoordinate.y = map.image.Height - sourceWidth / 2;
            }

            sourceWidth = Math.Min(Math.Max(sourceWidth, minWidth), maxWidth);
            Rectangle sourceRectangle = new Rectangle(mapCoordinate.x - sourceWidth / 2, mapCoordinate.y - sourceWidth / 2, sourceWidth, sourceWidth);
            Bitmap    bitmap          = new Bitmap(this.Width, this.Height);

            using (Graphics gr = Graphics.FromImage(bitmap)) {
                if (mapCoordinate.z == zCoordinate)
                {
                    gr.DrawImage(map != null ? map.image : mapImage, new Rectangle(0, 0, bitmap.Width, bitmap.Height), sourceRectangle, GraphicsUnit.Pixel);
                }
                else
                {
                    Map m = MainForm.getMap(mapCoordinate.z);
                    if (otherMap != null && m != otherMap)
                    {
                        otherMap.Dispose();
                    }
                    otherMap = m;
                    gr.DrawImage(m.image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), sourceRectangle, GraphicsUnit.Pixel);
                }
                foreach (TibiaPath path in paths)
                {
                    if (path.begin.z == mapCoordinate.z)
                    {
                        List <Point>  points = new List <Point>();
                        DijkstraPoint node   = path.path;
                        while (node != null)
                        {
                            points.Add(new Point(convertx(node.point.X), converty(node.point.Y)));
                            node = node.previous;
                        }
                        gr.DrawLines(MainForm.pathPen, points.ToArray());
                    }
                }

                foreach (Target target in targets)
                {
                    if (target.coordinate.z == mapCoordinate.z)
                    {
                        int x = target.coordinate.x - (mapCoordinate.x - sourceWidth / 2);
                        int y = target.coordinate.y - (mapCoordinate.y - sourceWidth / 2);
                        if (x >= 0 && y >= 0 && x < sourceWidth && y < sourceWidth)
                        {
                            x = (int)((double)x / sourceWidth * bitmap.Width);
                            y = (int)((double)y / sourceWidth * bitmap.Height);
                            int targetWidth = (int)((double)target.size / target.image.Height * target.image.Width);
                            gr.DrawImage(target.image, new Rectangle(x - targetWidth, y - target.size, targetWidth * 2, target.size * 2));
                        }
                    }
                }
            }
            if (this.Image != null)
            {
                this.Image.Dispose();
            }
            this.Image = bitmap;
            if (MapUpdated != null)
            {
                MapUpdated();
            }
        }