예제 #1
0
        void conn_recvPacket(short arg1, Client.RecievePacket arg2)
        {
            switch (arg1)
            {
            case (short)Pulse.Client.RecvHeaders.VERSION_CHECK:
                double serverversion = (double)arg2.info[0];
                if (serverversion > Config.Version)
                {
                    serverVer = serverversion;
                    verRemind = true;
                }
                else
                {
                    Console.WriteLine("running latest ver of pulse");
                }
                break;

            case (short)Pulse.Client.RecvHeaders.LOGIN_AUTH:
                byte login = (byte)arg2.info[0];
                if (login == 0)     //successful
                {
                    Account.currentAccount = new Account((string)arg2.info[2], (string)arg2.info[1], (string)arg2.info[3]);
                    //going to assume i can't set text from here because of gl context crap
                    //Game.game.Context.Ma
                    ((MenuScreen)screens["menuScreen"]).downloadAvatar();
                    lock (ircLock)
                    {
                        if (Game.ircl != null)
                        {
                            Game.ircl.terminate();
                            Game.ircl = null;
                        }
                        setMarquee         = true;
                        Game.ircl          = new Client.irc.IrcClient("pulse|" + Account.currentAccount.AccountName, Account.currentAccount.AccountName);
                        Game.ircl.realNick = Account.currentAccount.AccountName;
                        Game.pbox.setIrc(Game.ircl);
                    }
                }
                else
                {
                    Game.addToast("Login failed");
                }
                break;

            case (short)Pulse.Client.RecvHeaders.SPECTATE_RECORD:
                Config.Spectated = true;
                break;

            case (short)Pulse.Client.RecvHeaders.SPECTATE_END:
                Config.Spectated = false;
                break;

            case (short)Pulse.Client.RecvHeaders.SPECTATE_START:
                Config.SpectatedUser = (string)arg2.info[0];
                Config.Spectating    = true;
                int      diff = 0;
                SongInfo song = SongLibrary.findByMD5((string)arg2.info[1], ref diff);
                if (song != null)
                {
                    stopMedia = true;
                    IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                    try
                    {
                        if (active.Music != null)
                        {
                            active.Music.pause();
                        }
                        Mods m = new Mods()
                        {
                            Flags  = (uint)((int)arg2.info[2]),
                            Scroll = (double)arg2.info[3]
                        };
                        temp.loadSong(SongLibrary.loadSong(song), diff, m, new Replay(), IngameScreen.PlayType.SPECTATE);
                        Game.setScreen(game.screens["ingameScreen"]);
                        Game.M.Music.pause();
                        Game.M.setSong(ref song);
                        Game.M.Visible = false;
                        Game.M.Enabled = false;
                        Client.PacketWriter.sendSpectateGotChart(Game.conn.Bw);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message + e.StackTrace);
                    }
                }
                break;

            case (short)Pulse.Client.RecvHeaders.SPECTATE_CANCEL:
                if (active is IngameScreen)
                {
                    if (active.Music != null)
                    {
                        active.Music.stop();
                    }
                    Config.Spectating    = false;
                    Config.SpectatedUser = "";
                    Config.Specs         = "";
                    Game.setScreen(game.screens["menuScreen"]);
                }
                break;

            case (short)Pulse.Client.RecvHeaders.SPECTATE_USERS:
                Config.Specs = (string)arg2.info[0];
                Console.WriteLine(arg2.info[0]);
                break;

            case (short)Pulse.Client.RecvHeaders.SPECTATE_USERS_ME:
                Config.SpecsOnMe = (string)arg2.info[0];
                Console.WriteLine(arg2.info[0]);
                break;
            }
        }
예제 #2
0
파일: Game.cs 프로젝트: Zhangerr/pulse
        void conn_recvPacket(short arg1, Client.RecievePacket arg2)
        {
            
            switch (arg1)
            {
                case (short)Pulse.Client.RecvHeaders.VERSION_CHECK:
                    double serverversion = (double)arg2.info[0];
                    if (serverversion > Config.Version)
                    {
                        serverVer = serverversion;
                        verRemind = true;
                    }
                    else
                    {
                        Console.WriteLine("running latest ver of pulse");
                    }
                    break;
                case (short)Pulse.Client.RecvHeaders.LOGIN_AUTH:
                    byte login = (byte)arg2.info[0];
                    if (login == 0) //successful
                    {
                        Account.currentAccount = new Account((string)arg2.info[2], (string)arg2.info[1], (string)arg2.info[3]);
                        //going to assume i can't set text from here because of gl context crap
                        //Game.game.Context.Ma
                        ((MenuScreen)screens["menuScreen"]).downloadAvatar();
                        lock (ircLock)
                        {
                            if (Game.ircl != null)
                            {
                                Game.ircl.terminate();
                                Game.ircl = null;
                            }
                            setMarquee = true;
                            Game.ircl = new Client.irc.IrcClient("pulse|" + Account.currentAccount.AccountName, Account.currentAccount.AccountName);
                            Game.ircl.realNick = Account.currentAccount.AccountName;
                            Game.pbox.setIrc(Game.ircl);
                        }
                    }
                    else
                    {
                        Game.addToast("Login failed");
                    }
                    break;
                case (short)Pulse.Client.RecvHeaders.SPECTATE_RECORD:
                    Config.Spectated = true;
                    break;
                case (short)Pulse.Client.RecvHeaders.SPECTATE_END:
                    Config.Spectated = false;
                    break;
                case (short)Pulse.Client.RecvHeaders.SPECTATE_START:
                    Config.SpectatedUser = (string)arg2.info[0];
                    Config.Spectating = true;
                    int diff = 0;
                    SongInfo song = SongLibrary.findByMD5((string)arg2.info[1], ref diff);
                    if (song != null)
                    {                        
                        stopMedia = true;
                        IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                        try
                        {
                            if (active.Music != null)
                            {
                                active.Music.pause();
                            }
                            Mods m = new Mods()
                            {
                                Flags = (uint)((int)arg2.info[2]),
                                Scroll = (double)arg2.info[3]
                            };
                            temp.loadSong(SongLibrary.loadSong(song), diff, m, new Replay(), IngameScreen.PlayType.SPECTATE);
                            Game.setScreen(game.screens["ingameScreen"]);
                            Game.M.Music.pause();
                            Game.M.setSong(ref song);
                            Game.M.Visible = false;
                            Game.M.Enabled = false;
                            Client.PacketWriter.sendSpectateGotChart(Game.conn.Bw);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message + e.StackTrace);
                        }
                    }
                    break;
                case (short)Pulse.Client.RecvHeaders.SPECTATE_CANCEL:
                    if (active is IngameScreen)
                    {
                        if (active.Music != null)
                        {
                            active.Music.stop();
                        }
                        Config.Spectating = false;
                        Config.SpectatedUser = "";
                        Config.Specs = "";
                        Game.setScreen(game.screens["menuScreen"]);
                    }
                    break;
                case (short)Pulse.Client.RecvHeaders.SPECTATE_USERS:
                    Config.Specs = (string)arg2.info[0];
                    Console.WriteLine(arg2.info[0]);
                    break;
                case (short)Pulse.Client.RecvHeaders.SPECTATE_USERS_ME:
                    Config.SpecsOnMe = (string)arg2.info[0];
                    Console.WriteLine(arg2.info[0]);
                    break;

            }
        }