diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 74090d50e..89e0a9834 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -701,7 +701,7 @@ RequestStatus Client::ExecVote(int saveID, int direction) ByteString userIDText = ByteString::Build(authUser.UserID); data = http::Request::SimpleAuth(SCHEME SERVER "/Vote.api", &dataStatus, userIDText, authUser.SessionID, { { "ID", saveIDText }, - { "Action", direction == 1 ? "Up" : "Down" }, + { "Action", direction ? (direction == 1 ? "Up" : "Down") : "Reset" }, }); } else diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index fd942b1e8..c37087b16 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1467,7 +1467,7 @@ void GameController::FrameStep() void GameController::Vote(int direction) { - if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetSave()->GetID() && gameModel->GetSave()->GetVote()==0) + if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetSave()->GetID()) { try { diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 0808050e5..8ba4ccacd 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -272,7 +272,6 @@ GameView::GameView(): upVoteButton->Appearance.Margin.Top+=2; upVoteButton->Appearance.Margin.Left+=2; currentX+=38; - upVoteButton->SetActionCallback({ [this] { c->Vote(1); } }); AddComponent(upVoteButton); downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Dislike this save"); @@ -280,7 +279,6 @@ GameView::GameView(): downVoteButton->Appearance.Margin.Bottom+=2; downVoteButton->Appearance.Margin.Left+=2; currentX+=16; - downVoteButton->SetActionCallback({ [this] { c->Vote(-1); } }); AddComponent(downVoteButton); tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(227, 15), "[no tags set]", "Add simulation tags"); @@ -803,17 +801,29 @@ void GameView::NotifySaveChanged(GameModel * sender) else saveSimulationButton->SetShowSplit(false); reloadButton->Enabled = true; - upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==0); + upVoteButton->Enabled = sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetUser().Username != sender->GetSave()->GetUserName(); if(sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==1) - upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 108, 10, 255)); + { + upVoteButton->Appearance.BackgroundHover = (ui::Colour(20, 128, 30, 255)); + upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 108, 10, 255)); + } else - upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); + { + upVoteButton->Appearance.BackgroundHover = (ui::Colour(20, 20, 20)); + upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0)); + } downVoteButton->Enabled = upVoteButton->Enabled; if (sender->GetSave()->GetID() && sender->GetUser().UserID && sender->GetSave()->GetVote()==-1) - downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(108, 0, 10, 255)); + { + downVoteButton->Appearance.BackgroundHover = (ui::Colour(128, 20, 30, 255)); + downVoteButton->Appearance.BackgroundInactive = (ui::Colour(108, 0, 10, 255)); + } else - downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); + { + downVoteButton->Appearance.BackgroundHover = (ui::Colour(20, 20, 20)); + downVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0)); + } if (sender->GetUser().UserID) { @@ -826,6 +836,16 @@ void GameView::NotifySaveChanged(GameModel * sender) downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100); } + if (sender->GetSave()->GetVote() == 1) + upVoteButton->SetActionCallback({ [this] { c->Vote(0); } }); + else + upVoteButton->SetActionCallback({ [this] { c->Vote(1); } }); + + if (sender->GetSave()->GetVote() == -1) + downVoteButton->SetActionCallback({ [this] { c->Vote(0) ;} }); + else + downVoteButton->SetActionCallback({ [this] { c->Vote(-1) ;} }); + tagSimulationButton->Enabled = sender->GetSave()->GetID(); if (sender->GetSave()->GetID()) {