fixed some drawTrail double line issues, cleaning up color assignments
This commit is contained in:
parent
80e776d470
commit
9c46dcbd58
|
@ -104,6 +104,12 @@ void AircraftList::update(Modes *modes) {
|
||||||
if(p->lon == 0) {
|
if(p->lon == 0) {
|
||||||
p->created = now();
|
p->created = now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(p->lon == a->lon && p->lat == a->lat) {
|
||||||
|
a = a->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
p->lon = a->lon;
|
p->lon = a->lon;
|
||||||
p->lat = a->lat;
|
p->lat = a->lat;
|
||||||
|
|
||||||
|
|
93
View.cpp
93
View.cpp
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
//color schemes
|
//color schemes
|
||||||
#include "parula.h"
|
#include "parula.h"
|
||||||
#include "monokai.h"
|
|
||||||
|
|
||||||
#include "View.h"
|
#include "View.h"
|
||||||
|
|
||||||
|
@ -318,25 +317,6 @@ void View::font_init() {
|
||||||
|
|
||||||
labelFontWidth = 6 * screen_uiscale;
|
labelFontWidth = 6 * screen_uiscale;
|
||||||
labelFontHeight = 12 * screen_uiscale;
|
labelFontHeight = 12 * screen_uiscale;
|
||||||
|
|
||||||
//
|
|
||||||
// todo separate style stuff
|
|
||||||
//
|
|
||||||
|
|
||||||
SDL_Color bgcolor = {0,0,20,255};
|
|
||||||
SDL_Color greenblue = {236,192,68,255};
|
|
||||||
SDL_Color lightblue = {211,208,203,255};
|
|
||||||
SDL_Color mediumblue ={110,136,152,255};
|
|
||||||
SDL_Color darkblue = {23,41,51,255};
|
|
||||||
|
|
||||||
style.backgroundColor = bgcolor;
|
|
||||||
style.selectedColor = pink;
|
|
||||||
style.planeColor = greenblue;
|
|
||||||
style.planeGoneColor = grey;
|
|
||||||
style.mapInnerColor = darkblue;
|
|
||||||
style.mapOuterColor = darkblue;
|
|
||||||
style.scaleBarColor = lightGrey;
|
|
||||||
style.buttonColor = lightblue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::drawString(std::string text, int x, int y, TTF_Font *font, SDL_Color color)
|
void View::drawString(std::string text, int x, int y, TTF_Font *font, SDL_Color color)
|
||||||
|
@ -411,7 +391,7 @@ void View::drawStatusBox(int *left, int *top, std::string label, std::string mes
|
||||||
|
|
||||||
// filled black background
|
// filled black background
|
||||||
if(messageWidth) {
|
if(messageWidth) {
|
||||||
roundedBoxRGBA(renderer, *left, *top, *left + labelWidth + messageWidth, *top + messageFontHeight, ROUND_RADIUS, black.r, black.g, black.b, SDL_ALPHA_OPAQUE);
|
roundedBoxRGBA(renderer, *left, *top, *left + labelWidth + messageWidth, *top + messageFontHeight, ROUND_RADIUS, style.buttonBackground.r, style.buttonBackground.g, style.buttonBackground.b, SDL_ALPHA_OPAQUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filled label box
|
// filled label box
|
||||||
|
@ -424,7 +404,7 @@ void View::drawStatusBox(int *left, int *top, std::string label, std::string mes
|
||||||
roundedRectangleRGBA(renderer, *left, *top, *left + labelWidth + messageWidth, *top + messageFontHeight, ROUND_RADIUS,color.r, color.g, color.b, SDL_ALPHA_OPAQUE);
|
roundedRectangleRGBA(renderer, *left, *top, *left + labelWidth + messageWidth, *top + messageFontHeight, ROUND_RADIUS,color.r, color.g, color.b, SDL_ALPHA_OPAQUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString(label, *left + labelFontWidth/2, *top, labelFont, black);
|
drawString(label, *left + labelFontWidth/2, *top, labelFont, style.buttonBackground);
|
||||||
|
|
||||||
//message
|
//message
|
||||||
drawString(message, *left + labelWidth + messageFontWidth/2, *top, messageFont, color);
|
drawString(message, *left + labelWidth + messageFontWidth/2, *top, messageFont, color);
|
||||||
|
@ -582,9 +562,9 @@ void View::drawTrails(int left, int top, int right, int bottom) {
|
||||||
std::vector<float>::iterator lat_idx = p->latHistory.begin();
|
std::vector<float>::iterator lat_idx = p->latHistory.begin();
|
||||||
std::vector<float>::iterator heading_idx = p->headingHistory.begin();
|
std::vector<float>::iterator heading_idx = p->headingHistory.begin();
|
||||||
|
|
||||||
int idx = p->lonHistory.size();
|
float age = 0;
|
||||||
|
|
||||||
for(; std::next(lon_idx) != p->lonHistory.end(); ++lon_idx, ++lat_idx, ++heading_idx) {
|
for(; std::next(lon_idx) != p->lonHistory.end(); ++lon_idx, ++lat_idx, ++heading_idx, age += 1.0) {
|
||||||
|
|
||||||
pxFromLonLat(&dx, &dy, *(std::next(lon_idx)), *(std::next(lat_idx)));
|
pxFromLonLat(&dx, &dy, *(std::next(lon_idx)), *(std::next(lat_idx)));
|
||||||
screenCoords(¤tX, ¤tY, dx, dy);
|
screenCoords(¤tX, ¤tY, dx, dy);
|
||||||
|
@ -596,14 +576,11 @@ void View::drawTrails(int left, int top, int right, int bottom) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// float age = pow(1.0 - (float)idx / (float)p->lonHistory.size(), 2.2);
|
uint8_t colorVal = 255;//(uint8_t)floor(255.0 * (0.5 + age / (float)p->lonHistory.size()));
|
||||||
float age = 1.0 - (float)idx / (float)p->lonHistory.size();
|
|
||||||
|
|
||||||
uint8_t colorVal = (uint8_t)floor(255.0 * clamp(age,0,0.5));
|
//thickLineRGBA(renderer, prevX, prevY, currentX, currentY, 2 * screen_uiscale, 255, 255, 255, colorVal);
|
||||||
|
lineRGBA(renderer, prevX, prevY, currentX, currentY, style.trailColor.r, style.trailColor.g, style.trailColor.b, colorVal);
|
||||||
|
|
||||||
thickLineRGBA(renderer, prevX, prevY, currentX, currentY, 2 * screen_uiscale, 255, 255, 255, colorVal);
|
|
||||||
|
|
||||||
idx--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = p->next;
|
p = p->next;
|
||||||
|
@ -647,9 +624,9 @@ void View::drawLines(int left, int top, int right, int bottom, int bailTime) {
|
||||||
latLonFromScreenCoords(&screen_lat_min, &screen_lon_min, left, top);
|
latLonFromScreenCoords(&screen_lat_min, &screen_lon_min, left, top);
|
||||||
latLonFromScreenCoords(&screen_lat_max, &screen_lon_max, right, bottom);
|
latLonFromScreenCoords(&screen_lat_max, &screen_lon_max, right, bottom);
|
||||||
|
|
||||||
drawLinesRecursive(&(map.root), screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max, style.mapInnerColor);
|
drawLinesRecursive(&(map.root), screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max, style.geoColor);
|
||||||
|
|
||||||
drawLinesRecursive(&(map.airport_root), screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max, orange);
|
drawLinesRecursive(&(map.airport_root), screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max, style.airportColor);
|
||||||
|
|
||||||
drawTrails(left, top, right, bottom);
|
drawTrails(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
@ -742,7 +719,7 @@ void View::drawPlaceNames() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString((*label)->text, x, y, mapFont, grey);
|
drawString((*label)->text, x, y, mapFont, style.geoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::vector<Label*>::iterator label = map.airportnames.begin(); label != map.airportnames.end(); ++label) {
|
for(std::vector<Label*>::iterator label = map.airportnames.begin(); label != map.airportnames.end(); ++label) {
|
||||||
|
@ -756,7 +733,7 @@ void View::drawPlaceNames() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString((*label)->text, x, y, listFont, red);
|
drawString((*label)->text, x, y, listFont, style.airportColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,7 +861,7 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
maxCharCount = snprintf(flight,10," %s", p->flight);
|
maxCharCount = snprintf(flight,10," %s", p->flight);
|
||||||
|
|
||||||
if(maxCharCount > 1) {
|
if(maxCharCount > 1) {
|
||||||
drawStringBG(flight, p->x, p->y, mapBoldFont, white, black);
|
drawStringBG(flight, p->x, p->y, mapBoldFont, style.labelColor, style.labelBackground);
|
||||||
//roundedRectangleRGBA(renderer, p->x, p->y, p->x + maxCharCount * mapFontWidth, p->y + mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
//roundedRectangleRGBA(renderer, p->x, p->y, p->x + maxCharCount * mapFontWidth, p->y + mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
||||||
//drawString(flight, p->x, p->y, mapBoldFont, white);
|
//drawString(flight, p->x, p->y, mapBoldFont, white);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
|
@ -900,7 +877,7 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCharCount > 1) {
|
if(currentCharCount > 1) {
|
||||||
drawStringBG(alt, p->x, p->y + currentLine * mapFontHeight, mapFont, grey, black);
|
drawStringBG(alt, p->x, p->y + currentLine * mapFontHeight, mapFont, style.subLabelColor, style.labelBackground);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +893,7 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCharCount > 1) {
|
if(currentCharCount > 1) {
|
||||||
drawStringBG(speed, p->x, p->y + currentLine * mapFontHeight, mapFont, grey, black);
|
drawStringBG(speed, p->x, p->y + currentLine * mapFontHeight, mapFont, style.subLabelColor, style.labelBackground);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,10 +921,10 @@ void View::drawPlaneText(Aircraft *p) {
|
||||||
vy[3] = p->y + currentLine * mapFontHeight;
|
vy[3] = p->y + currentLine * mapFontHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
bezierRGBA(renderer,vx,vy,4,2,200,200,200,SDL_ALPHA_OPAQUE);
|
bezierRGBA(renderer,vx,vy,4,2,style.labelLineColor.r,style.labelLineColor.g,style.labelLineColor.b,SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
|
|
||||||
thickLineRGBA(renderer,p->x,p->y,p->x,p->y+currentLine*mapFontHeight,screen_uiscale,200,200,200,SDL_ALPHA_OPAQUE);
|
thickLineRGBA(renderer,p->x,p->y,p->x,p->y+currentLine*mapFontHeight,screen_uiscale,style.labelLineColor.r,style.labelLineColor.g,style.labelLineColor.b,SDL_ALPHA_OPAQUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->w = maxCharCount * mapFontWidth;
|
p->w = maxCharCount * mapFontWidth;
|
||||||
|
@ -977,7 +954,7 @@ void View::drawSelectedAircraftText(Aircraft *p) {
|
||||||
maxCharCount = snprintf(flight,10," %s", p->flight);
|
maxCharCount = snprintf(flight,10," %s", p->flight);
|
||||||
|
|
||||||
if(maxCharCount > 1) {
|
if(maxCharCount > 1) {
|
||||||
drawStringBG(flight, x, y, mapBoldFont, white, black);
|
drawStringBG(flight, x, y, mapBoldFont, style.labelColor, style.labelBackground);
|
||||||
//roundedRectangleRGBA(renderer, p->x, p->y, p->x + maxCharCount * mapFontWidth, p->y + mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
//roundedRectangleRGBA(renderer, p->x, p->y, p->x + maxCharCount * mapFontWidth, p->y + mapFontHeight, ROUND_RADIUS, white.r, white.g, white.b, SDL_ALPHA_OPAQUE);
|
||||||
//drawString(flight, p->x, p->y, mapBoldFont, white);
|
//drawString(flight, p->x, p->y, mapBoldFont, white);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
|
@ -991,7 +968,7 @@ void View::drawSelectedAircraftText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCharCount > 1) {
|
if(currentCharCount > 1) {
|
||||||
drawStringBG(alt, x, y + currentLine * mapFontHeight, mapFont, grey, black);
|
drawStringBG(alt, x, y + currentLine * mapFontHeight, mapFont, style.subLabelColor, style.labelBackground);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,7 +984,7 @@ void View::drawSelectedAircraftText(Aircraft *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentCharCount > 1) {
|
if(currentCharCount > 1) {
|
||||||
drawStringBG(speed, x, y + currentLine * mapFontHeight, mapFont, grey, black);
|
drawStringBG(speed, x, y + currentLine * mapFontHeight, mapFont, style.subLabelColor, style.labelBackground);
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1402,21 +1379,21 @@ void View::moveMapToTarget() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::drawMouse() {
|
// void View::drawMouse() {
|
||||||
if(!mouseMoved) {
|
// if(!mouseMoved) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(elapsed(mouseMovedTime) > 1000) {
|
// if(elapsed(mouseMovedTime) > 1000) {
|
||||||
mouseMoved = false;
|
// mouseMoved = false;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int alpha = (int)(255.0f - 255.0f * (float)elapsed(mouseMovedTime) / 1000.0f);
|
// int alpha = (int)(255.0f - 255.0f * (float)elapsed(mouseMovedTime) / 1000.0f);
|
||||||
|
|
||||||
lineRGBA(renderer, mousex - 10 * screen_uiscale, mousey, mousex + 10 * screen_uiscale, mousey, white.r, white.g, white.b, alpha);
|
// lineRGBA(renderer, mousex - 10 * screen_uiscale, mousey, mousex + 10 * screen_uiscale, mousey, white.r, white.g, white.b, alpha);
|
||||||
lineRGBA(renderer, mousex, mousey - 10 * screen_uiscale, mousex, mousey + 10 * screen_uiscale, white.r, white.g, white.b, alpha);
|
// lineRGBA(renderer, mousex, mousey - 10 * screen_uiscale, mousex, mousey + 10 * screen_uiscale, white.r, white.g, white.b, alpha);
|
||||||
}
|
// }
|
||||||
|
|
||||||
void View::drawClick() {
|
void View::drawClick() {
|
||||||
if(clickx && clicky) {
|
if(clickx && clicky) {
|
||||||
|
@ -1429,7 +1406,7 @@ void View::drawClick() {
|
||||||
clicky = 0;
|
clicky = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
filledCircleRGBA(renderer, clickx, clicky, radius, white.r, white.g, white.b, alpha);
|
filledCircleRGBA(renderer, clickx, clicky, radius, style.clickColor.r, style.clickColor.g, style.clickColor.b, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1453,7 +1430,7 @@ void View::drawClick() {
|
||||||
lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||||
|
|
||||||
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize/2, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize/2, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||||
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, pink.b, 255);
|
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,7 +1484,7 @@ void View::draw() {
|
||||||
moveMapToTarget();
|
moveMapToTarget();
|
||||||
zoomMapToTarget();
|
zoomMapToTarget();
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++) {
|
for(int i = 0; i <8; i++) {
|
||||||
resolveLabelConflicts();
|
resolveLabelConflicts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,7 +1499,7 @@ void View::draw() {
|
||||||
|
|
||||||
char fps[40] = " ";
|
char fps[40] = " ";
|
||||||
snprintf(fps,40," %d lines @ %.1ffps", lineCount, 1000.0 / elapsed(lastFrameTime));
|
snprintf(fps,40," %d lines @ %.1ffps", lineCount, 1000.0 / elapsed(lastFrameTime));
|
||||||
drawStringBG(fps, 0,0, mapFont, grey, black);
|
drawStringBG(fps, 0,0, mapFont, style.subLabelColor, style.backgroundColor);
|
||||||
|
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
|
69
View.h
69
View.h
|
@ -69,12 +69,75 @@ typedef struct Style {
|
||||||
SDL_Color selectedColor;
|
SDL_Color selectedColor;
|
||||||
SDL_Color planeColor;
|
SDL_Color planeColor;
|
||||||
SDL_Color planeGoneColor;
|
SDL_Color planeGoneColor;
|
||||||
|
SDL_Color trailColor;
|
||||||
|
|
||||||
|
SDL_Color geoColor;
|
||||||
|
SDL_Color airportColor;
|
||||||
|
|
||||||
|
SDL_Color labelColor;
|
||||||
|
SDL_Color labelLineColor;
|
||||||
|
SDL_Color subLabelColor;
|
||||||
|
SDL_Color labelBackground;
|
||||||
|
|
||||||
SDL_Color mapInnerColor;
|
|
||||||
SDL_Color mapOuterColor;
|
|
||||||
SDL_Color scaleBarColor;
|
SDL_Color scaleBarColor;
|
||||||
|
|
||||||
SDL_Color buttonColor;
|
SDL_Color buttonColor;
|
||||||
|
SDL_Color buttonBackground;
|
||||||
|
SDL_Color buttonOutline;
|
||||||
|
|
||||||
|
SDL_Color clickColor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// todo separate style stuff
|
||||||
|
//
|
||||||
|
|
||||||
|
Style() {
|
||||||
|
|
||||||
|
SDL_Color pink = {249,38,114,255};
|
||||||
|
|
||||||
|
SDL_Color purple = {85, 0, 255,255};
|
||||||
|
SDL_Color purple_dark = {33, 0, 122,255};
|
||||||
|
|
||||||
|
SDL_Color blue = {102,217,239,255};
|
||||||
|
SDL_Color blue_dark = {102,217,239,255};
|
||||||
|
|
||||||
|
SDL_Color green = {0,255,234,255};
|
||||||
|
SDL_Color green_dark = {24,100,110,255};
|
||||||
|
|
||||||
|
SDL_Color yellow = {216,255,0,255};
|
||||||
|
SDL_Color yellow_dark = {90,133,50,255};
|
||||||
|
|
||||||
|
SDL_Color orange = {253,151,31,255};
|
||||||
|
SDL_Color grey_light = {196,196,196,255};
|
||||||
|
SDL_Color grey = {127,127,127,255};
|
||||||
|
SDL_Color grey_dark = {64,64,64,255};
|
||||||
|
SDL_Color black = {0,0,0,255};
|
||||||
|
SDL_Color white = {255,255,255,255};
|
||||||
|
SDL_Color red = {255,0,0,255};
|
||||||
|
|
||||||
|
|
||||||
|
backgroundColor = black;
|
||||||
|
|
||||||
|
selectedColor = pink;
|
||||||
|
planeColor = yellow;
|
||||||
|
planeGoneColor = grey;
|
||||||
|
trailColor = yellow_dark;
|
||||||
|
|
||||||
|
geoColor = purple_dark;
|
||||||
|
airportColor = purple;
|
||||||
|
|
||||||
|
labelColor = white;
|
||||||
|
labelLineColor = grey_dark;
|
||||||
|
subLabelColor = grey;
|
||||||
|
labelBackground = black;
|
||||||
|
scaleBarColor = grey_light;
|
||||||
|
buttonColor = grey_light;
|
||||||
|
buttonBackground = black;
|
||||||
|
buttonOutline = grey_light;
|
||||||
|
|
||||||
|
clickColor = grey;
|
||||||
|
}
|
||||||
} Style;
|
} Style;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue