Esempio n. 1
0
void CGetCovers::RunEx()
{
	std::vector<CAlbum*> albumList;

	CMediaDatabase::GetAlbumsFromDatabaseNotLoaded(m_pWindow, &albumList);

	// set processbar max
	m_pProcessbar->SetMaxPosition((int) albumList.size());

	std::vector<CAlbum*>::iterator iter = albumList.begin();

	while ((iter != albumList.end()) && (!m_bPleaseStop))
	{
		CAlbum* album = *iter;
		
		std::string outfile = SallyAPI::String::PathHelper::GetDirectoryFromPath(album->GetFilename());
		outfile.append(album->GetCoverName());

		bool exists = SallyAPI::File::FileHelper::FileExists(outfile);
		
		if (exists)
		{
			// Datei exists already
			CMediaDatabase::SetAlbumInDatabase(m_pWindow, album->GetAlbum(), album->GetArtist(), true);
		}
		else
		{
			// Get it from Amazon
			bool result = false;

			result = m_AmazonCover.GetMusicCover(album->GetArtist(), album->GetAlbum(), outfile);

			if (result)
			{
				CMediaDatabase::SetAlbumInDatabase(m_pWindow, album->GetAlbum(), album->GetArtist(), true);
			}
			else
			{
				CMediaDatabase::SetAlbumInDatabase(m_pWindow, album->GetAlbum(), album->GetArtist(), false);
			}
		}
		++iter;

		// update processbar
		m_pProcessbar->SetPosition(m_pProcessbar->GetPosition() + 1);
	}

	// Delete vector
	iter = albumList.begin();
	while (iter != albumList.end())
	{
		SafeDelete(*iter);
		++iter;
	}

	if (!m_bPleaseStop)
		m_pWindow->SendMessageToParent(0, 0, m_iMessageId);
}
void CAddMusicAlbum::UpdateImages()
{
	EnterRenderLock();

	SallyAPI::Config::CConfig* config = SallyAPI::Config::CConfig::GetInstance(); 
	SallyAPI::Config::CTheme* theme = config->GetTheme();

	std::vector<CAlbum*>::iterator iter = m_vAlbumList.begin();

	int k = 0;
	int i = 0;

	if (m_iStartPicture == 0)
	{
		std::vector<SallyAPI::GUI::CImageBox*> imageBoxVector = m_mImage[0];
		std::vector<SallyAPI::GUI::CLabelBox*> imageNameVector = m_mImageName[0];
		std::vector<SallyAPI::GUI::CButton*> imageAddAllVector = m_mImageAddAlbum[0];

		for (int l = 0; l < m_iRows; ++l)
		{
			imageBoxVector[l]->Visible(false);
			imageNameVector[l]->Visible(false);
			imageAddAllVector[l]->Visible(false);
		}
		k = 1;
	}

	for (int l = 0; (l < (m_iStartPicture - 1) * m_iRows) && (iter != m_vAlbumList.end()); ++l)
	{
		++iter;
	}

	SallyAPI::GUI::CPicture* picture;

	while ((k < m_iCols + 2) && (iter != m_vAlbumList.end()))
	{
		std::vector<SallyAPI::GUI::CImageBox*> imageBoxVector = m_mImage[k];
		std::vector<SallyAPI::GUI::CLabelBox*> imageNameVector = m_mImageName[k];
		std::vector<SallyAPI::GUI::CButton*> imageAddAllVector = m_mImageAddAlbum[k];

		for (; (i < m_iRows) && (iter != m_vAlbumList.end()); i++)
		{
			CAlbum* album = *iter;

			std::string covername = album->GetCoverName();
			
			std::string filename = SallyAPI::String::PathHelper::GetDirectoryFromPath(album->GetFilename());
			filename = SallyAPI::String::PathHelper::CorrectPath(filename);

			filename.append(covername);

			std::string description = album->GetArtist();
			description.append("\n");
			description.append(album->GetAlbum());

			imageNameVector[i]->SetText(description);
			imageBoxVector[i]->SetText(filename);

			picture = m_mPictureMap[filename];

			// Not yet loaded... use default pic
			if (picture == NULL)
				picture = theme->GetPicture(GUI_APP_DEFAULT_CD + m_iGraphicId);

			// Now paint
			if (picture != NULL)
			{
				imageBoxVector[i]->SetPicture(picture);
				imageBoxVector[i]->Visible(true);

				/*
				int xImageBox = 0;
				int yImageBox = 0;
				imageBoxVector[i]->GetAbsolutPosition(&xImageBox, &yImageBox);

				float rotationAngleY = xImageBox - ((WINDOW_WIDTH) / 2) + MENU_WIDTH;
				rotationAngleY = rotationAngleY / 1500;

				imageBoxVector[i]->SetRotationAngleY(rotationAngleY);
				*/

				imageNameVector[i]->Visible(true);

				imageAddAllVector[i]->Visible(true);
			}
			else
			{
				imageBoxVector[i]->SetPicture(NULL);
				imageNameVector[i]->SetText("");
				imageNameVector[i]->Visible(false);
				imageAddAllVector[i]->Visible(false);
			}
			++iter;
		}
		if (iter != m_vAlbumList.end())
		{
			i = 0;
			k++;
		}
	}

	for (; k < m_iCols + 2; ++k)
	{
		std::vector<SallyAPI::GUI::CImageBox*> imageBoxVector = m_mImage[k];
		std::vector<SallyAPI::GUI::CLabelBox*> imageNameVector = m_mImageName[k];
		std::vector<SallyAPI::GUI::CButton*> imageAddAllVector = m_mImageAddAlbum[k];

		for (; i < m_iRows; ++i)
		{
			imageBoxVector[i]->Visible(false);
			imageNameVector[i]->Visible(false);
			imageAddAllVector[i]->Visible(false);
			imageNameVector[i]->SetText("");
			imageBoxVector[i]->SetPicture(NULL);
		}
		i = 0;
	}

	LeaveRenderLock();
}