diff --git a/src/client/Client.cpp b/src/client/Client.cpp index f630fbec2b..13adeafdd0 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; @@ -1874,14 +1876,15 @@ std::vector * 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); diff --git a/src/client/SaveInfo.cpp b/src/client/SaveInfo.cpp index f1a1668714..97ba494648 100644 --- a/src/client/SaveInfo.cpp +++ b/src/client/SaveInfo.cpp @@ -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), @@ -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), @@ -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 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 tags_): id(_id), - date(date_), + createdDate(_createdDate), + updatedDate(_updatedDate), votesUp(_votesUp), votesDown(_votesDown), vote(_vote), diff --git a/src/client/SaveInfo.h b/src/client/SaveInfo.h index e674bb122b..e366858c8e 100644 --- a/src/client/SaveInfo.h +++ b/src/client/SaveInfo.h @@ -14,7 +14,8 @@ class SaveInfo private: public: int id; - int date; + int createdDate; + int updatedDate; int votesUp, votesDown; int vote; bool Favourite; @@ -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 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 tags); ~SaveInfo(); diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 5548061ac0..5d2357cbcd 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -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)); } @@ -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)); } diff --git a/src/gui/preview/PreviewModel.cpp b/src/gui/preview/PreviewModel.cpp index dae6050ad9..e68a844453 100644 --- a/src/gui/preview/PreviewModel.cpp +++ b/src/gui/preview/PreviewModel.cpp @@ -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(); @@ -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; diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index b0f7bfc729..b9525956dc 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -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;