Exemplo n.º 1
0
 public UserList(Game game, Rectangle bounds, string text)
     : base(game, bounds, text)
 {
     bg = new Rect(bounds);
     bg.Colour = new OpenTK.Graphics.Color4(0, 0, 0, .5f);
     message = text;
     txt = new Text(Config.ClientSize, new Size((int)Pulse.Text.getStringSize(text, Pulse.Text.defaultFont).Width + bounds.Size.Width, bounds.Size.Height), new Point(bounds.X + bounds.Width, bounds.Y));
     txt.Line = message;
     txt.Shadow = false;
 }
Exemplo n.º 2
0
        List<Tab> toRemove = new List<Tab>(); //for closed tabs, a queue for them to be on until they finish transitioning

        #endregion Fields

        #region Constructors

        public PTextBox(Game game, Rectangle bounds, string text, IrcClient client)
            : base(game, bounds, text)
        {
            OnLoad(null);
            bg = new Rect(new Rectangle(bounds.Location, new Size(bounds.Size.Width, bounds.Size.Height + 10)));
            bg.Colour = Color.FromArgb(200, 20, 20, 20);
            origpos = bg.Bounds.Y;
            Tab pulse = new Tab(0, new List<Text>(), baseChannel, this);
            pulse.Scrollpos = -bounds.Height + spacing;
            activeTab = pulse;
            addTab(pulse);
            ic = client;
            chatLine = new Text(game.ClientSize, new Size(game.Bounds.Width, 50), new Point(bounds.X + 5, this.bounds.Y + this.bounds.Height - spacing));
            chatLine.textFont = boxFont;
            chatLine.Shadow = false;
            caret = new Rect(new Rectangle(0, 0, 2, 15));
            caret.Colour = Color.White;
            selectBox = new Rect(new Rectangle(bounds.X + 5, chatLine.Location.Y + 3, 20, 19));
            selectBox.Colour = Color.FromArgb(100, Color.LightGray);
            //activeTab.Scrollpos =
            addLine("Welcome to pulse chat! Press F2 to maximize/minimize chat.", Color.SteelBlue);
            Game.lua.RegisterFunction("show", this, this.GetType().GetMethod("show", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance));
            //   Game.lua["pbox"] = this;
            updateCaret();
            //try /lua pbox.bg.Bounds = test(0,300,1024,500)
            //Game.lua["cm"] = System.Drawing.Rectangle
            //  game.Keyboard.KeyRepeat = false;
            /*    foreach (string s in Game.lua.Globals)
                {
                    Console.WriteLine(s);
                }*/
        }
Exemplo n.º 3
0
        // Returns a System.Drawing.Bitmap with the contents of the current framebuffer
        //this can be used for vids O:
        public static Bitmap GrabScreenshot(Game game)
        {
            if (GraphicsContext.CurrentContext == null)
                throw new GraphicsContextMissingException();

            Bitmap bmp = new Bitmap(game.ClientSize.Width, game.ClientSize.Height);
            System.Drawing.Imaging.BitmapData data =
                bmp.LockBits(game.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            GL.ReadPixels(0, 0, game.ClientSize.Width, game.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0);
            bmp.UnlockBits(data);

            bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); //removing would increase performance significantly
            return bmp;
        }
Exemplo n.º 4
0
        public MediaPlayer(Game game)
        {
            this.game = game;
            stop = new Button(game, new Rectangle(155, 5, 45, 45), "", delegate(int data)
            {
                stopped = true;
                pause.Texture.useTexture(Skin.skindict["mediaPY"]);
                music.pause();
            }, Skin.skindict["mediaSP"]);
            stop.manualColour = true;
            forward = new Button(game, new Rectangle(new Point(105, 5), new Size(45, 45)), "", delegate(int data)
            {
                if (!music.Finished)
                {
                    music.stop();
                }
                pause.Texture.useTexture(Skin.skindict["mediaPS"]);
            }, Skin.skindict["mediaFF"]);
            forward.manualColour = true;
            pause = new Button(game, new Rectangle(new Point(55, 5), new Size(45, 45)), "", delegate(int data)
            {
                if (!music.Paused)
                {
                    music.pause();
                    pause.Texture.useTexture(Skin.skindict["mediaPY"]);
                }
                else
                {
                    if (stopped)
                    {
                        music.play(true);
                    }
                    else
                    {
                        music.play(false);
                    }
                    stopped = false;
                    pause.Texture.useTexture(Skin.skindict["mediaPS"]);
                }
            }, Skin.skindict["mediaPS"]);
            pause.manualColour = true;
            backward = new Button(game, new Rectangle(new Point(5, 5), new Size(45, 45)), "", delegate(int data)
            {

                pause.Texture.useTexture(Skin.skindict["mediaPS"]);
                if (previousSongs.Count > 1)
                {
                    music.stop();
                    if (currentID - 1 == -1)
                    {
                        currentID = 0;
                    }
                    else
                    {
                        currentID--;
                    }
                    setSong(previousSongs[currentID]);
                    play();
                }
                else
                {
                    music.PositionAsMilli = 0;
                    currentID = 0;
                }
            }, Skin.skindict["mediaFB"]);
            backward.manualColour = true;
            title = new Label(game, new Point(0, 50), "");
            Random r = new Random();
            if (SongLibrary.Songs.Count > 0)
            {
                int id;
                id = r.Next(0, SongLibrary.Songs.Count);
                setSong(id);
                play();
                previousSongs.Add(id);
                currentID = 0;
            }
            position = new Dragbar(game, new Point(10, 85), 230, false, delegate(int d)
                {
                    music.PositionAsMilli = (long)((music.Length / 100) * position.getPercentScrolled());
                });
        }
Exemplo n.º 5
0
        [STAThread] //for drag and drop :|
        static void Main(string[] args)
        {
#if DEBUG
            //   IntPtr stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
            //    SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
            //   FileStream fs = new FileStream(stdHandle, FileAccess.Write);
            //   StreamWriter sw = new StreamWriter(fs);
            //   Console.SetOut(sw);           
            //AttachConsole(ATTACH_PARENT_PROCESS);
            consoleAlloc = AllocConsole(); //allocate anyway if DEBUG defined
            Console.Title = "Pulse|Debug";
            Console.WriteLine("Running in Debug mode! All console output will be shown");
#endif

            if (args.Length > 0)
            {
                if (args[0].Equals("/debug") && !consoleAlloc)
                {
                    consoleAlloc = AllocConsole();
                    Console.Title = "Pulse|Debug";
                    Console.WriteLine("Running in Debug mode! All console output will be shown");
                }
                else
                {
                    try
                    {
                        string location = new DirectoryInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Parent.FullName;
                        Console.WriteLine(location);
                        Console.ReadKey();
                        string songFolder = location + "\\songs";
                        ZipFile zf = new ZipFile(args[0]);
                        if (!Directory.Exists(songFolder))
                        {
                            Directory.CreateDirectory(songFolder);
                        }

                        foreach (ZipEntry ze in zf)
                        {
                            ze.Extract(songFolder, ExtractExistingFileAction.OverwriteSilently);
                        }
                    }
                    catch (Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show("Error extracting " + e);
                    }
                    Environment.Exit(0);
                }
            }
            if (!Directory.Exists("replay"))
            {
                Directory.CreateDirectory("replay");
            }
            Config.load();
            //  SongLibrary.loadSongInfo();
            using (Game game = new Game())
            {
#if SENDFATAL

                try
                {
                    game.Run(120.0, Config.Fps);
                }
                catch (Exception e)
                {
                    if (game != null && game.active != null)
                    {
                        if (game.active is EditorScreen)
                        {
                            EditorScreen temp = (EditorScreen)game.active;
                            try
                            {
                                temp.saveMap();
                            }
                            catch
                            {

                            }
                        }
                    }
                    ErrorLog.log("User : "******"n/a") + " Fatal error: " + e.Message + "\n" + e.StackTrace);
                    System.Windows.Forms.MessageBox.Show("A fatal exception: \"" + e.Message + "\" has occured and been reported to the dev team");
                }
#endif

#if !SENDFATAL
                game.Run(120.0, Config.Fps); //want to show where exceptions are
#endif
            }
        }
Exemplo n.º 6
0
 public Game()
     : base(Config.ClientWidth, Config.ClientHeight, GraphicsMode.Default, "g")
 {
     game = this;
     this.Title = "Pulse";
     this.Mouse.ButtonDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonDown);
     this.Mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonUp);
     this.Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
     this.Keyboard.KeyUp += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
     if (Config.Vsync)
     {
         this.VSync = VSyncMode.On;
     }
     else
         this.VSync = VSyncMode.Off;
     if (Config.Fullscreen)
     {
         this.WindowState = WindowState.Fullscreen;
     }
     else
         this.WindowState = WindowState.Normal;
 }