Differentiate between created date / updated date in save preview

still only shows most recent date, this just changes the text
This commit is contained in:
jacob1
2017-06-30 21:21:09 -04:00
parent d0f1024f95
commit 057435baa6
6 changed files with 41 additions and 27 deletions

View File

@@ -1637,7 +1637,8 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
std::string tempUsername = objDocument["Username"].asString(); std::string tempUsername = objDocument["Username"].asString();
std::string tempName = objDocument["Name"].asString(); std::string tempName = objDocument["Name"].asString();
std::string tempDescription = objDocument["Description"].asString(); std::string tempDescription = objDocument["Description"].asString();
int tempDate = objDocument["Date"].asInt(); int tempCreatedDate = objDocument["DateCreated"].asInt();
int tempUpdatedDate = objDocument["Date"].asInt();
bool tempPublished = objDocument["Published"].asBool(); bool tempPublished = objDocument["Published"].asBool();
bool tempFavourite = objDocument["Favourite"].asBool(); bool tempFavourite = objDocument["Favourite"].asBool();
int tempComments = objDocument["Comments"].asInt(); int tempComments = objDocument["Comments"].asInt();
@@ -1649,9 +1650,9 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
for (Json::UInt j = 0; j < tagsArray.size(); j++) for (Json::UInt j = 0; j < tagsArray.size(); j++)
tempTags.push_back(tagsArray[j].asString()); tempTags.push_back(tagsArray[j].asString());
SaveInfo * tempSave = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown, SaveInfo * tempSave = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp,
tempMyScore, tempUsername, tempName, tempDescription, tempScoreDown, tempMyScore, tempUsername, tempName,
tempPublished, tempTags); tempDescription, tempPublished, tempTags);
tempSave->Comments = tempComments; tempSave->Comments = tempComments;
tempSave->Favourite = tempFavourite; tempSave->Favourite = tempFavourite;
tempSave->Views = tempViews; tempSave->Views = tempViews;
@@ -1700,7 +1701,8 @@ RequestBroker::Request * Client::GetSaveAsync(int saveID, int saveDate)
std::string tempUsername = objDocument["Username"].asString(); std::string tempUsername = objDocument["Username"].asString();
std::string tempName = objDocument["Name"].asString(); std::string tempName = objDocument["Name"].asString();
std::string tempDescription = objDocument["Description"].asString(); std::string tempDescription = objDocument["Description"].asString();
int tempDate = objDocument["Date"].asInt(); int tempCreatedDate = objDocument["DateCreated"].asInt();
int tempUpdatedDate = objDocument["Date"].asInt();
bool tempPublished = objDocument["Published"].asBool(); bool tempPublished = objDocument["Published"].asBool();
bool tempFavourite = objDocument["Favourite"].asBool(); bool tempFavourite = objDocument["Favourite"].asBool();
int tempComments = objDocument["Comments"].asInt(); int tempComments = objDocument["Comments"].asInt();
@@ -1712,9 +1714,9 @@ RequestBroker::Request * Client::GetSaveAsync(int saveID, int saveDate)
for (Json::UInt j = 0; j < tagsArray.size(); j++) for (Json::UInt j = 0; j < tagsArray.size(); j++)
tempTags.push_back(tagsArray[j].asString()); tempTags.push_back(tagsArray[j].asString());
SaveInfo * tempSave = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown, SaveInfo * tempSave = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp,
tempMyScore, tempUsername, tempName, tempDescription, tempScoreDown, tempMyScore, tempUsername, tempName,
tempPublished, tempTags); tempDescription, tempPublished, tempTags);
tempSave->Comments = tempComments; tempSave->Comments = tempComments;
tempSave->Favourite = tempFavourite; tempSave->Favourite = tempFavourite;
tempSave->Views = tempViews; tempSave->Views = tempViews;
@@ -1874,14 +1876,15 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string q
for (Json::UInt j = 0; j < savesArray.size(); j++) for (Json::UInt j = 0; j < savesArray.size(); j++)
{ {
int tempID = savesArray[j]["ID"].asInt(); int tempID = savesArray[j]["ID"].asInt();
int tempDate = savesArray[j]["Date"].asInt(); int tempCreatedDate = savesArray[j]["Created"].asInt();
int tempUpdatedDate = savesArray[j]["Updated"].asInt();
int tempScoreUp = savesArray[j]["ScoreUp"].asInt(); int tempScoreUp = savesArray[j]["ScoreUp"].asInt();
int tempScoreDown = savesArray[j]["ScoreDown"].asInt(); int tempScoreDown = savesArray[j]["ScoreDown"].asInt();
std::string tempUsername = savesArray[j]["Username"].asString(); std::string tempUsername = savesArray[j]["Username"].asString();
std::string tempName = savesArray[j]["Name"].asString(); std::string tempName = savesArray[j]["Name"].asString();
int tempVersion = savesArray[j]["Version"].asInt(); int tempVersion = savesArray[j]["Version"].asInt();
bool tempPublished = savesArray[j]["Published"].asBool(); bool tempPublished = savesArray[j]["Published"].asBool();
SaveInfo * tempSaveInfo = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown, tempUsername, tempName); SaveInfo * tempSaveInfo = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp, tempScoreDown, tempUsername, tempName);
tempSaveInfo->Version = tempVersion; tempSaveInfo->Version = tempVersion;
tempSaveInfo->SetPublished(tempPublished); tempSaveInfo->SetPublished(tempPublished);
saveArray->push_back(tempSaveInfo); saveArray->push_back(tempSaveInfo);

