ui_node_radar.c File Reference

#include <math.h>
#include "ui_node_radar.h"
#include "ui_node_abstractnode.h"
#include "../ui_render.h"
#include "../ui_timer.h"
#include "../ui_windows.h"
#include "../ui_main.h"
#include "../ui_input.h"
#include "../../client.h"
#include "../../battlescape/cl_localentity.h"
#include "../../battlescape/cl_hud.h"
#include "../../renderer/r_draw.h"
#include "../../renderer/r_misc.h"
#include "../../../shared/parse.h"
Include dependency graph for ui_node_radar.c:

Go to the source code of this file.

Data Structures

struct  hudRadarImage_s
 Each maptile must have an entry in the images array. More...
struct  hudRadar_s

Typedefs

typedef struct hudRadarImage_s hudRadarImage_t
 Each maptile must have an entry in the images array.
typedef struct hudRadar_s hudRadar_t

Functions

static void UI_FreeRadarImages (void)
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 imagename (mapname), the x and the y position (screencoordinates).
static void UI_GetRadarWidth (const uiNode_t *node, vec2_t gridSize)
 Get the width of radar.
static qboolean UI_CheckRadarImage (const char *imageName, const int level)
static void UI_InitRadar (const uiNode_t *node)
 Calculate some radar values that won't change during a mission.
static void UI_RadarNodeGetActorColor (const le_t *le, vec4_t color)
static void UI_RadarNodeDrawArrays (const vec4_t color, vec2_t coords[4], vec2_t vertices[4], const image_t *image)
static void UI_RadarNodeDrawActor (const le_t *le, const vec3_t pos)
static void UI_RadarNodeDrawItem (const le_t *le, const vec3_t pos)
static void UI_RadarNodeDraw (uiNode_t *node)
static void UI_RadarNodeCapturedMouseMove (uiNode_t *node, int x, int y)
 Called when the node is captured by the mouse.
static void UI_RadarNodeMouseDown (uiNode_t *node, int x, int y, int button)
static void UI_RadarNodeMouseUp (uiNode_t *node, int x, int y, int button)
static void UI_GetRadarMapInFrameBuffer (int *x, int *y, int *width, int *height)
static void UI_GenPreviewRadarMap_f (void)
static void UI_GenRadarMap_f (void)
static void UI_GenAllRadarMap (uiNode_t *node, uiTimer_t *timer)
static void UI_GenAllRadarMapRelease_f (void)
static void UI_GenAllRadarMap_f (void)
void UI_RegisterRadarNode (uiBehaviour_t *behaviour)

Variables

static hudRadar_t radar
static const char * imageExtensions []
uiTimer_ttimer

Detailed Description

Definition in file ui_node_radar.c.


Typedef Documentation

typedef struct hudRadar_s hudRadar_t

Each maptile must have an entry in the images array.


Function Documentation

static void UI_BuildRadarImageList ( const char *  tiles,
const char *  pos 
) [static]

Reads the tiles and position config strings and convert them into a linked list that holds the imagename (mapname), the x and the y position (screencoordinates).

Parameters:
[in] tiles The configstring with the tiles (map tiles)
[in] pos The position string, only used in case of random map assembly
See also:
UI_DrawRadar
R_ModBeginLoading

Definition at line 107 of file ui_node_radar.c.

References hudRadar_s::base, cl, Com_Error(), Com_Parse(), Com_Printf(), Com_sprintf(), ERR_DROP, hudRadar_s::gridMin, hudRadarImage_s::gridX, hudRadarImage_s::gridY, i, hudRadar_s::images, hudRadarImage_s::isTile, hudRadarImage_s::mapX, hudRadarImage_s::mapY, MAX_VAR, Mem_StrDup, hudRadarImage_s::name, name, hudRadar_s::numImages, Q_strncpyz(), and UNIT_SIZE.

Referenced by UI_InitRadar().

static qboolean UI_CheckRadarImage ( const char *  imageName,
const int  level 
) [static]

Definition at line 254 of file ui_node_radar.c.

References FS_CheckFile(), imageExtensions, qfalse, and qtrue.

Referenced by UI_InitRadar().

static void UI_FreeRadarImages ( void   )  [static]
static void UI_GenAllRadarMap ( uiNode_t node,
uiTimer_t timer 
) [static]
static void UI_GenAllRadarMap_f ( void   )  [static]

Take all screenshots from lower to upper map level. Use a timer to delay each capture

Definition at line 806 of file ui_node_radar.c.

References UI_AllocTimer(), UI_GenAllRadarMap(), and UI_TimerStart().

Referenced by UI_RegisterRadarNode().

static void UI_GenAllRadarMapRelease_f ( void   )  [static]
Todo:
allow to call UI_TimerRelease into timer callback

Definition at line 797 of file ui_node_radar.c.

References UI_ExecuteConfunc(), and UI_TimerRelease().

