Пример #1
0
        private static void SharedLabel(Packet p)
        {
            bool  toremove = p.ReadBool();
            short x        = (short)p.ReadUShort();
            short y        = (short)p.ReadUShort();
            byte  map      = p.ReadByte();

            if (toremove)
            {
                UserObject        user  = RenderObjectsManager.GetUser(p.ReadASCII(p.ReadByte()));
                SharedLabelObject label = RenderObjectsManager.Get <SharedLabelObject>().FirstOrDefault(s => s.Parent == user && s.Position.X == x && s.Position.Y == y && s.Map == map);
                label?.Dispose();

                UOClientManager.SysMessage(string.Format("[SharedLabel][{0}] Removed a shared label!", user.Name), 83);
            }
            else
            {
                string     description = p.ReadASCII(p.ReadByte());
                string     username    = p.ReadASCII(p.ReadByte());
                UserObject user        = RenderObjectsManager.GetUser(username);
                if (user == null)
                {
                    RenderObjectsManager.AddUser(user = new UserObject(username));
                }

                RenderObjectsManager.AddSharedLabel(new SharedLabelObject(user, x, y, map, description));
                UOClientManager.SysMessage(string.Format("[SharedLabel][{0}] Added a shared label!", user.Name), 83);
            }
        }
Пример #2
0
        public SharedLabelF()
        {
            InitializeComponent();
            Icon        = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            MinimumSize = MaximumSize = Size;
            MaximizeBox = false;
            Text        = "Shared Label Creator";

            void hanlder(object sender, EventArgs e)
            {
                if (sender is NumericTextBox tb && string.IsNullOrEmpty(tb.Text))
                {
                    tb.Text = "0";
                }
            }

            foreach (MapEntry m in Global.Maps)
            {
                comboBoxMap.Items.Add(m.Index);
                if (comboBoxMap.Items.Count - 1 == Global.Facet)
                {
                    comboBoxMap.SelectedIndex = comboBoxMap.Items.Count - 1;
                }
            }

            numericTextBoxX.Text = MouseManager.Location.X.ToString();
            numericTextBoxY.Text = MouseManager.Location.Y.ToString();

            numericTextBoxX.TextChanged += hanlder;
            numericTextBoxY.TextChanged += hanlder;

            customButtonSend.Click += (sender, e) =>
            {
                if (NetworkManager.SocketClient.IsConnected)
                {
                    NetworkManager.SocketClient.Send(new PSharedLabel((ushort)numericTextBoxX.IntValue, (ushort)numericTextBoxY.IntValue, (byte)comboBoxMap.SelectedIndex, textBoxDescription.Text));
                    RenderObjectsManager.AddSharedLabel(new SharedLabelObject(Global.PlayerInstance, (short)numericTextBoxX.IntValue, (short)numericTextBoxY.IntValue, (byte)comboBoxMap.SelectedIndex, textBoxDescription.Text));
                }
            };
        }