[Add] Major additions to communication panel.
BIN
gfx/ship/admonisher_comm.png
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
gfx/ship/admonisher_empire_comm.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
gfx/ship/admonisher_pirate_comm.png
Normal file
After Width: | Height: | Size: 57 KiB |
BIN
gfx/ship/ancestor_comm.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
gfx/ship/ancestor_draktharr_comm.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
gfx/ship/ancestor_pirate_comm.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
gfx/ship/drone_comm.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
gfx/ship/gawain_comm.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gfx/ship/goddard_comm.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
gfx/ship/goddard_draktharr_comm.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gfx/ship/hawking_comm.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
gfx/ship/hawking_empire_comm.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
gfx/ship/hyena_comm.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gfx/ship/lancelot_comm.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
gfx/ship/lancelot_empire_comm.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
gfx/ship/llama_comm.png
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
gfx/ship/mule_comm.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
gfx/ship/pacifier_comm.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
gfx/ship/pacifier_empire_comm.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
gfx/ship/schroedinger_comm.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gfx/ship/vendetta_comm.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
gfx/ship/vendetta_draktharr_comm.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
gfx/ship/vendetta_pirate_comm.png
Normal file
After Width: | Height: | Size: 48 KiB |
69
src/comm.c
@ -10,23 +10,20 @@
|
||||
#include "pilot.h"
|
||||
#include "comm.h"
|
||||
|
||||
#define COMM_WIDTH 320 /**< Communication window width. */
|
||||
#define COMM_HEIGHT 240 /**< Communication window height. */
|
||||
|
||||
#define BUTTON_WIDTH 90 /**< Button width. */
|
||||
#define BUTTON_WIDTH 80 /**< Button width. */
|
||||
#define BUTTON_HEIGHT 30 /*<< Button height. */
|
||||
|
||||
static Pilot* comm_pilot = NULL; /**< Pilot currently talking to. */
|
||||
|
||||
static void comm_close(unsigned int wid, char* str);
|
||||
|
||||
/**
|
||||
* @brief Open the communication dialogue with a pilot.
|
||||
* @param pilot Pilot to communicate with.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
int comm_open(unsigned int pilot) {
|
||||
char buf[128];
|
||||
int x, y, w;
|
||||
glTexture* logo, *gfx_comm;
|
||||
char* name, *stand;
|
||||
unsigned int wid;
|
||||
|
||||
/* Get the pilot. */
|
||||
@ -34,18 +31,58 @@ int comm_open(unsigned int pilot) {
|
||||
if(comm_pilot == NULL)
|
||||
return -1;
|
||||
|
||||
/* Create the window. */
|
||||
snprintf(buf, 128, "Comm - %s", comm_pilot->name);
|
||||
wid = window_create(buf, -1, -1, COMM_WIDTH, COMM_HEIGHT);
|
||||
/* Get graphics and text. */
|
||||
gfx_comm = comm_pilot->ship->gfx_comm;
|
||||
logo = faction_logoSmall(comm_pilot->faction);
|
||||
name = comm_pilot->name;
|
||||
stand = faction_getStandingBroad(faction_getPlayer(comm_pilot->faction));
|
||||
w = MAX(gl_printWidth(NULL, name), gl_printWidth(NULL, stand));
|
||||
y = gl_defFont.h*2 + 15;
|
||||
if(logo != NULL) {
|
||||
w += logo->w;
|
||||
y = MAX(y, logo->w);
|
||||
}
|
||||
x = (gfx_comm->w - w) / 2;
|
||||
|
||||
/* Create the window. */
|
||||
wid = window_create("Communication Channel", -1, -1,
|
||||
20 + gfx_comm->w + 20 + BUTTON_WIDTH + 20, 30 + gfx_comm->h + y + 5 + 20);
|
||||
|
||||
/* Create the ship image. */
|
||||
window_addRect(wid, 20, -30, gfx_comm->w, gfx_comm->h + y + 5, "rctShip", &cGrey10, 1);
|
||||
window_addImage(wid, 20, -30, "imgShip", gfx_comm, 0);
|
||||
|
||||
/* Faction logo. */
|
||||
if(logo != NULL) {
|
||||
window_addImage(wid, x, -30 - gfx_comm->h - 5,
|
||||
"imgFaction", logo, 0);
|
||||
x += logo->w + 10;
|
||||
y -= (logo->w - (gl_defFont.h*2 + 15)) / 2;
|
||||
}
|
||||
|
||||
/* Name. */
|
||||
window_addText(wid, x, -30 - gfx_comm->h - y + gl_defFont.h*2 + 10,
|
||||
gfx_comm->w - x, 20, 0, "txtName",
|
||||
NULL, &cDConsole, name);
|
||||
|
||||
/* Standing. */
|
||||
window_addText(wid, x, -30 - gfx_comm->h - y + gl_defFont.h + 5,
|
||||
gfx_comm->w - x, 20, 0, "txtStanding", NULL,
|
||||
faction_getColour(comm_pilot->faction), stand);
|
||||
|
||||
/* Buttons. */
|
||||
window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
||||
"btnClose", "Close Channel", comm_close);
|
||||
"btnClose", "Close Channel", window_close);
|
||||
window_addButton(wid, -20, 20 + BUTTON_HEIGHT + 20,
|
||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnGreet", "Greet", NULL);
|
||||
|
||||
if(faction_getPlayer(comm_pilot->faction) < 0)
|
||||
window_addButton(wid, -20, 20 + 2*BUTTON_HEIGHT + 40,
|
||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBribe", "Bribe", NULL);
|
||||
else
|
||||
window_addButton(wid, -20, 20 + 2*BUTTON_HEIGHT + 40,
|
||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnRequest", "Request...", NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void comm_close(unsigned int wid, char* str) {
|
||||
(void)str;
|
||||
window_destroy(wid);
|
||||
}
|
||||
|
||||
|
@ -263,6 +263,17 @@ char* faction_getStanding(double mod) {
|
||||
}
|
||||
#undef STANDING
|
||||
|
||||
/**
|
||||
* @brief Get the broad faction standing.
|
||||
* @param mod Players standing.
|
||||
* @return Human readable broad players standing.
|
||||
*/
|
||||
char* faction_getStandingBroad(double mod) {
|
||||
if(mod > PLAYER_ALLY) return "Friendly";
|
||||
else if(mod > 0.) return "Neutral";
|
||||
return "Hostile";
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn int areEnemies(int a, int b)
|
||||
*
|
||||
|
@ -15,6 +15,7 @@ void faction_modPlayer(int f, double mod);
|
||||
void faction_modPlayerRaw(int f, double mod);
|
||||
double faction_getPlayer(int f);
|
||||
char* faction_getStanding(double mod);
|
||||
char* faction_getStandingBroad(double mod);
|
||||
glColour* faction_getColour(int f);
|
||||
|
||||
/* Works with only factions. */
|
||||
|
23
src/ship.c
@ -15,6 +15,7 @@
|
||||
#define SHIP_GFX "../gfx/ship/"
|
||||
#define SHIP_EXT ".png"
|
||||
#define SHIP_TARGET "_target"
|
||||
#define SHIP_COMM "_comm"
|
||||
|
||||
#define VIEW_WIDTH 300
|
||||
#define VIEW_HEIGHT 300
|
||||
@ -214,6 +215,13 @@ static Ship* ship_parse(xmlNodePtr parent) {
|
||||
SHIP_GFX"%s"SHIP_EXT, xml_get(node));
|
||||
tmp->gfx_space = gl_newSprite(str, 6, 6);
|
||||
|
||||
/* Load the comm graphic. */
|
||||
snprintf(str, strlen(xml_get(node))+
|
||||
sizeof(SHIP_GFX)+sizeof(SHIP_COMM)+sizeof(SHIP_EXT),
|
||||
SHIP_GFX"%s"SHIP_COMM SHIP_EXT, xml_get(node));
|
||||
tmp->gfx_comm = gl_newImage(str);
|
||||
|
||||
/* Load the target graphic. */
|
||||
xmlr_attr(node, "target", stmp);
|
||||
if(stmp != NULL) {
|
||||
snprintf(str, strlen(stmp) +
|
||||
@ -373,19 +381,20 @@ void ships_free(void) {
|
||||
int i;
|
||||
for(i = 0; i < ship_nstack; i++) {
|
||||
/* Free stored strings. */
|
||||
if((ship_stack+i)->name) free(ship_stack[i].name);
|
||||
if((ship_stack+i)->description) free(ship_stack[i].description);
|
||||
if((ship_stack+i)->gui) free(ship_stack[i].gui);
|
||||
if((ship_stack+i)->fabricator) free(ship_stack[i].fabricator);
|
||||
if(ship_stack[i].name) free(ship_stack[i].name);
|
||||
if(ship_stack[i].description) free(ship_stack[i].description);
|
||||
if(ship_stack[i].gui) free(ship_stack[i].gui);
|
||||
if(ship_stack[i].fabricator) free(ship_stack[i].fabricator);
|
||||
|
||||
so = (ship_stack+i)->outfit;
|
||||
so = ship_stack[i].outfit;
|
||||
while(so) { /* free the ship outfit. */
|
||||
sot = so;
|
||||
so = so->next;
|
||||
free(sot);
|
||||
}
|
||||
gl_freeTexture((ship_stack+i)->gfx_space);
|
||||
gl_freeTexture((ship_stack+i)->gfx_target);
|
||||
gl_freeTexture(ship_stack[i].gfx_space);
|
||||
gl_freeTexture(ship_stack[i].gfx_comm);
|
||||
gl_freeTexture(ship_stack[i].gfx_target);
|
||||
}
|
||||
free(ship_stack);
|
||||
ship_stack = NULL;
|
||||
|
@ -51,7 +51,9 @@ typedef struct Ship_ {
|
||||
double thrust, turn, speed;
|
||||
|
||||
/* Graphics. */
|
||||
glTexture* gfx_space, *gfx_target;
|
||||
glTexture* gfx_space;
|
||||
glTexture* gfx_target;
|
||||
glTexture* gfx_comm;
|
||||
|
||||
/* GUI interface. */
|
||||
char* gui;
|
||||
|