UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_render.cpp File Reference
#include "ui_main.h"
#include "ui_font.h"
#include "ui_render.h"
#include "../client.h"
#include "../cl_video.h"
#include "../renderer/r_draw.h"
#include "../renderer/r_misc.h"
#include "../renderer/r_state.h"
Include dependency graph for ui_render.cpp:

Go to the source code of this file.

Functions

void UI_DrawFill (int x, int y, int w, int h, const vec4_t color)
 Fills a box of pixels with a single color.
void UI_DrawRect (int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
void UI_PushClipRect (int x, int y, int width, int height)
void UI_PopClipRect (void)
void UI_Transform (const vec3_t transform, const vec3_t rotate, const vec3_t scale)
 Pushes a new matrix, normalize to current resolution and move, rotate and scale the matrix to the given values.
const struct image_s * UI_LoadImage (const char *name)
 Searches for an image in the image array.
const struct image_s * UI_LoadWrappedImage (const char *name)
 Searches for a wrapped image in the image array.
void UI_DrawNormImage (bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const image_t *image)
 Draw a normalized (to the screen) image.
const image_tUI_DrawNormImageByName (bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const char *name)
 Draws an image or parts of it.
void UI_DrawPanel (const vec2_t pos, const vec2_t size, const char *texture, int texX, int texY, const int panelDef[7])
 draw a panel from a texture as we can see on the image
void UI_DrawBorderedPanel (const vec2_t pos, const vec2_t size, const char *texture, int texX, int texY, int texW, int texH, int border)
 draw a panel from a texture as we can see on the image
int UI_DrawStringInBox (const char *fontID, align_t align, int x, int y, int width, int height, const char *text, longlines_t method)
 draw a line into a bounding box
int UI_DrawString (const char *fontID, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char *c, int boxHeight, int scrollPos, int *curLine, bool increaseLine, longlines_t method)
void UI_EnableFlashing (const vec4_t flashingColor, float speed)
 Enables flashing effect for UI nodes.
void UI_DisableFlashing (void)
 Disables flashing effect for UI nodes.

Function Documentation

◆ UI_DisableFlashing()

void UI_DisableFlashing ( void )

Disables flashing effect for UI nodes.

Definition at line 417 of file ui_render.cpp.

References R_TexOverride().

Referenced by uiButtonNode::draw().

◆ UI_DrawBorderedPanel()

void UI_DrawBorderedPanel ( const vec2_t pos,
const vec2_t size,
const char * texture,
int texX,
int texY,
int texW,
int texH,
int border )

draw a panel from a texture as we can see on the image

Parameters
[in]posPosition of the output panel
[in]sizeSize of the output panel
[in]textureTexture contain the template of the panel
[in]texX,texYPosition of the panel template into the texture
[in]texW,texHWidth/height of the panel template into the texture
[in]borderSize of unscalable border From the first to the last: left width, mid width, right width, top height, mid height, bottom height, and margin
Todo
can we improve the code? is it need?

Definition at line 293 of file ui_render.cpp.

References UI_DrawNormImage(), and UI_LoadImage().

Referenced by UI_DrawSpriteInBox().

◆ UI_DrawFill()

◆ UI_DrawNormImage()

void UI_DrawNormImage ( bool flip,
float x,
float y,
float w,
float h,
float sh,
float th,
float sl,
float tl,
const image_t * image )

Draw a normalized (to the screen) image.

Parameters
[in]flipFlip the icon rendering (horizontal)
[in]x,yThe coordinates (normalized)
[in]wThe width (normalized)
[in]hThe height (normalized)
[in]shThe s part of the texture coordinate (horizontal)
[in]thThe t part of the texture coordinate (horizontal)
[in]slThe s part of the texture coordinate (vertical)
[in]tlThe t part of the texture coordinate (vertical)
[in]imageThe image to draw

Definition at line 126 of file ui_render.cpp.

References image_t::height, R_DrawImageArray(), viddef, and image_t::width.

Referenced by uiImageNode::draw(), uiMaterialEditorNode::draw(), uiSelectBoxNode::draw(), uiTextureNode::draw(), uiVScrollbarNode::draw(), uiSelectBoxNode::drawOverWindow(), UI_DrawBorderedPanel(), UI_DrawNormImageByName(), and UI_DrawPanel().

◆ UI_DrawNormImageByName()

const image_t * UI_DrawNormImageByName ( bool flip,
float x,
float y,
float w,
float h,
float sh,
float th,
float sl,
float tl,
const char * name )

Draws an image or parts of it.

Parameters
[in]flipFlip the icon rendering (horizontal)
[in]x,yposition to draw the image to
[in]wWidth of the image
[in]hHeight of the image
[in]shRight x corner coord of the square to draw
[in]thLower y corner coord of the square to draw
[in]slLeft x corner coord of the square to draw
[in]tlUpper y corner coord of the square to draw
[in]nameThe name of the image - relative to base/pics
See also
R_RegisterImage
Note
All these parameter are normalized to VID_NORM_WIDTH and VID_NORM_HEIGHT they are adjusted in this function

Definition at line 203 of file ui_render.cpp.

References Com_Printf(), name, UI_DrawNormImage(), and UI_LoadImage().

Referenced by uiRadarNode::draw(), uiRadioButtonNode::draw(), uiTBarNode::draw(), UI_DrawItem(), UI_DrawNormImageByName_(), and UI_DrawSpriteInBox().

◆ UI_DrawPanel()

void UI_DrawPanel ( const vec2_t pos,
const vec2_t size,
const char * texture,
int texX,
int texY,
const int panelDef[7] )

draw a panel from a texture as we can see on the image

Parameters
[in]posPosition of the output panel
[in]sizeSize of the output panel
[in]textureTexture contain the template of the panel
[in]texXPosition x of the panel template into the texture
[in]texYPosition y of the panel template into the texture
[in]panelDefArray of seven elements define the panel template used in the texture. From the first to the last: left width, mid width, right width, top height, mid height, bottom height, and margin
Todo
can we improve the code? is it need?
Todo
merge texX and texY here

Definition at line 230 of file ui_render.cpp.

References UI_DrawNormImage(), and UI_LoadImage().

Referenced by UI_DrawSpriteInBox().

◆ UI_DrawRect()

void UI_DrawRect ( int x,
int y,
int w,
int h,
const vec4_t color,
float lineWidth,
int pattern )

◆ UI_DrawString()

◆ UI_DrawStringInBox()

int UI_DrawStringInBox ( const char * fontID,
align_t align,
int x,
int y,
int width,
int height,
const char * text,
longlines_t method )

draw a line into a bounding box

Parameters
[in]fontIDthe font id (defined in ufos/fonts.ufo)
[in]alignAlign of the text into the bounding box
[in]x,yCurrent position of the bounded box
[in]widthCurrent width of the bounded box
[in]heightCurrent height of the bounded box
[in]textThe string to draw
[in]methodTruncation method
Note
the x, y, width and height values are all normalized here - don't use the viddef settings for drawstring calls - make them all relative to VID_NORM_WIDTH and VID_NORM_HEIGHT
Todo

remove the use of UI_DrawString

test the code for multiline?

fix problem with truncation (maybe problem into UI_DrawString)

Definition at line 359 of file ui_render.cpp.

References UI_DrawString().

Referenced by uiButtonNode::draw(), uiRadarNode::draw(), uiStringNode::draw(), uiTextEntryNode::draw(), uiWindowNode::draw(), and uiTextListNode::drawText().

◆ UI_EnableFlashing()

void UI_EnableFlashing ( const vec4_t flashingColor,
float speed )

Enables flashing effect for UI nodes.

Parameters
[in]flashingColorColor to fade to and back
[in]speedSpeed of flashing effect

Definition at line 406 of file ui_render.cpp.

References cls, M_PI, R_TexOverride(), and Vector4Copy.

Referenced by uiButtonNode::draw().

◆ UI_LoadImage()

const struct image_s * UI_LoadImage ( const char * name)

Searches for an image in the image array.

Parameters
[in]nameThe name of the image relative to pics/
Note
name may not be null and has to be longer than 4 chars
Returns
nullptr on error or image_t pointer on success
See also
R_FindImage

Definition at line 91 of file ui_render.cpp.

References it_pic, name, R_FindImage(), r_noTexture, and va().

Referenced by uiImageNode::draw(), uiSelectBoxNode::draw(), uiVScrollbarNode::draw(), uiSelectBoxNode::drawOverWindow(), uiImageNode::onLoaded(), UI_AutoGenerateSprite(), UI_DrawBorderedPanel(), UI_DrawNormImageByName(), UI_DrawPanel(), and UI_RadarNodeDrawActor().

◆ UI_LoadWrappedImage()

const struct image_s * UI_LoadWrappedImage ( const char * name)

Searches for a wrapped image in the image array.

Parameters
[in]nameThe name of the image relative to pics/
Note
name may not be null and has to be longer than 4 chars
Returns
nullptr on error or image_t pointer on success
See also
R_FindImage

Definition at line 106 of file ui_render.cpp.

References it_wrappic, name, R_FindImage(), r_noTexture, and va().

Referenced by uiTextureNode::draw().

◆ UI_PopClipRect()

◆ UI_PushClipRect()

void UI_PushClipRect ( int x,
int y,
int width,
int height )

◆ UI_Transform()

void UI_Transform ( const vec3_t transform,
const vec3_t rotate,
const vec3_t scale )

Pushes a new matrix, normalize to current resolution and move, rotate and scale the matrix to the given values.

Note
Will pop the matrix if transform is nullptr
Parameters
transformTranslation (if nullptr the matrix is removed from stack)
rotateRotation
scaleScale
See also
R_Transform
R_PopMatrix
R_PushMatrix

Definition at line 68 of file ui_render.cpp.

References R_PopMatrix(), R_PushMatrix(), R_Transform(), scale, VectorCopy, and viddef.

Referenced by uiLineChartNode::draw(), and SEQ_Render().