diff --git a/gfx/ship/admonisher_comm.png b/gfx/ship/admonisher_comm.png new file mode 100644 index 0000000..8ab12c1 Binary files /dev/null and b/gfx/ship/admonisher_comm.png differ diff --git a/gfx/ship/admonisher_empire_comm.png b/gfx/ship/admonisher_empire_comm.png new file mode 100644 index 0000000..e646c72 Binary files /dev/null and b/gfx/ship/admonisher_empire_comm.png differ diff --git a/gfx/ship/admonisher_pirate_comm.png b/gfx/ship/admonisher_pirate_comm.png new file mode 100644 index 0000000..3f24139 Binary files /dev/null and b/gfx/ship/admonisher_pirate_comm.png differ diff --git a/gfx/ship/ancestor_comm.png b/gfx/ship/ancestor_comm.png new file mode 100644 index 0000000..fed7f6c Binary files /dev/null and b/gfx/ship/ancestor_comm.png differ diff --git a/gfx/ship/ancestor_draktharr_comm.png b/gfx/ship/ancestor_draktharr_comm.png new file mode 100644 index 0000000..72cd28c Binary files /dev/null and b/gfx/ship/ancestor_draktharr_comm.png differ diff --git a/gfx/ship/ancestor_pirate_comm.png b/gfx/ship/ancestor_pirate_comm.png new file mode 100644 index 0000000..1f6d344 Binary files /dev/null and b/gfx/ship/ancestor_pirate_comm.png differ diff --git a/gfx/ship/drone_comm.png b/gfx/ship/drone_comm.png new file mode 100644 index 0000000..1816ecb Binary files /dev/null and b/gfx/ship/drone_comm.png differ diff --git a/gfx/ship/gawain_comm.png b/gfx/ship/gawain_comm.png new file mode 100644 index 0000000..9c019de Binary files /dev/null and b/gfx/ship/gawain_comm.png differ diff --git a/gfx/ship/goddard_comm.png b/gfx/ship/goddard_comm.png new file mode 100644 index 0000000..7906b42 Binary files /dev/null and b/gfx/ship/goddard_comm.png differ diff --git a/gfx/ship/goddard_draktharr_comm.png b/gfx/ship/goddard_draktharr_comm.png new file mode 100644 index 0000000..11d2889 Binary files /dev/null and b/gfx/ship/goddard_draktharr_comm.png differ diff --git a/gfx/ship/hawking_comm.png b/gfx/ship/hawking_comm.png new file mode 100644 index 0000000..4b3b12f Binary files /dev/null and b/gfx/ship/hawking_comm.png differ diff --git a/gfx/ship/hawking_empire_comm.png b/gfx/ship/hawking_empire_comm.png new file mode 100644 index 0000000..baaf87d Binary files /dev/null and b/gfx/ship/hawking_empire_comm.png differ diff --git a/gfx/ship/hyena_comm.png b/gfx/ship/hyena_comm.png new file mode 100644 index 0000000..df57348 Binary files /dev/null and b/gfx/ship/hyena_comm.png differ diff --git a/gfx/ship/lancelot_comm.png b/gfx/ship/lancelot_comm.png new file mode 100644 index 0000000..fb013b7 Binary files /dev/null and b/gfx/ship/lancelot_comm.png differ diff --git a/gfx/ship/lancelot_empire_comm.png b/gfx/ship/lancelot_empire_comm.png new file mode 100644 index 0000000..afe16ad Binary files /dev/null and b/gfx/ship/lancelot_empire_comm.png differ diff --git a/gfx/ship/llama_comm.png b/gfx/ship/llama_comm.png new file mode 100644 index 0000000..b3bb8ea Binary files /dev/null and b/gfx/ship/llama_comm.png differ diff --git a/gfx/ship/mule_comm.png b/gfx/ship/mule_comm.png new file mode 100644 index 0000000..25bc149 Binary files /dev/null and b/gfx/ship/mule_comm.png differ diff --git a/gfx/ship/pacifier_comm.png b/gfx/ship/pacifier_comm.png new file mode 100644 index 0000000..44920cd Binary files /dev/null and b/gfx/ship/pacifier_comm.png differ diff --git a/gfx/ship/pacifier_empire_comm.png b/gfx/ship/pacifier_empire_comm.png new file mode 100644 index 0000000..694b5af Binary files /dev/null and b/gfx/ship/pacifier_empire_comm.png differ diff --git a/gfx/ship/schroedinger_comm.png b/gfx/ship/schroedinger_comm.png new file mode 100644 index 0000000..8cf7bdd Binary files /dev/null and b/gfx/ship/schroedinger_comm.png differ diff --git a/gfx/ship/vendetta_comm.png b/gfx/ship/vendetta_comm.png new file mode 100644 index 0000000..c96cc61 Binary files /dev/null and b/gfx/ship/vendetta_comm.png differ diff --git a/gfx/ship/vendetta_draktharr_comm.png b/gfx/ship/vendetta_draktharr_comm.png new file mode 100644 index 0000000..31a856b Binary files /dev/null and b/gfx/ship/vendetta_draktharr_comm.png differ diff --git a/gfx/ship/vendetta_pirate_comm.png b/gfx/ship/vendetta_pirate_comm.png new file mode 100644 index 0000000..83a3b5b Binary files /dev/null and b/gfx/ship/vendetta_pirate_comm.png differ diff --git a/src/comm.c b/src/comm.c index 239c6b9..1197f6d 100644 --- a/src/comm.c +++ b/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); -} - diff --git a/src/faction.c b/src/faction.c index c376181..9c6d061 100644 --- a/src/faction.c +++ b/src/faction.c @@ -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) * diff --git a/src/faction.h b/src/faction.h index ec3f874..be50deb 100644 --- a/src/faction.h +++ b/src/faction.h @@ -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. */ diff --git a/src/ship.c b/src/ship.c index b478983..11878dc 100644 --- a/src/ship.c +++ b/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; diff --git a/src/ship.h b/src/ship.h index f02ffa9..3f67b69 100644 --- a/src/ship.h +++ b/src/ship.h @@ -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;