Skip to content

Commit

Permalink
Differentiate between created date / updated date in save preview
Browse files Browse the repository at this point in the history
still only shows most recent date, this just changes the text
  • Loading branch information
jacob1 committed Jul 1, 2017
1 parent d0f1024 commit 057435b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
23 changes: 13 additions & 10 deletions src/client/Client.cpp
Expand Up @@ -1637,7 +1637,8 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
std::string tempUsername = objDocument["Username"].asString();
std::string tempName = objDocument["Name"].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 tempFavourite = objDocument["Favourite"].asBool();
int tempComments = objDocument["Comments"].asInt();
Expand All @@ -1649,9 +1650,9 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
for (Json::UInt j = 0; j < tagsArray.size(); j++)
tempTags.push_back(tagsArray[j].asString());

SaveInfo * tempSave = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown,
tempMyScore, tempUsername, tempName, tempDescription,
tempPublished, tempTags);
SaveInfo * tempSave = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp,
tempScoreDown, tempMyScore, tempUsername, tempName,
tempDescription, tempPublished, tempTags);
tempSave->Comments = tempComments;
tempSave->Favourite = tempFavourite;
tempSave->Views = tempViews;
Expand Down Expand Up @@ -1700,7 +1701,8 @@ RequestBroker::Request * Client::GetSaveAsync(int saveID, int saveDate)
std::string tempUsername = objDocument["Username"].asString();
std::string tempName = objDocument["Name"].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 tempFavourite = objDocument["Favourite"].asBool();
int tempComments = objDocument["Comments"].asInt();
Expand All @@ -1712,9 +1714,9 @@ RequestBroker::Request * Client::GetSaveAsync(int saveID, int saveDate)
for (Json::UInt j = 0; j < tagsArray.size(); j++)
tempTags.push_back(tagsArray[j].asString());

SaveInfo * tempSave = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown,
tempMyScore, tempUsername, tempName, tempDescription,
tempPublished, tempTags);
SaveInfo * tempSave = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp,
tempScoreDown, tempMyScore, tempUsername, tempName,
tempDescription, tempPublished, tempTags);
tempSave->Comments = tempComments;
tempSave->Favourite = tempFavourite;
tempSave->Views = tempViews;
Expand Down Expand Up @@ -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++)
{
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 tempScoreDown = savesArray[j]["ScoreDown"].asInt();
std::string tempUsername = savesArray[j]["Username"].asString();
std::string tempName = savesArray[j]["Name"].asString();
int tempVersion = savesArray[j]["Version"].asInt();
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->SetPublished(tempPublished);
saveArray->push_back(tempSaveInfo);
Expand Down
13 changes: 8 additions & 5 deletions src/client/SaveInfo.cpp
Expand Up @@ -4,7 +4,8 @@

SaveInfo::SaveInfo(SaveInfo & save):
id(save.id),
date(save.date),
createdDate(save.createdDate),
updatedDate(save.updatedDate),
votesUp(save.votesUp),
votesDown(save.votesDown),
vote(save.vote),
Expand All @@ -25,9 +26,10 @@ SaveInfo::SaveInfo(SaveInfo & save):
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),
date(_date),
createdDate(_createdDate),
updatedDate(_updatedDate),
votesUp(_votesUp),
votesDown(_votesDown),
vote(0),
Expand All @@ -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),
date(date_),
createdDate(_createdDate),
updatedDate(_updatedDate),
votesUp(_votesUp),
votesDown(_votesDown),
vote(_vote),
Expand Down
7 changes: 4 additions & 3 deletions src/client/SaveInfo.h
Expand Up @@ -14,7 +14,8 @@ class SaveInfo
private:
public:
int id;
int date;
int createdDate;
int updatedDate;
int votesUp, votesDown;
int vote;
bool Favourite;
Expand All @@ -33,9 +34,9 @@ class SaveInfo

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();

Expand Down
4 changes: 2 additions & 2 deletions src/gui/game/GameController.cpp
Expand Up @@ -1393,7 +1393,7 @@ void GameController::OpenSaveWindow()
}
else
{
SaveInfo tempSave(0, 0, 0, 0, gameModel->GetUser().Username, "");
SaveInfo tempSave(0, 0, 0, 0, 0, gameModel->GetUser().Username, "");
tempSave.SetGameSave(gameSave);
new ServerSaveActivity(tempSave, new SaveUploadedCallback(this));
}
Expand Down Expand Up @@ -1440,7 +1440,7 @@ void GameController::SaveAsCurrent()
}
else
{
SaveInfo tempSave(0, 0, 0, 0, gameModel->GetUser().Username, "");
SaveInfo tempSave(0, 0, 0, 0, 0, gameModel->GetUser().Username, "");
tempSave.SetGameSave(gameSave);
new ServerSaveActivity(tempSave, true, new SaveUploadedCallback(this));
}
Expand Down
9 changes: 5 additions & 4 deletions src/gui/preview/PreviewModel.cpp
Expand Up @@ -213,7 +213,8 @@ bool PreviewModel::ParseSaveInfo(char * saveInfoResponse)
std::string tempUsername = objDocument["Username"].asString();
std::string tempName = objDocument["Name"].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 tempFavourite = objDocument["Favourite"].asBool();
int tempComments = objDocument["Comments"].asInt();
Expand All @@ -225,9 +226,9 @@ bool PreviewModel::ParseSaveInfo(char * saveInfoResponse)
for (Json::UInt j = 0; j < tagsArray.size(); j++)
tempTags.push_back(tagsArray[j].asString());

saveInfo = new SaveInfo(tempID, tempDate, tempScoreUp, tempScoreDown,
tempMyScore, tempUsername, tempName, tempDescription,
tempPublished, tempTags);
saveInfo = new SaveInfo(tempID, tempCreatedDate, tempUpdatedDate, tempScoreUp,
tempScoreDown, tempMyScore, tempUsername, tempName,
tempDescription, tempPublished, tempTags);
saveInfo->Comments = tempComments;
saveInfo->Favourite = tempFavourite;
saveInfo->Views = tempViews;
Expand Down
12 changes: 9 additions & 3 deletions src/gui/preview/PreviewView.cpp
Expand Up @@ -497,13 +497,19 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
votesUp = save->votesUp;
votesDown = save->votesDown;
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);
authorDateLabel->SetText("\bw" + save->userName + " \bgDate:\bw " + format::UnixtimeToDateMini(save->date));
authorDateLabel->SetText("\bw" + save->userName + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate));
}
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)
userIsAuthor = true;
Expand Down

0 comments on commit 057435b

Please sign in to comment.