Exemple #1
0
 public void Remove(Gump ToRemove)
 {
     this.m_Array = null;
     this.m_List.Remove(ToRemove);
     Gumps.Invalidate();
     this.m_Count = this.m_List.Count;
 }
Exemple #2
0
        private void OnClickReplace(object sender, EventArgs e)
        {
            if (listBox.SelectedItems.Count == 1)
            {
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    dialog.Multiselect     = false;
                    dialog.Title           = "Choose image file to replace";
                    dialog.CheckFileExists = true;
                    dialog.Filter          = "Image files (*.tif;*.tiff;*.bmp)|*.tif;*.tiff;*.bmp";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        Bitmap bmp = new Bitmap(dialog.FileName);
                        if (dialog.FileName.Contains(".bmp"))
                        {
                            bmp = Utils.ConvertBmp(bmp);
                        }

                        int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());
                        Gumps.ReplaceGump(i, bmp);
                        ControlEvents.FireGumpChangeEvent(this, i);
                        listBox.Invalidate();
                        ListBox_SelectedIndexChanged(this, EventArgs.Empty);
                        Options.ChangedUltimaClass["Gumps"] = true;
                    }
                }
            }
        }
Exemple #3
0
 protected internal override void OnDragStart()
 {
     if (this.m_Item != null)
     {
         base.m_IsDragging = false;
         Gumps.LastOver    = null;
         Gumps.Drag        = null;
         this.State        = 0;
         Gump gump = this.m_Item.OnBeginDrag();
         if (gump.GetType() == typeof(GDragAmount))
         {
             ((GDragAmount)gump).ToDestroy = this;
         }
         else
         {
             this.m_Item.RestoreInfo = new RestoreInfo(this.m_Item);
             World.Remove(this.m_Item);
             gump.m_OffsetX = base.m_OffsetX;
             gump.m_OffsetY = base.m_OffsetY;
             gump.X         = Engine.m_xMouse - base.m_OffsetX;
             gump.Y         = Engine.m_yMouse - base.m_OffsetY;
             if (base.m_Parent is GContainer)
             {
                 ((GContainer)base.m_Parent).m_Hash[this.m_Item] = null;
             }
             Gumps.Destroy(this);
         }
     }
 }
Exemple #4
0
 private void lstGump_DrawItem(object sender, DrawItemEventArgs e)
 {
     try
     {
         if (e.Index == -1)
         {
             return;
         }
         Size     size1    = new Size();
         Graphics graphics = e.Graphics;
         Bitmap   gump     = Gumps.GetGump(Cache[e.Index].ID);
         Size     size2    = Cache[e.Index].Size;
         size1.Width  = size2.Width <= 100 ? size2.Width : 100;
         size1.Height = size2.Height <= 100 ? size2.Height : 100;
         Rectangle rect = new Rectangle(e.Bounds.Location, size1);
         rect.Offset(45, 3);
         graphics.FillRectangle((e.State & DrawItemState.Selected) > DrawItemState.None ? SystemBrushes.Highlight : SystemBrushes.Window, e.Bounds);
         graphics.DrawString("0x" + Cache[e.Index].ID.ToString("X"), Font, SystemBrushes.WindowText, e.Bounds.X, e.Bounds.Y);
         graphics.DrawImage(gump, rect);
         gump.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show(@"There was an error rendering the gump art, try rebuilding the cache.\r\n\r\n" + ex.Message);
     }
 }
 public static void BeginRender()
 {
     while (MessageManager.m_ToRemove.Count > 0)
     {
         object obj = MessageManager.m_ToRemove.Dequeue();
         MessageManager.m_Messages.Remove(obj);
         Gumps.Destroy((Gump)obj);
     }
     MessageManager.m_yStack = Engine.GameY + Engine.GameHeight - 22;
     MessageManager.RecurseProcessItemGumps(Gumps.Desktop, 0, 0, false);
     for (int index = 0; index < MessageManager.m_Messages.Count; ++index)
     {
         ((IMessage)MessageManager.m_Messages[index]).OnBeginRender();
     }
     while (MessageManager.m_ToRemove.Count > 0)
     {
         object obj = MessageManager.m_ToRemove.Dequeue();
         MessageManager.m_Messages.Remove(obj);
         Gumps.Destroy((Gump)obj);
     }
     if (!Gumps.Invalidated)
     {
         return;
     }
     if (Engine.m_LastMouseArgs != null)
     {
         Engine.MouseMove((object)Engine.m_Display, Engine.m_LastMouseArgs);
         Engine.MouseMoveQueue();
     }
     Gumps.Invalidated = false;
 }
 public void OnTarget(object o)
 {
     if (o is Item)
     {
         Item removed = (Item)o;
         removed.OverrideHue(this.m_Hue);
         if ((removed.Parent != null) && (removed.Parent.Container != null))
         {
             removed.Parent.Container.OnItemRemove(removed);
             removed.Parent.Container.OnItemAdd(removed);
         }
         else if (removed.InWorld)
         {
             removed.Update();
         }
         else if (removed.IsEquip && (removed.EquipParent is Mobile))
         {
             Mobile equipParent = (Mobile)removed.EquipParent;
             if (equipParent.Paperdoll != null)
             {
                 Gumps.OpenPaperdoll(equipParent, equipParent.PaperdollName, equipParent.PaperdollCanDrag);
             }
         }
     }
     else
     {
         Engine.TargetHandler = this;
     }
 }
