Esempio n. 1
0
        public override Image GetImage()
        {
            TibiaObject obj = null;

            switch (imagetype)
            {
            case 1: obj = StorageManager.getOutfit(image); break;

            case 2: obj = StorageManager.getMount(image); break;

            case 3: obj = StorageManager.getQuest(image); break;

            case 4: obj = StorageManager.getHunt(image); break;

            case 5: obj = StorageManager.getCreature(image); break;

            case 6: obj = StorageManager.getNPC(image); break;

            case 7: obj = StorageManager.getItem(image); break;

            case 8: obj = StorageManager.getSpell(image); break;
            }
            if (obj != null)
            {
                Image img = obj.GetImage();
                if (img != null)
                {
                    return(img);
                }
            }
            switch (grade)
            {
            case 4: return(StyleManager.GetImage("achievementgrade4.png"));

            case 3: return(StyleManager.GetImage("achievementgrade3.png"));

            case 2: return(StyleManager.GetImage("achievementgrade2.png"));

            default: return(StyleManager.GetImage("achievementgrade1.png"));
            }
        }
Esempio n. 2
0
        public override void LoadForm()
        {
            this.SuspendForm();
            NotificationInitialize();

            UnregisterControl(nextStepButton);
            npcImage.Image = imageObject == null?StyleManager.GetImage("cross.png") : imageObject.GetImage();

            lock (npcImage.Image) {
                if (npcImage.Image.Width > npcImage.Width || npcImage.Image.Height > npcImage.Height)
                {
                    npcImage.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
            creatureName.Text = imageObject == null ? "Target" : imageObject.GetName().ToTitle();
            Font f = StyleManager.FontList[0];

            for (int i = 0; i < StyleManager.FontList.Count; i++)
            {
                Font font = StyleManager.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;

            Map m = StorageManager.getMap(targetCoordinate.z);

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

            Target t = new Target();

            t.coordinate = new Coordinate(targetCoordinate);
            t.image      = imageObject == null?StyleManager.GetImage("cross.png") : imageObject.GetImage();

            t.size = 20;

            mapBox.targets.Add(t);
            mapBox.sourceWidth   = mapBox.Width;
            mapBox.mapCoordinate = new Coordinate(targetCoordinate);
            mapBox.SetTargetCoordinate(new Coordinate(targetCoordinate));
            mapBox.zCoordinate = targetCoordinate.z;
            mapBox.UpdateMap();
            mapBox.MapUpdated += MapBox_MapUpdated;

            UnregisterControl(mapBox);

            this.mapUpLevel.Image = StyleManager.GetImage("mapup.png");
            this.UnregisterControl(mapUpLevel);
            this.mapUpLevel.Click  += mapUpLevel_Click;
            this.mapDownLevel.Image = StyleManager.GetImage("mapdown.png");
            this.UnregisterControl(mapDownLevel);
            this.mapDownLevel.Click += mapDownLevel_Click;

            base.NotificationFinalize();
            this.ResumeForm();
        }
Esempio n. 3
0
        public static int DisplayCreatureList(System.Windows.Forms.Control.ControlCollection controls, List <TibiaObject> l, int base_x, int base_y, int max_x, int spacing, Func <TibiaObject, string> tooltip_function = null, float magnification = 1.0f, List <Control> createdControls = null, int page = 0, int pageheight = 10000, PageInfo pageInfo = null, int currentDisplay = -1)
        {
            int x = 0, y = 0;
            int height = 0;
            // add a tooltip that displays the creature names
            ToolTip value_tooltip = new ToolTip();

            value_tooltip.AutoPopDelay = 60000;
            value_tooltip.InitialDelay = 500;
            value_tooltip.ReshowDelay  = 0;
            value_tooltip.ShowAlways   = true;
            value_tooltip.UseFading    = true;
            int currentPage = 0;

            if (pageInfo != null)
            {
                pageInfo.prevPage = page > 0;
            }
            int start = 0, end = 0;
            int pageStart = 0;

            if (currentDisplay >= 0)
            {
                page = int.MaxValue;
            }
            for (int i = 0; i < l.Count; i++)
            {
                TibiaObject cr = l[i];
                int         imageWidth;
                int         imageHeight;
                Image       image = cr.GetImage();
                string      name  = cr.GetName();

                if (cr.AsItem() != null || cr.AsSpell() != null)
                {
                    imageWidth  = 32;
                    imageHeight = 32;
                }
                else
                {
                    imageWidth  = image.Width;
                    imageHeight = image.Height;
                }

                if (currentDisplay >= 0 && i == currentDisplay)
                {
                    currentDisplay = -1;
                    i                    = pageStart;
                    start                = i;
                    page                 = currentPage;
                    pageInfo.prevPage    = page > 0;
                    pageInfo.currentPage = page;
                    x                    = 0;
                    y                    = 0;
                    continue;
                }

                if (max_x < (x + base_x + (int)(imageWidth * magnification) + spacing))
                {
                    x      = 0;
                    y      = y + spacing + height;
                    height = 0;
                    if (y > pageheight)
                    {
                        if (page > currentPage)
                        {
                            y            = 0;
                            currentPage += 1;
                            pageStart    = start;
                        }
                        else
                        {
                            if (pageInfo != null)
                            {
                                pageInfo.nextPage = true;
                            }
                            break;
                        }
                    }
                }
                if ((int)(imageHeight * magnification) > height)
                {
                    height = (int)(imageHeight * magnification);
                }
                if (currentPage == page)
                {
                    PictureBox image_box;
                    image_box           = new PictureBox();
                    image_box.Image     = image;
                    image_box.BackColor = Color.Transparent;
                    image_box.Size      = new Size((int)(imageWidth * magnification), height);
                    image_box.Location  = new Point(base_x + x, base_y + y);
                    image_box.SizeMode  = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                    image_box.Name      = cr.GetCommand();
                    image_box.Click    += executeNameCommand;
                    if (cr.AsItem() != null)
                    {
                        image_box.BackgroundImage = StyleManager.GetImage("item_background.png");
                    }
                    controls.Add(image_box);
                    if (createdControls != null)
                    {
                        createdControls.Add(image_box);
                    }
                    image_box.Image = image;
                    if (tooltip_function == null)
                    {
                        value_tooltip.SetToolTip(image_box, name.ToTitle());
                    }
                    else
                    {
                        string prefix = "";
                        if (cr.AsNPC() != null)
                        {
                            NPC npc = cr is NPC ? cr as NPC : (cr as LazyTibiaObject).getTibiaObject() as NPC;
                            prefix = name.ToTitle() + " (" + npc.city.ToTitle() + ")\n";
                        }
                        value_tooltip.SetToolTip(image_box, prefix + tooltip_function(cr));
                    }
                    end++;
                }
                else
                {
                    start++;
                }

                x = x + (int)(imageWidth * magnification) + spacing;
            }
            if (pageInfo != null)
            {
                pageInfo.startDisplay = start;
                pageInfo.endDisplay   = start + end;
            }
            x = 0;
            y = y + height;
            return(y);
        }