Exemple #1
0
void DrawLine(HDC hDC, DWORD dwDegree, DWORD dwRadius) {
	DWORD dwX1, dwY1, dwX2, dwY2;

	dwX1 = CalcX(dwDegree, dwRadius);
	dwY1 = CalcY(dwDegree, dwRadius);
	dwDegree += 180;
	dwX2 = CalcX(dwDegree, 10);
	dwY2 = CalcY(dwDegree, 10);
	MoveToEx(hDC, dwX1, dwY1, NULL);
	LineTo(hDC, dwX2, dwY2);
	return;
}
void TileSelector::OnLButtonDown(int mX, int mY) {
    int x = CROOM->GetXTile((float)mX);
    int y = CROOM->GetYTile((float)mY);

    switch (App::Application.GameMode) {
    case GAME_MODE_PLAN:
    {
        Soldier* o = App::Application.SelectedSoldier;
        if (CROOM->TileIsFree(o, y, x)) {
            if (!o->IsPlaced) {
                std::string s = std::string("./gfx/Soldier/SoldierStill") + o->bmSuffix + ".png";
                const char * img = s.c_str();
                Object::Instantiate(o, img, (float)CalcX(mX)+Width/2, (float)CalcY(mY)+Height/2, NULL, MIDDLECENTER);
                CROOM->OccupyTile(o, y, x);
            }
            else {
                CROOM->LeaveTile(o, CROOM->GetYTile(o->Y), CROOM->GetXTile(o->X));

                o->Y = (float)CalcY(mY)+Height/2;
                o->X = (float)CalcX(mX)+Width/2;
                o->DestX = o->X;
                CROOM->OccupyTile(o, y, x);
            }
            o->IsPlaced = true;

            // Select next soldier
            App::Application.AutoSelectSoldier();
        }
        else {
#ifdef PRINTDEBUG
            printf("Tile is already occupied\n");
#endif
        }
    }
    break;
    case GAME_MODE_PLAY:
        // Do nothing yet
        return;
        break;
    }
}
FF_ANIMATION_DYNAMIC_OBJECT FFLineMoveStrategy::Calculate(orxVECTOR* outPos,const orxCLOCK_INFO* pClockInfo )
{
	FFVector3 a = outPos;
	FF_ANIMATION_DYNAMIC_OBJECT anim;

	switch(_direction)
	{
	case MD_X:
		anim = CalcX(&a,pClockInfo);
		break;
	case MD_Y:
		anim =  CalcY(&a,pClockInfo);
		break;
	}
	outPos->fX = a._x;
	outPos->fY = a._y;
	outPos->fZ = a._z;

	return anim;
}
static void _DrawArc(int x0, int y0, int rx, int ry, int Angle0, int Angle1, int xMul, int yMul) {
  float afx[4];
  float afy[4];
	float ri = rx-(GUI_Context.PenSize+1.5)/2;
	float ro = rx+(GUI_Context.PenSize+1.5)/2;
  float fAngle0 = Angle0*3.1415926/180;
  float fAngle1 = Angle1*3.1415926/180;
  float sin0 = sin(fAngle0); 
  float sin1 = sin(fAngle1); 
  float cos0 = cos(fAngle0); 
  float cos1 = cos(fAngle1); 
  U32   ri2 = ri*ri;
  U32   ro2 = ro*ro;
	int y, yMax, yMin;
	afy[0] = ri*sin0;
	afy[1] = ro*sin0;
	afy[2] = ri*sin1;
	afy[3] = ro*sin1;
	afx[0] = ri*cos0;
	afx[1] = ro*cos0;
	afx[2] = ri*cos1;
	afx[3] = ro*cos1;
	yMin = ceil(afy[0]);
  yMax = floor(afy[3]);
  /* Use Clipping rect to reduce calculation (if possible) */
  if (GUI_Context.pClipRect_HL) {
    if (yMul ==1) {
      if (yMax > (GUI_Context.pClipRect_HL->y1 -y0))
        yMax = (GUI_Context.pClipRect_HL->y1 -y0);
      if (yMin < (GUI_Context.pClipRect_HL->y0 -y0))
        yMin = (GUI_Context.pClipRect_HL->y0 -y0);
    }
    if (yMul == -1) {
      if (yMin > (GUI_Context.pClipRect_HL->y1 -y0))
        yMin = (GUI_Context.pClipRect_HL->y1 -y0);
      if (yMax < (GUI_Context.pClipRect_HL->y0 -y0))
        yMax = (GUI_Context.pClipRect_HL->y0 -y0);
    }
  }
  /* Start drawing lines ... */
  {
  int xMinDisp, xMaxDisp, xMin=0,xMax=0;
    for (y=yMax; y>=yMin; y--) {
      CalcX(&xMin, y, ri2);
      CalcX(&xMax, y, ro2);
      if ((float)y< afy[1]) {
        xMaxDisp = CalcInterSectLin(y,afy[0], afy[1], afx[0], afx[1]);
			} else {
        xMaxDisp = xMax;			
			}
      if ((float)y > afy[2]) {
        xMinDisp = CalcInterSectLin(y,afy[2], afy[3], afx[2], afx[3]);
			} else {
        xMinDisp = xMin;			
			}
      if (xMul>0)
        LCD_HL_DrawHLine(xMinDisp+x0, yMul*y+y0, xMaxDisp+x0);
      else
        LCD_HL_DrawHLine(-xMaxDisp+x0, yMul*y+y0, -xMinDisp+x0);
    }
	}
#if 0  /* Test code */
{
  int i;
  GUI_SetColor( GUI_WHITE ); 
	for (i=0; i<4; i++)
    LCD_HL_DrawPixel(afx[i]+x0, afy[i]+y0);
}
#endif
  GUI_USE_PARA(ry);
}
void TileSelector::OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle) {
    X = (float)CalcX(mX);
    Y = (float)CalcY(mY);
}
bool CIVStatusBar::IsOverURL(CPoint pt, CString & rstr )
{

	if ( ! IsWindowEnabled()  || !GetTopLevelParent()->IsWindowEnabled()   )
		return false;

	CStatusBarCtrl & sb = GetStatusBarCtrl();
	int iPart = -1;
	CRect rc;
	for (int i=0; i < sb.GetParts(0, NULL); i++ )
	{
		sb.GetRect (i, rc);
		if (rc.PtInRect(pt) && ( GetPaneStyle(i) & SBT_OWNERDRAW )  )
		{
			iPart = i;
			break;
		}
	}

	if (iPart == -1)
		return false;

	if ( ! (GetPaneStyle(iPart)  & SBPS_NOBORDERS) )
		rc.InflateRect(-GetSystemMetrics(SM_CYBORDER), -GetSystemMetrics(SM_CXBORDER));

	if (!rc.PtInRect(pt))
		return false;

	CString strText = GetPaneText(iPart);
	CDC * pDC = GetDC();

	CFont * pFont = GetFont();
	CFont fntURL;
	GetLinkFont(fntURL);
	
	CFont * pOldFont =  pDC->SelectObject (pFont);

	int x = CalcX (pDC, rc, strText);

	bool bFound = false;
	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart = strText.Mid (i, szPos.cx-i);
			CRect rcURL;
			x += pDC->GetTextExtent (strStart).cx;
			rcURL.left = x;
	
			pFont = pDC->SelectObject (&fntURL);
		
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			
			CSize szURL =  pDC->GetTextExtent (strURL);
			x += szURL.cx;
			
			rcURL.right = x;
			rcURL.top = rc.top;
			rcURL.bottom = rc.top + szURL.cy;

			pDC->SelectObject (pFont);
			
			if (rcURL.PtInRect(pt))
			{
				rstr = strURL;
				bFound = true;
				break;
			}

			i = szPos.cx + szPos.cy;
		}
		else
			break;

	}

	pDC->SelectObject (pOldFont);


	return bFound;
}
void CIVStatusBar::DrawItem(LPDRAWITEMSTRUCT lpdis)
{
	CDC dc;
	dc.Attach(lpdis->hDC);
	
	CString strText = GetPaneText( lpdis->itemID);

	CRect rc = lpdis->rcItem; 
	CRect rcTmp = rc;

	COLORREF clrBack = dc.SetBkColor (GetSysColor (COLOR_3DFACE));
	COLORREF clrText = dc.SetTextColor (GetSysColor (COLOR_WINDOWTEXT));

	CFont * pFont =  GetFont();

	CFont fntURL;
	GetLinkFont(fntURL);
	CFont * pOldFont =  dc.SelectObject (pFont);
	
	int x = CalcX (&dc, rc, strText);
	int y = rc.top; 

	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart  = strText.Mid (i, szPos.cx-i);
			
			dc.TextOut (x, y, strStart);
			x += dc.GetTextExtent (strStart).cx;

			COLORREF clrText = dc.SetTextColor ( GetSysColor(COLOR_HIGHLIGHT));

			pFont = dc.SelectObject (&fntURL);
			
			
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			dc.TextOut (x, y, strURL);
			
			x += dc.GetTextExtent (strURL).cx;
			
			dc.SelectObject (pFont);
			dc.SetTextColor (clrText);

			i = szPos.cx + szPos.cy;
		}
		else
		{
			CString strStart  = strText.Mid (i);
			dc.TextOut (x, y, strStart);
			break;
		}

	}

	dc.SelectObject (pOldFont);

	dc.SetBkColor (clrBack);
	dc.SetTextColor (clrText);
	
	dc.Detach ();	

}