Beispiel #1
0
void NeoWindow::RedrawChartWindow() {
   if ( chart_wind == NULL ) return;
   fl_freeze_form( chart_wind->chart_window );
   int c = FL_BLACK + 1;
   fl_set_chart_maxnumb( chart_wind->population, 127 );
   if ( neo->time_step % 500 < 50 ) {
      char tmp[5]; sprintf( tmp, "%d", neo->num_creatures );
      fl_add_chart_value( chart_wind->population, neo->num_creatures, tmp, c );
   } else {
      fl_add_chart_value( chart_wind->population, neo->num_creatures, "", c );
   }
   int values[32];
   for ( int i = 1; i < 11; i ++ ) {
      for ( int j = 0; j < 32; j ++ ) values[j] = 0;
      for ( long k = 0; k < neo->max_index+1; k ++ ) {
	 if ( neo->ppCreatureList[k] != NULL ) {
	    Creature *c = neo->ppCreatureList[k];
	    Genome *g = c->genome;
	    switch ( i ) {
	    case 1: values[ *(g->maximum_mass) >> 3 ] ++; break;
	    case 2: values[ *(g->plant_eff) >> 3 ] ++; break;
	    case 3: values[ *(g->attack_defend) >> 3 ] ++; break;
	    case 4: values[ *(g->color1) >> 3 ] ++; break;
	    case 5: values[ *(g->color2) >> 3 ] ++; break;
	    case 6: values[ *(g->min_age_reproduce) >> 3 ] ++; break;
	    case 7: values[ *(g->min_energy_reproduce) >> 3 ] ++; break;
	    case 8: values[ c->energy >> 6 ] ++; break;
	    case 9: values[ c->a_ucMass >> 3 ] ++; break;
	    case 10: values[ *(g->metabolism) >> 3 ] ++; break;
	    }
	 }
      }
      FL_OBJECT *chart = NULL;
      switch ( i ) {
      case 1: chart = chart_wind->max_mass; break;
      case 2: chart = chart_wind->plant_eff; break;
      case 3: chart = chart_wind->attack; break;
      case 4: chart = chart_wind->color1; break;
      case 5: chart = chart_wind->color2; break;
      case 6: chart = chart_wind->breeding_age; break;
      case 7: chart = chart_wind->breeding_energy; break;
      case 8: chart = chart_wind->energy; break;
      case 9: chart = chart_wind->mass; break;
      case 10: chart = chart_wind->metabolism; break;
      }
      fl_clear_chart( chart );
      for ( int j = 0; j < 32; j ++ ) fl_add_chart_value( chart, values[j], "", c );
   }
Beispiel #2
0
static void
init_colors( int cc,
             int thecol )
{
    int i;
    const char *cn;

    fl_freeze_form( cs->colorform );
    for ( i = 0; i < 64; i++ )
    {
        fl_set_object_color( cs->col[ i ], cc + i, cc + i );
        fl_set_object_label( cs->col[ i ], "" );
        if ( thecol == cc + i )
            fl_set_object_label( cs->col[ i ], "@9plus" );
    }

    cn = fli_query_colorname( thecol );
    fl_set_object_label( cs->cindex, cn + ( cn[ 0 ] == 'F' ? 3 : 0 ) );
    fl_unfreeze_form( cs->colorform );
}
Beispiel #3
0
void
fli_show_tooltip( const char * s,
                  int          x,
                  int          y )
{
    int maxw = 0,
        maxh = 0,
        extra;

    if ( ! s )
        return;

    create_it( );

    extra =
           1 + ( tip->boxtype != FL_FLAT_BOX && tip->boxtype != FL_BORDER_BOX );
    fl_get_string_dimension( tip->fntstyle, tip->fntsize,
                             s, strlen( s ), &maxw, &maxh );

    maxw += 7 + extra;
    maxh += 7 + extra;

    if ( maxw > 800 )
        maxw = 800;
    if ( maxh > 800 )
        maxh = 800;

    fl_freeze_form( tip->tooltipper );
    fl_set_form_geometry( tip->tooltipper, x, y, maxw, maxh );
    fl_set_object_label( tip->text, s );
    fl_unfreeze_form( tip->tooltipper );

    if ( ! tip->tooltipper->visible )
        fl_show_form( tip->tooltipper, FL_PLACE_GEOMETRY | FL_FREE_SIZE,
                      FL_NOBORDER, "Tooltip" );

    fl_update_display( 1 );
}
Beispiel #4
0
/* fill the browser */
void FillBrowser(Int4  entries )
{
  Int4 index;
  Int4 real_index;
  char bl[100];
  
  fl_freeze_form(xew_mainf);
  fl_clear_browser(wad_brow);

  /* make a legend */
  sprintf(bl,"@_@fName     Type    Index");
  fl_add_browser_line(wad_brow, bl);

  for ( index = 0; index < entries; index++ ) {
    real_index = LinearMap[index+2];
    sprintf(bl,"%-8.8s %-7.7s %5d", pDirEnt[real_index].name,
	    TagString( pEntryTag[real_index] ),
	    real_index );
    fl_add_browser_line(wad_brow, bl);
  }
  fl_select_browser_line(wad_brow,1);
  fl_unfreeze_form(xew_mainf);
}   
Beispiel #5
0
/*
 * buildShCensus - Clears the existing contents of the ship census
 *                 window and redraws it based on current known
 *                 ships.
 */
void buildShCensus(void)
{
	ULONG shNum, crew;
	USHORT eff;
	FeShip_t tmpShip;
	char workBuf[90], nameBuf[10], shType, location[15], crewBuf[5],
		tBuff[28], shName[10];

	/* Speed up output */
	fl_freeze_form(fd_ShipCensusForm->ShipCensusForm);
	/* Clear the existing contents, if any */
	fl_clear_browser(fd_ShipCensusForm->ShBrowse);
	/* Loop for each known ship */
fprintf(stderr, "*** start of loop\n");
	for (shNum=0; shNum < next_ship; shNum++)
	{
fprintf(stderr, "*** shNum is %u!\n", shNum);
fprintf(stderr, "*** next_ship is %u!\n", next_ship);
		/* Make sure the ship has been seen */
		if (readShip(&tmpShip, shNum))
		{
fprintf(stderr, "*** readShip ok %u!\n", shNum);
			if(tmpShip.last_seen != 0)
			{
fprintf(stderr, "*** tempship ok %u!\n", shNum);
				if (tmpShip.owner != 0)
				{
fprintf(stderr, "*** owner %u!\n", tmpShip.owner);
					strncpy(nameBuf, Player[tmpShip.owner].name, 9);
					nameBuf[9] = '\0';
				}
				else
				{
fprintf(stderr, "*** unknown owner\n");
					strcpy(nameBuf, "???");
				}
				strncpy(shName, tmpShip.name, 9);
				shName[9]='\0';
				if (tmpShip.ShipType != 0)
				{
fprintf(stderr, "*** ship type %u!\n", tmpShip.ShipType);
					shType = tmpShip.ShipType;
				}
				else
				{
fprintf(stderr, "*** ship type unknown!\n");
					shType = '?';
				}
				crew = tmpShip.num_civ + tmpShip.num_mil + tmpShip.num_sci +
					tmpShip.num_ofc;
fprintf(stderr, "*** ship crew %u!\n", crew);
				if (crew < 1000)
				{
					sprintf(crewBuf, "%3u", crew);
				}
				else if (crew < 10000)
				{
					sprintf(crewBuf, "%2uX", crew / 100);
				}
				else
				{
					sprintf(crewBuf, "%2uK", crew / 1000);
				}
fprintf(stderr, "*** about to set ship location\n");
				sprintf(location, "%4u, %4u", tmpShip.sh_row, tmpShip.sh_col);
				strcpy(tBuff, ctime(&tmpShip.last_seen));
				tBuff[19]='\0';
				sprintf(workBuf, "%8u  %8s   %8s    %c   %s  %s %3u %s", shNum,
						shName, nameBuf, shType, location, crewBuf, tmpShip.efficiency,
						&tBuff[4]);
fprintf(stderr, "*** about to add browser line\n");
				fl_add_browser_line(fd_ShipCensusForm->ShBrowse, workBuf);
			}
		}
	}
fprintf(stderr, "*** about to unfreeze form\n");
	fl_unfreeze_form(fd_ShipCensusForm->ShipCensusForm);
}
Beispiel #6
0
/*
 * buildShDetDisp - Clears the existing contents of the ship detail
 *                 window and redraws it based on current known
 *                 ships.
 */
void buildShDetDisp(void)
{
	ULONG itNum;
	USHORT num_comp=0, num_eng=0, num_life=0, num_wpn=0, num_elect=0;
	FeShip_t tmpShip;
	FeItem_t tmpItem;
	int compChar, engChar, lifeChar, photChar, blasChar, sensChar,
		shldChar, telepChar, tractChar;
	char workBuf[90], nameBuf[10], itType, location[15], tBuff[28], inst;

	/* Speed up output */
	fl_freeze_form(fd_ShipDetailForm->ShipDetailForm);
	/* Clear the existing contents, if any */
	fl_clear_browser(fd_ShipDetailForm->ShDetItem);
	compChar = (int) BIG_PART_CHAR[bp_computer];
	engChar = (int) BIG_PART_CHAR[bp_engines];
	lifeChar = (int) BIG_PART_CHAR[bp_lifeSupp];
	photChar = (int) BIG_PART_CHAR[bp_photon];
	blasChar = (int) BIG_PART_CHAR[bp_blaser];
    sensChar = (int) BIG_PART_CHAR[bp_sensors];
	shldChar = (int) BIG_PART_CHAR[bp_shield];
	telepChar = (int) BIG_PART_CHAR[bp_teleport];
	tractChar = (int) BIG_PART_CHAR[bp_tractor];
	/* Loop for each known big item */
	for (itNum=0; itNum < next_item; itNum++)
	{
		/* Make sure the item has been seen and is on the ship */
		if (!readItem(&tmpItem, itNum))
		{
			continue;
		}
		if ((tmpItem.last_seen != 0) && (tmpItem.where == LastShip) &&
			!(tmpItem.flags & BF_ONPLAN))
		{
			if (tmpItem.owner != 0)
			{
				strncpy(nameBuf, Player[tmpItem.owner].name, 9);
				nameBuf[9] = '\0';
			}
			else
			{
				strcpy(nameBuf, "???");
			}
			if (tmpItem.type != 0)
			{
				itType=tmpItem.type;
			}
			else
			{
				itType='?';
			}
			/* Check if it is installed, or just cargo */
			if (tmpItem.flags & BF_INSTALL)
			{
				/* Installed */
				inst='Y';
				/* Increment our running counts */
				if (itType == tractChar)
				{
					num_comp++;
				}
				else if (itType == engChar)
				{
					num_eng++;
				}
				else if (itType == lifeChar)
				{
					num_life++;
				}
				else if ((itType == photChar) || (itType == blasChar))
				{
					num_wpn++;
				}
				else if ((itType == sensChar) || (itType == shldChar) ||
						 (itType == telepChar) || (itType == tractChar))
				{
					num_elect++;
				}
			}
			else
			{
				/* Not installed, just being carried */
				inst=' ';
			}
			sprintf(workBuf, "%8u  %c  %3u  %3u  %5u %c", itNum,
					itType, tmpItem.it_tf, tmpItem.efficiency,
					tmpItem.weight, inst);
			fl_add_browser_line(fd_ShipDetailForm->ShDetItem, workBuf);
		}
	}
	/* read the ship in */
	(void) readShip(&tmpShip, LastShip);
	/* Update using the counts we saw before */
	tmpShip.num_comp = num_comp;
	tmpShip.num_eng = num_eng;
	tmpShip.num_life = num_life;
	tmpShip.num_wpn = num_wpn;
	tmpShip.num_elect = num_elect;
	/* Write ship back */
	(void) writeShip(&tmpShip, LastShip);
	sprintf(workBuf, "%u", tmpShip.fuelLeft);
	fl_set_object_label(fd_ShipDetailForm->Fuel, workBuf);
	sprintf(workBuf, "%u", tmpShip.energy);
	fl_set_object_label(fd_ShipDetailForm->Energy, workBuf);
	sprintf(workBuf, "%u", tmpShip.armourLeft);
	fl_set_object_label(fd_ShipDetailForm->Armor, workBuf);
	sprintf(workBuf, "%u", tmpShip.shields);
	fl_set_object_label(fd_ShipDetailForm->Shields, workBuf);
	sprintf(workBuf, "%u", tmpShip.shieldsKeep);
	fl_set_object_label(fd_ShipDetailForm->ShKeep, workBuf);
	sprintf(workBuf, "%u", tmpShip.airLeft);
	fl_set_object_label(fd_ShipDetailForm->Air, workBuf);
	sprintf(workBuf, "%u", tmpShip.efficiency);
	fl_set_object_label(fd_ShipDetailForm->Effic, workBuf);
	sprintf(workBuf, "%u", tmpShip.sh_tf);
	fl_set_object_label(fd_ShipDetailForm->TF, workBuf);
	sprintf(workBuf, "%u", tmpShip.hullTF);
	fl_set_object_label(fd_ShipDetailForm->HullTF, workBuf);
	sprintf(workBuf, "%u", tmpShip.engTF);
	fl_set_object_label(fd_ShipDetailForm->EngTF, workBuf);
	sprintf(workBuf, "%u", tmpShip.engEff);
	fl_set_object_label(fd_ShipDetailForm->EngEff, workBuf);
	if (tmpShip.plagueStage != 0)
	{
		fl_set_object_label(fd_ShipDetailForm->Plague, "YES");
	}
	else
	{
		fl_set_object_label(fd_ShipDetailForm->Plague, "NO");
	}
	sprintf(workBuf, "%u", tmpShip.num_civ);
	fl_set_object_label(fd_ShipDetailForm->Civ, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_sci);
	fl_set_object_label(fd_ShipDetailForm->Sci, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_mil);
	fl_set_object_label(fd_ShipDetailForm->Mil, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_ofc);
	fl_set_object_label(fd_ShipDetailForm->Ofc, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_torp);
	fl_set_object_label(fd_ShipDetailForm->Torp, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_ore);
	fl_set_object_label(fd_ShipDetailForm->Ore, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_gold);
	fl_set_object_label(fd_ShipDetailForm->Bars, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_airt);
	fl_set_object_label(fd_ShipDetailForm->AirTnk, workBuf);
	sprintf(workBuf, "%u", tmpShip.num_ftnk);
	fl_set_object_label(fd_ShipDetailForm->FuelTnk, workBuf);
	sprintf(workBuf, "%u", tmpShip.cargo);
	fl_set_object_label(fd_ShipDetailForm->Cargo, workBuf);
	strcpy(workBuf, ctime(&tmpShip.last_seen));
	workBuf[24]='\0'; /* strip off NL */
	fl_set_object_label(fd_ShipDetailForm->Seen, workBuf);
	sprintf(workBuf, "%u", LastShip);
	fl_set_object_label(fd_ShipDetailForm->ShNum, workBuf);
	sprintf(workBuf, "%u,%u", tmpShip.sh_row, tmpShip.sh_col);
	fl_set_object_label(fd_ShipDetailForm->RowCol, workBuf);
	if (tmpShip.owner != 0)
	{
		strcpy(workBuf, Player[tmpShip.owner].name);
	}
	else
	{
		strcpy(workBuf, "???");
	}
	fl_set_object_label(fd_ShipDetailForm->Owner, workBuf);
	if (tmpShip.flags & BF_ONPLAN)
	{
		sprintf(workBuf, "Ship is on planet %u", tmpShip.planet);
		fl_set_object_label(fd_ShipDetailForm->Where, workBuf);
	}
	else
	{
		fl_set_object_label(fd_ShipDetailForm->Where, "Ship is in space");
	}

	fl_unfreeze_form(fd_ShipDetailForm->ShipDetailForm);
}