commit
1bce4984e3
@ -1691,7 +1691,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
|
|||||||
json::Number tempVersion = objDocument["Version"];
|
json::Number tempVersion = objDocument["Version"];
|
||||||
|
|
||||||
json::Array tagsArray = objDocument["Tags"];
|
json::Array tagsArray = objDocument["Tags"];
|
||||||
std::vector<std::string> tempTags;
|
std::list<std::string> tempTags;
|
||||||
|
|
||||||
for(int j = 0; j < tagsArray.Size(); j++)
|
for(int j = 0; j < tagsArray.Size(); j++)
|
||||||
{
|
{
|
||||||
@ -1767,7 +1767,7 @@ RequestBroker::Request * Client::GetSaveAsync(int saveID, int saveDate)
|
|||||||
json::Number tempVersion = objDocument["Version"];
|
json::Number tempVersion = objDocument["Version"];
|
||||||
|
|
||||||
json::Array tagsArray = objDocument["Tags"];
|
json::Array tagsArray = objDocument["Tags"];
|
||||||
std::vector<std::string> tempTags;
|
std::list<std::string> tempTags;
|
||||||
|
|
||||||
for(int j = 0; j < tagsArray.Size(); j++)
|
for(int j = 0; j < tagsArray.Size(); j++)
|
||||||
{
|
{
|
||||||
@ -2205,10 +2205,10 @@ Thumbnail * Client::GetThumbnail(int saveID, int saveDate)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> * Client::RemoveTag(int saveID, std::string tag)
|
std::list<std::string> * Client::RemoveTag(int saveID, std::string tag)
|
||||||
{
|
{
|
||||||
lastError = "";
|
lastError = "";
|
||||||
std::vector<std::string> * tags = NULL;
|
std::list<std::string> * tags = NULL;
|
||||||
std::stringstream urlStream;
|
std::stringstream urlStream;
|
||||||
char * data = NULL;
|
char * data = NULL;
|
||||||
int dataStatus, dataLength;
|
int dataStatus, dataLength;
|
||||||
@ -2243,7 +2243,7 @@ std::vector<std::string> * Client::RemoveTag(int saveID, std::string tag)
|
|||||||
{
|
{
|
||||||
json::Array tagsArray = responseObject["Tags"];
|
json::Array tagsArray = responseObject["Tags"];
|
||||||
|
|
||||||
tags = new std::vector<std::string>();
|
tags = new std::list<std::string>();
|
||||||
|
|
||||||
for(int j = 0; j < tagsArray.Size(); j++)
|
for(int j = 0; j < tagsArray.Size(); j++)
|
||||||
{
|
{
|
||||||
@ -2266,10 +2266,10 @@ std::vector<std::string> * Client::RemoveTag(int saveID, std::string tag)
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> * Client::AddTag(int saveID, std::string tag)
|
std::list<std::string> * Client::AddTag(int saveID, std::string tag)
|
||||||
{
|
{
|
||||||
lastError = "";
|
lastError = "";
|
||||||
std::vector<std::string> * tags = NULL;
|
std::list<std::string> * tags = NULL;
|
||||||
std::stringstream urlStream;
|
std::stringstream urlStream;
|
||||||
char * data = NULL;
|
char * data = NULL;
|
||||||
int dataStatus, dataLength;
|
int dataStatus, dataLength;
|
||||||
@ -2304,7 +2304,7 @@ std::vector<std::string> * Client::AddTag(int saveID, std::string tag)
|
|||||||
{
|
{
|
||||||
json::Array tagsArray = responseObject["Tags"];
|
json::Array tagsArray = responseObject["Tags"];
|
||||||
|
|
||||||
tags = new std::vector<std::string>();
|
tags = new std::list<std::string>();
|
||||||
|
|
||||||
for(int j = 0; j < tagsArray.Size(); j++)
|
for(int j = 0; j < tagsArray.Size(); j++)
|
||||||
{
|
{
|
||||||
|
@ -160,8 +160,8 @@ public:
|
|||||||
RequestStatus FavouriteSave(int saveID, bool favourite);
|
RequestStatus FavouriteSave(int saveID, bool favourite);
|
||||||
void SetAuthUser(User user);
|
void SetAuthUser(User user);
|
||||||
User GetAuthUser();
|
User GetAuthUser();
|
||||||
std::vector<std::string> * RemoveTag(int saveID, std::string tag); //TODO RequestStatus
|
std::list<std::string> * RemoveTag(int saveID, std::string tag); //TODO RequestStatus
|
||||||
std::vector<std::string> * AddTag(int saveID, std::string tag);
|
std::list<std::string> * AddTag(int saveID, std::string tag);
|
||||||
std::string GetLastError() {
|
std::string GetLastError() {
|
||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,13 @@ SaveInfo::SaveInfo(SaveInfo & save):
|
|||||||
votesDown(save.votesDown),
|
votesDown(save.votesDown),
|
||||||
gameSave(NULL),
|
gameSave(NULL),
|
||||||
vote(save.vote),
|
vote(save.vote),
|
||||||
tags(save.tags),
|
|
||||||
Comments(save.Comments),
|
Comments(save.Comments),
|
||||||
Views(save.Views),
|
Views(save.Views),
|
||||||
Version(save.Version)
|
Version(save.Version)
|
||||||
{
|
{
|
||||||
|
std::list<std::string> tagsSorted = save.tags;
|
||||||
|
tagsSorted.sort();
|
||||||
|
tags=tagsSorted;
|
||||||
if(save.gameSave)
|
if(save.gameSave)
|
||||||
gameSave = new GameSave(*save.gameSave);
|
gameSave = new GameSave(*save.gameSave);
|
||||||
}
|
}
|
||||||
@ -41,7 +43,7 @@ SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::vector<std::string> tags_):
|
SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags_):
|
||||||
id(_id),
|
id(_id),
|
||||||
votesUp(_votesUp),
|
votesUp(_votesUp),
|
||||||
votesDown(_votesDown),
|
votesDown(_votesDown),
|
||||||
@ -52,12 +54,13 @@ SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote,
|
|||||||
Published(published_),
|
Published(published_),
|
||||||
gameSave(NULL),
|
gameSave(NULL),
|
||||||
vote(_vote),
|
vote(_vote),
|
||||||
tags(tags_),
|
|
||||||
Comments(0),
|
Comments(0),
|
||||||
Views(0),
|
Views(0),
|
||||||
Version(0)
|
Version(0)
|
||||||
{
|
{
|
||||||
|
std::list<std::string> tagsSorted = tags_;
|
||||||
|
tagsSorted.sort();
|
||||||
|
tags=tagsSorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveInfo::~SaveInfo()
|
SaveInfo::~SaveInfo()
|
||||||
@ -150,11 +153,14 @@ int SaveInfo::GetVersion()
|
|||||||
return Version;
|
return Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveInfo::SetTags(std::vector<std::string> tags)
|
void SaveInfo::SetTags(std::list<std::string> tags)
|
||||||
{
|
{
|
||||||
this->tags = tags;
|
std::list<std::string> tagsSorted = tags;
|
||||||
|
tagsSorted.sort();
|
||||||
|
this->tags=tagsSorted;
|
||||||
}
|
}
|
||||||
std::vector<std::string> SaveInfo::GetTags()
|
|
||||||
|
std::list<std::string> SaveInfo::GetTags()
|
||||||
{
|
{
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef SAVE_H
|
#ifndef SAVE_H
|
||||||
#define SAVE_H
|
#define SAVE_H
|
||||||
|
|
||||||
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -26,7 +27,7 @@ public:
|
|||||||
|
|
||||||
SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name);
|
SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name);
|
||||||
|
|
||||||
SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::vector<std::string> tags);
|
SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags);
|
||||||
|
|
||||||
~SaveInfo();
|
~SaveInfo();
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ public:
|
|||||||
|
|
||||||
std::string Description;
|
std::string Description;
|
||||||
|
|
||||||
std::vector<std::string> tags;
|
std::list<std::string> tags;
|
||||||
|
|
||||||
int vote;
|
int vote;
|
||||||
|
|
||||||
@ -68,8 +69,8 @@ public:
|
|||||||
void SetVersion(int version);
|
void SetVersion(int version);
|
||||||
int GetVersion();
|
int GetVersion();
|
||||||
|
|
||||||
void SetTags(std::vector<std::string> tags);
|
void SetTags(std::list<std::string> tags);
|
||||||
std::vector<std::string> GetTags();
|
std::list<std::string> GetTags();
|
||||||
|
|
||||||
GameSave * GetGameSave();
|
GameSave * GetGameSave();
|
||||||
void SetGameSave(GameSave * gameSave);
|
void SetGameSave(GameSave * gameSave);
|
||||||
|
@ -909,14 +909,14 @@ void GameView::NotifySaveChanged(GameModel * sender)
|
|||||||
if(sender->GetSave()->GetID())
|
if(sender->GetSave()->GetID())
|
||||||
{
|
{
|
||||||
std::stringstream tagsStream;
|
std::stringstream tagsStream;
|
||||||
std::vector<string> tags = sender->GetSave()->GetTags();
|
std::list<string> tags = sender->GetSave()->GetTags();
|
||||||
if(tags.size())
|
if(tags.size())
|
||||||
{
|
{
|
||||||
for(int i = 0; i < tags.size(); i++)
|
for(std::list<std::string>::const_iterator iter = tags.begin(), begin = tags.begin(), end = tags.end(); iter != end; iter++)
|
||||||
{
|
{
|
||||||
tagsStream << sender->GetSave()->GetTags()[i];
|
if(iter != begin)
|
||||||
if(i < tags.size()-1)
|
|
||||||
tagsStream << " ";
|
tagsStream << " ";
|
||||||
|
tagsStream << *iter;
|
||||||
}
|
}
|
||||||
tagSimulationButton->SetText(tagsStream.str());
|
tagSimulationButton->SetText(tagsStream.str());
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,10 @@ void TagsModel::RemoveTag(std::string tag)
|
|||||||
{
|
{
|
||||||
if(save)
|
if(save)
|
||||||
{
|
{
|
||||||
std::vector<std::string> * tags = Client::Ref().RemoveTag(save->GetID(), tag);
|
std::list<std::string> * tags = Client::Ref().RemoveTag(save->GetID(), tag);
|
||||||
if(tags)
|
if(tags)
|
||||||
{
|
{
|
||||||
save->SetTags(std::vector<std::string>(*tags));
|
save->SetTags(std::list<std::string>(*tags));
|
||||||
notifyTagsChanged();
|
notifyTagsChanged();
|
||||||
delete tags;
|
delete tags;
|
||||||
}
|
}
|
||||||
@ -43,10 +43,10 @@ void TagsModel::AddTag(std::string tag)
|
|||||||
{
|
{
|
||||||
if(save)
|
if(save)
|
||||||
{
|
{
|
||||||
std::vector<std::string> * tags = Client::Ref().AddTag(save->GetID(), tag);
|
std::list<std::string> * tags = Client::Ref().AddTag(save->GetID(), tag);
|
||||||
if(tags)
|
if(tags)
|
||||||
{
|
{
|
||||||
save->SetTags(std::vector<std::string>(*tags));
|
save->SetTags(std::list<std::string>(*tags));
|
||||||
notifyTagsChanged();
|
notifyTagsChanged();
|
||||||
delete tags;
|
delete tags;
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,11 @@ void TagsView::NotifyTagsChanged(TagsModel * sender)
|
|||||||
|
|
||||||
if(sender->GetSave())
|
if(sender->GetSave())
|
||||||
{
|
{
|
||||||
for(int i = 0; i < sender->GetSave()->GetTags().size(); i++)
|
std::list<std::string> Tags = sender->GetSave()->GetTags();
|
||||||
|
int i = 0;
|
||||||
|
for(std::list<std::string>::const_iterator iter = Tags.begin(), end = Tags.end(); iter != end; iter++)
|
||||||
{
|
{
|
||||||
ui::Label * tempLabel = new ui::Label(ui::Point(35, 35+(16*i)), ui::Point(120, 16), sender->GetSave()->GetTags()[i]);
|
ui::Label * tempLabel = new ui::Label(ui::Point(35, 35+(16*i)), ui::Point(120, 16), *iter);
|
||||||
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
tags.push_back(tempLabel);
|
tags.push_back(tempLabel);
|
||||||
AddComponent(tempLabel);
|
AddComponent(tempLabel);
|
||||||
@ -119,10 +121,11 @@ void TagsView::NotifyTagsChanged(TagsModel * sender)
|
|||||||
tempButton->Appearance.Margin.Top += 2;
|
tempButton->Appearance.Margin.Top += 2;
|
||||||
tempButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
tempButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||||
tempButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
tempButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
tempButton->SetActionCallback(new DeleteTagAction(this, sender->GetSave()->GetTags()[i]));
|
tempButton->SetActionCallback(new DeleteTagAction(this, *iter));
|
||||||
tags.push_back(tempButton);
|
tags.push_back(tempButton);
|
||||||
AddComponent(tempButton);
|
AddComponent(tempButton);
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user