示例#1
0
        public void setSong(ref SongInfo s)
        {
            currentSong  = SongLibrary.loadSong(s);
            music        = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName);
            music.Volume = Config.Volume / 100.0f;
            updateText   = true;
            if (currentSong.FileVersion > 0)
            {
                if (currentSong.ID == -1)
                {
                    NameValueCollection nvc = new NameValueCollection();
                    nvc.Add("c", Utils.calcHash(currentSong.Charts[0].Path));
                    int id = Convert.ToInt32(Utils.HttpUploadFile("http://p.ulse.net/idchart", nvc));
                    if (id == -1)
                    {
                        id = -2;
                    }
                    currentSong.ID = id;

                    SongLibrary.Songs[SongLibrary.Songs.IndexOf(s)].ID = id;
                    SongLibrary.songInfos[currentSong.Dir].ID          = id;
                }
            }
            else
            {
                Console.WriteLine("Cannot get song id, pncv0");
            }
        }
示例#2
0
 protected override void OnUnload(EventArgs e)
 {
     base.OnUnload(e);
     Config.saveConfig();
     SongLibrary.saveSongInfo();
     if (consoleAlloc)
     {
         FreeConsole();
     }
     OpenTK.DisplayDevice.Default.ChangeResolution(Config.oldRes.Width, Config.oldRes.Height, OpenTK.DisplayDevice.Default.BitsPerPixel, OpenTK.DisplayDevice.Default.RefreshRate);
 }
示例#3
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;
            }
        }
示例#4
0
        protected override void OnLoad(EventArgs e)
        {
            lua = new Lua();

            lua.DoString("luanet=nil");
            Skin.luaInit();

            /*  Type ty = typeof(Config);
             * foreach (MethodInfo mi in ty.GetMethods())
             * {
             *   lua.RegisterFunction(mi.Name,this , mi);
             *   Console.WriteLine(mi.Name);
             * }*/
            conn             = new Client.Connection();
            conn.recvPacket += new Action <short, Client.RecievePacket>(conn_recvPacket);
            Pulse.Client.PacketWriter.sendCheckVersion(conn.Bw);
            this.Closing += new EventHandler <System.ComponentModel.CancelEventArgs>(Game_Closing);
            base.OnLoad(e);
            AudioManager.initBass();
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            if (Skin.MaskBursts)
            {
                Animation preloadBursts = new Animation(new Rectangle(1, 1, 1, 1), 1, "burst", 10, false, true);
            }
            blackOverlay.Colour = new Color4(0.0f, 0.0f, 0.0f, 0.2f);
            toasts        = new Queue <toast>();
            toasttexture  = new Rect(new Rectangle(0, 0, Config.ResWidth, 50), Skin.skindict["toast"]);
            volumeTexture = new Rect(new Rectangle((int)(Config.ResWidth * 0.26), 727, (int)(Config.ResWidth * 0.5), 43), Skin.skindict["volumecontrol"]);
            int toSet = (int)((Config.Volume / 100d) * (Config.ResWidth * 0.5));

            volumeRect        = new Rect(new Rectangle((int)(Config.ResWidth * 0.37), 739, toSet, 25));
            volumeRect.Colour = Color4.Orange;
            t         = new Text(new Size(Width, Height), new Size(Config.ResWidth, 50), new Point(50, 0));
            this.Icon = DefaultSkin.pulseicon;

            SongLibrary.loadSongInfo();
            SongLibrary.cacheSongInfo(); //for newly added songs while game wasn't onint diff = 0;
            m = new MediaPlayer(this);
            screens.Add("menuScreen", new MenuScreen(this, "Pulse Menu"));
            screens.Add("selectScreen", new SelectScreen(this, "Song Select"));
            screens.Add("sSScreen", new ScoreSelectScreen(this, "Score Select Screen"));
            screens.Add("editScreen", new EditorScreen(this, "Edit Mode"));
            screens.Add("timingScreen", new TimingScreen(this, "Timing Screen"));
            screens.Add("ingameScreen", new IngameScreen(this, "ingame"));
            screens["ingameScreen"].Hide();
            screens["timingScreen"].Hide();
            screens["editScreen"].Hide();
            screens["selectScreen"].Hide();
            screens["sSScreen"].Hide();
            screens["menuScreen"].Show();
            Active = screens["menuScreen"];

            GL.ClearColor(Color4.SlateGray);

            fpsText = new Text(new Size(Width, Height), new Size(150, 35), new Point(Config.ResWidth - 120, 733));
            fpsText.Update("fps: " + this.TargetRenderFrequency);
            fpsText.Colour = Color.Yellow;
            fpsText.Shadow = true;
            int tipIndex = new Random().Next(Tips.tips.Length);

            addToast(Tips.tips[tipIndex]);
            if (!Directory.Exists("skin"))
            {
                Directory.CreateDirectory("skin");
            }
            fsw = new FileSystemWatcher("skin");
            fsw.EnableRaisingEvents = true;
            fsw.Created            += new FileSystemEventHandler(fsw_Created);
            pbox = new PTextBox(game, new Rectangle(0, 768 - 300, Utils.getMX(1024), 290), "", ircl);
            pbox.minimize(0);
            // Thread check = new Thread(new ThreadStart(game.checkVersions));
            //   check.IsBackground = true;
            //   check.Start();
            Account.tryLoadAcc();
            int x = 5;

            SongLibrary.findByMD5("  ", ref x);
            userScreen = new UserDisplayScreen(this);
            //  n = new Notice(new Point(0, 200), 5000, "ASHASHASHASHASHASHASHASHASHASHASHASHASHASHASHASDFK;J");
        }