Exemple #7
0
 private void OnClick_SaveAllJpg(object sender, EventArgs e)
 {
     using (FolderBrowserDialog dialog = new FolderBrowserDialog())
     {
         dialog.Description         = "Select directory";
         dialog.ShowNewFolderButton = true;
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             for (int i = 0; i < listBox.Items.Count; ++i)
             {
                 int index = int.Parse(listBox.Items[i].ToString());
                 if (index >= 0)
                 {
                     string FileName = Path.Combine(dialog.SelectedPath, String.Format("Gump {0}.jpg", index));
                     Bitmap bit      = new Bitmap(Gumps.GetGump(index));
                     if (bit != null)
                     {
                         bit.Save(FileName, ImageFormat.Jpeg);
                     }
                     bit.Dispose();
                 }
             }
             MessageBox.Show(String.Format("All Gumps saved to {0}", dialog.SelectedPath), "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
         }
     }
 }
Exemple #8
0
        private void OpenList_OnClick(Gump g)
        {
            if (this.m_Dropdown != null)
            {
                Gumps.Destroy((Gump)this.m_Dropdown);
            }
            Point screen = this.PointToScreen(new Point(0, 0));

            this.m_Dropdown = new GBackground(this.m_BackID, this.Width, this.m_Count * 20 + (this.Height - this.UseHeight), screen.X, screen.Y, true);
            this.m_Dropdown.DestroyOnUnfocus = true;
            int offsetY = this.m_Dropdown.OffsetY;
            int num1    = 0;

            for (int index = 0; index < this.m_Count; ++index)
            {
                GTextButton gtextButton = new GTextButton(this.m_List[index], this.m_Font, this.m_HRegular, this.m_HOver, this.m_Dropdown.OffsetX, offsetY, new OnClick(this.SetIndex_OnClick));
                gtextButton.SetTag("Index", (object)index);
                this.m_Dropdown.Children.Add((Gump)gtextButton);
                offsetY += gtextButton.Height;
                if (gtextButton.Width + 3 > num1)
                {
                    num1 = gtextButton.Width + 3;
                }
            }
            this.m_Dropdown.Height = offsetY + (this.m_Dropdown.Height - (this.m_Dropdown.OffsetY + this.m_Dropdown.UseHeight));
            int num2 = num1 + (this.m_Dropdown.Width - this.m_Dropdown.UseWidth);

            if (num2 > this.m_Dropdown.Width)
            {
                this.m_Dropdown.Width = num2;
            }
            Gumps.Desktop.Children.Add((Gump)this.m_Dropdown);
        }
