Ejemplo n.º 1
0
void LbI_PointerHandler::OnEndPartialUpdate(void)
{
    LbSemaLock semlock(&sema_rel,1);
    Undraw(false);
    this->field_1054 = true;
    semlock.Release();
}
Ejemplo n.º 2
0
// add a corner to unclosed polyline
//
void CPolyLine::AppendCorner( int x, int y, int style, BOOL bDraw )
{
	Undraw();
	// increase size of arrays
	if( corner.GetSize() < m_ncorners+1 )
	{
		corner.SetSize( m_ncorners+DEF_ADD );
		side_style.SetSize( m_ncorners+DEF_ADD );
	}

	// add entries for new corner and side
	corner[m_ncorners].x = x;
	corner[m_ncorners].y = y;
	corner[m_ncorners].end_contour = FALSE;
	if( !corner[m_ncorners-1].end_contour )
		side_style[m_ncorners-1] = style;
	int dl_type;
	if( style == CPolyLine::STRAIGHT )
		dl_type = DL_LINE;
	else if( style == CPolyLine::ARC_CW )
		dl_type = DL_ARC_CW;
	else if( style == CPolyLine::ARC_CCW )
		dl_type = DL_ARC_CCW;
	else
		ASSERT(0);
	m_ncorners++;
	if( bDraw )
		Draw();
}
Ejemplo n.º 3
0
// move corner of polyline
//
void CPolyLine::MoveCorner( int ic, int x, int y )
{
	Undraw();
	corner[ic].x = x;
	corner[ic].y = y;
	Draw();
}
Ejemplo n.º 4
0
// delete corner and adjust arrays
//
void CPolyLine::DeleteCorner( int ic, BOOL bDraw )
{
	Undraw();
	int icont = GetContour( ic );
	int istart = GetContourStart( icont );
	int iend = GetContourEnd( icont );
	BOOL bClosed = icont < GetNumContours()-1 || GetClosed();

	if( !bClosed )
	{
		// open contour, must be last contour
		corner.RemoveAt( ic );
		if( ic != istart )
			side_style.RemoveAt( ic-1 );
		m_ncorners--;
	}
	else
	{
		// closed contour
		corner.RemoveAt( ic );
		side_style.RemoveAt( ic );
		if( ic == iend )
			corner[ic-1].end_contour = TRUE;
		m_ncorners--;
	}
	if( bClosed && GetContourSize(icont) < 3 )
	{
		// delete the entire contour
		RemoveContour( icont );
	}
	if( bDraw )
		Draw();
}
Ejemplo n.º 5
0
// Use the php clipping lib to clip this poly against poly
//
void CPolyLine::ClipPhpPolygon( int php_op, CPolyLine * poly )
{
	Undraw();
	poly->MakePhpPoly();
	MakePhpPoly();
	polygon * p = m_php_poly->boolean( poly->m_php_poly, php_op );
	poly->FreePhpPoly();
	FreePhpPoly();

	if( p )
	{
		// now screw with the PolyLine
		corner.RemoveAll();
		side_style.RemoveAll();
		do
		{
			vertex * v = p->getFirst();
			Start( m_layer, m_w, m_sel_box, v->X()*DENOM, v->Y()*DENOM, m_hatch, &m_id, m_ptr );
			do
			{
				vertex * n = v->Next();
				AppendCorner( v->X()*DENOM, v->Y()*DENOM );
				v = n;
			}
			while( v->id() != p->getFirst()->id() );
			Close();
//			p = p->NextPoly();
			delete p;
			p = NULL;
		}
		while( p );
	}
	Draw();
}
Ejemplo n.º 6
0
void CPolyLine::RemoveContour( int icont )
{
	Undraw();
	int istart = GetContourStart( icont );
	int iend = GetContourEnd( icont );

	if( icont == 0 && GetNumContours() == 1 )
	{
		// remove the only contour
		ASSERT(0);
	}
	else if( icont == GetNumContours()-1 )
	{
		// remove last contour
		corner.SetSize( GetContourStart(icont) );
		side_style.SetSize( GetContourStart(icont) );
		m_ncorners -= iend - istart + 1;
	}
	else
	{
		// remove closed contour
		for( int ic=iend; ic>=istart; ic-- )
		{
			corner.RemoveAt( ic );
			side_style.RemoveAt( ic );
			m_ncorners--;
		}
	}
	Draw();
}
Ejemplo n.º 7
0
// set pointer to display list, and draw into display list
//
void CPolyLine::SetDisplayList( CDisplayList * dl )
{
	if( m_dlist )
		Undraw();
	m_dlist = dl;
	if( m_dlist )
		Draw();
}
Ejemplo n.º 8
0
// destructor, removes display elements
//
CPolyLine::~CPolyLine()
{
	Undraw();
	FreeGpcPoly();
	delete m_gpc_poly;
	delete m_php_poly;
//	if( m_closed )
//		DeleteObject( m_hrgn );
}
Ejemplo n.º 9
0
void LbI_PointerHandler::OnEndSwap(void)
{
    LbSemaLock semlock(&sema_rel,1);
    if ( lbPointerAdvancedDraw )
    {
        Undraw(false);
        this->field_1054 = true;
    }
    semlock.Release();
}
Ejemplo n.º 10
0
void CPolyLine::MoveOrigin( int x_off, int y_off )
{
	Undraw();
	for( int ic=0; ic<GetNumCorners(); ic++ )
	{
		SetX( ic, GetX(ic) + x_off );
		SetY( ic, GetY(ic) + y_off );
	}
	Draw();
}
Ejemplo n.º 11
0
// close last polyline contour
//
void CPolyLine::Close( int style, BOOL bDraw )
{
	if( GetClosed() )
		ASSERT(0);
	Undraw();
	side_style[m_ncorners-1] = style;
	corner[m_ncorners-1].end_contour = TRUE;
	corner.SetSize( m_ncorners );
	side_style.SetSize( m_ncorners );
	if( bDraw )
		Draw();
}
Ejemplo n.º 12
0
void LbI_PointerHandler::Release(void)
{
    LbSemaLock semlock(&sema_rel,0);
    semlock.Lock(true);
    if ( this->field_1050 )
    {
        if ( lbInteruptMouse )
            Undraw(true);
        this->field_1050 = false;
        this->field_1054 = false;
        position = NULL;
        sprite = NULL;
        spr_offset = NULL;
        LbScreenSurfaceRelease(&surf1);
        LbScreenSurfaceRelease(&surf2);
    }
}
Ejemplo n.º 13
0
bool LbI_PointerHandler::OnMove(void)
{
    LbSemaLock semlock(&sema_rel,0);
    if (!semlock.Lock(true))
        return false;
    if (lbPointerAdvancedDraw && lbInteruptMouse)
    {
        Undraw(true);
        NewMousePos();
        Backup(true);
        Draw(true);
    } else
    {
        NewMousePos();
    }
    return true;
}
Ejemplo n.º 14
0
// insert a new corner between two existing corners
//
void CPolyLine::InsertCorner( int ic, int x, int y )
{
	Undraw();
	corner.InsertAt( ic, CPolyPt(x,y) );
	side_style.InsertAt( ic, STRAIGHT );
	m_ncorners++;
	if( ic )
	{
		if( corner[ic-1].end_contour )
		{
			// Extend to the new corner
			corner[ic-1].end_contour = FALSE;
			corner[ic].end_contour = TRUE;
		}
	}
	Draw();
}
Ejemplo n.º 15
0
void LbI_PointerHandler::SetHotspot(long x, long y)
{
    long prev_x,prev_y;
    LbSemaLock semlock(&sema_rel,0);
    semlock.Lock(true);
    if (this->field_1050)
    {
        // Set new coords, and backup previous ones
        prev_x = spr_offset->x;
        spr_offset->x = x;
        prev_y = spr_offset->y;
        spr_offset->y = y;
        ClipHotspot();
        // If the coords were changed, then update the pointer
        if ((spr_offset->x != prev_x) || (spr_offset->y != prev_y))
        {
            Undraw(true);
            NewMousePos();
            Backup(true);
            Draw(true);
        }
    }
}
Ejemplo n.º 16
0
// copy data from another poly, but don't draw it
//
void CPolyLine::Copy( CPolyLine * src )
{
	Undraw();
	m_dlist = src->m_dlist;
	m_id = src->m_id;
	m_ptr = src->m_ptr;
	m_layer = src->m_layer;
	m_w = src->m_w;
	m_sel_box = src->m_sel_box;
	m_ncorners = src->m_ncorners;
	m_hatch = src->m_hatch;
	m_nhatch = src->m_nhatch;
	// copy corners
	corner.SetSize( m_ncorners );
	for( int i=0; i<m_ncorners; i++ )
		corner[i] = src->corner[i];
	// copy side styles
	int nsides = src->GetNumSides();
	side_style.SetSize(nsides);
	for( int i=0; i<nsides; i++ )
		side_style[i] = src->side_style[i];
	// don't copy the Gpc_poly, just clear the old one
	FreeGpcPoly();
}
Ejemplo n.º 17
0
void CPolyLine::SetSideStyle( int is, int style )
{
	Undraw();
	CPoint p1, p2;
	if( is == (m_ncorners-1) )
	{
		p1.x = corner[m_ncorners-1].x;
		p1.y = corner[m_ncorners-1].y;
		p2.x = corner[0].x;
		p2.y = corner[0].y;
	}
	else
	{
		p1.x = corner[is].x;
		p1.y = corner[is].y;
		p2.x = corner[is+1].x;
		p2.y = corner[is+1].y;
	}
	if( p1.x == p2.x || p1.y == p2.y )
		side_style[is] = STRAIGHT;
	else
		side_style[is] = style;
	Draw();
}
Ejemplo n.º 18
0
// Use the General Polygon Clipping Library to clip contours
// If this results in new polygons, return them as CArray p
// If bRetainArcs == TRUE, try to retain arcs in polys
// Returns number of external contours, or -1 if error
//
int CPolyLine::NormalizeWithGpc( CArray<CPolyLine*> * pa, BOOL bRetainArcs )
{
	CArray<CArc> arc_array;

	if( bRetainArcs )
		MakeGpcPoly( -1, &arc_array );
	else
		MakeGpcPoly( -1, NULL );

	Undraw();

	// now, recreate poly
	// first, find outside contours and create new CPolyLines if necessary
	int n_ext_cont = 0;
	for( int ic=0; ic<m_gpc_poly->num_contours; ic++ )
	{
		if( !(m_gpc_poly->hole)[ic] )
		{
			if( n_ext_cont == 0 )
			{
				// first external contour, replace this poly
				corner.RemoveAll();
				side_style.RemoveAll();
				m_ncorners = 0;
				for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
				{
					int x = ((m_gpc_poly->contour)[ic].vertex)[i].x;
					int y = ((m_gpc_poly->contour)[ic].vertex)[i].y;
					if( i==0 )
						Start( m_layer, m_w, m_sel_box, x, y, m_hatch, &m_id, m_ptr );
					else
						AppendCorner( x, y, STRAIGHT, FALSE );
				}
				Close();
				n_ext_cont++;
			}
			else if( pa )
			{
				// next external contour, create new poly
				CPolyLine * poly = new CPolyLine;
				pa->SetSize(n_ext_cont);	// put in array
				(*pa)[n_ext_cont-1] = poly;
				for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
				{
					int x = ((m_gpc_poly->contour)[ic].vertex)[i].x;
					int y = ((m_gpc_poly->contour)[ic].vertex)[i].y;
					if( i==0 )
						poly->Start( m_layer, m_w, m_sel_box, x, y, m_hatch, &m_id, m_ptr );
					else
						poly->AppendCorner( x, y, STRAIGHT, FALSE );
				}
				poly->Close( STRAIGHT, FALSE );
				n_ext_cont++;
			}
		}
	}


	// now add cutouts to the CPolyLine(s)
	for( int ic=0; ic<m_gpc_poly->num_contours; ic++ )
	{
		if( (m_gpc_poly->hole)[ic] )
		{
			CPolyLine * ext_poly = NULL;
			if( n_ext_cont == 1 )
			{
				ext_poly = this;
			}
			else
			{
				// find the polygon that contains this hole
				for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
				{
					int x = ((m_gpc_poly->contour)[ic].vertex)[i].x;
					int y = ((m_gpc_poly->contour)[ic].vertex)[i].y;
					if( TestPointInside( x, y ) )
						ext_poly = this;
					else
					{
						for( int ext_ic=0; ext_ic<n_ext_cont-1; ext_ic++ )
						{
							if( (*pa)[ext_ic]->TestPointInside( x, y ) )
							{
								ext_poly = (*pa)[ext_ic];
								break;
							}
						}
					}
					if( ext_poly )
						break;
				}
			}
			if( !ext_poly )
				ASSERT(0);
			for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
			{
				int x = ((m_gpc_poly->contour)[ic].vertex)[i].x;
				int y = ((m_gpc_poly->contour)[ic].vertex)[i].y;
				ext_poly->AppendCorner( x, y, STRAIGHT, FALSE );
			}
			ext_poly->Close( STRAIGHT, FALSE );
		}
	}
	if( bRetainArcs )
		RestoreArcs( &arc_array, pa );
	FreeGpcPoly();

	return n_ext_cont;
}
Ejemplo n.º 19
0
//Move: Performs game round for Player.
void GamePlayer::Move(GameManager* mgr) {
	if (m_pauseMoveRounds == 0) { // check if player can move
		
		Undraw();

		Point p = GetPosition();
		p.set(p.getX()+m_direction.getX(),p.getY()+m_direction.getY()); // set new postion
		fixPoint(p); //if needed fix the position of the point
		bool move=!mgr->isValidPosition(p);

		if (!move) // in case the new position is valid,  do change of direction randomly
			move = (rand() % 10 == 0);

		while (move) { // if new poisiton is not valid get valid new position.
			p=GetPosition();
			m_direction.set(rand() % 3 - 1,rand() % 3 - 1);
			p.set(p.getX()+m_direction.getX(),p.getY()+m_direction.getY());
			fixPoint(p);

			if ( mgr->isValidPosition(p) && GetPosition().comper(p) != 0 ) 
				move=false;
		}

		SetPosition(p); //set the new position

		m_pauseMoveRounds=PAUSE_MOVE_AFTER_MOVE; //update waiting rounds

		Draw(mgr);

		switch(mgr->TakeMapObject(p)) { // check if payer is on gift
		case GlobalConsts::Food:
			m_power+=ADD_POWER;
			break;
		case GlobalConsts::Quiver:
			m_numOfArrows+=ADD_ARROWS;
			break;
		case GlobalConsts::Bomb:
			m_power-=LOSE_POWER;
			break;
		}

		HandleDeath(mgr); // check death

		if (m_pauseArrowsRounds == 0 && m_numOfArrows > 0 ) // handle shooting arrow
		{
			Point arrowPosition(GetPosition());
			arrowPosition.set(arrowPosition.getX() + m_direction.getX(),arrowPosition.getY() + m_direction.getY());
			if (mgr->isValidPosition(arrowPosition)) {
				mgr->createArrow(arrowPosition,m_direction);
				m_pauseArrowsRounds = PAUSE_ARROWS_AFTER_SHOOT;
				--m_numOfArrows;
			}
		}
		else if ( m_pauseArrowsRounds > 0 )  {
			m_pauseArrowsRounds--;
		}
	}
	else {
		--m_pauseMoveRounds;
	}
}
Ejemplo n.º 20
0
// draw polyline by adding all graphics to display list
// if side style is ARC_CW or ARC_CCW but endpoints are not angled,
// convert to STRAIGHT
//
void CPolyLine::Draw(  CDisplayList * dl )
{
	int i_start_contour = 0;

	// first, undraw if necessary
	if( bDrawn )
		Undraw();

	// use new display list if provided
	if( dl )
		m_dlist = dl;

	if( m_dlist )
	{
		// set up CArrays
		dl_side.SetSize( m_ncorners );
		if( m_sel_box )
		{
			dl_side_sel.SetSize( m_ncorners );
			dl_corner_sel.SetSize( m_ncorners );
		}
		else
		{
			dl_side_sel.RemoveAll();
			dl_corner_sel.RemoveAll();
		}

		CDL_job *pDL_job;

		if (m_layer >= LAY_TOP_COPPER)
		{
			CDL_job_copper_area *pDL_job_ca = new CDL_job_copper_area(m_dlist, this);

			m_dl_job = pDL_job = pDL_job_ca;
		}
		else
		{
			pDL_job = m_dlist->GetJob_traces(m_layer);

            m_dl_job = NULL;
		}

		// now draw elements
		for( int ic=0; ic<m_ncorners; ic++ )
		{
			m_id.ii = ic;
			int xi = corner[ic].x;
			int yi = corner[ic].y;
			int xf, yf;
			if( corner[ic].end_contour == FALSE && ic < m_ncorners-1 )
			{
				xf = corner[ic+1].x;
				yf = corner[ic+1].y;
			}
			else
			{
				xf = corner[i_start_contour].x;
				yf = corner[i_start_contour].y;
				i_start_contour = ic+1;
			}
			// draw
			if( m_sel_box )
			{
				m_id.sst = ID_SEL_CORNER;
				dl_corner_sel[ic] = m_dlist->AddSelector( m_id, m_ptr, m_layer, DL_HOLLOW_RECT,
					1, 0, 0, xi-m_sel_box, yi-m_sel_box,
					xi+m_sel_box, yi+m_sel_box, 0, 0 );
			}
			if( ic<(m_ncorners-1) || corner[ic].end_contour )
			{
				// draw side
				if( xi == xf || yi == yf )
				{
					// if endpoints not angled, make side STRAIGHT
					side_style[ic] = STRAIGHT;
				}

				int g_type = DL_LINE;
				if( side_style[ic] == STRAIGHT )
					g_type = DL_LINE;
				else if( side_style[ic] == ARC_CW )
					g_type = DL_ARC_CW;
				else if( side_style[ic] == ARC_CCW )
					g_type = DL_ARC_CCW;

				m_id.sst = ID_SIDE;

				int dx = xf - xi;
				int dy = yf - yi;

#if 0 // BAF attempt to move borders in by w [
				int w = 10 * PCBU_PER_MIL;

				if (abs(dx) == 0)
				{
					// Vertical
					if (dy<0) w = -w;
					dl_side[ic] = m_dlist->Add( pDL_job, m_id, m_ptr, m_layer, g_type, 1, m_w+5*PCBU_PER_MIL, 0, 0, xi+w, yi, xf+w, yf, 0, 0 );
				}
				else if (abs(dy) == 0)
				{
					if (dx<0) w = -w;
					dl_side[ic] = m_dlist->Add( pDL_job, m_id, m_ptr, m_layer, g_type, 1, m_w+5*PCBU_PER_MIL, 0, 0, xi, yi-w, xf, yf-w, 0, 0 );
				}
				else
				{
					double s, l;

					if (abs(dy) > abs(dx))
					{
						s = double(dx)/dy;
						l = double(w) / sqrt(1 + s*s);
						if (dy<0) l = -l;

						dl_side[ic] = m_dlist->Add( pDL_job, m_id, m_ptr, m_layer, g_type, 1, m_w+5*PCBU_PER_MIL, 0, 0, xi+l, yi-s*l, xf+l, yf-s*l, 0, 0 );
					}
					else
					{
						s = double(dy)/dx;
						l = double(w) / sqrt(1 + s*s);
						if (dx<0) l = -l;

						dl_side[ic] = m_dlist->Add( pDL_job, m_id, m_ptr, m_layer, g_type, 1, m_w+5*PCBU_PER_MIL, 0, 0, xi+s*l, yi-l, xf+s*l, yf-l, 0, 0 );
					}
				}
#endif // ]

				dl_side[ic] = m_dlist->Add( pDL_job, m_id, m_ptr, m_layer, g_type, 1, m_w+0*PCBU_PER_MIL, 0, 0, xi, yi, xf, yf, 0, 0 );

				if( m_sel_box )
				{
					m_id.sst = ID_SEL_SIDE;
					dl_side_sel[ic] = m_dlist->AddSelector( m_id, m_ptr, m_layer, g_type, 1, m_w, 0, xi, yi, xf, yf, 0, 0 );
				}
			}
		}

		if( m_hatch )
			Hatch(pDL_job);

        m_dlist->Add(pDL_job, m_layer);
	}
	bDrawn = TRUE;
}
Ejemplo n.º 21
0
// CText destructor
// removes all dlist elements
//
CText::~CText()
{
	Undraw();
}