mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-23 16:33:00 +02:00
Fix stamps page count
This commit is contained in:
@@ -824,37 +824,6 @@ SaveFile * Client::GetStamp(std::string stampID)
|
|||||||
{
|
{
|
||||||
return NULL;
|
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)
|
void Client::DeleteStamp(std::string stampID)
|
||||||
|
@@ -87,6 +87,11 @@ void LocalBrowserModel::UpdateSavesList(int pageNumber)
|
|||||||
notifySavesListChanged();
|
notifySavesListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LocalBrowserModel::GetPageCount()
|
||||||
|
{
|
||||||
|
return std::max(1, (int)(std::ceil(float(Client::Ref().GetStampsCount())/20.0f)));
|
||||||
|
}
|
||||||
|
|
||||||
void LocalBrowserModel::SelectSave(std::string stampID)
|
void LocalBrowserModel::SelectSave(std::string stampID)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < selected.size(); i++)
|
for(int i = 0; i < selected.size(); i++)
|
||||||
|
@@ -27,7 +27,7 @@ class LocalBrowserModel {
|
|||||||
void notifySelectedChanged();
|
void notifySelectedChanged();
|
||||||
public:
|
public:
|
||||||
LocalBrowserModel();
|
LocalBrowserModel();
|
||||||
int GetPageCount() { return std::max(1, (int)(std::ceil(stampIDs.size()/16))); }
|
int GetPageCount();
|
||||||
int GetPageNum() { return currentPage; }
|
int GetPageNum() { return currentPage; }
|
||||||
void AddObserver(LocalBrowserView * observer);
|
void AddObserver(LocalBrowserView * observer);
|
||||||
std::vector<SaveFile *> GetSavesList();
|
std::vector<SaveFile *> GetSavesList();
|
||||||
|
@@ -41,7 +41,8 @@ LocalBrowserView::LocalBrowserView():
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
nextButton->SetActionCallback(new NextPageAction(this));
|
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
|
class PrevPageAction : public ui::ButtonAction
|
||||||
{
|
{
|
||||||
@@ -54,7 +55,8 @@ LocalBrowserView::LocalBrowserView():
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
previousButton->SetActionCallback(new PrevPageAction(this));
|
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
|
class RemoveSelectedAction : public ui::ButtonAction
|
||||||
{
|
{
|
||||||
@@ -186,7 +188,7 @@ void LocalBrowserView::OnMouseWheel(int x, int y, int d)
|
|||||||
{
|
{
|
||||||
if(!d)
|
if(!d)
|
||||||
return;
|
return;
|
||||||
if(d<0)
|
if(d>0)
|
||||||
c->NextPage();
|
c->NextPage();
|
||||||
else
|
else
|
||||||
c->PrevPage();
|
c->PrevPage();
|
||||||
|
Reference in New Issue
Block a user