Beispiel #1
0
        private int InitializeList(List<Utility> utilities, List<TibiaObject> tibiaObjects) {
            foreach(Control c in controlList) {
                this.Controls.Remove(c);
                c.Dispose();
            }
            controlList.Clear();

            int width = tibiaObjects != null ? 48 : 32;
            int height = tibiaObjects != null ? 48 : 32;

            npcList = tibiaObjects;

            ToolTip nameTooltip = new ToolTip();
            nameTooltip.AutoPopDelay = 60000;
            nameTooltip.InitialDelay = 500;
            nameTooltip.ReshowDelay = 0;
            nameTooltip.ShowAlways = true;
            nameTooltip.UseFading = true;

            totalCount = tibiaObjects != null ? tibiaObjects.Count : utilities.Count;

            mapBox.targets.Clear();

            int totalHeight = 0;
            int baseX = mapBox.Location.X + mapBox.Size.Width + 5;
            int x = baseX;
            int y = mapBox.Location.Y;
            int index;
            for (index = baseIndex; index < totalCount; index++) {
                string name = "";
                Image image = null;
                Coordinate coordinate = null;

                if (tibiaObjects != null) {
                    name = tibiaObjects[index].GetName();
                    image = tibiaObjects[index].GetImage();
                    coordinate = new Coordinate((tibiaObjects[index] as NPC).pos);
                } else {
                    name = utilities[index].name;
                    image = MainForm.utilityImages[name];
                    coordinate = new Coordinate(utilities[index].location);
                }

                Target target = new Target();
                target.coordinate = coordinate;
                target.image = image;
                target.size = width / 2;
                mapBox.targets.Add(target);

                PictureBox utilityBox = new PictureBox();
                utilityBox.BackColor = Color.Transparent;
                utilityBox.Size = new Size(width, height);
                utilityBox.Image = image;
                utilityBox.Location = new Point(x, y);
                utilityBox.Click += UtilityBox_Click;
                utilityBox.Name = index.ToString();
                utilityBox.SizeMode = PictureBoxSizeMode.Zoom;
                nameTooltip.SetToolTip(utilityBox, MainForm.ToTitle(name));
                controlList.Add(utilityBox);
                this.Controls.Add(utilityBox);

                totalHeight = Math.Max(totalHeight, utilityBox.Height + utilityBox.Location.Y);

                x += width + 4;
                if (x + width + 4 > this.Size.Width) {
                    x = baseX;
                    y += height + 4;
                }
                if (y > 270 - height - 4) {
                    break;
                }
            }
            nextIndex = index + 1;
            nextButton.Visible = nextIndex < totalCount - 1;
            previousButton.Visible = baseIndex > 0;
            mapBox.UpdateMap();
            return totalHeight;
        }
Beispiel #2
0
        public override void LoadForm()
        {
            if (npc == null) return;

            this.SuspendForm();
            NotificationInitialize();
            npcImage.Image = npc.GetImage();
            creatureName.Text = npc.city.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;

            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 = StyleManager.NotificationTextColor;
                    label.BackColor = Color.Transparent;
                    label.Font = StyleManager.TextFont;
                    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 = StorageManager.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 = StyleManager.GetImage("mapup.png");
            this.mapUpLevel.Click -= c_Click;
            this.mapUpLevel.Click += mapUpLevel_Click;
            this.mapDownLevel.Image = StyleManager.GetImage("mapdown.png");
            this.mapDownLevel.Click -= c_Click;
            this.mapDownLevel.Click += mapDownLevel_Click;

            refresh();
            base.NotificationFinalize();
            this.ResumeForm();
        }
        private void UpdateMap()
        {
            Target target = new Target();
            target.coordinate = new Coordinate(targetCoordinate);
            target.image = StyleManager.GetImage("cross.png");
            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();
        }
Beispiel #4
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;
        }
Beispiel #5
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();
        }
Beispiel #6
0
        public override void LoadForm()
        {
            if (house == null) return;

            this.SuspendForm();
            NotificationInitialize();
            houseName.Text = house.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.houseName.Text, font);
                if (size.Width < houseName.MaximumSize.Width && size.Height < houseName.MaximumSize.Height) {
                    f = font;
                } else {
                    break;
                }
            }
            this.houseName.Font = f;

            cityLabel.Text = house.city.ToString();
            sizeLabel.Text = String.Format("{0} sqm", house.sqm);
            bedLabel.Text = house.beds.ToString();
            if (house.world != null) {
                statusLabel.Text = house.occupied ? "rented" : (house.hoursleft <= 0 ? "free" : "auctioned");
                if (house.occupied || house.hoursleft < 0) {
                    timeLeftLabel.Visible = false;
                    timeLeftHeader.Visible = false;
                } else {
                    timeLeftLabel.Text = String.Format("{0}{1}", house.hoursleft > 24 ? house.hoursleft / 24 : house.hoursleft, house.hoursleft > 24 ? "D" : "h");
                }
            } else {
                timeLeftHeader.Visible = false;
                statusHeader.Visible = false;
                timeLeftLabel.Visible = false;
                statusLabel.Visible = false;
            }

            Map m = StorageManager.getMap(house.pos.z);

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

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

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

            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();
        }
Beispiel #7
0
        public override void LoadForm()
        {
            if (house == null)
            {
                return;
            }

            this.SuspendForm();
            NotificationInitialize();
            houseName.Text = house.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.houseName.Text, font);
                if (size.Width < houseName.MaximumSize.Width && size.Height < houseName.MaximumSize.Height)
                {
                    f = font;
                }
                else
                {
                    break;
                }
            }
            this.houseName.Font = f;

            cityLabel.Text = house.city.ToString();
            sizeLabel.Text = String.Format("{0} sqm", house.sqm);
            bedLabel.Text  = house.beds.ToString();
            if (house.world != null)
            {
                statusLabel.Text = house.occupied ? "rented" : (house.hoursleft <= 0 ? "free" : "auctioned");
                if (house.occupied || house.hoursleft < 0)
                {
                    timeLeftLabel.Visible  = false;
                    timeLeftHeader.Visible = false;
                }
                else
                {
                    timeLeftLabel.Text = String.Format("{0}{1}", house.hoursleft > 24 ? house.hoursleft / 24 : house.hoursleft, house.hoursleft > 24 ? "D" : "h");
                }
            }
            else
            {
                timeLeftHeader.Visible = false;
                statusHeader.Visible   = false;
                timeLeftLabel.Visible  = false;
                statusLabel.Visible    = false;
            }

            Map m = StorageManager.getMap(house.pos.z);

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

            Target t = new Target();

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

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

            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();
        }