29#include "map_overlay.h"
42#include "player_gui.h"
49#define XML_GUI_ID "GUIs"
50#define XML_GUI_TAG "gui"
52#define RADAR_BLINK_PILOT 0.5
53#define RADAR_BLINK_SPOB 1.
61static gl_vbo *gui_radar_select_vbo = NULL;
90typedef struct Radar_ {
99#define RADAR_RES_MAX 300.
100#define RADAR_RES_REF 100.
101#define RADAR_RES_MIN 10.
102#define RADAR_RES_INTERVAL \
104static Radar gui_radar;
121typedef struct Mesg_ {
146static int gui_lua_create = LUA_NOREF;
147static int gui_lua_render = LUA_NOREF;
148static int gui_lua_render_cooldown = LUA_NOREF;
149static int gui_lua_cooldown_end = LUA_NOREF;
150static int gui_lua_mouse_move = LUA_NOREF;
151static int gui_lua_mouse_click = LUA_NOREF;
152static int gui_lua_update_cargo = LUA_NOREF;
153static int gui_lua_update_nav = LUA_NOREF;
154static int gui_lua_update_target = LUA_NOREF;
155static int gui_lua_update_ship = LUA_NOREF;
156static int gui_lua_update_system = LUA_NOREF;
157static int gui_lua_update_faction = LUA_NOREF;
158static int gui_lua_update_effects = LUA_NOREF;
166extern void weapon_minimap(
const double res,
const double w,
const double h,
167 const RadarShape shape,
174 double y,
double radius,
double angle,
177 double ry,
double hw,
double hh );
185 int cy,
const glColour *col );
186static void gui_blink(
double cx,
double cy,
double vr,
const glColour *col,
187 double blinkInterval,
double blinkVar );
191static int gui_doFunc(
int func_ref,
const char *func_name );
192static int gui_prepFunc(
int func_ref,
const char *func_name );
193static int gui_runFunc(
const char *func,
int nargs,
int nret );
237 o =
mesg_max - 2 * conf.mesg_visible - o;
302 gui_mesg_w - ( ( str[0] ==
'\t' ) ? 45 : 15 ) );
310 SDL_asprintf( &m->
dstr, p_(
"player_message",
"%s x%d" ), str,
313 gui_mesg_w - ( ( str[0] ==
'\t' ) ? 45 : 15 ) ) {
331 if ( iter.l_begin == 0 ) {
335 m->
str = malloc( iter.
l_end - iter.l_begin + 2 );
336 snprintf( m->
str, iter.
l_end - iter.l_begin + 2,
"\t%s",
337 &str[iter.l_begin] );
365 SDL_vasprintf( &buf, fmt, ap );
380 if ( player_isFlag( PLAYER_DESTROYED ) || player_isFlag( PLAYER_CREATING ) ||
381 (
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_DEAD ) )
385 if ( (
player.p->nav_spob < 0 ) && (
player.p->nav_hyperspace < 0 ) &&
386 (
player.p->nav_asteroid < 0 ) )
398 if (
player.p->nav_hyperspace >= 0 ) {
400 if ( jp_isKnown( jp ) ) {
408 if (
player.p->nav_spob >= 0 ) {
416 if (
player.p->nav_asteroid >= 0 ) {
424 r = ast->
gfx->
sw * 0.5;
440 double y,
double radius,
double angle,
451 glUseProgram( shd->program );
453 glUniform1f( shd->paramf, radius );
470 if (
player.p->target != PLAYER_ID )
476 if ( ( p == NULL ) || pilot_isFlag( p, PILOT_DEAD ) ) {
490 if ( pilot_isDisabled( p ) )
500 p->solid.pos.y, p->ship->size * 0.5, p->solid.dir,
517 double ry,
double hw,
double hh )
533 *cx = h * ( rx / ry );
537 *cy = -w * ( ry / rx );
539 *cx = -h * ( rx / ry );
543 *cy = w * ( ry / rx );
565 NTracingZone( _ctx, 1 );
573 gl_renderRect( SCREEN_W - 15., 0., 15., SCREEN_H, &cBlackHilight );
574 gl_renderRect( 15., 0., SCREEN_W - 30., 15., &cBlackHilight );
575 gl_renderRect( 15., SCREEN_H - 15., SCREEN_W - 30., 15., &cBlackHilight );
582 if ( !spob_isKnown( pnt ) )
601 if ( !jp_isUsable( jp ) )
610 if ( i ==
player.p->nav_hyperspace )
639 NTracingZoneEnd( _ctx );
671 cw = SCREEN_W / 2 + w / 2;
672 ch = SCREEN_H / 2 + h / 2;
674 if ( (
ABS( *rx ) > cw ) || (
ABS( *ry ) > ch ) )
701 *rx = ( pnt->
pos.
x -
player.p->solid.pos.x ) * z;
702 *ry = ( pnt->
pos.
y -
player.p->solid.pos.y ) * z;
705 *rx = ( jp->pos.x -
player.p->solid.pos.x ) * z;
706 *ry = ( jp->pos.y -
player.p->solid.pos.y ) * z;
721 if ( (
ABS( *rx ) > cw ) || (
ABS( *ry ) > ch ) )
741 if ( player_isFlag( PLAYER_CINEMATICS ) )
757 double fade, direction;
761 ( player_isFlag( PLAYER_DESTROYED ) ||
762 player_isFlag( PLAYER_CREATING ) ||
763 ( (
player.p != NULL ) && pilot_isFlag(
player.p, PILOT_DEAD ) ) ) ) {
764 NTracingZone( _ctx, 1 );
770 NTracingZoneEnd( _ctx );
779 if ( player_isFlag( PLAYER_CINEMATICS_GUI ) )
782 NTracingZone( _ctx, 1 );
804 lua_pushnumber(
naevL, dt );
808 if ( pilot_isFlag(
player.p, PILOT_COOLDOWN ) ) {
809 if (
gui_prepFunc( gui_lua_render_cooldown,
"render_cooldown" ) ==
825 if (
player.p->nav_hyperspace >= 0 ) {
828 if ( ( i != 0 ) && ( i !=
can_jump ) )
829 if ( !pilot_isFlag(
player.p, PILOT_HYPERSPACE ) )
835 fade = direction = 0.;
836 if ( pilot_isFlag(
player.p, PILOT_HYPERSPACE ) &&
837 (
player.p->ptimer < HYPERSPACE_FADEOUT ) ) {
838 fade = ( HYPERSPACE_FADEOUT -
player.p->ptimer ) / HYPERSPACE_FADEOUT;
839 direction = VANGLE(
player.p->solid.vel );
840 }
else if ( pilot_isFlag(
player.p, PILOT_HYP_END ) &&
842 fade =
player.p->ptimer / HYPERSPACE_FADEIN;
843 direction = VANGLE(
player.p->solid.vel ) + M_PI;
847 mat4 projection = gl_view_matrix;
850 glUseProgram( shaders.jump.program );
851 glEnableVertexAttribArray( shaders.jump.vertex );
859 gl_uniformMat4( shaders.jump.projection, &projection );
860 glUniform1f( shaders.jump.progress, fade );
861 glUniform1f( shaders.jump.direction, direction );
863 glUniform1f( shaders.jump.brightness, conf.jump_brightness );
866 if ( gl_has( OPENGL_SUBROUTINES ) ) {
868 glUniformSubroutinesuiv( GL_FRAGMENT_SHADER, 1,
869 &shaders.jump.jump_func.jump_nebula );
871 glUniformSubroutinesuiv( GL_FRAGMENT_SHADER, 1,
872 &shaders.jump.jump_func.jump_wind );
876 glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
879 glDisableVertexAttribArray( shaders.jump.vertex );
892 NTracingZoneEnd( _ctx );
900 gui_doFunc( gui_lua_cooldown_end,
"cooldown_end" );
912 gui_radar.shape = circle ? RADAR_CIRCLE : RADAR_RECT;
929 mat4 view_matrix_prev;
932 if ( !conf.always_radar && ovr_isOpen() )
935 NTracingZone( _ctx, 1 );
944 view_matrix_prev = gl_view_matrix;
945 if ( radar->
shape == RADAR_RECT ) {
947 mat4_translate_xy( &gl_view_matrix, x + radar->
w / 2.,
949 }
else if ( radar->
shape == RADAR_CIRCLE )
950 mat4_translate_xy( &gl_view_matrix, x, y );
956 if ( i !=
player.p->nav_spob )
959 if (
player.p->nav_spob > -1 )
968 if ( i !=
player.p->nav_hyperspace && jp_isUsable( jp ) )
972 if (
player.p->nav_hyperspace > -1 )
974 radar->
h, radar->
res, 1., 0 );
999 double range = EW_ASTEROID_DIST *
1000 player.p->stats.ew_detect;
1002 ax = round(
player.p->solid.pos.x );
1003 ay = round(
player.p->solid.pos.y );
1005 asteroid_collideQueryIL( ast, &
gui_qtquery, ax - r, ay - r, ax + r,
1007 for (
int j = 0; j < il_size( &
gui_qtquery ); j++ ) {
1017 gl_view_matrix = view_matrix_prev;
1018 if ( radar->
shape == RADAR_RECT )
1021 NTracingZoneEnd( _ctx );
1031 *res = gui_radar.res;
1039 for (
int i = 0; i <
mesg_max; i++ ) {
1053 double x, y, h, hs, vx, vy, dy;
1055 glColour
c = { .r = 1., .g = 1., .b = 1. };
1056 const glColour msgc = { .r = 0., .g = 0., .b = 0., .a = 0.6 };
1058 NTracingZone( _ctx, 1 );
1081 hs = h * (double)conf.mesg_visible / (
double)
mesg_max;
1088 for (
int i = 0; i < conf.mesg_visible; i++ ) {
1102 const char *str = (
mesg_stack[m].dstr != NULL )
1106 glColour fadedWhite = cFontWhite;
1111 if ( str[0] ==
'\t' ) {
1116 &fadedWhite, -1., &str[1] );
1121 &fadedWhite, -1., str );
1143 ( (
double)o / (
double)(
mesg_max - conf.mesg_visible ) ),
1147 NTracingZoneEnd( _ctx );
1160 const glColour *col;
1162 if ( p->id ==
player.p->target )
1163 col = &cRadar_tPilot;
1181 double res,
int overlay )
1183 double x, y, scale, ssize;
1184 const glColour *col;
1193 x = ( p->solid.pos.x / res );
1194 y = ( p->solid.pos.y / res );
1196 x = ( ( p->solid.pos.x -
player.p->solid.pos.x ) / res );
1197 y = ( ( p->solid.pos.y -
player.p->solid.pos.y ) / res );
1200 ssize = sqrt( (
double)
ship_size( p->ship ) );
1204 if ( ( ( shape == RADAR_RECT ) && ( (
ABS( x ) > ( w + scale ) / 2. ) ||
1205 (
ABS( y ) > ( h + scale ) / 2. ) ) ) ||
1206 ( ( shape == RADAR_CIRCLE ) &&
1210 if ( p->id ==
player.p->target && !overlay )
1218 ovr_center( &ox, &oy );
1223 if ( p->id ==
player.p->target )
1224 col = &cRadar_hilight;
1228 scale =
MAX( scale + 2.0, 3.5 + ssize );
1230 ( pilot_isFlag( p, PILOT_SCANNING ) && ( p->target == PLAYER_ID ) );
1232 if ( pilot_isFlag( p, PILOT_HILIGHT ) || scanning ) {
1233 glColour highlighted = cRadar_hilight;
1234 highlighted.a = 0.3;
1235 glUseProgram( shaders.hilight.program );
1237 gl_renderShader( x, y, scale * 2.0, scale * 2.0, 0., &shaders.hilight,
1241 glUseProgram( shaders.pilotmarker.program );
1242 gl_renderShader( x, y, scale, scale, p->solid.dir, &shaders.pilotmarker, col,
1246 if ( p->id ==
player.p->target )
1247 gui_blink( x, y,
MAX( scale * 2., 10.0 ), &cRadar_hilight,
1251 if ( overlay && pilot_isFlag( p, PILOT_HILIGHT ) ) {
1256 glUseProgram( shaders.pilotscanning.program );
1264 glUseProgram( shaders.pilotscanning.program );
1284 double x, y, r, sx, sy;
1286 const glColour *col;
1289 if ( a->state != ASTEROID_FG )
1302 x = ( a->sol.pos.x / res );
1303 y = ( a->sol.pos.y / res );
1305 x = ( ( a->sol.pos.x -
player.p->solid.pos.x ) / res );
1306 y = ( ( a->sol.pos.y -
player.p->solid.pos.y ) / res );
1316 ovr_center( &ox, &oy );
1324 px =
MAX( x - sx, -w );
1325 py =
MAX( y - sy, -h );
1328 ( ( i ==
player.p->nav_asteroid ) && ( j ==
player.p->nav_anchor ) );
1337 r = ( sx + sy ) / 2.0 + 1.5;
1338 glUseProgram( shaders.asteroidmarker.program );
1356 r = ( sqrt( 24. ) + 1. ) / 2. * ( 1. +
RADAR_RES_REF / res );
1359 ovr_center( &ox, &oy );
1360 x =
player.p->solid.pos.x / res + ox;
1361 y =
player.p->solid.pos.y / res + oy;
1368 glUseProgram( shaders.playermarker.program );
1370 &cRadar_player, 1 );
1381 const glColour *col;
1384 if ( i ==
player.p->nav_spob )
1385 col = &cRadar_tSpob;
1404static void gui_blink(
double cx,
double cy,
double vr,
const glColour *col,
1405 double blinkInterval,
double blinkVar )
1407 if ( blinkVar > blinkInterval / 2. )
1409 glUseProgram( shaders.blinkmarker.program );
1417 int cy,
const glColour *col )
1419 double a, x, y, x2, y2;
1422 a = ANGLE( cx, cy );
1423 if ( sh == RADAR_CIRCLE ) {
1432 x = w / 2. * ( cx * 1. / cy );
1434 }
else if ( cx >= cya ) {
1436 y = h / 2. * ( cy * 1. / cx );
1437 }
else if ( cya >= cxa ) {
1438 x = -w / 2. * ( cx * 1. / cy );
1442 y = -h / 2. * ( cy * 1. / cx );
1445 x2 = x - .15 * w * cos( a );
1446 y2 = y - .15 * w * sin( a );
1457 double alpha,
int overlay )
1459 GLfloat cx, cy, r, vr;
1462 const SimpleShader *shd;
1465 if ( !spob_isKnown(
cur_system->spobs[ind] ) )
1474 cx = spob->
pos.
x / res;
1475 cy = spob->
pos.
y / res;
1477 cx = ( spob->
pos.
x -
player.p->solid.pos.x ) / res;
1478 cy = ( spob->
pos.
y -
player.p->solid.pos.y ) / res;
1482 if ( shape == RADAR_CIRCLE ) {
1483 GLfloat x =
ABS( cx ) - r;
1484 GLfloat y =
ABS( cy ) - r;
1486 if ( x * x + y * y >
pow2( w - 2 * r ) ) {
1487 if ( (
player.p->nav_spob == ind ) && !overlay )
1493 if ( shape == RADAR_RECT ) {
1495 if ( (
ABS( cx ) - r > w / 2. ) || (
ABS( cy ) - r > h / 2. ) ) {
1496 if ( (
player.p->nav_spob == ind ) && !overlay )
1506 ovr_center( &ox, &oy );
1516 if ( spob_isKnown( spob ) && spob_isFlag( spob, SPOB_MARKED ) ) {
1517 glColour highlighted = cRadar_hilight;
1518 highlighted.a = 0.3;
1519 glUseProgram( shaders.hilight.program );
1530 if ( ind ==
player.p->nav_spob )
1533 if ( spob->
marker != NULL )
1535 else if ( spob_hasService( spob, SPOB_SERVICE_LAND ) )
1536 shd = &shaders.spobmarker_earth;
1538 shd = &shaders.spobmarker_empty;
1540 glUseProgram( shd->program );
1544 char buf[STRMAX_SHORT];
1564 double res,
double alpha,
int overlay )
1566 GLfloat cx, cy, x, y, r, vr;
1572 if ( !jp_isUsable( jp ) )
1577 vr = overlay ? jp->mo.radius :
MAX( r, 5. );
1579 cx = jp->pos.x / res;
1580 cy = jp->pos.y / res;
1582 cx = ( jp->pos.x -
player.p->solid.pos.x ) / res;
1583 cy = ( jp->pos.y -
player.p->solid.pos.y ) / res;
1587 if ( shape == RADAR_RECT ) {
1589 if ( (
ABS( cx ) - r > w / 2. ) || (
ABS( cy ) - r > h / 2. ) ) {
1590 if ( (
player.p->nav_hyperspace == ind ) && !overlay )
1595 }
else if ( shape == RADAR_CIRCLE ) {
1599 if ( x * x + y * y >
pow2( w - 2 * r ) ) {
1600 if ( (
player.p->nav_hyperspace == ind ) && !overlay )
1609 ovr_center( &ox, &oy );
1617 if ( sys_isMarked( s ) ) {
1618 glColour highlighted = cRadar_hilight;
1619 highlighted.a = 0.3;
1620 glUseProgram( shaders.hilight.program );
1626 if ( ind ==
player.p->nav_hyperspace )
1628 else if ( jp_isFlag( jp, JP_HIDDEN ) )
1634 glUseProgram( shaders.jumpmarker.program );
1636 &shaders.jumpmarker, &col, 1 );
1639 if ( ind ==
player.p->nav_hyperspace )
1644 char buf[STRMAX_SHORT];
1646 sys_isKnown( jp->target ) ? _( jp->target->name )
1649 cy + jp->mo.text_offy, &col, buf );
1695 gui_tl = atan2( +h, -w );
1698 gui_tr = atan2( +h, +w );
1701 gui_bl = atan2( -h, -w );
1704 gui_br = atan2( -h, +w );
1727 if ( gui_radar_select_vbo == NULL ) {
1745 gui_radar_select_vbo =
1750 osd_setup( 30., SCREEN_H - 90., 150., 300. );
1795 WARN( _(
"GUI '%s': Trying to run GUI func '%s' but no GUI is loaded!" ),
1802 if ( player_isFlag( PLAYER_DESTROYED ) || player_isFlag( PLAYER_CREATING ) ||
1803 (
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_DEAD ) ) {
1808 lua_rawgeti(
naevL, LUA_REGISTRYINDEX, func_ref );
1810 if ( lua_isnil(
naevL, -1 ) ) {
1811 WARN( _(
"GUI '%s': no function '%s' defined!" ),
gui_name, func_name );
1812 lua_pop(
naevL, 1 );
1829 int ret = nlua_pcall(
gui_env, nargs, nret );
1832 ( lua_isstring(
naevL, -1 ) ) ? lua_tostring(
naevL, -1 ) : NULL;
1833 WARN( _(
"GUI '%s' Lua -> '%s': %s" ),
gui_name, func,
1834 ( err ) ? err : _(
"unknown error" ) );
1835 lua_pop(
naevL, 1 );
1858 gui_doFunc( gui_lua_update_cargo,
"update_cargo" );
1866 gui_doFunc( gui_lua_update_nav,
"update_nav" );
1874 gui_doFunc( gui_lua_update_target,
"update_target" );
1882 gui_doFunc( gui_lua_update_ship,
"update_ship" );
1890 gui_doFunc( gui_lua_update_system,
"update_system" );
1899 gui_doFunc( gui_lua_update_faction,
"update_faction" );
1902void gui_updateEffects(
void )
1905 gui_doFunc( gui_lua_update_effects,
"update_effects" );
1918 if ( player_isFlag( PLAYER_DESTROYED ) || player_isFlag( PLAYER_CREATING ) ||
1919 (
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_DEAD ) )
1922 if ( (
player.p->target != PLAYER_ID ) && ( pilot->
id ==
player.p->target ) )
1924 else if ( pilot_isPlayer( pilot ) ) {
1938 if ( (
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_DEAD ) )
1940 else if (
player.gui != NULL )
1955 snprintf( path,
sizeof( path ), GUI_PATH
"%s.lua", name );
1956 return PHYSFS_exists( path );
1977 snprintf( path,
sizeof( path ), GUI_PATH
"%s.lua", name );
1979 if ( buf == NULL ) {
1980 WARN( _(
"Unable to find GUI '%s'." ), path );
1989 gui_env = nlua_newEnv( name );
1996 if ( nlua_dobufenv(
gui_env, buf, bufsize, path ) != 0 ) {
1997 WARN( _(
"Failed to load GUI Lua: %s\n"
1999 "Most likely Lua file has improper syntax, please check" ),
2000 path, lua_tostring(
naevL, -1 ) );
2009#define LUA_FUNC( funcname ) \
2010 gui_lua_##funcname = nlua_refenvtype( gui_env, #funcname, LUA_TFUNCTION );
2013 LUA_FUNC( render_cooldown );
2014 LUA_FUNC( cooldown_end );
2015 LUA_FUNC( mouse_move );
2016 LUA_FUNC( mouse_click );
2017 LUA_FUNC( update_cargo );
2018 LUA_FUNC( update_nav );
2019 LUA_FUNC( update_target );
2020 LUA_FUNC( update_ship );
2021 LUA_FUNC( update_system );
2022 LUA_FUNC( update_faction );
2023 LUA_FUNC( update_effects );
2027 if (
gui_doFunc( gui_lua_create,
"create" ) ) {
2060 ovr_boundsSet( 0, 0, 0, 0 );
2074 omsg_position( SCREEN_W / 2., SCREEN_H * 2. / 3., SCREEN_W * 2. / 3. );
2084#define LUA_CLEANUP( varname ) \
2085 if ( varname != LUA_NOREF ) \
2086 luaL_unref( naevL, LUA_REGISTRYINDEX, varname ); \
2088 LUA_CLEANUP( gui_lua_create );
2089 LUA_CLEANUP( gui_lua_render );
2090 LUA_CLEANUP( gui_lua_render_cooldown );
2091 LUA_CLEANUP( gui_lua_cooldown_end );
2092 LUA_CLEANUP( gui_lua_mouse_move );
2093 LUA_CLEANUP( gui_lua_mouse_click );
2094 LUA_CLEANUP( gui_lua_update_cargo );
2095 LUA_CLEANUP( gui_lua_update_nav );
2096 LUA_CLEANUP( gui_lua_update_target );
2097 LUA_CLEANUP( gui_lua_update_ship );
2098 LUA_CLEANUP( gui_lua_update_system );
2099 LUA_CLEANUP( gui_lua_update_faction );
2100 LUA_CLEANUP( gui_lua_update_effects );
2115 gui_radar_select_vbo = NULL;
2150 player_message( _(
"#oRadar set to %.0fx.#0" ), round( gui_radar.res ) );
2207 int mxr, myr, in_bounds;
2208 double x, y, cx, cy;
2211 if ( gui_radar.shape == RADAR_RECT ) {
2212 cx = gui_radar.x + gui_radar.w / 2.;
2213 cy = gui_radar.y + gui_radar.h / 2.;
2214 in_bounds = ( 2 *
ABS( mxr - cx ) <= gui_radar.w &&
2215 2 *
ABS( myr - cy ) <= gui_radar.h );
2220 (
pow2( mxr - cx ) +
pow2( myr - cy ) <=
pow2( gui_radar.w ) );
2224 x = ( mxr - cx ) * gui_radar.res +
player.p->solid.pos.x;
2225 y = ( myr - cy ) * gui_radar.res +
player.p->solid.pos.y;
2227 15. * gui_radar.res );
2239 double ang, angp, mouseang;
2241 int pntid, jpid, astid, fieid;
2243 int autonav = (
event->button.button == SDL_BUTTON_RIGHT ) ? 1 : 0;
2244 double px =
player.p->solid.pos.x;
2245 double py =
player.p->solid.pos.y;
2251 if ( !( ( mx <= 15 || my <= 15 ) ||
2259 mouseang = atan2( py - y, px - x );
2264 if ( (
ABS( angle_diff( mouseang, angp ) ) > M_PI / 64 ) ||
2265 ABS( angle_diff( mouseang, ang ) ) <
2266 ABS( angle_diff( mouseang, angp ) ) )
2268 if (
ABS( angle_diff( mouseang, ang ) ) > M_PI / 64 )
2269 jpid = pntid = astid = fieid =
2272 if ( pid != PLAYER_ID ) {
2275 }
else if ( pntid >= 0 ) {
2278 }
else if ( jpid >= 0 ) {
2281 }
else if ( astid >= 0 ) {
2284 }
else if ( pntid >= 0 ) {
2302 if ( ( evt->type == SDL_MOUSEBUTTONDOWN ) &&
2303 ( pilot_isFlag(
player.p, PILOT_HYP_PREP ) ||
2304 pilot_isFlag(
player.p, PILOT_HYP_BEGIN ) ||
2305 pilot_isFlag(
player.p, PILOT_HYPERSPACE ) ) )
2309 switch ( evt->type ) {
2311 case SDL_MOUSEMOTION:
2314 if (
gui_prepFunc( gui_lua_mouse_move,
"mouse_move" ) == 0 ) {
2316 lua_pushnumber(
naevL, x );
2317 lua_pushnumber(
naevL, y );
2323 case SDL_MOUSEBUTTONDOWN:
2324 case SDL_MOUSEBUTTONUP:
2327 if (
gui_prepFunc( gui_lua_mouse_click,
"mouse_click" ) == 0 ) {
2328 lua_pushnumber(
naevL, evt->button.button + 1 );
2330 lua_pushnumber(
naevL, x );
2331 lua_pushnumber(
naevL, y );
2332 lua_pushboolean(
naevL, ( evt->type == SDL_MOUSEBUTTONDOWN ) );
2334 ret = lua_toboolean(
naevL, -1 );
2335 lua_pop(
naevL, 1 );
Provides macros to work with dynamic arrays.
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.
int gl_printWidthRaw(const glFont *ft_font, const char *text)
Gets the width that it would take to print some text.
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 down 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.
static IntList gui_qtquery
const char * gui_pick(void)
Determines which GUI should be used.
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
int gui_exists(const char *name)
Checks to see if a GUI exists.
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.
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_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
void gui_targetPilotGFX(const glTexture *gfx)
Sets the pilot target GFX.
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.
void gui_targetSpobGFX(const glTexture *gfx)
Sets the spob target GFX.
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
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)
Recreates the land windows.
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).
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.
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 player_guiAdd(const char *name)
Adds a gui to the player.
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.
const char * start_gui(void)
Gets the module's starting ship was acquired.
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.