예제 #1
0
/**
 * @brief Gets the small faction logo which is 64x64 or smaller.
 *
 *    @luatparam Faction f Faction to get logo from.
 *    @luatreturn Tex The small faction logo or nil if not applicable.
 * @luafunc logoSmall( f )
 */
static int factionL_logoSmall( lua_State *L )
{
   int lf;
   glTexture *tex;
   lf = luaL_validfaction(L,1);
   tex = faction_logoSmall( lf );
   if (tex == NULL)
      return 0;
   lua_pushtex( L, gl_dupTexture( tex ) );
   return 1;
}
예제 #2
0
파일: land.c 프로젝트: Dinth/naev
/**
 * @brief Creates the main tab.
 *
 *    @param wid Window to create main tab.
 */
static void land_createMainTab( unsigned int wid )
{
   glTexture *logo;
   int offset;
   int w,h;

   /* Get window dimensions. */
   window_dimWindow( wid, &w, &h );

   /*
    * Faction logo.
    */
   offset = 20;
   if (land_planet->faction != -1) {
      logo = faction_logoSmall(land_planet->faction);
      if (logo != NULL) {
         window_addImage( wid, 440 + (w-460-logo->w)/2, -20,
               0, 0, "imgFaction", logo, 0 );
         offset = 84;
      }
   }

   /*
    * Pretty display.
    */
   window_addImage( wid, 20, -40, 0, 0, "imgPlanet", gfx_exterior, 1 );
   window_addText( wid, 440, -20-offset,
         w-460, h-20-offset-60-LAND_BUTTON_HEIGHT*2, 0,
         "txtPlanetDesc", &gl_smallFont, &cBlack, land_planet->description);

   /*
    * buttons
    */
   /* first column */
   window_addButton( wid, -20, 20,
         LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT, "btnTakeoff",
         "Takeoff", land_buttonTakeoff );

   /*
    * Checkboxes.
    */
   window_addCheckbox( wid, -20, 20 + 2*(LAND_BUTTON_HEIGHT + 20) + 40,
         175, 20, "chkRefuel", "Automatic Refuel",
         land_toggleRefuel, conf.autorefuel );
   land_toggleRefuel( wid, "chkRefuel" );
}
예제 #3
0
파일: land.c 프로젝트: Kinniken/naev
/**
 * @brief Creates the main tab.
 *
 *    @param wid Window to create main tab.
 */
static void land_createMainTab( unsigned int wid )
{
   glTexture *logo;
   int offset;
   int w,h;

   /* Get window dimensions. */
   window_dimWindow( wid, &w, &h );

   /*
    * Faction logo.
    */
   offset = 20;
   if (land_planet->faction != -1) {
      logo = faction_logoSmall(land_planet->faction);
      if (logo != NULL) {
         window_addImage( wid, 440 + (w-460-logo->w)/2, -20,
               0, 0, "imgFaction", logo, 0 );
         offset = 84;
      }
   }

   /*
    * Pretty display.
    */
   window_addImage( wid, 20, -40, 0, 0, "imgPlanet", gfx_exterior, 1 );
   window_addText( wid, 440, -20-offset,
         w-460, h-20-offset-60-LAND_BUTTON_HEIGHT*2, 0,
         "txtPlanetDesc", &gl_smallFont, &cBlack, land_planet->description);

   /*
    * buttons
    */
   /* first column */
   window_addButtonKey( wid, -20, 20,
         LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT, "btnTakeoff",
         "Take Off", land_buttonTakeoff, SDLK_t );

   /* Add "no refueling" notice if needed. */
   if (!planet_hasService(land_planet, PLANET_SERVICE_REFUEL)) {
      window_addText( land_windows[0], -20, 20 + (LAND_BUTTON_HEIGHT + 20) + 20,
               200, gl_defFont.h, 1, "txtRefuel",
               &gl_defFont, &cBlack, "No refueling services." );
   }
}
예제 #4
0
파일: info.c 프로젝트: AvanWolf/naev
/**
 * @brief Updates the standings menu.
 */
