Cleanup: get rid of the ancient Font_LoadFont() wrapper, pipe _all_ text
font info through our internal font_s data structure.
This commit is contained in:
parent
2484f6c283
commit
c22b001f60
35 changed files with 247 additions and 383 deletions
1
base/src/client/progs.src
Executable file → Normal file
1
base/src/client/progs.src
Executable file → Normal file
|
@ -3,7 +3,6 @@
|
|||
|
||||
#define CSQC
|
||||
#define CLIENT
|
||||
#define CLASSIC_VGUI
|
||||
#define GS_RENDERFX
|
||||
|
||||
#includelist
|
||||
|
|
|
@ -31,7 +31,7 @@ Scores_DrawTeam(player pl, vector pos)
|
|||
{
|
||||
drawfill(pos, [290, 1], SCORE_LINE_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
|
||||
drawfont = FONT_20;
|
||||
drawfont = Font_GetID(FONT_20);
|
||||
drawstring(pos + [0,-18], "Teams", [8,8], SCORE_HEADER_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
drawstring(pos + [124,-18], "kills / deaths", [8,8], SCORE_HEADER_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
drawstring(pos + [240,-18], "latency", [8,8], SCORE_HEADER_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
|
@ -84,7 +84,7 @@ Scores_DrawTeam(player pl, vector pos)
|
|||
pos[1] += 12;
|
||||
}
|
||||
|
||||
drawfont = FONT_CON;
|
||||
drawfont = Font_GetID(FONT_CON);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -92,7 +92,7 @@ Scores_DrawNormal(player pl, vector pos)
|
|||
{
|
||||
drawfill(pos, [290, 1], SCORE_LINE_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
|
||||
drawfont = FONT_20;
|
||||
drawfont = Font_GetID(FONT_20);
|
||||
drawstring(pos + [0,-18], "Player", [8,8], SCORE_HEADER_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
drawstring(pos + [124,-18], "kills / deaths", [8,8], SCORE_HEADER_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
drawstring(pos + [240,-18], "latency", [8,8], SCORE_HEADER_C, 1.0f, DRAWFLAG_ADDITIVE);
|
||||
|
@ -134,7 +134,7 @@ Scores_DrawNormal(player pl, vector pos)
|
|||
pos[1] += 20;
|
||||
}
|
||||
|
||||
drawfont = FONT_CON;
|
||||
drawfont = Font_GetID(FONT_CON);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
2
platform/base_scripts.pk3dir/fonts/chat.font
Normal file
2
platform/base_scripts.pk3dir/fonts/chat.font
Normal file
|
@ -0,0 +1,2 @@
|
|||
path gfx/shell/arial.ttf
|
||||
size 8
|
|
@ -1,3 +1,2 @@
|
|||
name "16"
|
||||
font "gfx/shell/arial.ttf"
|
||||
size "16"
|
||||
path gfx/shell/arial.ttf
|
||||
size 16
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
name "cr"
|
||||
font "gfx/shell/arial.ttf"
|
||||
size "20"
|
||||
path gfx/shell/arial.ttf
|
||||
size 20
|
|
@ -1,3 +1,2 @@
|
|||
name "font"
|
||||
font "gfx/shell/arial.ttf"
|
||||
size "12"
|
||||
path gfx/shell/arial.ttf
|
||||
size 12
|
|
@ -1,3 +1,2 @@
|
|||
name "label_p"
|
||||
font "gfx/shell/arialbd.ttf"
|
||||
size "16 21"
|
||||
rendersize "16 21"
|
||||
path gfx/shell/arialbd.ttf
|
|
@ -1,3 +1,2 @@
|
|||
name "label"
|
||||
font "gfx/shell/mssansserif.ttf"
|
||||
size "10 12 14"
|
||||
rendersize "10 12 14"
|
||||
path gfx/shell/mssansserif.ttf
|
|
@ -1,3 +1,2 @@
|
|||
name "label_b"
|
||||
font "gfx/shell/arialbd.ttf"
|
||||
size "14 12"
|
||||
rendersize "14 12"
|
||||
path gfx/shell/arialbd.ttf
|
|
@ -1,3 +1,2 @@
|
|||
name "label"
|
||||
font "gfx/shell/arial.ttf"
|
||||
size "14 11 12"
|
||||
rendersize "14 11 12"
|
||||
path gfx/shell/arial.ttf
|
4
platform/base_scripts.pk3dir/fonts/ui.font
Normal file
4
platform/base_scripts.pk3dir/fonts/ui.font
Normal file
|
@ -0,0 +1,4 @@
|
|||
color "255 255 255"
|
||||
alpha 255
|
||||
size 12
|
||||
path fonts/Tahoma.ttf
|
|
@ -1,4 +0,0 @@
|
|||
COLOR=255 255 255
|
||||
ALPHA=255
|
||||
SIZE=12
|
||||
PATH=fonts/Tahoma.ttf
|
|
@ -21,6 +21,13 @@ var int g_chatpos[2];
|
|||
var float g_chattime;
|
||||
var int g_chatlines = -1;
|
||||
string g_chatbuffer[CHAT_LINES];
|
||||
font_s g_fntChat;
|
||||
|
||||
void
|
||||
Chat_Init(void)
|
||||
{
|
||||
Font_Load("fonts/chat.font", g_fntChat);
|
||||
}
|
||||
|
||||
/*
|
||||
* called every frame pretty much and prints whatever is in the chatbuffer.
|
||||
|
@ -31,8 +38,6 @@ Chat_Draw(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
drawfont = FONT_CON;
|
||||
|
||||
/* the voting stuff resides here too, for now */
|
||||
if (serverkey("vote_cmd")) {
|
||||
string tempstr;
|
||||
|
@ -40,7 +45,7 @@ Chat_Draw(void)
|
|||
tempstr = sprintf("^3Vote: %s", serverkey("vote_cmd"));
|
||||
temppos[0] = (g_hudres[0]/2) - (stringwidth(tempstr, TRUE, [12,12]) / 2);
|
||||
temppos[1] = 96;
|
||||
drawstring(temppos, tempstr, [12,12], [1,1,1], 1.0f, 0);
|
||||
Font_DrawText(temppos, tempstr, g_fntChat);
|
||||
|
||||
tempstr = sprintf(
|
||||
"^2Yes: %s ^1No: %s",
|
||||
|
@ -48,7 +53,7 @@ Chat_Draw(void)
|
|||
serverkey("votes_n")
|
||||
);
|
||||
temppos[0] = (g_hudres[0]/2) - (stringwidth(tempstr, TRUE, [12,12]) / 2);
|
||||
drawstring(temppos + [0,16], tempstr, [12,12], [1,1,1], 1.0f, 0);
|
||||
Font_DrawText(temppos + [0,16], tempstr, g_fntChat);
|
||||
}
|
||||
|
||||
g_chatpos[0] = g_hudmins[0] + 16;
|
||||
|
@ -73,8 +78,7 @@ Chat_Draw(void)
|
|||
}
|
||||
|
||||
for (i = 0; i < CHAT_LINES; i++) {
|
||||
drawstring([g_chatpos[0],g_chatpos[1]], g_chatbuffer[i],
|
||||
[12,12], [1,1,1], 1.0f, 0);
|
||||
Font_DrawText([g_chatpos[0],g_chatpos[1]], g_chatbuffer[i], g_fntChat);
|
||||
g_chatpos[1] += 14;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "textmenu.h"
|
||||
#include "efx.h"
|
||||
#include "font.h"
|
||||
|
||||
/* flags for 2d drawing */
|
||||
#define DRAWFLAG_NORMAL 0
|
||||
|
@ -30,9 +31,9 @@
|
|||
#define PRINT_CHAT 3
|
||||
|
||||
/* fonts */
|
||||
var float FONT_16;
|
||||
var float FONT_20;
|
||||
var float FONT_CON;
|
||||
font_s FONT_16;
|
||||
font_s FONT_20;
|
||||
font_s FONT_CON;
|
||||
|
||||
/* clientside cvars */
|
||||
var float autocvar_zoom_sensitivity = 1.0f;
|
||||
|
|
|
@ -20,8 +20,7 @@ EFX_DebugInfo(void)
|
|||
static vector pos = [16, 16];
|
||||
|
||||
static void epr(string tx) {
|
||||
drawfont = FONT_CON;
|
||||
drawstring(pos, tx, [12,12], [1,1,1], 1.0f, 0);
|
||||
Font_DrawText(pos, tx, FONT_CON);
|
||||
pos[1] += 12;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,9 +55,6 @@ CSQC_Init(float apilevel, string enginename, float engineversion)
|
|||
registercommand("vote");
|
||||
registercommand("callvote");
|
||||
|
||||
registercommand("+saturn_menu");
|
||||
registercommand("-saturn_menu");
|
||||
|
||||
/* hud weapon selection system */
|
||||
registercommand("slot1");
|
||||
registercommand("slot2");
|
||||
|
@ -116,10 +113,9 @@ void
|
|||
CSQC_RendererRestarted(string rstr)
|
||||
{
|
||||
/* Fonts */
|
||||
FONT_16 = Font_LoadFont("fonts/font16.font");
|
||||
FONT_20 = Font_LoadFont("fonts/font20.font");
|
||||
FONT_CON = Font_LoadFont("fonts/fontcon.font");
|
||||
drawfont = FONT_CON;
|
||||
Font_Load("fonts/font16.font", FONT_16);
|
||||
Font_Load("fonts/font20.font", FONT_20);
|
||||
Font_Load("fonts/fontcon.font", FONT_CON);
|
||||
|
||||
/* Particles */
|
||||
PART_DUSTMOTE = particleeffectnum("volume.dustmote");
|
||||
|
@ -129,6 +125,7 @@ CSQC_RendererRestarted(string rstr)
|
|||
precache_pic("gfx/vgui/icntlk_pl");
|
||||
|
||||
/* View */
|
||||
Chat_Init();
|
||||
Weapons_Init();
|
||||
Scores_Init();
|
||||
View_Init();
|
||||
|
@ -384,7 +381,6 @@ CSQC_UpdateView(float w, float h, float focus)
|
|||
}
|
||||
|
||||
Fade_Update((int)video_mins[0],(int)video_mins[1], (int)w, (int)h);
|
||||
IN_Saturn_DrawMenu();
|
||||
View_PostDraw();
|
||||
|
||||
if (g_iIntermission) {
|
||||
|
@ -545,8 +541,6 @@ CSQC_Input_Frame(void)
|
|||
if (pSeat->m_flCameraTime > time) {
|
||||
/* TODO: Supress the changing of view_angles/input_angles. */
|
||||
}
|
||||
|
||||
IN_Saturn_InputFrame();
|
||||
}
|
||||
|
||||
|
||||
|
@ -818,12 +812,6 @@ CSQC_ConsoleCommand(string sCMD)
|
|||
case "slot10":
|
||||
HUD_SlotSelect(9);
|
||||
break;
|
||||
case "+saturn_menu":
|
||||
pSeat->m_iSaturnMenu = TRUE;
|
||||
break;
|
||||
case "-saturn_menu":
|
||||
pSeat->m_iSaturnMenu = FALSE;
|
||||
break;
|
||||
case "way_menu":
|
||||
Textmenu_Call("WAY_MENU");
|
||||
break;
|
||||
|
|
40
src/client/font.h
Normal file
40
src/client/font.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
enumflags
|
||||
{
|
||||
AF_RIGHT,
|
||||
AF_TOP,
|
||||
AF_LEFT,
|
||||
AF_BOTTOM
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int iID;
|
||||
int iScaleX;
|
||||
int iScaleY;
|
||||
vector vecColor;
|
||||
float flAlpha;
|
||||
int iFlags;
|
||||
} font_s;
|
||||
|
||||
void Font_Load(string strFile, font_s &fntNew);
|
||||
void Font_DrawText(vector vecOrigin, string strText, font_s fnt);
|
||||
void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, int iAlignFlags);
|
||||
string Font_RGBtoHex(vector vecColor);
|
||||
|
||||
float Font_GetID(font_s fnt);
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2021 Marco Hladik <marco@icculus.org>
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -14,42 +14,123 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* very basic wrapper around loadfont(), as we don't want to hard-code
|
||||
* paths to fonts used in the cgame */
|
||||
float
|
||||
Font_LoadFont(string filename)
|
||||
Font_GetID(font_s fnt)
|
||||
{
|
||||
string line;
|
||||
filestream fs_font;
|
||||
|
||||
fs_font = fopen(filename, FILE_READ);
|
||||
|
||||
if (fs_font < 0) {
|
||||
print(sprintf("[FONT] ^1WARNING: ^7Could NOT load %s\n", filename));
|
||||
return -1;
|
||||
}
|
||||
|
||||
string font = "gfx/conchars";
|
||||
string size = "8";
|
||||
string shortname = "";
|
||||
|
||||
while ((line = fgets(fs_font))) {
|
||||
int c = tokenize_console(line);
|
||||
|
||||
switch (argv(0)) {
|
||||
case "font":
|
||||
font = argv(1);
|
||||
break;
|
||||
case "size":
|
||||
size = argv(1);
|
||||
break;
|
||||
case "name":
|
||||
shortname = argv(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fs_font);
|
||||
|
||||
return loadfont(shortname, font, size, -1);
|
||||
return (float)fnt.iID;
|
||||
}
|
||||
|
||||
void
|
||||
Font_Load(string strFile, font_s &fntNew)
|
||||
{
|
||||
string strTemp = "";
|
||||
string strFontPath = "";
|
||||
string strRenderSize = "";
|
||||
|
||||
filestream fileFont = fopen(strFile, FILE_READ);
|
||||
fntNew.iID = 0;
|
||||
fntNew.iScaleX = fntNew.iScaleY = 8;
|
||||
fntNew.vecColor = [1,1,1];
|
||||
fntNew.flAlpha = 1.0f;
|
||||
fntNew.iFlags = 0;
|
||||
|
||||
if (fileFont >= 0) {
|
||||
int argc;
|
||||
while ((strTemp = fgets(fileFont))) {
|
||||
argc = tokenize_console(strTemp);
|
||||
if (argc != 2)
|
||||
continue;
|
||||
|
||||
switch (argv(0)) {
|
||||
case "color":
|
||||
fntNew.vecColor = stov(argv(1)) / 255;
|
||||
break;
|
||||
case "alpha":
|
||||
fntNew.flAlpha = stof(argv(1)) / 255;
|
||||
break;
|
||||
case "size_x":
|
||||
fntNew.iScaleX = (int)stof(argv(1));
|
||||
break;
|
||||
case "size_y":
|
||||
fntNew.iScaleY = (int)stof(argv(1));
|
||||
break;
|
||||
case "size":
|
||||
fntNew.iScaleY = fntNew.iScaleX = (int)stof(argv(1));
|
||||
break;
|
||||
case "path":
|
||||
strFontPath = argv(1);
|
||||
break;
|
||||
case "rendersize":
|
||||
strRenderSize = argv(1);
|
||||
break;
|
||||
case "flags":
|
||||
fntNew.iFlags = (int)stof(argv(1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fileFont);
|
||||
} else {
|
||||
error(sprintf("[MENU] Cannot load font file %s!", strFile));
|
||||
}
|
||||
|
||||
//print(sprintf("[FONT] %s: %s %s\n", strFile, strFontPath, strRenderSize));
|
||||
|
||||
if (strRenderSize != "")
|
||||
fntNew.iID = (int)loadfont("", strFontPath, strRenderSize, -1, 0, 0);
|
||||
else
|
||||
fntNew.iID = (int)loadfont("", strFontPath, ftos((float)fntNew.iScaleY), -1, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawText(vector vecOrigin, string strText, font_s fnt)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawstring(vecOrigin, strText, [fnt.iScaleX, fnt.iScaleY], fnt.vecColor, fnt.flAlpha, (float)fnt.iFlags);
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawText_A(vector vecOrigin, string strText, vector rgb, float a, font_s fnt)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawstring(vecOrigin, strText, [fnt.iScaleX, fnt.iScaleY], fnt.vecColor, a, (float)fnt.iFlags);
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawText_RGB(vector vecOrigin, string strText, vector rgb, font_s fnt)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawstring(vecOrigin, strText, [fnt.iScaleX, fnt.iScaleY], rgb, fnt.flAlpha, (float)fnt.iFlags);
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawText_RGBA(vector vecOrigin, string strText, vector rgb, float a, font_s fnt)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawstring(vecOrigin, strText, [fnt.iScaleX, fnt.iScaleY], rgb, a, (float)fnt.iFlags);
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, int iAlignFlags)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawtextfield(vecOrigin, vecSize, (float)iAlignFlags, strText);
|
||||
}
|
||||
|
||||
string
|
||||
Font_RGBtoHex(vector vecColor)
|
||||
{
|
||||
static string numtohex(float x) {
|
||||
x = rint(x * 15);
|
||||
if (x <= 9)
|
||||
return ftos(x);
|
||||
else {
|
||||
x -= 10;
|
||||
return sprintf("%c", 'A' + x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return sprintf("^x%s%s%s", numtohex(vecColor[0]), numtohex(vecColor[1]), numtohex(vecColor[2]));
|
||||
}
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* these are the key mapping for a SEGA Saturn controller in X360 mode */
|
||||
#define K_SATURN_DPAD_UP 251
|
||||
#define K_SATURN_DPAD_DOWN 252
|
||||
#define K_SATURN_DPAD_LEFT 253
|
||||
#define K_SATURN_DPAD_RIGHT 254
|
||||
|
||||
#define K_SATURN_A 190
|
||||
#define K_SATURN_B 191
|
||||
#define K_SATURN_C 197
|
||||
|
||||
#define K_SATURN_X 192
|
||||
#define K_SATURN_Y 193
|
||||
#define K_SATURN_Z 196
|
||||
|
||||
#define K_SATURN_LSHOULDER 194
|
||||
#define K_SATURN_RSHOULDER 195
|
||||
|
||||
#define K_SATURN_START 199
|
||||
|
||||
var int autocvar_in_saturnmode = FALSE;
|
||||
|
||||
vector dots[12] = {
|
||||
[0, 32],
|
||||
[32, 32],
|
||||
[32, 0],
|
||||
[64, 0],
|
||||
[64, 32],
|
||||
[96, 32],
|
||||
[96, 64],
|
||||
[64, 64],
|
||||
[64, 96],
|
||||
[32, 96],
|
||||
[32, 64],
|
||||
[0, 64]
|
||||
};
|
||||
|
||||
void
|
||||
IN_Saturn_DrawMenu(void)
|
||||
{
|
||||
if (!pSeat->m_iSaturnMenu)
|
||||
return;
|
||||
|
||||
vector col = autocvar_con_color / 255;
|
||||
vector center;
|
||||
center = (g_hudmins + (g_hudres / 2)) - [48, 48];
|
||||
drawline(2, center + dots[0], center + dots[1], col, 1.0f);
|
||||
drawline(2, center + dots[1], center + dots[2], col, 1.0f);
|
||||
drawline(2, center + dots[2], center + dots[3], col, 1.0f);
|
||||
drawline(2, center + dots[3], center + dots[4], col, 1.0f);
|
||||
drawline(2, center + dots[4], center + dots[5], col, 1.0f);
|
||||
drawline(2, center + dots[5], center + dots[6], col, 1.0f);
|
||||
drawline(2, center + dots[6], center + dots[7], col, 1.0f);
|
||||
drawline(2, center + dots[7], center + dots[8], col, 1.0f);
|
||||
drawline(2, center + dots[8], center + dots[9], col, 1.0f);
|
||||
drawline(2, center + dots[9], center + dots[10], col, 1.0f);
|
||||
drawline(2, center + dots[10], center + dots[11], col, 1.0f);
|
||||
drawline(2, center + dots[11], center + dots[0], col, 1.0f);
|
||||
|
||||
string textup = "RELOAD";
|
||||
string textdown = "FLASHLIGHT";
|
||||
string textleft = "PREVIOUS ITEM";
|
||||
string textright = "NEXT ITEM";
|
||||
drawfont = FONT_CON;
|
||||
center = (g_hudmins + (g_hudres / 2));
|
||||
drawstring(center + [0, -64] - [(stringwidth(textup, FALSE, [12,12]) / 2), 0], textup, [12,12], col, 1.0f, 0);
|
||||
drawstring(center + [0, 64] - [(stringwidth(textdown, FALSE, [12,12]) / 2), 0], textdown, [12,12], col, 1.0f, 0);
|
||||
drawstring(center + [-64, 0] - [stringwidth(textleft, FALSE, [12,12]), 0], textleft, [12,12], col, 1.0f, 0);
|
||||
drawstring(center + [64, 0], textright, [12,12], col, 1.0f, 0);
|
||||
}
|
||||
|
||||
void
|
||||
IN_Saturn_InputFrame(void)
|
||||
{
|
||||
int s = (float)getproperty(VF_ACTIVESEAT);
|
||||
pSeat = &g_seats[s];
|
||||
|
||||
if (!autocvar_in_saturnmode)
|
||||
return;
|
||||
|
||||
if (pSeat->m_iSaturnMenu) {
|
||||
if (input_movevalues[0] > 0) {
|
||||
localcmd("+reload;wait;wait;wait;-reload\n");
|
||||
pSeat->m_iSaturnMenu = FALSE;
|
||||
} else if (input_movevalues[0] < 0) {
|
||||
localcmd("impulse 100\n");
|
||||
pSeat->m_iSaturnMenu = FALSE;
|
||||
} else if (input_movevalues[1] > 0) {
|
||||
localcmd("invnext\n");
|
||||
pSeat->m_iSaturnMenu = FALSE;
|
||||
} else if (input_movevalues[1] < 0) {
|
||||
localcmd("invprev\n");
|
||||
pSeat->m_iSaturnMenu = FALSE;
|
||||
}
|
||||
input_movevalues = [0,0,0];
|
||||
}
|
||||
|
||||
if (input_buttons & INPUT_BUTTON5) {
|
||||
vector dir = input_movevalues;
|
||||
dir[0] *= -0.5f;
|
||||
dir[1] *= -0.5f;
|
||||
input_angles += clframetime * dir;
|
||||
input_movevalues = [0,0,0];
|
||||
setproperty(VF_CL_VIEWANGLES, input_angles);
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ chat.qc
|
|||
textmenu.qc
|
||||
vgui.qc
|
||||
way.qc
|
||||
in_saturn.qc
|
||||
efx.qc
|
||||
entry.qc
|
||||
#endlist
|
||||
|
|
|
@ -132,7 +132,7 @@ GameText_DrawMessage(int i, float timer, int highlight)
|
|||
void
|
||||
GameText_Draw(void)
|
||||
{
|
||||
drawfont = FONT_20;
|
||||
drawfont = Font_GetID(FONT_20);
|
||||
|
||||
for (int i = 0i; i < 6; i++) {
|
||||
GameText_DrawMessage(i, g_textchannels[i].m_flTime - g_textchannels[i].m_flFXTime, 0);
|
||||
|
@ -140,7 +140,7 @@ GameText_Draw(void)
|
|||
g_textchannels[i].m_flTime += clframetime;
|
||||
}
|
||||
|
||||
drawfont = FONT_CON;
|
||||
drawfont = Font_GetID(FONT_CON);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -130,12 +130,24 @@ View_DrawViewModel(void)
|
|||
if (autocvar_v_modellag == 0)
|
||||
m_eViewModel.angles = view_angles;
|
||||
else {
|
||||
float limit;
|
||||
float speed;
|
||||
makevectors(pSeat->m_vecLag);
|
||||
pSeat->m_vecLag = v_forward;
|
||||
makevectors(view_angles);
|
||||
pSeat->m_vecLag[0] = Math_Lerp(pSeat->m_vecLag[0], v_forward[0], clframetime * 20);
|
||||
pSeat->m_vecLag[1] = Math_Lerp(pSeat->m_vecLag[1], v_forward[1], clframetime * 20);
|
||||
pSeat->m_vecLag[2] = Math_Lerp(pSeat->m_vecLag[2], v_forward[2], clframetime * 20);
|
||||
|
||||
if (autocvar_v_modellag == 2) {
|
||||
float pitchfix = fabs(view_angles[0] / 180);
|
||||
limit = dotproduct(pSeat->m_vecLag, v_forward) * (1.0 - pitchfix);
|
||||
speed = (1.0 - limit) * clframetime;
|
||||
speed *= 90;
|
||||
} else {
|
||||
speed = clframetime * 20;
|
||||
}
|
||||
|
||||
pSeat->m_vecLag[0] = Math_Lerp(pSeat->m_vecLag[0], v_forward[0], speed);
|
||||
pSeat->m_vecLag[1] = Math_Lerp(pSeat->m_vecLag[1], v_forward[1], speed);
|
||||
pSeat->m_vecLag[2] = Math_Lerp(pSeat->m_vecLag[2], v_forward[2], speed);
|
||||
pSeat->m_vecLag = vectoangles(pSeat->m_vecLag);
|
||||
m_eViewModel.angles = pSeat->m_vecLag;
|
||||
}
|
||||
|
|
|
@ -49,15 +49,7 @@ Voice_DrawHUD(void)
|
|||
);
|
||||
|
||||
/* speaker name */
|
||||
drawfont = FONT_CON;
|
||||
drawstring(
|
||||
[pos[0] + 28, pos[1] + 8],
|
||||
getplayerkeyvalue(i, "name"),
|
||||
[12,12],
|
||||
[1,1,1],
|
||||
1.0f,
|
||||
DRAWFLAG_NORMAL
|
||||
);
|
||||
Font_DrawText([pos[0] + 28, pos[1] + 8], getplayerkeyvalue(i, "name"), FONT_CON);
|
||||
pos[1] -= 32;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,9 +106,8 @@ PointMessage_Draw(void)
|
|||
}
|
||||
|
||||
if (PointMessage_Visible(m.origin, vecPlayer, getproperty(VF_ANGLES)) == TRUE) {
|
||||
drawfont = FONT_CON;
|
||||
vector vTemp = project(m.origin) - [(stringwidth(msg, FALSE,[12,12]) / 2), 0];
|
||||
drawstring(vTemp, msg, [12,12], [1,1,1], 1.0f, 0);
|
||||
Font_DrawText(vTemp, msg, FONT_CON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +121,6 @@ PointMessage_StringAtPos(vector org, string message)
|
|||
pSeat = &g_seats[s];
|
||||
vecPlayer = pSeat->m_vecPredictedOrigin;
|
||||
|
||||
drawfont = FONT_CON;
|
||||
vector vTemp = project(org) - [(stringwidth(message, FALSE,[12,12]) / 2), 0];
|
||||
drawstring(vTemp, message, [12,12], [1,1,1], 1.0f, 0);
|
||||
vector vTemp = project(org) - [(stringwidth(message, FALSE,[12,12]) / 2), 0];
|
||||
Font_DrawText(vTemp, message, FONT_CON);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../client/font.h"
|
||||
|
||||
var int autocvar_menu_intro = TRUE;
|
||||
var int autocvar__menu_singleplayer;
|
||||
|
||||
|
@ -47,11 +49,11 @@ float frametime;
|
|||
var int g_background = FALSE;
|
||||
|
||||
/* Font IDs */
|
||||
int font_label;
|
||||
int font_label_b;
|
||||
int font_console;
|
||||
int font_arial;
|
||||
int font_label_p;
|
||||
font_s font_label;
|
||||
font_s font_label_b;
|
||||
font_s font_console;
|
||||
font_s font_arial;
|
||||
font_s font_label_p;
|
||||
|
||||
var int autocvar_menu_helptext_size = 11;
|
||||
|
||||
|
|
|
@ -114,11 +114,11 @@ m_init(void)
|
|||
registercommand("map_background");
|
||||
registercommand("menu_musicstart");
|
||||
|
||||
font_console = loadfont("font", "", "12", -1);
|
||||
font_label = Font_LoadFont("fonts/menu_label.font");
|
||||
font_arial = Font_LoadFont("fonts/menu_main.font");
|
||||
font_label_b = Font_LoadFont("fonts/menu_label_bold.font");
|
||||
font_label_p = Font_LoadFont("fonts/menu_header.font");
|
||||
Font_Load("fonts/fontcon.font", font_console);
|
||||
Font_Load("fonts/menu_label.font", font_label);
|
||||
Font_Load("fonts/menu_main.font", font_arial);
|
||||
Font_Load("fonts/menu_label_bold.font", font_label_b);
|
||||
Font_Load("fonts/menu_header.font", font_label_p);
|
||||
|
||||
localcmd("plug_load ffmpeg\n");
|
||||
|
||||
|
@ -247,7 +247,7 @@ m_draw(vector screensize)
|
|||
}
|
||||
|
||||
const string ver = "Nuclide (build " __DATE__ ")";
|
||||
drawfont = font_console;
|
||||
drawfont = Font_GetID(font_console);
|
||||
|
||||
WLabel_Static(640 - 8 - stringwidth(ver, TRUE, [12,12]),
|
||||
466,
|
||||
|
|
|
@ -144,7 +144,7 @@ Header_Draw(int id)
|
|||
if (whichpack(strcat(g_bmp[id],".bmp"))) {
|
||||
drawpic([g_menuofs[0]+45,g_menuofs[1]+45], g_bmp[id],[460,80], [1,1,1], 1.0f, 1);
|
||||
} else {
|
||||
drawfont = font_label_p;
|
||||
drawfont = Font_GetID(font_label_p);
|
||||
drawstring([g_menuofs[0]+45,g_menuofs[1]+45], g_header_text[id-HEAD_ADVANCED], [32,32], [1,1,1], 1.0f, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ CLabel::Draw(void)
|
|||
/* Sometimes all you need is a static label */
|
||||
void
|
||||
WLabel_Static(int x, int y, string msg, int sx, int sy, vector col,
|
||||
float alpha, float flags, int font)
|
||||
float alpha, float flags, font_s font)
|
||||
{
|
||||
drawfont = font;
|
||||
drawfont = Font_GetID(font);
|
||||
x += g_menuofs[0];
|
||||
y += g_menuofs[1];
|
||||
drawstring([x,y], msg, [sx,sy], col, alpha, flags);
|
||||
|
@ -56,9 +56,9 @@ WLabel_Static(int x, int y, string msg, int sx, int sy, vector col,
|
|||
|
||||
void
|
||||
WLabel_StaticR(int x, int y, string msg, int sx, int sy, vector col,
|
||||
float alpha, float flags, int font)
|
||||
float alpha, float flags, font_s font)
|
||||
{
|
||||
drawfont = font;
|
||||
drawfont = Font_GetID(font);
|
||||
x += g_menuofs[0] - stringwidth(msg, TRUE,[sx,sy]);
|
||||
y += g_menuofs[1];
|
||||
drawstring([x,y], msg, [sx,sy], col, alpha, flags);
|
||||
|
@ -66,9 +66,9 @@ WLabel_StaticR(int x, int y, string msg, int sx, int sy, vector col,
|
|||
|
||||
void
|
||||
WField_Static(int x, int y, string msg, int sx, int sy, vector col,
|
||||
float alpha, float flags, int font)
|
||||
float alpha, float flags, font_s font)
|
||||
{
|
||||
drawfont = font;
|
||||
drawfont = Font_GetID(font);
|
||||
x += g_menuofs[0];
|
||||
y += g_menuofs[1];
|
||||
drawtextfield([x,y], [sx,sy], flags, sprintf("%s%s",
|
||||
|
|
|
@ -117,7 +117,7 @@ CListBox::AddWrapped(string m)
|
|||
string tmp;
|
||||
string new;
|
||||
|
||||
drawfont = font_label;
|
||||
drawfont = Font_GetID(font_label);
|
||||
|
||||
argc = tokenizebyseparator(m, " ");
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ CMainButton::Draw(void)
|
|||
[0,((m_bitmap * 3)+1) * g_btnofs], [1,g_btnofs],
|
||||
[1,1,1], 1 - m_alpha, 1);
|
||||
} else {
|
||||
drawfont = font_label_p;
|
||||
drawfont = Font_GetID(font_label_p);
|
||||
if (!m_execute) {
|
||||
drawstring([g_menuofs[0]+m_x,g_menuofs[1]+m_y], g_mainbtn_text[m_bitmap], [16,16], col_button_disabled, 1.0, 0);
|
||||
return;
|
||||
|
|
|
@ -53,7 +53,7 @@ CTextBox::Draw(void)
|
|||
drawfill([g_menuofs[0]+m_x,g_menuofs[1]+m_y], [m_length,24], [0.25,0.25,0.25], 1.0f);
|
||||
}
|
||||
drawfill([g_menuofs[0]+m_x+3,g_menuofs[1]+m_y+3], [m_length-6,18], [0,0,0], 1.0f);
|
||||
drawfont = font_label;
|
||||
drawfont = Font_GetID(font_label);
|
||||
|
||||
if (m_flags & TEXTBOX_FOCUS) {
|
||||
if (rint(time*4) & 1) {
|
||||
|
|
|
@ -84,7 +84,7 @@ CTextBuffer::InsertWrapped(string m)
|
|||
string tmp;
|
||||
string new;
|
||||
|
||||
drawfont = font_label;
|
||||
drawfont = Font_GetID(font_label);
|
||||
|
||||
argc = tokenizebyseparator(m, " ");
|
||||
|
||||
|
|
124
src/vgui/font.qc
124
src/vgui/font.qc
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
enumflags
|
||||
{
|
||||
AF_RIGHT,
|
||||
AF_TOP,
|
||||
AF_LEFT,
|
||||
AF_BOTTOM
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int iID;
|
||||
int iScaleX;
|
||||
int iScaleY;
|
||||
vector vecColor;
|
||||
float flAlpha;
|
||||
int iFlags;
|
||||
} font_s;
|
||||
|
||||
void
|
||||
Font_Load(string strFile, font_s &fntNew)
|
||||
{
|
||||
#ifdef CLASSIC_VGUI
|
||||
fntNew.iID = (int)loadfont("", "gfx/conchars", "12", -1, 0, 0);
|
||||
fntNew.iScaleX = fntNew.iScaleY = 12;
|
||||
fntNew.vecColor = [255,200,0] / 255;
|
||||
fntNew.flAlpha = 1.0f;
|
||||
fntNew.iFlags = 0;
|
||||
#else
|
||||
string strTemp = "";
|
||||
string strFontPath = "";
|
||||
filestream fileFont = fopen(strFile, FILE_READ);
|
||||
fntNew.iID = 0;
|
||||
fntNew.iScaleX = fntNew.iScaleY = 8;
|
||||
fntNew.vecColor = [1,1,1];
|
||||
fntNew.flAlpha = 1.0f;
|
||||
fntNew.iFlags = 0;
|
||||
|
||||
if (fileFont >= 0) {
|
||||
int argc;
|
||||
while ((strTemp = fgets(fileFont))) {
|
||||
argc = tokenizebyseparator(strTemp, "=");
|
||||
if (argc == 2) {
|
||||
switch (argv(0)) {
|
||||
case "COLOR":
|
||||
fntNew.vecColor = stov(argv(1)) / 255;
|
||||
break;
|
||||
case "ALPHA":
|
||||
fntNew.flAlpha = stof(argv(1)) / 255;
|
||||
break;
|
||||
case "SIZE_X":
|
||||
fntNew.iScaleX = stoi(argv(1));
|
||||
break;
|
||||
case "SIZE_Y":
|
||||
fntNew.iScaleY = stoi(argv(1));
|
||||
break;
|
||||
case "SIZE":
|
||||
fntNew.iScaleY = fntNew.iScaleX = stoi(argv(1));
|
||||
break;
|
||||
case "PATH":
|
||||
strFontPath = argv(1);
|
||||
break;
|
||||
case "FLAGS":
|
||||
fntNew.iFlags = stoi(argv(1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fileFont);
|
||||
} else {
|
||||
error(sprintf("[MENU] Cannot load font file %s!", strFile));
|
||||
}
|
||||
|
||||
fntNew.iID = (int)loadfont("", strFontPath, ftos((float)fntNew.iScaleY), -1, 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawText(vector vecOrigin, string strText, font_s fnt)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawstring(vecOrigin, strText, [fnt.iScaleX, fnt.iScaleY], fnt.vecColor, fnt.flAlpha, (float)fnt.iFlags);
|
||||
}
|
||||
|
||||
void
|
||||
Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, int iAlignFlags)
|
||||
{
|
||||
drawfont = (float)fnt.iID;
|
||||
drawtextfield(vecOrigin, vecSize, (float)iAlignFlags, strText);
|
||||
}
|
||||
|
||||
string
|
||||
Font_RGBtoHex(vector vecColor)
|
||||
{
|
||||
static string numtohex(float x) {
|
||||
x = rint(x * 15);
|
||||
if (x <= 9)
|
||||
return ftos(x);
|
||||
else {
|
||||
x -= 10;
|
||||
return sprintf("%c", 'A' + x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return sprintf("^x%s%s%s", numtohex(vecColor[0]), numtohex(vecColor[1]), numtohex(vecColor[2]));
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
#includelist
|
||||
../vgui/font.qc
|
||||
../vgui/ui.qc
|
||||
../vgui/ui_button.qc
|
||||
../vgui/ui_menubutton.qc
|
||||
|
|
|
@ -161,7 +161,7 @@ UISystem_Init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
Font_Load("scripts/ui_font.txt", g_fntDefault);
|
||||
Font_Load("fonts/ui.font", g_fntDefault);
|
||||
precache_pic("textures/ui/steam/icon_radiosel");
|
||||
precache_pic("textures/ui/steam/icon_radiounsel");
|
||||
precache_pic("textures/ui/steam/icon_checked");
|
||||
|
|
Loading…
Reference in a new issue