示例#1
0
void search_handler(int c) {
  switch(c) {
    case KEY_BACKSPACE:
    case 127:
      if(pos > 0) {
        pos--;
        article_pos = 0;
        research();
      }
      break;
    case KEY_DOWN:
      if(article_pos + 1 < nresults) article_pos++;
      break;
    case KEY_UP:
      if(article_pos > 0) article_pos--;
      break;
    case KEY_ENTER:
    case 13:
      if(nresults > 0) {
        draw_article();
        handler = article_handler;
        return;
      }
      break;  
    default:
      article_pos = 0;
      needle[pos++] = c;
      research();
  }

  search_redraw();
}
示例#2
0
CharString NounStructure::status() const
{
	CharString info;
	info += "\n";

	if ( damage() > 0 )
		info += CharString().format("<color;0000ff>DAMAGE: %d%%</color>\n", (damage() * 100) / maxDamage() );
	if ( workers() != 0 )
		info += CharString().format( "Workers: %s\n", FormatNumber<char,int>( -workers() ).cstr() );
	if ( power() != 0 )
		info += CharString().format( "Power: %s\n", FormatNumber<char,int>( power() ).cstr() );
	if ( technology() != 0 )
		info += CharString().format( "Technology: %d\n", technology() );
	if ( upkeep() != 0 )
		info += CharString().format( "Upkeep: %d\n", upkeep() );

	if ( active() )
	{
		if ( food() != 0 )
			info += CharString().format( "Food: %s\n", FormatNumber<char,int>( food() ).cstr() );
		if ( habitat() != 0 )
			info += CharString().format( "Habitat: %s\n", FormatNumber<char,int>( habitat() ).cstr() );
		if ( mining() != 0 )
			info += CharString().format( "Mining: %s\n", FormatNumber<char,int>( mining() ).cstr() );
		if ( research() != 0 )
			info += CharString().format( "Research: %s\n", FormatNumber<char,int>( research() ).cstr() );
		if ( production() != 0 )
			info += CharString().format( "Production: %s\n", FormatNumber<char,int>( production() ).cstr() );
		if ( protection() != 0.0f )
			info += CharString().format( "PD: %d%%\n", (int)(protection() * 100) );
	}
	else if ( flags() & FLAG_ACTIVE )
	{
		if ( flags() & FLAG_WORKER_SHORT )
			info += "<color;0000ff>WORKER SHORTAGE!</color>\n";
		if ( flags() & FLAG_POWER_SHORT )
			info += "<color;0000ff>POWER SHORTAGE!</color>\n";
		if ( flags() & FLAG_TECH_SHORT )
			info += "<color;0000ff>TECHNOLOGY SHORTAGE!</color>\n";
	}
	else
	{
		info += "\n<color;ffffff>INACTIVE</color>\n";
	}

	if ( isBuilding() )
		info += CharString().format("\nBuilding...%d%% complete\n", buildComplete() );

	return info;
}