[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) { static void shipyard_yours_open(char* str) {
(void)str; (void)str;
char** ships; char** sships;
glTexture** tships;
int nships; int nships;
/* Create window. */ /* Create window. */
@ -767,19 +768,22 @@ static void shipyard_yours_open(char* str) {
window_addText(terciary_wid, 40+300+40+100, -55, window_addText(terciary_wid, 40+300+40+100, -55,
130, 96, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL); 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, 100, 20, 0, "txtSOutfits", &gl_smallFont, &cDConsole,
"Outfits:\n"); "Outfits:\n");
window_addText(terciary_wid, 40+300+40, -215-gl_smallFont.h-5, 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); &gl_smallFont, &cBlack, NULL);
/* Ship list. */ /* Ship list. */
ships = player_ships(&nships); nships = MAX(1, player_nships());
window_addList(terciary_wid, 20, 40, sships = malloc(sizeof(char*)*nships);
200, SHIPYARD_HEIGHT-80, "lstYourShips", tships = malloc(sizeof(glTexture*)*nships);
ships, nships, 0, shipyard_yoursUpdate); 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); 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 * @brief Return a buffer with all the players ship names
* or "None" if there are no ships. * 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; int i;
char** shipnames;
if(player_nstack==0) { if(player_nstack==0) {
(*nships) = 1; sships[0] = strdup("None");
shipnames = malloc(sizeof(char*)); tships[0] = NULL;
shipnames[0] = strdup("None");
} else { } else {
(*nships) = player_nstack; for(i = 0; i < player_nstack; i++) {
shipnames = malloc(sizeof(char*) * player_nstack); sships[i] = strdup(player_stack[i]->name);
for(i = 0; i < player_nstack; i++) tships[i] = player_stack[i]->ship->gfx_target;
shipnames[i] = strdup(player_stack[i]->name); }
} }
return shipnames;
} }
/** /**

View File

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