[Change] Unified colouring schemes.

This commit is contained in:
Allanis 2013-08-09 20:45:17 +01:00
parent 47f132a467
commit 79411d240e
7 changed files with 35 additions and 23 deletions

View File

@ -120,6 +120,14 @@ int faction_getPlayer(int f) {
}
}
/* Get the colour of the faction based on its standing with the player. */
glColour* faction_getColour(int f) {
if(f == -1) return &cInert;
else if(areAllies(FACTION_PLAYER, f)) return &cFriend;
else if(areEnemies(FACTION_PLAYER, f)) return &cHostile;
else return &cNeutral;
}
/* Return the players standing. */
static char* player_standings[] = {
"Hero", /* 0 */

View File

@ -1,4 +1,5 @@
#pragma once
#include "colour.h"
#define FACTION_PLAYER 0
@ -11,6 +12,7 @@ char* faction_longname(int f);
void faction_modPlayer(int f, int mod);
int faction_getPlayer(int f);
char* faction_getStanding(int mod);
glColour* faction_getColour(int f);
/* Works with only factions. */
int areEnemies(int a, int b);

View File

@ -322,11 +322,10 @@ static void map_render(double bx, double by, double w, double h) {
if(!sys_isMarked(sys) && !space_sysReachable(sys)) continue;
/* System Colours. */
if(sys == cur_system) COLOUR(cRadar_targ);
else if(!sys_isKnown(sys) || (sys->nplanets==0) || (sys->faction==-1))
COLOUR(cInert);
else if(areEnemies(player->faction, sys->faction)) COLOUR(cRed);
else COLOUR(cYellow);
if(sys == cur_system) col = &cRadar_targ;
else if(!sys_isKnown(sys) || (sys->nplanets == 0)) col = &cInert;
else col = faction_getColour(sys->faction);
COLOUR(*col);
/* Draw the system. */
tx = x + sys->pos.x * map_zoom;

View File

@ -104,7 +104,8 @@ unsigned pilot_getNearestHostile(void) {
tp = PLAYER_ID;
d = 0;
for(i = 0; i < pilot_nstack; i++)
if(pilot_isFlag(pilot_stack[i], PILOT_HOSTILE)) {
if(pilot_isFlag(pilot_stack[i], PILOT_HOSTILE) ||
areEnemies(FACTION_PLAYER, pilot_stack[i]->faction)) {
td = vect_dist(&pilot_stack[i]->solid->pos, &player->solid->pos);
if(!pilot_isDisabled(pilot_stack[i]) && ((tp == PLAYER_ID) || (td < d))) {
d = td;

View File

@ -71,7 +71,7 @@ typedef struct Pilot_ {
char* name; /* Pilot's name (if unique). */
char* title; /* Title - Usuall indicating special properties - TODO. */
int faction;
int faction; /* Pilot faction. */
/* Object characteristics. */
Ship* ship; /* Pilots ship. */

View File

@ -547,8 +547,7 @@ void player_renderBG(void) {
if(planet_target >= 0) {
planet = &cur_system->planets[planet_target];
if(areEnemies(player->faction, planet->faction)) c = &cHostile;
else c = &cNeutral;
c = faction_getColour(planet->faction);
x = planet->pos.x - planet->gfx_space->sw/2.;
y = planet->pos.y + planet->gfx_space->sh/2.;
@ -581,7 +580,7 @@ void player_render(void) {
/* There is still a pilot target. */
if(pilot_isDisabled(p)) c = &cInert;
else if(pilot_isFlag(p, PILOT_HOSTILE)) c = &cHostile;
else c = &cNeutral;
else c = faction_getColour(p->faction);
x = p->solid->pos.x - p->ship->gfx_space->sw * PILOT_SIZE_APROX/2.;
y = p->solid->pos.y + p->ship->gfx_space->sh * PILOT_SIZE_APROX/2.;
@ -869,6 +868,7 @@ void player_renderGUI(void) {
static void gui_renderPilot(const Pilot* p) {
int x, y, sx, sy;
double w, h;
glColour* col;
x = (p->solid->pos.x - player->solid->pos.x) / gui.radar.res;
y = (p->solid->pos.y - player->solid->pos.y) / gui.radar.res;
@ -878,8 +878,9 @@ static void gui_renderPilot(const Pilot* p) {
if(sy < 1.) sy = 1.;
if(((gui.radar.shape == RADAR_RECT) && ((ABS(x) > gui.radar.w/2.+sx)
|| (ABS(y) > gui.radar.h/2.+sy))) || ((gui.radar.shape == RADAR_CIRCLE) &&
((x*x + y*y) > (int)(gui.radar.w*gui.radar.w))))
|| (ABS(y) > gui.radar.h/2.+sy))) ||
((gui.radar.shape == RADAR_CIRCLE) &&
((x*x + y*y) > (int)(gui.radar.w*gui.radar.w))))
return; /* Pilot isn't in range. */
if(gui.radar.shape == RADAR_RECT) {
@ -893,10 +894,11 @@ static void gui_renderPilot(const Pilot* p) {
glBegin(GL_QUADS);
/* Colours. */
if(p->id == player_target) COLOUR(cRadar_targ);
else if(pilot_isDisabled(p)) COLOUR(cInert);
else if(pilot_isFlag(p, PILOT_HOSTILE)) COLOUR(cHostile);
else COLOUR(cNeutral);
if(p->id == player_target) col = &cRadar_targ;
else if(pilot_isDisabled(p)) col = &cInert;
else if(pilot_isFlag(p, PILOT_HOSTILE)) col = &cHostile;
else col = faction_getColour(p->faction);
COLOUR(*col);
/* Image. */
glVertex2d(MAX(x-sx, -w), MIN(y+sy, h)); /* Top left. */

View File

@ -93,6 +93,7 @@ void planets_minimap(const double res, const double w,
int cx, cy, x, y, r, rc;
double p;
Planet* planet;
glColour* col;
if(shape == RADAR_CIRCLE) rc = (int)(w*w);
@ -100,13 +101,12 @@ void planets_minimap(const double res, const double w,
for(i = 0; i < cur_system->nplanets; i++) {
planet = &cur_system->planets[i];
if((planet->faction == -1) && !planet_hasService(planet, PLANET_SERVICE_BASIC))
COLOUR(cInert);
else if(areEnemies(player->faction, planet->faction))
COLOUR(cHostile);
else if(areAllies(player->faction, planet->faction))
COLOUR(cFriend);
else COLOUR(cNeutral);
if(!planet_hasService(planet, PLANET_SERVICE_BASIC))
col = &cInert;
else
col = faction_getColour(planet->faction);
COLOUR(*col);
r = (int)(cur_system->planets[i].gfx_space->sw / 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);