Exemplo n.º 1
0
        public void SetSelectedTab(ChatTabs tabToSelect)
        {
            if ((ChatTabs)currentSelTab == ChatTabs.Global && tabToSelect != ChatTabs.Global)
            {
                Packet pkt = new Packet(PacketFamily.Global, PacketAction.Close);
                pkt.AddChar((byte)'n');
                World.Instance.Client.SendPacket(pkt);
            }
            else if (tabToSelect == ChatTabs.Global && (ChatTabs)currentSelTab != ChatTabs.Global)
            {
                Packet pkt = new Packet(PacketFamily.Global, PacketAction.Open);
                pkt.AddChar((byte)'y');
                World.Instance.Client.SendPacket(pkt);
            }

            tabs[currentSelTab].Selected = false;
            tabs[currentSelTab = (int)tabToSelect].Selected = true;
        }
 public bool AddMessage(string chatTabName, ChatMessage message)
 {
     lock (_locker)
     {
         var existing = ChatTabs.Where(c => c.Name == chatTabName);
         if (existing.Count() == 0)
         {
             ChatTab chatTab = new ChatTab(chatTabName);
             chatTab.ChatMessages.Add(message);
             ChatTabs.Add(chatTab);
         }
         else
         {
             existing.Select(c => { c.ChatMessages.Add(message); return(c); }).ToList();
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        private void _chatByPlayerName(TalkType type, string name, string msg)
        {
            switch (type)
            {
            //invalid types
            case TalkType.Local:
            case TalkType.Party:
                break;

            case TalkType.PM:
                m_game.Hud.AddChat(ChatTabs.Local, name, msg, ChatType.Note, ChatColor.PM);
                ChatTabs tab = m_game.Hud.GetPrivateChatTab(name);
                m_game.Hud.AddChat(tab, name, msg, ChatType.Note);
                break;

            case TalkType.Global: m_game.Hud.AddChat(ChatTabs.Global, name, msg, ChatType.GlobalAnnounce); break;

            case TalkType.Guild: m_game.Hud.AddChat(ChatTabs.Group, name, msg); break;

            case TalkType.Server:
                m_game.Hud.AddChat(ChatTabs.Local, World.GetString(DATCONST2.STRING_SERVER), msg, ChatType.Exclamation, ChatColor.Server);
                m_game.Hud.AddChat(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), msg, ChatType.Exclamation, ChatColor.ServerGlobal);
                m_game.Hud.AddChat(ChatTabs.System, "", msg, ChatType.Exclamation, ChatColor.Server);
                break;

            case TalkType.Admin:
                m_game.Hud.AddChat(ChatTabs.Group, name, msg, ChatType.HGM, ChatColor.Admin);
                break;

            case TalkType.Announce:
                World.Instance.ActiveMapRenderer.MakeSpeechBubble(null, msg, false);
                m_game.Hud.AddChat(ChatTabs.Local, name, msg, ChatType.GlobalAnnounce, ChatColor.ServerGlobal);
                m_game.Hud.AddChat(ChatTabs.Global, name, msg, ChatType.GlobalAnnounce, ChatColor.ServerGlobal);
                m_game.Hud.AddChat(ChatTabs.Group, name, msg, ChatType.GlobalAnnounce, ChatColor.ServerGlobal);
                break;
            }
        }
Exemplo n.º 4
0
 public void AddChat(ChatTabs whichTab, string who, string message, ChatType chatType = ChatType.None, ChatColor chatColor = ChatColor.Default)
 {
     chatRenderer.AddTextToTab(whichTab, who, message, chatType, chatColor);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Event for enter keypress of primary textbox. Does the chat
        /// </summary>
        private void _doTalk(object sender, EventArgs e)
        {
            if (chatTextBox.Text.Length <= 0)
            {
                return;
            }

            string chatText = chatTextBox.Text, filtered;

            chatTextBox.Text = "";
            switch (chatText[0])
            {
            case '+':                      //admin talk
                if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                {
                    goto default;
                }
                filtered = EOChatRenderer.Filter(chatText.Substring(1), true);
                if (filtered != null)
                {
                    if (!m_packetAPI.Speak(TalkType.Admin, chatText.Substring(1)))
                    {
                        _returnToLogin();
                        break;
                    }
                    AddChat(ChatTabs.Group, World.Instance.MainPlayer.ActiveCharacter.Name, filtered, ChatType.HGM, ChatColor.Admin);
                }
                break;

            case '@':                     //system talk (admin)
                if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                {
                    goto default;
                }
                filtered = EOChatRenderer.Filter(chatText.Substring(1), true);
                if (filtered != null)
                {
                    if (!m_packetAPI.Speak(TalkType.Announce, chatText.Substring(1)))
                    {
                        _returnToLogin();
                        break;
                    }
                    World.Instance.ActiveMapRenderer.MakeSpeechBubble(null, filtered, false);
                    string name = World.Instance.MainPlayer.ActiveCharacter.Name;
                    AddChat(ChatTabs.Local, name, filtered, ChatType.GlobalAnnounce, ChatColor.ServerGlobal);
                    AddChat(ChatTabs.Global, name, filtered, ChatType.GlobalAnnounce, ChatColor.ServerGlobal);
                    AddChat(ChatTabs.Group, name, filtered, ChatType.GlobalAnnounce, ChatColor.ServerGlobal);
                }
                break;

            case '\'':                     //group talk
                if (!m_party.PlayerIsMember((short)World.Instance.MainPlayer.ActiveCharacter.ID))
                {
                    break;                             //not in a party, cancel the talk
                }
                filtered = EOChatRenderer.Filter(chatText.Substring(1), true);
                if (filtered != null)
                {
                    if (!m_packetAPI.Speak(TalkType.Party, chatText.Substring(1)))
                    {
                        _returnToLogin();
                        break;
                    }
                    World.Instance.ActiveMapRenderer.MakeSpeechBubble(null, filtered, true);
                    AddChat(ChatTabs.Local, World.Instance.MainPlayer.ActiveCharacter.Name, filtered, ChatType.PlayerPartyDark, ChatColor.PM);
                    AddChat(ChatTabs.Group, World.Instance.MainPlayer.ActiveCharacter.Name, filtered, ChatType.PlayerPartyDark);
                }
                break;

            case '&':                      //guild talk
                if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "")
                {
                    goto default;
                }

                filtered = EOChatRenderer.Filter(chatText.Substring(1), true);
                if (filtered != null)
                {
                    if (!m_packetAPI.Speak(TalkType.Guild, chatText.Substring(1)))
                    {
                        _returnToLogin();
                        break;
                    }
                    //note: more processing of colors/icons is needed here
                    AddChat(ChatTabs.Group, World.Instance.MainPlayer.ActiveCharacter.Name, filtered);
                }
                break;

            case '~':                      //global talk
                filtered = EOChatRenderer.Filter(chatText.Substring(1), true);
                if (filtered != null)
                {
                    if (!m_packetAPI.Speak(TalkType.Global, chatText.Substring(1)))
                    {
                        _returnToLogin();
                        break;
                    }
                    AddChat(ChatTabs.Global, World.Instance.MainPlayer.ActiveCharacter.Name, filtered);
                }
                break;

            case '!':                      //private talk
            {
                string character, message;
                if (chatRenderer.SelectedTab.WhichTab == ChatTabs.Private1 || chatRenderer.SelectedTab.WhichTab == ChatTabs.Private2)
                {
                    character = chatRenderer.SelectedTab.ChatCharacter;
                    message   = chatText.Substring(1);
                }
                else
                {
                    int firstSpace = chatText.IndexOf(' ');
                    if (firstSpace < 7)
                    {
                        return;                                             //character names should be 6, leading ! should be 1, 6+1=7 and THAT'S MATH
                    }
                    character = chatText.Substring(1, firstSpace - 1);
                    message   = chatText.Substring(firstSpace + 1);
                }

                character = character.Substring(0, 1).ToUpper() + character.Substring(1).ToLower();

                filtered = EOChatRenderer.Filter(message, true);
                if (filtered != null)
                {
                    if (!m_packetAPI.Speak(TalkType.PM, message, character))
                    {
                        _returnToLogin();
                        break;
                    }

                    ChatTabs whichPrivateChat = chatRenderer.StartConversation(character);
                    //the other player will have their messages rendered in Color.PM on scr
                    //this player will have their messages rendered in Color.PM on the PM tab
                    if (whichPrivateChat != ChatTabs.None)
                    {
                        AddChat(whichPrivateChat, World.Instance.MainPlayer.ActiveCharacter.Name, filtered, ChatType.Note, ChatColor.PM);
                    }
                }
            }
            break;

            case '#':                      //local command
            {
                string   cmd  = chatText.Substring(1).ToLower().Trim();
                string[] args = cmd.Split(new[] { ' ' });

                if (args.Length == 1 && args[0] == "nowall")
                {
                    World.Instance.ActiveCharacterRenderer.NoWall = !World.Instance.ActiveCharacterRenderer.NoWall;
                }
                else if (args.Length == 2 && args[0] == "find")
                {
                    if (!m_packetAPI.FindPlayer(args[1]))
                    {
                        ((EOGame)Game).LostConnectionDialog();
                    }
                }
                else if (args.Length == 1 && args[0] == "loc")
                {
                    string firstPart = World.Instance.DataFiles[World.Instance.Localized2].Data[(int)DATCONST2.STATUS_LABEL_YOUR_LOCATION_IS_AT];
                    AddChat(ChatTabs.Local, "System", string.Format(firstPart + " {0}  x:{1}  y:{2}",
                                                                    World.Instance.ActiveMapRenderer.MapRef.MapID,
                                                                    World.Instance.MainPlayer.ActiveCharacter.X,
                                                                    World.Instance.MainPlayer.ActiveCharacter.Y),
                            ChatType.LookingDude);
                }
                else if (args.Length == 1 && cmd == "usage")
                {
                    int usage = World.Instance.MainPlayer.ActiveCharacter.Stats.usage;
                    AddChat(ChatTabs.Local, "System", string.Format("[x] usage: {0}hrs. {1}min.", usage / 60, usage % 60));
                }
                else if (args.Length == 1 && cmd == "ping")
                {
                    if (!m_packetAPI.PingServer())
                    {
                        ((EOGame)Game).LostConnectionDialog();
                    }
                }
            }
            break;

            default:
            {
                filtered = EOChatRenderer.Filter(chatText, true);
                if (filtered != null)
                {
                    //send packet to the server
                    if (!m_packetAPI.Speak(TalkType.Local, chatText))
                    {
                        _returnToLogin();
                        break;
                    }

                    //do the rendering
                    World.Instance.ActiveMapRenderer.MakeSpeechBubble(null, filtered, false);
                    AddChat(ChatTabs.Local, World.Instance.MainPlayer.ActiveCharacter.Name, filtered);
                }
            }
            break;
            }
        }
Exemplo n.º 6
0
 public void AddTextToTab(ChatTabs tab, string who, string text, ChatType icon = ChatType.None, ChatColor col = ChatColor.Default)
 {
     tabs[(int)tab].AddText(who, text, icon, col);
 }
Exemplo n.º 7
0
 public void AddChat(ChatTabs whichTab, string who, string message, ChatType chatType = ChatType.None, ChatColor chatColor = ChatColor.Default)
 {
     chatRenderer.AddTextToTab(whichTab, who, message, chatType, chatColor);
 }
Exemplo n.º 8
0
		public void AddTextToTab(ChatTabs tab, string who, string text, ChatType icon = ChatType.None, ChatColor col = ChatColor.Default)
		{
			tabs[(int)tab].AddText(who, text, icon, col);
		}
Exemplo n.º 9
0
		public void SetSelectedTab(ChatTabs tabToSelect)
		{
			if ((ChatTabs) currentSelTab == ChatTabs.Global && tabToSelect != ChatTabs.Global)
			{
				Packet pkt = new Packet(PacketFamily.Global, PacketAction.Close);
				pkt.AddChar((byte) 'n');
				World.Instance.Client.SendPacket(pkt);
			}
			else if(tabToSelect == ChatTabs.Global && (ChatTabs)currentSelTab != ChatTabs.Global)
			{
				Packet pkt = new Packet(PacketFamily.Global, PacketAction.Open);
				pkt.AddChar((byte) 'y');
				World.Instance.Client.SendPacket(pkt);
			}

			tabs[currentSelTab].Selected = false;
			tabs[currentSelTab = (int)tabToSelect].Selected = true;
		}
Exemplo n.º 10
0
		/// <summary>
		/// This Constructor should be used for all values in ChatTabs
		/// </summary>
		public ChatTab(ChatTabs tab, EOChatRenderer parentRenderer, bool selected = false)
			: base(null, null, parentRenderer)
		{
			WhichTab = tab;
			
			tabLabel = new XNALabel(new Rectangle(14, 2, 1, 1), Constants.FontSize08);
			tabLabel.SetParent(this);

			switch(WhichTab)
			{
				case ChatTabs.Local: tabLabel.Text = "scr";  break;
				case ChatTabs.Global: tabLabel.Text = "glb"; break;
				case ChatTabs.Group: tabLabel.Text = "grp"; break;
				case ChatTabs.System: tabLabel.Text = "sys"; break;
				case ChatTabs.Private1:
				case ChatTabs.Private2:
					tabLabel.Text = "[priv " + ((int)WhichTab + 1) + "]";
					break;
			}
			_selected = selected;

			relativeTextPos = new Vector2(20, 3);

			//enable close button based on which tab was specified
			switch(WhichTab)
			{
				case ChatTabs.Private1:
				case ChatTabs.Private2:
					{
						closeRect = new Rectangle(3, 3, 11, 11);
						drawArea = new Rectangle(drawArea.X, drawArea.Y, 132, 16);
						Visible = false;
					} break;
				default:
					{
						closeRect = null;
						drawArea = new Rectangle(drawArea.X, drawArea.Y, 43, 16);
						Visible = true;
					} break;
			}
			
			//568 331
			scrollBar = new ScrollBar(parent, new Vector2(467, 2), new Vector2(16, 97), ScrollBarColors.LightOnMed)
			{
				Visible = selected,
				LinesToRender = 7
			};
			World.IgnoreDialogs(scrollBar);
		}