Exemplo n.º 1
0
 public Tab(int scrollpos, List<Text> lines, string title, PTextBox box)
 {
     this.scrollpos = scrollpos;
     this.lines = lines;
     Title = title;
     tabRect = new Rect(new Rectangle(0, 0, 150, 25), Skin.skindict["tabBG"]);
     tabRect.Colour = Color.SteelBlue;
     tabText = new Text(Config.ClientSize, tabRect.Bounds.Size, Point.Empty);
     tabText.textFont = PTextBox.boxFont;
     tabText.Shadow = false;
     tabText.Update(title);
     pb = box;
 }
Exemplo n.º 2
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");
        }
Exemplo n.º 3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            heartbeatTime += e.Time;
            //n.OnUpdateFrame(e);
            nm.update(e);
            if (heartbeatTime > 30 && conn.Bw != null)
            {
                try
                {
                    Client.PacketWriter.sendClientHeartbeat(conn.Bw);
                    heartbeatTime = 0;
                }
                catch
                {
                }
            }
            if (!screenChange)
            {
                if (!active.loaded)
                {
                    active.OnLoad(null);
                    active.loaded   = true;
                    active.switched = true;
                }
                else if (!active.switched && active.loaded)
                {
                    active.onSwitched();
                    active.switched = true;
                }
            }
            if (displayUsers)
            {
                userScreen.OnUpdateFrame(e);
            }
            pbox.OnUpdateFrame(e);

            sleepCount++;
            if (sleepCount >= 10)
            {
                //need to work out a good way to use this to limit the cpu usage, or find another way to do it
                //skipFrame = true;
                sleepCount = 0;
            }
            if (verRemind)
            {
                System.Windows.Forms.MessageBox.Show("Client version (" + Config.Version + ") out of date! Latest (" + serverVer + ") available on the updater.");
                verRemind = false;
            }
            if (pressedKey.Contains(Key.F3) && userToggle)
            {
                userToggle   = false;
                displayUsers = !displayUsers;
                if (displayUsers)
                {
                    if (ircl != null)
                    {
                        string userss = "";
                        foreach (string i in ircl.pulseUsers)
                        {
                            userss += i.Split('|')[1] + ";";
                        }
                        //   Console.WriteLine(userss);
                        Client.PacketWriter.sendUserRequest(Game.conn.Bw, userss);
                    }
                }
            }
            else if (!pressedKey.Contains(Key.F3))
            {
                userToggle = true;
            }
            if (Keyboard[OpenTK.Input.Key.AltLeft] && Keyboard[OpenTK.Input.Key.F4])
            {
                this.Exit();
            }
            if (toasts.Count > 0 && activeToast == null)
            {
                activeToast = toasts.Dequeue();
                t.Update(activeToast.text);
            }
            if (activeToast != null)
            {
                if (activeToast.y < 0 && activeToast.DisplayTime > 0)
                {
                    activeToast.y      += 2;
                    toasttexture.Bounds = new Rectangle(0, activeToast.y, Config.ResWidth, 50);
                    t.Location          = new Point(50, activeToast.y);
                }
                if (activeToast.y == 0)
                {
                    activeToast.DisplayTime--;
                }
                if (activeToast.DisplayTime <= 0)
                {
                    activeToast.y      -= 2;
                    toasttexture.Bounds = new Rectangle(0, activeToast.y, Config.ResWidth, 50);
                    t.Location          = new Point(50, activeToast.y);
                }
                if (activeToast.y <= -50)
                {
                    activeToast         = null;
                    toasttexture.Bounds = new Rectangle(0, 0, Config.ResWidth, 50);
                    t.Location          = new Point(50, 0);
                }
            }
            base.OnUpdateFrame(e);
            time += e.Time;
            if (Config.DisplayFps)
            {
                if (time > 0.25)
                {
                    time = 0;
                    fpsText.Update("fps: " + frameCount * 4);
                    frameCount = 0;
                }
            }
            if (volumeLife > 0)
            {
                volumeLife -= (int)(e.Time * 1000);
                if (volumeTexture.Bounds.Y > 730)
                {
                    volumeTexture.Bounds = new Rectangle(volumeTexture.Bounds.X, volumeTexture.Bounds.Y - 5, volumeTexture.Bounds.Width, volumeTexture.Bounds.Height);
                    volumeRect.Bounds    = new Rectangle(volumeRect.Bounds.X, volumeRect.Bounds.Y - 5, volumeRect.Bounds.Width, volumeRect.Bounds.Height);
                }
            }
            if (volumeLife <= 0 && volumeTexture.Bounds.Y < 768)
            {
                volumeTexture.Bounds = new Rectangle(volumeTexture.Bounds.X, volumeTexture.Bounds.Y + 5, volumeTexture.Bounds.Width, volumeTexture.Bounds.Height);
                volumeRect.Bounds    = new Rectangle(volumeRect.Bounds.X, volumeRect.Bounds.Y + 5, volumeRect.Bounds.Width, volumeRect.Bounds.Height);
            }
            lock (ircLock)
            {
                if (ircl != null)
                {
                    while (ircl.recieved.Count > 0)
                    {
                        Client.irc.IrcMessage msg = ircl.recieved.Dequeue();
                        string now = DateTime.Now.Hour.ToString("D2") + ":" + DateTime.Now.Minute.ToString("D2") + " ";
                        if (msg.HLed)
                        {
                            if (!pbox.expanded)
                            {
                                addToast("You have received a highlight, press F2 to open chat");
                            }
                            pbox.addLine((msg.timestamp ? now : "") + msg.Msg, Color.Green, msg.Target);
                            if (Config.ChatSounds)
                            {
                                Skin.ChatSound.play(true);
                            }
                            if (pbox.tabs.ContainsKey(" " + msg.Target + " "))
                            {
                                pbox.tabs[msg.Target].Alert = true;
                            }
                            if (!pbox.tabs.ContainsKey("#highlight"))
                            {
                                pbox.addTab("#highlight");
                            }
                            pbox.addLine((msg.timestamp ? now : "") + "(" + msg.Target + ") " + msg.Msg, col, "#highlight");
                            pbox.tabs["#highlight"].Alert = true;
                        }
                        else
                        {
                            if (msg.Target.Equals(ircl.realNick) && !game.Focused && Config.ChatSounds)
                            {
                                if (!pbox.expanded)
                                {
                                    addToast("You have recieved a private message, press F2 to open chat");
                                }
                                Skin.ChatSound.play(true);
                            }
                            if (msg.customColor)
                            {
                                pbox.addLine((msg.timestamp ? now : "") + msg.Msg, msg.col, msg.Target);
                            }
                            else
                            {
                                string toadd = (msg.timestamp ? now : "") + msg.Msg;
                                if (!string.IsNullOrEmpty(msg.sender))
                                {
                                    Dictionary <Pair <int, int>, Color> colors = new Dictionary <Pair <int, int>, Color>();
                                    int index = toadd.IndexOf(msg.sender);
                                    colors.Add(new Pair <int, int>(0, index), col);
                                    colors.Add(new Pair <int, int>(index, index + msg.sender.Length), msg.sendercolor);
                                    colors.Add(new Pair <int, int>(index + msg.sender.Length, toadd.Length), col);
                                    pbox.addLine(toadd, colors, msg.Target);
                                }
                                else
                                {
                                    /* if (msg.Msg.Length > 115)
                                     * {
                                     *   Dictionary<Pair<int, int>, Color> colors = new Dictionary<Pair<int, int>, Color>();
                                     *   colors.Add(new Pair<int, int>(0, 100), Color.White);
                                     *   colors.Add(new Pair<int, int>(100, 110), Color.Blue);
                                     *   colors.Add(new Pair<int, int>(110, msg.Msg.Length), Color.White);
                                     *   pbox.addLine(toadd, colors, msg.Target);
                                     * }
                                     * else
                                     * {*/
                                    pbox.addLine(toadd, col, msg.Target);
                                    //}
                                }
                            }

                            if (pbox.activeTab.Title != msg.Target && pbox.tabs.ContainsKey(msg.Target))
                            {
                                pbox.tabs[msg.Target].Alert = true;
                            }
                        }
                    }
                }
            }
            if (!Config.DisableMousewheel)
            {
                float nowMouse = Mouse.WheelPrecise;
                float delta    = nowMouse - previousMouse;
                if (delta != 0)
                {
                    previousMouse = nowMouse;
                    if (Active != screens["selectScreen"] && active != screens["editScreen"] && !pbox.expanded)
                    {
                        delta *= 15;
                        int result = volumeRect.Bounds.Width + (int)delta;
                        if (result < 0)
                        {
                            result = 0;
                        }
                        else if (result > 370)
                        {
                            result = 370;
                        }
                        volumeRect.Bounds = new Rectangle(volumeRect.Bounds.X, volumeRect.Bounds.Y, result, volumeRect.Bounds.Height);
                        int percent = (int)((result / 370d) * 100);
                        Config.Volume = percent;
                        volumeLife    = 1000;
                    }
                }
            }


            if (active != null && active.Enabled)
            {
                active.OnUpdateFrame(e);
            }
            if (screenChange && !transIn)
            {
                screenChange = false;
                active.Hide();
                if (active.Music != null && !(tempScreen is MenuScreen))
                {
                    active.Music.stop();
                }
                Active     = tempScreen;
                tempScreen = null;
                active.Show();
            }
            if (transitioning)
            {
                if (transIn)
                {
                    blackOverlay.Alpha += 0.1f;
                    if (blackOverlay.Alpha >= 1f)
                    {
                        transIn = false;
                    }
                }
                else
                {
                    blackOverlay.Alpha -= 0.1f;
                    if (blackOverlay.Alpha <= 0f)
                    {
                        transitioning = false;
                        transIn       = true;
                    }
                }
            }
            if (m.Enabled)
            {
                m.onUpdateFrame(e);
            }
            lClickFrame = false;
        }
Exemplo n.º 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");
        }