View File

@@ -4,7 +4,8 @@
SaveInfo::SaveInfo(SaveInfo & save): SaveInfo::SaveInfo(SaveInfo & save):
id(save.id), id(save.id),
date(save.date), createdDate(save.createdDate),
updatedDate(save.updatedDate),
votesUp(save.votesUp), votesUp(save.votesUp),
votesDown(save.votesDown), votesDown(save.votesDown),
vote(save.vote), vote(save.vote),
@@ -25,9 +26,10 @@ SaveInfo::SaveInfo(SaveInfo & save):
gameSave = new GameSave(*save.gameSave); gameSave = new GameSave(*save.gameSave);
} }
SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name): SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, std::string _userName, std::string _name):
id(_id), id(_id),
date(_date), createdDate(_createdDate),
updatedDate(_updatedDate),
votesUp(_votesUp), votesUp(_votesUp),
votesDown(_votesDown), votesDown(_votesDown),
vote(0), vote(0),
@@ -45,9 +47,10 @@ 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::list<std::string> tags_): SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, 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),
date(date_), createdDate(_createdDate),
updatedDate(_updatedDate),
votesUp(_votesUp), votesUp(_votesUp),
votesDown(_votesDown), votesDown(_votesDown),
vote(_vote), vote(_vote),

View File

@@ -14,7 +14,8 @@ class SaveInfo
private: private:
public: public:
int id; int id;
int date; int createdDate;
int updatedDate;
int votesUp, votesDown; int votesUp, votesDown;
int vote; int vote;
bool Favourite; bool Favourite;
@@ -33,9 +34,9 @@ public:
SaveInfo(SaveInfo & save); SaveInfo(SaveInfo & save);
SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name); SaveInfo(int _id, int _createdDate, int _updatedDate, 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::list<std::string> tags); SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags);
~SaveInfo(); ~SaveInfo();

View File

