Beispiel #1
0
        // VID_SetMode (int modenum, unsigned char *palette)
        // sets the mode; only used by the Quake engine for resetting to mode 0 (the
        // base mode) on memory allocation failures
        public static void SetMode(int modenum, byte[] palette)
        {
            if (modenum < 0 || modenum >= _Modes.Length)
            {
                Sys.Error("Bad video mode\n");
            }

            mode_t mode = _Modes[modenum];

            // so Con_Printfs don't mess us up by forcing vid and snd updates
            bool temp = Scr.IsDisabledForLoading;

            Scr.IsDisabledForLoading = true;

            CDAudio.Pause();

            // Set either the fullscreen or windowed mode
            DisplayDevice dev  = MainForm.DisplayDevice;
            MainForm      form = MainForm.Instance;

            if (_Windowed)
            {
                form.WindowState  = WindowState.Normal;
                form.WindowBorder = WindowBorder.Fixed;
                form.Location     = new Point((mode.width - form.Width) / 2, (mode.height - form.Height) / 2);
                if (_WindowedMouse.Value != 0 && Key.Destination == keydest_t.key_game)
                {
                    Input.ActivateMouse();
                    Input.HideMouse();
                }
                else
                {
                    Input.DeactivateMouse();
                    Input.ShowMouse();
                }
            }
            else
            {
                try
                {
                    dev.ChangeResolution(mode.width, mode.height, mode.bpp, mode.refreshRate);
                }
                catch (Exception ex)
                {
                    Sys.Error("Couldn't set video mode: " + ex.Message);
                }
                form.WindowState  = WindowState.Fullscreen;
                form.WindowBorder = WindowBorder.Hidden;
            }

            viddef_t vid = Scr.vid;

            if (vid.conheight > dev.Height)
            {
                vid.conheight = dev.Height;
            }
            if (vid.conwidth > dev.Width)
            {
                vid.conwidth = dev.Width;
            }

            vid.width  = vid.conwidth;
            vid.height = vid.conheight;

            vid.numpages = 2;

            CDAudio.Resume();
            Scr.IsDisabledForLoading = temp;

            _ModeNum = modenum;
            Cvar.Set("vid_mode", (float)_ModeNum);

            // fix the leftover Alt from any Alt-Tab or the like that switched us away
            ClearAllStates();

            Con.SafePrint("Video mode {0} initialized.\n", GetModeDescription(_ModeNum));

            SetPalette(palette);

            vid.recalc_refdef = true;
        }
Beispiel #2
0
        /// <summary>
        /// V_RenderView
        /// The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
        /// the entity origin, so any view position inside that will be valid
        /// </summary>
        public static void RenderView()
        {
            if (Con.ForcedUp)
            {
                return;
            }

            // don't allow cheats in multiplayer
            if (client.cl.maxclients > 1)
            {
                cvar.Set("scr_ofsx", "0");
                cvar.Set("scr_ofsy", "0");
                cvar.Set("scr_ofsz", "0");
            }

            if (client.cl.intermission > 0)
            {
                // intermission / finale rendering
                CalcIntermissionRefDef();
            }
            else if (!client.cl.paused)
            {
                CalcRefDef();
            }

            render.PushDlights();

            if (_LcdX.Value != 0)
            {
                //
                // render two interleaved views
                //
                viddef_t vid  = Scr.vid;
                refdef_t rdef = render.RefDef;

                vid.rowbytes <<= 1;
                vid.aspect    *= 0.5f;

                rdef.viewangles.Y -= _LcdYaw.Value;
                rdef.vieworg      -= _Right * _LcdX.Value;

                render.RenderView();

                // ???????? vid.buffer += vid.rowbytes>>1;

                render.PushDlights();

                rdef.viewangles.Y += _LcdYaw.Value * 2;
                rdef.vieworg      += _Right * _LcdX.Value * 2;

                render.RenderView();

                // ????????? vid.buffer -= vid.rowbytes>>1;

                rdef.vrect.height <<= 1;

                vid.rowbytes >>= 1;
                vid.aspect    *= 2;
            }
            else
            {
                render.RenderView();
            }
        }
