40typedef struct hudRadarImage_s {
60typedef struct hudRadar_s {
85 for (
int i = 0;
i <
radar.numImages;
i++) {
88 for (
int j = 0; j < image->
maxlevel; j++)
105 const float mapMidX =
cl.mapData->mapBox.getWidthX() * 0.5;
106 const float mapMidY =
cl.mapData->mapBox.getWidthY() * 0.5;
120 if (token[0] ==
'-') {
133 image->
isTile = pos && pos[0];
139 for (
int i = 0;
i < 3;
i++) {
145 image->
gridX = sh[0];
146 image->
gridY = sh[1];
151 if (
radar.gridMin[0] > sh[0])
152 radar.gridMin[0] = sh[0];
153 if (
radar.gridMin[1] > sh[1])
154 radar.gridMin[1] = sh[1];
170 float ratioConversion;
171 const int ROUNDING_PIXEL = 1;
180 secondTileGridX =
radar.gridMin[0] + 1000;
181 secondTileGridY =
radar.gridMin[1] + 1000;
187 for (
int j = 0; j <
radar.numImages; j++) {
203 tileHeight[1] = image->
height;
208 tileHeight[0] = image->
height;
209 tileWidth[0] = image->
width;
210 }
else if (image->
gridY < secondTileGridY)
211 secondTileGridY = image->
gridY;
216 tileWidth[1] = image->
width;
218 }
else if (image->
gridX < secondTileGridX)
219 secondTileGridX = image->
gridX;
225 tileHeight[1] = tileHeight[0];
227 tileWidth[1] = tileWidth[0];
233 ratioConversion = std::max((secondTileGridX -
radar.gridMin[0]) / (tileWidth[0] - ROUNDING_PIXEL),
234 (secondTileGridY -
radar.gridMin[1]) / (tileHeight[0] - ROUNDING_PIXEL));
237 radar.w = floor((
radar.gridMax[0] -
radar.gridMin[0]) / ratioConversion) + tileWidth[1];
238 radar.h = floor((
radar.gridMax[1] -
radar.gridMin[1]) / ratioConversion) + tileHeight[1];
244#ifdef HAVE_LIBWEBP_DECODE_H
274 float distAB, distBC;
288 for (j = 0; j <
radar.numImages; j++) {
304 Com_sprintf(imagePath,
sizeof(imagePath),
"radars/%s_%i", tile->
name,
i + 1);
317 tile->
mapX =
cl.mapData->mapBox.getMinX();
318 tile->
mapY =
cl.mapData->mapBox.getMinY();
319 tile->
mapWidth =
cl.mapData->mapBox.getWidthX();
331 for (j = 0; j <
radar.numImages; j++) {
333 if (tile->
mapX < min[0])
335 if (tile->
mapY < min[1])
343 min[0] =
cl.mapData->mapBox.getMinX() + (
cl.mapData->mapBox.getWidthX() - (max[0] - min[0])) * 0.5 - min[0];
344 min[1] =
cl.mapData->mapBox.getMinY() + (
cl.mapData->mapBox.getWidthY() - (max[1] - min[1])) * 0.5 - min[1];
345 for (j = 0; j <
radar.numImages; j++) {
347 tile->
mapX += min[0];
348 tile->
mapY += min[1];
368 const float radarLength = std::max(1.0f, fabsf(gridSize[0]));
369 const float radarHeight = std::max(1.0f, fabsf(gridSize[1]));
371 const float gridFactorX =
radar.w / radarLength;
372 const float gridFactorY =
radar.h / radarHeight;
373 for (j = 0; j <
radar.numImages; j++) {
376 image->
x = (image->
gridX -
radar.gridMin[0]) * gridFactorX;
392 const int actorLevel = le->
pos[2];
396 if (actorLevel < cl_worldlevel->integer)
404 }
else if (le->
team !=
cls.team) {
431 const float size = 10;
432 const int tileSize = 28;
439 if (image ==
nullptr)
444 vertices[0][0] = -
size * 4;
445 vertices[0][1] = + 0;
446 vertices[1][0] = +
size * 4;
447 vertices[1][1] = + 0;
448 vertices[2][0] = +
size * 4;
449 vertices[2][1] = -
size * 4;
450 vertices[3][0] = -
size * 4;
451 vertices[3][1] = -
size * 4;
452 coords[0][0] = (7) / 128.0f;
453 coords[0][1] = (37 + 63) / 128.0f;
454 coords[1][0] = (7 + 114) / 128.0f;
455 coords[1][1] = (37 + 63) / 128.0f;
456 coords[2][0] = (7 + 114) / 128.0f;
457 coords[2][1] = (37) / 128.0f;
458 coords[3][0] = (7) / 128.0f;
459 coords[3][1] = (37) / 128.0f;
462 for (
i = 0;
i < 4;
i++) {
463 const float dx = vertices[
i][0];
464 const float dy = vertices[
i][1];
465 vertices[
i][0] = pos[0] + dx * sin(pov) + dy * cos(pov);
466 vertices[
i][1] = pos[1] + dx * cos(pov) - dy * sin(pov);
486 vertices[0][0] = -
size;
487 vertices[0][1] = +
size;
488 vertices[1][0] = +
size;
489 vertices[1][1] = +
size;
490 vertices[2][0] = +
size;
491 vertices[2][1] = -
size;
492 vertices[3][0] = -
size;
493 vertices[3][1] = -
size;
494 coords[0][0] = (tilePos) / 128.0f;
495 coords[0][1] = (5 + tileSize) / 128.0f;
496 coords[1][0] = (tilePos + tileSize) / 128.0f;
497 coords[1][1] = (5 + tileSize) / 128.0f;
498 coords[2][0] = (tilePos + tileSize) / 128.0f;
499 coords[2][1] = (5) / 128.0f;
500 coords[3][0] = (tilePos) / 128.0f;
501 coords[3][1] = (5) / 128.0f;
504 for (
i = 0;
i < 4;
i++) {
505 const float dx = vertices[
i][0];
506 const float dy = vertices[
i][1];
507 vertices[
i][0] = pos[0] + dx * sin(pov) + dy * cos(pov);
508 vertices[
i][1] = pos[1] + dx * cos(pov) - dy * sin(pov);
526#ifdef RADARSIZE_DEBUG
528 static const vec4_t red = {1, 0, 0, 0.5};
531 static const vec4_t backgroundColor = {0.0, 0.0, 0.0, 1};
532 const float mapWidth =
cl.mapData->mapBox.getWidthX();
533 const float mapHeight =
cl.mapData->mapBox.getWidthY();
536 const float mapCoefX = (float) node->
box.
size[0] / (
float) mapWidth;
537 const float mapCoefY = (float) node->
box.
size[1] / (
float) mapHeight;
545 UI_DrawFill(pos[0], pos[1], mapWidth * mapCoefX, mapHeight * mapCoefY, backgroundColor);
546#ifndef RADARSIZE_DEBUG
551 if (!
cl.radarInitialized) {
553 cl.radarInitialized =
true;
561 if (
radar.gridWidth < 6)
563 if (
radar.gridHeight < 6)
564 radar.gridHeight = 6;
566#ifdef RADARSIZE_DEBUG
567 UI_DrawStringInBox(
"f_small",
ALIGN_UL, 50, textposy, 500, 25,
va(
"%fx%f %fx%f map",
cl.mapData->mapBox.getMinX(),
cl.mapData->mapBox.getMinY(),
cl.mapData->getMaxX(),
cl.mapData->getMaxY()));
574 for (
int i = 0;
i <
radar.numImages;
i++) {
582 assert(tile->
path[maxlevel]);
583 imagePos[0] =
radar.x + mapCoefX * (tile->
mapX -
cl.mapData->mapBox.getMinX());
584 imagePos[1] =
radar.y + mapCoefY * (tile->
mapY -
cl.mapData->mapBox.getMinY());
588 0, 0, 0, 0, tile->
path[maxlevel]);
589#ifdef RADARSIZE_DEBUG
590 UI_DrawStringInBox(
"f_small",
ALIGN_UL, 50, textposy, 500, 25,
va(
"%dx%d %dx%d %s", tile->
x, tile->
y, tile->
width, tile->
height, tile->
path[maxlevel]));
596#ifdef RADARSIZE_DEBUG
597 UI_DrawFill(pos[0], pos[1], 100.0f * mapCoefX, 100.0f * mapCoefY,
red);
608 itempos[0] = pos[0] + (le->
origin[0] -
cl.mapData->mapBox.getMinX()) * mapCoefX;
609 itempos[1] = pos[1] + (mapHeight - (le->
origin[1] -
cl.mapData->mapBox.getMinY())) * mapCoefY;
622#ifdef RADARSIZE_DEBUG
623 UI_DrawStringInBox(
"f_small",
ALIGN_UL, 50, textposy, 500, 25,
va(
"%fx%f %dx%d actor", le->
origin[0], le->
origin[1], le->
pos[0], le->
pos[1]));
630#ifndef RADARSIZE_DEBUG
640 const float mapWidth =
cl.mapData->mapBox.getWidthX();
641 const float mapHeight =
cl.mapData->mapBox.getWidthY();
642 const float mapCoefX = node->
box.
size[0] / mapWidth;
643 const float mapCoefY = node->
box.
size[1] / mapHeight;
650 pos[0] =
cl.mapData->mapBox.getMinX() + x / mapCoefX;
651 pos[1] =
cl.mapData->mapBox.getMaxY() - y / mapCoefY;
684 behaviour->
name =
"radar";
char * CL_GetConfigString(int index)
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
#define LE_IsInvisible(le)
#define LE_IsSelected(le)
#define LE_IsCivilian(le)
void R_Color(const vec4_t rgba)
Change the color to given value.
void onMouseUp(uiNode_t *node, int x, int y, int button) override
void onWindowClosed(uiNode_t *node) override
void onMouseDown(uiNode_t *node, int x, int y, int button) override
void draw(uiNode_t *node) override
void onWindowOpened(uiNode_t *node, linkedList_t *params) override
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
Called when the node is captured by the mouse.
Primary header for client.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
const float directionAngles[CORE_DIRECTIONS]
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Shared parsing functions.
const image_t * R_DrawImageArray(const vec2_t texcoords[4], const vec2_t verts[4], const image_t *image)
void R_CleanupDepthBuffer(int x, int y, int width, int height)
"Clean up" the depth buffer into a rect
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Header for lua script functions.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
hudRadarImage_t images[MAX_MAPTILES]
Each maptile must have an entry in the images array.
char * path[PATHFINDING_HEIGHT]
node behaviour, how a node work
Atomic structure used to define most of the UI.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...
SharedPtr< uiNode > UINodePtr
static void UI_RadarNodeDrawItem(const le_t *le, const vec3_t pos)
static char const *const imageExtensions[]
static bool UI_CheckRadarImage(const char *imageName, const int level)
static void UI_RadarNodeDrawArrays(const vec4_t color, vec2_t coords[4], vec2_t vertices[4], const image_t *image)
static void UI_InitRadar(const uiNode_t *node)
Calculate some radar values that won't change during a mission.
void UI_RegisterRadarNode(uiBehaviour_t *behaviour)
static void UI_BuildRadarImageList(const char *tiles, const char *pos)
Reads the tiles and position config strings and convert them into a linked list that holds the imagen...
static void UI_FreeRadarImages(void)
static void UI_RadarNodeGetActorColor(const le_t *le, vec4_t color)
static void UI_RadarNodeDrawActor(const le_t *le, const vec3_t pos)
static void UI_GetRadarWidth(const uiNode_t *node, vec2_t gridSize)
Get the width of radar.
const struct image_s * UI_LoadImage(const char *name)
Searches for an image in the image array.
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
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.
void UI_PushClipRect(int x, int y, int width, int height)
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_PopClipRect(void)
#define Vector4Set(v, r, g, b, a)
#define VectorSubtract(a, b, dest)
#define VectorCopy(src, dest)
#define Vector2Set(v, x, y)
#define Vector2Dist(a, b)
#define VectorAdd(a, b, dest)
#define VectorSet(v, x, y, z)
#define Vector2Copy(src, dest)