Exemple #9
0
        public static void Update(double totalMS, double frameMS)
        {
            SortControlsByInfo();

            var first = Gumps.First;

            while (first != null)
            {
                var next = first.Next;

                Control g = first.Value;

                g.Update(totalMS, frameMS);

                if (g.IsDisposed)
                {
                    Gumps.Remove(first);
                }

                first = next;
            }

            GameCursor?.Update(totalMS, frameMS);
            HandleKeyboardInput();
            HandleMouseInput();
        }
Exemple #10
0
        public override void RefreshCache()
        {
            if (this.ImageCache != null)
            {
                this.ImageCache.Dispose();
            }

            this.ImageCache = Gumps.GetGump(this.mGumpID);

            if (this.ImageCache == null)
            {
                this.GumpID = 0;
            }
            if (this.mHue.Index != 0)
            {
                this.mHue.ApplyTo(this.ImageCache, false);
            }

            try
            {
                if (this.ImageCache != null && !this.ImageCache.Size.IsEmpty)
                {
                    this.mTileSize = this.ImageCache.Size;
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #11
0
        public static void MoveTo(Gump who)
        {
            Point point = who.PointToScreen(new Point(who.Width / 2, who.Height / 2));

            Cursor.Position = Engine.m_Display.PointToScreen((Point)point);
            Gumps.Invalidate();
        }
Exemple #12
0
        private void UpdateLabel(bool forceUpdate, IHue hue)
        {
            string text = this.m_String;

            if (this.m_PassChar != '\0')
            {
                text = new string(this.m_PassChar, text.Length);
            }
            if (this.m_Focus && this.ShowCaret)
            {
                text = text + "_";
            }
            if ((this.m_Text != null) && !forceUpdate)
            {
                this.m_Text.Text = text;
                this.m_Text.Hue  = hue;
            }
            else
            {
                if (this.m_Text != null)
                {
                    Gumps.Destroy(this.m_Text);
                }
                if (this.m_MaxChars >= 0)
                {
                    this.m_Text = new GWrappedLabel(text, this.m_Font, this.m_HNormal, 0, 0, this.m_Width);
                    this.m_Text.Scissor(0, 0, this.m_Width, this.m_Height);
                }
                else
                {
                    this.m_Text = new GLabel(text, this.m_Font, this.m_HNormal, 0, 0);
                }
            }
        }
Exemple #13
0
        private void UpdateLabel(bool forceUpdate, IHue hue)
        {
            string str = this.m_String;

            if ((int)this.m_PassChar != 0)
            {
                str = new string(this.m_PassChar, str.Length);
            }
            if (this.m_Focus && this.ShowCaret)
            {
                str += "_";
            }
            if (this.m_Text != null && !forceUpdate)
            {
                this.m_Text.Text = str;
                this.m_Text.Hue  = hue;
            }
            else
            {
                if (this.m_Text != null)
                {
                    Gumps.Destroy((Gump)this.m_Text);
                }
                if (this.m_MaxChars >= 0)
                {
                    this.m_Text = (GLabel) new GWrappedLabel(str, this.m_Font, this.m_HNormal, 0, 0, this.m_Width);
                    this.m_Text.Scissor(0, 0, this.m_Width, this.m_Height);
                }
                else
                {
                    this.m_Text = new GLabel(str, this.m_Font, this.m_HNormal, 0, 0);
                }
            }
        }
Exemple #14
0
 public void RemoveAt(int index)
 {
     this.m_Array = null;
     this.m_List.RemoveAt(index);
     Gumps.Invalidate();
     this.m_Count--;
 }
Exemple #15
0
 protected internal override void OnMouseUp(int X, int Y, MouseButtons mb)
 {
     if (mb == MouseButtons.Right)
     {
         Gumps.Destroy(this);
     }
 }
Exemple #16
0
        protected override void OnLoad(EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Options.LoadedUltimaClass["Gumps"] = true;
            ShowFreeSlots = false;
            showFreeSlotsToolStripMenuItem.Checked = false;

            listBox.BeginUpdate();
            listBox.Items.Clear();
            List <object> cache = new List <object>();

            for (int i = 0; i < Gumps.GetCount(); ++i)
            {
                if (Gumps.IsValidIndex(i))
                {
                    cache.Add((object)i);
                }
            }
            listBox.Items.AddRange(cache.ToArray());
            listBox.EndUpdate();
            if (listBox.Items.Count > 0)
            {
                listBox.SelectedIndex = 0;
            }
            if (!Loaded)
            {
                FiddlerControls.Events.FilePathChangeEvent += new FiddlerControls.Events.FilePathChangeHandler(OnFilePathChangeEvent);
                FiddlerControls.Events.GumpChangeEvent     += new FiddlerControls.Events.GumpChangeHandler(OnGumpChangeEvent);
            }
            Loaded         = true;
            Cursor.Current = Cursors.Default;
        }
Exemple #17
0
        private void OpenList_OnClick(Gump g)
        {
            if (this.m_Dropdown != null)
            {
                Gumps.Destroy(this.m_Dropdown);
            }
            Point point = base.PointToScreen(new Point(0, 0));

            this.m_Dropdown = new GBackground(this.m_BackID, this.Width, (this.m_Count * 20) + (this.Height - base.UseHeight), point.X, point.Y, true);
            this.m_Dropdown.DestroyOnUnfocus = true;
            int offsetY = this.m_Dropdown.OffsetY;
            int num2    = 0;

            for (int i = 0; i < this.m_Count; i++)
            {
                GTextButton toAdd = new GTextButton(this.m_List[i], this.m_Font, this.m_HRegular, this.m_HOver, this.m_Dropdown.OffsetX, offsetY, new OnClick(this.SetIndex_OnClick));
                toAdd.SetTag("Index", i);
                this.m_Dropdown.Children.Add(toAdd);
                offsetY += toAdd.Height;
                if ((toAdd.Width + 3) > num2)
                {
                    num2 = toAdd.Width + 3;
                }
            }
            this.m_Dropdown.Height = offsetY + (this.m_Dropdown.Height - (this.m_Dropdown.OffsetY + this.m_Dropdown.UseHeight));
            num2 += this.m_Dropdown.Width - this.m_Dropdown.UseWidth;
            if (num2 > this.m_Dropdown.Width)
            {
                this.m_Dropdown.Width = num2;
            }
            Gumps.Desktop.Children.Add(this.m_Dropdown);
        }
 public override void RefreshCache()
 {
     if (this.Image1Cache != null)
     {
         this.Image1Cache.Dispose();
     }
     if (this.Image2Cache != null)
     {
         this.Image1Cache.Dispose();
     }
     this.Image1Cache = (Image)Gumps.GetGump(this.mUncheckedID);
     if (this.Image1Cache == null)
     {
         this.UnCheckedID = 210;
     }
     this.Image2Cache = (Image)Gumps.GetGump(this.mCheckedID);
     if (this.Image2Cache == null)
     {
         this.CheckedID = 211;
     }
     if (this.mChecked)
     {
         this.mSize = this.Image2Cache.Size;
     }
     else
     {
         this.mSize = this.Image1Cache.Size;
     }
 }
Exemple #19
0
        private void listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());

            if (Gumps.IsValidIndex(i))
            {
                Bitmap bmp = Gumps.GetGump(i);
                if (bmp != null)
                {
                    pictureBox.BackgroundImage = bmp;
                    IDLabel.Text   = String.Format("ID: 0x{0:X} ({1})", i, i);
                    SizeLabel.Text = String.Format("Size: {0},{1}", bmp.Width, bmp.Height);
                }
                else
                {
                    pictureBox.BackgroundImage = null;
                }
            }
            else
            {
                pictureBox.BackgroundImage = null;
            }
            listBox.Invalidate();
            jumpToMaleFemaleInvalidate();
        }
Exemple #20
0
        public ActionResult GumpArt(int id, int hue = 0)
        {
            DeleteTempFiles(System.Web.HttpContext.Current);
            Files.SetMulPath(HttpContext.Server.MapPath("~/mul"));
            Bitmap bmp;

            if (hue > 0 && hue <= 3000)
            {
                bool patched;
                bmp = new Bitmap(Gumps.GetGump(id, Hues.GetHue(hue), false, out patched));
            }
            else
            {
                bmp = new Bitmap(Gumps.GetGump(id));
            }

            byte[] byteArray = ImageToByte(bmp);

            using (Image image = Image.FromStream(new MemoryStream(byteArray)))
            {
                image.Save(HttpContext.Server.MapPath("~/tempfiles/") + id + hue + ".png", ImageFormat.Png);
            }

            ViewBag.img = "/tempfiles/" + id + hue + ".png";
            return(File(HttpContext.Server.MapPath("~/tempfiles/") + id + hue + ".png", "image/png"));
        }
Exemple #21
0
 private void CloseIfClickOutGumps()
 {
     foreach (Gump gump in Gumps.OfType <Gump>().Where(s => s.CloseIfClickOutside))
     {
         gump.Dispose();
     }
 }
Exemple #22
0
 private void Entry_OnClick(Gump g)
 {
     if ((g.HasTag("HueID") && g.HasTag("Buttons")) && g.HasTag("Index"))
     {
         int          tag     = (int)g.GetTag("HueID");
         MouseButtons buttons = (MouseButtons)g.GetTag("Buttons");
         int          index   = (int)g.GetTag("Index");
         if ((buttons & MouseButtons.Right) != MouseButtons.None)
         {
             QuickHues.Remove(index);
             Gumps.Destroy(this);
             GQuickHues toAdd = new GQuickHues(this.m_Picker, this.m_Brightness, this.m_Okay);
             if (this.m_Expanded)
             {
                 toAdd.m_Expanded = true;
                 toAdd.Height     = toAdd.m_ExpandedHeight;
             }
             base.m_Parent.Children.Add(toAdd);
         }
         else if ((tag >= 2) && (tag < 0x3ea))
         {
             tag -= 2;
             int num3 = tag % 5;
             tag /= 5;
             int num4 = tag % 20;
             tag /= 20;
             int num5 = tag;
             this.m_Picker.Brightness = num3;
             this.m_Picker.ShadeX     = num4;
             this.m_Picker.ShadeY     = num5;
             this.m_Brightness.Refresh();
             this.m_Okay.Click();
         }
     }
 }
Exemple #23
0
        public static void MoveTo(Gump who)
        {
            Point screen = who.PointToScreen(new Point(who.Width / 2, who.Height / 2));

            System.Windows.Forms.Cursor.Position = Engine.m_Display.PointToScreen((System.Drawing.Point)screen);
            Gumps.Invalidate();
        }
Exemple #24
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
     if (edSvc != null)
     {
         var gumpArtBrowser = new GumpArtBrowser
         {
             GumpID = Conversions.ToInteger(value)
         };
         if (edSvc.ShowDialog(gumpArtBrowser) == DialogResult.OK)
         {
             Image gump = Gumps.GetGump(gumpArtBrowser.GumpID);
             if (gump != null)
             {
                 gump.Dispose();
                 ReturnValue = gumpArtBrowser.GumpID;
                 gumpArtBrowser.Dispose();
                 return(ReturnValue);
             }
             MessageBox.Show("Invalid GumpID");
             return(value);
         }
         gumpArtBrowser.Dispose();
     }
     return(value);
 }
