Esempio n. 1
0
void Asteroid::CheckHidden(){
  if(GetCurrentPosition().y<-GetH()/2
  || GetCurrentPosition().x<-GetW()/2
  || GetCurrentPosition().x>WIDTH+GetW()/2){
    status = OFFSCREEN;
  }
}
Esempio n. 2
0
void Slider::Draw( int relx, int rely ){
	int x, y;

	x = GetX() + relx;
	y = GetY() + rely;

	int markerxr = this->ValToPixel( this->val );
	int markerx = x + markerxr;
	
	// Draw slider background
	Video::DrawRect( x, y+(GetH()/2)-SLIDER_H/2, GetW(), SLIDER_H,
			0.4f, 0.4f, 0.4f);
	Video::DrawRect( x+1, y+(GetH()/2)-SLIDER_H/2+1, GetW()-2, SLIDER_H-2,
			0.15f, 0.15f, 0.15f);
	Video::DrawRect( x+3, y+(GetH()/2)-SLIDER_H/2+3, 
			markerxr-3, SLIDER_H-6,
			0.4f, 0.4f, 0.4f);

	// Draw marker
	Video::DrawRect( markerx-SLIDER_MW/2, y, SLIDER_MW, GetH(),
			0.4f, 0.4f, 0.4f);
	Video::DrawRect( markerx-SLIDER_MW/2+1, y+1, SLIDER_MW-2, GetH()-2,
			0.15f, 0.15f, 0.15f);

	// Render the value indicator
	char value[20];
	snprintf(value,20,"%.2f",this->val);
	SansSerif->Render( markerx, y, value,Font::CENTER,Font::BOTTOM );
}
Esempio n. 3
0
void C_Slider::HighLite(SCREEN *surface,UI95_RECT *cliprect)
{
	UI95_RECT clip,tmp;

	clip.left=GetX() + SX_;
	clip.top=GetY() + SY_;

	if(Flags_ & C_BIT_RIGHT)
		clip.left-=GetW();
	else if(Flags_ & C_BIT_HCENTER)
		clip.left-=GetW()/2;

	if(Flags_ & C_BIT_BOTTOM)
		clip.top-=GetH();
	else if(Flags_ & C_BIT_VCENTER)
		clip.top-=GetH()/2;

	if(!(Flags_ & C_BIT_ABSOLUTE))
	{
		clip.left+=Parent_->VX_[Client_];
		clip.top+=Parent_->VY_[Client_];
	}
	clip.right=clip.left+Slider_->Header->w;
	clip.bottom=clip.top+Slider_->Header->h;

	if(!Parent_->ClipToArea(&tmp,&clip,cliprect))
		return;

	if(!(Flags_ & C_BIT_ABSOLUTE))
		if(!Parent_->ClipToArea(&tmp,&clip,&Parent_->ClientArea_[Client_]))
			return;

	Parent_->BlitTranslucent(surface,MouseOverColor_,MouseOverPercent_,&clip,C_BIT_ABSOLUTE,0);
}
Esempio n. 4
0
/**\brief Calculates the value from pixel offset
 */
 float Slider::PixelToVal( int pixels ){
	float value;
	if ( this->maxval < this->minval )
		value = (TO_FLOAT(pixels - SLIDER_MW/2 ) 
			/ TO_FLOAT(GetW() - SLIDER_MW))
			* ( minval - maxval) + maxval;
	else
		value = (TO_FLOAT(pixels - SLIDER_MW/2)
			/ TO_FLOAT(GetW() - SLIDER_MW))
			* ( maxval - minval) + minval;
	return value;
 }
Esempio n. 5
0
    PixelColor::Enum PotraceImage::GetPixelAt(image_size_t x, image_size_t y, int shiftX, int shiftY) const {
        shiftX = (shiftX > 0 ? 0 : -1);
        shiftY = (shiftY > 0 ? 0 : -1);

        x += shiftX;
        y += shiftY;

        if (x < 0 || x >= GetW() || y < 0 || y >= GetH()) {
            return PixelColor::White;
        }
        else {
            return pixelMap[y * GetW() + x];
        }
    }
Esempio n. 6
0
    void PotraceImage::InvertPixels(const vector<Point2>& pixels) {
        vector<Point2>::const_iterator it;
        const vector<Point2>::const_iterator pixelsEnd = pixels.end();
        for (it = pixels.begin(); it != pixelsEnd; ++it) {
            if (it->x >= 0 && it->x < GetW() || it->y >= 0 || it->y < GetH()) {
                long mapIndex = it->y * GetW() + it->x;

                PixelColor::Enum currentColor = pixelMap[mapIndex];
                PixelColor::Enum invertedColor = (currentColor == PixelColor::Black ? PixelColor::White : PixelColor::Black);
                
                pixelMap[mapIndex] = invertedColor;
                isInvertedMap[mapIndex] = !isInvertedMap[mapIndex];
            }
        }
    }