Referenced by UI_RegisterRadarNode().

static void UI_GenPreviewRadarMap_f ( void   )  [static]
static void UI_GenRadarMap_f ( void   )  [static]

Take a screen shot of the map with the position of the radar

We add 1 pixel into the border to easy check the result: the screen shot must have a border of 1 black pixel

Definition at line 761 of file ui_node_radar.c.

References Cvar_GetInteger(), Cvar_GetString(), level, R_ScreenShot(), UI_GetRadarMapInFrameBuffer(), and va().

Referenced by UI_RegisterRadarNode().

static void UI_GetRadarMapInFrameBuffer ( int *  x,
int *  y,
int *  width,
int *  height 
) [static]

Return the rect where the radarmap should be, when we generate radar images

Parameters:
[out] x X position of the rect in the frame buffer (from bottom-to-top according to the screen)
[out] y Y position of the rect in the frame buffer (from bottom-to-top according to the screen)
[out] width Width of the rect in the frame buffer (from bottom-to-top according to the screen)
[out] height Height of the rect in the frame buffer (from bottom-to-top according to the screen)
Todo:
fix that function, map is not well captured

Definition at line 723 of file ui_node_radar.c.

References cl, viddef_t::height, viddef, and viddef_t::width.

Referenced by UI_GenPreviewRadarMap_f(), and UI_GenRadarMap_f().

static void UI_GetRadarWidth ( const uiNode_t node,
vec2_t  gridSize 
) [static]

Get the width of radar.

Parameters:
[in] node Node description of the radar
[in] gridSize size of the radar picture, in grid units.
See also:
UI_InitRadar

< Contains the width of the first and the last tile of the first line (in screen unit)

< Contains the height of the first and the last tile of the first column (in screen unit)

< Contains the grid X position of 2nd tiles in first line

< Contains the grid Y position of 2nd tiles in first column

< ratio conversion between screen coordinates and grid coordinates

< Number of pixel to remove to avoid rounding errors (and lines between tiles) We remove pixel because this is much nicer if tiles overlap a little bit rather than if they are too distant one from the other

Definition at line 170 of file ui_node_radar.c.

References hudRadar_s::gridMax, hudRadar_s::gridMin, hudRadarImage_s::gridX, hudRadarImage_s::gridY, hudRadar_s::h, hudRadarImage_s::height, hudRadar_s::images, hudRadar_s::numImages, Vector2Set, hudRadar_s::w, and hudRadarImage_s::width.

Referenced by UI_InitRadar().

static void UI_InitRadar ( const uiNode_t node  )  [static]
static void UI_RadarNodeCapturedMouseMove ( uiNode_t node,
int  x,
int  y 
) [static]

Called when the node is captured by the mouse.

Definition at line 680 of file ui_node_radar.c.

References cl, pos, uiNode_s::size, UI_NodeAbsoluteToRelativePos(), and VectorCopy.

Referenced by UI_RadarNodeMouseDown(), and UI_RegisterRadarNode().

static void UI_RadarNodeDraw ( uiNode_t node  )  [static]
static void UI_RadarNodeDrawActor ( const le_t le,
const vec3_t  pos 
) [static]
static void UI_RadarNodeDrawArrays ( const vec4_t  color,
vec2_t  coords[4],
vec2_t  vertices[4],
const image_t image 
) [static]

Definition at line 417 of file ui_node_radar.c.

References R_Color(), and R_DrawImageArray().

Referenced by UI_RadarNodeDrawActor().

static void UI_RadarNodeDrawItem ( const le_t le,
const vec3_t  pos 
) [static]
Todo:
We can merge actor and items draw function

Definition at line 512 of file ui_node_radar.c.

References f, i, UI_LoadImage(), UI_RadarNodeGetActorColor(), and Vector4Set.

Referenced by UI_RadarNodeDraw().

static void UI_RadarNodeGetActorColor ( const le_t le,
vec4_t  color 
) [static]
static void UI_RadarNodeMouseDown ( uiNode_t node,
int  x,
int  y,
int  button 
) [static]
static void UI_RadarNodeMouseUp ( uiNode_t node,
int  x,
int  y,
int  button 
) [static]

Definition at line 709 of file ui_node_radar.c.

References K_MOUSE1, and UI_MouseRelease().

Referenced by UI_RegisterRadarNode().

void UI_RegisterRadarNode ( uiBehaviour_t behaviour  ) 

Variable Documentation

const char* imageExtensions[] [static]
Initial value:
 {
    "tga", "jpg", "png", NULL
}

Definition at line 250 of file ui_node_radar.c.

Referenced by UI_CheckRadarImage().

hudRadar_t radar [static]

Definition at line 84 of file ui_node_radar.c.

Referenced by RADAR_AddDetectedUFOToEveryRadar(), and RADAR_CheckRadarSensored().

Definition at line 792 of file ui_node_radar.c.


Generated by  doxygen 1.6.2