Add test_grenadeclip.

Add helper functions to convert RGB255 to ^x color codes.
Small fixes for fonts in vguilib.
This commit is contained in:
Marco Cawthorne 2021-11-03 21:54:43 +01:00
parent 0a8dbd0edb
commit aa0ccf4413
Signed by: eukara
GPG Key ID: C196CD8BA993248A
17 changed files with 250 additions and 81 deletions

View File

@ -1,7 +1,7 @@
{
climb 0x00004000
vehicleclip 0x00008000
grenadeclip 0x00010000
grenadeclip 0x00000080
}
{
leakssteam 0x00080000

Binary file not shown.

View File

@ -0,0 +1,139 @@
// entity 0
{
"classname" "worldspawn"
// brush 0
{
( 248 192 -64 ) ( 248 -192 -64 ) ( -264 192 -64 ) next/cracked1 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 256 192 8 ) ( -256 192 8 ) ( 256 192 0 ) next/cracked1 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( 256 192 8 ) ( 256 192 0 ) ( 256 -192 8 ) next/cracked1 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -256 -192 -128 ) ( 256 -192 -128 ) ( -256 192 -128 ) next/cracked1 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( -256 -192 0 ) ( -256 -192 8 ) ( 256 -192 0 ) next/cracked1 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -256 -192 0 ) ( -256 192 0 ) ( -256 -192 8 ) next/cracked1 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
}
// brush 1
{
( 248 192 192 ) ( 248 -192 192 ) ( -264 192 192 ) skies/yukongold [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 256 192 264 ) ( -256 192 264 ) ( 256 192 256 ) skies/yukongold [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 256 192 264 ) ( 256 192 256 ) ( 256 -192 264 ) skies/yukongold [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( -256 -192 128 ) ( 256 -192 128 ) ( -256 192 128 ) skies/yukongold [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( -256 -192 256 ) ( -256 -192 264 ) ( 256 -192 256 ) skies/yukongold [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( -256 -192 256 ) ( -256 192 256 ) ( -256 -192 264 ) skies/yukongold [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
// brush 2
{
( 184 192 192 ) ( 184 -192 192 ) ( -328 192 192 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 192 192 264 ) ( -320 192 264 ) ( 192 192 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -256 192 8 ) ( -256 192 0 ) ( -256 -192 8 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -768 -192 -128 ) ( -256 -192 -128 ) ( -768 192 -128 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( -320 -192 256 ) ( -320 -192 264 ) ( 192 -192 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -320 -192 256 ) ( -320 192 256 ) ( -320 -192 264 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
}
// brush 3
{
( 760 192 192 ) ( 760 -192 192 ) ( 248 192 192 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 768 192 264 ) ( 256 192 264 ) ( 768 192 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( 320 192 8 ) ( 320 192 0 ) ( 320 -192 8 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -192 -192 -128 ) ( 320 -192 -128 ) ( -192 192 -128 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 256 -192 256 ) ( 256 -192 264 ) ( 768 -192 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( 256 -192 256 ) ( 256 192 256 ) ( 256 -192 264 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
}
// brush 4
{
( 184 -192 192 ) ( 184 -576 192 ) ( -328 -192 192 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 192 -192 264 ) ( -320 -192 264 ) ( 192 -192 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( 320 96 8 ) ( 320 96 0 ) ( 320 -288 8 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -768 -576 -128 ) ( -256 -576 -128 ) ( -768 -192 -128 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 272 -256 256 ) ( 272 -256 264 ) ( 784 -256 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -320 -576 256 ) ( -320 -192 256 ) ( -320 -576 264 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
}
// brush 5
{
( 184 256 192 ) ( 184 -128 192 ) ( -328 256 192 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 192 256 264 ) ( -320 256 264 ) ( 192 256 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( 320 544 8 ) ( 320 544 0 ) ( 320 160 8 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -768 -128 -128 ) ( -256 -128 -128 ) ( -768 256 -128 ) next/bunker2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.25 0.25 0 0 0
( 272 192 256 ) ( 272 192 264 ) ( 784 192 256 ) next/bunker2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
( -320 -128 256 ) ( -320 256 256 ) ( -320 -128 264 ) next/bunker2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.25 0.25 0 0 0
}
// brush 6
{
( 224 192 64 ) ( 224 92 64 ) ( 128 192 64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 224 192 64 ) ( 128 192 64 ) ( 224 192 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 192 228 64 ) ( 192 228 -64 ) ( 192 128 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 128 92 -64 ) ( 224 92 -64 ) ( 128 192 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 96 128 -64 ) ( 96 128 64 ) ( 192 128 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 128 92 -64 ) ( 128 192 -64 ) ( 128 92 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
// brush 7
{
( 288 64 64 ) ( 288 -36 64 ) ( 192 64 64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 288 64 64 ) ( 192 64 64 ) ( 288 64 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 256 100 64 ) ( 256 100 -64 ) ( 256 0 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 192 -36 -64 ) ( 288 -36 -64 ) ( 192 64 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 160 0 -64 ) ( 160 0 64 ) ( 256 0 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 192 -36 -64 ) ( 192 64 -64 ) ( 192 -36 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
// brush 8
{
( 288 -64 64 ) ( 288 -164 64 ) ( 192 -64 64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 288 -64 64 ) ( 192 -64 64 ) ( 288 -64 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 256 -28 64 ) ( 256 -28 -64 ) ( 256 -128 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 192 -164 -64 ) ( 288 -164 -64 ) ( 192 -64 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 160 -128 -64 ) ( 160 -128 64 ) ( 256 -128 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 192 -164 -64 ) ( 192 -64 -64 ) ( 192 -164 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
// brush 9
{
( 160 -128 64 ) ( 160 -228 64 ) ( 64 -128 64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 160 -128 64 ) ( 64 -128 64 ) ( 160 -128 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 128 -92 64 ) ( 128 -92 -64 ) ( 128 -192 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 64 -228 -64 ) ( 160 -228 -64 ) ( 64 -128 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 32 -192 -64 ) ( 32 -192 64 ) ( 128 -192 -64 ) next/plywood2 [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 64 -228 -64 ) ( 64 -128 -64 ) ( 64 -228 64 ) next/plywood2 [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
// brush 10
{
( 16 64 64 ) ( 16 -64 64 ) ( 0 64 64 ) common/clipgrenade [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 16 64 64 ) ( 0 64 64 ) ( 16 64 -64 ) common/clipgrenade [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 16 64 64 ) ( 16 64 -64 ) ( 16 -64 64 ) common/clipgrenade [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 0 -64 -64 ) ( 16 -64 -64 ) ( 0 64 -64 ) common/clipgrenade [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 0 -64 -64 ) ( 0 -64 64 ) ( 16 -64 -64 ) common/clipgrenade [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 0 -64 -64 ) ( 0 64 -64 ) ( 0 -64 64 ) common/clipgrenade [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
}
// entity 1
{
"classname" "info_player_start"
"origin" "-128.000000 0.000000 0.000000"
}
// entity 2
{
"classname" "info_player_deathmatch"
"origin" "-128.000000 0.000000 0.000000"
}
// entity 3
{
"classname" "light"
"origin" "128.000000 0.000000 64.000000"
"light" "100"
}
// entity 4
{
"classname" "light"
"origin" "-128.000000 0.000000 64.000000"
"light" "100"
}
// entity 5
{
"classname" "func_detail_illusionary"
// brush 0
{
( 16 64 64 ) ( 16 -64 64 ) ( 0 64 64 ) measure/wall128g [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 16 64 64 ) ( 0 64 64 ) ( 16 64 -64 ) measure/wall128g [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 16 64 64 ) ( 16 64 -64 ) ( 16 -64 64 ) measure/wall128g [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 0 -64 -64 ) ( 16 -64 -64 ) ( 0 64 -64 ) measure/wall128g [ 1 0 0 0 ] [ -0 -1 -0 0 ] -0 0.5 0.5 0 0 0
( 0 -64 -64 ) ( 0 -64 64 ) ( 16 -64 -64 ) measure/wall128g [ 1 0 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
( 0 -64 -64 ) ( 0 64 -64 ) ( 0 -64 64 ) measure/wall128g [ 0 1 0 0 ] [ -0 -0 -1 0 ] -0 0.5 0.5 0 0 0
}
}

View File

@ -1,14 +1,6 @@
// Vera Visions Material
{
program unlit
diffusemap models/logos/visions_eye.ktx
normalmap models/logos/visions_eye_n.tga
{
program vertexlit_specular
}
{
clampmap models/logos/visions_eye.tga
blendFunc add
rgbGen wave sin 1 0.2 1 .8
}
}

View File

@ -340,8 +340,8 @@ CSQC_UpdateView(float w, float h, float focus)
player bp = (player)c;
removeentity(c);
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin + bp.view_ofs);
setproperty(VF_ANGLES, [bp.pitch, bp.angles[1], bp.angles[2]]);
setproperty(VF_CL_VIEWANGLES, [bp.pitch, bp.angles[1], bp.angles[2]]);
setproperty(VF_ANGLES, bp.v_angle);
setproperty(VF_CL_VIEWANGLES, bp.v_angle);
}
break;
default:

View File

@ -14,7 +14,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*QUAKED env_glow (0 0.5 1) (-8 -8 -8) (8 8 8)
/*QUAKED env_glow (0 0.5 1) (-8 -8 -8) (8 8 8) EVGLOW_ORIENT
Client-side glare/glow orb effect like the flares in 1997's Unreal.
-------- KEYS --------
@ -37,6 +37,8 @@ class env_glow:NSEntity /* change to renderablentity? */
vector m_vecSize;
float m_flScale;
vector m_vecOrientation;
void(void) env_glow;
virtual float() predraw;
@ -55,6 +57,12 @@ env_glow::RendererRestarted(void)
m_strSprite = spriteframe(model, 0, 0.0f);
m_vecSize = drawgetimagesize(m_strSprite) / 2;
}
if (spawnflags & 1) {
hitcontentsmaski = CONTENTBIT_SOLID;
decal_pickwall(this, origin);
m_vecOrientation = vectoangles(g_tracedDecal.normal * -1);
}
}
float
@ -95,8 +103,11 @@ env_glow::predraw(void)
makevectors(vectoangles(origin - vecPlayer));
forg = origin + (v_forward * -16);
/* Project it, always facing the player */
makevectors(view_angles);
if (spawnflags & 1)
makevectors(m_vecOrientation);
else
makevectors(view_angles);
#ifndef FTE_QUADFIX
R_BeginPolygon(m_strSprite, 1, 0);
R_PolygonVertex(forg + v_right * fsize[0] - v_up * fsize[1],
@ -170,7 +181,6 @@ env_glow::env_glow(void)
drawmask = MASK_ENGINE;
setsize(this, [0,0,0], [0,0,0]);
effects &= ~EF_NOSHADOW;
Init();
RendererRestarted();

View File

@ -14,7 +14,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*QUAKED prop_rope (1 1 0.5) (-8 -8 -8) (8 8 8)
/*QUAKED prop_rope (1 1 0.5) (-8 -8 -8) (8 8 8) ROPE_VERTICAL
Client-side decorative rope entity.
Connect the entity to a named info_notnull and watch it swing around.

View File

@ -45,34 +45,34 @@ decal_pickwall(entity dself, vector vpos)
{
traced_t tmp[6];
float frac = 1.0f;
g_tracedDecal.fraction = 1.0f;
g_tracedDecal.endpos = [0,0,0];
g_tracedDecal.normal = [0,0,0];
/* unrolled, trace against walls in all 6 directions */
makevectors([0, 0, 0]);
traceline(vpos + (v_forward * -1), vpos + (v_forward * 128), 1, dself);
traceline(vpos + (v_forward * -1), vpos + (v_forward * 128), 0, dself);
tmp[0].fraction = trace_fraction;
tmp[0].normal = trace_plane_normal;
tmp[0].endpos = trace_endpos;
traceline(vpos + (v_forward * 1), vpos + (v_forward * -128), 1, dself);
traceline(vpos + (v_forward * 1), vpos + (v_forward * -128), 0, dself);
tmp[1].fraction = trace_fraction;
tmp[1].normal = trace_plane_normal;
tmp[1].endpos = trace_endpos;
traceline(vpos + (v_right * -1), vpos + (v_right * 128), 1, dself);
traceline(vpos + (v_right * -1), vpos + (v_right * 128), 0, dself);
tmp[2].fraction = trace_fraction;
tmp[2].normal = trace_plane_normal;
tmp[2].endpos = trace_endpos;
traceline(vpos + (v_right * 1), vpos + (v_right * -128), 1, dself);
traceline(vpos + (v_right * 1), vpos + (v_right * -128), 0, dself);
tmp[3].fraction = trace_fraction;
tmp[3].normal = trace_plane_normal;
tmp[3].endpos = trace_endpos;
traceline(vpos + (v_up * -1), vpos + (v_up * 128), 1, dself);
traceline(vpos + (v_up * -1), vpos + (v_up * 128), 0, dself);
tmp[4].fraction = trace_fraction;
tmp[4].normal = trace_plane_normal;
tmp[4].endpos = trace_endpos;
traceline(vpos + (v_up * 1), vpos + (v_up * -128), 1, dself);
traceline(vpos + (v_up * 1), vpos + (v_up * -128), 0, dself);
tmp[5].fraction = trace_fraction;
tmp[5].normal = trace_plane_normal;
tmp[5].endpos = trace_endpos;

View File

@ -64,6 +64,8 @@ void
func_tankcontrols::Respawn(void)
{
InitBrushTrigger();
solid = SOLID_BBOX;
setorigin(this, origin);
PlayerUse = OnPlayerUse;
}

View File

@ -396,6 +396,7 @@ NSEntity::Restore(string strKey, string strValue)
break;
case "solid":
solid = stof(strValue);
setorigin(this, origin);
break;
case "movetype":
movetype = stof(strValue);

View File

@ -14,6 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "../shared/colors.h"
vector col_help;
vector col_prompt_bg;
vector col_prompt_text;
@ -29,48 +31,6 @@ vector col_button_select; /* 1,0,0 */
vector col_button_click; /* 1,1,0 */
vector col_button_disabled; /* 0.25, 0.25, 0.25 */
string
Colors_RGB8_to_HEX(vector color)
{
string out = "^x";
for (int i = 0; i < 3; i++) {
string a = "";
float b = rint(color[i] * 15);
switch (b) {
case 10:
a = "A";
break;
case 11:
a = "B";
break;
case 12:
a = "C";
break;
case 13:
a = "D";
break;
case 14:
a = "E";
break;
case 15:
a = "F";
break;
default:
a = ftos(b);
}
out = sprintf("%s%s", out, a);
}
return out;
}
string
Colors_RGB255_to_HEX(vector color)
{
return Colors_RGB8_to_HEX(color / 255);
}
void
Colors_Init(void)
{

57
src/shared/colors.h Normal file
View File

@ -0,0 +1,57 @@
/*
* 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.
*/
string
Colors_RGB8_to_HEX(vector color)
{
string out = "^x";
for (int i = 0; i < 3; i++) {
string a = "";
float b = rint(color[i] * 15);
switch (b) {
case 10:
a = "A";
break;
case 11:
a = "B";
break;
case 12:
a = "C";
break;
case 13:
a = "D";
break;
case 14:
a = "E";
break;
case 15:
a = "F";
break;
default:
a = ftos(b);
}
out = sprintf("%s%s", out, a);
}
return out;
}
string
Colors_RGB255_to_HEX(vector color)
{
return Colors_RGB8_to_HEX(color / 255);
}

View File

@ -31,6 +31,7 @@
#include "propdata.h"
#include "surfaceproperties.h"
#include "vehicles.h"
#include "colors.h"
#define BSPVER_PREREL 28
#define BSPVER_Q1 29

View File

@ -25,7 +25,8 @@ enumflags
typedef struct
{
int iID;
int iScale;
int iScaleX;
int iScaleY;
vector vecColor;
float flAlpha;
int iFlags;
@ -36,7 +37,7 @@ Font_Load(string strFile, font_s &fntNew)
{
#ifdef CLASSIC_VGUI
fntNew.iID = (int)loadfont("", "gfx/conchars", "12", -1, 0, 0);
fntNew.iScale = 12;
fntNew.iScaleX = fntNew.iScaleY = 12;
fntNew.vecColor = [255,200,0] / 255;
fntNew.flAlpha = 1.0f;
fntNew.iFlags = 0;
@ -45,14 +46,16 @@ Font_Load(string strFile, font_s &fntNew)
string strFontPath = "";
filestream fileFont = fopen(strFile, FILE_READ);
fntNew.iID = 0;
fntNew.iScale = 8;
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))) {
if (tokenizebyseparator(strTemp, "=") == 2) {
argc = tokenizebyseparator(strTemp, "=");
if (argc == 2) {
switch (argv(0)) {
case "COLOR":
fntNew.vecColor = stov(argv(1)) / 255;
@ -60,14 +63,20 @@ Font_Load(string strFile, font_s &fntNew)
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.iScale = (int)stof(argv(1));
fntNew.iScaleY = fntNew.iScaleX = stoi(argv(1));
break;
case "PATH":
strFontPath = argv(1);
break;
case "FLAGS":
fntNew.iFlags = (int)stof(argv(1));
fntNew.iFlags = stoi(argv(1));
break;
default:
break;
@ -79,19 +88,19 @@ Font_Load(string strFile, font_s &fntNew)
error(sprintf("[MENU] Cannot load font file %s!", strFile));
}
fntNew.iID = (int)loadfont("", strFontPath, ftos((float)fntNew.iScale), -1, 0, 0);
fntNew.iID = (int)loadfont("", strFontPath, ftos((float)fntNew.iScaleY), -1, 0, 0);
#endif
}
void
Font_DrawText (vector vecOrigin, string strText, font_s fnt)
Font_DrawText(vector vecOrigin, string strText, font_s fnt)
{
drawfont = (float)fnt.iID;
drawstring(vecOrigin, strText, [fnt.iScale, fnt.iScale], fnt.vecColor, fnt.flAlpha, (float)fnt.iFlags);
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)
Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, int iAlignFlags)
{
drawfont = (float)fnt.iID;
drawtextfield(vecOrigin, vecSize, (float)iAlignFlags, strText);

View File

@ -85,14 +85,12 @@ void
CUIButton::SetTitle(string strName)
{
vector newsize;
int scale;
m_strTitle = strName;
m_strTitleActive = sprintf("^3%s", m_strTitle);
drawfont = g_fntDefault.iID;
scale = g_fntDefault.iScale;
newsize[0] = stringwidth(m_strTitle, TRUE, [scale, scale]) + 16;
newsize[0] = stringwidth(m_strTitle, TRUE, [g_fntDefault.iScaleX, g_fntDefault.iScaleY]) + 16;
newsize[1] = 24;
SetSize(newsize);
}

View File

@ -47,7 +47,7 @@ void CUILabel::SetTitle (string strName)
/* hack, add 2 just to make sure it doesn't immediately wrap. bug
* in engines' textfield thing in combo with ttf. */
SetSize([2 + stringwidth(m_strTitle, TRUE, [g_fntDefault.iScale, g_fntDefault.iScale]), 16]);
SetSize([2 + stringwidth(m_strTitle, TRUE, [g_fntDefault.iScaleX, g_fntDefault.iScaleY]), 16]);
}
void CUILabel::Draw(void)
{

View File

@ -60,7 +60,7 @@ vector CUITabView::GetSize(void)
void CUITabView::SetTitle (string strName)
{
m_strTitle = strName;
SetSize([stringwidth(m_strTitle, TRUE, [g_fntDefault.iScale, g_fntDefault.iScale]), 16]);
SetSize([stringwidth(m_strTitle, TRUE, [g_fntDefault.iScaleX, g_fntDefault.iScaleY]), 16]);
}
void CUITabView::Draw(void)
{