Пример #1
0
//The first step is copying a building.  After that, it either must be pasted or moved.
void CopyBuilding( INT32 iMapIndex )
{
	AssertMsg( !gpBuildingLayoutList, "Error:  Attempting to copy building multiple times." );

	//First step is to determine if we have a building in the area that we click.  If not, do nothing.
	if( !BuildingAtGridNo( iMapIndex ) )
		return;
	//Okay, a building does exist here to some undetermined capacity.
	//Allocate the basic structure, then calculate the layout.  The head node is
	gpBuildingLayoutList = (BUILDINGLAYOUTNODE*)MemAlloc( sizeof( BUILDINGLAYOUTNODE ) );
	Assert( gpBuildingLayoutList );
	gpBuildingLayoutList->sGridNo = (INT16)iMapIndex;
	gpBuildingLayoutList->next = NULL;

	//Set the anchor point for this building -- this is where the user clicked.
	gsBuildingLayoutAnchorGridNo = (INT16)iMapIndex;

	//Now, recursively expand out while adding unique gridnos to our list.  The recursion will
	//terminate when complete.
	BuildLayout( iMapIndex, -WORLD_COLS );
	BuildLayout( iMapIndex, -1 );
	BuildLayout( iMapIndex, 1 );
	BuildLayout( iMapIndex, WORLD_COLS );

	//We have our layout.  Now depending on the mode, we will either move the building or
	//copy it.  The layout automatically gets deleted as soon as the user releases the mouse
	//button.
}
Пример #2
0
void BuildLayout( INT32 iMapIndex, INT32 iOffset )
{
	BUILDINGLAYOUTNODE *curr;
	//First, validate the gridno
	iMapIndex += iOffset;
	if( iMapIndex < 0 && iMapIndex >= WORLD_COLS*WORLD_ROWS )
		return;
	//Now, check if there is a building here
	if( !BuildingAtGridNo( iMapIndex ) )
	{
		if( iOffset == 1 && !BuildingAtGridNo( iMapIndex - 1 ) )
			return;
		if( iOffset == WORLD_COLS && !BuildingAtGridNo( iMapIndex - WORLD_COLS ) )
			return;
		if( iOffset == -1 && !GetVerticalWall( iMapIndex ) )
			return;
		if( iOffset == -WORLD_COLS && !GetHorizontalWall( iMapIndex ) )
			return;
	}
	//Now, check to make sure this gridno hasn't already been processed.
	curr = gpBuildingLayoutList;
	while( curr )
	{
		if( (INT16)iMapIndex == curr->sGridNo )
			return;
		curr = curr->next;
	}
	//Good, it hasn't, so process it and add it to the head of the list.
	curr = (BUILDINGLAYOUTNODE*)MemAlloc( sizeof( BUILDINGLAYOUTNODE ) );
	Assert( curr );
	curr->sGridNo = (INT16)iMapIndex;
	curr->next = gpBuildingLayoutList;
	gpBuildingLayoutList = curr;

	//Use recursion to process the remainder.
	BuildLayout( iMapIndex, -WORLD_COLS );
	BuildLayout( iMapIndex, -1 );
	BuildLayout( iMapIndex, 1 );
	BuildLayout( iMapIndex, WORLD_COLS );
}
Пример #3
0
FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL)
  : nux::View(NUX_FILE_LINE_PARAM)
  , scale(DEFAULT_SCALE)
  , expanded(true)
  , layout_(nullptr)
  , top_bar_layout_(nullptr)
  , expander_view_(nullptr)
  , expander_layout_(nullptr)
  , right_hand_contents_(nullptr)
  , cairo_label_(nullptr)
{
  scale.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::UpdateScale));
  expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
  BuildLayout();
}