Пример #1
0
//-------- Begin of static function put_unit_rec --------//
//
static void put_unit_rec(int recNo, int x, int y, int refreshFlag)
{
	int   	 unitId = unit_filter(recNo);
	int   	 unitCount;
	const char* 	 str;
	UnitInfo* unitInfo;
	Nation* nationPtr = nation_array[info.viewing_nation_recno];
	int rc = unit_filter(recNo);

	switch( rc )
	{
		//------- count human units -------//

		case -1:
			str		  = "Human General";
			unitCount  = nationPtr->total_general_count;
			break;

		default:
			unitInfo   = unit_res[rc];
			str 		  = unitInfo->name;
			unitCount  = unitInfo->nation_unit_count_array[ info.viewing_nation_recno-1 ];
	}

	//---------- display info --------//

	x+=3;
	y+=3;

	font_san.put( x   , y, str );
	font_san.put( x+320, y, misc.format(unitCount,1) );
}
Пример #2
0
/**
 * Determines if @a un_it matches @a filter. If the filter is not empty,
 * the unit is required to additionally match the unit that was supplied
 * when this was constructed.
 */
bool entity_location::matches_unit_filter(const unit_map::const_iterator & un_it,
                                          const vconfig & filter) const
{
	if ( !un_it.valid() )
		return false;

	if ( filter.empty() )
		// Skip the check for un_it matching *this.
		return true;

	// Filter the unit at the filter location (should be the unit's
	// location if no special filter location was specified).
	return unit_filter(filter).matches(*un_it, filter_loc_)  &&
	       matches_unit(un_it);
}
Пример #3
0
	basic_unit_filter_impl(const vconfig & vcfg, const filter_context & fc, bool flat_tod)
		: fc_(fc)
		, vcfg(vcfg)
		, use_flat_tod_(flat_tod)
		, cond_children_()
		, cond_child_types_()
	{
		// Handle [and], [or], and [not] with in-order precedence
		vconfig::all_children_iterator cond = vcfg.ordered_begin();
		vconfig::all_children_iterator cond_end = vcfg.ordered_end();
		while(cond != cond_end)
		{
			const std::string& cond_name = cond.get_key();
			conditional::TYPE type;
			if(type.parse(cond_name)) {
				const vconfig& cond_filter = cond.get_child();

				cond_children_.push_back(unit_filter(cond_filter, &fc_, use_flat_tod_));
				cond_child_types_.push_back(type);
			}
			else {
				static const int NUM_VALID_TAGS = 5;
				static const std::string valid_tags[NUM_VALID_TAGS] = {
					"filter_vision",
					"filter_adjacent",
					"filter_location",
					"filter_side",
					"filter_wml",
				};
				static const std::string* const valid_tags_end = valid_tags + NUM_VALID_TAGS;

				if (std::find(valid_tags, valid_tags_end, cond_name) == valid_tags_end){
					std::stringstream errmsg;
					errmsg << "encountered a child [" << cond_name << "] of a standard unit filter, it is being ignored";
					DBG_CF << errmsg.str() << std::endl; //FAIL( errmsg.str() );
				}

			}
			++cond;
		}
		this->vcfg.make_safe();
	}
Пример #4
0
//--------- Begin of function Info::disp_military ---------//
//
void Info::disp_military(int refreshFlag)
{
	//------- Display the Troop report -------//

	int x=TROOP_BROWSE_X1+9;
	int y=TROOP_BROWSE_Y1+4;

	vga_back.d3_panel_up(TROOP_BROWSE_X1, TROOP_BROWSE_Y1, TROOP_BROWSE_X2, TROOP_BROWSE_Y1+33 );

	#if(defined(FRENCH))
		font_san.put( x	 , y+7 , "Commander" );
		font_san.put( x+170, y+7,  "Leadership" );
		font_san.put( x+275, y+7,  "Loyalty" );
		font_san.put( x+350, y,    "Points" );
		font_san.put( x+350, y+13, "de vie" );
		font_san.put( x+410, y+7,  "Garnison" );
		font_san.put( x+480, y+7, "Status" );
	#elif(defined(GERMAN))
		font_san.put( x	 , y+7 , "Commander" );
		font_san.put( x+210, y+7 , "Leadership" );
		font_san.put( x+275, y+7 , "Loyalty" );
		font_san.put( x+342, y+7 , "Hit Points" );
		font_san.put( x+406, y   , "Commanded" );
		font_san.put( x+415, y+13, "Soldiers" );
		font_san.put( x+485, y+7 , "Status" );
	#else
		font_san.put( x	 , y+7 , "Commander" );
		font_san.put( x+200, y+7 , "Leadership" );
		font_san.put( x+285, y+7 , "Loyalty" );
		font_san.put( x+342, y+7 , "Hit Points" );
		font_san.put( x+406, y   , "Commanded" );
		font_san.put( x+423, y+13, "Soldiers" );
		font_san.put( x+490, y+7 , "Status" );
	#endif

	if( refreshFlag == INFO_REPAINT )
	{
		browse_troop.init( TROOP_BROWSE_X1, TROOP_BROWSE_Y1+35, TROOP_BROWSE_X2, TROOP_BROWSE_Y2-20,
								 0, 22, troop_filter(), put_troop_rec, 1 );

		browse_troop.open(browse_troop_recno);
	}
	else
	{
		browse_troop.paint();
		browse_troop.open(browse_troop_recno, troop_filter());
	}

	disp_troop_total();

	//------- Display the unit report -------//

	x=UNIT_BROWSE_X1+9;
	y=UNIT_BROWSE_Y1+4;

	vga_back.d3_panel_up(UNIT_BROWSE_X1, UNIT_BROWSE_Y1, UNIT_BROWSE_X2, UNIT_BROWSE_Y1+20 );

	font_san.put( x	 , y, "Unit Type" );
	font_san.put( x+300, y, "No. of Units" );

	if( refreshFlag == INFO_REPAINT )
	{
		browse_unit.init( UNIT_BROWSE_X1, UNIT_BROWSE_Y1+22, UNIT_BROWSE_X2, UNIT_BROWSE_Y2-20,
								0, 16, unit_filter(), put_unit_rec, 1 );

		browse_unit.open(browse_unit_recno);
	}
	else
	{
		browse_unit.paint();
		browse_unit.open(browse_unit_recno, unit_filter());
	}

	disp_unit_total();
}