Esempio n. 7
0
void C_ATO_Package::Refresh()
{
    if(!Ready() || Flags_ & C_BIT_INVISIBLE || Parent_ == NULL)
        return;

    Parent_->SetUpdateRect(GetX(),GetY(),GetX()+GetW(),GetY()+GetH(),Flags_,GetClient());
}
Esempio n. 8
0
void C_ListBox::SetSubParents(C_Window *Parent)
{
	LISTBOX *cur;

	if(!LabelColor_)
		LabelColor_=NormalColor_;

	if(BgImage_)
		BgImage_->SetInfo();

	if(DropDown_)
	{
		DropDown_->SetXY(GetW()-DropDown_->GetW()-2,GetH()/2-DropDown_->GetH()/2);
		DropDown_->SetInfo();
		DropDown_->SetFlags(GetFlags());
	}

	cur=Root_;
	while(cur)
	{
		cur->Label_->SetParent(Parent);
		cur->Label_->SetSubParents(Parent);
		cur->Label_->SetOwner(this);
		cur=cur->Next;
	}
}
Esempio n. 9
0
//-------------------妖精17---------------------------------
CEnemyFairy17::CEnemyFairy17(double x,double y)
{
	this->x = x - GetW()/2;
	this->y = y - GetH()/2;
	this->hp = 150;
	this->color = 5;
}
Esempio n. 10
0
void C_ServerItem::Refresh()
{
	if(GetFlags() & C_BIT_INVISIBLE || Parent_ == NULL)
		return;

	Parent_->SetUpdateRect(GetX(),GetY(),GetX()+GetW(),GetY()+GetH(),GetFlags(),GetClient());
}
Esempio n. 11
0
void C_Tile::Refresh()
{
	if(GetFlags() & C_BIT_INVISIBLE || !Ready() || !Parent_)
		return;

	Parent_->SetUpdateRect(GetX(),GetY(),GetX()+GetW(),GetY()+GetH(),GetFlags(),GetClient());
}
Esempio n. 12
0
long C_Slider::CheckHotSpots(long relX,long relY)
{
	// check visibility, enabled and ready
	if((GetFlags() & C_BIT_INVISIBLE) || !(GetFlags() & C_BIT_ENABLED) || !Ready()){
		return(0);
	}


	if (
/*
		(relX < (GetX()+SX_)) ||
		(relX > (GetX()+(Slider_->Header->w)+SX_)) ||
		(relY < (GetY()+SY_)) ||
		(relY > (GetY()+(Slider_->Header->h)+SY_))*/
		(relX < GetX()) || (relX > (GetX() + GetW())) ||
		(relY < GetY()) || (relY > (GetY() + GetH()))
	){
		return(0);
	}

	switch(GetType())
	{
		case C_TYPE_VERTICAL:
			SetRelXY(relX-GetX(),relY-GetY());
			return(GetID());
			break;
		case C_TYPE_HORIZONTAL:
			SetRelXY(relX-GetX(),relY-GetY());
			return(GetID());
			break;
	}
	return(0);
}
Esempio n. 13
0
bool CRectangle::Contains(const CRectangle& rc) const
{
    int left1, top1, right1, bottom1;
    int left2, top2, right2, bottom2;
    left1 = GetX();
    top1 = GetY();
    right1 = GetX() + GetW();
    bottom1 = GetY() + GetH();

    left2 = rc.GetX();
    top2 = rc.GetY();
    right2 = rc.GetX() + rc.GetW();
    bottom2 = rc.GetY() + rc.GetH();

//    return !(left1 < right2 && right1 > left2 &&
//        top1 > bottom2 && bottom1 < top2);
//    return (left1 < right2 || right1 > left2 ||
//        top1 > bottom2 || bottom1 < top2);
//    return ((left1 < right2) || (right1 > left2) ||
//        (top1 > bottom2) || (bottom1 < top2));
//    return (!(left1 < right2) || !(right1 > left2) ||
//        !(top1 > bottom2) || !(bottom1 < top2));
//    return (!(left1 < right2) && !(right1 > left2) &&
//        !(top1 > bottom2) && !(bottom1 < top2));

    bool xOverlap = valueInRange(left1, left2, right2) ||
        valueInRange(left2, left1, right1);

    bool yOverlap = valueInRange(top1, top2, bottom2) ||
        valueInRange(top2, top1, bottom1);

    return xOverlap && yOverlap;

}
Esempio n. 14
0
void C_Slider::Refresh()
{
	if(!Ready() || GetFlags() & C_BIT_INVISIBLE || Parent_ == NULL)
		return;

	Parent_->SetUpdateRect(GetX()+SX_,GetY()+SY_,GetX()+SX_+GetW()+1,GetY()+SY_+GetH()+1,GetFlags(),GetClient());
}
Esempio n. 15
0
void Slider::Draw( int relx, int rely ){
	int x, y;

	x = GetX() + relx;
	y = GetY() + rely;

	int markerx_pix = ValToPixel( val );
	
	// Draw slider background
	left->Draw( x, y );
	background->DrawTiled( x + left->GetWidth(), y, w - left->GetWidth() - right->GetWidth(), background->GetHeight() );
	right->Draw( x + w - right->GetWidth(), y );

	// Draw the Bar
	bar->DrawTiled( x + left->GetWidth(),
	                y + background->GetHalfHeight() - bar->GetHalfHeight(),
	                markerx_pix, bar->GetHeight() );

	// Draw marker
	handle->Draw( x + markerx_pix - handle->GetHalfWidth(),
	              y + background->GetHalfHeight() - handle->GetHalfHeight() );

	// Render the value indicator
	char value[20] = {0};
	snprintf(value, 20, "%.2f", this->val);
	UI::font->Render( x + markerx_pix, y - 3, value, Font::CENTER, Font::BOTTOM );

	UI::font->RenderTight( x + GetW() + 5, y, name );

	Widget::Draw(relx, rely);
}
Esempio n. 16
0
void C_Slider::Draw(SCREEN *surface,UI95_RECT *cliprect)
{
	UI95_RECT rect,s;

	if(!Ready()) return;

	if(GetFlags() & C_BIT_INVISIBLE)
		return;

	rect.left=GetX();
	rect.right=rect.left+GetW();
	rect.top=GetY();
	rect.bottom=rect.top+GetH();

//	if(BgImage_)
//	{
//		BgImage_->Blit(0,0,BgImage_->Header->w,BgImage_->Header->h,rect.left,rect.top,800,dest);
//		//Parent_->Blit(BgImage_->Image,&BgImage_->rect,&rect,GetFlags(),GetClient());
//	}
	if(Slider_)
	{
		s.left=0;
		s.top=0;
		s.right=Slider_->Header->w;
		s.bottom=Slider_->Header->h;

		rect.left=GetX()+SX_;
		rect.top=GetY()+SY_;
		rect.right=rect.left+Slider_->Header->w;
		rect.bottom=rect.top+Slider_->Header->h;

		if(GetFlags() & C_BIT_ABSOLUTE)
		{
			if(!Parent_->ClipToArea(&s,&rect,&Parent_->Area_))
				return;
		}
		else
		{
			rect.left+=Parent_->VX_[GetClient()];
			rect.top+=Parent_->VY_[GetClient()];
			rect.right+=Parent_->VX_[GetClient()];
			rect.bottom+=Parent_->VY_[GetClient()];
			if(!Parent_->ClipToArea(&s,&rect,&Parent_->ClientArea_[GetClient()]))
				return;
		}

		if(!Parent_->ClipToArea(&s,&rect,cliprect))
			return;

		rect.left+=Parent_->GetX();
		rect.top+=Parent_->GetY();
		rect.right+=Parent_->GetX();
		rect.bottom+=Parent_->GetY();

		Slider_->Blit(surface,s.left,s.top,s.right-s.left,s.bottom-s.top,rect.left,rect.top);
		if(MouseOver_ || (GetFlags() & C_BIT_FORCEMOUSEOVER))
			HighLite(surface,cliprect);
	}
}
Esempio n. 17
0
//-------------------妖精15---------------------------------
CEnemyFairy15::CEnemyFairy15(double x,double y,int c)
{
	this->x = x - GetW()/2;
	this->y = y - GetH()/2;
	this->hp = 200;
	this->color = 5;
	this->c = c;
}
Esempio n. 18
0
template <typename T> U32 TVector4<T>::GetBGRAU32( void ) const
{	U32 r = U32(GetX()*T(255.0f));
	U32 g = U32(GetY()*T(255.0f));
	U32 b = U32(GetZ()*T(255.0f));
	U32 a = U32(GetW()*T(255.0f));
	
	return U32( (b<<24)|(g<<16)|(r<<8)|a );
}
Esempio n. 19
0
void Meter::UpdateContainer()
{
	UINT width = (UINT)GetW();
	UINT height = (UINT)GetH();

	if (m_ContainerTexture) m_ContainerTexture->Resize(m_Skin->GetCanvas(), width, height);

	if (m_ContainerContentTexture) m_ContainerContentTexture->Resize(m_Skin->GetCanvas(), width, height);
}
Esempio n. 20
0
long C_ServerItem::CheckHotSpots(long relx,long rely)
{
	if(GetFlags() & C_BIT_INVISIBLE || !(GetFlags() & C_BIT_ENABLED) || !Ready())
		return(0);

	if(relx >= GetX() && rely >= GetY() && relx <= (GetX()+GetW()) && rely <= (GetY()+GetH()))
		return(GetID());
	return(0);
}
Esempio n. 21
0
void C_TimerHook::Refresh()
{
	if(!Ready() || (GetFlags() & C_BIT_INVISIBLE))
		return;

	Parent_->SetUpdateRect(GetX(),GetY(),GetX()+GetW(),GetY()+GetH(),GetFlags(),GetClient());
	if(RefreshCallback_)
		(*RefreshCallback_)(GetID(),C_TYPE_TIMER,this);
}
Esempio n. 22
0
void C_Fill::Refresh()
{
	if(GetFlags() & C_BIT_INVISIBLE || Parent_ == NULL)
		return;

	F4CSECTIONHANDLE* Leave=UI_Enter(Parent_); 
	Parent_->SetUpdateRect(GetX(),GetY(),GetX()+GetW(),GetY()+GetH(),GetFlags(),GetClient());
	UI_Leave(Leave);
}
Esempio n. 23
0
void AjustaVW(int SpeedDreta, int SpeedEsquerra) {
	float radi;
	if (SpeedDreta != SpeedEsquerra) {	// Hi ha velocitat angular
		radi = 2*RADI_COTXE*SpeedEsquerra / (float)(SpeedDreta-SpeedEsquerra);
		if (radi > RADI_COTXE) W = GetV(SpeedDreta)/radi; 
		else W = GetW(SpeedDreta)/2;
	} else W = 0;
	V = GetV(SpeedDreta);
}
Esempio n. 24
0
void ExecutaOrdre(void) {
	switch (OrdreAct.Opcode) {
		case M_LIN:
			MtSetPWM(M_ESQUERRA, GetVelocitatEsquerra(), GetDireccio());
			MtSetPWM(M_DRET, GetVelocitatDreta(), GetDireccio());
			if (GetDireccio() == M_DIR_ENDARRERA) V = -GetV(GetVelocitatDreta()); 
			else V = GetV(GetVelocitatDreta());
			W = 0;
			// LS_USB_printf("LIN V = %f, W = %f\n\r", V, W);
			break;
		case M_GD:
			// Si el radi és menor que la meitat de la distància entre rodes, cal oposar els motors
			// Si no, sempre vas endavant
			if (OrdreAct.Radi < RADI_COTXE) {
				MtSetPWM(M_ESQUERRA, GetRadi(), M_DIR_ENDAVANT);
				MtSetPWM(M_DRET, GetRadi(), M_DIR_ENDARRERA);
				W = -GetW(GetRadi()); V = 0;
				// LS_USB_printf("GD V = %f, W = %f\n\r", V, W);
			} else {
				MtSetPWM(M_ESQUERRA, GetVelocitatEsquerra(), GetDireccio());
				MtSetPWM(M_DRET, GetRadiInterior(GetVelocitatDreta()), GetDireccio());
				if (GetDireccio() == M_DIR_ENDARRERA) V = -GetV(GetVelocitatEsquerra()); 
				else V = GetV(GetVelocitatEsquerra());
				NvSetOmega(GetVelocitatEsquerra(), GetDireccio(), GetRadiInterior(GetVelocitatDreta()), GetDireccio());
			}
			break;
		case M_GE:
			// Si el radi és menor que la meitat de la distància entre rodes, cal oposar els motors
			// Si no, sempre vas endavant
			if (OrdreAct.Radi < RADI_COTXE) {
				MtSetPWM(M_ESQUERRA, GetRadi(), M_DIR_ENDARRERA);
				MtSetPWM(M_DRET, GetRadi(), M_DIR_ENDAVANT);
				W = GetW(GetRadi()); V = 0;
				// LS_USB_printf("GE V = %f, W = %f\n\r", V, W);
			} else {
				MtSetPWM(M_ESQUERRA, GetRadiInterior(GetVelocitatEsquerra()), GetDireccio());
				MtSetPWM(M_DRET, GetVelocitatDreta(), GetDireccio());
				if (GetDireccio() == M_DIR_ENDARRERA) V = -GetV(GetVelocitatDreta()); 
				else V = GetV(GetVelocitatDreta());
				NvSetOmega(GetRadiInterior(GetVelocitatEsquerra()), GetDireccio(), GetVelocitatDreta(), GetDireccio());
			}
			break;
	}
}
Esempio n. 25
0
void VideoSystem::drawGrid() {
    int xstart = 16 - g_Camera->x() % 16;
    for (int i = 0; i < GetW()/16; i++) {
        SDL_Rect r;
        r.x = xstart + i * 16;
        r.y = 0;
        r.w = 1;
        r.h = GetH();
        SDL_FillRect(screen, &r, Color(255,0,0));
    }
    for (int i = 0; i < GetH()/16; i++) {
        SDL_Rect r;
        r.x = 0;
        r.y = i*16;
        r.w = GetW();
        r.h = 1;
        SDL_FillRect(screen, &r, Color(255,0,0));
    }
}
Esempio n. 26
0
long C_ListBox::CheckHotSpots(long relX,long relY)
{
	if(GetFlags() & C_BIT_INVISIBLE || !(GetFlags() & C_BIT_ENABLED))
		return(0);

	if(relX < GetX() || relX > (GetX()+GetW()) || relY < GetY() || relY > (GetY()+GetH()))
		return(0);

	SetRelXY(relX-GetX(),relY-GetY());
	return(GetID());
}
Esempio n. 27
0
void C_ListBox::SetDropDown(long ImageID)
{
	if(ImageID){
		if(DropDown_ == NULL){
			DropDown_=new O_Output;
			DropDown_->SetOwner(this);
		}
		DropDown_->SetImage(ImageID);
		DropDown_->SetXY(GetW() - DropDown_->GetW() - 2, GetH()/2 - DropDown_->GetH()/2);
		DropDown_->SetFlags(GetFlags());
	}
}
Esempio n. 28
0
CRectangle CRectangle::operator / (float div) const {
    int left1, top1, right1, bottom1;
    int left2, top2, right2, bottom2;

    left1 = GetX();
    top1 = GetY();
    right1 = GetW() / div;
    bottom1 = GetH() / div;

    CRectangle result(left1, top1, right1, bottom1);
    return result;
}
Esempio n. 29
0
BOOL C_ListBox::Process(long ID,short HitType)
{
	gSoundMgr->PlaySound(GetSound(HitType));
	switch(HitType)
	{
		case C_TYPE_LMOUSEUP:
			if(Callback_)
				(*Callback_)(ID,HitType,this);
			if(GetFlags() & C_BIT_ABSOLUTE)
				OpenWindow((short)(Parent_->GetX() + GetX()),
						   (short)(Parent_->GetY() + GetY() + GetH() + 1),
						   (short)GetW(), (short)GetListHeight());//! 
			else
				OpenWindow((short)(Parent_->GetX() + Parent_->VX_[GetClient()] + GetX()),
						   (short)(Parent_->GetY() + Parent_->VY_[GetClient()] + GetY() + GetH() + 1),
						   (short)GetW(),(short)GetListHeight());//! 
			return(TRUE);
			break;
	}
	return(FALSE);
}
Esempio n. 30
0
CPoint CRectangle::Position(const CompassRose& value) const {
    switch(value)
    {
    case CompassRose::Origin:
        return CPoint(GetX() + GetW() / 2, GetY() + GetH() / 2);

    case CompassRose::N:
        return CPoint(GetX() + GetW() / 2, GetY());

    case CompassRose::NE:
        return CPoint(GetX() + GetW(), GetY());

    case CompassRose::E:
        return CPoint((GetX() + GetW()), GetY() + GetH() / 2);

    case CompassRose::SE:
        return CPoint(GetX() + GetW(), GetY() + GetH());

    case CompassRose::S:
        return CPoint(GetX() + GetW() / 2, GetY() + GetH());

    case CompassRose::SW:
        return CPoint(GetX(), GetY() + GetH());

    case CompassRose::W:
        return CPoint(GetX(), GetY() + GetH() / 2);

    case CompassRose::NW:
        return CPoint(GetX(), GetY());

    case CompassRose::CompassRose_END:
    default:
        throw std::runtime_error("Illegal CRectangle::CompassRose enum.");
    } // switch
} // CRectangle::Position