diff --git a/dat/gui.xml b/dat/gui.xml
index 7a13dbb..b348443 100644
--- a/dat/gui.xml
+++ b/dat/gui.xml
@@ -1,5 +1,9 @@
+
+ -75
+ 0
+
128
128
@@ -45,4 +49,54 @@
+
+
+ -65
+ 0
+
+
+ 70
+ 72
+ 72
+
+
+
+ 98
+ 8
+ 52
+ 186
+
+
+ 98
+ 8
+ 52
+ 197
+
+
+ 98
+ 8
+ 52
+ 207
+
+
+
+
+ 34
+ 273
+
+
+ 40
+ 260
+
+
+ 40
+ 273
+
+
+ 40
+ 370
+
+
+
+
diff --git a/dat/ship.xml b/dat/ship.xml
index 3a30994..e238189 100644
--- a/dat/ship.xml
+++ b/dat/ship.xml
@@ -2,7 +2,7 @@
ship
- simple
+ minimal
1
400
diff --git a/gfx/gui/minimal.png b/gfx/gui/minimal.png
new file mode 100644
index 0000000..97eca1f
Binary files /dev/null and b/gfx/gui/minimal.png differ
diff --git a/gfx/gui/minimal_pilot.png b/gfx/gui/minimal_pilot.png
new file mode 100644
index 0000000..64635e0
Binary files /dev/null and b/gfx/gui/minimal_pilot.png differ
diff --git a/gfx/gui/minimal_planet.png b/gfx/gui/minimal_planet.png
new file mode 100644
index 0000000..e2b41d3
Binary files /dev/null and b/gfx/gui/minimal_planet.png differ
diff --git a/gfx/gui/simple.xcf b/gfx/gui/simple.xcf
deleted file mode 100644
index e9e2ad3..0000000
Binary files a/gfx/gui/simple.xcf and /dev/null differ
diff --git a/src/physics.c b/src/physics.c
index 03882f1..8ec9e45 100644
--- a/src/physics.c
+++ b/src/physics.c
@@ -2,6 +2,7 @@
#include
#include
+#include "main.h"
#include "physics.h"
// ================
diff --git a/src/physics.h b/src/physics.h
index 0fa1a8b..5ba2cb9 100644
--- a/src/physics.h
+++ b/src/physics.h
@@ -1,5 +1,6 @@
#pragma once
-#include "main.h"
+
+#include
#define VX(v) ((v).x)
#define VY(v) ((v).y)
@@ -9,7 +10,8 @@
#define MOD(x,y) (sqrt((x)*(x) + (y)*(y)))
#define ANGLE(x,y)(((x)==0.) ? 0. : (((x)<0.)?atan((y)/(x))+M_PI:atan((y)/(x))))
-#define vect_dist(v,u) MOD((v)->x-(u)->x, (v)->y-(u)->y)
+#define vect_dist(v,u) MOD((v)->x-(u)->x, (v)->y-(u)->y)
+#define vect_odist(v) MOD((v)->x, (v)->y)
// Misc
double angle_diff(const double ref, double a);
diff --git a/src/player.c b/src/player.c
index 3c7e0eb..dfa3afc 100644
--- a/src/player.c
+++ b/src/player.c
@@ -49,10 +49,6 @@ static unsigned int player_target = PLAYER_ID; // Targetted pilot.
extern Pilot** pilot_stack;
extern int pilots;
-// Weapon stuff for GUI.
-extern void weapon_minimap(double res, double w, double h);
-extern void planets_minimap(double res, double w, double h);
-
// GUI crap.
// Need these offsets to render properly. -- Used in opengl.c
// -- Colors.
@@ -74,8 +70,6 @@ Color cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. };
Color cArmor = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. };
Color cEnergy = { .r = 0.2, .g = 0.8, .b = 0.2, .a = 1. };
-typedef enum { RADAR_RECT, RADAR_CIRCLE } RadarShape;
-
typedef struct {
double w,h; // Dimensions.
RadarShape shape;
@@ -123,7 +117,9 @@ typedef struct {
static Msg* msg_stack;
// External.
-extern void pilot_render(Pilot* pilot); // Extern is in Pilot.*
+extern void pilot_render(const Pilot* pilot); // Extern is in Pilot.*
+extern void weapon_minimap(const double res, const double w, const double h, const RadarShape shape); // weapon.c
+extern void planets_minimap(const double res, const double w, const double h, const RadarShape shape); // space.c
// Internal.
static void rect_parse(const xmlNodePtr parent, double* x, double* y, double* w, double* h);
static int gui_parse(const xmlNodePtr parent, const char* name);
@@ -180,39 +176,34 @@ void player_render(void) {
// -- Radar.
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glTranslated(VX(gui.pos_radar) - gl_screen.w/2. + gui.radar.w/2.,
- VY(gui.pos_radar) - gl_screen.h/2. - gui.radar.h/2., 0.);
-
- switch(gui.radar.shape) {
- case RADAR_RECT:
- // Planets.
- COLOR(cFriend);
- planets_minimap(gui.radar.res, gui.radar.w, gui.radar.h);
+ if(gui.radar.shape == RADAR_RECT)
+ glTranslated(VX(gui.pos_radar) - gl_screen.w/2. + gui.radar.w/2.,
+ VY(gui.pos_radar) - gl_screen.h/2. - gui.radar.h/2., 0.);
+ else if(gui.radar.shape == RADAR_CIRCLE)
+ glTranslated(VX(gui.pos_radar) - gl_screen.w/2.,
+ VY(gui.pos_radar) - gl_screen.h/2., 0.);
- // Weapons.
- glBegin(GL_POINTS);
- COLOR(cRadar_weap);
- weapon_minimap(gui.radar.res, gui.radar.w, gui.radar.h);
- glEnd(); // Put end to those points.
- for(j = 0, i = 1; i < pilots; i++) {
- // Skip the player.
- if(pilot_stack[i]->id == player_target) j = i;
- else gui_renderPilot(pilot_stack[i]);
- }
- // Render the targetted pilot.
- if(j != 0) gui_renderPilot(pilot_stack[j]);
- glBegin(GL_POINTS); // For ze player.
- break;
- case RADAR_CIRCLE:
- glBegin(GL_POINTS);
- for(i = 1; i < pilots; i++) {
- p = pilot_stack[i];
- COLOR(cNeutral);
- glVertex2d((p->solid->pos.x - player->solid->pos.x) / gui.radar.res,
- (p->solid->pos.y - player->solid->pos.y) / gui.radar.res);
- }
- break;
+ // Planets.
+ COLOR(cFriend);
+ planets_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape);
+
+ // Weapons.
+ glBegin(GL_POINTS);
+ COLOR(cRadar_weap);
+ weapon_minimap(gui.radar.res, gui.radar.w, gui.radar.h, gui.radar.shape);
+ glEnd();
+
+ // Render the pilots.
+ for(j = 0, i = 1; i < pilots; i++) {
+ // Skip the player.
+ if(pilot_stack[i]->id == player_target) j = i;
+ else gui_renderPilot(pilot_stack[i]);
}
+ // Render the targetted pilot.
+ if(j != 0) gui_renderPilot(pilot_stack[j]);
+
+ // Player.
+ glBegin(GL_POINTS);
// Player. -- Drawn last.
COLOR(cRadar_player);
glVertex2d( 0., 2. ); // We represent the player with a small '+'
@@ -271,6 +262,7 @@ void player_render(void) {
// Renders a pilot.
static void gui_renderPilot(const Pilot* p) {
int x, y, sx, sy;
+ double w, h;
x = (p->solid->pos.x - player->solid->pos.x) / gui.radar.res;
y = (p->solid->pos.y - player->solid->pos.y) / gui.radar.res;
@@ -279,9 +271,20 @@ static void gui_renderPilot(const Pilot* p) {
if(sx < 1.) sx = 1.;
if(sy < 1.) sy = 1.;
- if((ABS(x) > gui.radar.w/2+sx) || (ABS(y) > gui.radar.h/2.+sy))
+ if(((gui.radar.shape == RADAR_RECT) && ((ABS(x) > gui.radar.w/2.+sx)
+ || (ABS(y) > gui.radar.h/2.+sy))) || ((gui.radar.shape == RADAR_CIRCLE) &&
+ ((x*x + y*y) > (int)(gui.radar.w*gui.radar.w))))
return; // Pilot isn't in range.
+ if(gui.radar.shape == RADAR_RECT) {
+ w = gui.radar.w/2.;
+ h = gui.radar.h/2.;
+ }
+ else if(gui.radar.shape == RADAR_CIRCLE) {
+ w = gui.radar.w;
+ h = gui.radar.w;
+ }
+
glBegin(GL_QUADS);
// Colors.
if(p->id == player_target) COLOR(cRadar_targ);
@@ -289,10 +292,10 @@ static void gui_renderPilot(const Pilot* p) {
else COLOR(cNeutral);
// Image.
- glVertex2d(MAX(x-sx, -gui.radar.w/2.), MIN(y+sy, gui.radar.h/2)); // Top left.
- glVertex2d(MIN(x+sx, gui.radar.w/2.), MIN(y+sy, gui.radar.h/2)); // Top right.
- glVertex2d(MIN(x+sx, gui.radar.w/2.), MAX(y-sy, -gui.radar.h/2)); // Bottom right.
- glVertex2d(MAX(x-sx, -gui.radar.w/2.), MAX(y-sy, -gui.radar.h/2)); // Bottom left.
+ glVertex2d(MAX(x-sx, -w), MIN(y+sy, h)); // Top left.
+ glVertex2d(MIN(x+sx, w), MIN(y+sy, h)); // Top right.
+ glVertex2d(MIN(x+sx, w), MAX(y-sy, -h)); // Bottom right.
+ glVertex2d(MAX(x-sx, -w), MAX(y-sy, -h)); // Bottom left.
glEnd();
}
@@ -458,13 +461,16 @@ static int gui_parse(const xmlNodePtr parent, const char* name) {
gl_screen.w - gui.gfx_frame->w, // x.
gl_screen.h - gui.gfx_frame->h); // h.
- // For rendering the player. Displaces it a little so it's centered onscreen.
- gui_xoff = - gui.gfx_frame->w/2.;
-
// Let's parse the data now.
node = parent->children;
do {
- if(strcmp((char*)node->name, "radar")==0) {
+ // Offset.
+ if(strcmp((char*)node->name, "offset")==0) {
+ rect_parse(node, &x, &y, NULL, NULL);
+ gui_xoff = x;
+ gui_yoff = y;
+ }
+ else if(strcmp((char*)node->name, "radar")==0) {
tmp = (char*)xmlGetProp(node, (xmlChar*)"type");
// Make sure type is valid.
@@ -476,7 +482,11 @@ static int gui_parse(const xmlNodePtr parent, const char* name) {
}
free(tmp);
- rect_parse(node, &x, &y, &gui.radar.w, &gui.radar.h);
+ // Load the appropriate measurements.
+ if(gui.radar.shape == RADAR_RECT)
+ rect_parse(node, &x, &y, &gui.radar.w, &gui.radar.h);
+ else if(gui.radar.shape == RADAR_CIRCLE)
+ rect_parse(node, &x, &y, &gui.radar.w, NULL);
vect_csetmin(&gui.pos_radar,
VX(gui.pos_frame) + x,
VY(gui.pos_frame) + gui.gfx_frame->h - y);
diff --git a/src/player.h b/src/player.h
index 90589d2..ae1107b 100644
--- a/src/player.h
+++ b/src/player.h
@@ -2,8 +2,10 @@
#include
#include "pilot.h"
+// The pilot.
extern Pilot* pilot;
+typedef enum { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions.
typedef enum { KEYBIND_NULL, KEYBIND_KEYBOARD, KEYBIND_JAXIS, KEYBIND_JBUTTON } KeybindType;
// Render.
diff --git a/src/space.c b/src/space.c
index c560c3d..b1f8dda 100644
--- a/src/space.c
+++ b/src/space.c
@@ -8,6 +8,7 @@
#include "pack.h"
#include "space.h"
#include "faction.h"
+#include "player.h"
#define XML_NODE_START 1
#define XML_NODE_TEST 3
@@ -56,12 +57,15 @@ extern void player_message(const char* fmt, ...);
// Draw the planet. Used in planet.c
// Matrix mode is already displaced to center of the minimap.
-#define PIXEL(x,y) if(ABS(x)nplanets; i++) {
diff --git a/src/weapon.c b/src/weapon.c
index a6c4051..f73288e 100644
--- a/src/weapon.c
+++ b/src/weapon.c
@@ -9,6 +9,7 @@
#include "rng.h"
#include "pilot.h"
#include "collision.h"
+#include "player.h"
#include "weapon.h"
// Some stuff from pilot.
@@ -49,24 +50,27 @@ static void weapon_destroy(Weapon* w, WeaponLayer layer);
static void weapon_free(Weapon* w);
// Draw the minimap weapons (player.c).
-void weapon_minimap(double res, double w, double h) {
- int i;
+#define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x) < w/2. && ABS(y)solid->pos.x - player->solid->pos.x) / res;
y = (wbackLayer[i]->solid->pos.y - player->solid->pos.y) / res;
- if(ABS(x) < w/2. && ABS(y) < h/2.)
- glVertex2d(x,y);
+ PIXEL(x,y);
}
for(i = 0; i < nwfrontLayer; i++) {
x = (wfrontLayer[i]->solid->pos.x - player->solid->pos.x) / res;
y = (wfrontLayer[i]->solid->pos.y - player->solid->pos.y) / res;
- if(ABS(x) < w/2. && ABS(y) < h/2.)
- glVertex2d(x,y);
-
+ PIXEL(x,y);
}
}
+#undef PIXEL
// Update all weapons in the layer.
void weapons_update(const double dt, WeaponLayer layer) {