public static DrawCharacter ( int x, int y, int num ) : void | ||
x | int | |
y | int | |
num | int | |
return | void |
/// <summary> /// SCR_DrawNotifyString /// </summary> private static void DrawNotifyString() { int offset = 0; int y = (int)(Scr.vid.height * 0.35); do { int end = _NotifyString.IndexOf('\n', offset); if (end == -1) { end = _NotifyString.Length; } if (end - offset > 40) { end = offset + 40; } int length = end - offset; if (length > 0) { int x = (vid.width - length * 8) / 2; for (int j = 0; j < length; j++, x += 8) { Drawer.DrawCharacter(x, y, _NotifyString[offset + j]); } y += 8; } offset = end + 1; } while(offset < _NotifyString.Length); }
// Con_DrawInput // // The input line scrolls horizontally if typing goes beyond the right edge private static void DrawInput() { if (Key.Destination != keydest_t.key_console && !_ForcedUp) { return; // don't draw anything } // add the cursor frame Key.Lines[Key.EditLine][Key.LinePos] = (char)(10 + ((int)(host.RealTime * _CursorSpeed) & 1)); // fill out remainder with spaces for (int i = Key.LinePos + 1; i < _LineWidth; i++) { Key.Lines[Key.EditLine][i] = ' '; } // prestep if horizontally scrolling int offset = 0; if (Key.LinePos >= _LineWidth) { offset = 1 + Key.LinePos - _LineWidth; } //text += 1 + key_linepos - con_linewidth; // draw it int y = _VisLines - 16; for (int i = 0; i < _LineWidth; i++) { Drawer.DrawCharacter((i + 1) << 3, _VisLines - 16, Key.Lines[Key.EditLine][offset + i]); } // remove cursor Key.Lines[Key.EditLine][Key.LinePos] = '\0'; }
/// <summary> /// Con_DrawNotify /// </summary> public static void DrawNotify() { int v = 0; for (int i = _Current - NUM_CON_TIMES + 1; i <= _Current; i++) { if (i < 0) { continue; } double time = _Times[i % NUM_CON_TIMES]; if (time == 0) { continue; } time = Host.RealTime - time; if (time > _NotifyTime.Value) { continue; } int textOffset = (i % _TotalLines) * _LineWidth; Scr.ClearNotify = 0; Scr.CopyTop = true; for (int x = 0; x < _LineWidth; x++) { Drawer.DrawCharacter((x + 1) << 3, v, _Text[textOffset + x]); } v += 8; } if (Key.Destination == keydest_t.key_message) { Scr.ClearNotify = 0; Scr.CopyTop = true; int x = 0; Drawer.DrawString(8, v, "say:"); string chat = Key.ChatBuffer; for (; x < chat.Length; x++) { Drawer.DrawCharacter((x + 5) << 3, v, chat[x]); } Drawer.DrawCharacter((x + 5) << 3, v, 10 + ((int)(Host.RealTime * _CursorSpeed) & 1)); v += 8; } if (v > _NotifyLines) { _NotifyLines = v; } }
// Sbar_DeathmatchOverlay static void DeathmatchOverlay() { Scr.CopyEverithing = true; Scr.FullUpdate = 0; glpic_t pic = Drawer.CachePic("gfx/ranking.lmp"); Menu.DrawPic((320 - pic.width) / 2, 8, pic); // scores SortFrags(); // draw the text int l = _ScoreBoardLines; int x = 80 + ((Scr.vid.width - 320) >> 1); int y = 40; for (int i = 0; i < l; i++) { int k = _FragSort[i]; Scoreboard s = Client.Cl.scores[k]; if (String.IsNullOrEmpty(s.name)) { continue; } // draw background int top = s.colors & 0xf0; int bottom = (s.colors & 15) << 4; top = ColorForMap(top); bottom = ColorForMap(bottom); Drawer.Fill(x, y, 40, 4, top); Drawer.Fill(x, y + 4, 40, 4, bottom); // draw number string num = s.frags.ToString().PadLeft(3); Drawer.DrawCharacter(x + 8, y, num[0]); Drawer.DrawCharacter(x + 16, y, num[1]); Drawer.DrawCharacter(x + 24, y, num[2]); if (k == Client.Cl.viewentity - 1) { Drawer.DrawCharacter(x - 8, y, 12); } // draw name Drawer.DrawString(x + 64, y, s.name); y += 10; } }
// Sbar_DrawCharacter // // Draws one solid graphics character static void DrawCharacter(int x, int y, int num) { if (Client.Cl.gametype == Protocol.GAME_DEATHMATCH) { Drawer.DrawCharacter(x + 4, y + Scr.vid.height - SBAR_HEIGHT, num); } else { Drawer.DrawCharacter(x + ((Scr.vid.width - 320) >> 1) + 4, y + Scr.vid.height - SBAR_HEIGHT, num); } }
// SCR_DrawCenterString private static void DrawCenterString() { int remaining; // the finale prints the characters one at a time if (Client.cl.intermission > 0) { remaining = (int)(_PrintSpeed.Value * (Client.cl.time - _CenterTimeStart)); } else { remaining = 9999; } int y = 48; if (_CenterLines <= 4) { y = (int)(_VidDef.height * 0.35); } string[] lines = _CenterString.Split('\n'); for (int i = 0; i < lines.Length; i++) { string line = lines[i].TrimEnd('\r'); int x = (vid.width - line.Length * 8) / 2; for (int j = 0; j < line.Length; j++, x += 8) { Drawer.DrawCharacter(x, y, line[j]); if (remaining-- <= 0) { return; } } y += 8; } }
// Con_DrawConsole // // Draws the console with the solid background // The typing input line at the bottom should only be drawn if typing is allowed public static void Draw(int lines, bool drawinput) { if (lines <= 0) { return; } // draw the background Drawer.DrawConsoleBackground(lines); // draw the text _VisLines = lines; int rows = (lines - 16) >> 3; // rows of text to draw int y = lines - 16 - (rows << 3); // may start slightly negative for (int i = _Current - rows + 1; i <= _Current; i++, y += 8) { int j = i - BackScroll; if (j < 0) { j = 0; } int offset = (j % _TotalLines) * _LineWidth; for (int x = 0; x < _LineWidth; x++) { Drawer.DrawCharacter((x + 1) << 3, y, _Text[offset + x]); } } // draw the input prompt, user text, and cursor if desired if (drawinput) { DrawInput(); } }
// void SCR_UpdateScreen (void); // This is called every frame, and can also be called explicitly to flush // text to the screen. // // WARNING: be very careful calling this from elsewhere, because the refresh // needs almost the entire 256k of stack space! public static void UpdateScreen() { if (BlockDrawing || !_IsInitialized || _InUpdate) { return; } _InUpdate = true; try { if (MainForm.Instance != null) { if ((MainForm.Instance.VSync == VSyncMode.On) != Vid.Wait) { MainForm.Instance.VSync = (Vid.Wait ? VSyncMode.On : VSyncMode.Off); } } _VidDef.numpages = 2 + (int)_glTripleBuffer.Value; CopyTop = false; _CopyEverything = false; if (IsDisabledForLoading) { if ((Host.RealTime - _DisabledTime) > 60) { IsDisabledForLoading = false; Con.Print("Load failed.\n"); } else { return; } } if (!Con.IsInitialized) { return; // not initialized yet } BeginRendering(); // // determine size of refresh window // if (_OldFov != _Fov.Value) { _OldFov = _Fov.Value; _VidDef.recalc_refdef = true; } if (_OldScreenSize != _ViewSize.Value) { _OldScreenSize = _ViewSize.Value; _VidDef.recalc_refdef = true; } if (_VidDef.recalc_refdef) { CalcRefdef(); } // // do 3D refresh drawing, and then update the screen // SetUpToDrawConsole(); View.RenderView(); Set2D(); // // draw any areas not covered by the refresh // Scr.TileClear(); if (_DrawDialog) { Sbar.Draw(); Drawer.FadeScreen(); DrawNotifyString(); _CopyEverything = true; } else if (_DrawLoading) { DrawLoading(); Sbar.Draw(); } else if (Client.cl.intermission == 1 && Key.Destination == keydest_t.key_game) { Sbar.IntermissionOverlay(); } else if (Client.cl.intermission == 2 && Key.Destination == keydest_t.key_game) { Sbar.FinaleOverlay(); CheckDrawCenterString(); } else { if (View.Crosshair > 0) { Drawer.DrawCharacter(_VRect.x + _VRect.width / 2, _VRect.y + _VRect.height / 2, '+'); } DrawRam(); DrawNet(); DrawTurtle(); DrawPause(); CheckDrawCenterString(); Sbar.Draw(); DrawConsole(); Menu.Draw(); } View.UpdatePalette(); EndRendering(); } finally { _InUpdate = false; } }
// Sbar_DeathmatchOverlay static void MiniDeathmatchOverlay() { if (Scr.vid.width < 512 || Sbar.Lines == 0) { return; } Scr.CopyEverithing = true; Scr.FullUpdate = 0; // scores SortFrags(); // draw the text int l = _ScoreBoardLines; int y = Scr.vid.height - Sbar.Lines; int numlines = Sbar.Lines / 8; if (numlines < 3) { return; } //find us int i; for (i = 0; i < _ScoreBoardLines; i++) { if (_FragSort[i] == Client.Cl.viewentity - 1) { break; } } if (i == _ScoreBoardLines) // we're not there { i = 0; } else // figure out start { i = i - numlines / 2; } if (i > _ScoreBoardLines - numlines) { i = _ScoreBoardLines - numlines; } if (i < 0) { i = 0; } int x = 324; for (; i < _ScoreBoardLines && y < Scr.vid.height - 8; i++) { int k = _FragSort[i]; Scoreboard s = Client.Cl.scores[k]; if (String.IsNullOrEmpty(s.name)) { continue; } // draw background int top = s.colors & 0xf0; int bottom = (s.colors & 15) << 4; top = ColorForMap(top); bottom = ColorForMap(bottom); Drawer.Fill(x, y + 1, 40, 3, top); Drawer.Fill(x, y + 4, 40, 4, bottom); // draw number string num = s.frags.ToString().PadLeft(3); Drawer.DrawCharacter(x + 8, y, num[0]); Drawer.DrawCharacter(x + 16, y, num[1]); Drawer.DrawCharacter(x + 24, y, num[2]); if (k == Client.Cl.viewentity - 1) { Drawer.DrawCharacter(x, y, 16); Drawer.DrawCharacter(x + 32, y, 17); } // draw name Drawer.DrawString(x + 48, y, s.name); y += 8; } }