From dfb57c177538bf4ac9c94b596fcb17ef8f272968 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sun, 10 Mar 2013 16:40:48 +0000 Subject: [PATCH] [Add] Map will draw hyperspace paths. :D --- src/map.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/map.c b/src/map.c index 427c74a..aff72b7 100644 --- a/src/map.c +++ b/src/map.c @@ -120,7 +120,7 @@ static void map_update(void) { // Render the map as a custom widget. static void map_render(double bx, double by, double w, double h) { - int i; + int i, j; double x, y, r; StarSystem* sys; @@ -136,14 +136,36 @@ static void map_render(double bx, double by, double w, double h) { glVertex2d(bx+w, by); glEnd(); - //COLOUR(cYellow); // Render the star systems. for(i = 0; i < systems_nstack; i++) { - if(&systems_stack[i] == cur_system) COLOUR(cRadar_targ); + sys = &systems_stack[i]; + + // Draw the system. + if(sys == cur_system) COLOUR(cRadar_targ); + else if(sys->nplanets == 0) COLOUR(cInert); else COLOUR(cYellow); - gl_drawCircleInRect(x + systems_stack[i].pos.x, - y + systems_stack[i].pos.y, + gl_drawCircleInRect(x + sys->pos.x, + y + sys->pos.y, r, bx, by, w, h); + + // Draw the hyperspace paths. + glShadeModel(GL_SMOOTH); + for(j = 0; j < sys->njumps; j++) { + // Cheaply use transparency instead of actually + // calculating from x to y the line must go. :) + glBegin(GL_LINE_STRIP); + COLOUR(cTrans); + glVertex2d(x+sys->pos.x, y+sys->pos.y); + COLOUR(cInert); + glVertex2d( + x+sys->pos.x+(systems_stack[sys->jumps[j]].pos.x-sys->pos.x)/2., + y+sys->pos.y+(systems_stack[sys->jumps[j]].pos.y-sys->pos.y)/2.); + COLOUR(cTrans); + glVertex2d(x+systems_stack[sys->jumps[j]].pos.x, + y+systems_stack[sys->jumps[j]].pos.y); + glEnd(); + } + glShadeModel(GL_FLAT); } // Selected planet. sys = &systems_stack[map_selected];