コード例 #1
0
ファイル: Screen.cs プロジェクト: Scrama/Quarp
        /// <summary>
        /// SCR_ModalMessage
        /// Displays a text string in the center of the screen and waits for a Y or N keypress.
        /// </summary>
        public static bool ModalMessage(string text)
        {
            if (Client.cls.state == cactive_t.ca_dedicated)
            {
                return(true);
            }

            _NotifyString = text;

            // draw a fresh screen
            Scr.FullUpdate = 0;
            _DrawDialog    = true;
            UpdateScreen();
            _DrawDialog = false;

            Sound.ClearBuffer();                // so dma doesn't loop current sound

            do
            {
                Key.KeyCount = -1;              // wait for a key down and up
                Sys.SendKeyEvents();
            } while (Key.LastPress != 'y' && Key.LastPress != 'n' && Key.LastPress != Key.K_ESCAPE);

            Scr.FullUpdate = 0;
            UpdateScreen();

            return(Key.LastPress == 'y');
        }
コード例 #2
0
        // _Host_Frame
        //
        //Runs all active servers
        static void InternalFrame(double time)
        {
            // keep the random time dependent
            Sys.Random();

            // decide the simulation time
            if (!FilterTime(time))
            {
                return;                 // don't run too fast, or packets will flood out
            }
            // get new key events
            Sys.SendKeyEvents();

            // allow mice or other external controllers to add commands
            Input.Commands();

            // process console commands
            Cbuf.Execute();

            Net.Poll();

            // if running the server locally, make intentions now
            if (Server.sv.active)
            {
                Client.SendCmd();
            }

            //-------------------
            //
            // server operations
            //
            //-------------------

            // check for commands typed to the host
            GetConsoleCommands();

            if (Server.sv.active)
            {
                ServerFrame();
            }

            //-------------------
            //
            // client operations
            //
            //-------------------

            // if running the server remotely, send intentions now after
            // the incoming messages have been read
            if (!Server.sv.active)
            {
                Client.SendCmd();
            }

            _Time += FrameTime;

            // fetch results from server
            if (Client.cls.state == cactive_t.ca_connected)
            {
                Client.ReadFromServer();
            }

            // update video
            if (_Speeds.Value != 0)
            {
                _Time1 = Sys.GetFloatTime();
            }

            Scr.UpdateScreen();

            if (_Speeds.Value != 0)
            {
                _Time2 = Sys.GetFloatTime();
            }

            // update audio
            if (Client.cls.signon == Client.SIGNONS)
            {
                Sound.Update(ref Render.Origin, ref Render.ViewPn, ref Render.ViewRight, ref Render.ViewUp);
                Client.DecayLights();
            }
            else
            {
                Sound.Update(ref Common.ZeroVector, ref Common.ZeroVector, ref Common.ZeroVector, ref Common.ZeroVector);
            }

            CDAudio.Update();

            if (_Speeds.Value != 0)
            {
                int pass1 = (int)((_Time1 - _Time3) * 1000);
                _Time3 = Sys.GetFloatTime();
                int pass2 = (int)((_Time2 - _Time1) * 1000);
                int pass3 = (int)((_Time3 - _Time2) * 1000);
                Con.Print("{0,3} tot {1,3} server {2,3} gfx {3,3} snd\n", pass1 + pass2 + pass3, pass1, pass2, pass3);
            }

            _FrameCount++;
        }