Пример #1
0
 public static UserStatus GetStatus(User user)
 {
     if (!(user.Visible && user.Online))
     {
         return Offline;
     }
     if (user.IsIgnored)
     {
         return Ignored;
     }
     if (user.IsDND)
     {
         return DND;
     }
     if (user.IsAway)
     {
         return Away;
     }
     if ((user.Equals(User.Current) && (ChatEffects.Current != null)) && ChatEffects.Current.Equals(ChatEffects.Chicken))
     {
         return Chicken;
     }
     if ((user.Equals(User.Current) && (ChatEffects.Current != null)) && ChatEffects.Current.Equals(ChatEffects.Canadian))
     {
         return Canadian;
     }
     return None;
 }
Пример #2
0
 private ITextEffect chatPanel_StyleChatLine(ChatPanel sender, User user, TextLine line)
 {
     if (user.ID == User.Current.ID)
     {
         return new FontColorEffect(Program.Settings.Chat.Appearance.SelfColor, Program.Settings.Chat.Appearance.SelfFont);
     }
     if (user.ID == this.Game.Host.ID)
     {
         return new FontColorEffect(Program.Settings.Chat.Appearance.GameColor, Program.Settings.Chat.Appearance.DefaultFont);
     }
     if (user.IsSystem)
     {
         if (user.Equals(User.Error))
         {
             return new FontColorEffect(Program.Settings.Chat.Appearance.ErrorColor, Program.Settings.Chat.Appearance.ErrorFont);
         }
         if (user.Equals(User.Event))
         {
             return new FontColorEffect(Program.Settings.Chat.Appearance.EventColor, Program.Settings.Chat.Appearance.EventFont);
         }
         if (user.Equals(User.System))
         {
             return new FontColorEffect(Program.Settings.Chat.Appearance.SystemColor, Program.Settings.Chat.Appearance.SystemFont);
         }
         if (user.Equals(User.Game))
         {
             return new FontColorEffect(Program.Settings.Chat.Appearance.GameColor, Program.Settings.Chat.Appearance.GameFont);
         }
     }
     return null;
 }
Пример #3
0
 public PlayerDisplayAwards(User player)
 {
     this.mPlayerID = player.ID;
     this.mAward1 = player.Award1;
     this.mAward2 = player.Award2;
     this.mAward3 = player.Award3;
     this.mAvatarID = player.Avatar;
 }
Пример #4
0
 public void AddUser(User user, bool block, bool refresh)
 {
     WaitCallback callBack = null;
     if (((!block && !base.InvokeRequired) && !base.Disposing) && !base.IsDisposed)
     {
         if (callBack == null)
         {
             callBack = delegate (object s) {
                 this.AddUser(user);
             };
         }
         ThreadPool.QueueUserWorkItem(callBack);
     }
     else if ((!base.Disposing && !base.IsDisposed) && this.IsBound)
     {
         if (this.UserRows.ContainsKey(user))
         {
             this.UpdateUser(user);
         }
         else
         {
             UserListRow item = null;
             UserListCategories initialCategory = this.DetermineUserCategory(user);
             if (this.Style == UserListStyles.Chatroom)
             {
                 int index = Chatroom.GatheringParticipants.IndexOf(user);
                 if (index >= 0)
                 {
                     Chatroom.GatheringParticipants.IndexObject(user);
                     Chatroom.GatheringParticipants[index] = user;
                 }
                 else
                 {
                     Chatroom.GatheringParticipants.IndexObject(user);
                     Chatroom.GatheringParticipants.Add(user);
                 }
             }
             item = new UserListRow(this, user, this.Style, initialCategory);
             item.MouseDown += new MouseEventHandler(this.row_MouseDown);
             item.MouseUp += new MouseEventHandler(this.row_MouseUp);
             this.AddedRows.Enqueue(item);
             if (refresh && this.AutoRefresh)
             {
                 this.RefreshData();
             }
         }
     }
 }
Пример #5
0
 public void RemoveUser(User user)
 {
     if (this.UserRows.ContainsKey(user))
     {
         UserListRow item = this.UserRows[user];
         this.RemovedRows.Enqueue(item);
         if (this.AutoRefresh)
         {
             this.RefreshData();
         }
     }
 }
