[Add] Added an indication on minimap as to where targeted planets
reside.
This commit is contained in:
parent
84ea77284a
commit
77afa506e4
@ -38,9 +38,11 @@ glColour cNeutral = { .r = 0.9, .g = 1.0, .b = 0.3, .a = 1. }; /**< Neutra
|
|||||||
glColour cFriend = { .r = 0.0, .g = 1.0, .b = 0.0, .a = 1. }; /**< Friend object colour. */
|
glColour cFriend = { .r = 0.0, .g = 1.0, .b = 0.0, .a = 1. }; /**< Friend object colour. */
|
||||||
glColour cHostile = { .r = 0.9, .g = 0.2, .b = 0.2, .a = 1. }; /**< Hostile object colour. */
|
glColour cHostile = { .r = 0.9, .g = 0.2, .b = 0.2, .a = 1. }; /**< Hostile object colour. */
|
||||||
/* Radar */
|
/* Radar */
|
||||||
glColour cRadar_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. }; /**< Player colour on radar. */
|
glColour cRadar_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. }; /**<Player colour on radar. */
|
||||||
glColour cRadar_targ = { .r = 0.0, .g = 0.7, .b = 1.0, .a = 1. }; /**< Targetted object colour.*/
|
glColour cRadar_tPilot = { .r = 0.0, .g = 1.0, .b = 1.0, .a = 1. }; /**<Targetted object colour.*/
|
||||||
glColour cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. }; /**< Weapon colour on radar. */
|
glColour cRadar_tPlanet = { .r = 0.4, .g = 0.0, .b = 1.0, .a = 1. }; /**<Targetted planet colour.*/
|
||||||
|
glColour cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. }; /**< Weapon colour on radar.*/
|
||||||
|
|
||||||
/* Bars. */
|
/* Bars. */
|
||||||
glColour cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. }; /**< Shield bar colour. */
|
glColour cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. }; /**< Shield bar colour. */
|
||||||
glColour cArmour = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. }; /**< Armour bar colour. */
|
glColour cArmour = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. }; /**< Armour bar colour. */
|
||||||
|
@ -49,7 +49,8 @@ extern glColour cFriend;
|
|||||||
extern glColour cHostile;
|
extern glColour cHostile;
|
||||||
/* Radar. */
|
/* Radar. */
|
||||||
extern glColour cRadar_player;
|
extern glColour cRadar_player;
|
||||||
extern glColour cRadar_targ;
|
extern glColour cRadar_tPilot;
|
||||||
|
extern glColour cRadar_tPlanet;
|
||||||
extern glColour cRadar_weap;
|
extern glColour cRadar_weap;
|
||||||
/* Health. */
|
/* Health. */
|
||||||
extern glColour cShield;
|
extern glColour cShield;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "space.h"
|
#include "space.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "mission.h"
|
#include "mission.h"
|
||||||
|
#include "colour.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
#define MAP_WDWNAME "Star Map"
|
#define MAP_WDWNAME "Star Map"
|
||||||
@ -329,8 +330,8 @@ static void map_render(double bx, double by, double w, double h) {
|
|||||||
/* Check to make sure system is known of adjacent to known (or marked). */
|
/* Check to make sure system is known of adjacent to known (or marked). */
|
||||||
if(!sys_isMarked(sys) && !space_sysReachable(sys)) continue;
|
if(!sys_isMarked(sys) && !space_sysReachable(sys)) continue;
|
||||||
|
|
||||||
/* System Colours. */
|
/* System colours. */
|
||||||
if(sys == cur_system) col = &cRadar_targ;
|
if(sys == cur_system) col = &cRadar_tPlanet;
|
||||||
else if(!sys_isKnown(sys) || (sys->nplanets == 0)) col = &cInert;
|
else if(!sys_isKnown(sys) || (sys->nplanets == 0)) col = &cInert;
|
||||||
else col = faction_getColour(sys->faction);
|
else col = faction_getColour(sys->faction);
|
||||||
COLOUR(*col);
|
COLOUR(*col);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define VANGLE(v) ((v).angle)
|
#define VANGLE(v) ((v).angle)
|
||||||
|
|
||||||
#define MOD(x,y) (sqrt((x)*(x) + (y)*(y)))
|
#define MOD(x,y) (sqrt((x)*(x) + (y)*(y)))
|
||||||
#define ANGLE(x,y) (((x)==0.) ? 0. : atan2(y,x))
|
#define ANGLE(x,y) (atan2(y,x))
|
||||||
|
|
||||||
#define vect_dist(v,u) MOD((v)->x-(u)->x, (v)->y-(u)->y)
|
#define vect_dist(v,u) MOD((v)->x-(u)->x, (v)->y-(u)->y)
|
||||||
#define vect_odist(v) MOD((v)->x, (v)->y)
|
#define vect_odist(v) MOD((v)->x, (v)->y)
|
||||||
|
@ -1186,7 +1186,7 @@ static void gui_renderPilot(const Pilot* p) {
|
|||||||
sx = 0.85 * x;
|
sx = 0.85 * x;
|
||||||
sy = 0.85 * y;
|
sy = 0.85 * y;
|
||||||
|
|
||||||
COLOUR(cRadar_targ);
|
COLOUR(cRadar_tPilot);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glVertex2d(x, y);
|
glVertex2d(x, y);
|
||||||
glVertex2d(sx, sy);
|
glVertex2d(sx, sy);
|
||||||
@ -1207,7 +1207,7 @@ static void gui_renderPilot(const Pilot* p) {
|
|||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
/* Colours. */
|
/* Colours. */
|
||||||
if(p->id == player->target) col = &cRadar_targ;
|
if(p->id == player->target) col = &cRadar_tPilot;
|
||||||
else if(pilot_isDisabled(p)) col = &cInert;
|
else if(pilot_isDisabled(p)) col = &cInert;
|
||||||
else if(pilot_isFlag(p, PILOT_BRIBED)) col = &cNeutral;
|
else if(pilot_isFlag(p, PILOT_BRIBED)) col = &cNeutral;
|
||||||
else if(pilot_isFlag(p, PILOT_HOSTILE)) col = &cHostile;
|
else if(pilot_isFlag(p, PILOT_HOSTILE)) col = &cHostile;
|
||||||
|
40
src/space.c
40
src/space.c
@ -78,6 +78,8 @@ static Star* stars = NULL; /* Star array. */
|
|||||||
static int nstars = 0; /* Total stars. */
|
static int nstars = 0; /* Total stars. */
|
||||||
static int mstars = 0; /* Memory stars are taking. */
|
static int mstars = 0; /* Memory stars are taking. */
|
||||||
|
|
||||||
|
extern int planet_target; /* player.c */
|
||||||
|
|
||||||
/* Intern. */
|
/* Intern. */
|
||||||
/* Planet load. */
|
/* Planet load. */
|
||||||
static int planet_parse(Planet* planet, const xmlNodePtr parent);
|
static int planet_parse(Planet* planet, const xmlNodePtr parent);
|
||||||
@ -107,28 +109,60 @@ void planets_minimap(const double res, const double w,
|
|||||||
int i;
|
int i;
|
||||||
int cx, cy, x, y, r, rc;
|
int cx, cy, x, y, r, rc;
|
||||||
double p;
|
double p;
|
||||||
|
double a, tx, ty;
|
||||||
Planet* planet;
|
Planet* planet;
|
||||||
glColour* col;
|
glColour* col;
|
||||||
|
|
||||||
if(shape == RADAR_CIRCLE) rc = (int)(w*w);
|
if(shape == RADAR_CIRCLE) rc = (int)(w*w);
|
||||||
|
|
||||||
glBegin(GL_POINTS);
|
|
||||||
for(i = 0; i < cur_system->nplanets; i++) {
|
for(i = 0; i < cur_system->nplanets; i++) {
|
||||||
planet = cur_system->planets[i];
|
planet = cur_system->planets[i];
|
||||||
|
|
||||||
|
/* Get the colour. */
|
||||||
col = faction_getColour(planet->faction);
|
col = faction_getColour(planet->faction);
|
||||||
if((col != &cHostile) && !planet_hasService(planet, PLANET_SERVICE_BASIC))
|
if(i == planet_target)
|
||||||
|
col = &cRadar_tPlanet;
|
||||||
|
else if((col != &cHostile) && !planet_hasService(planet, PLANET_SERVICE_BASIC))
|
||||||
col = &cInert; /* Override non-hostile planets without services. */
|
col = &cInert; /* Override non-hostile planets without services. */
|
||||||
COLOUR(*col);
|
COLOUR(*col);
|
||||||
|
|
||||||
|
/* Some parameters. */
|
||||||
r = (int)(cur_system->planets[i]->gfx_space->sw / res);
|
r = (int)(cur_system->planets[i]->gfx_space->sw / res);
|
||||||
cx = (int)((cur_system->planets[i]->pos.x - player->solid->pos.x) / res);
|
cx = (int)((cur_system->planets[i]->pos.x - player->solid->pos.x) / res);
|
||||||
cy = (int)((cur_system->planets[i]->pos.y - player->solid->pos.y) / res);
|
cy = (int)((cur_system->planets[i]->pos.y - player->solid->pos.y) / res);
|
||||||
|
|
||||||
|
/* Check if in range. */
|
||||||
|
if(shape == RADAR_RECT) {
|
||||||
|
/* Out of range. */
|
||||||
|
if((ABS(cx) - r> 2/2.) || (ABS(cy) - r > h/2.))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if(shape == RADAR_CIRCLE) {
|
||||||
|
x = cx-r;
|
||||||
|
y = cy-r;
|
||||||
|
/* Out of range. */
|
||||||
|
if(x*x + y*y > rc) {
|
||||||
|
if(planet_target == i) {
|
||||||
|
/* Draw a line like the one for pilots. */
|
||||||
|
a = ANGLE(cx, cy);
|
||||||
|
tx = w*cos(a);
|
||||||
|
ty = w*sin(a);
|
||||||
|
|
||||||
|
COLOUR(cRadar_tPlanet);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2d( tx, ty );
|
||||||
|
glVertex2d( 0.85*tx, 0.85*ty);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
y = r;
|
y = r;
|
||||||
p = (5. - (double)(r*3)) / 4.;
|
p = (5. - (double)(r*3)) / 4.;
|
||||||
|
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
|
||||||
PIXEL(cx, cy+y);
|
PIXEL(cx, cy+y);
|
||||||
PIXEL(cx, cy-y);
|
PIXEL(cx, cy-y);
|
||||||
PIXEL(cx+y, cy);
|
PIXEL(cx+y, cy);
|
||||||
@ -162,8 +196,8 @@ void planets_minimap(const double res, const double w,
|
|||||||
PIXEL(cx-y, cy-x);
|
PIXEL(cx-y, cy-x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#undef PIXEL
|
#undef PIXEL
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user