예제 #1
0
        /*
         * =================
         *
         * CL_PrepRefresh
         *
         * Call before entering a new level, or after changing dlls
         * =================
         */
        public static void PrepRefresh()
        {
            string mapname;
            int    i;
            string name;
            float  rotate;
            var    axis = new float[3];

            if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0)
            {
                return;                 // no map loaded
            }
            SCR.AddDirtyPoint(0, 0);
            SCR.AddDirtyPoint(Globals.viddef.getWidth() - 1, Globals.viddef.getHeight() - 1);

            // let the render dll load the map
            mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 9);             // skip "maps/"

            // cut off ".bsp"

            // register models, pics, and skins
            Com.Printf("Map: " + mapname + "\r");
            SCR.UpdateScreen();
            Globals.re.BeginRegistration(mapname);
            Com.Printf("                                     \r");

            // precache status bar pics
            Com.Printf("pics\r");
            SCR.UpdateScreen();
            SCR.TouchPics();
            Com.Printf("                                     \r");
            CL_tent.RegisterTEntModels();
            CL_view.num_cl_weaponmodels = 1;
            CL_view.cl_weaponmodels[0]  = "weapon.md2";

            for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++)
            {
                name = new(Globals.cl.configstrings[Defines.CS_MODELS + i]);

                if (name.Length > 37)
                {
                    name = name[..36];
예제 #2
0
        public static void PrepRefresh()
        {
            string mapname;
            int    i;
            string name;
            float  rotate;

            float[] axis = new float[3];
            if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0)
            {
                return;
            }
            SCR.AddDirtyPoint(0, 0);
            SCR.AddDirtyPoint(Globals.viddef.GetWidth() - 1, Globals.viddef.GetHeight() - 1);
            mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 4);
            Com.Printf("Map: " + mapname + "\\r");
            SCR.UpdateScreen();
            Globals.re.BeginRegistration(mapname);
            Com.Printf("                                     \\r");
            Com.Printf("pics\\r");
            SCR.UpdateScreen();
            SCR.TouchPics();
            Com.Printf("                                     \\r");
            CL_tent.RegisterTEntModels();
            num_cl_weaponmodels = 1;
            cl_weaponmodels[0]  = "weapon.md2";
            for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++)
            {
                name = new string (Globals.cl.configstrings[Defines.CS_MODELS + i]);
                if (name.Length > 37)
                {
                    name = name.Substring(0, 36);
                }
                if (name[0] != '*')
                {
                    Com.Printf(name + "\\r");
                }
                SCR.UpdateScreen();
                CoreSys.SendKeyEvents();
                if (name[0] == '#')
                {
                    if (num_cl_weaponmodels < Defines.MAX_CLIENTWEAPONMODELS)
                    {
                        cl_weaponmodels[num_cl_weaponmodels] = Globals.cl.configstrings[Defines.CS_MODELS + i].Substring(1);
                        num_cl_weaponmodels++;
                    }
                }
                else
                {
                    Globals.cl.model_draw[i] = Globals.re.RegisterModel(Globals.cl.configstrings[Defines.CS_MODELS + i]);
                    if (name[0] == '*')
                    {
                        Globals.cl.model_clip[i] = CM.InlineModel(Globals.cl.configstrings[Defines.CS_MODELS + i]);
                    }
                    else
                    {
                        Globals.cl.model_clip[i] = null;
                    }
                }

                if (name[0] != '*')
                {
                    Com.Printf("                                     \\r");
                }
            }

            Com.Printf("images\\r");
            SCR.UpdateScreen();
            for (i = 1; i < Defines.MAX_IMAGES && Globals.cl.configstrings[Defines.CS_IMAGES + i].Length > 0; i++)
            {
                Globals.cl.image_precache[i] = Globals.re.RegisterPic(Globals.cl.configstrings[Defines.CS_IMAGES + i]);
                CoreSys.SendKeyEvents();
            }

            Com.Printf("                                     \\r");
            for (i = 0; i < Defines.MAX_CLIENTS; i++)
            {
                if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].Length == 0)
                {
                    continue;
                }
                Com.Printf("client " + i + '\\');
                SCR.UpdateScreen();
                CoreSys.SendKeyEvents();
                CL_parse.ParseClientinfo(i);
                Com.Printf("                                     \\r");
            }

            CL_parse.LoadClientinfo(Globals.cl.baseclientinfo, "unnamed\\\\male/grunt");
            Com.Printf("sky\\r");
            SCR.UpdateScreen();
            rotate = float.Parse(Globals.cl.configstrings[Defines.CS_SKYROTATE]);
            StringTokenizer st = new StringTokenizer(Globals.cl.configstrings[Defines.CS_SKYAXIS]);

            st.MoveNext();
            axis[0] = float.Parse(st.Current);
            st.MoveNext();
            axis[1] = float.Parse(st.Current);
            st.MoveNext();
            axis[2] = float.Parse(st.Current);
            Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate, axis);
            Com.Printf("                                     \\r");
            Globals.re.EndRegistration();
            Con.ClearNotify();
            SCR.UpdateScreen();
            Globals.cl.refresh_prepped = true;
            Globals.cl.force_refdef    = true;
        }
