fixed plane selection when over multiple within cutoff

Former-commit-id: ed853a3145 [formerly 73ab51fc18ef6bde1ea8f93e6433af61cb41229c] [formerly 3427181832689a8a05aadd31046e7d4ebea050e5]
Former-commit-id: f8a4bd5efa51e94ff8366c6660aea76a5fa6ecd5
Former-commit-id: cb7dff754c6a523b957f1386af544075d6001590
This commit is contained in:
nathan 2020-02-17 23:17:19 -08:00
parent 617b1af43e
commit 78ca658fa1
3 changed files with 42 additions and 16 deletions

54
draw.c
View file

@ -925,16 +925,37 @@ void drawPlanes() {
time_t now = time(NULL); time_t now = time(NULL);
SDL_Color planeColor; SDL_Color planeColor;
//draw all trails first so they don't cover up planes and text // draw all trails first so they don't cover up planes and text
// also find closest plane to selection point
struct planeObj *selection = NULL;
while(p) { while(p) {
if ((now - p->seen) < Modes.interactive_display_ttl) { if ((now - p->seen) < Modes.interactive_display_ttl) {
drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx); drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx);
} }
if(selectedPlane == NULL) {
if((p->cx - appData.touchx) * (p->cx - appData.touchx) + (p->cy - appData.touchy) * (p->cy - appData.touchy) < 900) {
if(selection) {
if((p->cx - appData.touchx) * (p->cx - appData.touchx) + (p->cy - appData.touchy) * (p->cy - appData.touchy) <
(selection->cx - appData.touchx) * (selection->cx - appData.touchx) + (selection->cy - appData.touchy) * (selection->cy - appData.touchy)) {
selection = p;
}
} else {
selection = p;
}
}
}
p = p->next; p = p->next;
} }
if(selectedPlane == NULL) {
selectedPlane = selection;
}
p = planes; p = planes;
while(p) { while(p) {
@ -982,18 +1003,27 @@ void drawPlanes() {
appData.mapMoved = 1; appData.mapMoved = 1;
} }
lineRGBA(appData.renderer, usex - 20, usey - 20, usex - 5, usey - 20, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - 20, usey - 20, usex - 20, usey - 5, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex + 20, usey - 20, usex + 5, usey - 20, pink.r, pink.g, pink.b, 255); float elapsed = mstime() - appData.touchDownTime;
lineRGBA(appData.renderer, usex + 20, usey - 20, usex + 20, usey - 5, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex + 20, usey + 20, usex + 5, usey + 20, pink.r, pink.g, pink.b, 255); int boxSize;
lineRGBA(appData.renderer, usex + 20, usey + 20, usex + 20, usey + 5, pink.r, pink.g, pink.b, 255); if(elapsed < 300) {
boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed))));
} else {
boxSize = 20;
}
//rectangleRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - 20, usey + 20, usex - 5, usey + 20, pink.r, pink.g, pink.b, 255); lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - 20, usey + 20, usex - 20, usey + 5, pink.r, pink.g, pink.b, 255); lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE); planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
} else { } else {
planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE); planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
@ -1017,10 +1047,6 @@ void drawPlanes() {
//lineRGBA(appData.renderer, usex, usey, p->x+(p->w/2), p->y, 200,200,200, SDL_ALPHA_OPAQUE); //lineRGBA(appData.renderer, usex, usey, p->x+(p->w/2), p->y, 200,200,200, SDL_ALPHA_OPAQUE);
} }
if((p->cx - appData.touchx) * (p->cx - appData.touchx) + (p->cy - appData.touchy) * (p->cy - appData.touchy) < 900) {
selectedPlane = p;
}
if(p != selectedPlane) { if(p != selectedPlane) {
drawPlaneText(p); drawPlaneText(p);

View file

@ -1 +1 @@
4ae8e7876cd2e093957fa204a0d05b37b84446e9 f1227086156bca68b563a45527bb1442279dc1f5

View file

@ -1 +1 @@
edf88a35375fe1494f482826638f6a8879c9f1cb cbbacac08ce30232fcad4a508249c7e61768effa