tiny fixes (note: also removed workarounds, jogi update fteqcc).
added drawlame3dtext function as per jogi's request. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3987 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
9acd5a61a6
commit
ad32917970
3 changed files with 72 additions and 7 deletions
|
@ -466,6 +466,12 @@ void() editor_spline_add =
|
|||
local int i;
|
||||
local float ctime, stime;
|
||||
|
||||
local vector tdir;
|
||||
tdir_x = 16 * cos(time);
|
||||
tdir_y = 16 * sin(time);
|
||||
drawlame3dtext("charset", tdir*(-33/2), tdir, '0 0 -16', "hello jogi\ndoes this string appear for you?", '1 1 1', 1);
|
||||
drawlame3dtext("charset", tdir*(33/2), -tdir, '0 0 -16', "hello jogi\ndoes this string appear for you?", '1 1 1', 1);
|
||||
|
||||
if (splinefile < 0)
|
||||
spline_init();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ typedef struct
|
|||
vector mousediff;
|
||||
} menu_t;
|
||||
|
||||
void(menu_t menu, string fieldname, vector pos, float *value, float minv, float maxv) sliderf_widgit =
|
||||
void(menu_t *menu, string fieldname, vector pos, float *value, float minv, float maxv) sliderf_widgit =
|
||||
{
|
||||
local vector rpos, spos, col;
|
||||
local float f;
|
||||
|
@ -84,7 +84,6 @@ void(menu_t menu, string fieldname, vector pos, float *value, float minv, float
|
|||
}
|
||||
};
|
||||
|
||||
#pragma wrasm 1
|
||||
void(menu_t *menu, string fieldname, vector pos, float *value) sliderf_fixed_widgit =
|
||||
{
|
||||
local vector rpos, spos, col;
|
||||
|
@ -148,7 +147,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value) sliderf_fixed_wid
|
|||
if (key == 512)
|
||||
{
|
||||
f = *value;
|
||||
int*tmp=(int*)menu;tmp[0] = (int)value; //fteqcc bug - really menu->current = value;
|
||||
menu->current = value;
|
||||
print(sprintf("test thing: %i %i\n", menu->current, value));
|
||||
mp_x = spos_x + 4;
|
||||
*mpp = mp;
|
||||
|
@ -159,9 +158,8 @@ void(menu_t *menu, string fieldname, vector pos, float *value) sliderf_fixed_wid
|
|||
*value = *value - 0.1;
|
||||
}
|
||||
};
|
||||
#pragma wrasm 0
|
||||
|
||||
void(menu_t menu, string fieldname, vector pos, int *value, int minv, int maxv) slideri_widgit =
|
||||
void(menu_t *menu, string fieldname, vector pos, int *value, int minv, int maxv) slideri_widgit =
|
||||
{
|
||||
local vector rpos, spos, col;
|
||||
local int f;
|
||||
|
@ -284,3 +282,64 @@ void(string fieldname, vector pos, vector *mousepos_in, float *value, float key)
|
|||
}
|
||||
};
|
||||
|
||||
void(string shader, vector org, vector s, vector t, string text, vector col, float alph) drawlame3dtext =
|
||||
{
|
||||
/*the shader must be a 16*16 grid of 256 chars*/
|
||||
vector st = draw_getimagesize(shader);
|
||||
vector pos = org;
|
||||
float chr;
|
||||
float idx;
|
||||
vector tc0,tc1,tc2,tc3;
|
||||
|
||||
//with GL_LINEAR sampling, the sample value is interpolated from the nearby two pixels
|
||||
//this means that we must move the texture coord inwards by half of a pixel to avoid any bleed through into neighbouring chars
|
||||
//(with nearest sampling, this isn't needed)
|
||||
if (st != '0 0 0')
|
||||
{
|
||||
st_x = 0.5 / st_x;
|
||||
st_y = 0.5 / st_y;
|
||||
}
|
||||
|
||||
//precompute the st offset for each vertex
|
||||
tc0_x = (0.0/16) + st_x;
|
||||
tc1_x = (1.0/16) - st_x;
|
||||
tc2_x = (1.0/16) - st_x;
|
||||
tc3_x = (0.0/16) + st_x;
|
||||
tc0_y = (0.0/16) + st_y;
|
||||
tc1_y = (0.0/16) + st_y;
|
||||
tc2_y = (1.0/16) - st_y;
|
||||
tc3_y = (1.0/16) - st_y;
|
||||
|
||||
/*begin looks up the shader and is thus potentially expensive, fte requires it only once per batch of polygons.*/
|
||||
R_BeginPolygon(shader);
|
||||
|
||||
while((chr = text[idx]))
|
||||
{
|
||||
idx+=1;
|
||||
|
||||
/*handle new lines*/
|
||||
if (chr == '\n')
|
||||
{
|
||||
org += t;
|
||||
pos = org;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*skip spaces*/
|
||||
if (chr != ' ')
|
||||
{
|
||||
/*its a grid, so the top-left texturecoord should be easy to calculate*/
|
||||
/*weirdly though, qc has no (direct) modulo functionality, not even as a builtin, so this code is ugly*/
|
||||
st_x = (chr & 15) / 16;
|
||||
st_y = floor(chr/16) / 16;
|
||||
|
||||
/*plot the poly's point and emit the quad*/
|
||||
R_PolygonVertex(pos , st + tc0, col, alph);
|
||||
R_PolygonVertex(pos + s, st + tc1, col, alph);
|
||||
R_PolygonVertex(pos+s+t, st + tc2, col, alph);
|
||||
R_PolygonVertex(pos + t, st + tc3, col, alph);
|
||||
R_EndPolygon();
|
||||
}
|
||||
pos += s;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ void(textfield_t *fld) textfield_clean =
|
|||
fld->cursorcol = 0i;
|
||||
fld->dirty = TRUE; //because its changed
|
||||
};
|
||||
#pragma wrasm 1
|
||||
|
||||
/*fill a text field with data from a string. new lines are supported, but leading tabs and spaces will be stripped*/
|
||||
void(textfield_t *fld, string text) textfield_fill =
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ if (term) if (text[term-1] == '\r') term--;
|
|||
}
|
||||
fld->dirty = TRUE;
|
||||
};
|
||||
#pragma wrasm 0
|
||||
|
||||
|
||||
/*draws the text field on the screen at a given position.
|
||||
there's no size argument, so make sure data doesn't cause the display to overflow intended area (personally I'm just going to put it at the bottom+right of the screen)*/
|
||||
|
|
Loading…
Reference in a new issue