[Add] Players shipyard now follows same style as noraml shipyard.

This commit is contained in:
Allanis 2013-10-28 14:53:05 +00:00
parent 3877884730
commit 9699b0ed10
3 changed files with 23 additions and 23 deletions

View File

@ -719,7 +719,8 @@ static void shipyard_buy(char* str) {
static void shipyard_yours_open(char* str) {
(void)str;
char** ships;
char** sships;
glTexture** tships;
int nships;
/* Create window. */
@ -767,19 +768,22 @@ static void shipyard_yours_open(char* str) {
window_addText(terciary_wid, 40+300+40+100, -55,
130, 96, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL);
window_addText(terciary_wid, 40+200+40, -215,
window_addText(terciary_wid, 40+300+40, -215,
100, 20, 0, "txtSOutfits", &gl_smallFont, &cDConsole,
"Outfits:\n");
window_addText(terciary_wid, 40+300+40, -215-gl_smallFont.h-5,
SHIPYARD_WIDTH-40-200-40-20, 200, 0, "txtDOutfits",
SHIPYARD_WIDTH-40-300-40-20, 200, 0, "txtDOutfits",
&gl_smallFont, &cBlack, NULL);
/* Ship list. */
ships = player_ships(&nships);
window_addList(terciary_wid, 20, 40,
200, SHIPYARD_HEIGHT-80, "lstYourShips",
ships, nships, 0, shipyard_yoursUpdate);
nships = MAX(1, player_nships());
sships = malloc(sizeof(char*)*nships);
tships = malloc(sizeof(glTexture*)*nships);
player_ships(sships, tships);
window_addImageArray(terciary_wid, 20, 40,
310, SHIPYARD_HEIGHT-80, "lstYourShips", 64./96.*128., 64.,
tships, sships, nships, shipyard_yoursUpdate);
shipyard_yoursUpdate(NULL);
}

View File

@ -1946,29 +1946,25 @@ void player_destroyed(void) {
}
/**
* @fn char** player_ships(int* nships)
* @fn void player_ships(char** ssships, glTexture** tships)
*
* @brief Return a buffer with all the players ship names
* or "None" if there are no ships.
* @param nships Stores the number of ships.
* @return Freshly allocated array with allocated ship names.
*
* @param sships Fills sships with player_nships ship names.
* @param tships Fills sships with player_nships ship target textures.
*/
char** player_ships(int* nships) {
void player_ships(char** sships, glTexture** tships) {
int i;
char** shipnames;
if(player_nstack==0) {
(*nships) = 1;
shipnames = malloc(sizeof(char*));
shipnames[0] = strdup("None");
sships[0] = strdup("None");
tships[0] = NULL;
} else {
(*nships) = player_nstack;
shipnames = malloc(sizeof(char*) * player_nstack);
for(i = 0; i < player_nstack; i++)
shipnames[i] = strdup(player_stack[i]->name);
for(i = 0; i < player_nstack; i++) {
sships[i] = strdup(player_stack[i]->name);
tships[i] = player_stack[i]->ship->gfx_target;
}
}
return shipnames;
}
/**

View File

@ -57,7 +57,7 @@ int player_cargoOwned(const char* commodityname);
void player_rmMissionCargo(unsigned int cargo_id);
/* Pilot ships. */
char** player_ships(int* nships);
void player_ships(char** sships, glTexture** tships);
int player_nships(void);
Pilot* player_getShip(char* shipname);
char* player_getLoc(char* shipname);