예제 #3
0
파일: Key.cs 프로젝트: optimus-code/Q2Sharp
        public static void Console(int key)
        {
            switch (key)

            {
            case K_KP_SLASH:
                key = '/';
                break;

            case K_KP_MINUS:
                key = '-';
                break;

            case K_KP_PLUS:
                key = '+';
                break;

            case K_KP_HOME:
                key = '7';
                break;

            case K_KP_UPARROW:
                key = '8';
                break;

            case K_KP_PGUP:
                key = '9';
                break;

            case K_KP_LEFTARROW:
                key = '4';
                break;

            case K_KP_5:
                key = '5';
                break;

            case K_KP_RIGHTARROW:
                key = '6';
                break;

            case K_KP_END:
                key = '1';
                break;

            case K_KP_DOWNARROW:
                key = '2';
                break;

            case K_KP_PGDN:
                key = '3';
                break;

            case K_KP_INS:
                key = '0';
                break;

            case K_KP_DEL:
                key = '.';
                break;
            }

            if (key == 'l')
            {
                if (Globals.keydown[K_CTRL])
                {
                    Cbuf.AddText("clear\\n");
                    return;
                }
            }

            if (key == K_ENTER || key == K_KP_ENTER)
            {
                if (Globals.key_lines[Globals.edit_line][1] == '\\' || Globals.key_lines[Globals.edit_line][1] == '/')
                {
                    Cbuf.AddText(Encoding.ASCII.GetString(Globals.key_lines[Globals.edit_line], 2, Lib.Strlen(Globals.key_lines[Globals.edit_line]) - 2));
                }
                else
                {
                    Cbuf.AddText(Encoding.ASCII.GetString(Globals.key_lines[Globals.edit_line], 1, Lib.Strlen(Globals.key_lines[Globals.edit_line]) - 1));
                }
                Cbuf.AddText("\\n");
                Com.Printf(Encoding.ASCII.GetString(Globals.key_lines[Globals.edit_line], 0, Lib.Strlen(Globals.key_lines[Globals.edit_line])) + "\\n");
                Globals.edit_line = (Globals.edit_line + 1) & 31;
                history_line      = Globals.edit_line;
                Globals.key_lines[Globals.edit_line][0] = (byte)']';
                Globals.key_linepos = 1;
                if (Globals.cls.state == Defines.ca_disconnected)
                {
                    SCR.UpdateScreen();
                }
                return;
            }

            if (key == K_TAB)
            {
                CompleteCommand();
                return;
            }

            if ((key == K_BACKSPACE) || (key == K_LEFTARROW) || (key == K_KP_LEFTARROW) || ((key == 'h') && (Globals.keydown[K_CTRL])))
            {
                if (Globals.key_linepos > 1)
                {
                    Globals.key_linepos--;
                }
                return;
            }

            if ((key == K_UPARROW) || (key == K_KP_UPARROW) || ((key == 'p') && Globals.keydown[K_CTRL]))
            {
                do
                {
                    history_line = (history_line - 1) & 31;
                }while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0);
                if (history_line == Globals.edit_line)
                {
                    history_line = (Globals.edit_line + 1) & 31;
                }
                System.Array.Copy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].Length);
                Globals.key_linepos = Lib.Strlen(Globals.key_lines[Globals.edit_line]);
                return;
            }

            if ((key == K_DOWNARROW) || (key == K_KP_DOWNARROW) || ((key == 'n') && Globals.keydown[K_CTRL]))
            {
                if (history_line == Globals.edit_line)
                {
                    return;
                }
                do
                {
                    history_line = (history_line + 1) & 31;
                }while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0);
                if (history_line == Globals.edit_line)
                {
                    Globals.key_lines[Globals.edit_line][0] = (byte)']';
                    Globals.key_linepos = 1;
                }
                else
                {
                    System.Array.Copy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].Length);
                    Globals.key_linepos = Lib.Strlen(Globals.key_lines[Globals.edit_line]);
                }

                return;
            }

            if (key == K_PGUP || key == K_KP_PGUP)
            {
                Globals.con.display -= 2;
                return;
            }

            if (key == K_PGDN || key == K_KP_PGDN)
            {
                Globals.con.display += 2;
                if (Globals.con.display > Globals.con.current)
                {
                    Globals.con.display = Globals.con.current;
                }
                return;
            }

            if (key == K_HOME || key == K_KP_HOME)
            {
                Globals.con.display = Globals.con.current - Globals.con.totallines + 10;
                return;
            }

            if (key == K_END || key == K_KP_END)
            {
                Globals.con.display = Globals.con.current;
                return;
            }

            if (key < 32 || key > 127)
            {
                return;
            }
            if (Globals.key_linepos < Defines.MAXCMDLINE - 1)
            {
                Globals.key_lines[Globals.edit_line][Globals.key_linepos] = (byte)key;
                Globals.key_linepos++;
                Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0;
            }
        }