adding PC control options like fullscreen, added simple circle anim on first valid lat/long

Former-commit-id: da1002442084eb38451e0a048a6dfee888e0852f
Former-commit-id: f28b4b9bc6e18935c06c947570fccb2c55a5bd14
This commit is contained in:
nathan 2018-10-01 01:44:17 -05:00
parent 4a79fc6af0
commit fbfa9fd533
10 changed files with 69 additions and 80 deletions

View file

@ -14,7 +14,7 @@
#define SCREEN_HEIGHT 480
#define UPSCALE 1
#define SCALE 1
#define UISCALE 1
#define LOGMAXDIST 1000.0
#define MAXDIST 50.0

View file

@ -160,7 +160,7 @@
// at least greater than a given level for us to dump the signal.
#define MODES_DEBUG_NOPREAMBLE_LEVEL 25
#define MODES_INTERACTIVE_REFRESH_TIME 250 // Milliseconds
#define MODES_INTERACTIVE_REFRESH_TIME 33 // Milliseconds
#define MODES_INTERACTIVE_ROWS 22 // Rows on screen
#define MODES_INTERACTIVE_DELETE_TTL 300 // Delete from the list after 300 seconds
#define MODES_INTERACTIVE_DISPLAY_TTL 60 // Delete from display after 60 seconds
@ -233,6 +233,7 @@ struct aircraft {
double oldDx[MODES_INTERACTIVE_TRAIL_LENGTH], oldDy[MODES_INTERACTIVE_TRAIL_LENGTH]; // position history
time_t oldSeen[MODES_INTERACTIVE_TRAIL_LENGTH];// position time
uint8_t oldIdx; // index for ring buffer
uint64_t created;
int bFlags; // Flags related to valid fields in this structure
struct aircraft *next; // Next aircraft in our linked list
};
@ -344,9 +345,11 @@ struct { // Internal state
//display options
int screen_upscale;
int screen_uiscale;
int screen_width;
int screen_height;
int screen_depth;
int fullscreen;
// User details
double fUserLat; // Users receiver/antenna lat/lon needed for initial surface location

View file

@ -59,12 +59,17 @@ void init(char *title)
Modes.screen_upscale = 1;
#endif
Uint32 flags = SDL_HWPALETTE|SDL_DOUBLEBUF;
if(Modes.fullscreen) {
flags = flags | SDL_FULLSCREEN;
}
if(Modes.screen_upscale > 1) {
game.bigScreen = SDL_SetVideoMode(Modes.screen_width * Modes.screen_upscale, Modes.screen_height * Modes.screen_upscale, Modes.screen_depth, SDL_HWPALETTE|SDL_DOUBLEBUF);
game.bigScreen = SDL_SetVideoMode(Modes.screen_width * Modes.screen_upscale, Modes.screen_height * Modes.screen_upscale, Modes.screen_depth, flags);
game.screen = SDL_CreateRGBSurface(0, Modes.screen_width, Modes.screen_height, Modes.screen_depth, 0, 0, 0, 0);
} else {
game.screen = SDL_SetVideoMode(Modes.screen_width, Modes.screen_height, Modes.screen_depth, SDL_HWPALETTE|SDL_DOUBLEBUF);
game.screen = SDL_SetVideoMode(Modes.screen_width, Modes.screen_height, Modes.screen_depth, flags);
}
if (game.screen == NULL)
@ -78,22 +83,22 @@ void init(char *title)
/* Load the font */
game.mapFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * SCALE);
game.mapBoldFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * SCALE);
game.mapFont = loadFont("font/TerminusTTF-4.46.0.ttf", 12 * Modes.screen_uiscale);
game.mapBoldFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12 * Modes.screen_uiscale);
game.listFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 18 * SCALE);
game.listFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 18 * Modes.screen_uiscale);
game.messageFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 34 * SCALE);
game.labelFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 16 * SCALE);
game.messageFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 34 * Modes.screen_uiscale);
game.labelFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 16 * Modes.screen_uiscale);
game.mapFontWidth = 5 * SCALE;
game.mapFontHeight = 12 * SCALE;
game.mapFontWidth = 5 * Modes.screen_uiscale;
game.mapFontHeight = 12 * Modes.screen_uiscale;
game.messageFontWidth = 17 * SCALE;
game.messageFontHeight = 34 * SCALE;
game.messageFontWidth = 17 * Modes.screen_uiscale;
game.messageFontHeight = 34 * Modes.screen_uiscale;
game.labelFontWidth = 5 * SCALE;
game.labelFontHeight = 10 * SCALE;
game.labelFontWidth = 5 * Modes.screen_uiscale;
game.labelFontHeight = 10 * Modes.screen_uiscale;
/* Set the screen title */

View file

@ -45,8 +45,8 @@ void getInput()
case SDLK_m:
Modes.map = !Modes.map;
break;
break;
default:
break;
}

View file

@ -139,6 +139,8 @@ struct aircraft *interactiveCreateAircraft(struct modesMessage *mm) {
a->addr = mm->addr;
a->lat = a->lon = 0.0;
a->created = 0;
a->oldIdx = 0;
memset(a->oldDx, 0, sizeof(a->oldDx));
memset(a->oldDy, 0, sizeof(a->oldDy));

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
b27351eb14efa48364b7125548c8aa825a31afc6

View file

@ -8,6 +8,16 @@
#define CENTEROFFSET .375
static uint64_t mstime(void) {
struct timeval tv;
uint64_t mst;
gettimeofday(&tv, NULL);
mst = ((uint64_t)tv.tv_sec)*1000;
mst += tv.tv_usec/1000;
return mst;
}
void CROSSVP(double *v, double *u, double *w)
{
v[0] = u[1]*w[2] - u[2]*(w)[1];
@ -73,10 +83,10 @@ void drawPlaneHeading(int x, int y, double heading, SDL_Color planeColor)
return;
}
double body = 8.0 * SCALE;
double wing = 6.0 * SCALE;
double tail = 3.0 * SCALE;
double bodyWidth = 2.0 * SCALE;
double body = 8.0 * Modes.screen_uiscale;
double wing = 6.0 * Modes.screen_uiscale;
double tail = 3.0 * Modes.screen_uiscale;
double bodyWidth = 2.0 * Modes.screen_uiscale;
double vec[3];
vec[0] = sin(heading * M_PI / 180);
@ -104,7 +114,7 @@ void drawPlaneHeading(int x, int y, double heading, SDL_Color planeColor)
} else {
thickLineRGBA(game.screen,x,y,x2,y2,bodyWidth,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
filledTrigonRGBA(game.screen, x + round(-wing*.35*out[0]), y + round(-wing*.35*out[1]), x + round(wing*.35*out[0]), y + round(wing*.35*out[1]), x1, y1,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
filledCircleRGBA(game.screen, x2,y2,SCALE,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
filledCircleRGBA(game.screen, x2,y2,Modes.screen_uiscale,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
}
//wing
@ -190,7 +200,7 @@ void drawTrail(double *oldDx, double *oldDy, time_t * oldSeen, int idx) {
aalineRGBA(game.screen, prevX, prevY, currentX, currentY,colorVal, colorVal, colorVal, SDL_ALPHA_OPAQUE);
} else {
//thickLineRGBA(game.screen, prevX, prevY, currentX, currentY, 2, colorVal, colorVal, colorVal, SDL_ALPHA_OPAQUE);
thickLineRGBA(game.screen, prevX, prevY, currentX, currentY, 2 * SCALE, colorVal, colorVal, colorVal, SDL_ALPHA_OPAQUE);
thickLineRGBA(game.screen, prevX, prevY, currentX, currentY, 2 * Modes.screen_uiscale, colorVal, colorVal, colorVal, SDL_ALPHA_OPAQUE);
}
}
}
@ -243,7 +253,7 @@ void drawGeography() {
if(AA) {
aalineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, (alpha < 0) ? 0 : (uint8_t) alpha);
} else {
thickLineRGBA(game.screen, x1, y1, x2, y2, SCALE, purple.r,purple.g,purple.b, (alpha < 0) ? 0 : (uint8_t) alpha);
thickLineRGBA(game.screen, x1, y1, x2, y2, Modes.screen_uiscale, purple.r,purple.g,purple.b, (alpha < 0) ? 0 : (uint8_t) alpha);
}
}
}
@ -277,6 +287,15 @@ void drawMap(void) {
int x, y;
screenCoords(&x, &y, a->dx, a->dy);
if(a->created == 0) {
a->created = mstime();
}
double age_ms = (double)(mstime() - a->created);
if(age_ms < 500) {
circleRGBA(game.screen, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
}
if(MODES_ACFLAGS_HEADING_VALID) {
drawPlaneHeading(x, y,a->track, planeColor);

View file

@ -1 +1 @@
6d9c5442d0ddf630e47b4e32c4f9ea2b5ebf4d91
28dc4d035492ea5f8627c495e51ea37b58ea01ec

View file

@ -91,9 +91,11 @@ void view1090InitConfig(void) {
// Display options
Modes.screen_upscale = UPSCALE;
Modes.screen_uiscale = UISCALE;
Modes.screen_width = SCREEN_WIDTH;
Modes.screen_height = SCREEN_HEIGHT;
Modes.screen_depth = 32;
Modes.fullscreen = 0;
// Initialize status
Status.msgRate = 0;
@ -212,7 +214,10 @@ void showHelp(void) {
"\n-----------------------------------------------------------------------------\n"
"| SDL DISPLAY OPTIONS |\n"
"-----------------------------------------------------------------------------\n"
"--upscale <factor> Pixel upscaling\n"
"--upscale <factor> Buffer upscaling\n"
"--uiscale <factor> UI global scaling\n"
"--screensize <width> <height>\n"
"--fullscreen Start fullscreen\n"
);
}
@ -297,8 +302,15 @@ int main(int argc, char **argv) {
Modes.nfix_crc = 0;
} else if (!strcmp(argv[j],"--aggressive")) {
Modes.nfix_crc = MODES_MAX_BITERRORS;
} else if (!strcmp(argv[j],"--fullscreen")) {
Modes.fullscreen = 1;
} else if (!strcmp(argv[j],"--upscale") && more) {
Modes.screen_upscale = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--uiscale") && more) {
Modes.screen_uiscale = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--screensize") && more) {
Modes.screen_width = atoi(argv[++j]);
Modes.screen_height = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--help")) {
showHelp();
exit(0);
@ -372,7 +384,6 @@ int main(int argc, char **argv) {
while (go == 1)
{
getInput();
interactiveRemoveStaleAircrafts();
@ -387,7 +398,7 @@ int main(int argc, char **argv) {
}
modesReadFromClient(c,"",decodeBinMessage);
usleep(100000);
usleep(10000);
}
// The user has stopped us, so close any socket we opened