Пример #6
0
 public UserListRow(PnlUserList parent, GPG.Multiplayer.Quazal.User user, UserListStyles style, UserListCategories initialCategory)
 {
     this.PlayerAwards = null;
     this.PlayerStatus = null;
     this.mCategory = UserListCategories.Online;
     this.mPreviousRow = null;
     this.mNextRow = null;
     this.mIsSelected = false;
     this.LastCategory = null;
     this.ClanRankImage = null;
     this.Award1Image = null;
     this.Award2Image = null;
     this.Award3Image = null;
     this.AvatarImage = null;
     this.StatusImage = null;
     this.ClanLabelBounds = null;
     this.mParent = parent;
     this.mUser = user;
     this.mStyle = style;
     this.mCategory = initialCategory;
     this.Parent.MouseMove += new MouseEventHandler(this.Parent_MouseMove);
     this.Parent.MouseDown += new MouseEventHandler(this.Parent_MouseDown);
     this.Parent.MouseUp += new MouseEventHandler(this.Parent_MouseUp);
     this.BindToUser(this.User);
 }
Пример #7
0
 public bool TryFindUser(string name, out User user)
 {
     return this.TryFindUser(name, true, out user);
 }
Пример #8
0
 internal void RefreshChatParticipant(User user)
 {
     this.UpdateUser(user);
 }
Пример #9
0
 public static bool HasAccessTo(int acl, User user)
 {
     if (user == null)
     {
         return false;
     }
     return ((acl == 0) || (user.IsAdmin || (All.ContainsKey(acl) && All[acl].HasAccess(user))));
 }
Пример #10
0
 public PlayerView(User player)
 {
     this.mPlayer = player;
 }
Пример #11
0
 public void AddUser(User user)
 {
     this.AddUser(user, false);
 }
Пример #12
0
 public bool IsSpeaking(User user)
 {
     return this.IsSpeaking(user.Name);
 }
Пример #13
0
 public DlgAvatarPicker(User player)
 {
     this.InitializeComponent();
     this.mPlayer = player;
 }
