コード例 #1
0
ファイル: Menu.cs プロジェクト: InanZen/Chat-Assistant
 public void Close(bool force = false)
 {
     try
     {
         var player = CAMain.PlayerList[this.PlayerID];
         if (player != null)
         {
             MenuEventArgs args = new MenuEventArgs(this.contents, this.PlayerID, -1, (force)?MenuStatus.ForceExit:MenuStatus.Exit);
             if (this.MenuActionHandler != null)
             {
                 this.MenuActionHandler(this, args);
             }
             if (force || !args.Handled)
             {
                 player.InMenu = false;
                 player.Menu   = null;
                 if (!player.quitting)
                 {
                     CAMain.DisplayLog(player, 7);
                 }
             }
         }
     }
     catch (Exception ex) { Log.ConsoleError(ex.ToString()); }
 }
コード例 #2
0
ファイル: Menu.cs プロジェクト: banknomu/Chat-Assistant
 public Menu(int playerid, String title, List<MenuItem> contents, CAMain.MenuAction del = null)
 {
     this.contents = contents;
     this.PlayerID = playerid;
     this.title = title;
     if (del != null)
         this.MenuActionHandler = del;
     if (CAMain.PlayerList[playerid] != null)
         CAMain.PlayerList[playerid].InMenu = true;
     this.DisplayMenu();
 }
コード例 #3
0
ファイル: Menu.cs プロジェクト: banknomu/Chat-Assistant
 // --------------------------- STATIC METHODS -------------------------
 public static Menu CreateMenu(int playerID, string title, List<MenuItem> data, CAMain.MenuAction callback)
 {
     var player = CAMain.PlayerList[playerID];
     try
     {
         if (player != null && !player.InMenu)
         {
             player.Menu = new Menu(playerID, title, data, callback);
             return player.Menu;
         }
     }
     catch (Exception ex) { Log.ConsoleError(ex.ToString()); }
     return null;
 }
コード例 #4
0
        public List <ChatMessage> GetCombinedLog(int len = 50)
        {
            var playerlog   = this.GetPrivateLog(len);
            var globallog   = CAMain.GetLog(len);
            var channellog  = CAMain.Channels[this.Channel].GetLog(len);
            var combinedLog = playerlog.Union(globallog).Union(channellog).OrderByDescending(m => m.Timestamp).ToList(); // combine 3 logs + sort by timestamp descending (largest = latest on top)

            for (int i = combinedLog.Count - 1; i >= 0; i--)
            {
                if (this.Ignores.Contains(combinedLog[i].Sender))
                {
                    combinedLog.RemoveAt(i);
                }
            }
            if (combinedLog.Count > len) // take required len from the top
            {
                combinedLog = combinedLog.Take(len).ToList();
            }
            combinedLog.Reverse(); // reverse the result
            return(combinedLog);
        }
コード例 #5
0
ファイル: Channel.cs プロジェクト: InanZen/Chat-Assistant
 public void JoinChannel(CAPlayer player)
 {
     if (player == null)
     {
         return;
     }
     if (player.Channel >= 0 && player.Channel != this.ID && CAMain.Channels[player.Channel] != null)
     {
         CAMain.Channels[player.Channel].LeaveChannel(player);
     }
     player.Channel = this.ID;
     if (!this.Users.Contains(player.Index))
     {
         this.Users.Add(player.Index);
         CAMain.DisplayLog(player, 6);
         if (!this.Flags.HasFlag(ChannelFlags.BlockJoinLeaveMsg))
         {
             NetMessage.SendData((int)PacketTypes.ChatText, -1, player.Index, String.Format("[Join] {0} has joined the channel", player.TSPlayer.Name), 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, this.ID + 1);
         }
     }
 }