📄 scr.java
字号:
} }); scr_initialized = true; } /* * ============== SCR_DrawNet ============== */ static void DrawNet() { if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP - 1) return; re.DrawPic(scr_vrect.x + 64, scr_vrect.y, "net"); } /* * ============== SCR_DrawPause ============== */ static void DrawPause() { Dimension dim = new Dimension(); if (scr_showpause.value == 0) // turn off for screenshots return; if (cl_paused.value == 0) return; re.DrawGetPicSize(dim, "pause"); re.DrawPic((viddef.width - dim.width) / 2, viddef.height / 2 + 8, "pause"); } /* * ============== SCR_DrawLoading ============== */ static void DrawLoading() { Dimension dim = new Dimension(); if (scr_draw_loading == 0) return; scr_draw_loading = 0; re.DrawGetPicSize(dim, "loading"); re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading"); } // ============================================================================= /* * ================== SCR_RunConsole * * Scroll it up or down ================== */ static void RunConsole() { // decide on the height of the console if (cls.key_dest == key_console) scr_conlines = 0.5f; // half screen else scr_conlines = 0; // none visible if (scr_conlines < scr_con_current) { scr_con_current -= scr_conspeed.value * cls.frametime; if (scr_conlines > scr_con_current) scr_con_current = scr_conlines; } else if (scr_conlines > scr_con_current) { scr_con_current += scr_conspeed.value * cls.frametime; if (scr_conlines < scr_con_current) scr_con_current = scr_conlines; } } /* * ================== SCR_DrawConsole ================== */ static void DrawConsole() { Console.CheckResize(); if (cls.state == ca_disconnected || cls.state == ca_connecting) { // forced // full // screen // console Console.DrawConsole(1.0f); return; } if (cls.state != ca_active || !cl.refresh_prepped) { // connected, but // can't render Console.DrawConsole(0.5f); re.DrawFill(0, viddef.height / 2, viddef.width, viddef.height / 2, 0); return; } if (scr_con_current != 0) { Console.DrawConsole(scr_con_current); } else { if (cls.key_dest == key_game || cls.key_dest == key_message) Console.DrawNotify(); // only draw notify in game } } // ============================================================================= /* * ================ SCR_BeginLoadingPlaque ================ */ public static void BeginLoadingPlaque() { S.StopAllSounds(); cl.sound_prepped = false; // don't play ambients if (cls.disable_screen != 0) return; if (developer.value != 0) return; if (cls.state == ca_disconnected) return; // if at console, don't bring up the plaque if (cls.key_dest == key_console) return; if (cl.cinematictime > 0) scr_draw_loading = 2; // clear to balack first else scr_draw_loading = 1; UpdateScreen(); cls.disable_screen = Timer.Milliseconds(); cls.disable_servercount = cl.servercount; } /* * ================ SCR_EndLoadingPlaque ================ */ public static void EndLoadingPlaque() { cls.disable_screen = 0; Console.ClearNotify(); } /* * ================ SCR_Loading_f ================ */ static void Loading_f() { BeginLoadingPlaque(); } /* * ================ SCR_TimeRefresh_f ================ */ static void TimeRefresh_f() { int i; int start, stop; float time; if (cls.state != ca_active) return; start = Timer.Milliseconds(); if (Cmd.Argc() == 2) { // run without page flipping re.BeginFrame(0); for (i = 0; i < 128; i++) { cl.refdef.viewangles[1] = i / 128.0f * 360.0f; re.RenderFrame(cl.refdef); } re.EndFrame(); } else { for (i = 0; i < 128; i++) { cl.refdef.viewangles[1] = i / 128.0f * 360.0f; re.BeginFrame(0); re.RenderFrame(cl.refdef); re.EndFrame(); } } stop = Timer.Milliseconds(); time = (stop - start) / 1000.0f; Com.Printf("%f seconds (%f fps)\n", new Vargs(2).add(time).add( 128.0f / time)); } static void DirtyScreen() { AddDirtyPoint(0, 0); AddDirtyPoint(viddef.width - 1, viddef.height - 1); } /* * ============== SCR_TileClear * * Clear any parts of the tiled background that were drawn on last frame * ============== */ static dirty_t clear = new dirty_t(); static void TileClear() { int i; int top, bottom, left, right; clear.clear(); if (scr_drawall.value != 0) DirtyScreen(); // for power vr or broken page flippers... if (scr_con_current == 1.0f) return; // full screen console if (scr_viewsize.value == 100) return; // full screen rendering if (cl.cinematictime > 0) return; // full screen cinematic // erase rect will be the union of the past three frames // so tripple buffering works properly clear.set(scr_dirty); for (i = 0; i < 2; i++) { if (scr_old_dirty[i].x1 < clear.x1) clear.x1 = scr_old_dirty[i].x1; if (scr_old_dirty[i].x2 > clear.x2) clear.x2 = scr_old_dirty[i].x2; if (scr_old_dirty[i].y1 < clear.y1) clear.y1 = scr_old_dirty[i].y1; if (scr_old_dirty[i].y2 > clear.y2) clear.y2 = scr_old_dirty[i].y2; } scr_old_dirty[1].set(scr_old_dirty[0]); scr_old_dirty[0].set(scr_dirty); scr_dirty.x1 = 9999; scr_dirty.x2 = -9999; scr_dirty.y1 = 9999; scr_dirty.y2 = -9999; // don't bother with anything convered by the console) top = (int) (scr_con_current * viddef.height); if (top >= clear.y1) clear.y1 = top; if (clear.y2 <= clear.y1) return; // nothing disturbed top = scr_vrect.y; bottom = top + scr_vrect.height - 1; left = scr_vrect.x; right = left + scr_vrect.width - 1; if (clear.y1 < top) { // clear above view screen i = clear.y2 < top - 1 ? clear.y2 : top - 1; re.DrawTileClear(clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1, "backtile"); clear.y1 = top; } if (clear.y2 > bottom) { // clear below view screen i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1; re.DrawTileClear(clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1, "backtile"); clear.y2 = bottom; } if (clear.x1 < left) { // clear left of view screen i = clear.x2 < left - 1 ? clear.x2 : left - 1; re.DrawTileClear(clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1, "backtile"); clear.x1 = left; } if (clear.x2 > right) { // clear left of view screen i = clear.x1 > right + 1 ? clear.x1 : right + 1; re.DrawTileClear(i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1, "backtile"); clear.x2 = right; } } // =============================================================== static final int STAT_MINUS = 10; // num frame for '-' stats digit static final int ICON_WIDTH = 24; static final int ICON_HEIGHT = 24; static final int CHAR_WIDTH = 16; static final int ICON_SPACE = 8; /* * ================ SizeHUDString * * Allow embedded \n in the string ================ */ static void SizeHUDString(String string, Dimension dim) { int lines, width, current; lines = 1; width = 0; current = 0; for (int i = 0; i < string.length(); i++) { if (string.charAt(i) == '\n') { lines++; current = 0; } else { current++; if (current > width) width = current; } } dim.width = width * 8; dim.height = lines * 8; } static void DrawHUDString(String string, int x, int y, int centerwidth, int xor) { int margin; //char line[1024]; StringBuffer line = new StringBuffer(1024); int i; margin = x; for (int l = 0; l < string.length();) { // scan out one line of text from the string line = new StringBuffer(1024); while (l < string.length() && string.charAt(l) != '\n') { line.append(string.charAt(l)); l++; } if (centerwidth != 0) x = margin + (centerwidth - line.length() * 8) / 2; else x = margin; for (i = 0; i < line.length(); i++) { re.DrawChar(x, y, line.charAt(i) ^ xor); x += 8; } if (l < string.length()) { l++; // skip the \n x = margin; y += 8; } } } /* * ============== SCR_DrawField ============== */ static void DrawField(int x, int y, int color, int width, int value) { char ptr; String num; int l; int frame; if (width < 1) return; // draw number string if (width > 5) width = 5; AddDirtyPoint(x, y); AddDirtyPoint(x + width * CHAR_WIDTH + 2, y + 23); num = "" + value; l = num.length(); if (l > width) l = width; x += 2 + CHAR_WIDTH * (width - l); ptr = num.charAt(0); for (int i = 0; i < l; i++) { ptr = num.charAt(i); if (ptr == '-') frame = STAT_MINUS; else frame = ptr - '0'; re.DrawPic(x, y, sb_nums[color][frame]); x += CHAR_WIDTH; } } /* * =============== SCR_TouchPics * * Allows rendering code to cache all needed sbar graphics =============== */ static void TouchPics() { int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 11; j++) re.RegisterPic(sb_nums[i][j]); if (crosshair.value != 0.0f) { if (crosshair.value > 3.0f || crosshair.value < 0.0f) crosshair.value = 3.0f; crosshair_pic = "ch" + (int) crosshair.value; Dimension dim = new Dimension(); re.DrawGetPicSize(dim, crosshair_pic); crosshair_width = dim.width; crosshair_height = dim.height; if (crosshair_width == 0) crosshair_pic = ""; } } /* * ================ SCR_ExecuteLayoutString * * ================ */ static void ExecuteLayoutString(String s) { int x, y; int value; String token; int width; int index; clientinfo_t ci; if (cls.state != ca_active || !cl.refresh_prepped) return; // if (!s[0]) if (s == null || s.length() == 0) return; x = 0; y = 0; width = 3; Com.ParseHelp ph = new Com.ParseHelp(s); while (!ph.isEof()) { token = Com.Parse(ph); if (token.equals("xl")) { token = Com.Parse(ph); x = Lib.atoi(token); continue; } if (token.equals("xr")) { token = Com.Parse(ph); x = viddef.width + Lib.atoi(token); continue; } if (token.equals("xv")) { token = Com.Parse(ph); x = viddef.width / 2 - 160 + Lib.atoi(token); continue; } if (token.equals("yt")) { token = Com.Parse(ph); y = Lib.atoi(token); continue; } if (token.equals("yb")) { token = Com.Parse(ph); y = viddef.height + Lib.atoi(token); continue; } if (token.equals("yv")) { token = Com.Parse(ph); y = viddef.height / 2 - 120 + Lib.atoi(token);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -