Пример #1
0
bool CSprite::init(InitSprite data)
{
    SDL_Surface* temp = IMG_Load(data.imgFile.c_str());
    if(temp == NULL)
    {
        SYSTEM_STREAM << "IMG_Load error: " << IMG_GetError() << std::endl;
        return false;
    }
    metadata.Init(data.imgFile, temp->w, temp->h);
    if (metadata.Valid())
    {
        numFrameW = temp->w / metadata.GetW();
        numFrameH = temp->h / metadata.GetH();
    }
    else
    {
        numFrameH = data.numFrameH;
        numFrameW = data.numFrameW;
    }
    if((numFrameH == 0) || (numFrameW == 0))
    {        
        w = temp->w;
        h = temp->h;
        numFrameW = 1;
        numFrameH = 1;
    }
    else
    {
        w = temp->w / numFrameW;
        h = temp->h / numFrameH;
    }
    SYSTEM_STREAM << numFrameW << "x" << numFrameH << " - loaded " << data.imgFile << std::endl;

    Uint32 rmask, gmask, bmask, amask;
    SetMasks(&rmask, &gmask, &bmask, &amask);

    SDL_Rect place;
    place.x = 0;
    place.y = 0;
    place.h = h;
    place.w = w;
    frames = new SDL_Surface*[numFrameH * numFrameW];
    if (temp->flags & SDL_SRCALPHA)
        temp->flags = temp->flags ^ SDL_SRCALPHA;//for alpha canal
    SDL_Surface* local;
    for(int j = 0; j < numFrameH; ++j)
    {
        place.y = j * h;
        for(int i = 0; i < numFrameW; ++i)
        {
            place.x = i * w;
            local = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 32, bmask, gmask, rmask, amask);
            SDL_BlitSurface(temp, &place, local, NULL);
            frames[i * numFrameH + j] = local;
        }
    }
    SDL_FreeSurface(temp);
    return true;
}
Пример #2
0
//--------------------------------------------------------------------------------
//	@	ViewportManager::SetParentDimensions()
//--------------------------------------------------------------------------------
//		Set the parent dimensions. This changes the size of all viewports.
//--------------------------------------------------------------------------------
void ViewportManager::SetParentDimensions(uint32 w, uint32 h)
{
	//Set parent data
	parent_w = w;
	parent_h = h;

	//Adjust all viewports
	for (int32 i = 0; i < viewportList.size(); ++i)
	{
		viewportList[i].viewport.UpdateSize(w,h);
	}

	//Set masks
	SetMasks();

}	//End: ViewportManager::SetParentDimensions()
Пример #3
0
//--------------------------------------------------------------------------------
//	@	ViewportManager::Deactivate()
//--------------------------------------------------------------------------------
//		Deactivate a viewport. Returns true if viewport found and 
//		successfully deactivated.
//--------------------------------------------------------------------------------
bool ViewportManager::Deactivate(viewportID id)
{
	//Check if viewport exists
	int index;
	if (!viewportList.find(id, index))
		return false;

	//Set flag
	viewportList[index].viewport.SwitchActive(false);

	//Reset z-masks
	SetMasks();

	return true;

}	//End: ViewportManager::Deactivate()
Пример #4
0
bool CSprite::init(InitSprite data)
{
    SDL_Surface* temp = IMG_Load(data.imgFile.c_str());
    if(temp == NULL) return 0;
    numFrameH = data.numFrameH;
    numFrameW = data.numFrameW;
    if((numFrameH == 0) || (numFrameW == 0))
    {
        w = TITLE_SIZE;
        h = TITLE_SIZE;
        numFrameW = temp->w / TITLE_SIZE;
        numFrameH = temp->h / TITLE_SIZE;
        SYSTEM_STREAM << numFrameW << " x " << numFrameH << " - loaded " << data.imgFile.c_str() << std::endl;
    }
    else
    {
        w = temp->w / numFrameW;
        h = temp->h / numFrameH;
    }
    Uint32 rmask, gmask, bmask, amask;
    SetMasks(&rmask, &gmask, &bmask, &amask);

    SDL_Rect place;
    place.x = 0;
    place.y = 0;
    place.h = h;
    place.w = w;
    frames = new SDL_Surface*[numFrameH * numFrameW];
    if (temp->flags & SDL_SRCALPHA)
        temp->flags = temp->flags ^ SDL_SRCALPHA;//for alpha canal
    SDL_Surface* local;
    for(int j = 0; j < numFrameH; ++j)
    {
        place.y = j * h;
        for(int i = 0; i < numFrameW; ++i)
        {
            place.x = i * w;
            local = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 32, bmask, gmask, rmask, amask);
            SDL_BlitSurface(temp, &place, local, NULL);
            frames[i * numFrameH + j] = local;
        }
    }
    SDL_FreeSurface(temp);
    return 1;
}
Пример #5
0
//---------------------------------------------------------------------------
TFileMasks & TFileMasks::operator =(const TFileMasks & rhm)
{
  FForceDirectoryMasks = rhm.FForceDirectoryMasks;
  SetMasks(rhm.GetMasks());
  return *this;
}
Пример #6
0
//---------------------------------------------------------------------------
TFileMasks & TFileMasks::operator =(const UnicodeString & rhs)
{
  SetMasks(rhs);
  return *this;
}