Beispiel #3
0
        // Sbar_Draw
        // called every frame by screen
        public static void Draw()
        {
            viddef_t vid = Scr.vid;

            if (Scr.ConCurrent == vid.height)
            {
                return;     // console is full screen
            }

            if (_Updates >= vid.numpages)
            {
                return;
            }

            Scr.CopyEverithing = true;

            _Updates++;

            if (Sbar.Lines > 0 && vid.width > 320)
            {
                Drawer.TileClear(0, vid.height - Sbar.Lines, vid.width, Sbar.Lines);
            }

            if (Sbar.Lines > 24)
            {
                DrawInventory();
                if (Client.Cl.maxclients != 1)
                {
                    DrawFrags();
                }
            }

            ClientState cl = Client.Cl;

            if (_ShowScores || cl.stats[QStats.STAT_HEALTH] <= 0)
            {
                DrawPic(0, 0, _ScoreBar);
                DrawScoreboard();
                _Updates = 0;
            }
            else if (Sbar.Lines > 0)
            {
                DrawPic(0, 0, _SBar);

                // keys (hipnotic only)
                //MED 01/04/97 moved keys here so they would not be overwritten
                if (Common.GameKind == GameKind.Hipnotic)
                {
                    if (cl.HasItems(QItems.IT_KEY1))
                    {
                        DrawPic(209, 3, _Items[0]);
                    }

                    if (cl.HasItems(QItems.IT_KEY2))
                    {
                        DrawPic(209, 12, _Items[1]);
                    }
                }
                // armor
                if (cl.HasItems(QItems.IT_INVULNERABILITY))
                {
                    DrawNum(24, 0, 666, 3, 1);
                    DrawPic(0, 0, Drawer.Disc);
                }
                else
                {
                    if (Common.GameKind == GameKind.Rogue)
                    {
                        DrawNum(24, 0, cl.stats[QStats.STAT_ARMOR], 3, cl.stats[QStats.STAT_ARMOR] <= 25 ? 1 : 0); // uze: corrected color param
                        if (cl.HasItems(QItems.RIT_ARMOR3))
                        {
                            DrawPic(0, 0, _Armor[2]);
                        }
                        else if (cl.HasItems(QItems.RIT_ARMOR2))
                        {
                            DrawPic(0, 0, _Armor[1]);
                        }
                        else if (cl.HasItems(QItems.RIT_ARMOR1))
                        {
                            DrawPic(0, 0, _Armor[0]);
                        }
                    }
                    else
                    {
                        DrawNum(24, 0, cl.stats[QStats.STAT_ARMOR], 3, cl.stats[QStats.STAT_ARMOR] <= 25 ? 1 : 0);
                        if (cl.HasItems(QItems.IT_ARMOR3))
                        {
                            DrawPic(0, 0, _Armor[2]);
                        }
                        else if (cl.HasItems(QItems.IT_ARMOR2))
                        {
                            DrawPic(0, 0, _Armor[1]);
                        }
                        else if (cl.HasItems(QItems.IT_ARMOR1))
                        {
                            DrawPic(0, 0, _Armor[0]);
                        }
                    }
                }

                // face
                DrawFace();

                // health
                DrawNum(136, 0, cl.stats[QStats.STAT_HEALTH], 3, cl.stats[QStats.STAT_HEALTH] <= 25 ? 1 : 0);

                // ammo icon
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (cl.HasItems(QItems.RIT_SHELLS))
                    {
                        DrawPic(224, 0, _Ammo[0]);
                    }
                    else if (cl.HasItems(QItems.RIT_NAILS))
                    {
                        DrawPic(224, 0, _Ammo[1]);
                    }
                    else if (cl.HasItems(QItems.RIT_ROCKETS))
                    {
                        DrawPic(224, 0, _Ammo[2]);
                    }
                    else if (cl.HasItems(QItems.RIT_CELLS))
                    {
                        DrawPic(224, 0, _Ammo[3]);
                    }
                    else if (cl.HasItems(QItems.RIT_LAVA_NAILS))
                    {
                        DrawPic(224, 0, _RAmmo[0]);
                    }
                    else if (cl.HasItems(QItems.RIT_PLASMA_AMMO))
                    {
                        DrawPic(224, 0, _RAmmo[1]);
                    }
                    else if (cl.HasItems(QItems.RIT_MULTI_ROCKETS))
                    {
                        DrawPic(224, 0, _RAmmo[2]);
                    }
                }
                else
                {
                    if (cl.HasItems(QItems.IT_SHELLS))
                    {
                        DrawPic(224, 0, _Ammo[0]);
                    }
                    else if (cl.HasItems(QItems.IT_NAILS))
                    {
                        DrawPic(224, 0, _Ammo[1]);
                    }
                    else if (cl.HasItems(QItems.IT_ROCKETS))
                    {
                        DrawPic(224, 0, _Ammo[2]);
                    }
                    else if (cl.HasItems(QItems.IT_CELLS))
                    {
                        DrawPic(224, 0, _Ammo[3]);
                    }
                }

                DrawNum(248, 0, cl.stats[QStats.STAT_AMMO], 3, cl.stats[QStats.STAT_AMMO] <= 10 ? 1 : 0);
            }

            if (vid.width > 320)
            {
                if (Client.Cl.gametype == Protocol.GAME_DEATHMATCH)
                {
                    MiniDeathmatchOverlay();
                }
            }
        }