32#include "map_overlay.h"
63#define XML_GUI_ID "GUIs"
64#define XML_GUI_TAG "gui"
66#define RADAR_BLINK_PILOT 0.5
67#define RADAR_BLINK_SPOB 1.
75static gl_vbo *gui_radar_select_vbo = NULL;
102typedef struct Radar_ {
111#define RADAR_RES_MAX 300.
112#define RADAR_RES_REF 100.
113#define RADAR_RES_MIN 10.
114#define RADAR_RES_INTERVAL 10.
115static Radar gui_radar;
131typedef struct Mesg_ {
153static int gui_lua_create = LUA_NOREF;
154static int gui_lua_render = LUA_NOREF;
155static int gui_lua_render_cooldown = LUA_NOREF;
156static int gui_lua_cooldown_end = LUA_NOREF;
157static int gui_lua_mouse_move = LUA_NOREF;
158static int gui_lua_mouse_click = LUA_NOREF;
159static int gui_lua_update_cargo = LUA_NOREF;
160static int gui_lua_update_nav = LUA_NOREF;
161static int gui_lua_update_target = LUA_NOREF;
162static int gui_lua_update_ship = LUA_NOREF;
163static int gui_lua_update_system = LUA_NOREF;
164static int gui_lua_update_faction = LUA_NOREF;
165static int gui_lua_update_effects = LUA_NOREF;
173extern void weapon_minimap(
const double res,
const double w,
const double h,
174 const RadarShape shape,
double alpha );
179static void gui_renderTargetReticles(
const SimpleShader *shd,
double x,
double y,
double radius,
double angle,
const glColour*
c );
188static void gui_blink(
double cx,
double cy,
double vr,
const glColour *col,
double blinkInterval,
double blinkVar );
192static int gui_doFunc(
int func_ref,
const char *func_name );
193static int gui_prepFunc(
int func_ref,
const char *func_name );
194static int gui_runFunc(
const char *func,
int nargs,
int nret );
310 if (iter.l_begin == 0) {
356 if (player_isFlag(PLAYER_DESTROYED) || player_isFlag(PLAYER_CREATING) ||
377 if (jp_isKnown(jp)) {
400 r = ast->
gfx->
sw * 0.5;
425 glUseProgram(shd->program);
427 glUniform1f(shd->paramf, radius);
449 if ((p==NULL) || pilot_isFlag(p,PILOT_DEAD)) {
463 if (pilot_isDisabled(p))
472 gui_renderTargetReticles( &shaders.targetship, p->solid->pos.x, p->solid->pos.y, p->ship->gfx_space->sw * 0.5, p->solid->dir,
c );
544 gl_renderRect( SCREEN_W - 15., 0., 15., SCREEN_H, &cBlackHilight );
545 gl_renderRect( 15., 0., SCREEN_W - 30., 15., &cBlackHilight );
546 gl_renderRect( 15., SCREEN_H - 15., SCREEN_W - 30., 15., &cBlackHilight );
553 if (!spob_isKnown( pnt ))
572 if (!jp_isUsable( jp ))
638 cw = SCREEN_W/2 + tex->
sw/2;
639 ch = SCREEN_H/2 + tex->
sh/2;
641 if ((
ABS(*rx) > cw) || (
ABS(*ry) > ch))
687 if ((
ABS(*rx) > cw) || (
ABS(*ry) > ch))
707 if (player_isFlag(PLAYER_CINEMATICS))
722 double fade, direction;
726 (player_isFlag(PLAYER_DESTROYED) || player_isFlag(PLAYER_CREATING) ||
739 if (player_isFlag( PLAYER_CINEMATICS_GUI ))
762 lua_pushnumber( naevL, dt );
763 lua_pushnumber( naevL,
dt_mod );
766 if (pilot_isFlag(
player.
p, PILOT_COOLDOWN)) {
767 if (
gui_prepFunc( gui_lua_render_cooldown,
"render_cooldown" )==0) {
786 if (!pilot_isFlag(
player.
p, PILOT_HYPERSPACE))
792 fade = direction = 0.;
793 if (pilot_isFlag(
player.
p, PILOT_HYPERSPACE) &&
795 fade = (HYPERSPACE_FADEOUT-
player.
p->
ptimer) / HYPERSPACE_FADEOUT;
798 else if (pilot_isFlag(
player.
p, PILOT_HYP_END) &&
805 mat4 projection = gl_view_matrix;
808 glUseProgram( shaders.jump.program );
809 glEnableVertexAttribArray( shaders.jump.vertex );
816 gl_uniformMat4( shaders.jump.projection, &projection );
817 glUniform1f( shaders.jump.progress, fade );
818 glUniform1f( shaders.jump.direction, direction );
823 if (gl_has( OPENGL_SUBROUTINES )) {
825 glUniformSubroutinesuiv( GL_FRAGMENT_SHADER, 1, &shaders.jump.jump_func.jump_nebula );
827 glUniformSubroutinesuiv( GL_FRAGMENT_SHADER, 1, &shaders.jump.jump_func.jump_wind );
831 glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
834 glDisableVertexAttribArray( shaders.jump.vertex );
853 gui_doFunc( gui_lua_cooldown_end,
"cooldown_end" );
865 gui_radar.
shape = circle ? RADAR_CIRCLE : RADAR_RECT;
882 mat4 view_matrix_prev;
895 view_matrix_prev = gl_view_matrix;
896 if (radar->
shape==RADAR_RECT) {
899 x + radar->
w/2., y + radar->
h/2., 0 );
901 else if (radar->
shape==RADAR_CIRCLE)
947 for (
int j=0; j<ast->
nb; j++)
955 gl_view_matrix = view_matrix_prev;
956 if (radar->
shape==RADAR_RECT)
967 *res = gui_radar.
res;
987 double x, y, h, hs, vx, vy, dy;
989 glColour
c = {.r=1., .g=1., .b=1.};
990 const glColour msgc = {.r=0., .g=0., .b=0., .a=0.6};
1074 const glColour *col;
1077 col = &cRadar_tPilot;
1096 double x, y, scale, ssize;
1097 const glColour *col;
1105 x = (p->solid->pos.x / res);
1106 y = (p->solid->pos.y / res);
1113 ssize = sqrt( (
double)
ship_size( p->ship ) );
1117 if ( ((shape==RADAR_RECT) &&
1118 ((
ABS(x) > (w+scale)/2.) || (
ABS(y) > (h+scale)/2.)) ) ||
1119 ((shape==RADAR_CIRCLE) &&
1131 ovr_center( &ox, &oy );
1137 col = &cRadar_hilight;
1141 scale =
MAX(scale+2.0, 3.5+ssize);
1143 if (pilot_isFlag(p, PILOT_HILIGHT)) {
1144 glColour highlighted = cRadar_hilight;
1145 highlighted.a = 0.3;
1146 glUseProgram( shaders.hilight.program );
1148 gl_renderShader( x, y, scale*2.0, scale*2.0, 0., &shaders.hilight, &highlighted, 1 );
1151 glUseProgram(shaders.pilotmarker.program);
1152 gl_renderShader( x, y, scale, scale, p->solid->dir, &shaders.pilotmarker, col, 1 );
1159 if (overlay && pilot_isFlag(p, PILOT_HILIGHT))
1175 double x, y, r, sx, sy;
1177 const glColour *col;
1180 if (a->state != ASTEROID_FG)
1193 x = (a->pos.x / res);
1194 y = (a->pos.y / res);
1208 ovr_center( &ox, &oy );
1228 r = (sx+sy)/2.0+1.5;
1229 glUseProgram(shaders.asteroidmarker.program);
1249 ovr_center( &ox, &oy );
1258 glUseProgram(shaders.playermarker.program);
1270 const glColour *col;
1274 col = &cRadar_tSpob;
1293static void gui_blink(
double cx,
double cy,
double vr,
const glColour *col,
double blinkInterval,
double blinkVar )
1295 if (blinkVar > blinkInterval/2.)
1297 glUseProgram(shaders.blinkmarker.program);
1306 double a, x, y, x2, y2;
1310 if (sh == RADAR_CIRCLE) {
1320 x = w/2. * (cx*1./cy);
1322 }
else if (cx >= cya) {
1324 y = h/2. * (cy*1./cx);
1325 }
else if (cya >= cxa) {
1326 x = -w/2. * (cx*1./cy);
1330 y = -h/2. * (cy*1./cx);
1333 x2 = x - .15 * w * cos(a);
1334 y2 = y - .15 * w * sin(a);
1344void gui_renderSpob(
int ind, RadarShape shape,
double w,
double h,
double res,
double alpha,
int overlay )
1346 GLfloat cx, cy, x, y, r, vr;
1349 const SimpleShader *shd;
1350 char buf[STRMAX_SHORT];
1362 cx = spob->
pos.
x / res;
1363 cy = spob->
pos.
y / res;
1371 if (shape == RADAR_CIRCLE) {
1375 if (x*x + y*y >
pow2(w-2*r)) {
1382 if (shape == RADAR_RECT) {
1384 if ((
ABS(cx) - r > w/2.) || (
ABS(cy) - r > h/2.)) {
1394 ovr_center( &ox, &oy );
1403 if (spob_isKnown( spob ) && spob_isFlag( spob, SPOB_MARKED )) {
1404 glColour highlighted = cRadar_hilight;
1405 highlighted.a = 0.3;
1406 glUseProgram( shaders.hilight.program );
1408 gl_renderShader( cx, cy, vr*3.0, vr*3.0, 0., &shaders.hilight, &highlighted, 1 );
1419 if (spob->
marker != NULL)
1421 else if (spob_hasService(spob,SPOB_SERVICE_LAND))
1422 shd = &shaders.spobmarker_earth;
1424 shd = &shaders.spobmarker_empty;
1426 glUseProgram(shd->program);
1446void gui_renderJumpPoint(
int ind, RadarShape shape,
double w,
double h,
double res,
double alpha,
int overlay )
1448 GLfloat cx, cy, x, y, r, vr;
1450 char buf[STRMAX_SHORT];
1455 if (!jp_isUsable(jp))
1460 vr = overlay ? jp->mo.radius :
MAX( r, 5. );
1462 cx = jp->pos.x / res;
1463 cy = jp->pos.y / res;
1471 if (shape == RADAR_RECT) {
1473 if ((
ABS(cx) - r > w/2.) || (
ABS(cy) - r > h/2.)) {
1479 else if (shape == RADAR_CIRCLE) {
1483 if (x*x + y*y >
pow2(w-2*r)) {
1492 ovr_center( &ox, &oy );
1500 if (sys_isMarked(s)) {
1501 glColour highlighted = cRadar_hilight;
1502 highlighted.a = 0.3;
1503 glUseProgram( shaders.hilight.program );
1505 gl_renderShader( cx, cy, vr*3.0, vr*3.0, 0., &shaders.hilight, &highlighted, 1 );
1510 else if (jp_isFlag(jp, JP_HIDDEN))
1516 glUseProgram(shaders.jumpmarker.program);
1517 gl_renderShader( cx, cy, vr*1.5, vr*1.5, M_PI-jp->angle, &shaders.jumpmarker, &col, 1 );
1527 sys_isKnown(jp->target) ? _(jp->target->name) : _(
"Unknown") );
1573 gui_tl = atan2( +h, -w );
1576 gui_tr = atan2( +h, +w );
1579 gui_bl = atan2( -h, -w );
1582 gui_br = atan2( -h, +w );
1610 ERR(_(
"Out of Memory"));
1619 if (gui_radar_select_vbo == NULL) {
1642 osd_setup( 30., SCREEN_H-90., 150., 300. );
1688 WARN( _(
"GUI '%s': Trying to run GUI func '%s' but no GUI is loaded!"),
gui_name, func_name );
1694 lua_rawgeti( naevL, LUA_REGISTRYINDEX, func_ref );
1696 if (lua_isnil( naevL, -1 )) {
1697 WARN(_(
"GUI '%s': no function '%s' defined!"),
gui_name, func_name );
1715 int ret = nlua_pcall(
gui_env, nargs, nret );
1717 const char *err = (lua_isstring(naevL,-1)) ? lua_tostring(naevL,-1) : NULL;
1718 WARN(_(
"GUI '%s' Lua -> '%s': %s"),
gui_name,
1719 func, (err) ? err : _(
"unknown error"));
1743 gui_doFunc( gui_lua_update_cargo,
"update_cargo" );
1751 gui_doFunc( gui_lua_update_nav,
"update_nav" );
1759 gui_doFunc( gui_lua_update_target,
"update_target" );
1767 gui_doFunc( gui_lua_update_ship,
"update_ship" );
1775 gui_doFunc( gui_lua_update_system,
"update_system" );
1784 gui_doFunc( gui_lua_update_faction,
"update_faction" );
1787void gui_updateEffects (
void)
1790 gui_doFunc( gui_lua_update_effects,
"update_effects" );
1803 if (player_isFlag(PLAYER_DESTROYED) || player_isFlag(PLAYER_CREATING) ||
1809 else if (pilot_isPlayer(pilot)) {
1851 snprintf( path,
sizeof(path), GUI_PATH
"%s.lua", name );
1854 WARN(_(
"Unable to find GUI '%s'."), path );
1864 if (nlua_dobufenv(
gui_env, buf, bufsize, path ) != 0) {
1865 WARN(_(
"Failed to load GUI Lua: %s\n"
1867 "Most likely Lua file has improper syntax, please check"),
1868 path, lua_tostring(naevL,-1));
1881#define LUA_FUNC(funcname) gui_lua_##funcname = nlua_refenvtype( gui_env, #funcname, LUA_TFUNCTION );
1884 LUA_FUNC( render_cooldown );
1885 LUA_FUNC( cooldown_end );
1886 LUA_FUNC( mouse_move );
1887 LUA_FUNC( mouse_click );
1888 LUA_FUNC( update_cargo );
1889 LUA_FUNC( update_nav );
1890 LUA_FUNC( update_target );
1891 LUA_FUNC( update_ship );
1892 LUA_FUNC( update_system );
1893 LUA_FUNC( update_faction );
1894 LUA_FUNC( update_effects );
1898 if (
gui_doFunc( gui_lua_create,
"create" )) {
1925 ovr_boundsSet( 0, 0, 0, 0 );
1939 omsg_position( SCREEN_W/2., SCREEN_H*2./3., SCREEN_W*2./3. );
1949#define LUA_CLEANUP( varname ) if (varname!=LUA_NOREF) luaL_unref(naevL, LUA_REGISTRYINDEX, varname ); varname = LUA_NOREF
1950 LUA_CLEANUP( gui_lua_create );
1951 LUA_CLEANUP( gui_lua_render );
1952 LUA_CLEANUP( gui_lua_render_cooldown );
1953 LUA_CLEANUP( gui_lua_cooldown_end );
1954 LUA_CLEANUP( gui_lua_mouse_move );
1955 LUA_CLEANUP( gui_lua_mouse_click );
1956 LUA_CLEANUP( gui_lua_update_cargo );
1957 LUA_CLEANUP( gui_lua_update_nav );
1958 LUA_CLEANUP( gui_lua_update_target );
1959 LUA_CLEANUP( gui_lua_update_ship );
1960 LUA_CLEANUP( gui_lua_update_system );
1961 LUA_CLEANUP( gui_lua_update_faction );
1962 LUA_CLEANUP( gui_lua_update_effects );
1979 gui_radar_select_vbo = NULL;
2069 int mxr, myr, in_bounds;
2070 double x, y, cx, cy;
2073 if (gui_radar.
shape == RADAR_RECT) {
2074 cx = gui_radar.
x + gui_radar.
w / 2.;
2075 cy = gui_radar.
y + gui_radar.
h / 2.;
2076 in_bounds = (2*
ABS( mxr-cx ) <= gui_radar.
w && 2*
ABS( myr-cy ) <= gui_radar.
h);
2081 in_bounds = (
pow2( mxr-cx ) +
pow2( myr-cy ) <=
pow2( gui_radar.
w ));
2099 double ang, angp, mouseang;
2101 int pntid, jpid, astid, fieid;
2103 int autonav = (
event->button.button == SDL_BUTTON_RIGHT) ? 1 : 0;
2118 mouseang = atan2(py - y, px - x);
2122 if ((
ABS(angle_diff(mouseang, angp)) > M_PI / 64) ||
2123 ABS(angle_diff(mouseang, ang)) <
ABS(angle_diff(mouseang, angp)))
2125 if (
ABS(angle_diff(mouseang, ang)) > M_PI / 64 )
2126 jpid = pntid = astid = fieid = -1;
2128 if (pid != PLAYER_ID) {
2132 else if (pntid >= 0) {
2136 else if (jpid >= 0) {
2140 else if (astid >= 0) {
2158 if ((evt->type == SDL_MOUSEBUTTONDOWN) &&
2159 (pilot_isFlag(
player.
p,PILOT_HYP_PREP) ||
2160 pilot_isFlag(
player.
p,PILOT_HYP_BEGIN) ||
2161 pilot_isFlag(
player.
p,PILOT_HYPERSPACE)))
2165 switch (evt->type) {
2167 case SDL_MOUSEMOTION:
2172 lua_pushnumber( naevL, x );
2173 lua_pushnumber( naevL, y );
2178 case SDL_MOUSEBUTTONDOWN:
2179 case SDL_MOUSEBUTTONUP:
2183 lua_pushnumber( naevL, evt->button.button+1 );
2185 lua_pushnumber( naevL, x );
2186 lua_pushnumber( naevL, y );
2187 lua_pushboolean( naevL, (evt->type==SDL_MOUSEBUTTONDOWN) );
2189 ret = lua_toboolean( naevL, -1 );
2190 lua_pop( naevL, 1 );
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
double cam_getZoom(void)
Gets the camera zoom.
int gl_printHeightRaw(const glFont *ft_font, const int width, const char *text)
Gets the height of a non-formatted string.
void gl_printRestoreInit(glFontRestore *restore)
Initializes a restore structure.
int gl_printLineIteratorNext(glPrintLineIterator *iter)
Updates iter with the next line's information.
void gl_printRestore(const glFontRestore *restore)
Restores last colour from a restore structure.
void gl_printLineIteratorInit(glPrintLineIterator *iter, const glFont *ft_font, const char *text, int width)
Initialize an iterator object for breaking text into lines.
int gl_printMaxRaw(const glFont *ft_font, const int max, double x, double y, const glColour *c, double outlineR, const char *text)
Behaves like gl_printRaw but stops displaying text after a certain distance.
void gl_printStoreMax(glFontRestore *restore, const char *text, int max)
Stores the colour information from a piece of text limited to max characters.
void gl_printMarkerRaw(const glFont *ft_font, double x, double y, const glColour *c, const char *text)
Wrapper for gl_printRaw for map overlay markers.
static void gui_borderIntersection(double *cx, double *cy, double rx, double ry, double hw, double hh)
Gets the intersection with the border.
#define RADAR_BLINK_PILOT
static const int mesg_max
static void gui_renderSpobTarget(void)
Sets up rendering of spob and jump point targeting reticles.
void gui_renderSpob(int ind, RadarShape shape, double w, double h, double res, double alpha, int overlay)
Draws the spobs in the minimap.
int gui_radarClickEvent(SDL_Event *event)
Handles a click at a position in the current system.
void gui_clearMessages(void)
Clears the GUI messages.
int gui_init(void)
Initializes the GUI system.
static glTexture * gui_ico_hail
int gui_radarInit(int circle, int w, int h)
Initializes the radar.
void gui_setTarget(void)
Player just changed their pilot target.
void gui_renderPlayer(double res, int overlay)
Renders the player cross on the radar or whatever.
int gui_handleEvent(SDL_Event *evt)
Handles GUI events.
static void gui_renderBorder(double dt)
Renders the ships/spobs in the border.
void gui_messageScrollDown(int lines)
Scrolls up the message box.
static int gui_prepFunc(int func_ref, const char *func_name)
Prepares to run a function.
glTexture * gui_hailIcon(void)
Gets the hail icon texture.
void gui_setDefaults(void)
int gui_borderClickEvent(SDL_Event *event)
Handles clicks on the GUI border icons.
void gui_setSystem(void)
Player just changed their system.
void gui_radarRender(double x, double y)
Renders the GUI radar.
void gui_setRadarRel(int mod)
Modifies the radar resolution.
static void gui_eventToScreenPos(int *sx, int *sy, int ex, int ey)
Translates a mouse position from an SDL_Event to GUI coordinates.
static void gui_renderRadarOutOfRange(RadarShape sh, int w, int h, int cx, int cy, const glColour *col)
Renders an out of range marker for the spob.
void gui_renderAsteroid(const Asteroid *a, double w, double h, double res, int overlay)
Renders an asteroid in the GUI radar.
#define RADAR_RES_INTERVAL
void gui_mouseMoveEnable(int enable)
Enables the mouse movement callback.
void gui_messageScrollUp(int lines)
Scrolls up the message box.
static int mesg_viewpoint
void gui_mouseClickEnable(int enable)
Enables the mouse click callback.
static const double mesg_timeout
void gui_updateFaction(void)
Player's relationship with a faction was modified.
static void gui_renderMessages(double dt)
Renders the player's messages on screen.
int gui_load(const char *name)
Attempts to load the actual GUI.
char * gui_pick(void)
Determines which GUI should be used.
void gui_getOffset(double *x, double *y)
Gets the GUI offset.
void weapon_minimap(const double res, const double w, const double h, const RadarShape shape, double alpha)
Draws the minimap weapons (used in player.c).
static const glColour * gui_getSpobColour(int i)
Gets the colour of a spob.
void gui_targetPilotGFX(glTexture *gfx)
Sets the pilot target GFX.
void gui_setShip(void)
Player just upgraded their ship or modified it.
void gui_free(void)
Frees the gui stuff.
void gui_messageInit(int width, int x, int y)
Initializes the message system.
void gui_clearViewport(void)
Resets the viewport.
void gui_radarGetRes(double *res)
Outputs the radar's resolution.
void gui_reload(void)
Reloads the GUI.
void gui_forceBlink(void)
Force sets the spob and pilot radar blink.
int gui_onScreenPilot(double *rx, double *ry, const Pilot *pilot)
Takes a pilot and returns whether it's on screen, plus its relative position.
static double blink_pilot
static int gui_doFunc(int func_ref, const char *func_name)
Runs a GUI Lua function.
static void gui_renderPilotTarget(void)
Renders the players pilot target.
void gui_cooldownEnd(void)
Notifies GUI scripts that the player broke out of cooldown.
static const glColour * gui_getPilotColour(const Pilot *p)
Gets a pilot's colour, with a special colour for targets.
void gui_renderJumpPoint(int ind, RadarShape shape, double w, double h, double res, double alpha, int overlay)
Renders a jump point on the minimap.
int gui_onScreenSpob(double *rx, double *ry, const JumpPoint *jp, const Spob *pnt)
Takes a spob or jump point and returns whether it's on screen, plus its relative position.
void gui_cleanup(void)
Cleans up the GUI.
void gui_renderPilot(const Pilot *p, RadarShape shape, double w, double h, double res, int overlay)
Renders a pilot in the GUI radar.
static void gui_calcBorders(void)
Calculates and sets the GUI borders.
static double gui_viewport_y
static int gui_runFunc(const char *func, int nargs, int nret)
Runs a function.
void player_messageRaw(const char *str)
Adds a mesg to the queue to be displayed on screen.
static int gui_getMessage
static void gui_blink(double cx, double cy, double vr, const glColour *col, double blinkInterval, double blinkVar)
Renders the spob blink around a position on the minimap.
void gui_setNav(void)
Player just changed their nav computer target.
void gui_renderReticles(double dt)
Renders the gui targeting reticles.
void gui_render(double dt)
Renders the player's GUI.
void gui_setGeneric(const Pilot *pilot)
Calls trigger functions depending on who the pilot is.
static glTexture * gui_target_spob
void gui_targetSpobGFX(glTexture *gfx)
Sets the spob target GFX.
static double gui_viewport_w
void gui_setViewport(double x, double y, double w, double h)
Sets the viewport.
static void gui_renderTargetReticles(const SimpleShader *shd, double x, double y, double radius, double angle, const glColour *c)
Renders spob and jump point targeting reticles.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
void gui_setRadarResolution(double res)
Sets the radar resolution.
static double gui_viewport_x
static double animation_dt
void gui_setCargo(void)
Player just changed their cargo.
static double gui_viewport_h
void player_messageToggle(int enable)
Toggles if player should receive messages.
static glTexture * gui_target_pilot
void land_genWindows(int load, int changetab)
Recreates the land windows.
void mat4_translate(mat4 *m, double x, double y, double z)
Translates a homogenous transformation matrix.
void mat4_scale(mat4 *m, double x, double y, double z)
Scales a homogeneous transformation matrix.
void fps_setPos(double x, double y)
Sets the position to display the FPS.
Header file with generic functions and naev-specifics.
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
static char buf[NEWS_MAX_LENGTH]
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
int nlua_loadGFX(nlua_env env)
Loads the graphics library.
int nlua_loadGUI(nlua_env env)
Loads the GUI library.
int nlua_loadTk(nlua_env env)
Loads the Toolkit Lua library.
int vasprintf(char **strp, const char *fmt, va_list ap)
Like vsprintf(), but it allocates a large-enough string and returns the pointer in the first argument...
char * strndup(const char *s, size_t n)
Return a pointer to a new string, which is a duplicate of the string s (or, if necessary,...
void gl_setDefViewport(int x, int y, int w, int h)
Sets the default viewport.
void gl_defViewport(void)
Resets viewport to default.
void gl_viewport(int x, int y, int w, int h)
Sets the opengl viewport.
void gl_windowToScreenPos(int *sx, int *sy, int wx, int wy)
Translates the window position to screen position.
void gl_renderShader(double x, double y, double w, double h, double r, const SimpleShader *shd, const glColour *c, int center)
Renders a simple shader.
void gl_renderRect(double x, double y, double w, double h, const glColour *c)
Renders a rectangle.
void gl_renderLine(double x1, double y1, double x2, double y2, const glColour *c)
Draws a line.
void gl_gameToScreenCoords(double *nx, double *ny, double bx, double by)
Converts in-game coordinates to screen coordinates.
void gl_renderTriangleEmpty(double x, double y, double a, double s, double length, const glColour *c)
Renders a triangle at a given position.
void gl_unclipRect(void)
Clears the 2d clipping planes.
void gl_renderRectEmpty(double x, double y, double w, double h, const glColour *c)
Renders a rectangle.
void gl_clipRect(int x, int y, int w, int h)
Sets up 2d clipping planes around a rectangle.
void gl_renderCircle(double cx, double cy, double r, const glColour *c, int filled)
Draws a circle.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
glTexture * gl_newSprite(const char *path, const int sx, const int sy, const unsigned int flags)
Loads the texture immediately, but also sets it as a sprite.
void gl_freeTexture(glTexture *texture)
Frees a texture.
void gl_vboDestroy(gl_vbo *vbo)
Destroys a VBO.
void gl_vboActivateAttribOffset(gl_vbo *vbo, GLuint index, GLuint offset, GLint size, GLenum type, GLsizei stride)
Activates a VBO's offset.
gl_vbo * gl_vboCreateStatic(GLsizei size, const void *data)
Creates a stream vbo.
int pilot_isHostile(const Pilot *p)
Checks to see if pilot is hostile to the player.
int pilot_validTarget(const Pilot *p, const Pilot *target)
Checks to see if a pilot is a valid target for another pilot.
int pilot_isFriendly(const Pilot *p)
Checks to see if pilot is friendly to the player.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
const glColour * pilot_getColour(const Pilot *p)
Gets a pilot's colour.
static Pilot ** pilot_stack
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
double pilot_getNearestAng(const Pilot *p, unsigned int *tp, double ang, int disabled)
Get the pilot closest to an angle extending from another pilot.
void pilot_setTarget(Pilot *p, unsigned int id)
Sets the target of the pilot.
int pilot_inRangePilot(const Pilot *p, const Pilot *target, double *dist2)
Check to see if a pilot is in sensor range of another.
int pilot_inRangeSpob(const Pilot *p, int target)
Check to see if a spob is in sensor range of the pilot.
int pilot_inRangeAsteroid(const Pilot *p, int ast, int fie)
Check to see if an asteroid is in sensor range of the pilot.
void player_targetSpobSet(int id)
Sets the player's target spob.
void player_soundPlayGUI(int sound, int once)
Plays a GUI sound (unaffected by time accel).
int ship_size(const Ship *s)
Gets the size of the ship.
double system_getClosestAng(const StarSystem *sys, int *pnt, int *jp, int *ast, int *fie, double x, double y, double ang)
Gets the feature nearest to directly ahead of a position in the system.
int space_canHyperspace(const Pilot *p)
Checks to make sure if pilot is far enough away to hyperspace.
const glColour * spob_getColour(const Spob *p)
Gets the spob colour.
const char * jump_getSymbol(const JumpPoint *jp)
Gets the jump point symbol.
const char * spob_getSymbol(const Spob *p)
Gets the spob symbol.
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
glTexture * jumppoint_gfx
void spfx_cinematic(void)
Sets the cinematic mode.
Represents an asteroid field anchor.
Represents a single asteroid.
On screen player message.
The representation of an in-game pilot.
Represents the player's radar.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
const SimpleShader * marker
Evil hack to allow restoring, yes it makes me cry myself to sleep.
The state of a line iteration. This matches the process of rendering text into an on-screen box: An e...
Abstraction for rendering sprite sheets.