Пример #14
0
 internal void UpdateUser(User user, string status)
 {
     VGen0 target = null;
     try
     {
         user.IsFriend = User.CurrentFriends.ContainsIndex("name", user.Name);
         if (target == null)
         {
             target = delegate {
                 this.pnlUserListChat.UpdateUser(user);
             };
         }
         this.ChatroomQueue.Enqueue(target, new object[0]);
         int index = Chatroom.GatheringParticipants.IndexOf(user);
         if (index >= 0)
         {
             Chatroom.GatheringParticipants.IndexObject(user);
             Chatroom.GatheringParticipants[index] = user;
         }
         else
         {
             Chatroom.GatheringParticipants.IndexObject(user);
             Chatroom.GatheringParticipants.Add(user);
         }
         foreach (FrmPrivateChat chat in this.PrivateChats.Values)
         {
             if ((!chat.Disposing && !chat.IsDisposed) && chat.ChatTarget.Equals(user))
             {
                 chat.ChatTarget = user;
                 chat.RefreshToolstrip();
             }
         }
         if (status != null)
         {
             this.SetUserStatus(user.Name, status);
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }
Пример #15
0
 internal void UpdateUser(User user)
 {
     this.UpdateUser(user, null);
 }
Пример #16
0
 public bool TryFindUser(string name, bool doLookup, out User user)
 {
     if (Chatroom.InChatroom && Chatroom.GatheringParticipants.TryFindByIndex("name", name, out user))
     {
         return true;
     }
     if (User.CurrentFriends.TryFindByIndex("name", name, out user))
     {
         return true;
     }
     if (doLookup && DataAccess.TryGetObject<User>("GetPlayerDetails", out user, new object[] { name }))
     {
         return true;
     }
     user = null;
     return false;
 }
Пример #17
0
 public void UpdateUser(User user)
 {
     this.UpdatedUsers.Enqueue(user);
     if (this.AutoRefresh)
     {
         this.RefreshData();
     }
 }
Пример #18
0
 public PlayerView(User player, MappedObjectList<User> friends)
 {
     this.mPlayer = player;
     this.mFriends = friends;
 }
Пример #19
0
        private UserListCategories DetermineUserCategory(User user)
        {
            UserListCategories online = UserListCategories.Online;
            switch (this.Style)
            {
                case UserListStyles.Chatroom:
                    if (!Program.Settings.Chat.ShowSpeaking || !base.MainForm.IsSpeaking(user))
                    {
                        if (user.IsAdmin)
                        {
                            return UserListCategories.Admin;
                        }
                        if (user.IsModerator)
                        {
                            return UserListCategories.Moderator;
                        }
                        if (user.IsClanMate)
                        {
                            return UserListCategories.Clan;
                        }
                        if (user.IsFriend)
                        {
                            return UserListCategories.Friend;
                        }
                        if (user.IsAway)
                        {
                            return UserListCategories.Away;
                        }
                        return UserListCategories.Online;
                    }
                    return UserListCategories.Speaking;

                case UserListStyles.OnlineOffline:
                    if (!user.Online)
                    {
                        return UserListCategories.Offline;
                    }
                    return UserListCategories.Online;
            }
            return online;
        }
Пример #20
0
 public static bool IsUserIgnored(User user)
 {
     return IsUserIgnored(user.ID);
 }
Пример #21
0
 public void AddUser(User user, bool block)
 {
     this.AddUser(user, block, true);
 }
Пример #22
0
 public static bool Login(string username, string pwd, string server, int port, bool ignoreStatus)
 {
     VGen0 target = null;
     EventLog.WriteLine("Beginning Login Function.", new object[0]);
     try
     {
         if (Lobby.GetLobby().authenticationHelper.LoginUser(username, pwd, server, port))
         {
             EventLog.WriteLine("Finished Login Function.", new object[0]);
             if ((GetProtocol() != null) && (username.ToUpper().IndexOf("_T_E_M_P_") >= 0))
             {
                 mCurrent = MakeFakeUser("Guest");
                 return true;
             }
             if (!ignoreStatus)
             {
                 mCurrent = DataAccess.GetObjects<User>("GetPlayerDetails", new object[] { username })[0];
             }
             else
             {
                 mCurrent = MakeFakeUser(username);
             }
             if (target == null)
             {
                 target = delegate {
                     if (!ignoreStatus)
                     {
                         DataAccess.ExecuteQuery("SetAwayStatus", new object[] { 0 });
                         DataAccess.ExecuteQuery("SetDNDStatus", new object[] { 0 });
                     }
                     mCurrent.IsAway = false;
                     mCurrent.IsDND = false;
                     if (Lobby.sProtocol == null)
                     {
                         AuthenticationHelper.SetLoginName(Current.Name);
                     }
                 };
             }
             ThreadQueue.Quazal.Enqueue(target, new object[0]);
             return true;
         }
         return false;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return false;
     }
 }
Пример #23
0
 public bool HasAccess(User user)
 {
     if (user == null)
     {
         return false;
     }
     return (user.IsAdmin || this.HasAccess(user.ID));
 }
Пример #24
0
 internal void AddChat(User user, string message)
 {
     try
     {
         VGen0 method = null;
         VGen1 gen2 = null;
         bool scroll;
         if (!user.IsIgnored)
         {
             if (message.IndexOf("I am the effect: ") >= 0)
             {
                 this.RecieveChatEffect(user.Name, message.Replace("I am the effect: ", ""));
             }
             else
             {
                 message = Profanity.MaskProfanity(message);
                 message = message.Replace("\t", "  ");
                 if (Program.Settings.Sound.Speech.EnableSpeech)
                 {
                     Speech.Speak(string.Format("{0} says,, {1}", user.Name, message), false);
                 }
                 scroll = true;
                 if ((base.InvokeRequired && !base.Disposing) && !base.IsDisposed)
                 {
                     if (method == null)
                     {
                         method = delegate {
                             scroll = !this.gvChat.IsFocusedView && GPGGridView.IsMaxScrolled(this.gvChat);
                         };
                     }
                     base.Invoke(method);
                 }
                 else if (!(base.Disposing || base.IsDisposed))
                 {
                     scroll = !this.gvChat.IsFocusedView && GPGGridView.IsMaxScrolled(this.gvChat);
                 }
                 ChatLine line = new ChatLine(this.gpgChatGrid);
                 line.Tag = user;
                 line.PlayerInfo = user.Name;
                 line.Text = message;
                 line.Icon = null;
                 line.TextColor = Program.Settings.Chat.Appearance.DefaultColor;
                 line.TextFont = Program.Settings.Chat.Appearance.DefaultFont;
                 line.Filters["Self"] = user.IsCurrent;
                 line.Filters["System"] = user.Equals(User.System);
                 line.Filters["Game"] = user.Equals(User.Game);
                 line.Filters["Event"] = user.Equals(User.Event);
                 line.Filters["Error"] = user.Equals(User.Error);
                 line.Filters["Admin"] = !user.IsCurrent && user.IsAdmin;
                 line.Filters["Clan"] = !user.IsCurrent && user.IsClanMate;
                 line.Filters["Friend"] = user.IsFriend;
                 line.Filters["Other"] = ((!user.IsSystem && !user.IsAdmin) && (!user.IsClanMate && !user.IsFriend)) && !user.IsCurrent;
                 line.Filters["Speaking"] = true;
                 line.Filters[user.Name] = true;
                 this.OnStyleChatLine(line);
                 if (this.PlayerChatEffects.ContainsKey(user.Name))
                 {
                     foreach (TextSegment segment in line.TextSegments)
                     {
                         segment.Effect = this.PlayerChatEffects[user.Name];
                     }
                 }
                 if ((user != User.System) && (this.AddSpeaker != null))
                 {
                     this.AddSpeaker(this, user);
                 }
                 if ((base.InvokeRequired && !base.Disposing) && !base.IsDisposed)
                 {
                     if (gen2 == null)
                     {
                         gen2 = delegate (object objline) {
                             this.mChatLines.Add((ChatLine) objline);
                             if (scroll)
                             {
                                 this.gvChat.MoveLastVisible();
                             }
                         };
                     }
                     base.BeginInvoke(gen2, new object[] { line });
                 }
                 else if (!base.Disposing && !base.IsDisposed)
                 {
                     this.mChatLines.Add(line);
                     if ((!base.IsDisposed && !base.Disposing) && scroll)
                     {
                         this.gvChat.MoveLastVisible();
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }
Пример #25
0
 public static bool HasAccessTo(string aclName, User user)
 {
     return (((user != null) && user.IsAdmin) || HasAccessTo(aclName, user.ID));
 }
Пример #26
0
 private void AddSpeaker(User user)
 {
     ElapsedEventHandler handler = null;
     if (Program.Settings.Chat.ShowSpeaking && Chatroom.InChatroom)
     {
         if (this.SpeakingTimers.ContainsKey(user.Name))
         {
             this.SpeakingTimers[user.Name].Interval = this.SpeakingInterval;
         }
         else
         {
             TextContainer<StatusTextLine> container;
             VGen0 gen = null;
             StatusTextLine userLine = this.ChatContainers.Pop(user.Name, out container);
             if (userLine != null)
             {
                 if (container.Count < 1)
                 {
                     this.RefreshData = true;
                 }
                 if (gen == null)
                 {
                     gen = delegate {
                         if (this.ChatContainerLookup["Speaking"].Count < 1)
                         {
                             this.RefreshData = true;
                         }
                         this.ChatContainerLookup["Speaking"].Add(userLine);
                     };
                 }
                 this.ChatroomQueue.Enqueue(gen, new object[0]);
             }
             StateTimer timer = new StateTimer((double) this.SpeakingInterval);
             timer.AutoReset = false;
             timer.State = user;
             if (handler == null)
             {
                 handler = delegate (object sender, ElapsedEventArgs e) {
                     VGen0 target = null;
                     User _user = (User) (sender as StateTimer).State;
                     if (this.SpeakingTimers.ContainsKey(_user.Name))
                     {
                         this.SpeakingTimers.Remove(_user.Name);
                         if (this.ChatContainerLookup["Speaking"].Remove(_user.Name))
                         {
                             if (this.ChatContainerLookup["Speaking"].Count < 1)
                             {
                                 this.RefreshData = true;
                             }
                             if (target == null)
                             {
                                 target = delegate {
                                     this.AddChatParticipant(_user);
                                 };
                             }
                             this.ChatroomQueue.Enqueue(target, new object[0]);
                         }
                     }
                 };
             }
             timer.Elapsed += handler;
             this.SpeakingTimers[user.Name] = timer;
             timer.Start();
         }
     }
 }
Пример #27
0
 public static bool Logout()
 {
     try
     {
         if (Current != null)
         {
             ThreadQueue.LoggingOut = true;
             Lobby.LoggingOut = true;
             Thread.Sleep(500);
             EventLog.WriteLine("Logging out {0}", new object[] { Current });
             if (LoggingOut != null)
             {
                 LoggingOut(null, EventArgs.Empty);
             }
             ThreadQueue.Quazal.Stop();
             ThreadQueue.Quazal.WaitUntilEmpty(100);
             Messaging.StopPolling();
             Thread.Sleep(100);
             Chatroom.Leave();
             Lobby.Logout();
             mCurrent = null;
             Chatroom.Current = null;
             Chatroom.GatheringParticipants.Clear();
             if (LoggedOut != null)
             {
                 LoggedOut(null, EventArgs.Empty);
             }
             return true;
         }
         return false;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return false;
     }
 }
Пример #28
0
 internal void RefreshGathering(User user, string status)
 {
     Messaging.SendCustomCommand(CustomCommands.UpdateUser, new object[] { user.ToDataString(), status });
 }
Пример #29
0
 public void AddChatParticipant(User user)
 {
     this.ChatParticipants.Add(user);
 }
Пример #30
0
 public void BindToUser(GPG.Multiplayer.Quazal.User user, UserListCategories initialCategory)
 {
     this.mUser = user;
     this.mCategory = initialCategory;
     this.Award1Image = null;
     this.Award2Image = null;
     this.Award3Image = null;
     try
     {
         this.NameColor = Program.Settings.Chat.Appearance.DefaultColor;
         this.NameFont = DefaultFont;
         this.PlayerAwards = new PlayerDisplayAwards(user);
         if (!AvatarCache.ContainsKey(this.PlayerAwards.Avatar.ID))
         {
             AvatarCache[this.PlayerAwards.Avatar.ID] = DrawUtil.CopyImage(this.PlayerAwards.Avatar.Image);
         }
         this.AvatarImage = AvatarCache[this.PlayerAwards.Avatar.ID];
         if (this.PlayerAwards.Award1Specified)
         {
             this.Award1Image = this.PlayerAwards.Award1.SmallImage;
         }
         if (this.PlayerAwards.Award2Specified)
         {
             this.Award2Image = this.PlayerAwards.Award2.SmallImage;
         }
         if (this.PlayerAwards.Award3Specified)
         {
             this.Award3Image = this.PlayerAwards.Award3.SmallImage;
         }
         if (!(((!user.IsAway && !user.IsDND) && !user.IsIgnored) && user.Online))
         {
             this.NameColor = Program.Settings.Chat.Appearance.UnavailableColor;
             this.NameFont = DefaultFont;
         }
         else if (user.IsAdmin || ((Chatroom.InChatroom && !Chatroom.Current.IsPersistent) && user.IsChannelOperator))
         {
             this.NameColor = Program.Settings.Chat.Appearance.AdminColor;
             this.NameFont = AdminFont;
         }
         else if (user.IsModerator)
         {
             this.NameColor = Program.Settings.Chat.Appearance.ModeratorColor;
             this.NameFont = Program.Settings.Chat.Appearance.ModeratorFont;
         }
         else
         {
             this.NameColor = Program.Settings.Chat.Appearance.DefaultColor;
             this.NameFont = DefaultFont;
         }
         if (this.NameColor == Color.Empty)
         {
             this.NameColor = Program.Settings.Chat.Appearance.DefaultColor;
         }
         if (this.NameFont == null)
         {
             this.NameFont = DefaultFont;
         }
         this.PlayerStatus = UserStatus.GetStatus(user);
         if (this.PlayerStatus != null)
         {
             this.StatusImage = this.PlayerStatus.Icon;
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }