fixed plane selection when over multiple within cutoff
Former-commit-id: 3427181832689a8a05aadd31046e7d4ebea050e5 Former-commit-id: 73ab51fc18ef6bde1ea8f93e6433af61cb41229c
This commit is contained in:
parent
00f02a8125
commit
ed853a3145
54
draw.c
54
draw.c
|
@ -925,16 +925,37 @@ void drawPlanes() {
|
|||
time_t now = time(NULL);
|
||||
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) {
|
||||
if ((now - p->seen) < Modes.interactive_display_ttl) {
|
||||
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;
|
||||
}
|
||||
|
||||
if(selectedPlane == NULL) {
|
||||
selectedPlane = selection;
|
||||
}
|
||||
|
||||
|
||||
p = planes;
|
||||
|
||||
while(p) {
|
||||
|
@ -982,18 +1003,27 @@ void drawPlanes() {
|
|||
|
||||
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);
|
||||
lineRGBA(appData.renderer, usex + 20, usey - 20, usex + 20, usey - 5, pink.r, pink.g, pink.b, 255);
|
||||
float elapsed = mstime() - appData.touchDownTime;
|
||||
|
||||
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);
|
||||
int boxSize;
|
||||
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 - 20, usey + 20, usex - 20, usey + 5, 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);
|
||||
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
if((p->cx - appData.touchx) * (p->cx - appData.touchx) + (p->cy - appData.touchy) * (p->cy - appData.touchy) < 900) {
|
||||
selectedPlane = p;
|
||||
}
|
||||
|
||||
if(p != selectedPlane) {
|
||||
drawPlaneText(p);
|
||||
|
|
|
@ -1 +1 @@
|
|||
4ae8e7876cd2e093957fa204a0d05b37b84446e9
|
||||
f1227086156bca68b563a45527bb1442279dc1f5
|
|
@ -1 +1 @@
|
|||
edf88a35375fe1494f482826638f6a8879c9f1cb
|
||||
cbbacac08ce30232fcad4a508249c7e61768effa
|
Loading…
Reference in a new issue