Exemple #25
0
        private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());

            if (Gumps.IsValidIndex(i))
            {
                Bitmap bmp = Gumps.GetGump(i);
                if (bmp != null)
                {
                    pictureBox.BackgroundImage = bmp;
                    IDLabel.Text   = $"ID: 0x{i:X} ({i})";
                    SizeLabel.Text = $"Size: {bmp.Width},{bmp.Height}";
                }
                else
                {
                    pictureBox.BackgroundImage = null;
                }
            }
            else
            {
                pictureBox.BackgroundImage = null;
            }

            listBox.Invalidate();
            JumpToMaleFemaleInvalidate();
        }
Exemple #26
0
        private void Entry_OnClick(Gump Sender)
        {
            int tag = (int)Sender.GetTag("EntryID");

            Network.Send(new PPopupResponse(this.m_Owner, tag));
            Gumps.Destroy(this);
        }
Exemple #27
0
        private void OnClickFindFree(object sender, EventArgs e)
        {
            int id = int.Parse(listBox.Items[listBox.SelectedIndex].ToString());

            ++id;
            for (int i = listBox.SelectedIndex + 1; i < listBox.Items.Count; ++i, ++id)
            {
                if (id < int.Parse(listBox.Items[i].ToString()))
                {
                    listBox.SelectedIndex = i;
                    break;
                }

                if (!_showFreeSlots)
                {
                    continue;
                }

                if (!Gumps.IsValidIndex(int.Parse(listBox.Items[i].ToString())))
                {
                    listBox.SelectedIndex = i;
                    break;
                }
            }
        }
