/** * @brief Adds a new background image. */ unsigned int background_addImage( glTexture *image, double x, double y, double move, double scale, glColour *col, int foreground ) { background_image_t *bkg, **arr; if (foreground) arr = &bkg_image_arr_ft; else arr = &bkg_image_arr_bk; /* See if must create. */ if (*arr == NULL) *arr = array_create( background_image_t ); /* Create image. */ bkg = &array_grow( arr ); bkg->id = ++bkg_idgen; bkg->image = gl_dupTexture(image); bkg->x = x; bkg->y = y; bkg->move = move; bkg->scale = scale; memcpy( &bkg->col, (col!=NULL) ? col : &cWhite, sizeof(glColour) ); /* Sort if necessary. */ bkg_sort( *arr ); return bkg_idgen; }
/** * @brief Gets the store icon for an outfit. * * @usage ico = o:icon() -- Gets the shop icon for an outfit * * @luaparam o Outfit to get information of. * @luareturn The texture containing the icon of the outfit. * @luafunc icon( o ) */ static int outfitL_icon( lua_State *L ) { LuaTex lt; Outfit *o = luaL_validoutfit(L,1); lt.tex = gl_dupTexture( o->gfx_store ); lua_pushtex( L, lt ); return 1; }
/** * @brief Gets the tiny faction logo which is 24x24 or smaller. * * @luatparam Faction f Faction to get logo from. * @luatreturn Tex The tiny faction logo or nil if not applicable. * @luafunc logoTiny( f ) */ static int factionL_logoTiny( lua_State *L ) { int lf; glTexture *tex; lf = luaL_validfaction(L,1); tex = faction_logoTiny( lf ); if (tex == NULL) return 0; lua_pushtex( L, gl_dupTexture( tex ) ); return 1; }
/** * @brief Gets the texture of the planet in space. * * @uasge gfx = p:gfxSpace() * @luaparam p Planet to get texture of. * @luareturn The space texture of the planet. * @luafunc gfxSpace( p ) */ static int planetL_gfxSpace( lua_State *L ) { Planet *p; LuaTex lt; p = luaL_validplanet(L,1); if (p->gfx_space == NULL) /* Not loaded. */ lt.tex = gl_newImage( p->gfx_spaceName, OPENGL_TEX_MIPMAPS ); else lt.tex = gl_dupTexture( p->gfx_space ); lua_pushtex( L, lt ); return 1; }
/** * @brief Gets the small faction logo which is 64x64 or smaller. * * @luaparam f Faction to get logo from. * @luareturn The small faction logo or nil if not applicable. * @luafunc logoSmall( f ) */ static int factionL_logoSmall( lua_State *L ) { int lf; LuaTex lt; glTexture *tex; lf = luaL_validfaction(L,1); tex = faction_logoSmall( lf ); if (tex == NULL) return 0; lt.tex = gl_dupTexture( tex ); lua_pushtex( L, lt ); return 1; }
/** * @brief Adds a mission giver NPC to the mission computer. */ static unsigned int npc_add_giver( Mission *misn ) { NPC_t npc; /* Set up the data. */ npc.type = NPC_TYPE_GIVER; npc.name = strdup(misn->npc); npc.priority = misn->data->avail.priority; npc.portrait = gl_dupTexture(misn->portrait); npc.desc = strdup(misn->desc); memcpy( &npc.u.g, misn, sizeof(Mission) ); return npc_add( &npc ); }
/** * @brief Opens a communication dialogue with a planet. * * @param planet Planet to communicate with. * @return 0 on success. */ int comm_openPlanet( Planet *planet ) { unsigned int wid; /* Must not be disabled. */ if (!planet_hasService(planet, PLANET_SERVICE_BASIC)) { player_message("%s does not respond.", planet->name); return 0; } comm_planet = planet; /* Create the generic comm window. */ wid = comm_open( gl_dupTexture( comm_planet->gfx_space ), comm_planet->faction, 0, 0, comm_planet->name ); /* Add special buttons. */ if (areEnemies(player->faction, planet->faction) && !planet->bribed) window_addButton( wid, -20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnBribe", "Bribe", comm_bribePlanet ); return 0; }
/** * @brief Gets the store icon for an outfit. * * @usage ico = o:icon() -- Gets the shop icon for an outfit * * @luaparam o Outfit to get information of. * @luareturn The texture containing the icon of the outfit. * @luafunc icon( o ) */ static int outfitL_icon( lua_State *L ) { Outfit *o = luaL_validoutfit(L,1); lua_pushtex( L, gl_dupTexture( o->gfx_store ) ); return 1; }