Beispiel #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            InvSlot control = new InvSlot(this);

            control.Location = new Point(panelDesktop.Width / 2, panelDesktop.Height / 2);
            panelDesktop.Controls.Add(control);
        }
Beispiel #2
0
 internal void DrawInventorySlots()
 {
     for (int i = 0; i < 27; i++)
     {
         InvSlot invSlot = new InvSlot(this);
         invSlot.index       = i + 9;
         invSlot.Location    = new Point(i % 3 * invSlot.Width + panelDesktop.AutoScrollPosition.X, i / 3 * invSlot.Width + panelDesktop.AutoScrollPosition.Y + (innerHeader.Visible ? 40 : 0));
         invSlot.constant    = true;
         invSlot.hidden      = true;
         invSlot.elementName = "__invslot" + (i + 9);
         panelDesktop.Controls.Add(invSlot);
     }
     inventoryDrawed = true;
 }
Beispiel #3
0
 internal void TurnSlotsSelectionToDefault(Image selectionDefaultImage)
 {
     //2
     foreach (Control c in panelDesktop.Controls)
     {
         if (c.GetType() == typeof(Slot))
         {
             Slot _c = (Slot)c;
             _c.SetSelection(selectionDefaultImage);
         }
         else
         if (c.GetType() == typeof(InvSlot))
         {
             InvSlot _c = (InvSlot)c;
             _c.ToDefault();
             _c.SetSelection(selectionDefaultImage);
         }
     }
 }
Beispiel #4
0
 internal void TurnToDefault(Type type, Image slotDefaultImage, string slotImageName)
 {
     //1
     foreach (Control c in panelDesktop.Controls)
     {
         if (c.GetType() == type)
         {
             if (type == typeof(Slot))
             {
                 Slot _c = (Slot)c;
                 _c.ToDefault();
             }
             else
             if (type == typeof(InvSlot))
             {
                 InvSlot _c = (InvSlot)c;
                 _c.ToDefault();
             }
         }
     }
 }
Beispiel #5
0
        internal override InnerControl MakeCopy()
        {
            if (constant || hidden)
            {
                throw new ArgumentOutOfRangeException();
            }
            InvSlot control = new InvSlot(parentTabPage);

            control.Location   = Location;
            control.Size       = Size;
            control.Visible    = Visible;
            control.scale      = scale;
            control.originSize = originSize;
            control.originSize = originSize;

            control.ActiveImage = ActiveImage;
            control.ImageName   = ImageName;
            control.index       = index;
            control.ApplyImage();

            return(control);
        }
