[Add] Early map is actually drawing planets quite nicely.

This commit is contained in:
Allanis 2013-03-09 22:21:37 +00:00
parent 3eadb955ff
commit fe170aede4

View File

@ -5,7 +5,7 @@
#include "opengl.h" #include "opengl.h"
#include "map.h" #include "map.h"
#define MAP_WIDTH 500 #define MAP_WIDTH 550
#define MAP_HEIGHT 400 #define MAP_HEIGHT 400
#define BUTTON_WIDTH 60 #define BUTTON_WIDTH 60
@ -14,31 +14,32 @@
static int map_wid = 0; static int map_wid = 0;
static double map_xpos = 0.; static double map_xpos = 0.;
static double map_ypos = 0.; static double map_ypos = 0.;
static int map_selected = 0;
// Extern. // Extern.
extern StarSystem* systems_stack; extern StarSystem* systems_stack;
extern int systems_nstack; extern int systems_nstack;
void map_render(double bx, double by, double w, double h); static void map_render(double bx, double by, double w, double h);
void map_close(char* str); static void map_close(char* str);
// Open the map window. // Open the map window.
void map_open(void) { void map_open(void) {
if(map_wid) map_close(NULL); if(map_wid) map_close(NULL);
// Set the position to focus on current system. // Set the position to focus on current system.
map_xpos = cur_system->pos.x + (MAP_WIDTH-120)/2; map_xpos = cur_system->pos.x;
map_ypos = cur_system->pos.y + (MAP_HEIGHT-60)/2; map_ypos = cur_system->pos.y;
map_wid = window_create("Star Map", -1, -1, MAP_WIDTH, MAP_HEIGHT); map_wid = window_create("Star Map", -1, -1, MAP_WIDTH, MAP_HEIGHT);
window_addCust(map_wid, 20, 20, MAP_WIDTH - 120, MAP_HEIGHT - 60, window_addCust(map_wid, 20, 20, MAP_WIDTH - 150, MAP_HEIGHT - 60,
"cstMap", 1, map_render); "cstMap", 1, map_render);
window_addButton(map_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, window_addButton(map_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
"btnClose", "Close", map_close); "btnClose", "Close", map_close);
} }
void map_close(char* str) { static void map_close(char* str) {
(void)str; (void)str;
if(map_wid) { if(map_wid) {
window_destroy(map_wid); window_destroy(map_wid);
@ -47,7 +48,7 @@ void map_close(char* str) {
} }
// Render the map as a custom widget. // Render the map as a custom widget.
void map_render(double bx, double by, double w, double h) { static void map_render(double bx, double by, double w, double h) {
int i; int i;
// Background // Background
COLOUR(cBlack); COLOUR(cBlack);
@ -59,8 +60,12 @@ void map_render(double bx, double by, double w, double h) {
glEnd(); glEnd();
COLOUR(cYellow); COLOUR(cYellow);
for(i = 0; i < systems_nstack; i++) for(i = 0; i < systems_nstack; i++) {
gl_drawCircleInRect(systems_stack[i].pos.x, systems_stack[i].pos.y, if(i == map_selected) COLOUR(cRadar_targ);
else COLOUR(cYellow);
gl_drawCircleInRect(bx + systems_stack[i].pos.x - map_xpos + w/2,
by + systems_stack[i].pos.y - map_ypos + h/2,
5, bx, by, w, h); 5, bx, by, w, h);
} }
}