@@ -1393,7 +1393,7 @@ void GameController::OpenSaveWindow()
} }
else else
{ {
SaveInfo tempSave(0, 0, 0, 0, gameModel->GetUser().Username, ""); SaveInfo tempSave(0, 0, 0, 0, 0, gameModel->GetUser().Username, "");
tempSave.SetGameSave(gameSave); tempSave.SetGameSave(gameSave);
new ServerSaveActivity(tempSave, new SaveUploadedCallback(this)); new ServerSaveActivity(tempSave, new SaveUploadedCallback(this));
} }
@@ -1440,7 +1440,7 @@ void GameController::SaveAsCurrent()
} }
else else
{ {
SaveInfo tempSave(0, 0, 0, 0, gameModel->GetUser().Username, ""); SaveInfo tempSave(0, 0, 0, 0, 0, gameModel->GetUser().Username, "");
tempSave.SetGameSave(gameSave); tempSave.SetGameSave(gameSave);
new ServerSaveActivity(tempSave, true, new SaveUploadedCallback(this)); new ServerSaveActivity(tempSave, true, new SaveUploadedCallback(this));
} }

View File

@@ -213,7 +213,8 @@ bool PreviewModel::ParseSaveInfo(char * saveInfoResponse)
std::string tempUsername = objDocument["Username"].asString(); std::string tempUsername = objDocument["Username"].asString();
std::string tempName = objDocument["Name"].asString(); std::string tempName = objDocument["Name"].asString();
std::string tempDescription = objDocument["Description"].asString(); std::string tempDescription = objDocument["Description"].asString();
int tempDate = objDocument["Date"].asInt(); int tempCreatedDate = objDocument["DateCreated"].asInt();
int tempUpdatedDate = objDocument["Date"].asInt();
bool tempPublished = objDocument["Published"].asBool(); bool tempPublished = objDocument["Published"].asBool();
bool tempFavourite = objDocument["Favourite"].asBool(); bool tempFavourite = objDocument["Favourite"].asBool();
int tempComments = objDocument["Comments"].asInt(); int tempComments = objDocument["Comments"].asInt();
@@ -225,9 +226,9 @@ bool PreviewModel::ParseSaveInfo(char * saveInfoResponse)
for (Json::UInt j = 0; j < tagsArray.size(); j++) for (Json::UInt j = 0; j < tagsArray.size(); j++)
tempTags.push_back(tagsArray[j].asString()); tempTags.push_back(tagsArray[j].asString());
saveInfo = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown, saveInfo = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp,
tempMyScore, tempUsername, tempName, tempDescription, tempScoreDown, tempMyScore, tempUsername, tempName,
tempPublished, tempTags); tempDescription, tempPublished, tempTags);
saveInfo->Comments = tempComments; saveInfo->Comments = tempComments;
saveInfo->Favourite = tempFavourite; saveInfo->Favourite = tempFavourite;
saveInfo->Views = tempViews; saveInfo->Views = tempViews;

View File

@@ -497,13 +497,19 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
votesUp = save->votesUp; votesUp = save->votesUp;
votesDown = save->votesDown; votesDown = save->votesDown;
saveNameLabel->SetText(save->name); saveNameLabel->SetText(save->name);
if(showAvatars) { std::string dateType;
if (save->updatedDate == save->createdDate)
dateType = "Created:";
else
dateType = "Updated:";
if (showAvatars)
{
avatarButton->SetUsername(save->userName); avatarButton->SetUsername(save->userName);
authorDateLabel->SetText("\bw" + save->userName + " \bgDate:\bw " + format::UnixtimeToDateMini(save->date)); authorDateLabel->SetText("\bw" + save->userName + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate));
} }
else else
{ {
authorDateLabel->SetText("\bgAuthor:\bw " + save->userName + " \bgDate:\bw " + format::UnixtimeToDateMini(save->date)); authorDateLabel->SetText("\bgAuthor:\bw " + save->userName + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate));
} }
if (Client::Ref().GetAuthUser().ID && save->userName == Client::Ref().GetAuthUser().Username) if (Client::Ref().GetAuthUser().ID && save->userName == Client::Ref().GetAuthUser().Username)
userIsAuthor = true; userIsAuthor = true;