Beispiel #6
0
        private void VisualizeElement(string name, string element)
        {
            string type = GetClearField(element, "type");

            switch (type)
            {
            case "slot":
            {
                Slot       slot = new Slot(parentTabPage);
                int        x;
                Expression e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                int size;
                if (!int.TryParse(GetClearField(element, "size").Split('.')[0], out size))
                {
                    size = slot.Width;
                }
                bool visual;
                if (!bool.TryParse(GetClearField(element, "visual"), out visual))
                {
                    visual = false;
                }
                string ImageName = GetClearField(element, "bitmap");
                if (ImageName == "")
                {
                    ImageName = slot.ImageName;
                }
                string Clicker = GetField(element, "clicker");
                slot.Apply(name, x, y, size, visual, ImageName, Clicker);
                parentTabPage.GetDesktopPanel().Controls.Add(slot);
                break;
            }

            case "invSlot":
            {
                InvSlot    slot = new InvSlot(parentTabPage);
                int        x;
                Expression e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                int size;
                if (!int.TryParse(GetClearField(element, "size").Split('.')[0], out size))
                {
                    size = slot.Width;
                }
                string ImageName = GetClearField(element, "bitmap");
                if (ImageName == "")
                {
                    ImageName = slot.ImageName.Split('.')[0];
                }
                string Clicker = GetField(element, "clicker");
                int    index;
                if (!int.TryParse(GetClearField(element, "y").Split('.')[0], out index))
                {
                    index = 0;
                }
                slot.Apply(name, x, y, size, ImageName, index);
                parentTabPage.GetDesktopPanel().Controls.Add(slot);
                break;
            }

            case "button":
            {
                InnerButton slot = new InnerButton(parentTabPage);
                int         x;
                Expression  e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                float scale;
                if (!float.TryParse(GetClearField(element, "scale"), NumberStyles.Any, CultureInfo.InvariantCulture, out scale))
                {
                    scale = 1;
                }
                string activeImageName = GetClearField(element, "bitmap");
                if (activeImageName == "")
                {
                    activeImageName = slot.activeImageName.Split('.')[0];
                }
                string activeImage2 = GetClearField(element, "bitmap2");
                if (activeImage2 == "")
                {
                    activeImage2 = activeImageName;
                }
                string Clicker = GetField(element, "clicker");
                slot.Apply(name, x, y, scale, activeImage2, activeImageName, Clicker);
                parentTabPage.GetDesktopPanel().Controls.Add(slot);
                break;
            }

            case "text":
            {
                InnerText  text = new InnerText(parentTabPage);
                int        x;
                Expression e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                int width;
                if (!int.TryParse(GetClearField(element, "width").Split('.')[0], out width))
                {
                    width = text.Width;
                }
                int height;
                if (!int.TryParse(GetClearField(element, "height").Split('.')[0], out height))
                {
                    height = text.Height;
                }
                string _text = GetField(element, "text");
                text.Apply(name, x, y, width, height, _text);
                parentTabPage.GetDesktopPanel().Controls.Add(text);
                break;
            }

            case "image":
            {
                InnerImage image = new InnerImage(parentTabPage);
                int        x;
                Expression e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                float scale;
                if (!float.TryParse(GetClearField(element, "scale"), NumberStyles.Any, CultureInfo.InvariantCulture, out scale))
                {
                    scale = 1;
                }
                string imageName = GetClearField(element, "bitmap");
                if (imageName == "")
                {
                    imageName = image.imageName.Split('.')[0];
                }
                string Clicker          = GetField(element, "clicker");
                string overlayImageName = GetClearField(element, "overlay");
                if (overlayImageName == "")
                {
                    image.Apply(name, x, y, scale, imageName, Clicker);
                }
                else
                {
                    float overlayScale;
                    if (!float.TryParse(GetClearField(element, "overlayScale"), out overlayScale))
                    {
                        if (!float.TryParse(GetClearField(element, "overlay_scale"), out overlayScale))
                        {
                            overlayScale = scale;
                        }
                    }
                    string offset = GetClearField(element, "overlayOffset");
                    int    offsetX;
                    if (!int.TryParse(GetClearField(offset, "x").Split('.')[0], out offsetX))
                    {
                        offsetX = 0;
                    }
                    int offsetY;
                    if (!int.TryParse(GetClearField(offset, "x").Split('.')[0], out offsetY))
                    {
                        offsetY = 0;
                    }
                    image.Apply(name, x, y, scale, imageName, overlayImageName, new Point(offsetX, offsetY), overlayScale, Clicker);
                }
                parentTabPage.GetDesktopPanel().Controls.Add(image);
                break;
            }

            case "scale":
            {
                Scale      _scale = new Scale(parentTabPage);
                int        x;
                Expression e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                float  scale;
                string _sc = GetClearField(element, "scale");
                if (!float.TryParse(_sc, NumberStyles.Any, CultureInfo.InvariantCulture, out scale))
                {
                    scale = 1;
                }
                string imageName = GetClearField(element, "bitmap");
                if (imageName == "")
                {
                    imageName = _scale.imageName.Split('.')[0];
                }
                string Clicker = GetField(element, "clicker");
                int    side;
                if (!int.TryParse(GetClearField(element, "direction").Split('.')[0], out side))
                {
                    side = 0;
                }
                bool invert;
                if (!bool.TryParse(GetClearField(element, "invert").Split('.')[0], out invert))
                {
                    invert = false;
                }
                string overlayImageName = GetClearField(element, "overlay");
                if (overlayImageName == "")
                {
                    _scale.Apply(name, x, y, scale, imageName, side, invert, Clicker);
                }
                else
                {
                    float overlayScale;
                    if (!float.TryParse(GetClearField(element, "overlayScale"), out overlayScale))
                    {
                        if (!float.TryParse(GetClearField(element, "overlay_scale"), out overlayScale))
                        {
                            overlayScale = scale;
                        }
                    }
                    string offset = GetClearField(element, "overlayOffset");
                    int    offsetX;
                    if (!int.TryParse(GetClearField(offset, "x").Split('.')[0], out offsetX))
                    {
                        offsetX = 0;
                    }
                    int offsetY;
                    if (!int.TryParse(GetClearField(offset, "x").Split('.')[0], out offsetY))
                    {
                        offsetY = 0;
                    }
                    _scale.Apply(name, x, y, scale, imageName, side, invert, overlayImageName, new Point(offsetX, offsetY), overlayScale, Clicker);
                }
                parentTabPage.GetDesktopPanel().Controls.Add(_scale);
                break;
            }

            default:


                break;
            }
        }