[Fix] Fixed some rough edges around bribing and communication in general.
This commit is contained in:
parent
37d61803d7
commit
cf1520b304
31
src/comm.c
31
src/comm.c
@ -11,6 +11,7 @@
|
|||||||
#include "pilot.h"
|
#include "pilot.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "llua.h"
|
#include "llua.h"
|
||||||
|
#include "player.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
|
|
||||||
#define BUTTON_WIDTH 80 /**< Button width. */
|
#define BUTTON_WIDTH 80 /**< Button width. */
|
||||||
@ -34,17 +35,30 @@ int comm_open(unsigned int pilot) {
|
|||||||
glTexture* logo, *gfx_comm;
|
glTexture* logo, *gfx_comm;
|
||||||
char* name, *stand;
|
char* name, *stand;
|
||||||
unsigned int wid;
|
unsigned int wid;
|
||||||
|
glColour* c;
|
||||||
|
|
||||||
/* Get the pilot. */
|
/* Get the pilot. */
|
||||||
comm_pilot = pilot_get(pilot);
|
comm_pilot = pilot_get(pilot);
|
||||||
if(comm_pilot == NULL)
|
if(comm_pilot == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* Must not be disabled. */
|
||||||
|
if(pilot_isFlag(comm_pilot, PILOT_DISABLED)) {
|
||||||
|
player_message("%s does not respond.", comm_pilot->name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get graphics and text. */
|
/* Get graphics and text. */
|
||||||
gfx_comm = comm_pilot->ship->gfx_comm;
|
gfx_comm = comm_pilot->ship->gfx_comm;
|
||||||
logo = faction_logoSmall(comm_pilot->faction);
|
logo = faction_logoSmall(comm_pilot->faction);
|
||||||
name = comm_pilot->name;
|
name = comm_pilot->name;
|
||||||
stand = faction_getStandingBroad(faction_getPlayer(comm_pilot->faction));
|
/* Get standing colour / text. */
|
||||||
|
if(pilot_isFlag(comm_pilot, PILOT_HOSTILE)) {
|
||||||
|
stand = "Hostile";
|
||||||
|
c = &cHostile;
|
||||||
|
} else {
|
||||||
|
stand = faction_getStandingBroad(faction_getPlayer(comm_pilot->faction));
|
||||||
|
c = faction_getColour(comm_pilot->faction);
|
||||||
|
}
|
||||||
w = MAX(gl_printWidth(NULL, name), gl_printWidth(NULL, stand));
|
w = MAX(gl_printWidth(NULL, name), gl_printWidth(NULL, stand));
|
||||||
y = gl_defFont.h*2 + 15;
|
y = gl_defFont.h*2 + 15;
|
||||||
if(logo != NULL) {
|
if(logo != NULL) {
|
||||||
@ -76,8 +90,7 @@ int comm_open(unsigned int pilot) {
|
|||||||
|
|
||||||
/* Standing. */
|
/* Standing. */
|
||||||
window_addText(wid, x, -30 - gfx_comm->h - y + gl_defFont.h + 5,
|
window_addText(wid, x, -30 - gfx_comm->h - y + gl_defFont.h + 5,
|
||||||
gfx_comm->w - x, 20, 0, "txtStanding", NULL,
|
gfx_comm->w - x, 20, 0, "txtStanding", NULL, c, stand);
|
||||||
faction_getColour(comm_pilot->faction), stand);
|
|
||||||
|
|
||||||
/* Buttons. */
|
/* Buttons. */
|
||||||
window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
window_addButton(wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
||||||
@ -85,8 +98,9 @@ int comm_open(unsigned int pilot) {
|
|||||||
window_addButton(wid, -20, 20 + BUTTON_HEIGHT + 20,
|
window_addButton(wid, -20, 20 + BUTTON_HEIGHT + 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnGreet", "Greet", NULL);
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnGreet", "Greet", NULL);
|
||||||
|
|
||||||
if((faction_getPlayer(comm_pilot->faction) < 0) ||
|
if(!pilot_isFlag(comm_pilot, PILOT_BRIBED) && /* Not already bribed. */
|
||||||
pilot_isFlag(comm_pilot, PILOT_HOSTILE))
|
((faction_getPlayer(comm_pilot->faction) < 0) || /* Hostile. */
|
||||||
|
pilot_isFlag(comm_pilot, PILOT_HOSTILE)))
|
||||||
window_addButton(wid, -20, 20 + 2*BUTTON_HEIGHT + 40,
|
window_addButton(wid, -20, 20 + 2*BUTTON_HEIGHT + 40,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBribe", "Bribe", comm_bribe);
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBribe", "Bribe", comm_bribe);
|
||||||
else
|
else
|
||||||
@ -117,6 +131,13 @@ static void comm_bribe(unsigned int wid, char* str) {
|
|||||||
answer = dialogue_YesNo("Bribe Pilot", "\"I'm gonna need at least %d credits \
|
answer = dialogue_YesNo("Bribe Pilot", "\"I'm gonna need at least %d credits \
|
||||||
to not leave you as a hunk of floating debris.\"\n\npay %d Credits?", price, price);
|
to not leave you as a hunk of floating debris.\"\n\npay %d Credits?", price, price);
|
||||||
|
|
||||||
|
/* Said no. */
|
||||||
|
if(answer == 0) {
|
||||||
|
dialogue_msg("Bribe Pilot", "You decide not to pay.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if has the money. */
|
||||||
if(player->credits < price) {
|
if(player->credits < price) {
|
||||||
dialogue_msg("Bribe Pilot", "You don't have enough credits for the bribary.");
|
dialogue_msg("Bribe Pilot", "You don't have enough credits for the bribary.");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user