Example #1
0
        private void OnConnect(int serverId)
        {
            try {
                if (this.Any(m => m is MenuItemSubMenu men && men.Child is PlayerMenu p && p.ServerId == serverId))
                {
                    return;
                }

                var playerMenu = new PlayerMenu(serverId, this, Client);
                Add(new MenuItemSubMenu(Client, this, playerMenu, $"[{serverId}] {playerMenu.Title}", Constants.AceAdminMonitor, serverId));
            }
            catch (Exception ex) {
                Log.Error(ex);
            }
        }
Example #2
0
        public BanMenu(Client client, PlayerMenu parent) : base($"Ban {parent.Player.Name}", parent)
        {
            var reason = new MenuItem(client, this, "Ban Reason")
            {
                SubLabel = "None Specified"
            };

            reason.Activate += async() => {
                _reason = await UiHelper.PromptTextInput("", controller : client.Menu);

                reason.SubLabel = _reason.Length > 16 ? $"{_reason.Substring( 0, 16 )}..." : _reason;
            };
            Add(reason);

            var length = new MenuItemSpinnerInt(client, this, "Ban Duration", 60, 1, 8192, 1, true);

            Add(length);

            var lengthUnit = new MenuItemSpinnerList <string>(client, this, "Ban Duration (Units)", Units.Keys.ToList(), 0, true);

            Add(lengthUnit);

            var perma = new MenuItemCheckbox(client, this, "Permanent Ban");

            perma.Activate += () => {
                _perma = !_perma;
                lengthUnit.IsVisible = length.IsVisible = _perma;
                return(Task.FromResult(0));
            };
            Add(perma);

            var submit = new MenuItem(client, this, "Execute Ban");

            submit.Activate += () => {
                var time = _perma ? int.MinValue : Units.ElementAt((int)lengthUnit.Value).Value *(int)length.Value;
                client.Menu.CurrentMenu = parent.Parent;
                parent.Ban(_reason, time);
                return(Task.FromResult(0));
            };
            Add(submit);
        }
Example #3
0
        public KickMenu(Client client, PlayerMenu parent) : base($"Kick {parent.Player.Name}", parent)
        {
            var reason = new MenuItem(client, this, "Kick Reason")
            {
                SubLabel = "None Specified"
            };

            reason.Activate += async() => {
                _reason = await UiHelper.PromptTextInput("", controller : client.Menu);

                reason.SubLabel = _reason.Length > 16 ? $"{_reason.Substring( 0, 16 )}..." : _reason;
            };
            Add(reason);

            var submit = new MenuItem(client, this, "Kick Player");

            submit.Activate += () => {
                client.Menu.CurrentMenu = parent.Parent;
                parent.Kick(_reason);
                return(Task.FromResult(0));
            };
            Add(submit);
        }