[Change] Slowly bringing all the other toolkit stuff inline.
This commit is contained in:
parent
49bed575a5
commit
66e1be552e
68
src/board.c
68
src/board.c
@ -12,13 +12,11 @@
|
|||||||
#define BOARDING_WIDTH 300 /** Boarding window width. */
|
#define BOARDING_WIDTH 300 /** Boarding window width. */
|
||||||
#define BOARDING_HEIGHT 200 /** boarding window height. */
|
#define BOARDING_HEIGHT 200 /** boarding window height. */
|
||||||
|
|
||||||
static unsigned int board_wid = 0; /** Boarding window identifier. */
|
static void board_exit(unsigned int wdw, char* str);
|
||||||
|
static void board_stealCreds(unsigned int wdw, char* str);
|
||||||
static void board_exit(char* str);
|
static void board_stealCargo(unsigned int wdw, char* str);
|
||||||
static void board_stealCreds(char* str);
|
static int board_fail(unsigned int wdw);
|
||||||
static void board_stealCargo(char* str);
|
static void board_update(unsigned int wdw);
|
||||||
static int board_fail(void);
|
|
||||||
static void board_update(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn void player_board(void)
|
* @fn void player_board(void)
|
||||||
@ -29,6 +27,7 @@ static void board_update(void);
|
|||||||
*/
|
*/
|
||||||
void player_board(void) {
|
void player_board(void) {
|
||||||
Pilot* p;
|
Pilot* p;
|
||||||
|
unsigned int wdw;
|
||||||
|
|
||||||
if(player->target == PLAYER_ID) {
|
if(player->target == PLAYER_ID) {
|
||||||
player_message("You need a target to board first!");
|
player_message("You need a target to board first!");
|
||||||
@ -62,49 +61,47 @@ void player_board(void) {
|
|||||||
player_message("Boarding ship %s.", p->name);
|
player_message("Boarding ship %s.", p->name);
|
||||||
|
|
||||||
/* Create the boarding window. */
|
/* Create the boarding window. */
|
||||||
board_wid = window_create("Boarding", -1, -1, BOARDING_WIDTH, BOARDING_HEIGHT);
|
wdw = window_create("Boarding", -1, -1, BOARDING_WIDTH, BOARDING_HEIGHT);
|
||||||
|
|
||||||
window_addText(board_wid, 20, -30, 120, 60,
|
window_addText(wdw, 20, -30, 120, 60,
|
||||||
0, "txtCargo", &gl_smallFont, &cDConsole,
|
0, "txtCargo", &gl_smallFont, &cDConsole,
|
||||||
"SCreds:\n"
|
"SCreds:\n"
|
||||||
"Cargo:\n");
|
"Cargo:\n");
|
||||||
|
|
||||||
window_addText(board_wid, 80, -30, 120, 60, 0, "txtData",
|
window_addText(wdw, 80, -30, 120, 60, 0, "txtData",
|
||||||
&gl_smallFont, &cBlack, NULL);
|
&gl_smallFont, &cBlack, NULL);
|
||||||
|
|
||||||
window_addButton(board_wid, 20, 20, 50, 30, "btnStealCredits",
|
window_addButton(wdw, 20, 20, 50, 30, "btnStealCredits",
|
||||||
"Credits", board_stealCreds);
|
"Credits", board_stealCreds);
|
||||||
|
|
||||||
window_addButton(board_wid, 90, 20, 50, 30, "btnStealCargo",
|
window_addButton(wdw, 90, 20, 50, 30, "btnStealCargo",
|
||||||
"Cargo", board_stealCargo);
|
"Cargo", board_stealCargo);
|
||||||
|
|
||||||
window_addButton(board_wid, -20, 20, 50, 30, "btnBoardingClose",
|
window_addButton(wdw, -20, 20, 50, 30, "btnBoardingClose",
|
||||||
"Leave", board_exit);
|
"Leave", board_exit);
|
||||||
|
|
||||||
board_update();
|
board_update(wdw);
|
||||||
|
|
||||||
/* Run hook if needed. */
|
/* Run hook if needed. */
|
||||||
pilot_runHook(p, PILOT_HOOK_BOARD);
|
pilot_runHook(p, PILOT_HOOK_BOARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn void board_exit(char* str)
|
|
||||||
*
|
|
||||||
* @brief Closes the boarding window.
|
* @brief Closes the boarding window.
|
||||||
|
* @param wdw Window triggered the function.
|
||||||
* @param str Unused.
|
* @param str Unused.
|
||||||
*/
|
*/
|
||||||
static void board_exit(char* str) {
|
static void board_exit(unsigned int wdw, char* str) {
|
||||||
(void)str;
|
(void) str;
|
||||||
window_destroy(window_get("Boarding"));
|
window_destroy(wdw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn static void board_stealCreds(char* str)
|
|
||||||
*
|
|
||||||
* @brief Attempt to steal the boarding ships credits.
|
* @brief Attempt to steal the boarding ships credits.
|
||||||
|
* @param wdw Window triggered the function.
|
||||||
* @param str Unused.
|
* @param str Unused.
|
||||||
*/
|
*/
|
||||||
static void board_stealCreds(char* str) {
|
static void board_stealCreds(unsigned int wdw, char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
Pilot* p;
|
Pilot* p;
|
||||||
|
|
||||||
@ -116,21 +113,20 @@ static void board_stealCreds(char* str) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(board_fail()) return;
|
if(board_fail(wdw)) return;
|
||||||
|
|
||||||
player->credits += p->credits;
|
player->credits += p->credits;
|
||||||
p->credits = 0;
|
p->credits = 0;
|
||||||
board_update(); /* Update the lack of credits. */
|
board_update(wdw); /* Update the lack of credits. */
|
||||||
player_message("You manage to steal the ship's Scred.");
|
player_message("You manage to steal the ship's Scred.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn static void board_stealCargo(char* str)
|
* @brief Attempt to steal the boarded ships cargo.
|
||||||
*
|
* @param wdw Window triggering the function.
|
||||||
* @breif Attempt to steal the boarded ships cargo.
|
|
||||||
* @param str Unused.
|
* @param str Unused.
|
||||||
*/
|
*/
|
||||||
static void board_stealCargo(char* str) {
|
static void board_stealCargo(unsigned int wdw, char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
int q;
|
int q;
|
||||||
Pilot* p;
|
Pilot* p;
|
||||||
@ -147,7 +143,7 @@ static void board_stealCargo(char* str) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(board_fail()) return;
|
if(board_fail(wdw)) return;
|
||||||
|
|
||||||
/** Steal as much as possible until full - @todo: Allow the player to choose. */
|
/** Steal as much as possible until full - @todo: Allow the player to choose. */
|
||||||
q = 1;
|
q = 1;
|
||||||
@ -158,17 +154,15 @@ static void board_stealCargo(char* str) {
|
|||||||
pilot_rmCargo(p, p->commodities[0].commodity, q);
|
pilot_rmCargo(p, p->commodities[0].commodity, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
board_update();
|
board_update(wdw);
|
||||||
player_message("You manage to steal the ship's cargo.");
|
player_message("You manage to steal the ship's cargo.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn static int board_fail(void)
|
|
||||||
*
|
|
||||||
* @brief Check to see if the hijack attempt failed.
|
* @brief Check to see if the hijack attempt failed.
|
||||||
* @return 1 on failure to board. Otherwise 0.
|
* @return 1 on failure to board. Otherwise 0.
|
||||||
*/
|
*/
|
||||||
static int board_fail(void) {
|
static int board_fail(unsigned int wdw) {
|
||||||
Pilot* p;
|
Pilot* p;
|
||||||
|
|
||||||
p = pilot_get(player->target);
|
p = pilot_get(player->target);
|
||||||
@ -186,16 +180,14 @@ static int board_fail(void) {
|
|||||||
/* You just got locked out!! */
|
/* You just got locked out!! */
|
||||||
player_message("The ship's security system locks you out!");
|
player_message("The ship's security system locks you out!");
|
||||||
|
|
||||||
board_exit(NULL);
|
board_exit(wdw, NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn static void board_update(void)
|
|
||||||
*
|
|
||||||
* @brief Updates the boarding window.
|
* @brief Updates the boarding window.
|
||||||
*/
|
*/
|
||||||
static void board_update(void) {
|
static void board_update(unsigned int wdw) {
|
||||||
int i;
|
int i;
|
||||||
char str[128], buf[32];
|
char str[128], buf[32];
|
||||||
char cred[10];
|
char cred[10];
|
||||||
@ -218,6 +210,6 @@ static void board_update(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window_modifyText(board_wid, "txtData", str);
|
window_modifyText(wdw, "txtData", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user