]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/miscfunctions.qc
map previews when voting, g_maplist_textonly for old style
[divverent/nexuiz.git] / data / qcsrc / client / miscfunctions.qc
1 float databuf;
2 var float(string text, float handleColors) stringwidth;
3
4 float stringwidth_oldfont(string text, float handleColors)
5 {
6         float i, len, ch, width;
7         len = strlen(text);
8         if(!handleColors)
9                 return len;
10         width = 0;
11         for(i = 0; i < len; ++i)
12         {
13                 if(substring(text, i, 1) == "^")
14                 {
15                         ch = str2chr(text, i+1);
16                         if(ch >= '0' && ch <= '9')
17                                 ++i;
18                         else
19                                 ++width;
20                 }
21                 else
22                         ++width;
23         }
24         return width;
25 }
26
27 void CSQC_CheckEngine()
28 {
29         /*
30         registercvar("csqc_flags", "0");
31         csqc_flags = cvar("csqc_flags");
32         */
33
34         csqc_flags = 0;
35         
36         if(checkextension("DP_SV_WRITEPICTURE"))
37         {
38                 stringwidth = stringwidth_engine;
39                 sbar_font = FONT_USER+1;
40                 csqc_flags |= CSQC_FLAG_READPICTURE;
41         } else {
42                 stringwidth = stringwidth_oldfont;
43                 sbar_font = FONT_DEFAULT;
44         }
45 }
46
47 vector Sbar_GetFontsize()
48 {
49         if(csqc_flags & CSQC_FLAG_READPICTURE)
50                 return stov(cvar_string("sbar_fontsize"));
51         return '8 8' ;
52 }
53
54 float PreviewExists(string name)
55 {
56         float f;
57         string file;
58         file = strcat(name, ".tga");
59         f = fopen(file, FILE_READ);
60         if(f >= 0)
61         {
62                 fclose(f);
63                 return true;
64         }
65         file = strcat(name, ".png");
66         f = fopen(file, FILE_READ);
67         if(f >= 0)
68         {
69                 fclose(f);
70                 return true;
71         }
72         file = strcat(name, ".jpg");
73         f = fopen(file, FILE_READ);
74         if(f >= 0)
75         {
76                 fclose(f);
77                 return true;
78         }
79         file = strcat(name, ".pcx");
80         f = fopen(file, FILE_READ);
81         if(f >= 0)
82         {
83                 fclose(f);
84                 return true;
85         }
86         return false;
87 }