⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scr.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * SCR.java * Copyright (C) 2003 *  * $Id: SCR.java,v 1.18 2005/12/04 17:32:42 cawe Exp $ *//* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */package jake2.client;import jake2.Defines;import jake2.Globals;import jake2.game.Cmd;import jake2.game.cvar_t;import jake2.qcommon.*;import jake2.sound.S;import jake2.sys.Sys;import jake2.sys.Timer;import jake2.util.Lib;import jake2.util.Vargs;import java.awt.Dimension;import java.io.IOException;import java.io.RandomAccessFile;import java.nio.ByteBuffer;import java.nio.ByteOrder;import java.util.Arrays;/** * SCR */public final class SCR extends Globals {    //	cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc    static String[][] sb_nums = {            { "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6",                    "num_7", "num_8", "num_9", "num_minus" },            { "anum_0", "anum_1", "anum_2", "anum_3", "anum_4", "anum_5",                    "anum_6", "anum_7", "anum_8", "anum_9", "anum_minus" } };    /*     * full screen console put up loading plaque blanked background with loading     * plaque blanked background with menu cinematics full screen image for quit     * and victory     *      * end of unit intermissions     */    static float scr_con_current; // aproaches scr_conlines at scr_conspeed    static float scr_conlines; // 0.0 to 1.0 lines of console to display    static boolean scr_initialized; // ready to draw    static int scr_draw_loading;    // scr_vrect ist in Globals definiert    // position of render window on screen    static cvar_t scr_viewsize;    static cvar_t scr_conspeed;    static cvar_t scr_centertime;    static cvar_t scr_showturtle;    static cvar_t scr_showpause;    static cvar_t scr_printspeed;    static cvar_t scr_netgraph;    static cvar_t scr_timegraph;    static cvar_t scr_debuggraph;    static cvar_t scr_graphheight;    static cvar_t scr_graphscale;    static cvar_t scr_graphshift;    static cvar_t scr_drawall;    public static cvar_t fps = new cvar_t();    static dirty_t scr_dirty = new dirty_t();    static dirty_t[] scr_old_dirty = { new dirty_t(), new dirty_t() };    static String crosshair_pic;    static int crosshair_width, crosshair_height;    static class dirty_t {        int x1;        int x2;        int y1;        int y2;        void set(dirty_t src) {            x1 = src.x1;            x2 = src.x2;            y1 = src.y1;            y2 = src.y2;        }        void clear() {            x1 = x2 = y1 = y2 = 0;        }    }    /*     * ===============================================================================     *      * BAR GRAPHS     *      * ===============================================================================     */    //	typedef struct    //	{    //		float value;    //		int color;    //	} graphsamp_t;    static class graphsamp_t {        float value;        int color;    }    static int current;    static graphsamp_t[] values = new graphsamp_t[1024];    static {        for (int n = 0; n < 1024; n++)            values[n] = new graphsamp_t();    }    /*     * ============== SCR_DebugGraph ==============     */    public static void DebugGraph(float value, int color) {        values[current & 1023].value = value;        values[current & 1023].color = color;        current++;    }    /*     * ============== SCR_DrawDebugGraph ==============     */    static void DrawDebugGraph() {        int a, x, y, w, i, h;        float v;        int color;        // draw the graph        w = scr_vrect.width;        x = scr_vrect.x;        y = scr_vrect.y + scr_vrect.height;        re.DrawFill(x, (int) (y - scr_graphheight.value), w,                (int) scr_graphheight.value, 8);        for (a = 0; a < w; a++) {            i = (current - 1 - a + 1024) & 1023;            v = values[i].value;            color = values[i].color;            v = v * scr_graphscale.value + scr_graphshift.value;            if (v < 0)                v += scr_graphheight.value                        * (1 + (int) (-v / scr_graphheight.value));            h = (int) v % (int) scr_graphheight.value;            re.DrawFill(x + w - 1 - a, y - h, 1, h, color);        }    }    /*     * ===============================================================================     *      * CENTER PRINTING     *      * ===============================================================================     */    // char scr_centerstring[1024];    static String scr_centerstring;    static float scr_centertime_start; // for slow victory printing    static float scr_centertime_off;    static int scr_center_lines;    static int scr_erase_center;    /*     * ============== SCR_CenterPrint     *      * Called for important messages that should stay in the center of the     * screen for a few moments ==============     */    static void CenterPrint(String str) {        //char *s;        int s;        StringBuffer line = new StringBuffer(64);        int i, j, l;        //strncpy (scr_centerstring, str, sizeof(scr_centerstring)-1);        scr_centerstring = str;        scr_centertime_off = scr_centertime.value;        scr_centertime_start = cl.time;        // count the number of lines for centering        scr_center_lines = 1;        s = 0;        while (s < str.length()) {            if (str.charAt(s) == '\n')                scr_center_lines++;            s++;        }        // echo it to the console        Com                .Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");        s = 0;        if (str.length() != 0) {            do {                // scan the width of the line                for (l = 0; l < 40 && (l + s) < str.length(); l++)                    if (str.charAt(s + l) == '\n' || str.charAt(s + l) == 0)                        break;                for (i = 0; i < (40 - l) / 2; i++)                    line.append(' ');                for (j = 0; j < l; j++) {                    line.append(str.charAt(s + j));                }                line.append('\n');                Com.Printf(line.toString());                while (s < str.length() && str.charAt(s) != '\n')                    s++;                if (s == str.length())                    break;                s++; // skip the \n            } while (true);        }        Com                .Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");        Console.ClearNotify();    }    static void DrawCenterString() {        String cs = scr_centerstring + "\0";        int start;        int l;        int j;        int x, y;        int remaining;        if (cs == null)            return;        if (cs.length() == 0)            return;        // the finale prints the characters one at a time        remaining = 9999;        scr_erase_center = 0;        start = 0;        if (scr_center_lines <= 4)            y = (int) (viddef.height * 0.35);        else            y = 48;        do {            // scan the width of the line            for (l = 0; l < 40; l++)                if (start + l == cs.length() - 1                        || cs.charAt(start + l) == '\n')                    break;            x = (viddef.width - l * 8) / 2;            SCR.AddDirtyPoint(x, y);            for (j = 0; j < l; j++, x += 8) {                re.DrawChar(x, y, cs.charAt(start + j));                if (remaining == 0)                    return;                remaining--;            }            SCR.AddDirtyPoint(x, y + 8);            y += 8;            while (start < cs.length() && cs.charAt(start) != '\n')                start++;            if (start == cs.length())                break;            start++; // skip the \n        } while (true);    }    static void CheckDrawCenterString() {        scr_centertime_off -= cls.frametime;        if (scr_centertime_off <= 0)            return;        DrawCenterString();    }    // =============================================================================    /*     * ================= SCR_CalcVrect     *      * Sets scr_vrect, the coordinates of the rendered window =================     */    static void CalcVrect() {        int size;        // bound viewsize        if (scr_viewsize.value < 40)            Cvar.Set("viewsize", "40");        if (scr_viewsize.value > 100)            Cvar.Set("viewsize", "100");        size = (int) scr_viewsize.value;        scr_vrect.width = viddef.width * size / 100;        scr_vrect.width &= ~7;        scr_vrect.height = viddef.height * size / 100;        scr_vrect.height &= ~1;        scr_vrect.x = (viddef.width - scr_vrect.width) / 2;        scr_vrect.y = (viddef.height - scr_vrect.height) / 2;    }    /*     * ================= SCR_SizeUp_f     *      * Keybinding command =================     */    static void SizeUp_f() {        Cvar.SetValue("viewsize", scr_viewsize.value + 10);    }    /*     * ================= SCR_SizeDown_f     *      * Keybinding command =================     */    static void SizeDown_f() {        Cvar.SetValue("viewsize", scr_viewsize.value - 10);    }    /*     * ================= SCR_Sky_f     *      * Set a specific sky and rotation speed =================     */    static void Sky_f() {        float rotate;        float[] axis = { 0, 0, 0 };        if (Cmd.Argc() < 2) {            Com.Printf("Usage: sky <basename> <rotate> <axis x y z>\n");            return;        }        if (Cmd.Argc() > 2)            rotate = Float.parseFloat(Cmd.Argv(2));        else            rotate = 0;        if (Cmd.Argc() == 6) {            axis[0] = Float.parseFloat(Cmd.Argv(3));            axis[1] = Float.parseFloat(Cmd.Argv(4));            axis[2] = Float.parseFloat(Cmd.Argv(5));        } else {            axis[0] = 0;            axis[1] = 0;            axis[2] = 1;        }        re.SetSky(Cmd.Argv(1), rotate, axis);    }    // ============================================================================    /*     * ================== SCR_Init ==================     */    static void Init() {        scr_viewsize = Cvar.Get("viewsize", "100", CVAR_ARCHIVE);        scr_conspeed = Cvar.Get("scr_conspeed", "3", 0);        scr_showturtle = Cvar.Get("scr_showturtle", "0", 0);        scr_showpause = Cvar.Get("scr_showpause", "1", 0);        scr_centertime = Cvar.Get("scr_centertime", "2.5", 0);        scr_printspeed = Cvar.Get("scr_printspeed", "8", 0);        scr_netgraph = Cvar.Get("netgraph", "1", 0);        scr_timegraph = Cvar.Get("timegraph", "1", 0);        scr_debuggraph = Cvar.Get("debuggraph", "1", 0);        scr_graphheight = Cvar.Get("graphheight", "32", 0);        scr_graphscale = Cvar.Get("graphscale", "1", 0);        scr_graphshift = Cvar.Get("graphshift", "0", 0);        scr_drawall = Cvar.Get("scr_drawall", "1", 0);        fps = Cvar.Get("fps", "0", 0);        //        // register our commands        //        Cmd.AddCommand("timerefresh", new xcommand_t() {            public void execute() {                TimeRefresh_f();            }        });        Cmd.AddCommand("loading", new xcommand_t() {            public void execute() {                Loading_f();            }        });        Cmd.AddCommand("sizeup", new xcommand_t() {            public void execute() {                SizeUp_f();            }        });        Cmd.AddCommand("sizedown", new xcommand_t() {            public void execute() {                SizeDown_f();            }        });        Cmd.AddCommand("sky", new xcommand_t() {            public void execute() {                Sky_f();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -