/** * @brief Patches a new mission bar npc into the bar system. * * @note Do not reuse the pointer once it's fed. * * @param misn Mission to patch in. */ void npc_patchMission( Mission *misn ) { /* Add mission giver. */ npc_add_giver( misn ); /* Sort NPC. */ npc_sort(); }
/** * @brief Generates the mission list for the bar. * * @param wid Window to create mission list for. */ static int bar_genList( unsigned int wid ) { glTexture **portraits; char **names, *focused; int w, h, iw, ih, bw, bh; int n; /* Get dimensions. */ bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh ); /* Save focus. */ focused = strdup(window_getFocus(wid)); /* Destroy widget if already exists. */ if (widget_exists( wid, "iarMissions" )) window_destroyWidget( wid, "iarMissions" ); /* We sort just in case. */ npc_sort(); /* Set up missions. */ if (mission_portrait == NULL) mission_portrait = gl_newImage( PORTRAIT_GFX_PATH"news.png", 0 ); n = npc_getArraySize(); if (n <= 0) { n = 1; portraits = malloc(sizeof(glTexture*)); portraits[0] = mission_portrait; names = malloc(sizeof(char*)); names[0] = strdup("News"); } else { n = n+1; portraits = malloc( sizeof(glTexture*) * n ); portraits[0] = mission_portrait; npc_getTextureArray( &portraits[1], n-1 ); names = malloc( sizeof(char*) * n ); names[0] = strdup("News"); npc_getNameArray( &names[1], n-1 ); } window_addImageArray( wid, 20, -40, iw, ih, "iarMissions", 100, 75, portraits, names, n, bar_update, NULL ); /* write the outfits stuff */ bar_update( wid, NULL ); /* Restore focus. */ window_setFocus( wid, focused ); free(focused); return 0; }
/** * @brief Generates the bar missions. */ void npc_generate (void) { int i; Mission *missions; int nmissions; /* Get the missions. */ missions = missions_genList( &nmissions, land_planet->faction, land_planet->name, cur_system->name, MIS_AVAIL_BAR ); /* Add to the bar NPC stack - may be not empty. */ for (i=0; i<nmissions; i++) npc_add_giver( &missions[i] ); /* Clean up. */ if (missions != NULL) free( missions ); /* Sort NPC. */ npc_sort(); }