static void standings_update( unsigned int wid, char* str )
{
   (void) str;
   int p, y;
   glTexture *t;
   int w, h, lw;
   char buf[128];
   int m;

   /* Get dimensions. */
   info_getDim( wid, &w, &h, &lw );

   /* Get faction. */
   p = toolkit_getListPos( wid, "lstStandings" );
   y = 0;

   /* Render logo. */
   t = faction_logoSmall( info_factions[p] );
   if (t != NULL) {
      window_modifyImage( wid, "imgLogo", t, 0, 0 );
      y  = -40;
      window_moveWidget( wid, "imgLogo", lw+40 + (w-(lw+60)-t->w)/2, y );
      y -= t->h;
   }
   else {
      window_modifyImage( wid, "imgLogo", NULL, 0, 0 );
      y = -20;
   }

   /* Modify text. */
   y -= 20;
   window_modifyText( wid, "txtName", faction_longname( info_factions[p] ) );
   window_moveWidget( wid, "txtName", lw+40, y );
   y -= 40;
   m = round( faction_getPlayer( info_factions[p] ) );
   snprintf( buf, sizeof(buf), "%+d%%   [ %s ]", m, faction_getStanding( m ) );
   window_modifyText( wid, "txtStanding", buf );
   window_moveWidget( wid, "txtStanding", lw+40, y );
}
예제 #5
0
파일: map.c 프로젝트: Elderman/naev
/**
 * @brief Updates the map window.
 *
 *    @param wid Window id.
 */
