Beispiel #1
0
 public UserDisplay(User u, Point location)
 {
     this.u = u;
     back.Bounds = new Rectangle(location, new Size(back.Bounds.Width, back.Bounds.Height));
     front.Bounds = new Rectangle(location.X + 2, location.Y + 2, front.Bounds.Width, front.Bounds.Height);
     back.Colour = new Color4(0.6f, 0.6f, 0.6f, 0.9f);
     front.Colour = new Color4(0.6f, 0.6f, 0.6f, 0.8f);
     Thread t = new Thread(new ParameterizedThreadStart(downloadThread));
     wc = new WebClient();
     t.IsBackground = true;
     t.Start(u.Avatar);
     name = new Text(new Size(118, 200), new Point(location.X + 90, location.Y + 2));
     name.Shadow = false;
     name.Update(u.RealName);
     playCount = new Text(new Size(300, 300), new Point(location.X + 90, location.Y + 35));
     playCount.Shadow = false;
     playCount.textFont = new Font("Myriad Pro", 14);
     playCount.Line = ("PC: " + u.Playcount + "\nScore: " + u.TotalScore + "\nLevel: " + u.Level);
     b = new Button(Game.game, new Rectangle(playCount.Location, new Size(100, 30)), "PM", delegate(int e)
     {
         Game.pbox.addTab("pulse|" + u.RealName);
     });
     b2 = new Button(Game.game, new Rectangle(playCount.Location, new Size(100, 30)), "Spec", delegate(int e)
     {
         if (!Config.Spectating)
         {
             if (!u.Name.ToLower().Equals(Account.currentAccount.AccountName.ToLower()))
             {
                 Client.PacketWriter.sendSpectateHook(Game.conn.Bw, u.Name);
                 Game.pbox.addLine("Spectating " + u.Name + " (if they are online)");
             }
             else
             {
                 Game.pbox.addLine("You can't spectate yourself");
             }
         }
         else
         {
             if (!Config.SpectatedUser.Equals(""))
             {
                 Game.pbox.addLine("Canceling spectate on " + Config.SpectatedUser);
             }
             Client.PacketWriter.sendSpectateCancel(Game.conn.Bw, Config.SpectatedUser);
             Config.SpectatedUser = "";
             Config.Spectating = false;
         }
     });
     if (u.avatarRect != null)
     {
         avatar = u.avatarRect;
     }
 }
Beispiel #2
0
        public RecievePacket handleData(System.IO.BinaryReader br, System.IO.BinaryWriter bw, System.Net.Sockets.TcpClient client)
        {
            //online bool, name,realname,,avatar,playcount,totalscore,mode,currentsong,currentchart, accuracy, level
            bool online = br.ReadBoolean();
            if (online)
            {
                //Console.WriteLine("name:" + br.ReadString());
                //Console.WriteLine("pc:" + br.ReadInt32());
                string user = br.ReadString();
                string rn = br.ReadString();
                string avatar = br.ReadString();
                int pc = br.ReadInt32();
                int totalscore = br.ReadInt32();
                PlayMode pm = (PlayMode)br.ReadInt32();
                string cs = br.ReadString();
                string cc = br.ReadString();
                float acc = br.ReadSingle();//float
                int lvl = br.ReadInt32();
                lock (User.users)
                {
                    if (User.users.ContainsKey(user))
                    {
                        User.users[user].Name = user;
                        User.users[user].RealName = rn;
                        User.users[user].Avatar = avatar;
                        User.users[user].Playcount = pc;
                        User.users[user].TotalScore = totalscore;
                        User.users[user].Mode = pm;
                        User.users[user].CurrentSong = cs;
                        User.users[user].CurrentChart = cs;
                        User.users[user].Accuracy = acc;
                        User.users[user].Level = lvl;
                        User.users[user].UpdateGraphics = true;
                    }
                    else
                    {
                        User u = new User()
                        {
                            Name = user,
                            RealName = rn,
                            Avatar = avatar,
                            Playcount = pc,
                            TotalScore = totalscore,
                            Mode = pm,
                            CurrentSong = cs,
                            CurrentChart = cc,
                            Accuracy = acc,
                            Level = lvl
                        };

                        User.users.Add(user, u);
                        u.UpdateGraphics = true;
                    }
                    Console.WriteLine("added/modified {0} score is {1}", user, totalscore);
                }
            }
            else
            {
                string removeuser = br.ReadString();
                lock (User.users)
                {
                    if (User.users.ContainsKey(removeuser))
                    {
                        Console.WriteLine("removed {0}", removeuser);
                        Console.WriteLine(User.users.Remove(removeuser) + " at removing " + removeuser);
                    }
                    else
                    {
                        Console.WriteLine("no key userhandler.cs");
                    }
                }
            }
            return null;
        }