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

📄 console.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    private static int cr;    public static void Print(String txt) {        int y;        int c, l;        int mask;        int txtpos = 0;        if (!con.initialized)            return;        if (txt.charAt(0) == 1 || txt.charAt(0) == 2) {            mask = 128; // go to colored text            txtpos++;        } else            mask = 0;        while (txtpos < txt.length()) {            c = txt.charAt(txtpos);            // count word length            for (l = 0; l < con.linewidth && l < (txt.length() - txtpos); l++)                if (txt.charAt(l + txtpos) <= ' ')                    break;            // word wrap            if (l != con.linewidth && (con.x + l > con.linewidth))                con.x = 0;            txtpos++;            if (cr != 0) {                con.current--;                cr = 0;            }            if (con.x == 0) {                Console.Linefeed();                // mark time for transparent overlay                if (con.current >= 0)                    con.times[con.current % NUM_CON_TIMES] = cls.realtime;            }            switch (c) {            case '\n':                con.x = 0;                break;            case '\r':                con.x = 0;                cr = 1;                break;            default: // display character and advance                y = con.current % con.totallines;                con.text[y * con.linewidth + con.x] = (byte) (c | mask | con.ormask);                con.x++;                if (con.x >= con.linewidth)                    con.x = 0;                break;            }        }    }    /*     * ============== Con_CenteredPrint ==============     */    static void CenteredPrint(String text) {        int l = text.length();        l = (con.linewidth - l) / 2;        if (l < 0)            l = 0;        StringBuffer sb = new StringBuffer(1024);        for (int i = 0; i < l; i++)            sb.append(' ');        sb.append(text);        sb.append('\n');        sb.setLength(1024);        Console.Print(sb.toString());    }    /*     * ==============================================================================     *      * DRAWING     *      * ==============================================================================     */    /*     * ================ Con_DrawInput     *      * The input line scrolls horizontally if typing goes beyond the right edge     * ================     */    static void DrawInput() {        int i;        byte[] text;        int start = 0;        if (cls.key_dest == key_menu)            return;        if (cls.key_dest != key_console && cls.state == ca_active)            return; // don't draw anything (always draw if not active)        text = key_lines[edit_line];        // add the cursor frame        text[key_linepos] = (byte) (10 + ((int) (cls.realtime >> 8) & 1));        // fill out remainder with spaces        for (i = key_linepos + 1; i < con.linewidth; i++)            text[i] = ' ';        // prestep if horizontally scrolling        if (key_linepos >= con.linewidth)            start += 1 + key_linepos - con.linewidth;        // draw it        //		y = con.vislines-16;        for (i = 0; i < con.linewidth; i++)            re.DrawChar((i + 1) << 3, con.vislines - 22, text[i]);        // remove cursor        key_lines[edit_line][key_linepos] = 0;    }    /*     * ================ Con_DrawNotify     *      * Draws the last few lines of output transparently over the game top     * ================     */    static void DrawNotify() {        int x, v;        int text;        int i;        int time;        String s;        int skip;        v = 0;        for (i = con.current - NUM_CON_TIMES + 1; i <= con.current; i++) {            if (i < 0)                continue;            time = (int) con.times[i % NUM_CON_TIMES];            if (time == 0)                continue;            time = (int) (cls.realtime - time);            if (time > con_notifytime.value * 1000)                continue;            text = (i % con.totallines) * con.linewidth;            for (x = 0; x < con.linewidth; x++)                re.DrawChar((x + 1) << 3, v, con.text[text + x]);            v += 8;        }        if (cls.key_dest == key_message) {            if (chat_team) {                DrawString(8, v, "say_team:");                skip = 11;            } else {                DrawString(8, v, "say:");                skip = 5;            }            s = chat_buffer;            if (chat_bufferlen > (viddef.width >> 3) - (skip + 1))                s = s.substring(chat_bufferlen                        - ((viddef.width >> 3) - (skip + 1)));            for (x = 0; x < s.length(); x++) {                re.DrawChar((x + skip) << 3, v, s.charAt(x));            }            re.DrawChar((x + skip) << 3, v,                    (int) (10 + ((cls.realtime >> 8) & 1)));            v += 8;        }        if (v != 0) {            SCR.AddDirtyPoint(0, 0);            SCR.AddDirtyPoint(viddef.width - 1, v);        }    }    /*     * ================ Con_DrawConsole     *      * Draws the console with the solid background ================     */    static void DrawConsole(float frac) {        int i, j, x, y, n;        int rows;        int text;        int row;        int lines;        String version;        lines = (int) (viddef.height * frac);        if (lines <= 0)            return;        if (lines > viddef.height)            lines = viddef.height;        // draw the background        re.DrawStretchPic(0, -viddef.height + lines, viddef.width,                viddef.height, "conback");        SCR.AddDirtyPoint(0, 0);        SCR.AddDirtyPoint(viddef.width - 1, lines - 1);        version = Com.sprintf("v%4.2f", new Vargs(1).add(VERSION));        for (x = 0; x < 5; x++)            re.DrawChar(viddef.width - 44 + x * 8, lines - 12, 128 + version                    .charAt(x));        // draw the text        con.vislines = lines;        rows = (lines - 22) >> 3; // rows of text to draw        y = lines - 30;        // draw from the bottom up        if (con.display != con.current) {            // draw arrows to show the buffer is backscrolled            for (x = 0; x < con.linewidth; x += 4)                re.DrawChar((x + 1) << 3, y, '^');            y -= 8;            rows--;        }        row = con.display;        for (i = 0; i < rows; i++, y -= 8, row--) {            if (row < 0)                break;            if (con.current - row >= con.totallines)                break; // past scrollback wrap point            int first = (row % con.totallines) * con.linewidth;            for (x = 0; x < con.linewidth; x++)                re.DrawChar((x + 1) << 3, y, con.text[x + first]);        }        //ZOID        // draw the download bar        // figure out width        if (cls.download != null) {            if ((text = cls.downloadname.lastIndexOf('/')) != 0)                text++;            else                text = 0;            x = con.linewidth - ((con.linewidth * 7) / 40);            y = x - (cls.downloadname.length() - text) - 8;            i = con.linewidth / 3;            StringBuffer dlbar = new StringBuffer(512);            if (cls.downloadname.length() - text > i) {                y = x - i - 11;                int end = text + i - 1;                ;                dlbar.append(cls.downloadname.substring(text, end));                dlbar.append("...");            } else {                dlbar.append(cls.downloadname.substring(text));            }            dlbar.append(": ");            dlbar.append((char) 0x80);            // where's the dot go?            if (cls.downloadpercent == 0)                n = 0;            else                n = y * cls.downloadpercent / 100;            for (j = 0; j < y; j++) {                if (j == n)                    dlbar.append((char) 0x83);                else                    dlbar.append((char) 0x81);            }            dlbar.append((char) 0x82);            dlbar.append((cls.downloadpercent < 10) ? " 0" : " ");            dlbar.append(cls.downloadpercent).append('%');            // draw it            y = con.vislines - 12;            for (i = 0; i < dlbar.length(); i++)                re.DrawChar((i + 1) << 3, y, dlbar.charAt(i));        }        //ZOID        // draw the input prompt, user text, and cursor if desired        DrawInput();    }}

⌨️ 快捷键说明

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