static void map_update( unsigned int wid )
{
   int i;
   StarSystem* sys;
   int f, h, x, y;
   double standing, nstanding;
   unsigned int services;
   int l;
   int hasPresence, hasPlanets;
   char t;
   char buf[PATH_MAX];
   int p;
   glTexture *logo;
   double w;
   double unknownPresence;

   /* Needs map to update. */
   if (!map_isOpen())
      return;

   /* Get selected system. */
   sys = system_getIndex( map_selected );

   /* Not known and no markers. */
   if (!(sys_isFlag(sys, SYSTEM_MARKED | SYSTEM_CMARKED)) &&
         !sys_isKnown(sys) && !space_sysReachable(sys)) {
      map_selectCur();
      sys = system_getIndex( map_selected );
   }

   /*
    * Right Text
    */

   x = -70; /* Side bar X offset. */
   w = ABS(x) + 60; /* Width of the side bar. */
   y = -20 - 20 - 64 - gl_defFont.h; /* Initialized to position for txtSFaction. */

   if (!sys_isKnown(sys)) { /* System isn't known, erase all */
      /*
       * Right Text
       */
      if (sys_isFlag(sys, SYSTEM_MARKED | SYSTEM_CMARKED))
         window_modifyText( wid, "txtSysname", sys->name );
      else
         window_modifyText( wid, "txtSysname", "Unknown" );;

      /* Faction */
      window_modifyImage( wid, "imgFaction", NULL, 0, 0 );
      window_moveWidget( wid, "txtSFaction", x, y);
      window_moveWidget( wid, "txtFaction", x + 50, y - gl_smallFont.h - 5 );
      window_modifyText( wid, "txtFaction", "Unknown" );
      y -= 2 * gl_smallFont.h + 5 + 15;

      /* Standing */
      window_moveWidget( wid, "txtSStanding", x, y );
      window_moveWidget( wid, "txtStanding", x + 50, y - gl_smallFont.h - 5 );
      window_modifyText( wid, "txtStanding", "Unknown" );
      y -= 2 * gl_smallFont.h + 5 + 15;

      /* Presence. */
      window_moveWidget( wid, "txtSPresence", x, y );
      window_moveWidget( wid, "txtPresence",  x + 50, y - gl_smallFont.h - 5 );
      window_modifyText( wid, "txtPresence", "Unknown" );
      y -= 2 * gl_smallFont.h + 5 + 15;

      /* Planets */
      window_moveWidget( wid, "txtSPlanets", x, y );
      window_moveWidget( wid, "txtPlanets", x + 50, y - gl_smallFont.h - 5 );
      window_modifyText( wid, "txtPlanets", "Unknown" );
      y -= 2 * gl_smallFont.h + 5 + 15;

      /* Services */
      window_moveWidget( wid, "txtSServices", x, y );
      window_moveWidget( wid, "txtServices", x + 50, y -gl_smallFont.h - 5 );
      window_modifyText( wid, "txtServices", "Unknown" );

      /*
       * Bottom Text
       */
      window_modifyText( wid, "txtSystemStatus", NULL );
      return;
   }

   /* System is known */
   window_modifyText( wid, "txtSysname", sys->name );

   standing  = 0.;
   nstanding = 0.;
   f         = -1;
   for (i=0; i<sys->nplanets; i++) {
      if (sys->planets[i]->real != ASSET_REAL)
         continue;
      if (!planet_isKnown(sys->planets[i]))
         continue;

      if ((f==-1) && (sys->planets[i]->faction>0)) {
         f = sys->planets[i]->faction;
         standing += faction_getPlayer( f );
         nstanding++;
      }
      else if (f != sys->planets[i]->faction && /** @todo more verbosity */
               (sys->planets[i]->faction>0)) {
         nsnprintf( buf, PATH_MAX, "Multiple" );
         break;
      }
   }
   if (f == -1) {
      window_modifyImage( wid, "imgFaction", NULL, 0, 0 );
      window_modifyText( wid, "txtFaction", "N/A" );
      window_modifyText( wid, "txtStanding", "N/A" );
      h = gl_smallFont.h;
   }
   else {
      if (i==sys->nplanets) /* saw them all and all the same */
         nsnprintf( buf, PATH_MAX, "%s", faction_longname(f) );

      /* Modify the image. */
      logo = faction_logoSmall(f);
      window_modifyImage( wid, "imgFaction", logo, 0, 0 );
      if (logo != NULL)
         window_moveWidget( wid, "imgFaction",
               -90 + logo->w/2, -20 - 32 - 10 - gl_defFont.h + logo->h/2);

      /* Modify the text */
      window_modifyText( wid, "txtFaction", buf );
      window_modifyText( wid, "txtStanding",
            faction_getStanding( standing / nstanding ) );

      h = gl_printHeightRaw( &gl_smallFont, w, buf );
   }

   /* Faction */
   window_moveWidget( wid, "txtSFaction", x, y);
   window_moveWidget( wid, "txtFaction", x + 50, y - gl_smallFont.h - 5 );
   y -= gl_smallFont.h + h + 5 + 15;

   /* Standing */
   window_moveWidget( wid, "txtSStanding", x, y );
   window_moveWidget( wid, "txtStanding", x + 50, y - gl_smallFont.h - 5 );
   y -= 2 * gl_smallFont.h + 5 + 15;

   /* Get presence. */
   hasPresence = 0;
   buf[0]      = '\0';
   l           = 0;
   unknownPresence = 0;
   for (i=0; i < sys->npresence; i++) {
      if (sys->presence[i].value <= 0)
         continue;
      hasPresence = 1;
      if (faction_isKnown( sys->presence[i].faction )) {
         t           = faction_getColourChar(sys->presence[i].faction);
         /* Use map grey instead of default neutral colour */
         l += nsnprintf( &buf[l], PATH_MAX-l, "%s\e0%s: \e%c%.0f",
                        (l==0)?"":"\n", faction_shortname(sys->presence[i].faction),
                        (t=='N')?'M':t, sys->presence[i].value);
      }
      else
예제 #6
0
파일: map.c 프로젝트: isfos/naev
/**
 * @brief Updates the map window.
 *
 *    @param wid Window id.
 */
static void map_update( unsigned int wid )
{
    int i;
    StarSystem* sys;
    int f, y, h, multiple_faction;
    double standing, nstanding;
    unsigned int services;
    char buf[PATH_MAX];
    int p;
    glTexture *logo;

    /* Needs map to update. */
    if (!map_isOpen())
        return;

    sys = system_getIndex( map_selected );

    /* Not known and no markers. */
    if (!(sys_isFlag(sys, SYSTEM_MARKED | SYSTEM_CMARKED)) &&
            !sys_isKnown(sys) && !space_sysReachable(sys)) {
        map_selectCur();
        sys = system_getIndex( map_selected );
    }

    /*
     * Right Text
     */
    if (!sys_isKnown(sys)) { /* System isn't known, erase all */
        /*
         * Right Text
         */
        if (sys_isFlag(sys, SYSTEM_MARKED | SYSTEM_CMARKED))
            window_modifyText( wid, "txtSysname", sys->name );
        else
            window_modifyText( wid, "txtSysname", "Unknown" );
        window_modifyImage( wid, "imgFaction", NULL );
        window_moveWidget( wid, "txtSFaction", -20, -60 );
        window_moveWidget( wid, "txtFaction", -20, -60-gl_smallFont.h-5 );
        window_modifyText( wid, "txtFaction", "Unknown" );
        /* Standing */
        window_moveWidget( wid, "txtSStanding", -20, -100 );
        window_moveWidget( wid, "txtStanding", -20, -100-gl_smallFont.h-5 );
        window_modifyText( wid, "txtStanding", "Unknown" );
        /* Security. */
        window_moveWidget( wid, "txtSSecurity", -20, -140 );
        window_moveWidget( wid, "txtSecurity",  -20, -140-gl_smallFont.h-5 );
        window_modifyText( wid, "txtSecurity", "Unknown" );
        /* Planets */
        window_moveWidget( wid, "txtSPlanets", -20, -180 );
        window_moveWidget( wid, "txtPlanets", -20, -180-gl_smallFont.h-5 );
        window_modifyText( wid, "txtPlanets", "Unknown" );
        /* Services */
        window_moveWidget( wid, "txtSServices", -20, -220 );
        window_moveWidget( wid, "txtServices", -20, -220-gl_smallFont.h-5 );
        window_modifyText( wid, "txtServices", "Unknown" );

        /*
         * Bottom Text
         */
        window_modifyText( wid, "txtSystemStatus", NULL );
        return;
    }

    /* System is known */
    window_modifyText( wid, "txtSysname", sys->name );

    standing  = 0.;
    nstanding = 0.;
    f         = -1;
    multiple_faction = 0;
    for (i=0; i<sys->nplanets; i++) {
        if ((f==-1) && (sys->planets[i]->faction>0)) {
            f = sys->planets[i]->faction;
            standing += faction_getPlayer( f );
            nstanding++;
        }
        else if (f != sys->planets[i]->faction && /** @todo more verbosity */
                 (sys->planets[i]->faction>0)) {
            snprintf( buf, PATH_MAX, "Multiple" );
            multiple_faction = 1;
            break;
        }
    }
    if (f == -1) {
        window_modifyImage( wid, "imgFaction", NULL );
        window_moveWidget( wid, "txtSFaction", -20, -60 );
        window_moveWidget( wid, "txtFaction", -20, -60-gl_smallFont.h-5 );
        window_modifyText( wid, "txtFaction", "NA" );
        window_moveWidget( wid, "txtSStanding", -20, -100 );
        window_moveWidget( wid, "txtStanding", -20, -100-gl_smallFont.h-5 );
        window_modifyText( wid, "txtStanding", "NA" );
        y = -100;

    }
    else {
        if (i==sys->nplanets) /* saw them all and all the same */
            snprintf( buf, PATH_MAX, "%s", faction_longname(f) );

        y = -60;

        /* Modify the image. */
        logo = faction_logoSmall(f);
        window_modifyImage( wid, "imgFaction", logo );
        if (logo != NULL) {
            window_moveWidget( wid, "imgFaction",
                               -(90-logo->w)/2-20-logo->w, y-(64-logo->h)/2-logo->h );
            y -= 64 + 10;
        }

        /* Modify the text */
        window_modifyText( wid, "txtFaction", buf );
        window_modifyText( wid, "txtStanding",
                           faction_getStanding( standing / nstanding ) );

        /* Lower text if needed */
        window_moveWidget( wid, "txtSFaction", -20, y );
        window_moveWidget( wid, "txtFaction", -20, y-gl_smallFont.h-5 );
        h = gl_printHeightRaw( &gl_smallFont, 80, buf );
        window_moveWidget( wid, "txtSStanding", -20, y );
        window_moveWidget( wid, "txtStanding", -20, y-gl_smallFont.h-5 );
        y -= 40 + (h - gl_smallFont.h);
        window_moveWidget( wid, "txtSStanding", -20, y );
        window_moveWidget( wid, "txtStanding", -20, y-gl_smallFont.h-5 );
    }

    /* Get security. */
    y -= 40;
    if (sys->nfleets == 0)
        snprintf(buf, PATH_MAX, "NA" );
    else
        snprintf(buf, PATH_MAX, "%.0f %%", sys->security * 100.);
    window_moveWidget( wid, "txtSSecurity", -20, y );
    window_moveWidget( wid, "txtSecurity", -20, y-gl_smallFont.h-5 );
    window_modifyText( wid, "txtSecurity", buf );

    /* Get planets */
    if (sys->nplanets == 0) {
        strncpy( buf, "None", PATH_MAX );
        window_modifyText( wid, "txtPlanets", buf );
    }
    else {
        p = 0;
        buf[0] = '\0';
        if (sys->nplanets > 0)
            p += snprintf( &buf[p], PATH_MAX-p, "%s", sys->planets[0]->name );
        for (i=1; i<sys->nplanets; i++) {
            p += snprintf( &buf[p], PATH_MAX-p, ",\n%s", sys->planets[i]->name );
        }

        window_modifyText( wid, "txtPlanets", buf );
    }
    y -= 40;
    window_moveWidget( wid, "txtSPlanets", -20, y );
    window_moveWidget( wid, "txtPlanets", -20, y-gl_smallFont.h-5 );

    /* Get the services */
    h = gl_printHeightRaw( &gl_smallFont, 80, buf );
    y -= 40 + (h - gl_smallFont.h);
    window_moveWidget( wid, "txtSServices", -20, y );
    window_moveWidget( wid, "txtServices", -20, y-gl_smallFont.h-5 );
    services = 0;
    for (i=0; i<sys->nplanets; i++)
        services |= sys->planets[i]->services;
    buf[0] = '\0';
    p = 0;
    /*snprintf(buf, sizeof(buf), "%f\n", sys->prices[0]);*/ /*Hack to control prices. */
    if (services & PLANET_SERVICE_COMMODITY)
        p += snprintf( &buf[p], PATH_MAX-p, "Commodity\n");
    if (services & PLANET_SERVICE_OUTFITS)
        p += snprintf( &buf[p], PATH_MAX-p, "Outfits\n");
    if (services & PLANET_SERVICE_SHIPYARD)
        p += snprintf( &buf[p], PATH_MAX-p, "Shipyard\n");
    if (buf[0] == '\0')
        p += snprintf( &buf[p], PATH_MAX-p, "None");
    window_modifyText( wid, "txtServices", buf );


    /*
     * System Status
     */
    buf[0] = '\0';
    p = 0;
    /* Nebula. */
    if (sys->nebu_density > 0.) {

        /* Volatility */
        if (sys->nebu_volatility > 700.)
            p += snprintf(&buf[p], PATH_MAX-p, " Volatile");
        else if (sys->nebu_volatility > 300.)
            p += snprintf(&buf[p], PATH_MAX-p, " Dangerous");
        else if (sys->nebu_volatility > 0.)
            p += snprintf(&buf[p], PATH_MAX-p, " Unstable");

        /* Density */
        if (sys->nebu_density > 700.)
            p += snprintf(&buf[p], PATH_MAX-p, " Dense");
        else if (sys->nebu_density < 300.)
            p += snprintf(&buf[p], PATH_MAX-p, " Light");
        p += snprintf(&buf[p], PATH_MAX-p, " Nebula");
    }
    /* Interference. */
    if (sys->interference > 0.) {

        if (buf[0] != '\0')
            p += snprintf(&buf[p], PATH_MAX-p, ",");

        /* Density. */
        if (sys->interference > 700.)
            p += snprintf(&buf[p], PATH_MAX-p, " Dense");
        else if (sys->interference < 300.)
            p += snprintf(&buf[p], PATH_MAX-p, " Light");

        p += snprintf(&buf[p], PATH_MAX-p, " Interference");
    }
    window_modifyText( wid, "txtSystemStatus", buf );
}