27 #include "../ui_render.h"
28 #include "../ui_main.h"
29 #include "../ui_behaviour.h"
30 #include "../ui_input.h"
32 #include "../../client.h"
33 #include "../../battlescape/cl_hud.h"
34 #include "../../renderer/r_draw.h"
35 #include "../../../shared/parse.h"
37 #include "../../../common/scripts_lua.h"
88 for (
int j = 0; j < image->
maxlevel; j++)
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];
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];
240 Vector2Set(gridSize, round(radar.
w * ratioConversion), round(radar.
h * ratioConversion));
244 "jpg",
"png",
nullptr
252 if (
FS_CheckFile(
"pics/radars/%s_%i.%s", imageName, level, *ext) > 0)
269 float distAB, distBC;
279 radar.
x = nodepos[0] + node->
box.
size[0] / 2;
280 radar.
y = nodepos[1] + node->
box.
size[1] / 2;
299 Com_sprintf(imagePath,
sizeof(imagePath),
"radars/%s_%i", tile->
name, i + 1);
328 if (tile->
mapX < min[0])
330 if (tile->
mapY < min[1])
342 tile->
mapX += min[0];
343 tile->
mapY += min[1];
363 const float radarLength = std::max(1.0
f, fabsf(gridSize[0]));
364 const float radarHeight = std::max(1.0
f, fabsf(gridSize[1]));
366 const float gridFactorX = radar.
w / radarLength;
367 const float gridFactorY = radar.
h / radarHeight;
377 radar.
x -= (radar.
w / 2);
378 radar.
y -= (radar.
h / 2);
387 const int actorLevel = le->
pos[2];
391 if (actorLevel < cl_worldlevel->integer)
426 const float size = 10;
427 const int tileSize = 28;
434 if (image ==
nullptr)
439 vertices[0][0] = - size * 4;
440 vertices[0][1] = + 0;
441 vertices[1][0] = + size * 4;
442 vertices[1][1] = + 0;
443 vertices[2][0] = + size * 4;
444 vertices[2][1] = - size * 4;
445 vertices[3][0] = - size * 4;
446 vertices[3][1] = - size * 4;
447 coords[0][0] = (7) / 128.0
f;
448 coords[0][1] = (37 + 63) / 128.0
f;
449 coords[1][0] = (7 + 114) / 128.0
f;
450 coords[1][1] = (37 + 63) / 128.0
f;
451 coords[2][0] = (7 + 114) / 128.0
f;
452 coords[2][1] = (37) / 128.0
f;
453 coords[3][0] = (7) / 128.0
f;
454 coords[3][1] = (37) / 128.0
f;
457 for (i = 0; i < 4; i++) {
458 const float dx = vertices[
i][0];
459 const float dy = vertices[
i][1];
460 vertices[
i][0] = pos[0] + dx * sin(pov) + dy * cos(pov);
461 vertices[
i][1] = pos[1] + dx * cos(pov) - dy * sin(pov);
481 vertices[0][0] = -
size;
482 vertices[0][1] = +
size;
483 vertices[1][0] = +
size;
484 vertices[1][1] = +
size;
485 vertices[2][0] = +
size;
486 vertices[2][1] = -
size;
487 vertices[3][0] = -
size;
488 vertices[3][1] = -
size;
489 coords[0][0] = (tilePos) / 128.0
f;
490 coords[0][1] = (5 + tileSize) / 128.0
f;
491 coords[1][0] = (tilePos + tileSize) / 128.0
f;
492 coords[1][1] = (5 + tileSize) / 128.0
f;
493 coords[2][0] = (tilePos + tileSize) / 128.0
f;
494 coords[2][1] = (5) / 128.0
f;
495 coords[3][0] = (tilePos) / 128.0
f;
496 coords[3][1] = (5) / 128.0
f;
499 for (i = 0; i < 4; i++) {
500 const float dx = vertices[
i][0];
501 const float dy = vertices[
i][1];
502 vertices[
i][0] = pos[0] + dx * sin(pov) + dy * cos(pov);
503 vertices[
i][1] = pos[1] + dx * cos(pov) - dy * sin(pov);
521 #ifdef RADARSIZE_DEBUG
523 static const vec4_t red = {1, 0, 0, 0.5};
526 static const vec4_t backgroundColor = {0.0, 0.0, 0.0, 1};
531 const float mapCoefX = (float) node->
box.
size[0] / (
float) mapWidth;
532 const float mapCoefY = (float) node->
box.
size[1] / (
float) mapHeight;
540 UI_DrawFill(pos[0], pos[1], mapWidth * mapCoefX, mapHeight * mapCoefY, backgroundColor);
541 #ifndef RADARSIZE_DEBUG
561 #ifdef RADARSIZE_DEBUG
562 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()));
577 assert(tile->
path[maxlevel]);
583 0, 0, 0, 0, tile->
path[maxlevel]);
584 #ifdef RADARSIZE_DEBUG
585 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]));
591 #ifdef RADARSIZE_DEBUG
592 UI_DrawFill(pos[0], pos[1], 100.0
f * mapCoefX, 100.0
f * mapCoefY, red);
617 #ifdef RADARSIZE_DEBUG
618 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]));
625 #ifndef RADARSIZE_DEBUG
637 const float mapCoefX = node->
box.
size[0] / mapWidth;
638 const float mapCoefY = node->
box.
size[1] / mapHeight;
679 behaviour->
name =
"radar";
#define VectorCopy(src, dest)
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
void UI_PopClipRect(void)
void onMouseUp(uiNode_t *node, int x, int y, int button) override
#define VectorSet(v, x, y, z)
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
const image_t * R_DrawImageArray(const vec2_t texcoords[4], const vec2_t verts[4], const image_t *image)
static void UI_RadarNodeGetActorColor(const le_t *le, vec4_t color)
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...
char * CL_GetConfigString(int index)
hudRadarImage_t images[MAX_MAPTILES]
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
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...
#define LE_IsInvisible(le)
#define LE_IsCivilian(le)
struct hudRadar_s hudRadar_t
void Com_Printf(const char *const fmt,...)
char * path[PATHFINDING_HEIGHT]
void onWindowClosed(uiNode_t *node) override
Each maptile must have an entry in the images array.
void R_Color(const vec4_t rgba)
Change the color to given value.
void Com_Error(int code, const char *fmt,...)
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
static void UI_FreeRadarImages(void)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
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.
#define Vector4Set(v, r, g, b, a)
#define Vector2Set(v, x, y)
#define LE_IsSelected(le)
SharedPtr< uiNode > UINodePtr
const struct image_s * UI_LoadImage(const char *name)
Searches for an image in the image array.
static bool UI_CheckRadarImage(const char *imageName, const int level)
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_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
static void UI_GetRadarWidth(const uiNode_t *node, vec2_t gridSize)
Get the width of radar.
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
#define Vector2Dist(a, b)
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
#define VectorAdd(a, b, dest)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
void onWindowOpened(uiNode_t *node, linkedList_t *params) override
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
node behaviour, how a node work
static void UI_RadarNodeDrawArrays(const vec4_t color, vec2_t coords[4], vec2_t vertices[4], const image_t *image)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
static void UI_RadarNodeDrawItem(const le_t *le, const vec3_t pos)
#define Vector2Copy(src, dest)
void UI_PushClipRect(int x, int y, int width, int height)
const float directionAngles[CORE_DIRECTIONS]
void draw(uiNode_t *node) override
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
Called when the node is captured by the mouse.
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
static char const *const imageExtensions[]
static void UI_RadarNodeDrawActor(const le_t *le, const vec3_t pos)
#define VectorSubtract(a, b, dest)
void R_CleanupDepthBuffer(int x, int y, int width, int height)
"Clean up" the depth buffer into a rect
void onMouseDown(uiNode_t *node, int x, int y, int button) override
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)
struct hudRadarImage_s hudRadarImage_t
Each maptile must have an entry in the images array.
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...