예제 #1
0
 public ChatMessage(MessageType type, CommandType command, UserData user, string channel, string message)
 {
     this.message = message;
     this.type = (int)type;
     this.channel = channel;
     this.command = (int)command;
     this.from = user;
 }
예제 #2
0
        static void Main()
        {
            Config = new Configuration();
            LoadConfig(ConfigurationFilename);
            #if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            #endif
            //new update server - Forced change to prevent resting a users config
            Config.UpdaterAddress = "http://ygopro.de/launcher/version.php";
            Config.ServerInfoAddress = "http://ygopro.de/launcher/server.php";

            LanguageManager = new LanguageManager();
            //LanguageManager.Save("English");
            LanguageManager.Load(Config.Language);

            if (LauncherHelper.CheckInstance())
                if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                    return;

            UserInfo = new UserData();
            ChatServer = new ChatClient();
            DuelServer = new DuelServerClient();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (CheckUpdates())
                return;
            CheckServerInfo();
            #if DEBUG
            Config.ServerAddress = "86.0.24.143";
            Config.ChatPort = 9999;
            Config.GamePort = 6666;
            Server = new ServerInfo("DevPro", "86.0.24.143", 3333);
            #endif

            MainForm = new MainFrm();
            Application.Run(MainForm);
        }
예제 #3
0
 private void UpdateUserList(UserData[] userlist)
 {
     if (InvokeRequired)
     {
         Invoke(new Action<UserData[]>(UpdateUserList), (object)userlist);
         return;
     }
     m_onlineMode = false;
     m_friendMode = false;
     UserList.Items.Clear();
     UserList.Items.AddRange(userlist);
     m_filterUsers.Clear();
     m_filterUsers.AddRange(userlist);
 }
예제 #4
0
        public void CreateTeamList(UserData[] users)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<UserData[]>(CreateTeamList), (object)users);
                return;
            }

            m_onlineMode = true;
            UserList.Items.Clear();
            UserList.Items.AddRange(users);
            m_filterUsers.Clear();
            m_filterUsers.AddRange(users);
        }
예제 #5
0
 private void UpdateUserInfo(UserData user)
 {
     Program.UserInfo = user;
     Program.MainForm.UpdateUsername();
     if (!string.IsNullOrEmpty(Program.UserInfo.team))
         LoadTeamWindow();
 }
예제 #6
0
        private void AddOrRemoveChannelUser(UserData channelUser, bool remove)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<UserData, bool>(AddOrRemoveChannelUser), channelUser, remove);
                return;
            }

            UserData toRemove = null;
            foreach (UserData user in ChannelList.Items)
            {
                if (user.username == channelUser.username)
                    toRemove = user;
            }
            if(toRemove != null)
                ChannelList.Items.Remove(toRemove);
            if (!remove)
            {
                ChannelList.Items.Add(channelUser);
            }
        }
예제 #7
0
        public bool IgnoreUser(UserData user)
        {
            return IgnoreList.Items.Contains(user.username.ToLower()) && user.rank < 1;

        }
예제 #8
0
 private void CreateUserList(UserData[] userlist)
 {
     if (InvokeRequired)
     {
         Invoke(new Action<UserData[]>(CreateUserList), (object)userlist);
     }
     else
     {
         foreach (UserData user in userlist)
         {
             if (m_userData.ContainsKey(user.username))
                 m_userData[user.username] = user;
             else
                 m_userData.Add(user.username, user);
         }
         UserList.Items.Clear();
     // ReSharper disable CoVariantArrayConversion
         if (m_userData != null)
             UserList.Items.AddRange(m_userData.Keys.ToArray());
     // ReSharper restore CoVariantArrayConversion
     }
 }
예제 #9
0
        private void AddUser(UserData userinfo)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<UserData>(AddUser), userinfo);
            }
            else
            {
                if (!m_userData.ContainsKey(userinfo.username))
                    m_userData.Add(userinfo.username, userinfo);
                else
                    m_userData[userinfo.username] = userinfo;

                if (userinfo.username == Program.UserInfo.username)
                {
                    Program.UserInfo = userinfo;
                    if (!string.IsNullOrEmpty(Program.UserInfo.team))
                    {
                        LoadTeamWindow();
                    }
                }

                if (!string.IsNullOrEmpty(userinfo.team) && userinfo.team == Program.UserInfo.team)
                {
                    if (!TeamList.Items.Contains(userinfo.username))
                        TeamList.Items.Add(userinfo.username);
                }
                else
                {
                    if (TeamList.Items.Contains(userinfo.username))
                        TeamList.Items.Remove(userinfo.username);
                }

                if (!Program.Config.HideJoinLeave)
                {
                    WriteMessage(FriendList.Items.Contains(userinfo.username)
                                     ? new ChatMessage(MessageType.Join, CommandType.None, null,
                                                       "Your friend " + userinfo.username + " has joined the channel.")
                                     : new ChatMessage(MessageType.Join, CommandType.None, null,
                                                       userinfo.username + " has joined the channel."));
                }
                else
                {
                    if (FriendList.Items.Contains(userinfo.username))
                        WriteMessage(new ChatMessage(MessageType.Join, CommandType.None, null, "Your friend " + userinfo.username + " has logged in."));
                }
                if (UserSearch.Text == "" || UserSearch.Text == "Search")
                {
                    if (!UserList.Items.Contains(userinfo.username))
                        UserList.Items.Add(userinfo.username);
                }
                else
                {
                    if (userinfo.username.ToLower().Contains(UserSearch.Text.ToLower()))
                    {
                        if (!UserList.Items.Contains(userinfo.username))
                            UserList.Items.Add(userinfo.username);
                    }
                }
            }
        }
예제 #10
0
 private void UpdateUserInfo(UserData user)
 {
     Program.UserInfo = user;
     Program.MainForm.UpdateUsername();
     if (!string.IsNullOrEmpty(Program.UserInfo.team))
     {
         LoadTeamWindow();
         Program.MainForm.SetTeamProfile(true);
     }
     else
         Program.MainForm.SetTeamProfile(false);
 }
예제 #11
0
 private void LoginResponse(DevClientPackets type, UserData data)
 {
     if (type == DevClientPackets.Banned)
     {
         MessageBox.Show("You are banned.");
     }
     else if (type == DevClientPackets.LoginFailed)
     {
         ResetTimeOut();
         MessageBox.Show("Incorrect Password or Username.");
     }
     else
     {
         Program.UserInfo = data;
         ResetTimeOut();
         Program.MainForm.Login();
     }
 }