Exemple #28
0
 protected internal override void OnMouseDown(int x, int y, MouseButtons mb)
 {
     if ((mb & MouseButtons.Right) != MouseButtons.None)
     {
         Gumps.Destroy(this.m_Owner);
     }
 }
Exemple #29
0
 protected internal override void OnDragDrop(Gump g)
 {
     if ((g != null) && (g.GetType() == typeof(GDraggedItem)))
     {
         GDraggedItem item  = (GDraggedItem)g;
         Client.Item  item2 = item.Item;
         if (((GContainer)base.m_Parent).m_HitTest)
         {
             TileFlags flags = Map.m_ItemFlags[this.m_Item.ID & 0x3fff];
             if (flags[TileFlag.Container])
             {
                 Network.Send(new PDropItem(item2.Serial, -1, -1, 0, this.m_Item.Serial));
                 Gumps.Destroy(item);
             }
             else if ((flags[TileFlag.Generic] && (item2.ID == this.m_Item.ID)) && (item2.Hue == this.m_Item.Hue))
             {
                 Point point = ((GContainer)base.m_Parent).Clip(item.Image, item.Double, base.m_Parent.PointToClient(new Point(Engine.m_xMouse - item.m_OffsetX, Engine.m_yMouse - item.m_OffsetY)), item.m_OffsetX, item.m_OffsetY);
                 Network.Send(new PDropItem(item2.Serial, (short)point.X, (short)point.Y, 0, this.m_Item.Serial));
                 Gumps.Destroy(item);
             }
             else
             {
                 base.m_Parent.OnDragDrop(item);
             }
         }
         else
         {
             base.m_Parent.OnDragDrop(item);
         }
     }
 }
