예제 #1
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);
}   
예제 #2
0
void *
superspec_to_spec( FL_OBJECT * obj )
{
    void *v = obj->spec;
    SuperSPEC *ssp = obj->u_vdata;
    int i = 0;

    if ( ! ssp )
        return v;

    if ( obj->objclass == FL_BROWSER )
    {
        FLI_BROWSER_SPEC *sp = obj->spec;

        fl_clear_browser( obj );

        sp->h_pref = ssp->h_pref;
        sp->v_pref = ssp->v_pref;

        for ( i = 1; i <= ssp->nlines; i++ )
            fl_addto_browser( obj, ssp->content[ i ] );
    }
    else if ( obj->objclass == FL_CHOICE )
    {
        fl_clear_choice( obj );

        ( ( FLI_CHOICE_SPEC * ) obj->spec)->align = ssp->align;

        for ( i = 1; i <= ssp->nlines; i++ )
        {
            fl_addto_choice( obj, ssp->content[ i ] );
            if ( ssp->shortcut[ i ] )
                fl_set_choice_item_shortcut( obj, i, ssp->shortcut[ i ] );
            fl_set_choice_item_mode( obj, i, ssp->mode[ i ] );
        }

        if ( ssp->nlines >= ssp->int_val )
            fl_set_choice( obj, ssp->int_val );
    }
    else if ( obj->objclass == FL_MENU )
    {
        fl_clear_menu( obj );

        for ( i = 1; i <= ssp->nlines; i++ )
        {
            fl_addto_menu( obj, ssp->content[ i ] );
            if ( ssp->shortcut[ i ] )
                fl_set_menu_item_shortcut( obj, i, ssp->shortcut[ i ] );
            if ( ssp->callback[ i ] )
                fl_set_menu_item_callback( obj, i,
                               ( FL_PUP_CB ) fl_strdup( ssp->callback[ i ] ) );
            fl_set_menu_item_mode( obj, i, ssp->mode[ i ] );
            if ( ssp->mval[ i ] != i )
                fl_set_menu_item_id( obj, i, ssp->mval[ i ] );
        }
    }
    else if (    obj->objclass == FL_SLIDER
              || obj->objclass == FL_VALSLIDER
              || obj->objclass == FL_THUMBWHEEL)
    {
        FLI_SLIDER_SPEC *sp = obj->spec;

        sp->val    = ssp->val;
        sp->min    = ssp->min;
        sp->max    = ssp->max;
        sp->step   = ssp->step;
        sp->prec   = ssp->prec;
        sp->ldelta = ssp->ldelta;
        sp->rdelta = ssp->rdelta;
        sp->slsize = ssp->slsize;
    }
    else if (    ISBUTTON( obj->objclass )
              || obj->objclass == FL_PIXMAP
              || obj->objclass == FL_BITMAP )
    {
        FL_BUTTON_SPEC *sp = obj->spec;

        for ( i = 0; i < 5; i++ )
            sp->react_to[ i ] = ( ssp->mbuttons & ( 1 << i ) ) != 0;
        if ( ISBUTTON( obj->objclass ) )
            fl_set_button_mouse_buttons( obj, ssp->mbuttons );

        sp->val = ssp->int_val;

        if ( ISBUTTON( obj->objclass ) )
            fl_set_button( obj, sp->val );
    }
    else if ( obj->objclass == FL_POSITIONER )
    {
        FLI_POSITIONER_SPEC *sp = obj->spec;

        sp->xstep      = ssp->xstep;
        sp->ystep      = ssp->ystep;
        sp->xmin       = ssp->xmin;
        sp->xmax       = ssp->xmax;
        sp->xval       = ssp->xval;
        sp->ymin       = ssp->ymin;
        sp->ymax       = ssp->ymax;
        sp->yval       = ssp->yval;
    }
    else if ( obj->objclass == FL_COUNTER )
    {
        FLI_COUNTER_SPEC *sp = obj->spec;

        sp->val        = ssp->val;
        sp->sstep      = ssp->sstep;
        sp->lstep      = ssp->lstep;
        sp->min        = ssp->min;
        sp->max        = ssp->max;
        sp->prec       = ssp->prec;
    }
    else if ( obj->objclass == FL_SPINNER )
    {
        FLI_SPINNER_SPEC *sp = obj->spec;

        fl_set_spinner_value( obj, ssp->val );
        fl_set_spinner_bounds( obj, ssp->min, ssp->max );
        fl_set_spinner_step( obj, ssp->step );
        fl_set_spinner_precision( obj, ssp->prec );
        sp->orient = ssp->orient;
    }
    else if ( obj->objclass == FL_DIAL )
    {
        FLI_DIAL_SPEC *sp = obj->spec;

        sp->min       = ssp->min;
        sp->max       = ssp->max;
        sp->val       = ssp->val;
        sp->step      = ssp->step;
        sp->thetai    = ssp->thetai;
        sp->thetaf    = ssp->thetaf;
        sp->direction = ssp->direction;
    }
    else if ( obj->objclass == FL_XYPLOT )
    {
        FLI_XYPLOT_SPEC *sp = obj->spec;

        sp->xmajor         = ssp->xmajor;
        sp->xminor         = ssp->xminor;
        sp->ymajor         = ssp->ymajor;
        sp->yminor         = ssp->yminor;
        sp->xscale         = ssp->xscale;
        sp->yscale         = ssp->yscale;
        sp->xgrid          = ssp->xgrid;
        sp->ygrid          = ssp->ygrid;
        sp->xbase          = ssp->xbase;
        sp->ybase          = ssp->ybase;
        sp->grid_linestyle = ssp->grid_linestyle;
        sp->mark_active    = ssp->mark_active;
    }
    else if ( obj->objclass == FL_SCROLLBAR )
    {
        FLI_SCROLLBAR_SPEC *scbsp = obj->spec;
        FLI_SLIDER_SPEC *sp = scbsp->slider->spec;

        sp->val    = ssp->val;
        sp->min    = ssp->min;
        sp->max    = ssp->max;
        sp->prec   = ssp->prec;
        sp->step   = ssp->step;
        sp->slsize = ssp->slsize;
        sp->ldelta = ssp->ldelta;
        sp->rdelta = ssp->rdelta;
    }
    else if ( obj->objclass == FL_SLIDER )
    {
        FLI_SPINNER_SPEC *sp = obj->spec;

        ssp->val = fl_get_spinner_value( obj );
        fl_get_spinner_bounds( obj, &ssp->min, &ssp->max );
        ssp->step = fl_get_spinner_step( obj );
        ssp->prec = fl_get_spinner_precision( obj );
        ssp->orient = sp->orient;
    }
    else if ( obj->objclass == FL_INPUT )
    {
        /* Simply reset some attributes of the object to the defaults -
           this makes only sense when, during testing, text was entered
           into the input field and new we need to get rid of it */

        FLI_INPUT_SPEC *sp = obj->spec;

        sp->position = -1;
        sp->endrange = -1;
        sp->lines    = sp->ypos = 1;
        *sp->str     = '\0';
    }

    return v;
}
예제 #3
0
파일: ship.c 프로젝트: fstltna/ImpFE
/*
 * 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);
}
예제 #4
0
파일: ship.c 프로젝트: fstltna/ImpFE
/*
 * 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);
}