int print_items( const recipe &r, const catacurses::window &w, int ypos, int xpos, nc_color col,
                 int batch )
{
    if( !r.has_byproducts() ) {
        return 0;
    }

    const int oldy = ypos;

    mvwprintz( w, ypos++, xpos, col, _( "Byproducts:" ) );
    for( const auto &bp : r.byproducts ) {
        const auto t = item::find_type( bp.first );
        int amount = bp.second * batch;
        std::string desc;
        if( t->count_by_charges() ) {
            amount *= t->charges_default();
            desc = string_format( "> %s (%d)", t->nname( 1 ).c_str(), amount );
        } else {
            desc = string_format( "> %d %s", amount,
                                  t->nname( static_cast<unsigned int>( amount ) ).c_str() );
        }
        mvwprintz( w, ypos++, xpos, col, desc.c_str() );
    }

    return ypos - oldy;
}
std::string item_comp::to_string( int batch ) const
{
    const int c = std::abs( count ) * batch;
    const auto type_ptr = item::find_type( type );
    if( type_ptr->stackable ) {
        return string_format( "%s (%d)", type_ptr->nname( 1 ).c_str(), c );
    }
    //~ <item-count> <item-name>
    return string_format( ngettext( "%d %s", "%d %s", c ), c, type_ptr->nname( c ).c_str() );
}
Exemple #3
0
int id_map::get_new_id(

  const char *name)

  {
  int id;

  pthread_mutex_lock(&this->mutex);
  std::string nname(name);

  try 
    {
    id = this->str_map->at(nname);
    }
  catch (...)
    {
    id = this->counter++;
    std::pair<std::string, int> p1(nname, id);
    this->str_map->insert(p1);
    this->names->push_back(nname);
    }
  pthread_mutex_unlock(&this->mutex);

  return(id);
  }
bool BatchCommands::RenameChain(const wxString & oldchain, const wxString & newchain)
{
   // Build the filenames
   wxFileName oname(FileNames::ChainDir(), oldchain, wxT("txt"));
   wxFileName nname(FileNames::ChainDir(), newchain, wxT("txt"));

   // Rename it...wxRenameFile will display errors
   return wxRenameFile(oname.GetFullPath(), nname.GetFullPath());
}
Exemple #5
0
long itype::invoke( player &p, item &it, const tripoint &pos, const std::string &iuse_name ) const
{
    const use_function *use = get_use( iuse_name );
    if( use == nullptr ) {
        debugmsg( "Tried to invoke %s on a %s, which doesn't have this use_function",
                  iuse_name.c_str(), nname( 1 ).c_str() );
        return 0;
    }

    return use->call( p, it, false, pos );
}
Exemple #6
0
int id_map::get_id(
    
  const char *name)

  {
  int id = -1;

  pthread_mutex_lock(&this->mutex);

  try 
    {
    std::string nname(name);
    id = this->str_map->at(nname);
    }
  catch (...)
    {
    }
  pthread_mutex_unlock(&this->mutex);

  return(id);
  }
Exemple #7
0
void ContentReader::endElement(void*, const xmlChar *name)
{
	QString nname(QString((const char*) name).toLower());
	creader->endElement(NULL, NULL, nname);
}