Exemple #30
0
 private void lstGump_DrawItem(object sender, DrawItemEventArgs e)
 {
     try
     {
         if (e.Index == -1)
         {
             return;
         }
         Size     size1    = new Size();
         Graphics graphics = e.Graphics;
         Bitmap   gump     = Gumps.GetGump(GumpArtBrowser.Cache[e.Index].ID);
         Size     size2    = GumpArtBrowser.Cache[e.Index].Size;
         size1.Width  = size2.Width <= 100 ? size2.Width : 100;
         size1.Height = size2.Height <= 100 ? size2.Height : 100;
         Rectangle rect = new Rectangle(e.Bounds.Location, size1);
         rect.Offset(45, 3);
         if ((e.State & DrawItemState.Selected) > DrawItemState.None)
         {
             graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
         }
         else
         {
             graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
         }
         graphics.DrawString("0x" + GumpArtBrowser.Cache[e.Index].ID.ToString("X"), this.Font, SystemBrushes.WindowText, (float)e.Bounds.X, (float)e.Bounds.Y);
         graphics.DrawImage((Image)gump, rect);
         gump.Dispose();
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         int num = (int)Interaction.MsgBox((object)("There was an error rendering the gump art, try rebuilding the cache.\r\n\r\n" + ex.Message), MsgBoxStyle.OkOnly, (object)null);
         ProjectData.ClearProjectError();
     }
 }