29 #include "../idlib/precompiled.h"
53 for (
int i = 0;
i <
c;
i++) {
89 if ( num >= 0 && num <
fonts.
Num() ) {
201 if ( ow <= 0.0
f || oh <= 0.0
f ) {
206 *w -= clipRect->
x - *
x;
208 }
else if (*x > clipRect->
x + clipRect->
w) {
209 *x = *w = *y = *h = 0;
212 *h -= clipRect->
y - *
y;
214 }
else if (*y > clipRect->
y + clipRect->
h) {
215 *x = *w = *y = *h = 0;
217 if (*w > clipRect->
w) {
218 *w = clipRect->
w - *x + clipRect->
x;
219 }
else if (*x + *w > clipRect->
x + clipRect->
w) {
220 *w = clipRect->
Right() - *
x;
222 if (*h > clipRect->
h) {
223 *h = clipRect->
h - *y + clipRect->
y;
224 }
else if (*y + *h > clipRect->
y + clipRect->
h) {
228 if ( s1 && s2 && t1 && t2 && ow > 0.0
f ) {
229 float ns1, ns2, nt1, nt2;
231 float u = ( *x - ox ) / ow;
232 ns1 = *s1 * ( 1.0f - u ) + *s2 * ( u );
235 u = ( *x + *w - ox ) / ow;
236 ns2 = *s1 * ( 1.0f - u ) + *s2 * ( u );
239 u = ( *y - oy ) / oh;
240 nt1 = *t1 * ( 1.0f - u ) + *t2 * ( u );
243 u = ( *y + *h - oy ) / oh;
244 nt2 = *t1 * ( 1.0f - u ) + *t2 * ( u );
254 return (*w == 0 || *h == 0) ?
true :
false;
296 verts[1].
xyz[0] = x +
w;
310 verts[2].
xyz[0] = x +
w;
311 verts[2].
xyz[1] = y + h;
325 verts[3].
xyz[1] = y + h;
364 float s0, s1, t0, t1;
411 float s0, s1, t0, t1;
445 if ( angle == 0.0
f &&
ClippedCoords( &x, &y, &w, &h, &s0, &t0, &s1, &t1 ) ) {
478 verts[1].
xyz[0] = x +
w;
492 verts[2].
xyz[0] = x +
w;
493 verts[2].
xyz[1] = y + h;
507 verts[3].
xyz[1] = y + h;
539 origTrans.
x = x+(w/2);
540 origTrans.
y = y+(h/2);
551 rotz[1][0] = -sinAng;
553 for(
int i = 0;
i < 4;
i++) {
555 verts[
i].
xyz -= origTrans;
561 verts[
i].
xyz += origTrans;
570 if ( color.
w == 0.0f ) {
587 if ( color.
w == 0.0f ) {
606 if ( color.
w == 0.0f ) {
686 if ( text && color.
w != 0.0f ) {
687 const unsigned char *
s = (
const unsigned char*)text;
689 memcpy(&newColor[0], &color[0],
sizeof(
idVec4));
691 if (limit > 0 && len > limit) {
695 while (s && *s && count < len) {
713 newColor[3] = color[3];
715 if (cursor == count || cursor == count+1) {
716 float partialSkip = ((glyph->
xSkip * useScale) + adjust) / 5.0f;
717 if ( cursor == count ) {
729 float yadj = useScale * glyph->
top;
732 if (cursor == count) {
735 x += (glyph->
xSkip * useScale) + adjust;
751 if ( width != 0.0
f && height != 0.0
f ) {
763 glyph = &font->
glyphs[(
const unsigned char)c];
773 if ( text ==
NULL ) {
779 for ( i = 0; text[
i] !=
'\0' && i < limit; i++ ) {
783 width += glyphs[((
const unsigned char *)text)[
i]].
xSkip;
787 for ( i = 0; text[
i] !=
'\0'; i++ ) {
791 width += glyphs[((
const unsigned char *)text)[
i]].
xSkip;
803 const char *
s = text;
811 if (limit > 0 && len > limit) {
816 while (s && *s && count < len) {
822 glyph = &font->
glyphs[*(
const unsigned char*)s];
823 if (max < glyph->
height) {
858 const char *
p, *textPtr, *newLinePtr;
860 int len, textWidth, newLine, newLineWidth;
933 float yadj = useScale * glyph2->
top;
938 const char *
p, *textPtr, *newLinePtr;
940 int len, newLine, newLineWidth,
count;
947 float cursorSkip = ( cursor >= 0 ? charSkip : 0 );
949 bool lineBreak, wordBreak;
956 if (!calcOnly && !(text && *text)) {
966 y = lineSkip + rectDraw.
y;
982 if ( *p ==
'\n' || *p ==
'\r' || *p ==
'\0' ) {
984 if ((*p ==
'\n' && *(p + 1) ==
'\r') || (*p ==
'\r' && *(p + 1) ==
'\n')) {
995 if ( !lineBreak && ( textWidth + nextCharWidth ) > rectDraw.
w ) {
998 if ( len > 0 && newLine == 0 ) {
1001 newLineWidth = textWidth;
1004 }
else if ( lineBreak || ( wrap && (*p ==
' ' || *p ==
'\t') ) ) {
1008 newLineWidth = textWidth;
1011 if ( lineBreak || wordBreak ) {
1012 float x = rectDraw.
x;
1015 x = rectDraw.
x + rectDraw.
w - newLineWidth;
1017 x = rectDraw.
x + (rectDraw.
w - newLineWidth) / 2;
1020 if ( wrap || newLine > 0 ) {
1021 buff[newLine] =
'\0';
1026 if ( wordBreak && cursor >= newLine && newLine == len ) {
1032 count +=
DrawText(x, y, textScale, color, buff, 0, 0, 0, cursor);
1035 if ( cursor < newLine ) {
1037 }
else if ( cursor >= 0 ) {
1038 cursor -= ( newLine + 1 );
1045 if ( ( limit && count > limit ) || *p ==
'\0' ) {
1051 if ( !calcOnly && y > rectDraw.
Bottom() ) {
1058 breaks->
Append(p - text);
1087 static int index = 0;
1088 static char str[ 8 ][ 48 ];
1093 index = (index + 1)&7;
void SetTransformInfo(const idVec3 &origin, const idMat3 &mat)
virtual void SetColor(const idVec4 &rgba)=0
const int C_COLOR_DEFAULT
idCVarSystem * cvarSystem
glyphInfo_t glyphs[GLYPHS_PER_FONT]
static idVec4 colorYellow
float GetFloat(void) const
void DrawEditCursor(float x, float y, float scale)
GLenum GLenum GLenum GLenum GLenum scale
idCVar gui_mediumFontLimit("gui_mediumFontLimit","0.60", CVAR_GUI|CVAR_ARCHIVE,"")
void DrawMaterialRect(float x, float y, float w, float h, float size, const idMaterial *mat, const idVec4 &color)
idRenderSystem * renderSystem
const idMaterial * whiteImage
virtual bool RegisterFont(const char *fontName, fontInfoEx_t &font)=0
void SetGranularity(int newgranularity)
static idVec4 colorOrange
fontInfoEx_t * activeFont
volatile int com_ticNumber
void PushClipRect(float x, float y, float w, float h)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
fontInfo_t fontInfoMedium
static idVec4 & ColorForIndex(int i)
bool ClippedCoords(float *x, float *y, float *w, float *h)
void SetFontByScale(float scale)
static idVec4 colorPurple
int Icmp(const char *text) const
int FindFont(const char *name)
void DrawMaterialRotated(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0, float angle=0.0f)
GLuint GLuint GLsizei count
int MaxCharWidth(float scale)
const idMaterial * scrollBarImages[SCROLLBAR_COUNT]
int DrawText(const char *text, float textScale, int textAlign, idVec4 color, idRectangle rectDraw, bool wrap, int cursor=-1, bool calcOnly=false, idList< int > *breaks=NULL, int limit=0)
GLubyte GLubyte GLubyte GLubyte w
idRegion * GetTextRegion(const char *text, float textScale, idRectangle rectDraw, float xStart, float yStart)
int TextWidth(const char *text, float scale, int limit)
static int FtoiFast(float f)
static float Sin(float a)
void DrawFilledRect(float x, float y, float width, float height, const idVec4 &color)
virtual const char * GetCVarString(const char *name) const =0
bool IsIdentity(const float epsilon=MATRIX_EPSILON) const
void DrawStretchPic(float x, float y, float w, float h, float s0, float t0, float s1, float t1, const idMaterial *mat)
void GetTransformInfo(idVec3 &origin, idMat3 &mat)
static void Copynz(char *dest, const char *src, int destsize)
idCVar gui_smallFontLimit("gui_smallFontLimit","0.30", CVAR_GUI|CVAR_ARCHIVE,"")
int MaxCharHeight(float scale)
char * String(void) const
virtual void Printf(const char *fmt,...) id_attribute((format(printf
virtual void DrawStretchPic(const idDrawVert *verts, const glIndex_t *indexes, int vertCount, int indexCount, const idMaterial *material, bool clip=true, float min_x=0.0f, float min_y=0.0f, float max_x=640.0f, float max_y=480.0f)=0
GLenum GLsizei GLsizei height
void DrawCursor(float *x, float *y, float size)
idDeclManager * declManager
int CharWidth(const char c, float scale)
idList< idRectangle > clipRects
int Append(const type &obj)
GLdouble GLdouble GLdouble r
void AdjustCoords(float *x, float *y, float *w, float *h)
bool RemoveIndex(int index)
void PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, const idMaterial *hShader)
const char * c_str(void) const
const idMaterial * cursorImages[CURSOR_COUNT]
int TextHeight(const char *text, float scale, int limit)
static idList< fontInfoEx_t > fonts
void SetSort(float s) const
char * va(const char *fmt,...)
void SetSize(float width, float height)
void Replace(const char *old, const char *nw)
void DrawStretchPicRotated(float x, float y, float w, float h, float s0, float t0, float s1, float t1, const idMaterial *mat, float angle=0.0f)
void DrawMaterial(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0)
const idMaterial * GetScrollBarImage(int index)
int sprintf(idStr &string, const char *fmt,...)
void DrawRect(float x, float y, float width, float height, float size, const idVec4 &color)
static float Cos(float a)
static bool CharIsPrintable(int c)