Fix stamps page count

This commit is contained in:
Simon Robertshaw 2012-08-21 14:06:54 +01:00
parent 41e622ab78
commit 62f067d29d
4 changed files with 11 additions and 35 deletions

View File

@ -824,37 +824,6 @@ SaveFile * Client::GetStamp(std::string stampID)
{
return NULL;
}
/*std::ifstream stampFile;
stampFile.open(std::string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), std::ios::binary);
if(stampFile.is_open())
{
stampFile.seekg(0, std::ios::end);
size_t fileSize = stampFile.tellg();
stampFile.seekg(0);
unsigned char * tempData = new unsigned char[fileSize];
stampFile.read((char *)tempData, fileSize);
stampFile.close();
SaveFile * file = new SaveFile(std::string(stampID).c_str());
GameSave * tempSave = NULL;
try
{
GameSave * tempSave = new GameSave((char *)tempData, fileSize);
file->SetGameSave(tempSave);
}
catch (ParseException & e)
{
delete[] tempData;
std::cerr << "Client: Invalid stamp file, " << stampID << " " << std::string(e.what()) << std::endl;
}
delete[] tempData;
return file;
}
else
{
return NULL;
}*/
}
void Client::DeleteStamp(std::string stampID)

View File

@ -87,6 +87,11 @@ void LocalBrowserModel::UpdateSavesList(int pageNumber)
notifySavesListChanged();
}
int LocalBrowserModel::GetPageCount()
{
return std::max(1, (int)(std::ceil(float(Client::Ref().GetStampsCount())/20.0f)));
}
void LocalBrowserModel::SelectSave(std::string stampID)
{
for(int i = 0; i < selected.size(); i++)

View File

@ -27,7 +27,7 @@ class LocalBrowserModel {
void notifySelectedChanged();
public:
LocalBrowserModel();
int GetPageCount() { return std::max(1, (int)(std::ceil(stampIDs.size()/16))); }
int GetPageCount();
int GetPageNum() { return currentPage; }
void AddObserver(LocalBrowserView * observer);
std::vector<SaveFile *> GetSavesList();

View File

@ -41,7 +41,8 @@ LocalBrowserView::LocalBrowserView():
}
};
nextButton->SetActionCallback(new NextPageAction(this));
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight; nextButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
class PrevPageAction : public ui::ButtonAction
{
@ -54,7 +55,8 @@ LocalBrowserView::LocalBrowserView():
}
};
previousButton->SetActionCallback(new PrevPageAction(this));
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; previousButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
class RemoveSelectedAction : public ui::ButtonAction
{
@ -186,7 +188,7 @@ void LocalBrowserView::OnMouseWheel(int x, int y, int d)
{
if(!d)
return;
if(d<0)
if(d>0)
c->NextPage();
else
c->PrevPage();